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

Fixed submission:
#!/usr/bin/env python3
# coding: utf-8
def main():
    K = int(input())
    S = input()
    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + '...')

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# coding: utf-8
import math
# def debug(arg):
#     if __debug__:
#         pass
#     else:
#         import sys
#         print(arg, file=sys.stderr)

def main():
    A, B, H, M = map(int, input().split())

    vh = ((H * 60 + M) / (12 * 60))
    vm = (M / 60)

    theta = (vh - vm) * math.tau
    d = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta))

    print(d)

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

Fixed submission:


s, t= [""] * 2
a, b = [0] * 2
u = [""]

def format_input(filename = None):
	global s,t
	global a,b
	global u
	if filename == None:
		s, t = list(map(str, input().split()))
		a, b = list(map(int, input().split()))
		u = list(map(str, input().split())).pop()

def get_answer():
	answer = [a, b]
	if u == s:
		answer[0] -= 1
	else:
		answer[1] -= 1

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans[0], ans[1])

Buggy submission (verdict: Runtime Error):


a, b, c = [0] * 3
x = []

def format_input(filename = None):
	global a, b, c
	global x
	if filename == None:
		a, b, c = list(map(int, input().split()))
		x = [list(map(int, input().split())) for i in range(n)]

	elif filename == '__random__'
		from random import randint as rng
		a = rng(1, 10**1)
		b = rng(1, 10**1)
		c = rng(1, 10**1)
		x = [[rng(1, 10**1), rng(1, 10**1)] for i in range(n)]

def get_answer(a, b, c, x):
	answer = 0
	return answer

if __name__ == '__main__':
	format_input('__random__')

	ans = get_answer(a, b, c, x)
	print(ans)

Buggy submission (verdict: Runtime Error):


s, t= [""] * 2
a, b = [0] * 2
u = [""]

def format_input(filename = None):
	global s,t
	global a,b
	global u
	if filename == None:
		s, t = list(map(str, input().split()))
		a, b = list(map(int, input().split()))
		u = list(map(str, input().split())).pop()

def get_answer():
	answer = [a, b]
	if u == s:
		answer[0] -= 1
	else:
		answer[1] -= 1

	return answer

if __name__ == '__main__':
	format_input()

	ans = get_answer()
	print(ans[0], ans[1])
Problem p02689 (python)

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

road_list = []
for _ in range(N):
    road_list.append([])
    
for i in range(M):
    a, b = list(map(int, input().split()))
    
    H_a, H_b = [H_list[a - 1], H_list[b - 1]]
    
    if H_a <= H_b:
        road_list[a - 1].append(b)

    if H_b <= H_a:
        road_list[b - 1].append(a)

ans = 0
for road in road_list:
    if len(road) == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
H_list = list(map(int, input().split()))
road_list = []

for _ in range(M):
    road_list.append([])
for i in range(M):
    a, b = list(map(int, input().split()))
    H_a, H_b = [H_list[a - 1], H_list[b - 1]]
    if H_a <= H_b:
        road_list[a - 1].append(a)
    elif H_b <= H_a:
        road_list[b - 1].append(b)

ans = 0
for road in road_list:
    if len(road) == 0:
        ans += 1
print(ans)
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r ** 2)

Buggy submission (verdict: Runtime Error):
x, y = input().split()
x = int(x)
y = int(y)
xy_sum = x + y
point_num = 0
kimari = 10 ** 9 + 7
if (xy_sum % 3 == 0):
    point_num += ((xy_sum - 1) / 3) ** 2
    point_num += (xy_sum - 1) // 6
    count = 2 ** point_num
    print(count % kimari)
else:
    print(0)
Problem p02831 (python)

Fixed submission:
#!/usr/bin/env python3
import sys

def gcd(A,B):
    while B:
        A, B = B, A % B

    return A

