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

Fixed submission:
def resolve():
	n, m = map(int, input().split())
	a = list(map(int, input().split()))
	print(n-sum(a) if n-sum(a) > -1 else -1)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    input().split()
    map(int, input().split())
    list(map(int, input().split()))
resolve()
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce

def resolve():
	k = int(input())
	ans = 0
	for i in range(1, k+1):
		for j in range(1, k + 1):
			for k in range(1, k + 1):
				ans += reduce(math.gcd, [i, j, k])
	print(ans)

resolve()

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce


def resolve():
	k = int(input())
	ans = 0
	for i in range(1, k+1):
		for j in range(1, k + 1):
			for k in range(1, k + 1):
				ans += reduce(math.gcd, [i, j, k])
	print(ans)

ressolve()
Problem p02717 (python)

Fixed submission:
def resolve():
    a, b, c = map(int, open(0).read().split())
    tmp_a = a
    a = b
    b = tmp_a
    tmp_c = c
    c = a
    a = tmp_c
    print(a, b, c)
    
resolve()

Buggy submission (verdict: Runtime Error):
, M, *A = map(int, open(0).read().split())
vote = sum(A) / (4*M)
num = list(filter(lambda x: x > vote, A))
num = len(num)
if num >= M:
	print("Yes")
else:
	print("No")
Problem p02718 (python)

Fixed submission:
def resolve():
	N, M, *A = map(int, open(0).read().split())
	vote = sum(A) * (1 / (4*M))
	num = list(filter(lambda x: x >= vote, A))
	num = len(num)
	if num >= M:
		print("Yes")
	else:
		print("No")
resolve()

Buggy submission (verdict: Runtime Error):
, M, *A = map(int, open(0).read().split())
print(sum(A))
vote = sum(A) / (4*M)
num = list(filter(lambda x: x > vote, A))
num = len(num)
if num >= M:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
    N, M, *A = map(int, open(0).read().split())
    print(sum(A))
    vote = sum(A) / (4*M)
    num = list(filter(lambda x: x > vote, A))
    num = len(num)
    if num >= M:
      print("Yes")
    else:
      print("No")
Problem p03160 (python)

Fixed submission:
def resolve():
	N = int(input())
	H = list(map(int, input().split()))
	DP = [-1]*N
	DP[0], DP[1] = 0, abs(H[0] - H[1])
	for i in range(2, N):
		a = DP[i-2] + abs(H[i] - H[i-2])
		b = DP[i-1] + abs(H[i] - H[i - 1])
		DP[i] = min(a, b)
	print(DP[-1])
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n, k = map(int, input().split())
	h = list(map(int, input().split()))
	dp = [float('inf')]*n
	dp[0], dp[1] = 0, abs(h[0] - h[1])
	for i in range(2, n):
		s = []
		for j in range(1, k+1):
			if i-j >= 0:
				s.append(dp[i-j] + abs(h[i-j] - h[i]))
		dp[i] = min(s)
	print(dp[-1])
resolve()

Buggy submission (verdict: Runtime Error):
def search(i, h, dp):
	if i == 0 or i == 1:
		return dp[i]
	if dp[i] < float('inf'):
		return dp[i]
	a = search(i - 1, h, dp) + abs(h[i] - h[i-1])
	b = search(i - 2, h, dp) + abs(h[i] - h[i-2])
	dp[i] = min(a, b)
	return dp[i]

def resolve():
	N = int(input())
	H = list(map(int, input().split()))
	DP = [float('inf')]*N
	DP[0], DP[1] = 0, abs(H[0] - H[1])
	print(search(N-1, H, DP))
resolve()
Problem p03280 (python)

Fixed submission:
def resolve():
	a, b = map(int, input().split())
	print(a*b - (a+b-1))
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	s = input()
	k = int(input())
	if len(s) == 1:
		print(s)
		return

	for i in s:
		if int(i) == 1:
			continue
		print(i)
		return
resolve()
Problem p03288 (python)

