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

Fixed submission:
import sys


def calc(n):
    i = 1
    sm = 0
    st = set()
    if n <= 2:
        st.add(n)
        return st
    while sm < n:
        st.add(i)
        sm += i
        i += 1
    st = st - calc(sm - n)
    return st


sys.setrecursionlimit(10000000)
n = int(input())

c = calc(n)

for cc in c:
    print(cc)

Buggy submission (verdict: Runtime Error):
def calc(n):
    i=1
    sm = 0
    st = set()
    if n<=2:
        st.add(n)
        return st
    while sm<=n:
        st.add(i)
        sm += i
        i+=1
    st = st - calc(sm-n)
    return st

n = int(input())

c = calc(n)

for cc in c:
    print(cc)

Buggy submission (verdict: Runtime Error):
def calc(n):
    i=1
    sm = 0
    st = set()
    if n<=2:
        st.add(n)
        return st
    while sm<=n:
        st.add(i)
        sm += i
        i+=1
    st = st - calc(sm-n)
    return st

n = int(input())

c = calc(n)

for cc in c:
    print(cc)
Problem p03962 (python)

Fixed submission:
# coding: utf-8

colors = input().split()

bef = 0
count = 0
colors.sort()

for c in colors:
    if bef == 0:
        count += 1
        bef = c
    else:
        if c > bef:
            count += 1
            bef = c

print(count)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math
from decimal import Decimal

N = int(input())

votes = []

for _ in range(N):
    votes.append([Decimal(n) for n in input().split()])

befa = 1
befb = 1

for a, b in votes:
    kakeru = Decimal(max(math.ceil(befa / a), math.ceil(befb / b)))
    befa = a * kakeru
    befb = b * kakeru

print(int(befa)+int(befb))
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
n =[]
for i in range(a,a+k if k<(b-a) else b+1):
    n.append(i)
for i in range(b-k+1 if k<(b-a) else b+1,b+1):
    if(i not in n):
        n.append(i)
for i in n:
    print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
n = list(range(a,b+1))
nf=n[:k]
nb=n[len(n)-k:]
n=list(set(nf+nb))
n.sort()
for i in n:
    print(i)
Problem p03437 (python)

Fixed submission:
import sys
a,b = map(int,input().split())
if(a%b==0):
    print(-1)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
import sys
a,b = map(int,input().split())
if(a%b==0):
    print(-1)
    sys.exit(-1)
for i in range(10**18):
    if(i%a==0 and i%b):
        print(i)
        sys.exit(0)
print(-1)
Problem p03359 (python)

Fixed submission:
def main(input):
  a, b = [int(i) for i in input.split()]
  print(a if a <= b else a-1)

# tests = [
#   '5 5',  # 5
#   '2 1',  # 1
#   '11 30',  # 11
# ]

# for test in tests:
#   main(test)

main(input())

Buggy submission (verdict: Runtime Error):
def main(input):
  a, b = [int(i) for i in input.split()]
  print(a if a <= b else a-1)

# tests = [
#   '5 5',  # 5
#   '2 1',  # 1
#   '11 30',  # 11
# ]

# for test in tests:
#   main(test)


main(a, b)
Problem p03359 (python)

Fixed submission:
month, day = map(int, input().split())
if month > day:
    print(month-1)
else:
    print(month)

Buggy submission (verdict: Runtime Error):
month, day = map(int, input())
if month > day:
    print(month-1)
else:
    print(month)
Problem p03502 (python)

Fixed submission:
N = input()

num = [int(i) for i in N]
f = sum(num)
if int(N)%f == 0:
    print("Yes")
else:
    print('No')

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

num = [int(i) for i in N]
f = sum(num)
if N%f == 0:
    print("Yes")
else:
    print('No')
Problem p03377 (python)

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

if a <= x <= a + b:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
x = int(input())

if a <= x <= a + b:
    print("YES")
else:
    print("NO")
Problem p03471 (python)

Fixed submission:
import sys
n, y = map(int, input().split())
for i in range(n+1):
  for j in range(i, n+1):
      if (i*10000+(j-i)*5000+(n-j)*1000 == y):
        print(i, j-i, n-j)
        sys.exit(0)
