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

Fixed submission:
n = int(input())
x = input()
k = x.count("1")
cnt = 0
s = int(x, 2)
if k >= 2:
	k1 = s % (k-1)
k2 = s % (k+1)
while s != 0:
	targ = bin(s).count("1")
	s = s % targ
	cnt += 1

def ev(n):
	cnt = 0
	while n != 0:
		m = bin(n).count("1")
		n = n % m
		cnt += 1
	return cnt

if k != 1:
	for i in range(n):
		if x[i] == "0":
			targ = k+1
			print(ev((k2+pow(2, n-i-1, targ)) % targ)+1)
		else:
			targ = k-1
			print(ev((k1-pow(2, n-i-1, targ)) % targ)+1)
else:
	for i in range(n):
		if x[i] == "0":
			targ = k+1
			print(ev((k2+pow(2, n-i-1, targ)) % targ)+1)
		else:
			targ = k-1
			print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = input()
k = x.count("1")
cnt = 0
s = int(x, 2)
if k != 1:
	k1 = s % (k-1)
k2 = s % (k+1)
while s != 0:
	targ = bin(s).count("1")
	s = s % targ
	cnt += 1

def ev(n):
	cnt = 0
	while n != 0:
		m = bin(n).count("1")
		n = n % m
		cnt += 1
	return cnt

