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

Fixed submission:
N,K = input().split()
S = list(input())

for i,j in enumerate(S):
	if i+1 == int(K):
		S[i] = j.lower()
print("".join(S))

Buggy submission (verdict: Runtime Error):
import sys

S = input()
mon30 = ["02","04","06","09","11"]
mon31 = ["01","03","05","07","08","10","12"]

f_yymm = 0
f_mmyy = 0

if (S[0]+S[1]) in mon30 and  int(S[2]+S[3]) <= 30:
	f_yymm = 1
elif (S[0]+S[1]) in mon31 and  int(S[2]+S[3]) <= 31:
	f_yymm = 1
if (S[2]+S[3]) in mon30 and  int(S[0]+S[1]) <= 30:
	f_mmyy = 1
elif (S[2]+S[3]) in mon31 and  int(S[0]+S[1]) <= 31:
	f_mmyy = 1
if (S[0]+S[1]) == "00" or (S[2]+S[3]) == "00":
	print("NA")
	sys.exit()

if  f_yymm == 1 and f_mmyy == 1:
	print("AMBIGUOUS")
elif f_yymm == 1:
	print("YYMM")
elif f_mmyy == 1:
	print("MMYY")
else:
	print("NA")
Problem p03075 (python)

Fixed submission:
a= int(input())
b= int(input())
c= int(input())
d= int(input())
e= int(input())
k= int(input())

result = 0
if e - a <= k:
    print('Yay!')
elif e - a > k:
    print(':(')

Buggy submission (verdict: Runtime Error):
import sys
import itertools

x,y,z,k = map(int,(input().split()))

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

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

comb_a = [a[0]]
comb_b = [b[0]]
comb_c = [c[0]]
next = []
sum = []

comb = list(itertools.product(comb_a,comb_b,comb_c))
num_comb = len(comb)

#while num_comb < k*2 and num_comb < 3000:
while num_comb < 3000:


    next = []
    for i in a,b,c:
        if len(i) >= 2:
            next.append(i[0] - i[1])
        if len(i) == 1:
            next.append(10000000001)
    if min(next) != 10000000001:
        if len(a) >= 2 and min(next) == a[0] - a[1]:
            comb_a.append(a[1])
            a.pop(0)
        elif len(b) >= 2 and min(next) == b[0] - b[1]:
            comb_b.append(b[1])
            b.pop(0)
        elif len(c) >= 2 and min(next) == c[0] - c[1]:
            comb_c.append(c[1])
            c.pop(0)
    else:
        break
    comb = list(itertools.product(comb_a,comb_b,comb_c))
    num_comb = len(comb)
    
for i in comb:
    sum.append(i[0]+i[1]+i[2])
sum.sort(reverse=True)
for i in range(k):
    print(sum[i])
Problem p03041 (python)

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

S_L = list(S)
S_L[K-1] = S_L[K-1].lower()
print("".join(S_L))

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

S_L = list(S)
S_L[K-1] = S_L[K-1].lower
print("".join(S_L))
Problem p03042 (python)

Fixed submission:
s = input()
s1 = s[0:2]
s2 = s[2:4]

i1 = int(s1)
i2 = int(s2)
 
if 1 <= i1 <=12 and 1 <= i2 <= 12:
    res = "AMBIGUOUS"
elif 1 <= i1 <= 12:
    res = "MMYY"
elif 1 <= i2 <= 12:
    res = "YYMM"
else:
    res = "NA"

print(res)

Buggy submission (verdict: Runtime Error):
s = input()
s1 = s[0:1]
s2 = s[2:3]

i1 = int(s1)
i2 = int(s2)

if i1 = 0 or i2 = 0: res =NA
if i1 <=12:
	if i2 <= 12:
		res = "AMBIGUOUS"
    else:
      	res = "MMYY"
elif 12 < i1:
  	if i2 <= 12:
      	res = "YYMM"
    else:
      	res = NA
        
print(res)
Problem p03041 (python)

Fixed submission:
N,K = map(int, input().split())
S = input()
dir = {'A':'a', 'B':'b', 'C':'c'}

