Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
T=input()

res = ""
for i in len(T) :
    if (T[i] != "?") :
        res += T[i]
        continue

    if (i != 0) :
        if (T[i-1] == "P") :
            res += "D"
        else :
            res += "D"

print(res)


Fixed submission:
T=input()

res = ""
for i in range(len(T)) :
    if (T[i] != "?") :
        res += T[i]
        continue
    res += "D"

    # if (i != 0) :
    #     if (T[i-1] == "P") :
    #         res += "D"
    #     else :
    #         res += "D"

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
H_list = [int(i) for i in input().split()]
not_good_list = []
AB_list = []
for i in range(M) :
    AB_list.append([int(i) for i in input().split()])

# AB_list = list(set(list(map(tuple,AB_list))))

# for i in range(M) :
for t in AB_list :
    A = t[0]
    B = t[1]

    if (A not in not_good_list) :
        if (H_list[A-1] <= H_list[B-1]) :
            not_good_list.append(A)

    if (B not in not_good_list) :
        if (H_list[B-1] <= H_list[A-1]) :
            not_good_list.append(B)
            continue

# for t in AB_list :
#     A = t[1]
#     B = t[0]

#     if (A in not_good_list) :
#         continue

#     if (H_list[A-1] <= H_list[B-1]) :
#         not_good_list.append(A)
#         continue
print(N - len(not_good_list))

Fixed submission:
N,M = map(int,input().split())
H_list = [int(i) for i in input().split()]
# not_good_list = []
not_good_set = set()
not_good_count = 0
AB_list = []
for i in range(M) :
    AB_list.append([int(i) for i in input().split()])

for t in AB_list :
    A = t[0]
    B = t[1]

    if (A not in not_good_set) :
        if (H_list[A-1] <= H_list[B-1]) :
            not_good_set.add(A)
            not_good_count += 1

    if (B not in not_good_set) :
        if (H_list[B-1] <= H_list[A-1]) :
            not_good_set.add(B)
            not_good_count += 1
            continue

print(N - not_good_count)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
H_list = [int(i) for i in input().split()]
not_good_list = []
AB_list = []
for i in range(M) :
    AB_list.append([int(i) for i in input().split()])

AB_list = list(set(list(map(tuple,AB_list))))

# for i in range(M) :
for t in AB_list :
    A = t[0]
    B = t[1]

    if (A in not_good_list) :
        continue

    if (H_list[A-1] <= H_list[B-1]) :
        not_good_list.append(A)
        continue

for t in AB_list :
    A = t[1]
    B = t[0]

    if (A in not_good_list) :
        continue

    if (H_list[A-1] <= H_list[B-1]) :
        not_good_list.append(A)
        continue

print(N - len(not_good_list))

Fixed submission:
N,M = map(int,input().split())
H_list = [int(i) for i in input().split()]
# not_good_list = []
not_good_set = set()
not_good_count = 0
AB_list = []
for i in range(M) :
    AB_list.append([int(i) for i in input().split()])

for t in AB_list :
    A = t[0]
    B = t[1]

    if (A not in not_good_set) :
        if (H_list[A-1] <= H_list[B-1]) :
            not_good_set.add(A)
            not_good_count += 1

    if (B not in not_good_set) :
        if (H_list[B-1] <= H_list[A-1]) :
            not_good_set.add(B)
            not_good_count += 1
            continue