Fixed submission:
def resolve():
	r = int(input())
	if r < 1200:
		return print('ABC')
	if r < 2800:
		return print('ARC')
	else:
		return print('AGC')
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	d, g = map(int, input().split())
	ps = []
	cs = []
	ans = 100**6
	for _ in range(d):
		p, c = map(int, input().split())
		ps.append(p)
		cs.append(c)
	for i in range(d-1, -1, -1):
		total = 0
		solved = 0
		for _ in range(ps[i]):
			if total >= g:
				if ans > solved:
					ans = solved
				break
			total += 100 * (i + 1)
			solved += 1
		total += cs[i]
		if total >= g and ans > solved:
			ans = solved
			break
		for j in range(d-1, -1, -1):
			if i == j:
				continue
			for _ in range(ps[j]):
				if total >= g:
					if ans > solved:
						ans = solved
					continue
				total += 100 * (j+1)
				solved += 1
			total += cs[j]
	print(ans)
resolve()
Problem p03290 (python)

Fixed submission:
def resolve():
	d, g = map(int, input().split())
	ps = []
	cs = []
	ans = 100**6
	for _ in range(d):
		p, c = map(int, input().split())
		ps.append(p)
		cs.append(c)
	for i in range(d-1, -1, -1):
		total = 0
		solved = 0
		for _ in range(ps[i]):
			if total >= g and ans > solved:
				ans = solved
			total += 100 * (i + 1)
			solved += 1
		total += cs[i]
		if total >= g and ans > solved:
			ans = solved
			break
		for j in range(1 << d):
			done = False
			t_solved = solved
			t_total = total
			for k in range(d-1, -1, -1):
				if (j >> k) & 1:
					if i == k:
						continue
					if done:
						break
					for _ in range(ps[k]):
						if done:
							break
						if t_total >= g and ans > t_solved:
							ans = t_solved
							done = True
							continue
						t_total += 100 * (k+1)
						t_solved += 1
					t_total += cs[k]
					if t_total >= g and ans > t_solved:
						ans = t_solved
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
import math

def resolve():
	d, g = map(int, input().split())
	ps = []
	cs = []
	ans = math.inf
	for _ in range(d):
		p, c = map(int, input().split())
		ps.append(p)
		cs.append(c)
	for i in range(d-1, -1, -1):
		total = 0
		solved = 0
		for _ in range(ps[i]):
			if total >= g:
				if ans > solved:
					ans = solved
				break
			total += 100 * (i + 1)
			solved += 1
		total += cs[i]
		if total >= g and ans > solved:
			ans = solved
			break
		for j in range(d-1, -1, -1):
			if i == j:
				continue
			for _ in range(ps[j]):
				if total >= g:
					if ans > solved:
						ans = solved
					continue
				total += 100 * (j+1)
				solved += 1
			total += cs[j]
	print(ans)
resolve()
Problem p03309 (python)

Fixed submission:
import statistics
def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	seq = []
	for i in range(1, n+1):
		seq.append(i-a[i-1])
	seq = sorted(seq)
	m = int(statistics.median(seq))
	ans = 0
	for i in seq:
		ans += abs(i-m)
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
import statistics
def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	seq = []
	for i in range(1, n+1):
		seq.append(abs(i-a[i-1]))
	seq = sorted(seq)
	m = statistics.median(seq)
	ans = 0
	for i in seq:
		ans += abs(i-m)
	print(ans)
resolve()
Problem p03339 (python)

Fixed submission:
from collections import Counter

def resolve():
	n = int(input())
	s = input()
	sum_e = [0]*(n+1)
	sum_w = [0]*(n+1)
	for i in range(n):
		ev = 1 if s[i] == 'E' else 0
		wv = 1 if s[i] == 'W' else 0
		sum_e[i+1] = sum_e[i] + ev
		sum_w[i+1] = sum_w[i] + wv
	ans = float('inf')
	if n == 2:
		print(1 if len(Counter(list(s)).keys()) == 2 else 0)
		return
	e_w = sum_e[-1] - sum_e[1]
	e_e = sum_w[n-1]
	ans = min(e_w, e_e)
	for i in range(n):
		v = sum_w[i-1] + (sum_e[-1] - sum_e[i])
		ans = min(ans, v)
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
from collections import Counter