def solve(A: int, B: int):
    print( (A*B) // gcd(A, B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import math

def solve(A: int, B: int):
    print( (A*B) // math.gcd(A, B))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()
Problem p02880 (python)

Fixed submission:
num = int(input())
lst = list(range(1, 10))
count = 0
for i in lst:
    if num / i in lst:
        count += 1
if count > 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
num = int(input())
for i in range(1, 9):
    if num / i in lst:
        print('Yes')
    else:
        print('No')
Problem p02897 (python)

Fixed submission:
number = int(input())
if number % 2 == 0:
	odd_num = number // 2
	percent = odd_num / number
else:
	odd_num = number // 2 + 1
	percent = odd_num / number

print(percent)

Buggy submission (verdict: Runtime Error):
number = int(input())
if number * 2 == 0:
	odd_num = number // 2
	percent = odd_num / number
    print(percent)
else:
	odd_num = number // 2 + 1
    percent = odd_num / number
	print(percent)

Buggy submission (verdict: Runtime Error):
number = int(input())
if number * 2 = 0:
	odd_num = number // 2
	percent = odd_num / number
    print(percent)
else:
	odd_num = number // 2 + 1
    percent = odd_num / number
	print(percent)

Buggy submission (verdict: Runtime Error):
number = int(input())
if number * 2 = 0:
	odd_num = number // 2
	percent = odd_num / number
else:
	odd_num = number // 2 + 1
    percent = odd_num / number
  
print(percent)

Buggy submission (verdict: Runtime Error):
number = int(input())
if number * 2 = 0:
	odd_num = number // 2
	percent = odd_num / number
else:
	odd_number = number // 2 + 1
    percent = odd_num / number
  
print(percent)

Buggy submission (verdict: Runtime Error):
number = int(imput())
odd_num = number // 2 + 1
percent = odd_num / number
print(percent)
Problem p02793 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)
import collections
import math

MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))


def eratosthenes(n):  #エラトステネスの篩
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    if n > 1:
        _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


def factorize(n, primes):        # 素数の値をカウントする
    if n < 2:
        return dict()
    counter = collections.Counter()
    for p in primes:
        while n % p == 0:
            counter[p] += 1
            n //= p
        if n == 1:
            break
    if n > 1:
        counter[n] += 1
    return counter


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

sieve = eratosthenes(10 ** 3)
primes = [x for x, b in enumerate(sieve) if b]

lcm = collections.Counter()
for x in a:
    counter = factorize(x, primes)
    for p, k in counter.items():
        lcm[p] = max(lcm[p], k)
lcm_val = 1
for p, k in lcm.items():  # 各素因数と個数
    lcm_val *= pow(p, k, MOD)
    #lcm_val %= MOD       # 最小公倍数


res = 0
for x in a:
    res += lcm_val * pow(x, MOD - 2, MOD)  # 最小公倍数lcm_val / 各値x の余り 逆元をとる
    res %= MOD
print(res)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)
import math

M = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
p = a[0]
ans = 0
for i in range(1, n):
    p = p * a[i] // math.gcd(p, a[i])

for i in range(n):
    ans += p // a[i]
print(ans % M)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)
import math

M = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
p = a[0]
ans = 0
for i in range(1, n):
    p = p * a[i] // math.gcd(p, a[i])

for i in range(n):
    ans += p // a[i]
print(ans % M)
Problem p02695 (python)

Fixed submission:
import itertools

n,m,q = input().split()
n = int(n)
m = int(m)
q = int(q)
num_list = []
a = list(range(1, n+1))
for i in range(q):
    num_list.append(list(map(int,input().split())))
ff = list(itertools.combinations_with_replacement(range(1, m + 1), n))
max = 0
for i in range(len(ff)):
  s = 0
  for j in range(q):
    a,b,c,d = num_list[j]
    if ff[i][b-1] - ff[i][a-1] == c:
      s = s + d
  if max < s:
        max = s
print(max)

Buggy submission (verdict: Runtime Error):
import itertools

n,m,q = input().split()
n = int(n)
m = int(m)
q = int(q)
num_list = []
a = list(range(1, n+1))
for i in range(q):
    num_list.append(list(map(int,input().split())))
ff = list(itertools.combinations_with_replacement(a, m))
max = 0
for i in range(len(ff)):
  s = 0
  for j in range(q):
    a,b,c,d = num_list[j]
    if ff[i][b-1] - ff[i][a-1] == c:
      s = s + d
  if max < s:
        max = s
print(max)

Buggy submission (verdict: Runtime Error):
import itertools

n,m,q = input().split()
n = int(n)
m = int(m)
q = int(q)
num_list = []
a = list(range(1, n+1))
for i in range(q):
    num_list.append(list(map(int,input().split())))
num_list = sorted(num_list, reverse=True, key=lambda x: x[3])
ff = list(itertools.combinations_with_replacement(a, m))
max = 0
for i in range(len(ff)):
  s = 0
  for j in range(q):
    a,b,c,d = num_list[j]
    if ff[i][b-1] - ff[i][a-1] == c:
      s = s + d
  if max < s:
        max = s
print(max)
Problem p02726 (python)

Fixed submission:
from collections import defaultdict as dd
N,X,Y = map(int,input().split())

pdic = dd(lambda:0)

# count = 0

for i in range(1,N):
    for j in range(i+1,N+1):