print(N - not_good_count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    height_list = list(map(int,input().split()))
    # print(height_list)

    match_count = 0
    for a_i, a_height in enumerate(height_list) :
        for b_i, b_height in enumerate(height_list[a_i+1:], a_i+1) :
            # print(a_i,b_i, b_height)
            # b_height = height_list[b_i]
            height_sum = a_height + b_height
            no_diff = b_i - a_i
            if (height_sum == no_diff) :
                match_count += 1
    
    print(match_count)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    height_list = list(map(int,input().split()))

    L = {} # i + Ai
    R = {} # j - Ai
    for i,Ai in enumerate(height_list) :
        l = i + Ai
        if (l not in L.keys()) :
            L[l] = 0
        L[l] += 1

        r = i - Ai
        if (r not in R.keys()) :
            R[r] = 0
        R[r] += 1

    count = 0
    for l_key in L.keys() :
        if (l_key in R.keys()) :
            count += L[l_key] * R[l_key]
    
    print(count)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    height_list = list(map(int,input().split()))
    # print(height_list)

    match_count = 0
    for a_i, a_height in enumerate(height_list) :
        for b_i in range(a_i,N) :
            b_height = height_list[b_i]
            height_sum = a_height + b_height
            no_diff = b_i - a_i
            if (height_sum == no_diff) :
                match_count += 1
    
    print(match_count)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    height_list = list(map(int,input().split()))

    L = {} # i + Ai
    R = {} # j - Ai
    for i,Ai in enumerate(height_list) :
        l = i + Ai
        if (l not in L.keys()) :
            L[l] = 0
        L[l] += 1

        r = i - Ai
        if (r not in R.keys()) :
            R[r] = 0
        R[r] += 1

    count = 0
    for l_key in L.keys() :
        if (l_key in R.keys()) :
            count += L[l_key] * R[l_key]
    
    print(count)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())
