Problem: In the Kingdom of AtCoder, only banknotes are used as currency. There are 10^{100}+1 kinds of banknotes, with the values of 1, 10, 10^2, 10^3, \dots, 10^{(10^{100})}. You have come shopping at a mall and are now buying a takoyaki machine with a value of N. _(Takoyaki is the name of a Japanese snack.)_  To make the payment, you will choose some amount of money which is at least N and give it to the clerk. Then, the clerk gives you back the change, which is the amount of money you give minus N.  What will be the minimum possible number of total banknotes used by you and the clerk, when both choose the combination of banknotes to minimize this count?  Assume that you have sufficient numbers of banknotes, and so does the clerk.

Submission attempts (in order):
n=int(input())
h=list(map(int,input().split()))


N=list(map(int, input()))

s= [input() for _ in range(n)]

w,h,n=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]

s.sort()
print(''.join(s))

s="abcABC"
s[0].upper()+s[1:].lower()


import numpy as np
a=[[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]
b=np.array(a)
c=b[1:3,1:3].tolist()
print(c)

z =[[0]*500 for i in range(500)]


s = '1234'
s_zero = s.zfill(8)


import collections
l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
c = collections.Counter(l)
for i in c.items():
    print(i)

l.sort(key=lambda x: x[1])



from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

a = cmb(n, r)

 mod 10**9+7
w,h=map(int,input().split())
n=w+h-2
r=min(w,h)-1
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 
N = 10**4
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 )
a = cmb(n,r,mod)
print(a%mod)


#DFS
import sys
sys.setrecursionlimit(10 ** 9) 
H, W = map(int, input().split())
m = [input() for i in range(H)]

sindex = ''.join(m).index('s')

sh = sindex // W
sw = sindex % W

dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]

zz = [[0] * W for i in range(H)]

def dfs(h, w):
    
    zz[h][w] = 1

    
    for i in range(4):
        nh = h + dy[i]
        nw = w + dx[i]

        
        if nh < 0 or nw < 0 or nh >= H or nw >= W:
            continue
        
        if m[nh][nw] == "#":
            continue
        
        if zz[nh][nw]:
            continue
        
        if m[nh][nw] == "g":
            print("Yes")
            sys.exit()

        
        dfs(nh, nw)

dfs(sh, sw)

print("No")



n = int(input())
h = list(map(int, input().split()))
dp = [10 ** 9] * (n + 1)
dp[0] = 0
for i in range(n):
    for j in range(1, 3):
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[n - 1])


import itertools as it
l=[ i for i in it.product([0, 1], repeat=10)]
print(l)


bin_str = format(i, '08b') 


a=[list(map(int,input().split())) for _ in range(m)]
G=[[] for _ in range(n+1)]
for j,k in a:
    G[j].append(k)
    G[k].append(j)

n = [0]
n1 = list(input())
n2 = [int(s) for s in n1]
nn = len(n1)
n = n + n2
# print(n)

ans = 0
for i in range(nn, -1, -1):
    # print(n[i])
    if n[i] >= 10:
        n[i - 1] += 1
    elif n[i] == 5:
        if n[i - 1] >= 5:
            ans += n[i]
            n[i - 1] += 1
        else:
            ans += n[i]
    elif n[i] < 5:
        ans += n[i]
    else:
        ans += 10 - n[i]
        n[i - 1] += 1
print(ans)


Verdicts: Runtime Error

Accepted