print(S[0:K-1] + dir[S[K-1]]+ S[K::])

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
S = Input()
dir = {'A':'a', 'B':'b', 'C':'c'}

print(S[0:K-1] + dir[S[K-1]]+ S[K::])
Problem p03042 (python)

Fixed submission:
S = input()

fr_half = int(S[0:2]) 
se_half = int(S[2::])

if se_half > 0 and se_half <= 12:
  if fr_half  > 0 and fr_half <= 12:
    print('AMBIGUOUS')
  else:
    print('YYMM')
else:
  if fr_half  > 0 and fr_half <= 12:
    print('MMYY')
  else:
   	print('NA')

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

fr_half = int(S[0:2]) 
se_half = int(S[2::])

if se_half > 0 and se_half <= 12:
	if fr_half  > 0 and fr_half <= 12:
		print('AMBIGUOUS')
  	else:
		print('YYMM')
else:
	if fr_half  > 0 and fr_half <= 12:
		print('MMYY')
	else:
		print('NA')
Problem p03201 (python)

Fixed submission:
# coding:utf-8

import sys
from collections import defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    MA = defaultdict(int)
    # 目標値をO(1)で見つけるために辞書に格納
    for a in A:
        MA[a] += 1

    key_n = list(MA.keys())
    key_n.sort()
    key_n.reverse()

    res = 0
    p = 30
    for x in key_n:
        # すでにペアを作るために使用してしまっている時はパス
        if not MA[x]:
            continue

        # 残っているボールの中で一番大きな値xを選ぶと，そのボールを使って表せる2べきの値x + yは1つに定まる
        # x + 1 <= x + y < 2x
        # 2べきの比は2であるのに対して，x + 1と2xの比は2未満だから
        while 2 * x < 2 ** p:
            p -= 1

        if x + 1 <= 2 ** p:
            y = 2 ** p - x
            if not MA[y]:
                continue

            if x == y:
                _add = MA[x] // 2
            else:
                _add = min(MA[x], MA[y])

            res += _add
            MA[x] -= _add
            MA[y] -= _add

    print(res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# coding:utf-8

import sys
from bisect import bisect_left, bisect_right
INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()
    A.sort()

    res = 0
    used = [0] * n
    for p in range(1, max(A).bit_length() + 1)[::-1]:
        t = 2 ** p
        for i in range(n)[::-1]:
            a = A[i]
            if used[i]:
                continue
            if a >= t:
                break
            bi = bisect_left(A, t - a)
            if A[bi] == t - a:
                if i != bi and not used[bi]:
                    res += 1
                    used[i] = 1
                    used[bi] = 1

    print(res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# coding:utf-8

import bisect

INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


def solve(num_cnt: list) -> int:
    num_cnt.sort()
    t = 2 ** (len(bin(num_cnt[-1])) - 2)
    used = [False] * len(num_cnt)
    cnt = 0
    for i in range(len(num_cnt))[::-1]:
        if used[i]:
            continue
        n = num_cnt[i]
        used[i] = True
        while 2 * n < t:
            t //= 2
        j = bisect.bisect_left(num_cnt, t - n)
        # print(n, t, j)
        if t - n == num_cnt[j] and n != t - n:
            cnt += 1
            used[j] = True

    return cnt


N = int(input())
A = inpl()

cnt_e, cnt_o = [], []
for a in A:
    if a % 2:
        cnt_o.append(a)
    else:
        cnt_e.append(a)

print(solve(cnt_e) + solve(cnt_o))
Problem p03265 (python)

Fixed submission:
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


x1, y1, x2, y2 = inpl()

diff_y = y2 - y1
diff_x = x2 - x1
ans1 = [x2 - diff_y, y2 + diff_x]
ans2 = [ans1[0] - diff_x, ans1[1] - diff_y]
ans = ans1 + ans2
ans = ' '.join(map(str, ans))
print(ans)

Buggy submission (verdict: Runtime Error):
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


x1, y1, x2, y2 = inpl()

diff_y = y2 - y1
diff_x = x2 - x1
ans1 = [x2 - diff_y, y2 + diff_x]
ans2 = [ans1[0] - diff_x, ans1[1] - diff_y]
ans = ans1 + ans2
print(' '.join(map(str, ans))
Problem p03286 (python)

Fixed submission:
#coding:utf-8


n = int(input())

ans = ''
while(n != 0):
    if n % 2 != 0:
        n -= 1
        ans = '1' + ans
    else:
        ans = '0' + ans

    n /= -2

if ans == '': ans = '0'

print(ans)

Buggy submission (verdict: Runtime Error):
# coding:utf-8

n = input()

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

ans = ''
while abs(n) > 0:
    if n % 2 != 0:
        ans += '1'
        n -= 1
        n //= -2
    else:
        ans += '0'
        n //= -2

print(ans[::-1])
Problem p03426 (python)

Fixed submission:
# coding:utf-8

import sys

input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


H, W, D = inpl()

num_coordinate = {}
for i in range(H):
    w = inpl()
    for j in range(W):
        num_coordinate[w[j]] = (i, j)

c_sum = {}
for d in range(1, D + 1):
    c_sum[d] = [0]

for d in range(1, D + 1):
    for n in range(d + D, H * W + 1, D):
        c_sum[d].append(c_sum[d][-1] + abs(num_coordinate[n][0] - num_coordinate[n - D][0])
                        + abs(num_coordinate[n][1] - num_coordinate[n - D][1]))

Q = int(input())
for _ in range(Q):
    l, r = inpl()
    index = (l - 1) % D + 1
    index_l, index_r = (l - 1) // D, (r - 1) // D

    print(c_sum[index][index_r] - c_sum[index][index_l])

Buggy submission (verdict: Runtime Error):
# coding:utf-8

import sys

input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


H, W, D = inpl()

num_coordinate = {}
for i in range(H):
    w = inpl()
    for j in range(W):
        num_coordinate[w[j]] = (i, j)

c_sum = {}
for d in range(1, D + 1):
    c_sum[d] = [0]

for d in range(1, D + 1):
    for n in range(d + D, H * W, D):
        c_sum[d].append(c_sum[d][-1] + abs(num_coordinate[n][0] - num_coordinate[n - D][0])
                        + abs(num_coordinate[n][1] - num_coordinate[n - D][1]))

Q = int(input())
for _ in range(Q):
    l, r = inpl()
    index = (l - 1) % D + 1
    index_l, index_r = (l - 1) // D, (r - 1) // D

    print(c_sum[index][index_r] - c_sum[index][index_l])
Problem p03776 (python)

Fixed submission:
# coding:utf-8

import sys
import math
from collections import defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, a, b = LI()
V = LI()
V.sort()
V.reverse()

cnt = defaultdict(int)
sum_v = 0
for i in range(a):
    sum_v += V[i]
    cnt[V[i]] += 1

# 大きい順にa個選ぶ場合，価値の平均値は最大となる
print(sum_v / a)

# a個選んだ中で一番価値の低いものがいくつ残っているか数える
min_v = V[i]
min_cnt = cnt[min_v]
for i in range(a, n):
    v = V[i]
    if v != min_v:
        break
    cnt[v] += 1

if cnt[min_v] == min_cnt:
    print(1)
    exit()
elif len(cnt.keys()) != 1:
    print(comb(cnt[min_v], min_cnt))
    exit()
ans = 0
for i in range(b - a + 1):
    if cnt[min_v] < min_cnt + i:
        break
    ans += comb(cnt[min_v], min_cnt + i)

print(ans)

Buggy submission (verdict: Runtime Error):
# coding:utf-8

import sys
import math
from collections import defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def comb(n, r):
    if n - r < r: return comb(n, n - r)
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, a, b = LI()
V = LI()
V.sort()
V.reverse()

cnt = defaultdict(int)
sum_v = 0
for i in range(a):
    sum_v += V[i]
    cnt[V[i]] += 1

# 大きい順にa個選ぶ場合，価値の平均値は最大となる
print(sum_v / a)

# a個選んだ中で一番価値の低いものがいくつ残っているか数える
min_v = V[i]
min_cnt = cnt[min_v]
for i in range(a, n):
    v = V[i]
    if v != min_v:
        break
    cnt[v] += 1

if cnt[min_v] == min_cnt:
    print(1)
    exit()
elif len(cnt.keys()) != 1:
    print(cnt[min_v])
    exit()
ans = 0
for i in range(b - a + 1):
    ans += comb(cnt[min_v], min_cnt + i)

print(ans)

Buggy submission (verdict: Runtime Error):
# coding:utf-8

import sys
import math
from collections import defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, a, b = LI()
V = LI()
V.sort()
V.reverse()

cnt = defaultdict(int)
sum_v = 0
for i in range(a):
    sum_v += V[i]
    cnt[V[i]] += 1

# 大きい順にa個選ぶ場合，価値の平均値は最大となる
print(sum_v / a)

# a個選んだ中で一番価値の低いものがいくつ残っているか数える
min_v = V[i]
min_cnt = cnt[min_v]
for i in range(a, n):
    v = V[i]
    if v != min_v:
        break
    cnt[v] += 1

if cnt[min_v] == min_cnt:
    print(1)
    exit()
elif len(cnt.keys()) != 1:
    print(comb(cnt[min_v], min_cnt))
    exit()
ans = 0
for i in range(b - a + 1):
    ans += comb(cnt[min_v], min_cnt + i)

print(ans)
Problem p04008 (python)

Fixed submission:
# coding:utf-8

import sys
from collections import defaultdict

sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, k = LI()
    A = LI_()

    D = defaultdict(list)
    for i in range(1, n):
        D[A[i]].append(i)

    # 首都は必ず自己ループでなければならない
    global res
    res = 0 if A[0] == 0 else 1

    def DFS(v, par):
        global res
        h = 0
        for to in D[v]:
            # print('dfs {} -> {}'.format(v+1, to+1))
            # h: 葉からの距離の最大値
            h = max(h, DFS(to, v))

        # 根が首都ではなく，高さがk - 1の場合は首都につなぎ直す
        if h == k - 1 and par != 0:
            res += 1
            h = -1
        # print('Finish {} <- {}'.format(par+1, v+1))
        return h + 1

    DFS(0, 0)

    return res


print(main())

Buggy submission (verdict: Runtime Error):
# coding:utf-8

import sys
from collections import defaultdict, deque


INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, k = LI()
    A = LI_()

    D = defaultdict(list)
    for i in range(1, n):
        D[A[i]].append(i)

    q = deque([(0, 0)])
    # 首都は必ず自己ループでなければならない
    global res
    res = 0 if A[0] == 0 else 1

    def DFS(v, par):
        global res
        h = 0
        for to in D[v]:
            # print('dfs {} -> {}'.format(v+1, to+1))
            # h: 葉からの距離の最大値
            h = max(h, DFS(to, v))
            
        # 根が首都ではなく，高さがk - 1の場合は首都につなぎ直す
        if h == k - 1 and par != 0:
            res += 1
            h = -1
        # print('Finish {} <- {}'.format(par+1, v+1))
        return h + 1

    DFS(0, 0)

    return res


print(main())
Problem p03317 (python)

Fixed submission:
#coding: utf-8

N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
    if(A[i] == 1):
        one = i
        #print('1は',one + 1,'番目')

ans = []

for i in range(K):
    start = one - (K - 1) + i
    end = one + i

    before = start
    after = N - (end+1)

    before_num = before//(K-1)
    if(before%(K-1) != 0):
        before_num += 1

    after_num = after//(K-1)
    if(after%(K-1) != 0):
        after_num += 1

    answer = before_num + after_num + 1
    ans.append(answer)

print(min(ans))

Buggy submission (verdict: Runtime Error):
#coding: utf-8
 
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
if(N==K):
    ans = 1
 
print(ans)

Buggy submission (verdict: Runtime Error):
#coding: utf-8

N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K):
    if(A[i] == 1):
        one = i
        #print('1は',one + 1,'番目')

ans = []

for i in range(K):
    start = one - (K - 1) + i
    end = one + i
    
    before = start
    after = N - (end+1)
    
    before_num = before//(K-1)
    if(before%(K-1) != 0):
        before_num += 1
        
    after_num = after//(K-1)
    if(after%(K-1) != 0):
        after_num += 1
    
    answer = before_num + after_num + 1
    ans.append(answer)

print(min(ans))

Buggy submission (verdict: Runtime Error):
#coding: utf-8

N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K):
    if(A[i] == 1):
        one = i
        #print('1は',one + 1,'番目')

ans = []

for i in range(K):
    start = one - (K - 1) + i
    end = one + i
    
    before = start
    after = N - (end+1)
    
    before_num = before//(K-1)
    if(before%(K-1) != 0):
        before_num += 1
        
    after_num = after//(K-1)
    if(after%(K-1) != 0):
        after_num += 1
    
    answer = before_num + after_num + 1
    ans.append(answer)

print(min(ans))
Problem p03250 (python)

Fixed submission:
abc = list(map(int,input().split()))
abc.sort()
print(abc[0]+int(str(abc[2])+str(abc[1])))

Buggy submission (verdict: Runtime Error):
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

print(["War","No War"][X<min(y) and max(x)<Y and max(x)<min(y)])

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()

if A>=B and B>=C:
    print(int(A+B)+int(C))
elif B>A and A>C:
    print(int(B+A)+int(C))
elif A>C and C>B:
    print(int(A+C)+int(B))
elif C>B and B>A:
    print(int(C+B)+int(A))
elif B>C and B>A:
    print(int(B+C)+int(A))
else:
    print(int(C+A)+int(B))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())

