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

Fixed submission:
# 1行、2変数を受け取るとき
X, Y, Z = map(int, input().split())

print("{} {} {}".format(Z, X, Y))

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

def isRunRun(X):
    x = str(X)
    sa = 0
    for i in range(len(x)-1):
        if abs(int(x[i]) - int(x[i+1])) > 1:
            return False
    return True

if K > 23527:
    num = 99999999
    count = 23527
elif K > 10000:
    num = 22111101
    count = 10000
elif K > 5000:
    num = 110111
    count = 1000
else:
    num = 1
    count = 0

while count < K:
    if isRunRun(num):
        count += 1
    num += 1

print(num-1)

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

def isRunRun(X):
    x = str(X)
    sa = 0
    for i in range(len(x)-1):
        if abs(int(x[i]) - int(x[i+1])) > 1:
            return False
    return True

if K > 10000:
    num = 22111101
    count = 10000
elif K > 5000:
    num = 110111
    count = 1000
else:
    num = 1
    count = 0

while count < K:
    if isRunRun(num):
        count += 1
    num += 1

print(num-1)

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

def isRunRun(X):
    x = str(X)
    sa = 0
    for i in range(len(x)-1):
        if abs(int(x[i]) - int(x[i+1])) > 1:
            return False
    return True


if K < 1000:
    num = 1
    count = 0
elif K < 5000:
    num = 110111
    count = 1000
elif K < 10000:
    num = 22111101
    count = 10000


while count < K:
    if isRunRun(num):
        count += 1
    num += 1

print(num-1)

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

if len([c for c in A if c >= sum(A) / (4 * M)]) >= M:
    print("Yes")
else:
    print("No")

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

if len([c for c in A if c > sum(A) / (4 * M)]) > M:
    print("Yes")
else:
    print("No")
Problem p02724 (python)

Fixed submission:
# 1行、1変数を受け取るとき
s = int(input())
print((int(s / 500) * 1000) + (int(s % 500 / 5) * 5))

Buggy submission (verdict: Runtime Error):
# 1行、1変数を受け取るとき
s = int(input())

print(int(s / 500) * 1000) + (int(s % 10 / 5) * 5)
Problem p02706 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=sum(a)
print(max(-1,n-b))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input())
a=list(map(int,input().split()))
b=sum(a)
print(max(-1,n-b))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input())
a=list(map(int,input().split()))
b=sum(a)
print(max(0,n-b))
Problem p02837 (python)

Fixed submission:
n=int(input())
a=[]
d=[]
for i in range(n):
  c=[]
  b=int(input())
  d.append(b)
  for j in range(b):
    c.append(list(map(int,input().split())))
  a.append(c)


count=0
for i in range(2**n):
  x=[0]*n
  pre=0
  for j in range(n):
    if ((i>>j)&1):
      x[n-1-j]=1 
      for l in range(d[j]):
        if ((i>>(a[j][l][0]-1))&1)!=a[j][l][1]:
          pre+=1
  if pre!=0:
    count=count
  else:
    count=max(count,x.count(1))
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
d=[]
for i in range(n):
  c=[]
  b=int(input())
  d.append(b)
  for j in range(b):
    c.append(list(map(int,input().split())))
  a.append(c)


count=0
for i in range(2**n):
  x=[0]*n
  pre=0
  for j in range(n):
    if ((i>>j)&1):
      x[n-1-j]=1 
      for l in range(d[n-1-j]):
        if ((i>>(a[j][l][0]-1))&1)!=a[j][l][1]:
          pre+=1
  if pre!=0:
    count=count
  else:
    count=max(count,x.count(1))
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
d=[]
for i in range(n):
  c=[]
  b=int(input())
  d.append(b)
  for j in range(b):
    c.append(list(map(int,input().split())))
  a.append(c)


count=0
for i in range(2**n):
  x=[0]*n
  for j in range(n):
    if ((i>>j)&1):
      x[n-1-j]=1 


  pre=0
  for k in range(n):
    for l in range(d[n-1]):
      #print([x[a[k][l][0]-1],a[k][l][1]])
      if ((x[k]==1 and x[a[k][l][0]-1]!=a[k][l][1]) or 
          (x[k]==0 and x[a[k][l][0]-1]==a[k][l][1])):
        pre+=1
  if pre!=0:
    count=count
  else:
    count=max(count,x.count(1))