def resolve():
	n = int(input())
	s = input()
	sum_e = [0]*(n+1)
	sum_w = [0]*(n+1)
	for i in range(n):
		ev = 1 if s[i] == 'E' else 0
		wv = 1 if s[i] == 'W' else 0
		sum_e[i+1] = sum_e[i] + ev
		sum_w[i+1] = sum_w[i] + wv
	ans = float('inf')
	if n == 2:
		print(1 if len(Counter(list(s)).keys()) == 2 else 0)
		return
	for i in range(n+1):
		if i == 0:
			v = sum_e[-1] - sum_e[i]
			ans = min(ans, v)
		else:
			v = sum_w[i-1] + (sum_e[-1] - sum_e[i+1])
			ans = min(ans, v)
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n = int(input())
	s = input()
	sum_e = [0]*(n+1)
	sum_w = [0]*(n+1)
	for i in range(n):
		ev = 1 if s[i] == 'E' else 0
		wv = 1 if s[i] == 'W' else 0
		sum_e[i+1] = sum_e[i] + ev
		sum_w[i+1] = sum_w[i] + wv
	ans = float('inf')
	if n == 2:
		print(1 if len(Counter(list(s)).keys()) == 2 else 0)
		return
	for i in range(n+1):
		if i == 0:
			v = sum_e[-1] - sum_e[i]
			ans = min(ans, v)
		else:
			v = sum_w[i-1] + (sum_e[-1] - sum_e[i+1])
			ans = min(ans, v)
	print(ans)
resolve()
Problem p03455 (python)

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

ans = 'Odd' if int(a) * int(b) % 2 else 'Even'
print(ans)

Buggy submission (verdict: Runtime Error):
s = map(lambda x: int(x), input().split())

ans = 'Odd' if s[0] * b[1] % 2 else 'Even'
print(ans)
Problem p03494 (python)

Fixed submission:
def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	ans = 0
	while True:
		again = True
		for i in range(n):
			if a[i] % 2:
				again = False
			a[i] = a[i] / 2
		if again:
			ans += 1
		else:
			break
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n = int(input())
	ws = [input() for _ in range(n)]
	cnt = []
	for w in ws:
		if w in cnt:
			print('No')
			return
		if len(cnt) and cnt[-1][-1] != w[-1]:
			print('No')
			return
		cnt.append(w)
	print('Yes')
resolve()
Problem p03495 (python)

Fixed submission:
from collections import Counter

def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	c = Counter(a)
	lc = len(c.keys())
	if lc > k:
		v = 0
		sc = sorted(c.values())
		for i in range(lc-k):
			v += sc[i]
		print(v)
	else:
		print(0)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	c = Counter(a)
	lc = len(c.keys())
	if lc > k:
		v = sum(sorted(c.values())[:k-1])
		print(v)
	else:
		print(0)
resolve()
Problem p03565 (python)

Fixed submission:
import copy

def check(s, t, k):
	for i in range(len(t)):
		if s[i+k] != t[i] and s[i+k] != '?':
			return False
	return True

def construct(s, t, k):
	ans = copy.deepcopy(s)
	for i in range(len(t)):
		ans[i+k] = t[i]
	for i in range(len(s)):
		if ans[i] == '?':
			ans[i] = 'a'
	return "".join(ans)

def resolve():
	s = list(input())
	t = list(input())
	ans = []
	if len(s) < len(t):
		print('UNRESTORABLE')
		return
	for i in range(len(s) - len(t) + 1):
		if check(s, t, i):
			ans.append(construct(s, t, i))
	if len(ans) >= 1:
		print(min(ans))
	else:
		print('UNRESTORABLE')
resolve()

Buggy submission (verdict: Runtime Error):
def check(s, t):
	for i in range(len(s)):
		if s[i] == t[i] or s[i] == '?':
			continue
		return False
	return True