max_n = -1
endpoint = min(B-1,N)
for i in range(endpoint+1) :
    n = ((A * i) // B) - A * (i // B)
    # print(i,n)
    if (max_n < n) :
        max_n = n

print(max_n)

Fixed submission:
def f(x) :
    return ((A * x) // B) - A * (x // B)

A,B,N = map(int,input().split())
print(f(min(B-1,N)))

Buggy python submission (verdict: Time Limit Exceeded):
import math
import time

A,B,N = map(int,input().split())
max_n = -1
st = time.time()
for i in range(N+1) :
    # n = math.floor((A * i)/B) - A * math.floor(i/B)
    # n = ((A * i) // B) - A * (i // B)
    n = ((A * i) // B) - A * (i // B)
    # print(i,n)
    if (max_n < n) :
        max_n = n
    
    if (time.time() - st > 2) :
        break

print(max_n)

Fixed submission:
def f(x) :
    return ((A * x) // B) - A * (x // B)

A,B,N = map(int,input().split())
print(f(min(B-1,N)))
Buggy python submission (verdict: Runtime Error):
S = int(input())
W = int(input())

if (S <= W) :
    print("unsafe")
else :
    print("safe")



Fixed submission:
S,W = map(int,input().split())

if (S <= W) :
    print("unsafe")
else :
    print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
dice_list = [int(i) for i in input().split()]
wa_list = [0]
for dice in dice_list :
    prob = 0
    for i in range(dice) :
        prob += (i+1) * (1/(dice))
    wa_list.append(wa_list[-1] + prob)

max_p = -1
for i in range(N-K+1) :
    p = wa_list[i+K] - wa_list[i]
    if (max_p < p) :
        max_p = p

print(max_p)





Fixed submission:
N,K = map(int,input().split())
dice_list = [int(i) for i in input().split()]
wa_list = [0]
for dice in dice_list :
    # prob = 0
    # for i in range(dice) :
    #     prob += (i+1) * (1/(dice))
    prob = (1+dice) / 2
    wa_list.append(wa_list[-1] + prob)

max_p = -1
for i in range(N-K+1) :
    p = wa_list[i+K] - wa_list[i]
    if (max_p < p) :
        max_p = p

print(max_p)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P_list = [int(i) for i in input().split()]

# cnt = 1 # 1件目は必ず合致するので

# for i in range(1,len(P_list)) :
#     pi = P_list[i]
#     is_match = True
#     for j in range(i) : # Pi==Pjは必ず正なのでジャッジ不要
#         pj = P_list[j]
#         if (pi > pj) :
#             is_match = False
#             break
    
#     if (is_match) :
#         cnt += 1

cnt = 1 # 1件目は必ず合致するので
min_map = [P_list[0]]
for i in range(1,len(P_list)) :
    # print(P_list[0:i])
    min_value = min(P_list[0:i])
    min_map.append(min_value)

# print(min_map)
for i in range(1,len(P_list)) :
    if (min_map[i] >= P_list[i]) :
        cnt += 1



print(cnt)

Fixed submission:
N = int(input())
P_list = [int(i) for i in input().split()]

# cnt = 1 # 1件目は必ず合致するので

# for i in range(1,len(P_list)) :
#     pi = P_list[i]
#     is_match = True
#     for j in range(i) : # Pi==Pjは必ず正なのでジャッジ不要
#         pj = P_list[j]
#         if (pi > pj) :
#             is_match = False
#             break
    
#     if (is_match) :
#         cnt += 1

cnt = 1 # 1件目は必ず合致するので
min_map = [P_list[0]]
min_value = P_list[0]
for i in range(1,len(P_list)) :
    min_value = min(min_value,P_list[i])
    min_map.append(min_value)

# print(min_map)
for i in range(1,len(P_list)) :
    if (min_map[i] >= P_list[i]) :
        cnt += 1



print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P_list = [int(i) for i in input().split()]

cnt = 1 # 1件目は必ず合致するので
for i in range(1,len(P_list)) :
    pi = P_list[i]
    is_match = True
    for j in range(i) : # Pi==Pjは必ず正なのでジャッジ不要
        pj = P_list[j]
        if (pi > pj) :
            is_match = False
            break
    
    if (is_match) :
        cnt += 1

print(cnt)

Fixed submission:
N = int(input())
P_list = [int(i) for i in input().split()]

# cnt = 1 # 1件目は必ず合致するので

# for i in range(1,len(P_list)) :
#     pi = P_list[i]
#     is_match = True
#     for j in range(i) : # Pi==Pjは必ず正なのでジャッジ不要
#         pj = P_list[j]
#         if (pi > pj) :
#             is_match = False
#             break
    
#     if (is_match) :
#         cnt += 1

cnt = 1 # 1件目は必ず合致するので
min_map = [P_list[0]]
min_value = P_list[0]
for i in range(1,len(P_list)) :
    min_value = min(min_value,P_list[i])
    min_map.append(min_value)

# print(min_map)
for i in range(1,len(P_list)) :
    if (min_map[i] >= P_list[i]) :
        cnt += 1



print(cnt)
Buggy python submission (verdict: Runtime Error):
import statistics as stat
import collections as cl

N = int(input())

s_li = []
s_dic:dict = {}
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    # con = s_li.count(s)
    # if (con >= 1) :
    #     c += con
    # s_li.append(s)
    if (s in s_dic) :
        c += s_dic[s]
        s_dic[s] += 1
    else :
        s_dic[s] = 1
print(c)

Fixed submission:
import statistics as stat
import collections as cl

N = int(input())

s_li = []
s_dic = {}
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    # con = s_li.count(s)
    # if (con >= 1) :
    #     c += con
    # s_li.append(s)
    if (s in s_dic) :
        c += s_dic[s]
        s_dic[s] += 1
    else :
        s_dic[s] = 1

print(c)

Buggy python submission (verdict: Runtime Error):
import statistics as stat
import collections as cl

N = int(input())

s_li = []
s_dic:dict = {}
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    # con = s_li.count(s)
    # if (con >= 1) :
    #     c += con
    # s_li.append(s)
    if (s in s_dic) :
        c += s_dic[s]
        s_dic[s] += 1
    else :
        s_dic[s] = 1
print(c)

Fixed submission:
import statistics as stat
import collections as cl

N = int(input())

s_li = []
s_dic = {}
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    # con = s_li.count(s)
    # if (con >= 1) :
    #     c += con
    # s_li.append(s)
    if (s in s_dic) :
        c += s_dic[s]
        s_dic[s] += 1
    else :
        s_dic[s] = 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())

s_li = []
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    con = s_li.count(s)
    if (con >= 1) :
        c += con
    s_li.append(s)

print(c)

Fixed submission:
import statistics as stat
import collections as cl

N = int(input())

s_li = []
s_dic = {}
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    # con = s_li.count(s)
    # if (con >= 1) :
    #     c += con
    # s_li.append(s)
    if (s in s_dic) :
        c += s_dic[s]
        s_dic[s] += 1
    else :
        s_dic[s] = 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import statistics as stat
import collections as cl

N = int(input())

s_li = []
c = 0
for i in range(N) :
    s = sorted(list(input()))
    for s_item in s_li :
        if (s == s_item) :
            c += 1
    s_li.append(s)


print(c)

Fixed submission:
import statistics as stat
import collections as cl

N = int(input())

s_li = []
s_dic = {}
c = 0
for i in range(N) :
    s = ''.join(sorted(list(input())))
    # con = s_li.count(s)
    # if (con >= 1) :
    #     c += con
    # s_li.append(s)
    if (s in s_dic) :
        c += s_dic[s]
        s_dic[s] += 1
    else :
        s_dic[s] = 1

print(c)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

remove_count = 0
while(True) :
    S = S.replace("10","X").replace("01","X")
    current_count = S.count("X")
    if (current_count == 0) :
        break
    remove_count += current_count
    S = S.replace("X","")

print(remove_count * 2)

Fixed submission:
S = input()

remove_count = 0
# while(True) :
#     S = S.replace("10","X").replace("01","X")
#     current_count = S.count("X")
#     if (current_count == 0) :
#         break
#     remove_count += current_count
#     S = S.replace("X","")
# print(remove_count * 2)
print(min(S.count("1"), S.count("0") )* 2)
Buggy python submission (verdict: Runtime Error):
import math

N =int(input())
lives = [int(i) for i in input().split()]
gcd_value = lives[0]

for i in range(1,len(lives)) :
    gcd_value = math.gcd(gcd_value, lives[i])

print(gcd_value)

Fixed submission:
import fractions

N =int(input())
lives = [int(i) for i in input().split()]
gcd_value = lives[0]

for i in range(1,len(lives)) :
    gcd_value = fractions.gcd(gcd_value, lives[i])

print(gcd_value)

Buggy python submission (verdict: Runtime Error):
import math

N =int(input())
lives = [int(i) for i in input().split()]
gcd_value = lives[0]

for i in range(1,len(lives)) :
    gcd_value = math.gcd(gcd_value, lives[i])

print(gcd_value)

Fixed submission:
import fractions

N =int(input())
lives = [int(i) for i in input().split()]
gcd_value = lives[0]

for i in range(1,len(lives)) :
    gcd_value = fractions.gcd(gcd_value, lives[i])

print(gcd_value)
Buggy python submission (verdict: Runtime Error):
N,X = [int(i) for i in input().split()]

def get_next_burger(current_burger) :
	return "B" + current_burger + "P" + current_burger + "B"

current = "P"

for i in range(N) :
	current = get_next_burger(current)

target = current[:X]
print(target.count("P"))

Fixed submission:
D = int(input())

if (D == 25) :
	print("Christmas")
elif (D == 24) :
	print("Christmas Eve")
elif (D == 23):
	print("Christmas Eve Eve")
elif (D == 22):
	print("Christmas Eve Eve Eve")
Buggy python submission (verdict: Runtime Error):
N,K = input().split()
N = int(N)
K = int(K)

trees = []
for i in range(N) :
	trees.append(int(input()))

trees.sort()
min_diff = 99999999999
a,b,c = trees[0:K]
for i in range(N-K+1) :
	max_v = c
	min_v = a
	diff = max_v - min_v
	if (min_diff > diff) :
		min_diff = diff
	if (min_diff == 0) :
		break

	a,b,c = b,c,trees[i+K]


print(min_diff)

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

trees = []
for i in range(N) :
	trees.append(int(input()))

trees.sort()
min_diff = 99999999999
for i in range(N-K+1) :
	max_v = trees[i+K-1]
	min_v = trees[i]
	diff = max_v - min_v
	if (min_diff > diff) :
		min_diff = diff
	if (min_diff == 0) :
		break



print(min_diff)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = input().split()
N = int(N)
K = int(K)

trees = []
for i in range(N) :
	trees.append(int(input()))

trees.sort()
min_diff = 99999999999
for i in range(N-K+1) :
	arr = trees[i:i+K]
	max_v = max(arr)
	min_v = min(arr)
	diff = max_v - min_v
	if (min_diff > diff) :
		min_diff = diff
	if (min_diff == 0) :
		break


print(min_diff)

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

trees = []
for i in range(N) :
	trees.append(int(input()))

trees.sort()
min_diff = 99999999999
for i in range(N-K+1) :
	max_v = trees[i+K-1]
	min_v = trees[i]
	diff = max_v - min_v
	if (min_diff > diff) :
		min_diff = diff
	if (min_diff == 0) :
		break



print(min_diff)

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

trees = []
for i in range(N) :
	trees.append(int(input()))

trees.sort()
min_diff = 999999
for i in range(N-K+1) :
	arr = trees[i:i+K]
	max_v = max(arr)
	min_v = min(arr)
	diff = max_v - min_v
	if (min_diff > diff) :
		min_diff = diff
	if (min_diff = 0) :
		break


print(min_diff)

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

trees = []
for i in range(N) :
	trees.append(int(input()))

trees.sort()
min_diff = 99999999999
for i in range(N-K+1) :
	max_v = trees[i+K-1]
	min_v = trees[i]
	diff = max_v - min_v
	if (min_diff > diff) :
		min_diff = diff
	if (min_diff == 0) :
		break



print(min_diff)
Buggy python submission (verdict: Time Limit Exceeded):
def is_753(s) :
	if (s.find("0") > -1) :
		return False
	elif (s.find("1") > -1) :
		return False
	elif (s.find("2") > -1) :
		return False
	elif (s.find("4") > -1) :
		return False
	elif (s.find("6") > -1) :
		return False
	elif (s.find("8") > -1) :
		return False
	elif (s.find("9") > -1) :
		return False
	
	if (s.find("7") > -1 and s.find("5") > -1 and s.find("3") > -1) :
		return True
	
	return False

N = int(input())
count = 0
# index = 0

for i in range(N+1) :
	s = str(i)
	if (is_753(s)) :
		count += 1

print(count)

Fixed submission:
import math
def is_753(s) :
	
	if ("0" in s) :
		return False
	elif ("1" in s) :
		return False
	elif ("2" in s) :
		return False
	elif ("4" in s) :
		return False
	elif ("6" in s) :
		return False
	elif ("8" in s) :
		return False
	elif ("9" in s) :
		return False
	
	if ("7" in s and "5" in s and "3" in s) :
		return True
	
	return False

def hoge(s) :
	for i in range(len(s)) :
		if (s[i] != "3" and s[i] != "5" and s[i] != "7") :
			return int(math.pow(10, len(s) - (i+1)))

	return 0

def main() :
	N = int(input())
	count = 0
	index = 356
	
	if (N < 357) :
		print("0")
		return

	while index <= N :
		s = str(index)
		a = hoge(s)
		if (a != 0) :
			index += a
			continue		
		
		if (is_753(s)) :
			count += 1
		
		index += 1
	
	print(count)


main()
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()

out_str = "Yes"
well_known_indexes = []
for i in range(len(S)) :
	if(i in well_known_indexes) :
		continue

	indexes_s = [n for n, x in enumerate(list(S)) if x == S[i]]
	indexes_t = [n for n, x in enumerate(list(T)) if x == T[i]]
	if (indexes_s == indexes_t) :
		well_known_indexes.extend(indexes_s)
		continue
	out_str = "No"
	break

print(out_str)

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

out_str = "Yes"

indexes_s_all = []
indexes_t_all = []
for i in range(26) :
	c = chr(ord('a') + i)
	indexes_s = [n for n, x in enumerate(list(S)) if x == c]
	indexes_t = [n for n, x in enumerate(list(T)) if x == c]
	indexes_s_all.append(indexes_s)
	indexes_t_all.append(indexes_t)

indexes_s_all.sort()
indexes_t_all.sort()
if (indexes_s_all == indexes_t_all) :
	print("Yes")
else :
	print("No")

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()

out_str = "Yes"
for i in range(len(S)) :
	indexes_s = [n for n, x in enumerate(list(S)) if x == S[i]]
	indexes_t = [n for n, x in enumerate(list(T)) if x == T[i]]
	if (indexes_s == indexes_t) :
		continue
	out_str = "No"
	break

print(out_str)

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

out_str = "Yes"

indexes_s_all = []
indexes_t_all = []
for i in range(26) :
	c = chr(ord('a') + i)
	indexes_s = [n for n, x in enumerate(list(S)) if x == c]
	indexes_t = [n for n, x in enumerate(list(T)) if x == c]
	indexes_s_all.append(indexes_s)
	indexes_t_all.append(indexes_t)

indexes_s_all.sort()
indexes_t_all.sort()
if (indexes_s_all == indexes_t_all) :
	print("Yes")
else :
	print("No")

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()

out_str = "Yes"
for i in range(len(S)) :
	indexes_s = [n for n, x in enumerate(list(S)) if x == S[i]]
	indexes_t = [n for n, x in enumerate(list(T)) if x == T[i]]
	if (indexes_s == indexes_t) :
		continue
	out_str = "No"

print(out_str)

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

out_str = "Yes"

indexes_s_all = []
indexes_t_all = []
for i in range(26) :
	c = chr(ord('a') + i)
	indexes_s = [n for n, x in enumerate(list(S)) if x == c]
	indexes_t = [n for n, x in enumerate(list(T)) if x == c]
	indexes_s_all.append(indexes_s)
	indexes_t_all.append(indexes_t)

indexes_s_all.sort()
indexes_t_all.sort()
if (indexes_s_all == indexes_t_all) :
	print("Yes")
else :
	print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(i) for i in input().split()]

candidates = []
for i in range(1,N+1) :
	i = int(i)
	if (i % K == 0) :
		# Kの倍数は候補にする
		candidates.append(i)
		continue
	
	if (K % 2 == 0 and i % (K/2) == 0) :
		# Kが偶数だったらK/2も候補としてよい
		candidates.append(i)
		continue

count = 0
for a in candidates :
	for b in candidates :
		for c in candidates :
			if (int(a+b) % K == 0 and int(b+c) % K == 0 and int(c+a) % K == 0) :
				count += 1

print(count)

Fixed submission:
import itertools as it
N,K = [int(i) for i in input().split()]

candidates = []
even = []
odd = []
for i in range(1,N+1) :
	i = int(i)
	if (i % K == 0) :
		# Kの倍数は候補にする
		even.append(i)
		continue
	
	if (K % 2 == 0 and i % (K/2) == 0) :
		# Kが偶数だったらK/2も候補としてよい
		odd.append(i)
		continue

# a,b,cの組み合わせ(Kが奇数のとき)
count = len(even) * len(even) * len(even)

# a,b,cの組み合わせ(Kが偶数のとき)
# すべての要素がK/2で揃っているケース
if (K % 2 == 0) :
	count += (len(odd) * len(odd) * len(odd))

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(i) for i in input().split()]

# 愚直に3重ループ
count = 0
for a in range(1,N+1) :
	for b in range(1, N+1) :
		for c in range(1, N+1) :
			if (int(a+b) % K == 0 and int(b+c) % K == 0 and int(c+a) % K == 0) :
				count += 1

print(count)

Fixed submission:
import itertools as it
N,K = [int(i) for i in input().split()]

candidates = []
even = []
odd = []
for i in range(1,N+1) :
	i = int(i)
	if (i % K == 0) :
		# Kの倍数は候補にする
		even.append(i)
		continue
	
	if (K % 2 == 0 and i % (K/2) == 0) :
		# Kが偶数だったらK/2も候補としてよい
		odd.append(i)
		continue

# a,b,cの組み合わせ(Kが奇数のとき)
count = len(even) * len(even) * len(even)

# a,b,cの組み合わせ(Kが偶数のとき)
# すべての要素がK/2で揃っているケース
if (K % 2 == 0) :
	count += (len(odd) * len(odd) * len(odd))

print(count)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

p = 0
for i in range(len(S)) :
	if (S[i] != "1") :
		print(S[i])
		p = 1
		break
	
if (p == 0) :
	print("1")

Fixed submission:
read_line = [int(i) for i in input().split()]
A = read_line[0]
B = read_line[1]

print(A*B-A-B+1)
Buggy python submission (verdict: Runtime Error):
S = input()
K = long(input())

for i in range(len(S)) :
	if (S[i] == "1") :
		continue
	
	print(S[i])
	break

Fixed submission:
def main() :
	S = input()
	K = int(input())

	is_1 = True
	for i in range(K) :
		if (len(S) < i) :
			break

		# print("S[i] : " + S[i])
		if (S[i] != "1") :
			is_1 = False
			break

	if (is_1) :
		print("1")
		return

	for i in range(len(S)) :
		if (S[i] == "1") :
			continue

		print(S[i])
		break


main()