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

Fixed submission:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
l = len(a)
print(a[0],end='')
print(l-2,end='')
print(a[l-1])

Buggy submission (verdict: Runtime Error):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
print(a[0],end=“”)
print(len(a)-2,end=“”)
print(a[len(a)-1])
Problem p03761 (python)

Fixed submission:
import math
import fractions
import copy
import numpy as np

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
n = ip()
s = input()
scut = [s[i] for i in range(len(s))]
scut.sort()
if n == 1:
	print(''.join(scut))
	exit(0)
for i in range(n-1):
	s = input()
	sncut = [s[i] for i in range(len(s))]
	sncut.sort()
	nextline = []
	while len(sncut) and len(scut):
	  if sncut[0] == scut[0]:
	  	nextline.append(sncut[0])
	  	scut.pop(0)
	  	sncut.pop(0)
	  elif sncut[0] > scut[0]:
	  	scut.pop(0)
	  else: sncut.pop(0)
	scut = copy.copy(nextline)
print(''.join(nextline))

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

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
n = ip()
s = input()
scut = [s[i] for i in range(len(s))]
scut.sort()
for i in range(n-1):
	s = input()
	sncut = [s[i] for i in range(len(s))]
	sncut.sort()
	nextline = []
	while len(sncut) and len(scut):
	  if sncut[0] == scut[0]:
	  	nextline.append(sncut[0])
	  	scut.pop(0)
	  	sncut.pop(0)
	  elif sncut[0] > scut[0]:
	  	scut.pop(0)
	  else: sncut.pop(0)
	scut = copy.copy(nextline)
print(''.join(nextline))
Problem p03813 (python)

Fixed submission:
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()
a = []
for i in range(len(x)):
   a.append(int(x[i]))
if a[0] <1200:print("ABC")
else:print("ARC")

Buggy submission (verdict: Runtime Error):
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()
a = []
#for i in range(len(x)):
 #  a.append(int(x[i]))
if a[0] <1200:print("ABC")
else:print("ARC")
Problem p03853 (python)

Fixed submission:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


def calculate(a):
    s = 0
    for i in range(len(a)):
        for k in range(i+1,len(a)):
            s+=(a[i]*a[k])
    return s

#n = ip()                              #入力整数1つ
n,m= (int(i) for i in input().split())      #入力整数横2つ
#n,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#s = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a =[]
for i in range(n):
	a.append(input())
for i in range(n):
	print(a[i])
	print(a[i])

Buggy submission (verdict: Runtime Error):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


def calculate(a):
    s = 0
    for i in range(len(a)):
        for k in range(i+1,len(a)):
            s+=(a[i]*a[k])
    return s

#n = ip()                              #入力整数1つ
h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#s = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a =[]
for i in range(n):
	a.append(input())
for i in range(n):
	print(a[i])
	print(a[i])
Problem p03861 (python)