if A>=B and B>=C:
    print(int(str(A)+str(B))+C)
elif B>A and A>C:
    print(int(str(B)+str(A))+C)
elif A>C and C>B:
    print(int(str(A)+str(C))+B)
elif C>B and B>A:
    print(int(str(C)+str(B))+A)
elif B>C and B>A:
    print(int(str(B)+str(C))+A)
else:
    print(int(str(C)+str(A))+B)
Problem p03041 (python)

Fixed submission:
n, k = map(int, raw_input().split())
s = list(raw_input())
s[k - 1] = s[k - 1].lower()
ans = ""
for i in s:
  ans = ans + i
print ans

Buggy submission (verdict: Runtime Error):
n, k = map(int, raw_input().split())
s = list(raw_input())
s[k] = s[k].lower()
ans = ""
for i in s:
  ans = ans + i
print ans
Problem p03041 (python)

Fixed submission:
n,k = [ int(i) for i in input().split(" ") ]
s = input()
print(s[:k-1] + s[k-1].lower() + s[k:])

Buggy submission (verdict: Runtime Error):
n,k = [ int(i) for i in input().split(" ") ]
s = input()
print(s[:k] + s[k].lower() + s[k+1:])
Problem p03209 (python)

Fixed submission:
n, x = [int(i) for i in input().split()]

