Language: C++

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("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())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s


#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 = []
for i in range(n):
    l.append(ip())
if a in l and b in l and c in l:
    print(0)
    exit(0)
l.sort()
req = [a, b,c]


m  = pow(10,30)
set = [0 for i in range(n)]
set[0] = -1
while sum(set) < n*3:
    while sum(set) < n*3:
        d = 0
        set[d]+=1
        while set[d] == 4:
            set[d]=0
            d+=1
            set[d]+=1
        if 0 in set and 1 in set and 2 in set: break
    s = [0,0,0,0]
    mi = 0
    for i in range(n):
        s[set[i]]+= l[i]
    for i in range(3):
        mi += abs(s[i] - req[i]) + (set.count(i)-1) * 10
    m  = min(m,mi)
print(m)


Compiler output:
a.cc:31:2: error: invalid preprocessing directive #n
   31 | #n = ip()                              #入力整数1つ
      |  ^
a.cc:32:2: error: invalid preprocessing directive #h
   32 | #h,w= (int(i) for i in input().split())      #入力整数横2つ
      |  ^
a.cc:33:2: error: invalid preprocessing directive #n
   33 | #n,x,y = (int(i) for i in input().split())    #入力整数横3つ
      |  ^
a.cc:34:45: error: stray '#' in program
   34 | n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
      |                                             ^
a.cc:35:2: error: invalid preprocessing directive #a
   35 | #a = [int(i) for i in input().split()]        #入力整数配列
      |  ^
a.cc:36:2: error: invalid preprocessing directive #a
   36 | #a = input()                                  #入力文字列
      |  ^
a.cc:37:2: error: invalid preprocessing directive #a
   37 | #a = input().split()                          #入力文字配列
      |  ^
a.cc:38:2: error: invalid preprocessing directive #n
   38 | #n = ip()                      #入力セット(整数改行あり)(1/2)
      |  ^
a.cc:39:2: error: invalid preprocessing directive #a
   39 | #a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
      |  ^
a.cc:41:2: error: invalid preprocessing directive #j\U0000306e\U00005909\U00006570\U0000306f\U00003057\U00003088\U00003046\U00003067\U0000304d\U0000306a\U00003044\U0000306e\U00003067\U00006ce8\U0000610f
   41 | #jの変数はしようできないので注意
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:42:2: error: invalid preprocessing directive #\U00005168\U00008db3\U00003057\U0000306bsum\U00005909\U00006570\U00004f7f\U00007528\U0000306fsum\U000095a2\U00006570\U00004f7f\U00007528\U00003067\U0000304d\U0000306a\U00003044\U0000306e\U00003067\U00006ce8\U0000610f
   42 | #全足しにsum変数使用はsum関数使用できないので注意
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:1:1: error: 'from' does not name a type
    1 | from statistics import mean, median,variance,stdev
      | ^~~~