print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
import sys
n, y = map(int, input().split())
for i in reversed(range(y//10000+1)):
  for j in reversed(range((y-i*10000)//5000+1)):
    if i*10000+j*5000+(n-i-j)*1000 == y:
      print(i, j, n-i-j)
      sys.exit(1)

print('-1 -1 -1')
Problem p03472 (python)

Fixed submission:
n, h = map(int, input().split())
a = []
b = []
amax = 0
for i in range(n):
  ai, bi = map(int, input().split())
  if amax < ai:
    amax = ai
  a.append(ai)
  b.append(bi)

b = [b[j] for j in range(n) if b[j] > amax]
sumb = sum(b)
if sumb >= h:
  s = 0
  b = sorted(b)
  c = 0
  while s < h:
    s += b[-1]
    b.pop(-1)
    c += 1
  print(c)
else:
  print((h-sumb)//amax+((h-sumb)%amax!=0) + len(b))

Buggy submission (verdict: Runtime Error):
n, h = map(int, input().split())
a = []
b = []
amax = 0
for i in range(n):
  ai, bi = map(int, input().split())
  if amax < ai:
    amax = ai
  a.append(ai)
  b.append(bi)

b = [b[j] for j in range(n) if b[j] > amax]
sumb = sum(b)
if sumb >= h:
  s = 0
  b = sorted(b)
  c = 0
  while s < h:
    s += b[-1]
    b.pop(-1)
    c + =1
  print(c)
else:
  print((h-sumb)//amax+((h-sumb)%amax!=0) + len(b))
Problem p03434 (python)

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

def sort_reverse(n):
    n.sort(reverse=True)
    return n

N_Even = list(range(0, N, 2))
N_Odd = list(range(1, N, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0

for i in N_Even:
    sum1 += a1[i]
for j in N_Odd:
    sum2 += a1[j]

print(sum1 - sum2)

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

def sort_reverse(n):
    n.sort(reverse=True)
    return n

N_Even = list(range(0, N+1, 2))
N_Odd = list(range(1, N+1, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0

for i in N_Even:
    sum1 += a1[i]
for j in N_Odd:
    sum2 += a1[j]

print(sum1 - sum2)

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

def sort_reverse(n):
    n.sort(reverse=True)
    return n

N_Even = list(range(0, N+1, 2))
N_Odd = list(range(1, N+1, 2))
a1 = sort_reverse(a)
sum1 = 0
sum2 = 0

for i in N_Even:
    sum1 += a1[i]
for j in N_Odd:
    sum2 += a1[i]

print(sum1 - sum2)
Problem p03457 (python)

Fixed submission:
import sys
N = int(input())
t_param = 0
x_param = 0
y_param = 0

for i in range(N):
    t, x, y = map(int, input().split())
    if (abs(x - x_param) + abs(y - y_param))  > (abs(t - t_param)) or ((x + y + t)%2) != 0 :
        print('No')
        sys.exit()
    t_param = t
    x_param = x
    y_param = y
print('Yes')

Buggy submission (verdict: Runtime Error):
using namespace std;

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}
Problem p03796 (python)

Fixed submission:
INF = 1000000007
n = int(input())

ans = 1


for i in range(1,n+1):
  ans = ans * i % INF
  
print(ans)

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

for i in range(1,n+1):
  power = power * i
  
print(powe r% (pow(10,9) + 7))
Problem p03574 (python)

Fixed submission:
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

check_i = []
check_j = []
for i in range(H):
    if H == 1:
        check_i = [0]
    elif i == 0:
        check_i = [0, 1]
    elif i == H-1:
        check_i = [i-1, i]
    else:
        check_i = [i-1, i, i+1]
    for j in range(W):
        if S[i][j] == "#":
            continue

        if W == 1:
            check_j = [0]
        elif j == 0:
            check_j = [0, 1]
        elif j == W-1:
            check_j = [j-1, j]
        else:
            check_j = [j-1, j, j+1]
        
        count = 0
        for k in check_i:
            for l in check_j:
                if S[k][l] == "#":
                    count += 1
        S[i][j] = str(count)

for i in range(H):
    print("".join(S[i]))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

check_i = []
check_j = []
for i in range(H):
    if i == 0:
        check_i = [0, 1]
    elif i == H-1:
        check_i = [i-1, i]
    else:
        check_i = [i-1, i, i+1]
    for j in range(W):
        if S[i][j] == "#":
            continue

        if j == 0:
            check_j = [0, 1]
        elif j == W-1:
            check_j = [j-1, j]
        else:
            check_j = [j-1, j, j+1]
        
        count = 0
        for k in check_i:
            for l in check_j:
                if S[k][l] == "#":
                    count += 1
        S[i][j] = str(count)

for i in range(H):
    print("".join(S[i]))
Problem p03448 (python)

Fixed submission:
import functools

A = int(input())
B = int(input())
C = int(input())
X = int(input())

if min(A, B, C, X) == X:
	print(0)

@functools.lru_cache(1000)
def num_patterns(A, B, C, X):
    if X == 0:
      	return 1

    if min(A, B, C, X) == X:
        return 0

    if A > 0:
        return sum(
            num_patterns(0, B, C, X - 500 * nA) if X >= 500 * nA else 0
            for nA in range(0, A + 1)
        )
    if B > 0:
        return sum(
            num_patterns(0, 0, C, X - 100 * nB) if X >= 100 * nB else 0
            for nB in range(0, B + 1)
        )
    if C > 0 and X % 50 == 0 and X / 50 <= C:
        return 1
    else:
        return 0

print(num_patterns(A, B, C, X))

Buggy submission (verdict: Runtime Error):
import functools

A = int(input())
B = int(input())
C = int(input())
X = int(input())

if min(A, B, C, X) == X:
	print(0)

@functools.lru_cache
def num_patterns(A, B, C, X):
    if X == 0:
      	return 1

    if min(A, B, C, X) == X:
        return 0
    branch_A = num_patterns(A - 1, B    , C    , X - 500) if A > 0 else 0
    branch_B = num_patterns(A    , B - 1, C    , X - 100) if B > 0 else 0
    branch_C = num_patterns(A    , B    , C - 1, X - 50 ) if C > 0 else 0
    return branch_A + branch_B + branch_C

print(num_patterns(A, B, C, X))

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

if min(A, B, C, X) == X:
	print(0)

def num_patterns(A, B, C, X):
    if X == 0:
      	return 1
	if min(A, B, C, X) == X:
    	return 0
    branch_A = num_patterns(A - 1, B    , C    , X - 500) if A > 0 else 0
    branch_B = num_patterns(A    , B - 1, C    , X - 100) if B > 0 else 0
    branch_C = num_patterns(A    , B    , C - 1, X - 50) if C > 0 else 0
    return branch_A + branch_B + branch_C

print(num_patterns(A, B, C, X))
Problem p03493 (python)

Fixed submission:
print(len(list(filter(lambda s: s == '1', list(input())))))

Buggy submission (verdict: Runtime Error):
print(len(filter(lambda s: s == '1', list(input()))))
Problem p03680 (python)

Fixed submission:
N = int(input())  
 
data = ([int(input()) for i in range(N)])

data.insert(0, 0)

cnt = 0
i = 1
v = 0

while v != 2:
  v = data[i]
  i = v
  if cnt >= N: 
    cnt = -1
    break
  cnt += 1
  
print(cnt)

Buggy submission (verdict: Runtime Error):
length = int(input())  
 
data = ([int(input()) for i in range(length)])

cnt = 0
i = 1
v = 0

while v != 2:
  v = data[i]
  i = v
  if cnt >= data[0]: 
    cnt = -1
    break
  cnt += 1
  
print(cnt)

Buggy submission (verdict: Runtime Error):
length = int(input())  
 
data = ([int(input()) for i in range(length)])

cnt = 0
i = 1
v = 0

while v != 2:
  v = data[i]
  i = v
  cnt += 1
  if cnt >= data[0]: 
    cnt = -1
    break
print(cnt)
Problem p03796 (python)

Fixed submission:
N = int(input())
power = 1

for i in range(1, N + 1, 1):
 
  power = (i * power) % (10**9 + 7)
  
print(power)

Buggy submission (verdict: Runtime Error):
N = int(input())
power = 1

for i in range(1, N + 1, 1):
  power = i * power
  
print(power / (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
N = int(input())

for i in range(1, N + 1, 1):
  
  if i == 1:
    power = i
  else:
  	power = i * power
  
print(power / (10 ** 9 + 7))
Problem p03854 (python)

Fixed submission:
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = str(input())
 
inputs = inputs.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "")

if len(list(inputs)) > 0:
  print("NO")
else:
  print("YES")

Buggy submission (verdict: Runtime Error):
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}
 
ans = []
 
inputs = list(input())
 
inputs = inputs.replace("eraser", "").replace("dreamer", "")
inputs = .replace("dream", "").replace("erase", "")

if len(list(inputs)) > 0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
words = {"dream": "A", "dreamer": "A", "erase": "A", "eraser": "A"}

ans = []

inputs = list(input())

tmp1 = []

for c in reversed(inputs):
  
  tmp1.append(c)
  
  tmp2 = "".join([x for x in reversed(tmp1)])
  
  if tmp2 in words:
    ans.append("".join(tmp2))
    tmp1.clear()
    tmp2.clear()

ans = [x for x in reversed(ans)]

if "".join(ans) == "".join(inputs):
  print("YES")
else:
  print("No")
Problem p03471 (python)

Fixed submission:
count,total = list(map(int,input().split()))
ret1 = -1
ret2 = -1
ret3 = -1
NF = True
if total <= count * 10000:
	for i in range(count + 1):
		rCount = count - i
		if total-10000*i <= rCount * 5000:
			for j in range(rCount + 1):
				if (i*10000 + j*5000 + (count-i-j)*1000) == total:
					ret1 = i
					ret2 = j
					ret3 = count-i-j
					NF = False
					break
if NF:
	ret1 = -1
	ret2 = -1
	ret3 = -1
print(str(ret1) + " " + str(ret2) + " " + str(ret3))

Buggy submission (verdict: Runtime Error):
count,total = list(map(int,input().split()))
ret1 = -1
ret2 = -1
ret3 = -1
NF = True
if total <= count * 10000:
	for i in range(count + 1):
		rCount = count - i
		if total-10000*i <= rCount * 5000:
			for j in range(rCount + 1):
				if (i*10000 + j*5000 + (count-i-j)*1000) == total:
					ret1 = i
					ret2 = j
					ret3 = count-i-j
                    NF = False
				break
if NF:
  ret1 = -1
  ret2 = -1
  ret3 = -1
print(str(ret1) + " " + str(ret2) + " " + str(ret3))
Problem p03597 (python)

Fixed submission:

input1 = int(input())
input2 = int(input())

print (input1*input1 - input2)

Buggy submission (verdict: Runtime Error):

if __name__ == "__main__":
  input1 = input()
  input2 = input()

  print (input1*input1 - input2)

Buggy submission (verdict: Runtime Error):

input1 = input()
input2 = input()

print (input1*input1 - input2)
Problem p03992 (python)

Fixed submission:
s = raw_input()
print s[:4], s[4:]

Buggy submission (verdict: Runtime Error):
moji = {a: b for a, b in zip("abcdefghijklmnopqrstuvwxyz", range(26))}

s = list(raw_input())
k = int(raw_input())

for i, e in enumerate(s):
    if 26 - moji[e] <= k:
        s[i] = "a"
        k -= 26 - moji[e]

k = k % 26 if k >= 0 else 0
if k != 0:
    s[-1] = "abcdefghijklmnopqrstuvwxyz"[(moji[s[-1]] + k) % 26]

print "".join(s)
Problem p03369 (python)

Fixed submission:
import sys                        
n = input()
num = n.count('o')
print(700+(num*100))

Buggy submission (verdict: Runtime Error):
import sys                        
n = raw_input()
num = n.count('o')
print(700+(num*100))
Problem p03370 (python)

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

m = [None for i in range(n)]

for i in range(n):
    m[i] = int(input())

cnt = n
x -= sum(m)
cnt += x // min(m)

print(cnt)

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

m = [None for i in range(n)]

for i in range(n):
    m[i] = int(input())

# print(n, x, m)

# print(sum(m), min(m))

cnt = n

x -= sum(m)

cnt += x // min(m)

print(cnt)
n, x=[int(i) for i in input().split()]

m = [None for i in range(n)]

for i in range(n):
    m[i] = int(input())

# print(n, x, m)

# print(sum(m), min(m))

cnt = n

x -= sum(m)

cnt += x // min(m)

print(cnt)
Problem p03624 (python)

Fixed submission:
s = input()

alp = [chr(i) for i in range(97, 97+26)]

flag = [False for i in range(26)]

for c in s:
    flag[ord(c) - ord("a")] = True


def pr():
    for i in range(26):
        if not flag[i]:
            print(alp[i])
            return

    print('None')
    return

pr()

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

alp = [chr(i) for i in range(97, 97+26)]

flag = [False for i in range(26)]

for c in s:
    for i in range(26):
        if c == alp[i]:
            flag[i] = True


def pr():
    for i in range(26):
        if flag[i] == False:
            return alp[i]

    return 'None'

print(pr())
Problem p03671 (python)

Fixed submission:
a, b, c = [int(i) for i in input().split()]

if a > b:
  a, b = b, a

if b > c:
  b, c = c, b

if a > b:
  a, b = b, a

print(a+b)

Buggy submission (verdict: Runtime Error):
a, b, c = [int(i) for i in input().split()]

if a > b:
  swap(a, b)

if b > c:
  swap(b, c)

if a > b:
  swap(a, b)

print(a+b)
Problem p03762 (python)

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

def sum(a, n):
    sum_a = 0
    for i in range(0, n):
        sum_a += i * a[i] - (n-1-i) * a[i]
    return sum_a

sum_x = sum(x,n)
sum_y = sum(y,m)

s = sum_x * sum_y % (10**9 + 7)

print(s)

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

s = 0

map = [[0 for i in range(n)] for j in range(m)]

yokomap = [0] * n
tatemap = [0] * m

for i in range(n-1):
    for j in range(m-1):
        yokomap = (i+1) * (n-1-i)
        tatemap = (j+1) * (m-1-j)
        map[i][j] = yokomap * tatemap

for i in range(n-1):
    for j in range(m-1):
        yoko = x[i+1] - x[i]
        tate = y[j+1] - y[j]
        s += yoko * tate * map[i][j]
        s %= (10**9 + 7)


print(s)

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

s = 0

map = [[0 for i in range(n)] for j in range(m)]

yokomap = [0] * n
tatemap = [0] * m

for i in range(n-1):
    for j in range(m-1):
        yokomap = (i+1) * (n-1-i)
        tatemap = (j+1) * (m-1-j)
        map[i][j] = yokomap * tatemap

for i in range(n-1):
    for j in range(m-1):
        yoko = x[i+1] - x[i]
        tate = y[j+1] - y[j]
        s += yoko * tate * map[i][j]

s %= (10**9 + 7)

print(s)
Problem p03777 (python)

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

if (a == 'H' and b == 'H') or (a == 'D' and b == 'D'):
    print('H')
else:
    print('D')

Buggy submission (verdict: Runtime Error):
W, a, b = [int(i) for i in input().split()]

if a > b:
    a, b = b, a

print(b-(a+W))
Problem p03854 (python)

Fixed submission:
s = input()

# t = ['dream', 'dreamer', 'erase', 'eraser']

s = s[::-1]
# for i in range(4):
#     t[i] = t[i][::-1]

# print(s,t)

tmp = s

while tmp != '':
    d = tmp[:5] == 'maerd'
    dr = tmp[:7] == 'remaerd'
    e = tmp[:5] == 'esare'
    er = tmp[:6] == 'resare'
    # print(tmp[:5])
    # print(d,dr,e,er)

    if d:
        tmp = tmp[5:]
    elif e:
        tmp = tmp[5:]
    elif dr:
        tmp = tmp[7:]
    elif er:
        tmp = tmp[6:]
    else:
        print('NO')
        break

if tmp == '':
    print('YES')

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

# t = ['dream', 'dreamer', 'erase', 'eraser']

s = s[::-1]
for i in range(4):
    t[i] = t[i][::-1]

# print(s,t)

tmp = s

while tmp != '':
    d = tmp[:5] == 'maerd'
    dr = tmp[:7] == 'remaerd'
    e = tmp[:5] == 'esare'
    er = tmp[:6] == 'resare'
    # print(tmp[:5])
    # print(d,dr,e,er)

    if d:
        tmp = tmp[5:]
    elif e:
        tmp = tmp[5:]
    elif dr:
        tmp = tmp[7:]
    elif er:
        tmp = tmp[6:]
    else:
        print('NO')
        break

if tmp == '':
    print('YES')
Problem p03381 (python)

Fixed submission:
n = int(input())
l0 = list(map(int, input().split()))
l = sorted(l0)

m1 = l[n//2 - 1]
m2 = l[n//2]
for i in range(len(l0)):
    if l0[i] < m2:
        print(m2)
    elif l0[i] > m1:
        print(m1)
    elif l0[i] == m1:
        print(m2)
    elif l0[i] == m2:
        print(m1)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
d = {i: {chr(i): 0 for i in range(ord('a'), ord('z')+1)} for i in range(n)}
d2 = {i: {chr(i): 0 for i in range(ord('a'), ord('z')+1)} for i in range(m)}
for i in range(n):
    s = input()
    for j in s:
        d[i][j] += 1
    for j in range(len(s)):
        d2[j][s[j]] += 1

k = [0 for i in range(n)]
k2 = [0 for i in range(m)]

f = True
for i in range(n):
    for j in range(n):
        if d[i] == d[j]:
            k[i] += 1


for i in range(m):
    for j in range(m):
        if d2[i] == d2[j]:
            k2[i] += 1

k2 = sorted(k2)
k = sorted(k)
if n % 2:
    if len(k) > 1:
        if k[1] < 2:
            f = False
else:
    if k[0] < 2:
        f = False

if m % 2:
    if len(k) > 1:
        if k2[1] < 2:
            f = False
else:
    if k2[0] < 2:
        f = False

if f:
    print('YES')
else:
    print('NO')
Problem p03389 (python)

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

lst.sort()

mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av
ans1 = 0
mini += d
d2 = max - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans1 += 1

else:
    d2 = d2 // 2

ans1 += d + d2

ans2 = 0
mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av

mini += d

d2 = max + 1 - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans2 += 1
else:
    d2 = d2 // 2

ans2 += d + d2 + 1

print(min(ans1, ans2))

Buggy submission (verdict: Runtime Error):
import math

def slv(A, B):
    A, B = (A, B) if A > B else (B, A)
    
    s = A * B
    c = math.floor(math.sqrt(A * B))
    
    if A == B:
        return 2 * c - 2
    elif c * c < s:
        return 2 * c - 2
    elif c * (c - 1) < s:
        return 2 * c - 3

Q = int(input())
for q in range(Q):
    A, B = map(int, input().split())
    print(slv(A, B))
Problem p04029 (python)

Fixed submission:
n = int(raw_input())
print (n*(n+1)/2)

Buggy submission (verdict: Runtime Error):
n = raw_input()
print (n*(n-1)/2)
Problem p03377 (python)

Fixed submission:
a, b, x = map(int, input().split())
if x<a: print('NO')
elif x>a+b: print('NO')
else:print('YES')

Buggy submission (verdict: Runtime Error):
import copy
n = int(input())
N = int(n/2-1)
x = list(map(int, input().split()))
y = sorted(x)

for i in range(n):
    Y  = copy.deepcopy(y)
    Y.remove(x[i])
    print(Y[N)

Buggy submission (verdict: Runtime Error):
import copy
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)

for i in range(n):
    Y  = copy.deepcopy(y)
    Y.remove(x[i])
    print(Y[int(n/2 -1)])

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

for i in range(n):
    x_in  = copy.deepcopy(x)
    del x_in[i]
    x_in.sort()
    print(x_in[int(n/2 -1)])
    x_in  = []