def tlen(L):
    l = 1
    for i in range(1, L):
        l = l*2 + 3
    return l

def tpat(L):
    p = 1
    for i in range(1, L):
        p = p*2 + 1
    return p

def maisu(n, x):
    tl = tlen(n)
    if x == 1:
        return(0)
    elif n == 1:
        b = "bpppb"
        b = b[:x]
        return(b.count("p"))
    elif 2 <= x <= 1+tl-1:
        return(maisu(n-1, x-1))
    elif x == 1+tl:
        return(tpat(n))
    elif x == 2+tl:
        return(tpat(n)+1)
    elif tl+3 <= x <= 1+tl*2:
        return(tpat(n)+1+maisu(n-1,x-2-tl))
    else:
        return(tpat(n)*2+1)  

print(maisu(n,x))

Buggy submission (verdict: Runtime Error):
n, x = [int(i) for i in input().split()]

def tlen(L):
    l = 1
    for i in range(1, L):
        l = l*2 + 3
    return l

def tpat(L):
    p = 1
    for i in range(1, L):
        p = p*2 + 1
    return p

def maisu(n, x):
    tl = tlen(n)
    if x == 1:
        return(0)
    elif n == 1:
        b = "bpppb"
        b = b[:x]
        return(b.count(p))
    elif 2 <= x <= 1+tl-1:
        return(maisu(n-1, x-1))
    elif x == 1+tl:
        return(tpat(n))
    elif x == 2+tl:
        return(tpat(n)+1)
    elif tl+3 <= x <= 1+tl*2:
        return(tpat(n)+1+maisu(n-1,x-2-tl))
    else:
        return(tpat(n)*2+1)  