print(count)
Problem p02845 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
x=[0,0,0]
count=1
mod=10**9+7
for i in range(n):
  if x[0]==0 and a[i]==0:
    x[0]+=1
    count=count*3
  elif x[1]==0 and a[i]==0:
    x[1]+=1
    count=count*2
  elif x[2]==0 and a[i]==0:
    x[2]+=1
    count=count*1
  else:
    if x.count(a[i])==0:
      count=0
      break
    else:
      count=count*x.count(a[i])
      x[x.index(a[i])]+=1
print(count%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
x=[0,0,0]
count=1
mod=10**9+7
for i in range(n):
  if x[0]==0 and a[i]==0:
    x[0]+=1
    count=count*3
  elif x[1]==0 and a[i]==0:
    x[1]+=1
    count=count*2
  elif x[2]==0 and a[i]==0:
    x[2]+=1
    count=count*1
  else:
    count=count*x.count(a[i])
    x[x.index(a[i])]+=1
print(count%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
x=[0,0,0]
count=1
for i in range(n):
  if x[0]==0 and a[i]==0:
    x[0]+=1
    count*=3
  elif x[1]==0 and a[i]==0:
    x[1]+=1
    count*=2
  elif x[2]==0 and a[i]==0:
    x[2]+=1
    count*=1
  else:
    count*=x.count(a[i])
    x[x.index(a[i])]+=1
print(count%(10**9+7))
Problem p03005 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

counter = 0
for i in range(N):
    a = x[i]-x[0]
    b = y[i]-y[0]
    for j in range(1,N):
        for k in range(j,N):
            if a == x[j]-x[k] and b == y[j]-y[k]:
                counter += 1
if N==2:
  print(1)
else:
  print(counter-1)
Problem p03029 (python)

Fixed submission:
a,p = map(int,input().split())
z = a*3+p
if z % 2 == 0:
  print(int(z/2))
else:
  print(int((z-1)/2))

Buggy submission (verdict: Runtime Error):
a,p = map(int,input().split())
z = a*3+p
if z % 2 = 0:
  print(int(z/2))
else:
  print(int((z-1)/2))

Buggy submission (verdict: Runtime Error):
a,p = map(int,input().split())
z = a*3+p
if z % 2 = 0:
  print(z/2)
else:
  print((z-1)/2)
Problem p03711 (python)

Fixed submission:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
x,y=map(int,input().split())
if a.count(x)==a.count(y) and b.count(x)==b.count(y) and c.count(x)==c.count(y):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
x,y=map(int,input())
if a.count(x)==a.count(y) and b.count(x)==b.count(y) and c.count(x)==c.count(y):
  print('Yes')
else:
  print('No')
Problem p03720 (python)

Fixed submission:
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
for j in range(n):
  print(a.count(j+1)+b.count(j+1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(m):
  a[i],b[i]=map(int,input().split())
for j in range(n):
  print(a.count(j+1)+b.count(j+1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())
for j in range(m):
  print(a.count(m+1)+b.count(m+1))
Problem p02924 (python)

Fixed submission:
a=int(input())

print(((a - 1) * a // 2))

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

print(long((a - 1) * a / 2))
Problem p03074 (python)

Fixed submission:
import numpy as np
n,k = map(int,input().split())	
s=list(input())	

li = []
is1s = False
if s[0] == "1":
    is1s = True
cnt0 = 0
cnt1 = 0
for i in range(len(s)):
    if s[i] == "0" :
        cnt0 += 1
    elif s[i] == "1":
        cnt1 += 1
    if i >= 1:
        if s[i] == "0" and s[i-1] == "1":
            li.append(cnt1)
            cnt1 = 0
        elif s[i] == "1" and s[i-1] == "0": 
            li.append(cnt0)
            cnt0 = 0

if (cnt1 > 0):
    li.append(cnt1)
if (cnt0 > 0):
    li.append(cnt0)
pivot = 2 * k 
li = np.array(li)
anslist=[]
if(is1s):
    for i in range(len(li)):
        if(i % 2 == 0):
            tmp = np.sum(li[i:min(len(li), i+pivot+1)])
            anslist.append(tmp)
else:
    for i in range(len(li)):
        if(i % 2 == 1):
            tmp = np.sum(li[i:min(len(li), i+pivot+1)])
            anslist.append(tmp)
    anslist.append(sum(li[0:pivot]))

print(max(anslist))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k = map(int,input().split())	
s=list(input())	

li = []
is1s = False
if s[0] == "1":
    is1s = True
cnt0 = 0
cnt1 = 0
for i in range(len(s)):
    if s[i] == "0" :
        cnt0 += 1
    if s[i] == "1":
        cnt1 += 1
    if i >= 1:
        if s[i] == "0" and s[i-1] == "1":
            li.append(cnt1)
            cnt1 = 0
        if s[i] == "1" and s[i-1] == "0": 
            li.append(cnt0)
            cnt0 = 0

if (cnt1 > 0):
    li.append(cnt1)
if (cnt0 > 0):
    li.append(cnt0)
pivot = 2 * k 
li = np.array(li)
anslist=[]
if(is1s):
    for i in range(len(li)):
        if(i % 2 == 0):
            tmp = np.sum(li[i:min(len(li), i+pivot+1)])
            anslist.append(tmp)
else:
    for i in range(len(li)):
        if(i % 2 == 1):
            tmp = np.sum(li[i:min(len(li), i+pivot+1)])
            anslist.append(tmp)
    anslist.append(sum(li[0:pivot]))

print(max(anslist))
Problem p03241 (python)

Fixed submission:



def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


x,n = map(int,input().split())
if x == 1 and n == 1:
    print(1)
    exit()
fct = factorize(n)


divlist=[]
for div in divisorize(fct):
    divlist.append(num(div))

divlist.sort()
ans = 1
for i in range(0,len(divlist)):
    if divlist[i] <= n/x:
        ans = divlist[i]
print(ans)

Buggy submission (verdict: Runtime Error):



def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


x,n = map(int,input().split())
fct = factorize(n)


divlist=[]
for div in divisorize(fct):
    divlist.append(num(div))

divlist.sort()
ans = 1
for i in range(0,len(divlist)):
    if divlist[i] <= n/x:
        ans = divlist[i]
print(ans)
Problem p02818 (python)

Fixed submission:
a, b, k = map(int, input().split())
 
if a >= k:
    print(a - k, b)
else:
    print(0, max(0, b - k + a))

Buggy submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
ea=min(A,K)
A-=ea
K-=ea
eb=min(B,K)
B-=eb
k-=eb
print(A,B)
Problem p03963 (python)

Fixed submission:
n,k=map(int,input().split())
print(k*(k-1)**(n-1))

Buggy submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
if n % k == 0:
	x= n//k
    print(x*math.factorial(k))
"""else:
	r= n % k
	div=n-r
	y=div//k
	sum= y*(math.factorial(k))
	z=nCr(k,r)
	sum+=z
	print(sum)
    """


def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)

Buggy submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
if n % k == 0:
	x= n//k
	print(x*math.factorial(k))
else:
	r= n % k
	div=n-r
	y=div//k
	sum= y*(math.factorial(k))
	z=nCr(k,r)
	sum+=z
	print(sum)


def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)
Problem p02705 (python)

Fixed submission:
from math import pi
n = int(input())
print(2 * pi * n)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
print(n * 2 * math.p)
Problem p02706 (python)

Fixed submission:
input_line = input().split(' ')
input_line = list(map(int, input_line))
input_assign = input().split(' ')
input_assign = list(map(int, input_assign))

len = input_line[0] - sum(input_assign)
if len < 0:
  print(-1)
else:
  print(len)

Buggy submission (verdict: Runtime Error):
input_line = int(input())
ans = [0] * input_line

inputs = input().split(' ')
inputs = list(map(int, inputs))
for e in inputs:
  for i in range(1, input_line):
    if e == i:
      ans[i] += 1

for i in range(len(ans)):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
input_line = input().split(' ')
days = input_line[0]
assignments = input_line[1]

input_assign = input().split(' ')

how_many_days = sum(input_assign)

len = days - how_many_days
if len < 0:
  print(-1)
else:
  print(len)
Problem p02802 (python)

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


N = input_int_list[0]
M = input_int_list[1]

Q_ans_list = [0] * (N+1)

ans_correct = 0
ans_penalty = 0

for i in range(M):
	input_list_i = list( input().split())
	Q_num = int(input_list_i[0])
	if input_list_i[1] == "WA":
		if Q_ans_list[Q_num] != -1:
			Q_ans_list[Q_num] = Q_ans_list[Q_num] + 1
	elif input_list_i[1] == "AC":
		if Q_ans_list[Q_num] != -1:
			ans_correct = ans_correct + 1
			ans_penalty = ans_penalty + Q_ans_list[Q_num]
			Q_ans_list[Q_num] = -1





print(ans_correct,ans_penalty)

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


N = input_int_list[0]
M = input_int_list[1]

Q_ans_list = [0] * N

ans_correct = 0
ans_penalty = 0

for i in range(M):
	input_list_i = list( input().split())
	Q_num = int(input_list_i[0])
	if input_list_i[1] == "WA":
		if Q_ans_list[Q_num] != -1:
			Q_ans_list[Q_num] = Q_ans_list[Q_num] + 1
	elif input_list_i[1] == "AC":
		if Q_ans_list[Q_num] != -1:
			ans_correct = ans_correct + 1
			ans_penalty = ans_penalty + Q_ans_list[Q_num]
			Q_ans_list[Q_num] = -1





print(ans_correct,ans_penalty)
Problem p02802 (python)

Fixed submission:
import numpy as np

N,M = map(int,input().split())

#numAC = [0]*N
numWA = [0]*N
flgAC = [0]*N

#print(num)

for ii in range(M):
  pi,Si = input().split()
  pi = int(pi) - 1 #indexとして使うので-1する
  
  if flgAC[pi] == 0:
    if Si == "AC":
      #numAC[pi] = 1
      flgAC[pi] = 1
    elif Si == "WA":
      numWA[pi] += 1

countWA = 0
for ii in range(N):
  if flgAC[ii] == 1:
    countWA += numWA[ii]
print(np.sum(flgAC),countWA)

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

N,M = map(int,input().split())

numAC = [0]*N
numWA = [0]*N
flgAC = [0]*N

#print(num)

for ii in range(M):
  pi,Si = input().split()
  pi = int(pi)
  
  if flgAC[pi] == 0:
    if Si == "AC":
      numAC[pi] = 1
      flgAC[pi] = 1
    elif Si == "WA":
      numWA[pi] += 1

print(np.sum(numAC),np.sum(numWA))
Problem p02717 (python)

Fixed submission:
el = input().split()
print("{} {} {}".format(el[2],el[0],el[1]))

Buggy submission (verdict: Runtime Error):
s = input().split()
i = s[0]
m = int(s[1])
j = 0
el = input().split()
for p in el:
    if int(p) < 1 / (4 * m):
      j = 1 
if j == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input().split()
i = s[0]
m = int(s[1])
j = 0
el = input().split()
for p in el:
    if int(p) < 1 / (4 * m):
      j = 1 
if j == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input().split()
i = s[0]
m = int(s[1])
j = 0
el = input().split()
for p in el:
    if int(p) < (1 / (4 * m)):
      j = 1 
if j == 0:
    print("Yes")
else:
    print("No")
Problem p02718 (python)

Fixed submission:
s = input().split()
i = s[0]
m = int(s[1])
count = 0
sun = 0
el = input().split()
for p in el:
    sun += int(p)
for k in el:
    if int(k) >= sun / (4 * m):
        count += 1
if count >= m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input().split()
i = s[0]
m = s[1]
j = 0
el = input().split()
for p in el:
    if int(p) < 1 / (4 * m):
      j = 1 
if j == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = input().split()
i = s[0]
m = s[1]
j = 0
el = input().split()
for p in el:
  if int(p) < 1 / (4 * m):
    j = 1
     
if j == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input().split()
i = s[0]
m = s[1]
j = 0
el = input().split()
for p in el:
  if p < 1 / (4 * m):
    j = 1

if j == 0:
  print("Yes")
else:
  print("No")
Problem p03035 (python)

Fixed submission:
x = input()
li = x.split()
age = int(li[0])
m = int(li[1])
if(age <= 5):
  print(0)
elif(age <= 12):
  print(int(m / 2))
else:
  print(m)

Buggy submission (verdict: Runtime Error):
x = input()
li = x.split()
age = li[0]
m = li[1]
if(age <= 5):
  print(0)
elif(age <= 12):
  printf(m / 2)
else:
  print(m)
Problem p03455 (python)

Fixed submission:
li = input().split()
a = int(li[0])
b = int(li[1])
if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
li = input().split()
if li[0] * li[1] % 2 == 0:
    print("Even")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
if a * b % 2 == 0:
  print(Even)
else:
  print(Odd)
Problem p03493 (python)

Fixed submission:
li = list(input())
ans = 0
for i in li:
    if int(i) == 1:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
li = input().split()
t = 0
li2 = []
for i in li:
    t  = 0
    while True:
        if int(i) % 2 == 0:
            i = int(i) / 2
            t += 1
        else:
            li2.append(t)
            break

li2.sort()
ans = li2[0]
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
li = input().split()
ans = 1
t = 0
li2 = []
while True:
    for i in li:
        if int(i) % 2 == 0:
            li2.append(int(i)/2)
        else:
            t = 1
    if t == 1:
        break
    else:
        ans += 1
        li = li2

print(ans)
Problem p03161 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''
import numpy as np


def main():
    N, K = list(map(int, input().split()))
    H = list(map(int, input().split()))
    H = np.array(H)

    cost = np.array([100000] * N)
    cost[0] = 0
    for i in range(1, N):
        cost[i] = min(
            cost[max(i - K, 0): i] + abs(H[i] - H[max(i - K, 0): i]))
        # print(i, cost[i])
    print(cost[N - 1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''
import numpy as np


def main():
    N, K = list(map(int, input().split()))
    H = list(map(int, input().split()))
    H = np.array(H)

    cost = np.array([100000] * N)
    cost[0] = 0
    for i in range(1, N):
        cost[i] = min(
            cost[max(i - K, 0): i] + abs(H[i] - H[max(i - K, 0): i]))
        # print(i, cost[i])
    print(cost[N - 1])


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

Fixed submission:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

X, Y, A, B, C = i_l()
p = i_l()
q = i_l()
r = i_l()

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

p = p[:X]
q = q[:Y]
arr = sorted((p + q + r), reverse=True)

print(sum(arr[:(X+Y)]))

Buggy submission (verdict: Runtime Error):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

X, Y, A, B, C = i_l()
p = i_l()
q = i_l()
r = i_l()

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

p_i = 0
q_i = 0
r_i = 0

ans1 = 0
for i in range(X):
    if p[i] > r[r_i] or r_i > C-1:
        ans1 += p[i]
    else:
        ans1 += r[r_i]
        r_i += 1
for i in range(Y):
    if q[i] > r[r_i] or r_i > C-1:
        ans1 += q[i]
    else:
        ans1 += r[r_i]
        r_i += 1


ans2 = 0
r_i = 0
for i in range(X):
    if p[i] > r[r_i] or r_i > C-1:
        ans2 += p[i]
    else:
        ans2 += r[r_i]
        r_i += 1
for i in range(Y):
    if q[i] > r[r_i] or r_i > C-1:
        ans2 += q[i]
    else:
        ans2 += r[r_i]
        r_i += 1

ans3 = 0
if X + Y <= C:
    ans3 = sum(r[:(X+Y)])

print(max(ans1, ans2, ans3))
Problem p02814 (python)

Fixed submission:
import sys
# import fractions
import math
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
stdin = sys.stdin

def gcd(a,b):
  while b:a,b=b,a%b
  return a

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

def lcm_list(l):
    return reduce(lcm, l, 1)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N, M = i_l()
a = i_l()
half_lcm = lcm_list(a) // 2

for i in a:
    if half_lcm // (i // 2) % 2 == 0:
        print(0)
        exit()

print(((M // half_lcm) + 1) // 2)

Buggy submission (verdict: Runtime Error):
import sys
import fractions
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N, M = map(int, input().split())
a = [int(x) for x in input().split()]

ans = 0
half_lcm = lcm_list(a) // 2

a = set(a)
for i in range(half_lcm, M+1, half_lcm):
    if all(int((i / x * 2)) & 1 for x in a):
        ans += 1

print(ans)
Problem p02924 (python)

Fixed submission:
n = int(input())


a = (1+n-1)*(n-1)//2
print(a)

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


a = list(range(1, n))

print(sum(a))

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

a = list(range(1, n+1))
b = a[1:]+[1]
ans = 0

for i in range(n):
    ans += a[i] % b[i]

print(ans)

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

a = list(range(1, n+1))
b = a[1:]+[1]
ans = 0

for i in range(n):
    ans += a[i] % b[i]

print(ans)

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

a = list(range(1, n+1))
# b = sorted(a, reverse=True)

b = list(range(2, n+1))+[1]
ans = 0

for i in range(n):
    ans += a[i] % b[i]

print(ans)