Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

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

#################################################
#################################################
#################################################
#################################################


n = int(input())
c = list(map(int, input().split()))
a = []
for i in range(n):
    temp = list(map(int, input().split()))
    a.append(temp)

ans = [(i%26) for i in range(n)]

def cost(a,c,ans):
    val = 0
    last = [0 for i in range(26)]
    for i in range(n):
        for j in range(26):
            last += 1
        here = ans[i]
        val += a[i][here]
        last[here] = 0
        for j in range(26):
            val -= last[j]*c[j]
    return val
#

for i in range(n):
    maxim = -10**9
    idx = -1
    for j in range(26):
        if(maxim < a[i][j]):
            idx = j
            maxim = a[i][j]
    ans[i] = idx
#print(ans)

d = [[i,c[i]]]

for i in ans:
    print(i+1)











Fixed submission:
for i in range(365):
  print(i%26+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
info = [0 for i in range(10**6)]
mid = 5*10**5

for i in range(n):
    num = a[i] - i
    info[mid + num] += 1
#print(info[mid-8:mid+8])
ans = 0
for i in range(n):
    num = a[i] - i
    ans += info[mid + num - a[i]*2]

print(ans)



Fixed submission:

n = int(input())
a = list(map(int, input().split()))
info = [0 for i in range(10**6)]
mid = 5*10**5

for i in range(n):
    if(a[i]<=2*10**5):
        num = a[i] - i
        info[mid + num] += 1
#print(info[mid-8:mid+8])
ans = 0
for i in range(n):
    if(a[i]<=2*10**5):
        num = a[i] - i
        ans += info[mid + num - a[i]*2]

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = list(map(int, input().split()))

if(math.sqrt(a) + math.sqrt(b) < math.sqrt(c)-0.000001):
    print("Yes")
else:
    print("No")
print(math.sqrt(a) + math.sqrt(b),math.sqrt(c)-0.000001)




Fixed submission:


import decimal
#decimal.getcontext().prec = 30
a,b,c = list(map(int, input().split()))
a = decimal.Decimal(a)
b = decimal.Decimal(b)
c = decimal.Decimal(c)
d = decimal.Decimal(0.5)
e = decimal.Decimal(1/10000000)

#print(a**decimal.Decimal(0.5))

if(a**d + b**d < (c)**d ):
    print("Yes")
else:
    print("No")
#print(a**d + b**d , (c)**d)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
s = str(n)
l = len(s)

N = [0 for i in range(l)]

for i in range(l):
    N[i] = int(s[-i-1])
N.append(0)

for i in range(l+1):
    if N[i]<5:
        ans += N[i]
    elif N[i]>5:
        ans += 10-N[i]
        N[i+1] += 1
    elif N[i+1]>4:
        ans += 10-N[i]
        N[i+1] += 1
    else:
        ans += N[i]

print(ans)


Fixed submission:

ans = 0
s = input()
l = len(s)

N = [0 for i in range(l)]

for i in range(l):
    N[i] = int(s[-i-1])
N.append(0)

for i in range(l+1):
    if N[i]<5:
        ans += N[i]
    elif N[i]>5:
        ans += 10-N[i]
        N[i+1] += 1
    elif N[i+1]>4:
        ans += 10-N[i]
        N[i+1] += 1
    else:
        ans += N[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
l = len(str(n))

N = [0 for i in range(l)]

for i in range(l):
    N[i] = int(str(n)[-i-1])
N.append(0)

for i in range(l+1):
    if N[i]<5:
        ans += N[i]
    elif N[i]>5:
        ans += 10-N[i]
        N[i+1] += 1
    elif N[i+1]>4:
        ans += 10-N[i]
        N[i+1] += 1
    else:
        ans += N[i]

print(ans)


Fixed submission:

ans = 0
s = input()
l = len(s)

N = [0 for i in range(l)]

for i in range(l):
    N[i] = int(s[-i-1])
N.append(0)

for i in range(l+1):
    if N[i]<5:
        ans += N[i]
    elif N[i]>5:
        ans += 10-N[i]
        N[i+1] += 1
    elif N[i+1]>4:
        ans += 10-N[i]
        N[i+1] += 1
    else:
        ans += N[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

n = int(input())

ans = [-1 for i in range(30002)]
for i in range(10001):
    price = int((i*1.08)//1)
    ans[price] = i

if(ans[n]!=-1):
    print(ans[n])
else:
    print(':(')
    

Fixed submission:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

n = int(input())

ans = [-1 for i in range(80002)]
for i in range(50002):
    price = int((i*1.08)//1)
    ans[price] = i

if(ans[n]!=-1):
    print(ans[n])
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

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

phase = 0
now = [0,0,0]
ans=1

for i in range(n):
    if(a[i]==0):
        now[phase]=1
        ans*=3-phase
        ans%=1000000007
        phase+=1
    else:
        corr = []
        for j in range(3):
            if(now[j]==a[i]):
                corr.append(j)
        ans*=len(corr)
        ans%=1000000007
        now[corr[0]]+=1
print(ans) 


Fixed submission:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

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

phase = 0
now = [0,0,0]
ans=1

for i in range(n):
    if(a[i]==-1):
        now[phase]=1
        ans*=3-phase
        ans%=1000000007
        phase+=1
    else:
        corr = []
        for j in range(3):
            if(now[j]==a[i]):
                corr.append(j)
        ans*=len(corr)
        ans%=1000000007
        if(len(corr)!=0):
            now[corr[0]]+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

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

phase = 0
now = [0,0,0]
ans=1

for i in range(n):
    if(a[i]==0):
        now[phase]=1
        ans*=3-phase
        ans%=1000000007
        phase+=1
    else:
        corr = []
        for j in range(3):
            if(now[j]==a[i]):
                corr.append(j)
        ans*=len(corr)
        ans%=1000000007
        now[corr[0]]+=1
print(ans) 

Fixed submission:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

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

phase = 0
now = [0,0,0]
ans=1

for i in range(n):
    if(a[i]==-1):
        now[phase]=1
        ans*=3-phase
        ans%=1000000007
        phase+=1
    else:
        corr = []
        for j in range(3):
            if(now[j]==a[i]):
                corr.append(j)
        ans*=len(corr)
        ans%=1000000007
        if(len(corr)!=0):
            now[corr[0]]+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

dist = [0 for i in range(n)]
for i in range(n):
    dist[a[i]] += 1
#print(dist)
ans = 1

if (a[0]!=0):
    print(0)
else:
    
    now = 1
    total = 1
    while(total<n):
        for j in range(dist[now]):
            ans *= dist[now-1]
            ans %= 998244353
            total+=1
        now+=1
        
    print(ans)

Fixed submission:
import math

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

dist = [0 for i in range(n)]
for i in range(n):
    dist[a[i]] += 1
#print(dist)


if (a[0]!=0):
    print(0)
else:
    zero = 0
    for j in range(n):
        if(a[j]==0):
            zero+=1
    #print(zero)
    if(zero==1):
        ans = 1
        now = 1
        total = 1
        while(total<n and now<=n-1):
            for j in range(dist[now]):
                ans *= dist[now-1]
                #print(ans)
                ans %= 998244353
                total+=1
            now+=1
            
        print(ans)
    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))

maxim = max(a)
minim = min(a)

while(maxim>minim*2 and m>=1):
    lmax=-1
    maxid=-1
    for i in range(n):
        if(lmax<a[i]):
            lmax=a[i]
            maxid=i
    maxim=lmax
    if(maxim<=minim*2):
        break
    a[maxid] = a[maxid]//2
    m-=1
    if(a[maxid]<minim):
        minim=a[maxid]
        
a.sort()
aa=a
a=[aa[n-1-i] for i in range(n)]
#print(a)

if(m>=1):
    for i in range(m):
        a[i%n] = a[i%n]//2
    

#print(a)
print(sum(a))

Fixed submission:
import math
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))

b=[]

for i in range(n):
    for j in range(1+math.floor(math.log(a[i]+0.1)/math.log(2))):
        b.append(a[i]//(2**j)-a[i]//(2**(j+1)))
        
b.sort()
bb=b
b=[bb[len(b)-1-i] for i in range(len(bb))]


print(sum(a)-sum(b[0:m]))
Buggy python submission (verdict: Runtime Error):
print(n*(n-1)//2)

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
import math

a,b,x,y = list(map(int, input().split()))

z = x * y // math.gcd(x,y)

def num(u,v,k):
    ww=v//k - (u-1)//k
    return ww

print((b-a+1)-(num(a,b,x)+num(a,b,y)-num(a,b,z)))



Fixed submission:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

a,b,x,y = list(map(int, input().split()))

z = x * y // gcd(x,y)

def num(u,v,k):
    ww=v//k - (u-1)//k
    return ww

print((b-a+1)-(num(a,b,x)+num(a,b,y)-num(a,b,z)))
Buggy python submission (verdict: Runtime Error):
n = list(map(int, input().split()))
n = n[0]
xy=[]
for i in range(n):
    x,y = list(map(int, input().split()))
    xy.append([x,y])

distlist=[]
distnum=[]

for i in range(n):
    for j in range(n):
        vec=[xy[i][0]-xy[j][0], xy[i][1]-xy[j][1]]
        if(i==j):
             continue
        flag=0
        for k in range(len(distlist)):
            if(distlist[k][0]==vec[0] and distlist[k][1]==vec[1]):
                distnum[k] += 1
                flag=1
                break
        if(flag==0):
            distlist.append(vec)
            distnum.append(1)

print(n-max(distnum))

Fixed submission:
n = list(map(int, input().split()))
n = n[0]
xy=[]
for i in range(n):
    x,y = list(map(int, input().split()))
    xy.append([x,y])

distlist=[]
distnum=[]

for i in range(n):
    for j in range(n):
        vec=[xy[i][0]-xy[j][0], xy[i][1]-xy[j][1]]
        if(i==j):
             continue
        flag=0
        for k in range(len(distlist)):
            if(distlist[k][0]==vec[0] and distlist[k][1]==vec[1]):
                distnum[k] += 1
                flag=1
                break
        if(flag==0):
            distlist.append(vec)
            distnum.append(1)

if(n==1):
    print(1)
else:
    print(max(n-max(distnum),1))
Buggy python submission (verdict: Runtime Error):
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
bc=[]
for i in range(m):
    temp=list(map(int, input().split()))
    bc.append(temp)

a.sort()

bc.sort(key=lambda x:x[1],reverse=True)
#print(a)
#print(bc)

now=0
for i in range(n):
    if(a[i] < bc[now][1]):
        a[i] = bc[now][1]
        bc[now][0] -= 1
    else:
        break
    if(bc[now][0]==0):
        now+=1
    
print(sum(a))
#print(a)

Fixed submission:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
bc=[]
for i in range(m):
    temp=list(map(int, input().split()))
    bc.append(temp)

a.sort()

bc.sort(key=lambda x:x[1],reverse=True)
#print(a)
#print(bc)

now=0
for i in range(n):
    if(a[i] < bc[now][1]):
        a[i] = bc[now][1]
        bc[now][0] -= 1
    else:
        break
    if(bc[now][0]==0):
        now+=1
    if(now>=m):
        break
    
print(sum(a))
#print(a)

Buggy python submission (verdict: Runtime Error):
import math


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

bc=[]

for i in range(m):
    l,r=list(map(int, input().split()))
    bc.append([l,r])
    
list.sort(a)
list.sort(bc, key=lambda x:x[0])

count=0

for i in range(m):
    for j in range(min(bc[m-i-1][0],len(a))):
        if(a[count]<bc[m-i-1][1]):
            a[count]=bc[m-i-1][1]
            count+=1

print(sum(a))

Fixed submission:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
bc=[]
for i in range(m):
    temp=list(map(int, input().split()))
    bc.append(temp)

a.sort()

bc.sort(key=lambda x:x[1],reverse=True)
#print(a)
#print(bc)

now=0
for i in range(n):
    if(a[i] < bc[now][1]):
        a[i] = bc[now][1]
        bc[now][0] -= 1
    else:
        break
    if(bc[now][0]==0):
        now+=1
    if(now>=m):
        break
    
print(sum(a))
#print(a)
Buggy python submission (verdict: Runtime Error):
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

#####################################


#2:26
n,a,b = list(map(int, input().split()))
ans=[]
if(n<a+b-1 or n>a*b):
    print(-1)
else:
    x = (n-a)//(b-1)
    y = (n-a)%(b-1)
    times=[0 for i in range(b-1)]
    for i in range(a):
        ans.append(n-a+i+1)
    for i in range(b-1):
        if(i<y):
            times[i]=x+1
        else:
            times[i]=x
    now = n-a
    for i in range(b-1):
        now -= times[i]
        for j in range(times[i]):
            ans.append(now+j+1)
print(' '.join(map(str,ans)))

Fixed submission:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

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

#####################################


#2:26
n,a,b = list(map(int, input().split()))
ans=[]
if(n<a+b-1 or n>a*b):
    print(-1)
else:
    if(b>=2):
        x = (n-a)//(b-1)
        y = (n-a)%(b-1)
    else:
        x=1
        y=1
    times=[0 for i in range(b-1)]
    for i in range(a):
        ans.append(n-a+i+1)
    for i in range(b-1):
        if(i<y):
            times[i]=x+1
        else:
            times[i]=x
    now = n-a
    for i in range(b-1):
        now -= times[i]
        for j in range(times[i]):
            ans.append(now+j+1)
print(' '.join(map(str,ans)))
Buggy python submission (verdict: Runtime Error):
s = input()
a = ""
for i in range(len(s+1)//2):
  a += s[2*i]
print(a)

Fixed submission:
s = input()
a = ""
for i in range((len(s)+1)//2):
  a = a+ str(s[2*i])
print(a)
Buggy python submission (verdict: Runtime Error):

w,h = list(map(int, input().split()))
ws = []
hs = []
for i in range(w): ws.append(int(input()))
for i in range(h): hs.append(int(input()))

ws.sort(reverse = True)
hs.sort(reverse = True)

remainW = w
remainH = h
aliveW = [1 for i in range(w)]
aliveH = [1 for i in range(h)]

ans = 0
while(remainW>0 or remainH>0):
    #print(ans, remainW, remainH)
    costW = ws[remainW-1] * (remainH + 1)
    costH = hs[remainH-1] * (remainW + 1)
    if(ws[remainW-1] > hs[remainH-1] or remainW==0):
        ans += costH
        remainH-=1
    else:
        ans += costW
        remainW -= 1
print(ans)

                             



Fixed submission:

w,h = list(map(int, input().split()))
ws = []
hs = []
for i in range(w): ws.append(int(input()))
for i in range(h): hs.append(int(input()))

ws.sort(reverse = True)
hs.sort(reverse = True)

remainW = w
remainH = h
aliveW = [1 for i in range(w)]
aliveH = [1 for i in range(h)]

ans = 0
while(remainW>0 or remainH>0):
    #print(ans, remainW, remainH)
    costW = ws[remainW-1] * (remainH + 1)
    costH = hs[remainH-1] * (remainW + 1)
    if(remainH!=0 and (ws[remainW-1] > hs[remainH-1] or remainW==0)):
        ans += costH
        remainH = max(0,remainH-1)
    else:
        ans += costW
        remainW = max(0,remainW-1)
print(ans)

Buggy python submission (verdict: Runtime Error):

w,h = list(map(int, input().split()))
ws = []
hs = []
for i in range(w): ws.append(int(input()))
for i in range(h): hs.append(int(input()))

ws.sort(reverse = True)
hs.sort(reverse = True)

remainW = w
remainH = h
aliveW = [1 for i in range(w)]
aliveH = [1 for i in range(h)]

ans = 0
while(remainW>0 or remainH>0):
    #print(ans, remainW, remainH)
    costW = ws[remainW-1] * (remainH + 1)
    costH = hs[remainH-1] * (remainW + 1)
    if(costW > costH or remainW==0):
        ans += costH
        remainH-=1
    else:
        ans += costW
        remainW -= 1
print(ans)


Fixed submission:

w,h = list(map(int, input().split()))
ws = []
hs = []
for i in range(w): ws.append(int(input()))
for i in range(h): hs.append(int(input()))

ws.sort(reverse = True)
hs.sort(reverse = True)

remainW = w
remainH = h
aliveW = [1 for i in range(w)]
aliveH = [1 for i in range(h)]

ans = 0
while(remainW>0 or remainH>0):
    #print(ans, remainW, remainH)
    costW = ws[remainW-1] * (remainH + 1)
    costH = hs[remainH-1] * (remainW + 1)
    if(remainH!=0 and (ws[remainW-1] > hs[remainH-1] or remainW==0)):
        ans += costH
        remainH = max(0,remainH-1)
    else:
        ans += costW
        remainW = max(0,remainW-1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
n = len(s)

a = []
for i in range(n):
    a.append(ord(s[i])-ord('a'))

for i in range(n):
    need = 26 - a[i]
    if(k>=need):
        a[i]=0
        k-=need


k %= 26

for ii in range(n):
    i = n-1-ii
    rem = 25 - a[i]
    if(rem<=k):
        a[i]+=rem
        k-=rem
    else:
        a[i]+=k
        k=0
        
        break
ans = ''
for i in range(n):        
    ans += chr(a[i]+ord('a'))
print(ans)


Fixed submission:

s = input()
k = int(input())
n = len(s)

a = []
for i in range(n):
    a.append(ord(s[i])-ord('a'))

for i in range(n):
    need = (26 - a[i])%26
    if(k>=need):
        a[i]=0
        k-=need


k %= 26

for ii in range(n):
    i = n-1-ii
    rem = 25 - a[i]
    if(rem<=k):
        a[i]+=rem
        k-=rem
    else:
        a[i]+=k
        k=0
        
        break
ans = [' ' for i in range(n)]
for i in range(n):        
    ans[i] = chr(a[i]+ord('a'))
print(''.join(map(str,ans)))
Buggy python submission (verdict: Runtime Error):

ss = input()
n = len(ss)
s=[]
for i in range(n):
    s.append(int(ss[i]))

ans = 0
for i in range(2**(n-1)):
    d=[[]]
    bit = ValueToBits(i,n-1)
    for j in range(n-1):
        d[-1].append(s[j])
        if(bit[j]==1):
            d.append([])
    d[-1].append(s[n-1])
    #print(d)
    
    for j in d:
        for k in range(len(j)):
            ans += 10**(len(j)-1-k) * j[k]

            



print(ans)


Fixed submission:
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

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

#################################################
#################################################
#################################################
#################################################



ss = input()
n = len(ss)
s=[]
for i in range(n):
    s.append(int(ss[i]))

ans = 0
for i in range(2**(n-1)):
    d=[[]]
    bit = ValueToBits(i,n-1)
    for j in range(n-1):
        d[-1].append(s[j])
        if(bit[j]==1):
            d.append([])
    d[-1].append(s[n-1])
    #print(d)
    
    for j in d:
        for k in range(len(j)):
            ans += 10**(len(j)-1-k) * j[k]

            



print(ans)