print(maisu(n,x))
Problem p03042 (python)

Fixed submission:
import sys

def isM(s):
    if (s[0] == '0' and '1'<=s[1]<='9' ) or \
        (s[0] == '1' and s[1] in ('0', '1', '2')):
        return True
    return False

if __name__ == '__main__':
    input = sys.stdin.read()
    F, S = input[:2], input[2:]
    if isM(F) and not isM(S): print "MMYY"
    elif not isM(F) and isM(S): print "YYMM"
    elif isM(F) and isM(S): print "AMBIGUOUS"
    else: print 'NA'

Buggy submission (verdict: Runtime Error):
def isM(s):
    return 1<=int(s)<=12

if __name__ == '__main__':
    input = sys.stdin.read()
    F, S = input[:2], input[2:]
    if isM(F) and not isM(S): print "MMYY"
    elif not isM(F) and isM(S): print "YYMM"
    elif isM(F) and isM(S): print "AMBIGUOUS"
    else: print 'NA'
Problem p03041 (python)

Fixed submission:
# cook your dish here
n,k=map(int,input().split())
s=input()
a=""
for i in range(n):
    if i==k-1:
        a+=(s[i].lower())
    else:
        a+=s[i]
print(a)

Buggy submission (verdict: Runtime Error):
# cook your dish here
import math
        