Fixed submission:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
#n = ip()                                     #入力整数1つ
x,y,z= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[input() for i in range(x)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
low = (x//z)*z
if low < x: low+=z
high = (y//z)*z
print((high - low)//z+1)

Buggy submission (verdict: Runtime Error):
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a==1: print("YES")
    else :print("NO")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#x = int(input())                              #入力整数1つ
#x,y = (int(i) for i in input().split())      #入力整数横2つ
x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#a,b,c,k = (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#x = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
lower = (x//z)*z
if lower < x: lower+=z
high = (y//z)*z
print((high - low)/z+1)
Problem p02743 (python)

Fixed submission:
a,b,c=map(int,input().split())
if c>=a+b and 4*a*b<(c-a-b)**2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input(),split())
if 2*((a*b)**0.5)<c**2-a-b:
  print('Yes')
else:
  print('No')
Problem p02760 (python)

Fixed submission:
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for _ in range(n):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==b:
        a[i][j]=-1
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==-1:
    print('Yes')
    exit()
  if a[0][i]==a[1][i]==a[2][i]==-1:
    print('Yes')
    exit()
if a[0][0]==a[1][1]==a[2][2]==-1 or a[0][2]==a[1][1]==a[2][0]==-1:
  print('Yes')
  exit()
print('No')

Buggy submission (verdict: Runtime Error):
a=[list(map(int,input().split()))]
n=int(input())
for _ in range(n):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==b:
        a[i][j]=-1
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==-1:
    print('Yes')
    exit()
  if a[0][i]==a[1][i]==a[2][i]==-1:
    print('Yes')
    exit()
if a[0][0]==a[1][1]==a[2][2]==-1 or a[0][2]==a[1][1]==a[2][0]==-1:
  print('Yes')
  exit()
print('No')

Buggy submission (verdict: Runtime Error):
a=[list(map(int,input().split()))]
n=int(input())
for i in range(n):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==b:
        a[i][j]=-1
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==-1:
    print('Yes')
    exit()
  if a[0][i]==a[1][i]==a[2][i]==-1:
    print('Yes')
    exit()
if a[0][0]==a[1][1]==a[2][2]==-1 or a[0][2]==a[1][1]==a[2][0]==-1:
  print('Yes')
  exit()
print('No')
Problem p02784 (python)

Fixed submission:
h,n=map(int,input().split())
a = list(map(int,input().split()))
print('Yes' if sum(a)>=h else 'No')

Buggy submission (verdict: Runtime Error):
h,n=map(int,input())
a = list(map(int,input().split()))
print('Yes' if sum(a)>=h else 'No')
Problem p02786 (python)

Fixed submission:
import math
h=int(input())
m=int(math.log(h,2))
print(int(2**(m+1)-1))

Buggy submission (verdict: Runtime Error):
import math
h=int(input())
m=int(math.long(h,2))
print(2**(h+1)-1)

Buggy submission (verdict: Runtime Error):
h=int(input())
m=int(math.long(h,2))
print(2**(h+1)-1)
Problem p02802 (python)

Fixed submission:
n,m=map(int,input().split())
cnt=[0]*(n+1)
l=[0]*(n+1)
ac=0
wa=0
for i in range(m):
  p,s=input().split()
  p=int(p)
  if l[p]==1:
    continue
  if l[p]==0 and s=='WA':
    cnt[p]+=1
  if l[p]==0 and s=='AC':
    ac+=1
    l[p]=1
for i in range(1,n+1):
  if l[i]==1:
    wa+=cnt[i]
print(ac,wa)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
cnt=[0]*(n+1)
l=[0]*(n+1)
ac=0
wa=0
for i in range(m):
  p,s=input().split()
  p=int(p)
  if l[p]!=0:
    continue
  if l[p]==0 and s=='WA':
    cnt[i]+=1
  if l[p]==0 and s=='AC':
    ac+=1
    l[p]=1
for i in range(1,n+1):
  if l[i]!=0:
    wa+=cnt[i]
print(ac,wa)
Problem p02813 (python)

Fixed submission:
import itertools as it
s = list(range(1,int(input())+1))
a = list(it.permutations(s))
p,q = [tuple(map(int,input().split())) for i in range(2)]
print(abs(a.index(p)-a.index(q)))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
l=list(itertools.permutations([i for i in range(1,n+1)]))
a=0
b=0
for i in range(len(l)):
  if l[i]==p:
    a=i
  if l[i]==q:
    b=i
print(abs(a-b))
Problem p02818 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
if a+b<=k:
  print("0 0")
elif a>=k:
  print((a-k)+" "+b)
else print(0+" "+(a+b-k))
Problem p02838 (python)

Fixed submission:
import numpy as np
n=int(input())
a=np.array([int(i) for i in input().split()])
mod=int(1e9+7)
ans=0
for k in range(60):
  b=(a>>k)&1
  m=np.count_nonzero(b)
  ans+=m*(n-m)*2**k
  ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
if max(a)==0:
  print(0)
  exit()
m=math.floor(math.log2(max(a)))+1
ans=0
for i in range(m):
  cnt0=0
  cnt1=0
  for j in range(n):
    if a[j]>>i&1:
      cnt1+=1
    else:
      cnt0+=1
  ans+=(2**i)*(cnt1*cnt0)
  ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
m=math.floor(math.log2(max(a)))+1
ans=0
for i in range(m):
  cnt0=0
  cnt1=0
  for j in range(n):
    if a[j]>>i&1:
      cnt1+=1
    else:
      cnt0+=1
  ans+=(2**i)*(cnt1*cnt0)
  ans%=mod
print(ans)
Problem p02923 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
  if h[i-1]>=h[i]:
    dp[i]=dp[i-1]+1
  else:
    dp[i]=0
print(max(dp))

Buggy submission (verdict: Runtime Error):
n=int(input())
h=map(int,input().split())
dp=[0]*n
for i in range(1,n):
  if h[i-1]>=h[i]:
    dp[i]=dp[i-1]+1
  else:
    dp[i]=0
print(max(dp))
Problem p02947 (python)

Fixed submission:
from math import factorial
def comb(n,k):
  if n<0 or k<0 or n<k:return 0
  if n==0 and k==0:return 1
  a=factorial(n)
  b=factorial(k)
  c=factorial(n-k)
  return a//(b*c)
n=int(input())
s=[sorted(list(input())) for i in range(n)]
s.sort()
cnt=1
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=comb(cnt,2)
    cnt=1
if cnt>=2:
  ans+=comb(cnt,2)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial
def cmb(m,r):
  return factorial(m)//(factorial(r)*factorial(m-r))
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=0
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=cmb(cnt+1,2)
    cnt=0
print(ans)

Buggy submission (verdict: Runtime Error):
from math import factorial
def cmb(n,r):
  return factorial(n)//(factorial(r)*factorial(n-r))
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=0
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=cmb(cnt+1,2)
    cnt=0
print(ans)
Problem p02971 (python)

Fixed submission:
import copy
n=int(input())
a=[int(input()) for i in range(n)]
b=copy.deepcopy(a)
b.sort()
for i in range(n):
  if a[i]==b[-1]:
    print(b[-2])
  else:
    print(b[-1])

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

Fixed submission:
n=int(input())
s=list(map(int,input().split()))
ans=s[0]
for i in range(1,n):
  ans^=s[i]
if ans!=0:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=s[0]
for i in range(n):
  ans^=s[i]
if ans!=0:
  print('No')
else:
  print('Yes')
Problem p02983 (python)

Fixed submission:
L,R=map(int,input().split())
l,r=L%2019,R%2019
x,y=L//2019,R//2019
if x<y:
  print(0)
else:
  ans=10**9
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans=min(ans,(i*j)%2019)
  print(ans)

Buggy submission (verdict: Runtime Error):
L,R=map(int,input().split())
l,r=L%2019,R%2019
x,y=L//2019,R//2019
if x<y:
  print(0)
else:
  ans=10**9
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans=min(ans,(i*j)%2019)
print(ans)
Problem p02985 (python)

Fixed submission:
n,k=map(int,input().split())
path=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
mod=10**9+7
stack=[0]
visited=[1]+[0]*(n-1)
ans=k
while stack:
  v=stack.pop(0)
  c=k-2 if v!=0 else k-1
  for d in path[v]:
    if visited[d]:
      continue
    visited[d]=1
    ans=(ans*c)%mod
    c-=1
    stack.append(d)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
path=[[] for i in range(n)]
for i in range(n):
  a,b=map(int,input().split())
  path[a-1].append(b-1)
  path[b-1].append(a-1)
mod=10**9+7
stack=[0]
visited=[1]+[0]*(n-1)
ans=k
while stack:
  v=stack.pop(0)
  c=k-2 if v!=0 else k-1
  for d in path[v]:
    if visited[d]:
      continue
    visited[d]=1
    ans=(ans*c)%mod
    c-=1
    stack.append(d)
print(ans)
Problem p03001 (python)

Fixed submission:
w,h,x,y=map(int,input().split())
s=w*h/2
i=1 if x==w/2 and y==h/2 else 0
print(s,i)

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
s=w*h/2
i=1 if x=w/2 and y=h/2 else 0
print(s,i)
Problem p03006 (python)

Fixed submission:
from collections import Counter
n=int(input())
b=[tuple(map(int,input().split())) for _ in range(n)]
r=[(x[0]-y[0],x[1]-y[1]) for x in b for y in b if x!=y]
c=Counter(r).most_common(1)
print(n-c[0][1] if c else n)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
b=[tuple(map(int,input().split())) for _ in range(n)]
r=[(x[0]-y[0],x[1]-y[1]) for x in b for y in b if x!=y]
c=Counter(r).most_commom(1)
print(n-c[0][1] if c else n)
Problem p03007 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
xy=[]
for i in range(n-2,0,-1):
  y=a[i]
  if y>0:
    x=a[0]
    a[0]-=y
  else:
    x=a[n-1]
    a[n-1]-=y
  xy.append((x,y))
print(a[n-1]-a[0])
xy.append((a[n-1],a[0]))
print('\n'.join([' '.join(map(str,t)) for t in xy]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n):
  ans+=abs(a[i])
if a[0]>0:
  print(sum(a)-2*a[0])
else:
  print(ans)
plus=list()
minus=list()
for i in range(n):
  if a[i]>=0:
    plus.append(a[i])
  else:
    minus.append(a[i])
if len(minus)>0:
  while len(plus)>=2:
    p=plus.pop(0)
    m=minus.pop(0)
    minus.append(m-p)
    print(str(m)+' '+str(p))
if len(plus)>=2 and len(minus)==0:
  plus.sort()
  p1=plus.pop(0)
  p2=plus.pop(-1)
  minus.append(p1-p2)
  print(str(p1)+' '+str(p2))
if len(plus)==0:
  minus.sort()
  m1=minus.pop(-1)
  m2=minus.pop(-2)
  plus.append(m1-m2)
  print(str(m1)+' '+str(m2))
while len(minus)>0:
  p=plus.pop(0)
  m=minus.pop(0)
  plus.append(p-m)
  print(str(p)+' '+str(m))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n):
  ans+=abs(a[i])
print(ans)
plus=list()
minus=list()
for i in range(n):
  if a[i]>=0:
    plus.append(a[i])
  else:
    minus.append(a[i])
while len(plus)>=2 :
  p=plus.pop(0)
  m=minus.pop(0)
  minus.append(m-p)
  print(str(m)+' '+str(p))
while len(minus)>0:
  p=plus.pop(0)
  m=minus.pop(0)
  plus.append(p-m)
  print(str(p)+' '+str(m))
Problem p03008 (python)

Fixed submission:
n=int(input())
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
s=[0]*(n+1)
for i in range(a,n+1):
  s[i]=max(s[i],s[i-a]+d-a)
for i in range(b,n+1):
  s[i]=max(s[i],s[i-b]+e-b)
for i in range(c,n+1):
  s[i]=max(s[i],s[i-c]+f-c)
n+=s[-1]
s=[0]*(n+1)
for i in range(d,n+1):
  s[i]=max(s[i],s[i-d]+a-d)
for i in range(e,n+1):
  s[i]=max(s[i],s[i-e]+b-e)
for i in range(f,n+1):
  s[i]=max(s[i],s[i-f]+c-f)
print(n+s[-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
s=[0]*(n+1)
for i in range(a,n+1):
  s[i]=max(s[i],s[i-a]+d-a)
for i in range(b,n+1):
  s[i]=max(s[i],s[i-b]+e-b)
for i in range(c,n+1):
  s[i]=max(s[i],s[i-b]+f-c)
n+=s[-1]
s=[0]*(n+1)
for i in range(d,n+1):
  s[i]=max(s[i],s[i-d]+a-d)
for i in range(e,n+1):
  s[i]=max(s[i],s[i-e]+b-e)
for i in range(f,n+1):
  s[i]=max(s[i],s[i-f]+c-f)
print(n+s[-1])
Problem p03078 (python)

Fixed submission:
from heapq import nlargest
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=nlargest(k,(x+y for x in a for y in b))
abc=nlargest(k,(xy+z for xy in ab for z in c))
for i in abc:
  print(i)

Buggy submission (verdict: Runtime Error):
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=[]
for i in range(x):
  for j in range(y):
    ab.append(a[i]+b[j])
ab.sort(reverse=True)
ab=ab[:k]
abc=[]
for i in range(k):
  for j in range(z):
    abc.append(ab[i]+c[j])
abc.sort(reverse=True)
for i in range(k):
  print(abc[i])
Problem p03111 (python)

Fixed submission:
def Base_10_to_n(x,n):
  tmp=x
  out=''
  while tmp>0:
    out=str(tmp%n)+out
    tmp=int(tmp/n)
  return out
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
ans=10**18
for i in range(4**n):
  cost=0
  d=[[] for j in range(4)]
  s=Base_10_to_n(i,4).zfill(n)
  for j in range(n):
    k=int(s[j])
    d[k].append(l[j])
  if len(d[1])*len(d[2])*len(d[3])==0:
    continue
  for j in range(1,4):
    cost+=(len(d[j])-1)*10
  d1=sum(d[1])
  d2=sum(d[2])
  d3=sum(d[3])
  L=[abs(d1-a)+abs(d2-b)+abs(d3-c),abs(d1-a)+abs(d2-c)+abs(d3-b),abs(d1-b)+abs(d2-a)+abs(d3-c),abs(d1-b)+abs(d2-c)+abs(d3-a),abs(d1-c)+abs(d2-a)+abs(d3-b),abs(d1-c)+abs(d2-b)+abs(d3-a)]
  cost+=min(L)
  ans=min(ans,cost)
print(ans)

Buggy submission (verdict: Runtime Error):
def Base_10_to_n(x,n):
  tmp=x
  out=''
  while tmp>0:
    out=str(tmp%n)+out
    tmp=int(tmp/n)
  return out
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
ans=10**18
for i in range(4**n):
  cost=0
  d=[[] for i in range(4)]
  s=Base_10_to_n(i,4).zfill(n)
  for j in range(n):
    k=int(s[j])
    d[k].append(l[j])
  if len(d[1])*len(d[2])*len(d[3])==0:
    continue
  for i in range(1,4):
    cost+=(len(d[k])-1)*10
  d1=sum(d[1])
  d2=sum(d[2])
  d3=sum(d[3])
  l=[abs(d1-a)+abs(d2-b)+abs(d3-c),abs(d1-a)+abs(d2-c)+abs(d3-b),abs(d1-b)+abs(d2-a)+abs(d3-c),abs(d1-b)+abs(d2-c)+abs(d3-a),abs(d1-c)+abs(d2-a)+abs(d3-b),abs(d1-c)+abs(d2-b)+abs(d3-a)]
  cost=min(l)
  ans=min(ans,cost)
print(ans)
Problem p03244 (python)

Fixed submission:
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
s1,s2=[],[]
for i in range(n):
  if i%2==0:
    s1.append(v[i])
  else:
    s2.append(v[i])
c1=Counter(s1)
c2=Counter(s2)
d1=c1.most_common()
d2=c2.most_common()
if d1[0][0]!=d2[0][0]:
  print(n-d1[0][1]-d2[0][1])
else:
  if len(d1)>1 and len(d2)>1:
    print(min(n-d1[0][1]-d2[1][1],n-d1[1][1]-d2[0][1]))
  elif len(d1)==1 and len(d2)==1:
    print(n//2)
  elif len(d1)==1:
    print(n//2-d2[0][1])
  else:
    print(n//2-d1[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
s1,s2=[],[]
for i in range(n):
  if i%2==0:
    s1.append(v[i])
  else:
    s2.append(v[i])
c1=Counter(s1)
c2=Counter(s2)
d1=c1.most_common()
d2=c2.most_common()
if d1[0][0]!=d2[0][0]:
  print(n-d1[0][1]-d2[0][1])
else:
  print(min(n-d1[0][1]-d2[1][1],n-d1[1][1]-d2[0][1]))

Buggy submission (verdict: Runtime Error):
import Counter
n=int(input())
v=list(map(int,input().split()))
s1,s2=[],[]
for i in range(n):
  if i%2==0:
    s1.append(v[i])
  else:
    s2.append(v[i])
c1=Counter(s1)
c2=Counter(s2)
d1=c1.most_common()
d2=c2.most_common()
if d1[0][0]!=d2[0][0]:
  print(n-d1[0][1]-d2[0][1])
else:
  print(min(n-d1[0][1]-d2[1][1],n-d1[1][1]-d2[0][1]))
Problem p03266 (python)

Fixed submission:
n,k=map(int,input().split())
s=n//k
t=0
if k%2==0:
  t=(n+k//2)//k
print(s*s*s+t*t*t)

Buggy submission (verdict: Runtime Error):
N=10**6
def comb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r]
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,k=map(int,input().split())
if k==2:
  print((comb(n//2,3)+comb(n-n//2,3))*6)
else:
  print(comb(n//k,3)*6)
Problem p03287 (python)

Fixed submission:
from collections import Counter
import numpy as np
n,m=map(int,input().split())
a=[0]+list(map(int,input().split()))
d=Counter(np.cumsum(a)%m)
ans=0
for v in d.values():
  ans+=v*(v-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*(n+1)
cnt=[0]*m
s=set()
for i in range(1,n+1):
  b[i]=b[i-1]+a[i-1]
for i in range(n+1):
  cnt[b[i]%m]+=1
  s.add(b[i]%m)
ans=0
for i in s:
  ans+=cnt[i]*(cnt[i]-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*(n+1)
cnt=[0]*m
for i in range(1,n+1):
  b[i]=b[i-1]+a[i-1]
for i in range(n+1):
  cnt[b[i]%m]+=1
ans=0
for i in range(m):
  ans+=cnt[i]*(cnt[i]-1)//2
print(ans)