def norm(s):
	ans = []
	for i in s:
		ans.append('a' if i == '?' else i)
	ans[0] = 'a'
	return "".join(ans)

def resolve():
	s = list(input())
	t = list(input())
	if len(s) < len(t):
		print('UNRESTORABLE')
		return
	for i in range(len(s) - len(t) + 1):
		if check(s[i:i+len(s)], t):
			for j in range(len(t)):
				s[i+j] = t[j]
			print(norm(s))
			return
	print('UNRESTORABLE')
resolve()

Buggy submission (verdict: Runtime Error):
def check(s, t):
	for i in range(len(s)):
		if s[i] == t[i] or s[i] == '?':
			continue
		return False
	return True

def norm(s):
	ans = []
	for i in s:
		ans.append('a' if i == '?' else i)
	ans[0] = 'a'
	return "".join(ans)

def resolve():
	s = list(input())
	t = list(input())
	for i in range(len(s) - len(t) + 1):
		if check(s[i:i+len(s)], t):
			for j in range(len(t)):
				s[i+j] = t[j]
			print(norm(s))
			return
	print('UNRESTORABLE')
resolve()
Problem p03597 (python)

Fixed submission:
def resolve():
	n = int(input())
	a = int(input())
	print(n**2 - a)
resolve()

Buggy submission (verdict: Runtime Error):
def dense(a, b):
	return b / (a+b)

def resolve():
	a, b, c, d, e, f = map(int, input().split())
	ws = set()
	ss = set()
	for i in range(31):
		for j in range(31):
			if a*100*i + b*100*j <= f:
				ws.add(a*100*i + b*100*j)
	for i in range(3001):
		for j in range(3001):
			if c*i + j*d <= f:
				ss.add(c*i + j*d)
	ans_w, ans_s = -1, 0
	lim = e / (100+e)
	for wv in ws:
		for sv in ss:
			if wv + sv > f:
				continue
			if wv + sv == 0:
				continue
			if lim >= dense(wv, sv):
				if dense(ans_w, ans_s) <= dense(wv, sv):
					ans_w, ans_s = wv, sv
	print(ans_w + ans_s, ans_s)
resolve()
Problem p03633 (python)

Fixed submission:
def gcd(a, b):
	"""Compute the greatest common divisor of a and b"""
	while b > 0:
		a, b = b, a % b
	return a

def lcm(a, b):
	"""Compute the lowest common multiple of a and b"""
	return a * b // gcd(a, b)

def resolve():
	n = int(input())
	T = []
	for _ in range(n):
		T.append(int(input()))
	ans = 1
	for i in range(n):
		ans = lcm(ans, T[i])
	print(int(ans))
resolve()

Buggy submission (verdict: Runtime Error):
from math import gcd

def resolve():
	n = int(input())
	ans = int(input())
	for i in range(n-1):
		v = int(input())
		ans = ans * v // gcd(ans, v)
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
from math import gcd

def resolve():
	n = int(input())
	ans = int(input())
	for i in range(n-1):
		v = int(input())
		ans = ans * v // gcd(ans, v)
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
	"""Compute the greatest common divisor of a and b"""
	while b > 0:
		a, b = b, a % b
	return a

def lcm(a, b):
	"""Compute the lowest common multiple of a and b"""
	return a * b / gcd(a, b)

def resolve():
	n = int(input())
	T = []
	for _ in range(n):
		T.append(int(input()))
	ans = 1
	for i in range(n):
		ans = lcm(ans, T[i])
	print(int(ans))
resolve()
Problem p03644 (python)

