ABC153~ABC157までの灰色diffのコード

１日３ACしていて、解説PDFにサンプルコードがない物もあるので記事にしてみました。
他の方の参考になれば嬉しいと思います。

#ABC 157
##[A - Duplex Printing](https://atcoder.jp/contests/abc157/tasks/abc157_a)

```Python:Python
N = int(input())
print(N//2+N%2)
```

##[B - Bingo](https://atcoder.jp/contests/abc157/tasks/abc157_b)

- 3*3の為、全探索でも間に合う

```Python:Python

A = [[0] * 3, [0] * 3, [0] * 3]
Field = [[False] * 3, [False] * 3]

for i in range(0, 3):
    A1, A2, A3 = list(map(int, input().split()))
    A[i][0] = A1
    A[i][1] = A2
    A[i][2] = A3

N = int(input())
B = [0] * N
for i in range(0, N):
    B[i] = int(input())
 
for b in range(0, N):
    for i in range(3):
        for j in range(3):
            if A[i][j] == B[b]:
                Field[i][j] = True

Ans = False
for i in range(3):
    field = True
    for j in range(3):
        if Field[i][j] == False:
            field = False
    
    if field==True:
        Ans = True
        break
else:
    for i in range(3):
        field = True
        for j in range(3):
            if Field[j][i] == False:
                field = False
        
        if field==True:
            Ans = True
            break
    else:
        if Field[0][0] and Field[1][1] and Field[2][2]:
            Ans = True
        if Field[0][2] and Field[1][1] and Field[2][0]:
            Ans = True

if Ans:
    print('Yes')
else:
    print('No')
```

#ABC 156
##[A - Beginner](https://atcoder.jp/contests/abc156/tasks/abc156_a)

```Python:Python
N, R = list(map(int, input().split()))

if N>=10:
    print(R)
else:
    print(R + 100*(10-N))
```

##[B - Digits](https://atcoder.jp/contests/abc156/tasks/abc156_b)

```Python:Python
N, K = list(map(int, input().split()))

res=0
while N > 0:
    N = N // K
    res+=1

print(res)
```

##[C - Rally](https://atcoder.jp/contests/abc156/tasks/abc156_c)

```Python:Python
N = int(input())
X = list(map(int, input().split()))

X.sort()
MAX = X[len(X)-1]

res=100000000
for i in range(MAX+1):
    SUM=0
    for j in range(len(X)):
        SUM += (X[j] - i) ** 2
    res = min(res, SU
M)

print(res)
```

#ABC 155
##[A - Poor](https://atcoder.jp/contests/abc155/tasks/abc155_a)

```Python:Python
A = [0] * 10

B = list(map(int, input().split()))
for i in range(len(B)):
    A[B[i]] += 1

for i in range(len(A)):
    if A[i] == 2:
        print('Yes')
        break
else:
    print('No')
```

##[B - Papers, Please](https://atcoder.jp/contests/abc155/tasks/abc155_b)

```Python:Python
N = int(input())
A = list(map(int, input().split()))

res = True
for i in range(N):
    if A[i] % 2 == 0 and (A[i] % 3 != 0 and A[i] % 5 != 0):
        res = False
        break
if res:
    print('APPROVED')
else:
    print('DENIED')
```

##[C - Poll](https://atcoder.jp/contests/abc155/tasks/abc155_c)

```Python:Python
N = int(input())
A = {}

MAX = 0
for i in range(N):
    s = input()
    A[s] = A.get(s,0) + 1
    MAX = max(MAX, A[s])

B = sorted(A.items())
for k, v in B:
    if v == MAX:
        print(k)
```

#ABC 154
##[A - Remaining Balls](https://atcoder.jp/contests/abc154/tasks/abc154_a)

```Python:Python
red, blue = input().split()
red_num, blue_num = list(map(int, input().split()))
s = input()

if s == red:
    red_num -= 1
elif s == blue:
    blue_num -= 1

print(red_num + ' ' + blue_num)
```

##[B - I miss you... / ](https://atcoder.jp/contests/abc154/tasks/abc154_b)

```Python:Python
import re

N = input()
N = re.sub(r'[A-z]', 'x', N)

print(N)
```

##[C - Distinct or Not](https://atcoder.jp/contests/abc154/tasks/abc154_c)

```Python:Python
N = int(input())
A = list(map(int, input().split()))

MAX = 0
A_map = {}
for i in range(N):
    num = A[i]
    A_map[num] = A_map.get(num,0) + 1
    MAX = max(MAX, A_map[num])

if MAX>=2:
    print('NO')
else:
    print('YES')
```

#ABC 153
##[A - Serval vs Monster](https://atcoder.jp/contests/abc153/tasks/abc153_a)

```Python:Python
H, A = list(map(int, input().split()))

count=0
while H>0:
    H-=A
    count+=1
print(count)
```

##[B - Common Raccoon vs Monster](https://atcoder.jp/contests/abc153/tasks/abc153_b)

```Python:Python
H, N = list(map(int, input().split()))
A = list(map(int, input().split()))

if H<=sum(A):
    print('Yes')
else:
    print('No')
```

##[C - Fennec vs Monster](https://atcoder.jp/contests/abc153/tasks/abc153_c)

```Python:Python
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

A.sort()

SUM = 0
for i in range(N - K):
    SUM += A[i]

print(SUM)
```

##[D - Caracal vs Monster](https://atcoder.jp/contests/abc153/tasks/abc153_d)

```Python:Python
def dfs(h):
    if h == 1:
        return 1
    else:
        return dfs(h//2) * 2 + 1

H = int(input())

print(dfs(H))
```