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

Fixed submission:
import sys
import collections
#import cython
def get_keys(d, val):
    return [k for k, v in d.items() if v == val]
    
def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    N, K  = map(int,read().split())
    A = list(map(int,read().split()))
    
    g = collections.defaultdict(int)
    for i, val in enumerate(A):
        g[i + 1] = val
        
    v = collections.defaultdict(int)
    cnt = 0
    cur = 1
    p = 0
    mp = 0
    while True:
        if v[cur] > 0 or cnt > 2*10**5:
            p = cnt - v[cur]
            mp = v[cur]
            break
        v[cur] = cnt
        cnt += 1
        cur = g[cur]
    
    print(get_keys(v, (K-mp)%p + mp)[0] if K >= mp else get_keys(v, K)[0])


 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def get_keys(d, val):
    return [k for k, v in d.items() if v == val]
    
def main():
    read = lambda: sys.stdin.readline().rstrip()
    
    N, K  = map(int,read().split())
    A = list(map(int,read().split()))
    
    g = collections.defaultdict(int)
    for i, val in enumerate(A):
        g[i + 1] = val
        
    v = collections.defaultdict(int)
    cnt = 0
    cur = 1
    p = 0
    mp = 0
    while True:
        if v[cur] > 0:
            p = cnt - v[cur]
            mp = v[cur]
            break
        v[cur] = cnt
        cnt += 1
        cur = g[cur]
    
    print(get_keys(v, (K-mp)%p + mp)[0] if K >= mp else get_keys(v, K)[0])


 
if __name__ == "__main__":
    main()
Problem p02783 (python)