#         count += 1

        # no shortcut
        d1 = j-i
        # with shortcut
        i2x = abs(X-i)
        y2j = abs(Y-j)
        d2 = i2x + y2j + 1

        dist = min(d1,d2)
        pdic[str(dist)] += 1

for n in range(1,N):
    print(pdic[str(n)])

# print("count:",count)

Buggy submission (verdict: Runtime Error):
    from collections import defaultdict as dd
    N,X,Y = map(int,input().split())
     
    pdic = dd(lambda:0)
     
    # count = 0
     
    for i in range(1,N):
        for j in range(i+1,N+1):
            
    #         count += 1
            
            # no shortcut
            d1 = j-i
            # with shortcut
            i2x = abs(X-i)
            y2j = abs(Y-j)
            d2 = i2x + y2j + 1
            
            dist = min(d1,d2)
            pdic[str(dist)] += 1
            
    for n in range(1,N):
        print(pdic[str(n)])
        
    # print("count:",count)
Problem p02777 (python)

Fixed submission:
S,T = input().split()
A,B = map(int,input().split())
U = input()
if U ==S:
    print(A-1,B)
else:
    print(A,B-1)

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


mind = -1
mmax = -1

sums = []
csum = 0

for i in range(N):
    p = PP[i]
    csum += (p+1)/2
    sums.append(csum)
    if i < K:
        if mmax < csum:
            mind = i
            mmax = csum
    else:
        ksum = csum - sums[(i-K)]
        if mmax < ksum:
            mind = i
            mmax = ksum
            
print(ksum)
time3 = datetime.now()
Problem p03042 (python)

Fixed submission:
S = input()
ot = S[:2]
tf = S[2:]

isotMM = 0
istfMM = 0

if 0 < int(ot) and int(ot) < 13:
    isotMM = 1
if 0 < int(tf) and int(tf) < 13:
    istfMM = 1
    
if isotMM == 1:
    if istfMM == 1:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if istfMM == 1:
        print('YYMM')
    else:
        print("NA")

Buggy submission (verdict: Runtime Error):
S = input()
ot = S[:2]
tf = S[2:]

isotMM = 0
istfMM = 0

if 0 < int(ot) and int(ot) < 13:
    isotMM = 1
if 0 < int(tf) and int(tf) < 13:
    istfMM = 1
    
if isotMM == 1:
    if istfMM == 1:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if istfMM == 1:
        print('YYMM')
    else:
        print(NA)
Problem p02785 (python)

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

if K < N:
    H.sort()
    H = H[0:N-K]
    print(sum(H))
    
else:
    print('0')

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

H.sort()

if K < N:
    for x in range(K):
        H.pop(-x-1)
    print(sum(H))

else:
    print('0')
Problem p02831 (python)

Fixed submission:
import fractions
A,B = list(map(int,input().split()))
print(int(A*B/fractions.gcd(A,B)))

Buggy submission (verdict: Runtime Error):
import math
A,B = list(map(int,input().split()))
print(int(A*B/math.gcd(A,B)))

Buggy submission (verdict: Runtime Error):
import math
A,B = list(map(int,input().split()))
print(int(A*B/math.gcd(A,B)))

Buggy submission (verdict: Runtime Error):
import math
A,B = list(map(int,input().split()))
print(int(A*B/math.gcd(A,B)))

Buggy submission (verdict: Runtime Error):
import math
A,B = list(map(int,input().split()))
print(A*B/math.gcd(A,B))
Problem p02881 (python)

Fixed submission:
n = int(input())
s = int(n ** 0.5)
i = 0
while True:
    if n%(s + i) == 0:
        k = 1
        break
    if n%(s - i) == 0:
        k = -1
        break
    i += 1