n,k=map(int,input().split())
summ=0
for i in range(1,n+1):
    if k/i<=1:
        value=0
    elif abs((math.log(k)-math.log(i))//math.log(2)-(math.log(k)-math.log(i))/math.log(2))<=0.00001:
        value = (math.log(k)-math.log(i))//math.log(2)
    else:
        value = (math.log(k)-math.log(i))//math.log(2)+1    
    else:
        value=math.log(k)-math.log(i)
    po=(0.5)**value
    summ+=po
    
summ=summ/n
print('{0:.12f}'.format(summ))
Problem p03107 (python)

Fixed submission:
def solve(S):
    return min(S.count("0"),S.count("1"))*2
  
S = input()
print(solve(S))

Buggy submission (verdict: Runtime Error):
memo = {}
def solve(S):
    if len(S)<1:
        return 0
    crs = 0
    if S in memo:
        return memo[S]
    while crs + 1 < len(S):
        if S[crs] != S[crs+1]:
            memo[S] = solve(S[:crs]+S[crs+2:])+2
            return memo[S]
        crs += 1
    return 0
S = input()
print(solve(S))

Buggy submission (verdict: Runtime Error):
def solve(S,crs=0):
    if crs >= len(S) or crs <0:
        return 0
    while crs + 1 < len(S):
        if S[crs] != S[crs+1]:
            #print(S,crs)
            return max(solve(S,crs+1),solve(S[:crs]+S[crs+2:],crs-1)+2)
        crs += 1
        
    return 0
  
S = input()
print(solve(S,0))

Buggy submission (verdict: Runtime Error):
def solve(S,crs=0):
    if crs >= len(S):
        return 0
    while crs + 1 < len(S):
        if S[crs] != S[crs+1]:
            return max(solve(S,crs+1),solve(S[:crs]+S[crs+2:],crs-1)+2)
        crs += 1
        
    return 0
  
S = input()
print(solve(S,0))
Problem p03127 (python)

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

ans = 10**10
for i in range(N-1):
    ans = min(ans, fractions.gcd(A[i],A[i+1]))
print(ans)

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

ans = 10**10
for i in range(N-1):
    ans = min(ans, math.gcd(A[i],A[i+1]))
print(ans)

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

ans = 10**10
for i in range(N-1):
    ans = min(ans, math.gcd(A[i],A[i+1]))
print(ans)