for i in range(n):
	if x[i] == "0":
		targ = k+1
		print(ev((k2+pow(2, n-i-1, targ)) % targ)+1)
	else:
		targ = k-1
		print(ev((k1-pow(2, n-i-1, targ)) % targ)+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = input()
k = x.count("1")
cnt = 0
s = int(x, 2)
k1 = s % (k-1)
k2 = s % (k+1)
while s != 0:
	targ = bin(s).count("1")
	s = s % targ
	cnt += 1

def ev(n):
	cnt = 0
	while n != 0:
		m = bin(n).count("1")
		n = n % m
		cnt += 1
	return cnt

for i in range(n):
	if x[i] == "0":
		targ = k+1
		print(ev((k2+pow(2, n-i-1, targ)) % targ)+1)
	else:
		targ = k-1
		print(ev((k1-pow(2, n-i-1, targ)) % targ)+1)
Problem p02642 (python)

Fixed submission:
import itertools
from collections import Counter
h = int(input())
if h == 1:
	print(1)
	exit()
a = list(map(int,input().split()))
t = Counter(a)
b = []
for i, j in t.most_common():
	if j == 1:
		b.append(i)
bset = set(a)

def sieve(n):
	ret = []
	divlis = [-1]*(n+1)  # 何で割ったかのリスト(初期値は-1)
	flag = [True]*(n+1)
	flag[0] = False
	flag[1] = False
	ind = 2
	while ind <= n:
		if flag[ind]:
			ret.append(ind)
			ind2 = ind**2
			while ind2 <= n:
				flag[ind2] = False
				divlis[ind2] = ind
				ind2 += ind
		ind += 1
	#何で割ったかのリストを取得したいとき, divlisも出力する
	return ret

k = sieve(1000)

def pfact(m):
	pf = {}
	cnt = 0
	i = k[cnt]
	st = len(k)
	while m > 1 and cnt < st:
		i = k[cnt]
		while m%i == 0:
			pf[i] = pf.get(i,0) + 1
			m //= i
		cnt += 1
	if m>1 : pf[m]=1
	return pf

def makediv(n):
	s = pfact(n)
	k = [range(i+1) for i in s.values()]
	ansl = []
	for i in itertools.product(*k):
		ans = 1
		for n, j in enumerate(s.keys()):
			ans *= (j**i[n])
		ansl.append(ans)
	ansl.sort()
	return ansl

ans = 0
for i in b:
	t=makediv(i)
	t.remove(i)
	mode = 1
	for l in t:
		if l in bset:
			mode = 0
			break
	if mode:
		ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
from collections import Counter
h = int(input())
if h == 1:
	print(1)
	exit()
a = list(map(int,input().split()))
t = Counter(a)
b = []
for i, j in t.most_common():
	if j == 1:
		b.append(i)
bset = set(a)

def sieve(n):
	ret = []
	divlis = [-1]*(n+1)  # 何で割ったかのリスト(初期値は-1)
	flag = [True]*(n+1)
	flag[0] = False
	flag[1] = False
	ind = 2
	while ind <= n:
		if flag[ind]:
			ret.append(ind)
			ind2 = ind**2
			while ind2 <= n:
				flag[ind2] = False
				divlis[ind2] = ind
				ind2 += ind
		ind += 1
	#何で割ったかのリストを取得したいとき, divlisも出力する
	return ret

k = sieve(1000)

def pfact(m):
	pf = {}
	cnt = 0
	i = k[cnt]
	while m > 1:
		while m%i == 0:
			pf[i] = pf.get(i,0) + 1
			m //= i
		cnt += 1
		i = k[cnt]
	if m>1 : pf[m]=1
	return pf

def makediv(n):
	s = pfact(n)
	k = [range(i+1) for i in s.values()]
	ansl = []
	for i in itertools.product(*k):
		ans = 1
		for n, j in enumerate(s.keys()):
			ans *= (j**i[n])
		ansl.append(ans)
	ansl.sort()
	return ansl

ans = 0
for i in b:
	t=makediv(i)
	t.remove(i)
	mode = 1
	for l in t:
		if l in bset:
			mode = 0
			break
	if mode:
		ans += 1
print(ans)
Problem p02664 (python)

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

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

Buggy submission (verdict: Runtime Error):
t=list(input())
ans = 0
for i in range(len(t)):
	if i != 0 and i != len(t)-1:
		if t[i] == "?":
			if t[i-1] == "P":
				t[i] = "D"
			elif t[i+1] == "D" or "?":
				t[i] = "P"
			else:
				t[i] = "D"
	elif i==0:
		if t[i] == "?":
			if t[i+1] == "D" or "?":
				t[i] = "P"
			else:
				t[i] = "D"
	else:
		if t[i] == "?":
			t[i] = "D"
print("".join(t))
Problem p02717 (python)

Fixed submission:
x,y,z=map(int,input().split())
print(str(z)+" "+str(x)+" "+str(y))

Buggy submission (verdict: Runtime Error):
print(" ".join([map(str,input().split())]))

Buggy submission (verdict: Runtime Error):
d,s,r=map(int,input().split())
print(f"{r} {d} {s}")
Problem p02719 (python)

Fixed submission:
n,k=map(int,input().split())
if (n-k)!=0:
	print(min([abs(n%k), abs(abs(n%k)-k)]))
else:
	print("0")

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
print(min([n%abs(n-k), abs(n%abs(n-k)-k)]))
Problem p02742 (python)

Fixed submission:
h,w=map(int,input().split())
if h>=2 and w>=2:
	k=h//2
	s=h%2
	print(k*w+s*((w+1)//2))
else:
	print("1")

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
if k>=2 and s>=2:
	k=h//2
	s=h%2
	print(k*w+s*((w+1)//2))
else:
	print("1")
Problem p02783 (python)

Fixed submission:
h,a=map(int,input().split())
print(int(h/a+0.99995))

Buggy submission (verdict: Runtime Error):
h,a=map(int, input())
print(h//a+1)
Problem p02797 (python)

Fixed submission:
n,k,s = map(int,input().split())
if k == 0:
	if s != 10**9:
		print(" ".join([str(10**9) for _ in range(n)]))
	else:
		print(" ".join([str(1) for _ in range(n)]))
elif s != 10**9:
	ans = [10**9 for _ in range(n)]
	for i in range(k):
		ans[i] = s
	print(" ".join([str(ans[i]) for i in range(n)]))
else:
	ans = [1 for _ in range(n)]
	for i in range(k):
		ans[i] = s
	print(" ".join([str(ans[i]) for i in range(n)]))

Buggy submission (verdict: Runtime Error):
n,k,s = map(int,input().split())
if k == 0:
	if s != 10**9:
		print(" ".join([s+1 for _ in range(n)]))
	else:
		print(" ".join(1 for _ in range(n)))
elif s != 10**9:
	ans = [10**9 for _ in range(n)]
	for i in range(k):
		ans[i] = s
	print(" ".join([str(ans[i]) for i in range(n)]))
else:
	ans = [1 for _ in range(n)]
	for i in range(k):
		ans[i] = s
	print(" ".join([str(ans[i]) for i in range(n)]))

Buggy submission (verdict: Runtime Error):
n,k,s = map(int,input().split())
if k == 0:
	if s != 10**9:
		print(" ".join([s+1 for _ in range(n)]))
	else:
		print(" ".join([1] for _ in range(n)))
elif s != 10**9:
	ans = [10**9 for _ in range(n)]
	for i in range(k):
		ans[i] = s
	print(" ".join([str(ans[i]) for i in range(n)]))
else:
	ans = [1 for _ in range(n)]
	for i in range(k):
		ans[i] = s
	print(" ".join([str(ans[i]) for i in range(n)]))
Problem p02817 (python)

Fixed submission:
s,t=input().split()
print(t+s)

Buggy submission (verdict: Runtime Error):
import math
x=int(input())
primemode = True
while primemode:
  sos = True
  for n in range(math.floor(math.sqrt(x))):
    if n+1 != 1:
      if x%(n+1) == 0:
        sos = False
  if sos:
    primemode = False
  else:
    x = x+1
print(x)

Buggy submission (verdict: Runtime Error):
import math
x=int(input())
primemode = True
while primemode:
  x = x+1
  sos = True
  for n in range(math.floor(math.sqrt(x))):
    if n+1 != 1:
      if x%(n+1) == 0:
        sos = False
  if sos:
    primemode = False
print(x)

Buggy submission (verdict: Runtime Error):
a,b = input()
print(b+a)
Problem p02882 (python)

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

if b*a**2 == x:
	print(0)
	exit()

s = 2*x/(a*b)
if s < a:
	print(math.atan(b/s)/math.pi*180)
else:
	s = 2*b-2*x/(a**2)
	print(90-math.atan(a/s)/math.pi*180)

Buggy submission (verdict: Runtime Error):
import math
a,b,x = map(int,input().split())
s = 2*x/(a*b)
if s < a:
	print(math.atan(b/s)/math.pi*180)
else:
	s = 2*b-2*x/(a**2)
	print(90-math.atan(a/s)/math.pi*180)
Problem p03048 (python)

Fixed submission:
ans = 0
r,g,b,n = map(int,input().split())
for i in range(n//r+1):
	targ = i*r
	for j in range(n//g+1):
		if (n-i*r-j*g) % b == 0 and (n-i*r-j*g) >= 0:
			ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
ans = 0
r,g,b,n = map(int,input().split())
for i in range(n//r+1):
	targ = i*r
	for j in range(n//g+1):
		if (n-i*r-j*g) % b == 0 and (n-i*r-j*g) >= 0:
			ans += 1
print(ans)
Problem p03160 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
val1 = [0 for _ in range(n)]
val2 = [0 for _ in range(n)]
val = [0 for _ in range(n)]
for i in range(n):
	if i + 1 <= n - 1:
		val1[i] = abs(h[i] - h[i + 1])
	if i + 2 <= n - 1:
		val2[i] = abs(h[i] - h[i + 2])
for i in range(n):
	if i-2 >= 0:
		val[i] = min([val[i-1]+val1[i-1], val[i-2]+val2[i-2]])
	elif i-1 >= 0:
		val[i] = val[i-1]+val1[i-1]
print(val[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
v=[0 for _ in range(n)]
w=[0 for _ in range(n)]
for i in range(n):
	w[i],v[i] = map(int,input().split())
 
dp = [[0 for i in range(k+1)] for j in range(n+1)]
 
for i in range(n):
	for j in range(k+1):
		if j-w[i] < 0:
			dp[i+1][j] = dp[i][j]
		else:
			dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
print(dp[n][k])
Problem p03163 (python)

Fixed submission:
n,k=map(int,input().split())
v=[0 for _ in range(n)]
w=[0 for _ in range(n)]
for i in range(n):
	w[i],v[i] = map(int,input().split())

dp = [[0 for i in range(k+1)] for j in range(n+1)]

for i in range(n):
	for j in range(k+1):
		if j-w[i] < 0:
			dp[i+1][j] = dp[i][j]
		else:
			dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
print(dp[n][k])

Buggy submission (verdict: Runtime Error):
import numpy as np

n,k=map(int,input().split())
v=[0 for _ in range(n)]
w=[0 for _ in range(n)]
for i in range(n):
	w[i],v[i] = map(int,input().split())

dp = np.full((n+1, k+1), 0, dtype=np.int64)

for i in range(n):
	for j in range(k+1):
		if j-w[i] < 0:
			dp[i+1][j] = dp[i][j]
		else:
			dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
print(dp[n][k])
Problem p03379 (python)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
a = x[:]
a.sort()
kijun = a[n//2]
a1 = a[n//2]
a2 = a[n//2-1]
for i in x:
	if i < kijun:
		print(a1)
	else:
		print(a2)

Buggy submission (verdict: Runtime Error):
import statistics
n = int(input())
x = list(map(int,input().split()))
a = x[:]
a.sort()
kijun = a[n//2]
a1 = a[n//2]
a2 = a[n//2-1]
for i in x:
	if i < kijun:
		print(a1)
	else:
		print(a2)
Problem p03701 (python)

Fixed submission:
n = int(input())
s = [int(input()) for _ in range(n)]
k = sum(s)
if k % 10 != 0:
	print(k)
else:
	for i in sorted(s):
		if i % 10 != 0:
			print(k-i)
			exit()
	print(0)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [int(input()) for _ in range(n)]
"""
b := ruisekiwa
b[r]-b[l] >= (r-l)k
b[r]-rk >= b[l]-lk (1-indexed)
c := b[i]-ik
"""
b = [0 for _ in range(n)]
b[0] = a[0]
for i in range(1, n):
	b[i] = b[i-1] + a[i]
 
c = [b[i]-(i+1)*k for i in range(n)]
 
"""
cr >= cl なる ペア(l, r)の個数を求めたい.
for i in range(n), find (i,j)
"""
 
class BIT:
	"""
	<Attention> 0-indexed.
	query ... return the sum [0 to m]
	sum ... return the sum [a to b]
	sumall ... return the sum [all]
	add ... 'add' number to element (be careful that it doesn't set a value.)
	search ... the sum version of bisect.right
	output ... return the n-th element
	listout ... return the BIT list
	"""
	def query(self, m):
		res = 0
		while m > 0:
			res += self.bit[m]
			m -= m&(-m)
		return res
	
	def sum(self, a, b):
		return self.query(b)-self.query(a)
	
	def sumall(self):
		bitlen = self.bitlen-1
		return self.query(bitlen)
 
	def add(self, m, x):
		m += 1
		bitlen = len(self.bit)
		while m <= bitlen-1:
			self.bit[m] += x
			m += m&(-m)
		return
	
	def search(self, a):
		tmpsum = 0
		i = 0
		k = (self.bitlen-1).bit_length()
		while k >= 0:
			tmpk = 2**k
			if i+tmpk <= self.bitlen-1:
				if tmpsum + self.bit[i+tmpk] < a:
					tmpsum += self.bit[i+tmpk]
					i += tmpk
			k = k - 1
		return i+1
	
	def output(self, a):
		return self.query(a+1)-self.query(a)
	
	def listout(self):
		return self.bit
	
	def __init__(self, a):
		self.bitlen = len(a)+1
		self.bit = [0]*(len(a)+1)
		for i, j in enumerate(a):
			self.add(i, j)
 
def compress(arr):
	*XS, = set(arr)
	XS.sort()
	target = {e: i for i, e in enumerate(XS)}
	rtl = []
	for i in range(n):
		rtl.append(target[arr[i]])
	return rtl
 
d = compress(c)
 
bit = BIT([0 for _ in range(n)])
ans = 0
for i in range(n):
	bit.add(d[i], 1)
	ans += bit.query(d[i]+1)
	if c[i] < 0:
		ans -= 1
print(ans)
Problem p03712 (python)

Fixed submission:
h,w = map(int, input().split())
print("#"*(w+2))
for i in range(h):
  print("#"+input()+"#")
print("#"*(w+2))

Buggy submission (verdict: Runtime Error):
h,w = map(int, input().split())
a = [[] for _ in range(h)]
for i in range(h):
  a[h] = list(map(str, input().split()))
print("#"*(w+2))
for i in range(h):
  print("#"+a[h].join("")+"#")
print("#"*(w+2))
Problem p02694 (python)

Fixed submission:
import math
x = int(input())
now = 100
ans = 0
while(now < x):
    ans += 1
    now += now//100
print(ans)

Buggy submission (verdict: Runtime Error):
import math
x = int(raw_input())
now = 100
ans = 0
while(now < x):
    ans += 1
    now *= 1.01
    now = math.floor(now)
print(ans)
Problem p03261 (python)

Fixed submission:
n = int(input())

ans = 'Yes'

w = []

for i in range(n):
	a = input()
	if a in w:
		ans = 'No'
	else:
		w.append(a)
b = w[0]
c = w[1:]
for i in c:
	if i[0] == b[-1]:
		b = i
	else:
		ans = 'No'
		break
print(ans)

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

ans = 'Yes'

w = []

for i in range(n):
	a = input()
	if a in w:
		ans = 'No'
	else:
		w.append(a)

if n == 2:
	if w[0][-1] != w[1][0]:
		ans = 'No'
elif n == 3:
	if w[0][-1] != w[1][0]:
		ans = 'No'
	if w[1][-1] != w[2][0]:
		ans = 'No'
else:
	for i in range(1,n-2):
		print(i)
		if b[-1] == w[i][0]:
			b = w[i]
		else:
			ans = 'No'
print(ans)
Problem p03263 (python)

Fixed submission:
h,w = map(int,input().split())

a = []

for i in range(h):
	a.append(list(map(int,input().split())))
ans = []
for i in range(h):
	for j in range(w-1):
		if a[i][j] % 2 == 1:
			a[i][j+1] += 1
			ans.append([i+1,j+1,i+1,j+2])

for k in range(h-1):
	if a[k][w-1] % 2 == 1:
		a[k+1][w-1] += 1
		ans.append([k+1,w,k+2,w])
print(len(ans))
for i in ans:
	print(i[0],i[1],i[2],i[3])

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())

a = []
for i in range(h):
	b = list(map(int,input().split()))
	b = [i%2 for i in b]
	a.append(b)

ans = []
for i in range(h):
	for j in range(w-1):
		if a[i][j] == 1:
			a[i][j+1] += 1
			ans.append([i+1,j+1,i+1,j+2])
if w != 2:
	for i in range(h-1):
		if a[i][-1] == 1:
			a[i+1][j] += 1
			ans.append([i+1,w,i+2,w])


print(len(ans))

for i in ans:
	print(i[0],i[1],i[2],i[3])
Problem p03274 (python)

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

x = list(map(int,input().split()))
ans = 100000000000000

a = 0
while a != n:
	if x[a] >= 0:
		break
	a += 1
for i in range(max(0,a-k),n-k+1):
	if x[i+k-1] <= 0:
		ans = min(ans,-x[i])
	elif x[i] >= 0:
		ans = min(x[i+k-1],ans)
	else:
		ans = min(x[i+k-1]-x[i]+min(-x[i],x[i+k-1]),ans)
print(ans)

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

x = list(map(int,input().split()))
ans = 100000000000000


for i in range(n-k+1):
	if x[i+k-1] <= 0:
		ans = min(ans,-x[i])
	elif x[i] >= 0:
		ans = min(x[i+k-1],ans)
	else:
		ans = min(x[i+k-1]-x[i]+min(abs(x[i]),x[i+k-1]))
print(ans)
Problem p03379 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
for i in range(n):
    if b[int(n/2)] <= a[i]:
        print(b[int(n/2)-1])
    else:
        print(b[int(n/2)])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
for i in range(n):
    if b[int(n/2)+1] <= a[i]:
        print(b[int(n/2)-1])
    else:
        print(b[int(n/2)])
Problem p03427 (python)

Fixed submission:
a =input()

b = [int(x) for x in list(a)]
if len(a) == 1:
    print(int(a))
elif len(a) == a[1:].count('9') + 1:
    print(sum(b))
else:
    print(int(b[0])-1+(len(a)-1)*9)

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

b = [x for x in list(a)]
if len(a) == 1:
    print(int(a))
elif len(a) == a[1:].count('9') + 1:
    print(sum(b))
else:
    print(int(b[0])-1+(len(a)-1)*9)
Problem p03470 (python)

Fixed submission:
n = int(input())
a = []
b = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    if a[i] in b:
        continue
    else:
        b.append(a[i])
print(len(b))

Buggy submission (verdict: Runtime Error):
a = []
b = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    if a[i] in b:
        continue
    else:
        b.append(a[i])
print(len(b))
Problem p03545 (python)

Fixed submission:
n = input()

a = ['+','-']
b = ''
for i in a:
    for j in a:
        for k in a:
            if eval(n[0]+i+n[1]+j+n[2]+k+n[3]) == 7:
                b =n[0]+i+n[1]+j+n[2]+k+n[3]+'=7'
                break
print(b)

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

a = ['+','-']

b = ''
ans = ''
for i in a:
    b += n[0]+i
    for j in a:
        b += n[1]+j
        for k in a:
            b += n[2]+k+n[3]
            if eval(b) == 7:
                ans = b+'=7'
            else:
                b = ''
print(ans)
Problem p03559 (python)

Fixed submission:
n = int(input())

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

d = 0
e = 0
ans = 0
for i in b:
    while i > a[min(d,n-1)] and d <= n-1:
        d += 1
    while i >= c[min(e,n-1)] and e < n:
        e += 1
    ans += d*(n-e)

print(ans)

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

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

d = 0
e = 0
ans = 0
for i in b:
    while i > a[min(d,n-1)] and d <= n-1:
        d += 1
    while i >= c[e] and e < n:
        e += 1
    ans += d*(n-e)

print(ans)
Problem p03563 (python)

Fixed submission:
a= int(input())
b= int(input())
print(2*b-a)

Buggy submission (verdict: Runtime Error):
a, b= list(map(int,input().split()))
print(2*b-a)
Problem p03565 (python)

Fixed submission:
s = input()
t = input()
a =[]
for i in range(len(s)-len(t)+1):
    f = True
    for j in range(len(t)):
        if s[i+j] != '?' and s[i+j] != t[j]:
            f = False
    if f == True:
        a.append(i)

s = s.replace('?','a')
if len(a) !=0:
    print(s[:a[-1]]+t+s[a[-1]+len(t):])
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
a =[]
for i in range(len(s)-len(t)+1):
    f = True
    for j in range(len(t)):
        if s[i+j] != '?' and s[i+j] != t[j]:
            f = False
    if f == True:
        a.append(i)

s = s.replace('?','a')

print(s[:a[-1]]+t+s[a[-1]+len(t):])
Problem p03613 (python)

Fixed submission:
n = int(input())

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

b ={i:0 for i in range(min(min(a),-1),max(a)+10)}
for i in a:
    b[i] += 1


c = 0
for i in range(len(b)-3):
    c = max(c,b[i]+b[i+1]+b[i+2])
print(c)

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

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

b ={i:0 for i in range(min(a)-1,max(a)+10)}

for i in a:
    b[i] += 1

c = 0
for i in range(1,len(b)-3):
    c = max(c,b[i]+b[i+1]+b[i+2])
print(c)
Problem p03633 (python)

Fixed submission:
def gcd(x,y):
	while y != 0:
		x , y = y , x % y
	return x

def lcm(x,y):
    return x*y//gcd(x,y)


n = int(input())

a =[]
for i in range(n):
    a.append(int(input()))

for i in range(n-1):
    a[i+1] = lcm(a[i],a[i+1])
print(a[-1])

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
	while y != 0:
		x , y = y , x % y
	return x

def lcm(x,y):
    return int(x*y/gcd(x,y))


n = int(input())

a =[]
for i in range(n):
    a.append(int(input()))

for i in range(n-1):
    a[i+1] = lcm(a[i],a[i+1])
print(a[-1])
Problem p03695 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b =[]
countmax = 0
countmin = 0

for i in range(n):
    b.append(a[i]//400)
for i in range(13):
    if b.count(i) >=1:
        if i<= 7:
            countmax +=1
            countmin +=1
        else:
            countmax += b.count(i)
print(max(1,countmin),countmax)

Buggy submission (verdict: Runtime Error):
for i in range(n):
    b.append(a[i]//400)
for i in range(13):
    if b.count(i) >=1:
        if i<= 7:
            countmax +=1
            countmin +=1
        else:
            countmax += b.count(i)
print(countmin,countmax)
Problem p03777 (python)

Fixed submission:
a, b = list(input().split())
if b == 'H':
    print(a)
elif a == b:
    print('H')
else:
    print('D')

Buggy submission (verdict: Runtime Error):
if b == 'H':
    print(a)
elif a == b:
    print('H')
else:
    print('D')
Problem p03797 (python)

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

if s >= c//2:
    print(c//2)
else:
    print((2*s+c)//4)

Buggy submission (verdict: Runtime Error):
if s >= c//2:
    print(c//2)
else:
    print((2*s+c)//4)
Problem p03815 (python)

Fixed submission:
a = int(input())
ans =a // 11 *2
b = a % 11
if b == 0:
    print(ans)
elif b <= 6:
    print(ans+1)
else:
    print(ans+2)

Buggy submission (verdict: Runtime Error):
a = int(input())
ans =a // 11 *2
b = a % 11
if b == 0:
    print(ans)
elif b <= 6:
    print(ans+1)
else:
    print(num+2)
Problem p03920 (python)

Fixed submission:
n = int(input())
a = 0
for i in range(n+1):
    if i*(i+1)//2 >= n:
        a = i
        break

b=[]
c = a*(a+1)//2
for i in range(1,a+1):
    b.append(i)


if c > n:
    b.pop(c-n-1)

for i in b:
    print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int((2*n)**0.5)+1
b = int((a*(a+1))/2)-n
c = [i for i in range(1,a+1)]
c.remove(b)
for i in c:
    print(i)
Problem p03929 (python)

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

a = 4;b = 2;c = 0;d = 9;e = 7
f = [a,b,c,d,e]
ans = 0
for i in range((n-2)%11):
	if k in (a,b,c,d,e):
		ans += 1
	a = (a+8)%11
	b = (b+8)%11
	c = (c+8)%11
	d = (d+8)%11
	e = (e+8)%11

print(ans+((n-2)//11)*5)

Buggy submission (verdict: Runtime Error):
a = 4;b = 2;c = 0;d = 9;e = 7
f = [a,b,c,d,e]
ans = 0
for i in range((n-2)%11):
	if k in (a,b,c,d,e):
		ans += 1
	a = (a+8)%11
	b = (b+8)%11
	c = (c+8)%11
	d = (d+8)%11
	e = (e+8)%11

print(ans+((n-2)//11)*5)
Problem p03998 (python)

Fixed submission:

a = input()
b = input()
c = input()

d = a[0]
a = a[1:]
while True:
    if d == "a":
        if len(a) == 0:
            print("A")
            break
        d = a[0]
        a = a[1:]
    if d == "b":
        if len(b) == 0:
            print("B")
            break
        d = b[0]
        b = b[1:]
    if d == "c":
        if len(c) == 0:
            print("C")
            break
        d = c[0]
        c = c[1:]

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

d = a[0]
a.pop(0)
while True:
    if d == "a":
        if len(a) == 0:
            print("A")
            break
        d = a[0]
        a.pop(0)
    if d == "b":
        if len(b) == 0:
            print("B")
            break
        d = b[0]
        b.pop(0)
    if d == "c":
        if len(c) == 0:
            print("C")
            break
        d = c[0]
        c.pop(0)