Fixed submission:
h, a = map(int, input().split())
print(h//a+1 if h%a != 0 else h//a)

Buggy submission (verdict: Runtime Error):
h, a = map(int, input())
print(h//a+1 if h%a != 0 else h//a)
Problem p02811 (python)

Fixed submission:
K, X = map(int,input().split())
print("Yes" if 500*K >= X else "No")

Buggy submission (verdict: Runtime Error):
K, X = map(int,input().split())
print("Yes" if 500*K >= X else "No")
Problem p02817 (python)

Fixed submission:
A, B = input().split()
print(B+A)

Buggy submission (verdict: Runtime Error):
T = input("")
S = input("")
print("T"+"S")

Buggy submission (verdict: Runtime Error):
A, B = input().strip()
print(B+A)

Buggy submission (verdict: Runtime Error):
A, B = input().strip()
print(A+B)

Buggy submission (verdict: Runtime Error):
def isPrime(n):
    if n == 1: return False
 
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
  
num = input()
 
res = True
ans = 0
if num > 2 and num%2 == 0:
  num += 1
while(res):
  if isPrime(num):
    print(num)
    break
  num += 2
Problem p02866 (python)

Fixed submission:
import sys
read = lambda: sys.stdin.readline().rstrip()

def counting_tree(N, D):
    tot = 1
    
    # cnt = collections.Counter(D)
    cnt = [0]*N
    for i in D:
        cnt[i]+=1

    for i in D[1:]:
        tot = tot * cnt[i-1]%998244353

    return tot if D[0]==0 else 0

def main():
    
    N0 = int(read())
    D0 = tuple(map(int, read().split()))

    res = counting_tree(N0, D0)

    print(res)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = lambda: sys.stdin.readline().rstrip()

def counting_tree(N, D):
    tot = 1
    cnt = [0]*N
    # cnt = collections.Counter(D)
    for i in D:
        cnt[i]+=1
        
    for i in D[1:]:
        tot = tot*cnt[i-1]%998244353

    return tot if D[0]!=0 else 0

def main():
    
    N0 = int(read().split())
    D0 = tuple(map(int, read().split()))

    res = counting_tree(N0, D0)

    print(res)

if __name__ == "__main__":
    main()
Problem p03069 (python)

Fixed submission:
import sys
input = sys.stdin.readline
 
 
def main():
    N = int(input())
    S = input().strip()
    ans = 0
    x = 0
    for c in S:
        if c == "#":
            x += 1
        else:
            if x > 0:
                ans += 1
                x = max(x-1, 0)
    print(ans)
 
 
if __name__ == '__main__':
    main()

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

black_right, min_val = 0, 2000001
white_left = s.count('.')
ans = []

for moji in s:
    if moji == '.':
        white_left -=1
    else:
        black_right += 1
    ans.append[white_left+black_right]
    #min_val = min(min_val, white_left+black_right)

print(min(ans))

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

black_right, min_val = 0, 2000001
white_left = s.count('.')

for moji in range(s):
    if moji == '.':
        white_left -=1
    else:
        black_right += 1
    min_val = min(min_val, white_left+black_right)

print(min_val)
Problem p03160 (python)

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

INF = 10 ** 20

dp = [INF]*(n)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
 
for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
 
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import sys
read = lambda: sys.stdin.readline().rstrip()
 
N,W=map(int,read().split())
 
def solve_knapsack(capacity):
    # basic checks
 
    dp = [0]*(capacity + 1)
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit
 
    for i in range(0, N):
        weights,profits = map(int,read().split())
        for c in range(capacity, weights-1, -1):
            tmp = profits + dp[c - weights]
            if tmp > dp[c]: dp[c] = tmp
 
    # maximum profit will be at the bottom-right corner.
    return dp[capacity]
  
def main():
 
    res = solve_knapsack(W)
 
    print(res)
if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
def solve_knapsack(profits, weights, capacity):
    # basic checks
    n = len(profits)

    dp = [[0 for x in range(capacity+1)] for y in range(n)]
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit
    for i in range(0, n):
        dp[i][0] = 0
    for c in range(0, capacity+1):
        if weights[0] <= c: dp[0][c] = profits[0]
    for i in range(1, n):
        for c in range(1, capacity+1):
            if weights[i] <= c:
                dp[i][c] = max(profits[i] + dp[i - 1][c - weights[i]], dp[i - 1][c])
            else: dp[i][c]  = dp[i - 1][c]

    # maximum profit will be at the bottom-right corner.
    return dp[n - 1][capacity]
  
def main():

    for i in range(N):
        weights[i],profits[i] = map(int,input().split())
    res = solve_knapsack(profits, weights, capacity)
 
    print(res)
if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
import sys
read = lambda: sys.stdin.readline().rstrip()
 
def main():
    INF = 10 ** 20

    n,k = map(int,input().split())
    h = tuple(map(int,read().split()))
    dp = [INF]*(n+1)
    dp[0] = 0

    for step in range(1, k+1):
        for i in range(step,n):
            dp[i] = min(dp[i], dp[i-step]+abs(h[i]-h[i-step]))

    print(dp[n-1])
if __name__ == "__main__":
    main()

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

INF = 10 ** 20

dp = [INF]*(n+1)
dp[0] = dp[1] = 0
dp[2] = h[1]-h[0]
 
coin_list = list(map(int,input().split()))
 
for i in range(3,n+1):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
 
print(dp[n])
Problem p03161 (python)

Fixed submission:
N,K = map(int,input().split())
h = list(map(int,input().split()))
INF = 10**10
 
dp = [INF]*N
dp[0] = 0
 
for i,hi in enumerate(h):
    if i == 0:
        continue
    s = i-K if i-K >= 0 else 0
    dp[i] = min([dpk + abs(hi-hk) for dpk,hk in zip(dp[s:i],h[s:i])])
 
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
read = lambda: sys.stdin.readline().rstrip()
 
def main():
    INF = 10 ** 20
 
    n,k = map(int,input().split())
    height = tuple(map(int,read().split()))
    dp = [INF]*(n+1)
    dp[0] = 0
 
    
    for step in range(1, k + 1):
    	for target in range(n, 0, -1):
            if target-step >= 0: dp[target] = min(dp[target], dp[target - step] + abs(height[target] - height[target - step]))
 
    print(dp[n-1])
 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    INF = 10 ** 20
 
    n,k = map(int,input().split())
    height = tuple(map(int,read().split()))
    dp = [INF]*(n+1)
    dp[0] = 0
 
    for target in range(1, n):
        for step in range(1, k + 1):
            if target-step >= 0: dp[target] = min(dp[target], dp[target - step] + abs(height[target] - height[target - step]))
 
    print(dp[n-1])

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = lambda: sys.stdin.readline().rstrip()

def main():

	A0 = tuple(map(int, read().split()))

  	INF = 10 ** 20

    n,k = map(int,input().split())
    h = tuple(map(int,read().split()))
    dp = [INF]*(n+1)
    dp[0] = 0

    for step in range(1, k+1):
        for i in range(step,n):
            dp[i] = min(dp[i], dp[i-step]+abs(h[i]-h[i-step]))
 
	print(dp[n-1])

 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
INF = 10 ** 20
 
n,k = map(int,input().split())
height = list(map(int,input().split()))
dp = [INF]*(n+1)
dp[0] = 0
 
for step in range(1, k+1):
    for i in range(step,n):
        dp[i] = min(dp[i], dp[i-step]+abs(h[i]-h[i-step]))
 
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
"""

"""
INF = 10 ** 20

N,K = map(int,input().split())
h = list(map(int,input().split()))
INF = 10**10
 
dp = [INF]*N
dp[0] = 0
 
for i,hi in enumerate(h):
    if i == 0:
        continue
    s = i-K if i-K >= 0 else 0
    dp[i] = min([dpk + abs(hi-hk) for dpk,hk in zip(dp[i-K:i],h[i-K:i])])
 
print(dp[-1])
Problem p03163 (python)

Fixed submission:
def main():
  n, w = [int(e) for e in input().split()]
  t = [-1 for i in range(w + 1)]
  t[w] = 0
  for _ in range(n):
    nw, nv = [int(e) for e in input().split()]
    for i in range(nw, w + 1):
      if t[i] == -1:
        continue
      if t[i - nw] < t[i] + nv:
        t[i - nw] = t[i] + nv
  print(max(t))
main()

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
dp = [0]*(capacity + 1)

def solve_knapsack(capacity):
    # basic checks
 
    
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit

    for i in range(0, N):
        weights,profits = map(int,input().split())
        for c in range(capacity, weights-1, -1):
            tmp = profits + dp[c - weights]
            if tmp > dp[c]: dp[c] = tmp
 
    # maximum profit will be at the bottom-right corner.
    return dp[capacity]
  
def main():
 
    res = solve_knapsack(W)
 
    print(res)
if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline


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

def solve_knapsack(capacity):
    # basic checks
    n = len(profits)
 
    dp = [0]*(capacity + 1)
    # populate the capacity = 0 columns, with '0' capacity we have '0' profit

    for i in range(0, n):
        weights,profits = map(int,input().split())
        for c in range(capacity, weights-1, -1):
            tmp = profits + dp[c - weights
            if tmp > dp[c]: dp[c] = tmp
 
    # maximum profit will be at the bottom-right corner.
    return dp[capacity]
  
def main():
 
    res = solve_knapsack(W)
 
    print(res)
if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
def solve_knapsack(profits, weights, capacity):
  # create a two dimensional array for Memoization, each element is initialized to '-1'
	dp = [[-1 for x in range(capacity+1)] for y in range(len(profits))]
    return knapsack_recursive(dp, profits, weights, capacity, 0)


def knapsack_recursive(dp, profits, weights, capacity, currentIndex):

  # base checks
    if capacity <= 0 or currentIndex >= len(profits): return 0

  # if we have already solved a similar problem, return the result from memory
    if dp[currentIndex][capacity] != -1: return dp[currentIndex][capacity]

  # recursive call after choosing the element at the currentIndex
  # if the weight of the element at currentIndex exceeds the capacity, we
  # shouldn't process this
    profit1 = 0
    if weights[currentIndex] <= capacity:
        profit1 = profits[currentIndex] + knapsack_recursive(dp, profits, weights, capacity - weights[currentIndex], currentIndex + 1)

  # recursive call after excluding the element at the currentIndex
    profit2 = knapsack_recursive(dp, profits, weights, capacity, currentIndex + 1)

    dp[currentIndex][capacity] = max(profit1, profit2)
    return dp[currentIndex][capacity]
  
def main():
    N,W=map(int,input().split())
    w,v=map(int,input().split())
    res = solve_knapsack(v, w, W)

    print(res)
if __name__ == "__main__":
	main()
Problem p03363 (python)

Fixed submission:
import collections
def subarraySum(nums, k):
    count = total = 0
    cache = collections.defaultdict(int)
    cache[0] = 1
    for num in nums:
        total += num
        count += cache[total - k]
        cache[total] += 1
    return count
A = input()
nums = list(map(int,input().split()))
k = 0
print(subarraySum(nums, 0))

Buggy submission (verdict: Runtime Error):
def subarraySum(nums, k):
  count = total = 0
  cache = collections.defaultdict(int)
  cache[0] = 1
  for num in nums:
    total += num
    count += cache[total - k]
    cache[total] += 1
    return count
A = input()
nums = list(map(int,input().split()))
k = 0
print(subarraySum(nums, 0))
Problem p03369 (python)

Fixed submission:
print(input().count('o')*100+700)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
a = [int(input()) for i in range(N)]
print((X-sum(a))/min(a)+N)
Problem p03377 (python)

Fixed submission:
A, B, X = map(int, input().split())
print("YES" if A<=X<=A+B else "NO")

Buggy submission (verdict: Runtime Error):
A, B, X = map(int, raw_input().split())
print("YES" if A<=X<=A+B else "NO")
Problem p03378 (python)

Fixed submission:
n,m,x=map(int,input().split())
Al=list(map(int,input().split()))
A = sum(i>x for i in Al)
print(min(A, m-A))

Buggy submission (verdict: Runtime Error):
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

def cmb(n,r):
    from operator import mul
    from functools import reduce
    
    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

class Solution(object):
    def binomial_coefficients(self, n, A):

        num_max = max(A)
        min_val = 1000000001
        num_min = 0

        for i in range(n):
            if abs(A[i]-num_max/2) < min_val:
                min_val = A[i]-num_max/2
                num_min = A[i]

        return num_max, num_min

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()
Problem p03379 (python)

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
X0 = sorted(X)
for i in range (N):
    if X[i] > X0[(N-1)//2]:
        print(X0[(N-1)//2])
    else:
        print(X0[int(N/2)])

Buggy submission (verdict: Runtime Error):
N = input()
X = sorted(list(map(int, input().split())))
for i in range (N):
    if i > (N+1)/2:
        print(X[N/2])
    else:
        print(X[N/2-1])
Problem p03399 (python)

Fixed submission:
a = [int(input()) for i in range(4)]
print(min(a[0], a[1])+min(a[2], a[3]))

Buggy submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]
print(min(a[0], a[1])+min(a[2], a[3]))
Problem p03408 (python)

Fixed submission:
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

s1 = list(set(s))
a = [0 for i in range(101)]
for i in range (len(s1)):
    for j in range (N):
        if s1[i] == s[j]:
            a[i]+=1
for i in range (len(s1)):
    for j in range (M):
        if s1[i] == t[j]:
            a[i]-=1
print(max(a))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]
M = int(input())
t = [int(input()) for i in range(M)]

s1 = list(set(s))
a = []
for i in range (len(s1)):
    for j in range (N):
        if s1[i] == s[j]:
            a[i]+=1
for i in range (len(s1)):
    for j in range (M):
        if s1[i] == t[j]:
            a[i]-=1
print(max(a))
Problem p03416 (python)

Fixed submission:
A, B = map(int, input().split())
cnt = 0
for i in range (A, B+1):
    if str(i) == str(i)[::-1]:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]
M = int(input())
t = [int(input()) for i in range(M)]

s1 = list(set(s))
a = []
for i in range (len(s1)):
    for j in range (N):
        if s1[i] == s[j]:
            a[i]+=1
for i in range (len(s1)):
    for j in range (M):
        if s1[i] == t[j]:
            a[i]-=1
print(max(a))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [int(input()) for i in range(N)]
M = int(input())
t = [int(input()) for i in range(M)]

s1 = list(set(s))
a = []
for i in range len(s1):
    for j in range (N):
    if s1[i] == s[j]:
        a[i]+=1
for i in range len(s1):
    for j in range (M):
    if s1[i] == t[j]:
        a[i]-=1
print(max(a))
Problem p03424 (python)

Fixed submission:
N = int(input())
s = list(map(str, input().split()))
print(["Four", "Three"][len(set(s))==3])

Buggy submission (verdict: Runtime Error):
N = int(input())
s = list(map(input().split()))
print(len(set(s)))
Problem p03433 (python)

Fixed submission:
print(["No", "Yes"][int(input())%500 <= int(input())])

Buggy submission (verdict: Runtime Error):
print(["No", "Yes"][input()%500 <= input()])
Problem p03447 (python)

Fixed submission:
print((int(input())-int(input()))%int(input()))

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
n=0
for i in range(A+1):
    for j in range(B+1):
        if 0 <= (X-500*i-100*j)//50 <= C:
            n+=1
print(n)
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
print(['Even','Odd'][a*b%2==1])

Buggy submission (verdict: Runtime Error):
result = 'Yes'
 
N = int(input())
for i in range(N):
    t,x,y = map(int,input().split())
    if t < (x+y) or t % 2 != ((x+y) % 2):
        result = 'No'
 
print(result)

Buggy submission (verdict: Runtime Error):
print(["Odd", "Even"][int(input())*int(input())%2 == 0]
Problem p03473 (python)

Fixed submission:
print(48-int(input()))

Buggy submission (verdict: Runtime Error):
print(int(input()-24)
Problem p03477 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
print(["Balanced","Left","Right"][a+b>c+d or-(a+b<c+d)])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print((a+b+1)//2)
Problem p03485 (python)

Fixed submission:
a, b = map(int, input().split())
print((a + b + 1) // 2)

Buggy submission (verdict: Runtime Error):
print((int(input())+int(input())+1)//2)

Buggy submission (verdict: Runtime Error):
print(int((int(input())+int(input())+1)/2))

Buggy submission (verdict: Runtime Error):
print(int((int(input())+int(input()))/2))

Buggy submission (verdict: Runtime Error):
print(int((int(input())+int(input())/2))
Problem p03486 (python)

Fixed submission:
print(["No", "Yes"][sorted(input())<sorted(input())[::-1]])

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
print(["No", "Yes"][s.sort()<t.sort()[::-1]])
Problem p03487 (python)

Fixed submission:
from collections import Counter
N = int(input())
cnt = Counter(map(int, input().split()))
print(sum(v - k if v >= k else v for k, v in cnt.items()))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
b = [0 for i in range (10000000)]
for i in range (N):
    b[a[i]] += 1
tot = 0
for i in range (1, 10000000):
    if  0 < b[i] < i:
        tot += b[i]
    elif b[i] > i:
        tot += b[i]-i
print(tot)
Problem p03549 (python)

Fixed submission:
N,M=map(int,input().split())
print((1900*M+100*(N-M))*(2**M))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
print((1900*M+100*(N-M))*(2**M)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
print((1900*M+100*(N-M))*2**M)
Problem p03555 (python)

Fixed submission:
a = input()
b = input()
print(["NO", "YES"][a[0]==b[2] and a[1]==b[1] and a[2]==b[0]])

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
print(["NO", "YES"][a[0]=b[2] and a[1]=b[1] and a[2]=b[0]])
Problem p03565 (python)

Fixed submission:
S = input()
T = input()

moji = []

for i in range(len(S)):
    j = 0
    cnt = 0
    
    while j < len(T) and i+len(T)-1 < len(S):
        if S[i+j] == T[j] or S[i+j] == '?':
            cnt += 1

        else:
            break
        j += 1
    
    if cnt == len(T):
        moji0 = ''
        if i == 0: moji0 = T+S[i+len(T):len(S)]
        elif i+len(T) > len(S)-1: 
            moji0 = S[0:i]+T
        else:
            moji0 = S[0:i]+T+S[i+len(T):len(S)]

        
        moji1 = moji0.replace('?', 'a')
        moji.append(moji1)

print(min(moji) if moji != [] else "UNRESTORABLE")

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

moji = []

for i in range(len(S)):
    j = 0
    cnt = 0
    

    while j < len(T) and i+len(T)-1 < len(S):
        if S[i+j] == T[j] or S[i+j] == '?':
            cnt += 1

        else:
            break
        j += 1
    
    if cnt == len(T):
        moji0 = ''
        if i == 0: moji0 = T+S[i+len(T):len(S)]
        elif i+len(T) > len(S)-1: 
            moji0 = S[0:i]+T
        else:
            moji0 = S[0:i]+T+S[i+len(T):len(S)]

        
        moji1 = moji0.replace('?', 'a')
\
        moji.append(moji1)

    
print(min(moji) if moji != [] else "UNRESTORABLE")

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

moji = []

for i in range(len(S)):
    j = 0
    cnt = 0
    

    while j < len(T) and i+len(T)-1 < len(S):
        if S[i+j] == T[j] or S[i+j] == '?':
            cnt += 1

        else:
            break
        j += 1
    
    if cnt == len(T):
        moji0 = ''
        if i == 0: moji0 = T+S[i+len(T):len(S)]
        elif i+len(T) > len(S)-1: 
            moji0 = S[0:i]+T
        else:
            moji0 = S[0:i]+T+S[i+len(T):len(S)]

        
        moji1 = moji0.replace('?', 'a')
\
        moji.append(moji1)

    
print(min(moji))

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

for i in range(len(S)):
    j = 0
    cnt = 0
    moji = []

    while j < len(T) and i+len(T)-1 < len(S):
        if S[i+j] == T[j] or S[i+j] == '?':
            cnt += 1
    if cnt == len(T):
        moji0 = S[0:i]+T+S[i+len(T)]
        moji1 = moji0.replace('?', 'a')
        moji.append(moji1)

    
print(min(moji))

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

for i in range(len(S)):
    j = 0
    cnt = 0
    moji = []

    while j < len(T) and i+len(T)-1 < len(S):
        if S[i+j] == T[j] or S[i+j] == '?':
            cnt += 1
    if cnt == len(T):
        moji0 = S[0:i]+T+S[i+len(T)]
        moji1 = moji0.replace('?', 'a')
        moji.append(moji1)

    
print(min(moji))
Problem p03605 (python)

Fixed submission:
a = int(input())
print(["No", "Yes"][a//10 == 9 or a%10 == 9])

Buggy submission (verdict: Runtime Error):
a = int(input())
print(["No", "Yes"][a//10 == 9 or a%10 == 9]
Problem p03609 (python)

Fixed submission:
a,b=map(int,input().split())
print(max(0,a-b))

Buggy submission (verdict: Runtime Error):
print(max(int(input())-int(input()), 0))
Problem p03610 (python)

Fixed submission:
s = input()
s1 = s[0]
for i in range (len(s)):
    if i%2 == 0 and i > 0:
        s1 += s[i]
print(s1)

Buggy submission (verdict: Runtime Error):
s = input()
s1 = s[0]
for i in range (len(s)):
    if i%2 == 0 && i > 0:
        s1 += s[i]
print(s1)
Problem p03623 (python)

Fixed submission:
A, B, C = map(int, input().split())
print(["A", "B"][abs(A-B) > abs(A-C)])

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))
B = [0, 0]
for i in A.keys():
    if A[i] >= 2:
        B.append(i)
    if A[i] >= 4:
        B.append(i)
B.sort()
print(B[-1]*B[-2])