s = s + i * k 
print((s + n // s) - 2)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
ran = math.floor(math.sqrt(N))
max = 0
for i in range(１、ran):
    if N%i == 0:
        if i > max:
            max = i
print(i + N/i -2)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
a = 1
b = 1
ran = math.floor(math.sqrt(N))
max = 0
for i in range(ran):
    if N%i == 0:
        if i > max:
            max = i
print(i + N/i -2)
Problem p02897 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 0:
    print((N/2)/N)
else:
    print((N//2)+1/(N)
Problem p02915 (python)

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

Buggy submission (verdict: Runtime Error):
print(int(input())**3))

Buggy submission (verdict: Runtime Error):
print(int(input()**3))
Problem p02951 (python)

Fixed submission:
A = list(map(int,input().split()))
if A[2] > A[0]-A[1]:
    print(A[2] - (A[0]-A[1]))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split()))
print(A[2] - (A[1]-A[2])
Problem p03011 (python)

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

Buggy submission (verdict: Runtime Error):
P= list(map(int(input().split()))
P.sort()
print(P[0]+P[1])
Problem p03041 (python)

Fixed submission:
N,K = list(map(int, input().split()))
S = str(input())
s = [S[i] for i in range(len(S))]
s[K-1] = chr(ord(s[K-1])+32)
print(''.join(s))

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
S = str(input())
s = [S[i] for i in range(len(S))]
s[K-1] = chr(ord(s[k-1])+32)
print(join(s))

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
S = str(input())
s = [S[i] for i in range(len(S))]
ans = (s[K-1].lower)
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
S = str(input())
s = [S[i] for i in range(len(S))]
ans = (s[K-1].lower)
print(join(ans))
Problem p03242 (python)

Fixed submission:
N = int(input())
A = []
a = N//100
b = N//10-a*10
c = N - a*100 - b*10
A.append(a)
A.append(b)
A.append(c)
for i in range(3):
    if A[i]==1:
        A[i]=9
    elif A[i]==9:
        A[i]=1
print(A[0]*100+A[1]*10+A[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
A.append(N//100)
A.append(N//10-A)
A.append(N-A-B)
for i in range(3):
    if A[i]==1:
        A[i]=9
    if A[i]==9:
        A[i]=1
print(A[0]*100+A[1]*10+A[2])
Problem p03307 (python)

Fixed submission:
N = int(input())
if N % 2 == 0:
    print(N)
else:
    print(N * 2)

Buggy submission (verdict: Runtime Error):
N = input()
if N % 2 == 0:
    print(N)
else:
    print(N * 2)
Problem p03317 (python)

Fixed submission:
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
print( (n-1 + k-1 - 1)// (k-1) )

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
a = list(map(int, input().split()))
print( (n-1 + k-1 - 1)// (k-1) )
Problem p03345 (python)

Fixed submission:
A = list(map(int,input().split()))
if A[3] == 0:
    print(A[0]-A[1])
elif A[3]%2 == 0:
    print(A[0]-A[1])
else:
    print(A[1]-A[0])

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split()))
if A[3] == 0 or A[3]%2 == 0:
    print(A[0]-A{1])
else:
    print(A[1]-A[0])

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split()))
for i in range(K):
    A[0] = A[1] + A[2]
    A[1] = A[0] + A[2]
    A[2] = A[0] + A[1]
if abs(A[0]-A[1]) > 10**18:
    print('unfair')
else:
    print(A[0]-A[1])

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split))
for i in range(K):
    A[0] = A[1] + A[2]
    A[1] = A[0] + A[2]
    A[2] = A[0] + A[1]
if abs(A[0]-A[1]) > 10**18:
    print('unfair')
else:
    print(A[0]-A[1])
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
A = set(int(input()) for _ in range(M))
mod = 10 ** 9 + 7

dp = [0] * (N+1)
dp[0] = 1
for i in range(1, N+1):
    if i in A:
        continue
    if i == 1:
        dp[i] = 1
        continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod

print(dp[N] % mod)

Buggy submission (verdict: Runtime Error):
N, M = tuple(map(int, input().split()))
ans = 0
a = []
tmp = -10
d = 10**9 + 7

for i in range(M):
    num = (int(input()))
    if ((tmp+1) == num):
        print(0)
        exit()
    a.append(num)
    tmp = num

def stairs(n):
    if (n in a):
        return 0
    if (n == 1):
        return 1
    if (n == 2):
        return 2
    ans = stairs(n-1)%d + stairs(n-2)%d
    return ans

print(stairs(N))
Problem p03038 (python)

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

A = list(map(int, input().split(" ")))
bc = []
for _ in range(m):
  b,c = list(map(int, input().split(" ")))
  bc.append((b,c))

count = 0
bc = sorted(bc,key=lambda x:x[1],reverse = True)
big_list = []
for b,c in bc:
  big_list += [c for _ in range(b)]
  count += b
  if count >= n:
    break
print(sum( sorted((A+big_list),reverse=True)[:n] ))

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

A = list(map(int, input().split(" ")))
bc = []
for _ in range(m):
  b,c = list(map(int, input().split(" ")))
  bc.append((b,c))

count = 0
bc = sorted(bc,key=lambda x:x(1),reverse = True)
big_list = []
for b,c in bc:
  big_list += [c for _ in range(b)]
  count += b
  if count >= n:
    break
print(sum( sorted((A+big_list),reverse=True)[:n] ))

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

A = list(map(int, input().split(" ")))
bc = []
for _ in range(m):
  b,c = list(map(int, input().split(" ")))
  bc.append((b,c))

count = 0
bc = sorted(bc,key=lambda x:x(1),reverse = True)
big_list = []
for b,c in bc:
  big_list += [c for _ in range(b)]
  count += b
  if count >= N:
    break
print(sum( sorted((A+big_list),reverse=True)[:N] ))

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

A = list(map(int, input().split(" ")))
bc = []
for _ in range(m):
  b,c = list(map(int, input().split(" ")))
  bc_ append((b,c))

count = 0
bc = sorted(bc,key=lambda x:x(1),reverse = True)
big_list = []
for b,c in bc:
  big_list += [c for _ in range(b)]
  count += b
  if count >= N:
    break
print(sum( sorted((A+big_list),reverse=True)[:N] ))
Problem p02729 (python)

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

print(int(n*(n-1)/2 + m*(m-1)/2))

Buggy submission (verdict: Runtime Error):
n,m = list(map(int, split()))

print(n*(n-1)/2 + m*(m-1)/2)
Problem p02951 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
print(max(a-b,c)
Problem p03208 (python)

Fixed submission:
N,K = list(map(int, input().split()))
h = [int(input()) for i in range(N)]
candidate = None
h.sort()
for i in range(N-K+1):
    tmp = h[i+K-1] - h[i]
    if candidate == None or tmp < candidate:
        candidate = tmp
print(candidate)

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
h = [int(input()) for i in range(N)]
candidate = None
h.sort()
for i in range(N-K+1):
    tmp = h[i+K+1] - h[i]
    if candidate == None or tmp < candidate:
        candidate = tmp
print(candidate)

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
h = [int(input()) for i in range(N)]
first_flg = True
h.sort()
for i in range(N-K-1):
    tmp = h[i+K-1] - h[i]
    if first_flg or tmp < candidate:
        first_flg = False
        candidate = tmp
print(candidate)

Buggy submission (verdict: Runtime Error):
import numpy as  np
import copy
for i in range(N-K+1):
    
    diff = 0
    print("h[i] is {}".format(h[i]))
    for j in range(K-1):
        if(h[i] >= h[j]):
            target = [a for a in h if a <= h[i] and a >= h[j]]
            print("0")
            exit()
        else :
            target = [a for a in h if a > h[i] and a < h[j]]
        media = (a.pop(np.abs(np.asarray(a) - h[i]).argmin()))
        choose_h =[h[i],h[j],media]
        diff = max(choose_h)-min(choose_h)
        if(diff < candidate):
            candidate = diff
print(candidate)
Problem p03221 (python)

Fixed submission:
n, m = list(map(int, input().split()))
city_list = []

for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list.append([i,pm,ym])

city_count = {}
city = {}

for i,p,y in sorted(city_list, key=lambda x: x[2]):
    if not p in city_count:
        city_count[p] = 1
    else:
        city_count[p] += 1
    city[i,p] = city_count[p]

for i,p,y in city_list:
    print("{:0=6}{:0=6}".format(p, city[i,p]))

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
city_list = [[] for i in range(n)]

for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list[pm-1].append(ym)

for i in range(n):
    city_list_copied[i].sort()
    for j in range(len(city_list[i])):
        cindex = sum(x <= city_list[i][j] for x in city_list[i])
        print("{:0=6}{:0=6}".format(i+1, cindex))

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
city_list = [[] for i in range(n)]

for i in range(m):
    pm, ym = list(map(int, input().split()))
    city_list[pm-1].append(ym)
city_list_copied = copy.deepcopy(city_list)

for i in range(n):
    city_list_copied[i].sort()
    for j in range(len(city_list[i])):
        cindex = sum(x <= city_list[i][j] for x in city_list[i])
        print("{:0=6}{:0=6}".format(i+1, cindex))
Problem p03252 (python)

Fixed submission:
s = input()
t = input()
dic1 = {}
dic2 = {}
for i in range(len(s)):
    if dic1.get(s[i]) == None:
        dic1[s[i]] = t[i]
    elif dic1[s[i]] != t[i]:
        print("No")
        exit()
    if dic2.get(t[i]) == None:
        dic2[t[i]] = s[i]
    elif dic2[t[i]] != s[i]:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
dic1 = {}
dic2 = {}
for i in range(len(s)):
    if dic1.get(s[i]) == None:
        dic1[s[i]] = t[i]
    elif dic1[s[i]] != t[i] 
        print("No")
        exit()
    if dic2.get(t[i]) == None:
        dic2[t[i]] = s[i]
    elif dic2[t[i]] != s[i]:
        print("No")
        exit()
print("Yes")