Fixed submission:
def resolve():
	n = int(input())
	ans = 0
	dp = [0]*(n+1)
	for i in range(1, n+1):
		if i % 2 == 0:
			dp[i] = dp[i//2] + 1
	print(dp.index(max(dp)) or 1)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n = int(input())
	ans = 0
	for i in range(1, n+1):
		if i % 2 == 0:
			ans += 1
	print(ans)
resolve()
Problem p03679 (python)

Fixed submission:
def resolve():
	x, a, b = map(int, input().split())
	if b - a > x:
		print('dangerous')
	elif a >= b:
		print('delicious')
	else:
		print('safe')
resolve()

Buggy submission (verdict: Runtime Error):
from math import factorial

def resolve():
	n, m = map(int, input().split())
	mod = 10**9+7
	if abs(n - m) > 1:
		print(0)
		return
	a = factorial(m) % mod * factorial(n) % mod
	if (n + m) % 2 == 0:
		a = a * 2 % mod
	print(a)
resolve()
Problem p03680 (python)

Fixed submission:
import sys
from io import StringIO
import unittest

sys.setrecursionlimit(10**6)

def rec(n, a, seen):
	if seen[n-1]:
		return -1
	if a[n-1] == 2:
		return seen.count(True) + 1
	seen[n-1] = True
	return rec(a[n-1], a, seen)

def resolve():
	n = int(input())
	a = []
	seen = [False]*n
	for _ in range(n):
		a.append(int(input()))
	print(rec(1, a, seen))
resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

sys.setrecursionlimit(10**5)

def rec(n, a, seen):
	if seen[n-1]:
		return -1
	if a[n-1] == 2:
		return seen.count(True) + 1
	seen[n-1] = True
	return rec(a[n-1], a, seen)

def resolve():
	n = int(input())
	a = []
	seen = [False]*n
	for _ in range(n):
		a.append(int(input()))
	print(rec(1, a, seen))
resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

sys.setrecursionlimit(100**5)

def rec(n, a, seen):
	if seen[n-1]:
		return -1
	if a[n-1] == 2:
		return seen.count(True) + 1
	seen[n-1] = True
	return rec(a[n-1], a, seen)

def resolve():
	n = int(input())
	a = []
	seen = [False]*n
	for _ in range(n):
		a.append(int(input()))
	print(rec(1, a, seen))
resolve()

Buggy submission (verdict: Runtime Error):
def rec(n, a, seen):
	if seen[n-1]:
		return -1
	if a[n-1] == 2:
		return seen.count(True) + 1
	seen[n-1] = True
	return rec(a[n-1], a, seen)

def resolve():
	n = int(input())
	a = []
	seen = [False]*n
	for i in range(n):
		a.append(int(input()))
	print(rec(1, a, seen))
resolve()
Problem p03681 (python)

Fixed submission:
from math import factorial

def resolve():
	n, m = map(int, input().split())
	mod = 10**9+7
	if abs(n - m) > 1:
		print(0)
		return
	a = factorial(m) % mod * factorial(n) % mod
	if (n + m) % 2 == 0:
		a = a * 2 % mod
	print(a)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n, m = map(int, input().split())
	mod = 10**9+7
	if abs(n - m) > 1:
		print(0)
		return
	a = factorial(m) % mod * factorial(n) % mod
	if (n + m) % 2 == 0:
		a = a * 2 % mod
	print(a)
resolve()
Problem p03730 (python)

Fixed submission:
def resolve():
	a, b, c = map(int, input().split())
	ans = "NO"
	for i in range(1, b+1):
		if i*a % b == c:
			ans = "YES"
			break
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
from math import gcd

def ngcd(nums):
	n = 0
	for i in nums:
		n = gcd(n, i)
	return n

def resolve():
	nums = list(map(int, input().split()))
	t = ngcd(nums)
	if t != 1:
		nums = [int(i/t) for i in nums]
	if gcd(nums[0], nums[1]) == 1:
		print("YES")
	else:
		print("NO")
resolve()

Buggy submission (verdict: Runtime Error):
from math import gcd

def ngcd(nums):
	n = 0
	for i in nums:
		n = gcd(n, i)
	return n

def resolve():
	nums = list(map(int, input().split()))
	t = ngcd(nums)
	if t != 1:
		nums = [int(i/t) for i in nums]
	if gcd(nums[0], nums[1]) == 1:
		print("YES")
	else:
		print("NO")
resolve()
Problem p03761 (python)

Fixed submission:
def cnt(s, b):
	ans = []
	for i in s:
		if i in b:
			ans.append(i)
	return ans

def resolve():
	n = int(input())
	h = []
	for i in range(n):
		h.append(input())
	ans = h[0]
	for i in range(1, n):
		sec = list(set(ans) & set(h[i]))
		tmp = ""
		for j in sec:
			tmp += j*min(ans.count(j), h[i].count(j))
		ans = tmp

	print("".join(sorted(ans)))
resolve()

Buggy submission (verdict: Runtime Error):
def cnt(s, b):
	ans = []
	for i in s:
		if i in b:
			ans.append(i)
	return ans

def intersection(lst1, lst2):
	lst3 = [value for value in lst1 if value in lst2]
	cnt1 = cnt(lst1, lst3)
	cnt2 = cnt(lst2, lst3)

	if len(cnt1) > len(cnt2):
		return cnt2
	else:
		return cnt1
resolve()
Problem p03814 (python)

Fixed submission:
def resolve():
	s = list(input())
	b = -1
	e = -1
	for i in range(len(s)):
		if s[i] == 'A' and b < 0:
			b = i
		if s[i] == 'Z':
			e = i
	if b == -1 or e == -1:
		print(0)
	else:
		print(e-b+1)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	s = input()
	a = float('inf')
	z = 0
	for i in s:
		if i == 'A':
			a = min(a, i)
		if i == 'Z':
			z = max(z, i)
	print(z - a + 1)
resolve()
Problem p03854 (python)

Fixed submission:
def resolve():
	s = input()
	w = ['dream', 'dreamer', 'erase', 'eraser']
	h = dict()
	for i in range(len(w)):
		h[w[i][::-1]] = True
	s = s[::-1]
	c = ''
	for i in s:
		c += i
		if h.get(c):
			c = ''
	if not len(c):
		print('YES')
	else:
		print('NO')
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	s = input()
	if re.search("^(dream|dreamer|erase|eraser)+$", s):
		print("YES")
	else:
		print("NO")
resolve()
Problem p03944 (python)

Fixed submission:
def resolve():
	w, h, n = map(int, input().split())
	r = [[True]*w for _ in range(h)]
	for _ in range(n):
		ix, iy, a = map(int, input().split())
		if a == 1:
			for i in range(h):
				for j in range(ix):
					r[i][j] = False
		elif a == 2:
			for i in range(h):
				for j in range(ix, w):
					r[i][j] = False
		elif a == 3:
			for i in range(iy):
				for j in range(w):
					r[i][j] = False
		else:
			for i in range(iy, h):
				for j in range(w):
					r[i][j] = False
	ans = 0

	for row in r:
		for i in row:
			if i:
				ans += 1
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	w, h, n = map(int, input().split())
	r = [[True]*w for _ in range(h)]
	for _ in range(n):
		ix, iy, a = map(int, input().split())
		if a == 1:
			for row in r:
				row[:ix] = [False]*ix
		elif a == 2:
			for row in r:
				row[ix:] = [False]*ix if ix > 0 else [False]*w
		elif a == 3:
			for i in range(iy):
				for j in range(w):
					r[i][j] = False
		else:
			for i in range(iy, h):
				for j in range(w):
					r[i][j] = False
	ans = 0

	for row in r:
		for i in row:
			if i:
				ans += 1
	print(ans)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	w, h, n = map(int, input().split())
	r = [[True]*w for _ in range(h)]
	for _ in range(n):
		ix, iy, a = map(int, input().split())
		if a == 1:
			for row in r:
				row[:ix] = [False]*ix
		elif a == 2:
			for row in r:
				row[ix:] = [False]*ix
		elif a == 3:
			for i in range(iy):
				for j in range(w):
					r[i][j] = False
		else:
			for i in range(iy, h):
				for j in range(w):
					r[i][j] = False
	ans = 0

	for row in r:
		for i in row:
			if i:
				ans += 1
	print(ans)
resolve()
Problem p03962 (python)

Fixed submission:
def resolve():
	s = input().split()
	uni = []
	for i in s:
		if i not in uni:
			uni.append(i)
	print(len(uni))
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n, k = map(int, input().split())
	if n == 1:
		print(k)
	else:
		print(k*((k-1)**(n-1)))
resolve()
Problem p03964 (python)

Fixed submission:

def resolve():
	n = int(input())
	v = []
	for _ in range(n):
		v.append(list(map(int, input().split())))
	t, a = 1, 1
	for i in range(n):
		tv, av = v[i]
		c = max(t//tv + (t%tv!=0), a//av + (a%av!=0))
		t, a = c*tv, c*av
	print(t+a)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n = int(input())
	v = []
	for _ in range(n):
		v.append(list(map(int, input().split())))
	t, a = 1, 1
	for i in range(n):
		tv, av = v[i]
		c = max(math.ceil(t/tv), math.ceil(a/av))
		t, a = c*tv, c*av
	print(t+a)
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n = int(input())
	v = []
	for _ in range(n):
		v.append(list(map(int, input().split())))
	t, a = v[0][0], v[0][1]
	for i in range(1, n):
		tv, av = v[i]
		c = max(math.ceil(t/tv), math.ceil(a/av))
		t, a = c*tv, c*av
	print(t+a)
resolve()
Problem p04031 (python)

Fixed submission:
def resolve():
	n = int(input())
	ans = 1000000
	a = list(map(int, input().split()))
	for i in range(-100, 101):
		tmp = 0

		for j in a:
			tmp += (j-i)**2
		if tmp < ans:
			ans = tmp
	print(ans)

resolve()

Buggy submission (verdict: Runtime Error):
import math

def resolve():
	_ = int(input())
	a = list(map(int, input().split()))
	ans = math.inf
	for i in range(-100, 101):
		s = 0
		for j in a:
			s += (i-j)**2
		if ans > s:
			ans = s
	print(ans)
resolve()
Problem p04044 (python)

Fixed submission:
def resolve():
	n, m = map(int, input().split())
	w = list()
	ans = ""
	for _ in range(n):
		w.append(input())
	w.sort()
	for word in w:
		ans += word
	print(ans)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n, m = map(int, input().split())
	w = list()
	ans = ""
	for _ in range(m):
		w.append(input())
	w.sort()
	for word in w:
		ans += word
	print(ans)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n, m = map(int, input().split())
	w = list()
	ans = ""
	for _ in range(m):
		w.append("".join(sorted(input())))
	w.sort()
	for word in w:
		ans += word
	print(ans)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n, m = map(int, input().split())
	w = list()
	for _ in range(m):
		w.append(input())
	w.sort()
	print("".join(w))

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
	n, m = map(int, input().split())
	w = list()
	for _ in range(m):
		w.append(input())
	w.sort()
	print("".join(w))
resolve()
Problem p02664 (python)

Fixed submission:
a = input()
t = list(a)
if t[len(t)-1] == "?":
    t[len(t)-1] = "D"
if t[0] == "?":
    if t[1] == "D" or t[1] == "?":
        t[0] = "P"
    else:
        t[0] = "D"
for i in range(1, len(t)-1):
    if t[i] == "?" and t[i-1] == "P":
        t[i] = "D"
    elif t[i] == "?" and t[i+1] == "D":
        t[i] = "P"
    elif t[i] == "?" and t[i+1] == "?":
        t[i] = "P"
    elif t[i] == "?":
        t[i] = "D"

answer = "".join(t)
print(answer)

Buggy submission (verdict: Runtime Error):
a = input()
t =list(a)
if t[0] == "?":
    if t[1] == "P":
        t[0] = "D"
    else:
        t[0] = "P"
if t[len(t)-1] == "?":
    t[len(t)-1] = "D"
for i in reversed(range(1,len(t)-1)):
    if t[i] == "?" and t[i+1] == "D":
        t[i] = "P"
    elif t[i] == "?":
        t[i] = "D"
answer = "".join(t)
print(answer)