iidai/codenet huggingface dataset:
Language: Python

N, K = map(int, input().split())
S = list(input())
if S[K-1] == "A":
    S[K-1] = "a"
elif S[K-1] == "B":
    S[K-1] = "b"
else:
    S[K-1] = "c"
ans = "".join(S)
print(ans)


Example test case(s):
input: 3 1
ABC

output: aBC
Language: Python

n = int(input())
x = list(map(int, input().split()))
x.reverse()
print(*x)


Example test case(s):
input: 5
1 2 3 4 5

output: 5 4 3 2 1
Language: Python

A, B = map(int, input().split())
print(A*B)


Example test case(s):
input: 2 5

output: 10
Language: Python

N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]


def dfs(cur, a, b, c):
    if cur == N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else 10 ** 9
    no_add = dfs(cur + 1, a, b, c)
    add_a = dfs(cur + 1, a + l[cur], b, c) + 10
    add_b = dfs(cur + 1, a, b + l[cur], c) + 10
    add_c = dfs(cur + 1, a, b, c + l[cur]) + 10

    return min(no_add, add_a, add_b, add_c)


print(dfs(0, 0, 0, 0))


Example test case(s):
input: 5 100 90 80
98
40
30
21
80

output: 23
Language: Python

N = int(input())

if N % 9 == 0:
    print('Yes')
else:
    print('No')


Example test case(s):
input: 123456789

output: Yes
Language: Python

N = int(input())
c = input()

num_w = c.count("W")
num_r = N - num_w

comp = "R"*num_r + "W"*num_w
ans = 0
for i in range(num_r):
    if c[i] != comp[i]:
        ans += 1

ans = min(num_w, num_r, ans)
print(ans)


Example test case(s):
input: 4
WWRR

output: 2
Language: Python

import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()


INF = 10 ** 18
MOD = 10 ** 9 + 7


def main():
    N = II()
    a_li = LI()

    a_li.sort()

    n = a_li[-1]

    dif = INF
    prev_dif = dif
    for a in a_li[:-1]:
        dif = min(abs(n/2 - a), dif)
        if dif != prev_dif:
            r = a
            prev_dif = dif

    print(n, r)


main()


Example test case(s):
input: 5
6 9 4 2 11

output: 11 6
Language: Python

S = input()
T = input()

N = len(S)
M = len(T)
ans = M
for i in range(N-M+1):
    S_2 = S[i:i+M]
    cnt = 0
    for j in range(M):
        if T[j] != S_2[j]:
            cnt += 1
    ans = min(ans, cnt)

print(ans)


Example test case(s):
input: cabacc
abc

output: 1
Language: Python

from bisect import bisect
n, m, x = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
ans = 0
i = bisect(a, x)
print(min(len(a[:i]), len(a[i:])))


Example test case(s):
input: 5 3 3
1 2 4

output: 1
Language: Python

def main():
    n = int(input())
    sdic = {}
    for _ in range(n):
        s = [_s for _s in sorted(input().strip())]
        s = ''.join(s)
        if s in sdic:
            sdic[s] += 1
        else:
            sdic[s] = 1
    ans = 0
    for k, v in sdic.items():
        ans += v*(v-1)//2
    print(ans)


if __name__ == '__main__':
    main()


Example test case(s):
input: 3
acornistnt
peanutbomb
constraint

output: 1
Language: Python

s = input()

if s == 'RRR':
    print(3)
elif s == 'SSS':
    print(0)
elif s == 'RRS' or s == 'SRR':
    print(2)
else:
    print(1)


Example test case(s):
input: RRS

output: 2
Language: Python

n = int(input())
res = 0
for _ in range(n):
    x, u = list(input().split())
    if u == "BTC":
        res += float(x) * 380000
    else:
        res += int(x)
print(res)


Example test case(s):
input: 2
10000 JPY
0.10000000 BTC

output: 48000.0
Language: Python

import collections


def main():
    n = int(input())
    v = list(map(int, input().split()))
    ve = []
    vo = []
    for i in range(n//2):
        ve.append(v[2*i])
        vo.append(v[2*i+1])
    ce = collections.Counter(ve)
    co = collections.Counter(vo)
    ans = n
    if ce.most_common()[0][0] != co.most_common()[0][0]:
        ans = n-ce.most_common()[0][1]-co.most_common()[0][1]
    elif len(ce) == 1 and len(co) == 1:
        ans = n-ce.most_common()[0][1]
    elif len(ce) == 1:
        ans = n-ce.most_common()[0][1]-co.most_common()[1][1]
    elif len(co) == 1:
        ans = n-ce.most_common()[1][1]-co.most_common()[0][1]
    else:
        ans = min(n-ce.most_common()[0][1]-co.most_common()[1]
                  [1], n-ce.most_common()[1][1]-co.most_common()[0][1])
    print(ans)


if __name__ == "__main__":
    main()


Example test case(s):
input: 4
3 1 3 2

output: 1
Language: Python

def main():
    a, b = map(int, input().split())
    print(a*b)


main()


Example test case(s):
input: 2 5

output: 10
Language: Python

a, b, c = input().strip().split()

if a == b and b == c:
    print("Yes")
else:
    print("No")


Example test case(s):
input: 2 2 2

output: Yes
Language: Python

a, b = map(int, input().split())
lst = [a+b, a-b, a*b]
print(max(lst))


Example test case(s):
input: -13 3

output: -10
Language: Python

A, B = map(int, input().split())

min = B * 10
max = (B+1) * 10 - 1

ans = -1
for i in range(min, max+1):
    if int(i * 0.08) == A:
        ans = i
        break

print(ans)


Example test case(s):
input: 2 2

output: 25
Language: Python

N = int(input())
if N % 2 == 0:
    print(N//2)
else:
    print(N//2+1)


Example test case(s):
input: 5

output: 3
Language: Python

import numpy as np
n = int(input())
A = np.zeros(n)

x, y, z = 1, 1, 1

while x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
    while x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x <= n:
        while x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x <= n:
            i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            A[i - 1] += 1
            z += 1
        z = 1
        y += 1
    y, z = 1, 1
    x += 1
for i in range(n):
    print(int(A[i]))


Example test case(s):
input: 20

output: 0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0
Language: Python

N, K = map(int, input().split())
A = []

for i in range(N):
    A.append(0)

for i in range(K):
    d = int(input())
    AA = list(map(int, input().split()))
    for j in range(d):
        A[AA[j] - 1] = 1

n = 0
for i in range(N):
    if A[i] == 0:
        n += 1
print(n)


Example test case(s):
input: 3 2
2
1 3
1
3

output: 1
Language: Python

n, k = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
tmp = li[:k]
print(sum(tmp))


Example test case(s):
input: 5 3
50 100 80 120 80

output: 210
Language: Python

A, B, C = map(int, input().split())
if B < C:
    print(0)
elif A * C < B:
    print(C)
else:
    print(B//A)


Example test case(s):
input: 2 11 4

output: 4
Language: Python

n, a, b = map(int, input().split())
print(min(n * a, b))


Example test case(s):
input: 7 17 120

output: 119
Language: Python

import sys
from bisect import bisect_left


def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [(int(a) % K) - 1 for a in input().split()]
    sum_A = [0 for _ in range(N + 1)]

    count = 0
    modK = dict()
    modK[0] = [0]
    for i in range(N):
        sum_A[i + 1] = (sum_A[i] + A[i]) % K
        if sum_A[i+1] not in modK:
            modK[sum_A[i+1]] = [i + 1]
        else:
            modK[sum_A[i+1]].append(i+1)

    for key in modK:
        lenK = len(modK[key])
        for i, a in enumerate(modK[key]):
            count += bisect_left(modK[key], a + K, i, lenK) - i - 1

    print(count)
    return 0


if __name__ == "__main__":
    solve()


Example test case(s):
input: 5 4
1 4 2 3 5

output: 4
Language: Python

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

gate_cond = [[int(x) for x in input().split()] for _ in range(m)]
max_under_th = max([l[0] for l in gate_cond])
min_upper_th = min([l[1] for l in gate_cond])
if min_upper_th - max_under_th >= 0:
    print(min_upper_th - max_under_th + 1)
else:
    print(0)


Example test case(s):
input: 4 2
1 3
2 4

output: 2
Language: Python

nums = list(map(int, input().split(" ")))
nums.sort(reverse=True)
print(nums[0]*10+nums[1]+nums[2])


Example test case(s):
input: 1 5 2

output: 53
Language: Python

ABC = list(map(int, input().split()))

A = ABC[0]
B = ABC[1]
C = ABC[2]

print(max([10*A+B+C, 10*B+C+A, 10*C+A+B]))


Example test case(s):
input: 1 5 2

output: 53
Language: Python

import sys
def input(): return sys.stdin.readline().rstrip()
def input_nums(): return list(map(int, input().split()))


def main():
    K, N = input_nums()
    A = input_nums()
    dist = []
    for i in range(len(A)-1):
        dist.append(A[i+1]-A[i])
    dist.append(K+A[0]-A[-1])
    maxv = max(dist)
    print(sum(dist) - maxv)


if __name__ == '__main__':
    main()


Example test case(s):
input: 20 3
5 10 15

output: 10
Language: Python

N = int(input())
S, T = input().split()

char_lists = []

for i, char in enumerate(S):
    char_lists.append(char)
    char_lists.append(T[i])

print("".join(char_lists))


Example test case(s):
input: 2
ip cc

output: icpc
Language: Python

n = int(input())
s = input()
cnt = 1
for i in range(n-1):
    if s[i] == s[i+1]:
        continue

    else:
        cnt += 1

print(cnt)


Example test case(s):
input: 10
aabbbbaaca

output: 5
Language: Python

A, B = map(int, input().split())
lst = []
lst.append(A+B)
lst.append(A-B)
lst.append(A*B)
print(max(lst))


Example test case(s):
input: -13 3

output: -10
Language: Python

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

for i in range(1, n+1):
    print(a.count(i)+b.count(i))


Example test case(s):
input: 4 3
1 2
2 3
1 4

output: 2
2
1
1
Language: Python

a = [int(input()) for i in range(5)]

dic = {}

for i in range(5):
    if str(a[i])[-1] == "0":
        dic.update({i: 0})
    else:
        dic.update({i: int(str(a[i])[-1]) - 10})


min_num = [i for i in dic if dic[i] == min(dic.values())][0]
a_sum = sum(a)
dic.pop(min_num)
print(abs(sum(dic.values())) + a_sum)


Example test case(s):
input: 29
20
7
35
120

output: 215
Language: Python

N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
print('No War' if max(max(x), X) < min(min(y), Y) else 'War')


Example test case(s):
input: 3 2 10 20
8 15 13
16 22

output: No War
Language: Python

def main():
    X, K, D = map(int, input().split())

    r = X // D
    if abs(r) > K:
        print(abs(X) - K * D)
        exit()
    a = X - r * D
    if (K - r) % 2 == 0:
        print(a)
    else:
        print(abs(D - a))


if __name__ == '__main__':
    main()


Example test case(s):
input: 6 2 4

output: 2
Language: Python

n = int(input())
l = input().split()
max = -1e9
min = 1e9
sum = 0
for i in range(n):
    sum += int(l[i])
    if max < int(l[i]):
        max = int(l[i])
    if min > int(l[i]):
        min = int(l[i])
print(min, max, sum)


Example test case(s):
input: 5
10 1 5 4 17

output: 1 17 37
Language: Python

H, W = map(int, input().split())
h, w = map(int, input().split())
ans = H * W - (h * W + w * H - h * w)
print(ans)


Example test case(s):
input: 3 2
2 1

output: 1
Language: Python

N, A, B = map(int, input().split())
ans = A * (N//(A+B)) + min(A, N % (A+B))
print(ans)


Example test case(s):
input: 8 3 4

output: 4
Language: Python

A, B, K = map(int, input().split())
if A+K-1 >= B-K+1:
    while A <= B:
        print(A)
        A += 1
else:
    i = 0
    while i <= K-1:
        print(A+i)
        i += 1
    while B-K+1 <= B:
        print(B-K+1)
        K -= 1


Example test case(s):
input: 3 8 2

output: 3
4
7
8
Language: Python

N, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
for i in range(1, N):
    tmp = a[i - 1] + a[i]
    if tmp > x:
        if tmp - x > a[i]:
            a[i - 1] = tmp - a[i] - x
            a[i] = 0
        else:
            a[i] = a[i] - (tmp - x)
        cnt += tmp - x

print(cnt)


Example test case(s):
input: 3 3
2 2 2

output: 1
Language: Python

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a == b:
    print('YES')
elif v <= w:
    print('NO')
else:
    if t < abs(a - b) / (v - w):
        print('NO')
    else:
        print('YES')


Example test case(s):
input: 1 2
3 1
3

output: YES
Language: Python

from collections import deque
n = int(input())
a = list(map(str, input().split()))
b = []

b = a[1::2][::-1]+a[::2]
if len(a) % 2 == 0:
    print(' '.join(b))
else:
    print(' '.join(b[::-1]))


Example test case(s):
input: 4
1 2 3 4

output: 4 2 1 3
Language: Python

n = int(input())
arr = {}

for i in range(n):
    s = input()
    if not s in arr:
        arr[s] = 1
    else:
        arr[s] += 1

max_count = max(arr.values())
dic = [key[0] for key in arr.items() if key[1] == max_count]

out_sort = sorted(dic)
for i in out_sort:
    print(i)


Example test case(s):
input: 7
beat
vet
beet
bed
vet
bet
beet

output: beet
vet
Language: Python

n = int(input())
s = str(input())

ans = 0

for i in range(n):
    x = set(s[:i+1])
    y = set(s[i+1:])

    z = 0
    for w in x:
        if w in y:
            z += 1
    if z > ans:
        ans = z
print(ans)


Example test case(s):
input: 6
aabbca

output: 2
Language: Python

s = input()

if len(s) == 2:
    print(s)
else:
    print(s[::-1])


Example test case(s):
input: abc

output: cba
Language: Python

import math
MOD = 10**9+7
f = math.factorial
n, m = sorted(map(int, input().split()))
print(max(2 - m + n, 0)*f(n)*f(m) % MOD)


Example test case(s):
input: 2 2

output: 8
Language: Python

N = int(input())
m = []
line = ''
m = [[[0 for k in range(10)] for j in range(3)] for i in range(10)]
for i in range(N):
    n = input().split()
    b = int(n[0])
    f = int(n[1])
    r = int(n[2])
    v = int(n[3])
    m[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            line += ' {0}'.format(m[i][j][k])
        print(line)
        line = ''
    if i < 3:
        print('#'*20)


Example test case(s):
input: 3
1 1 3 8
3 2 2 7
4 3 8 1

output:  0 0 8 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 7 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
####################
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 1 0 0
Language: Python

a = input()
print("Yes" if '9' in a else "No")


Example test case(s):
input: 29

output: Yes
Language: Python

N = int(input())
S = input()
x = 1
for i in range(N-1):
    if S[i] != S[i+1]:
        x = x+1
print(x)


Example test case(s):
input: 10
aabbbbaaca

output: 5
Language: Python

def main():

    N, M, Q = map(int, input().split())
    train = [[0 for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        l, r = map(int, input().split())
        train[l-1][r-1] += 1

    accum = [[0 for _ in range(N+1)]]
    for i in range(N):
        temp = [0]
        v = 0
        for j in range(N):
            v += train[i][j]
            temp.append(accum[-1][j+1]+v)
        accum.append(temp)

    for _ in range(Q):
        p, q = map(int, input().split())
        v = accum[q][q] - accum[p-1][q] - accum[q][p-1] + accum[p-1][p-1]
        print(v)


if __name__ == '__main__':
    main()


Example test case(s):
input: 2 3 1
1 1
1 2
2 2
1 2

output: 3
Language: Python

A, B = map(int, input().split())
if A == B:
    print("Draw")
elif A == 1:
    print("Alice")
elif B == 1:
    print("Bob")
elif A > B:
    print("Alice")
else:
    print("Bob")


Example test case(s):
input: 8 6

output: Alice
Language: Python

print(input().swapcase())


Example test case(s):
input: fAIR, LATER, OCCASIONALLY CLOUDY.

output: Fair, later, occasionally cloudy.
Language: Python

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(int(i))
        i += 1
    if n > 1:
        table.append(int(n))
    return table


def digit(i):
    if i > 0:
        return digit(i//10) + [i % 10]
    else:
        return []


def getNearestValueIndex(list, num):

    idx = np.abs(np.asarray(list) - num).argmin()
    return idx


S = input()
T = S.split('/')

date = int(T[1]+T[2])
if date <= 430:
    print('Heisei')
else:
    print('TBD')


Example test case(s):
input: 2019/04/30

output: Heisei
Language: Python

from itertools import *

N = int(input())
x = 1

N_list = [x+1 for x in range(N)]

n = list(product(N_list, repeat=3))

m = len(n)

print(m)


Example test case(s):
input: 2

output: 8
Language: Python

n, x = map(int, input().split())
m = [int(input()) for _ in range(n)]
m.sort()
print(n + (x - sum(m)) // m[0])


Example test case(s):
input: 3 1000
120
100
140

output: 9
Language: Python

N, K = [int(_) for _ in input().split()]
S = set()
for i in range(K):
    d = int(input())
    A = [int(_) for _ in input().split()]
    S = S | set(A)
print(N - len(S))


Example test case(s):
input: 3 2
2
1 3
1
3

output: 1
Language: Python

N = int(input())
ans = []

for i in range(1, N+1):
    if sum(range(1, i + 1)) < N:
        continue
    else:
        ans = [i - 1, sum(range(1, i + 1)) - N]
        break
for i in range(ans[0]+1):
    if i + 1 != ans[1]:
        print(i + 1)


Example test case(s):
input: 4

output: 1
3
Language: Python

a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")


Example test case(s):
input: 5 4

output: Yay!
Language: Python

import collections

n = int(input())
ls = [input() for i in range(n)]
c = collections.Counter(ls)

count = c.most_common()[0][1]
ans = []
p = c.most_common()
for i in range(len(c)):
    if p[i][1] == count:
        ans.append(p[i][0])
    else:
        break
ans = sorted(ans)
for i in ans:
    print(i)


Example test case(s):
input: 7
beat
vet
beet
bed
vet
bet
beet

output: beet
vet
Language: Python

n, a, b = map(int, input().split())
ans = n//(a+b)*a
r = min(n % (a+b), a)
ans += r
print(ans)


Example test case(s):
input: 8 3 4

output: 4
Language: Python

from collections import deque
H, W = map(int, input().split())
G = []
for i in range(H+2):
    if i == 0 or i == H+1:
        G.append('#'*(W+2))
    else:
        G.append('#' + input() + '#')

ans = 0
for sx in range(W+2):
    for sy in range(H+2):
        if G[sy][sx] == '.':
            dist = [[-float('inf') for i in range(W+2)] for i in range(H+2)]
            visited = [[-1 for i in range(W+2)] for i in range(H+2)]
            q = deque([])
            q.append((sx, sy))
            dist[sy][sx] = 0
            visited[sy][sx] = 1
            while q:
                x, y = q.popleft()

                if G[y][x+1] == '.' and visited[y][x+1] == -1:
                    q.append((x+1, y))
                    dist[y][x+1] = dist[y][x] + 1
                    visited[y][x+1] = 1

                if G[y][x-1] == '.' and visited[y][x-1] == -1:
                    q.append((x-1, y))
                    dist[y][x-1] = dist[y][x] + 1
                    visited[y][x-1] = 1

                if G[y+1][x] == '.' and visited[y+1][x] == -1:
                    q.append((x, y+1))
                    dist[y+1][x] = dist[y][x] + 1
                    visited[y+1][x] = 1

                if G[y-1][x] == '.' and visited[y-1][x] == -1:
                    q.append((x, y-1))
                    dist[y-1][x] = dist[y][x] + 1
                    visited[y-1][x] = 1
            for i in range(W+2):
                for j in range(H+2):
                    ans = max(ans, dist[j][i])
print(ans)


Example test case(s):
input: 3 3
...
...
...

output: 4
Language: Python

s = input()
t = input()

if t[:-1] == s:
    print('Yes')
else:
    print('No')


Example test case(s):
input: chokudai
chokudaiz

output: Yes
Language: Python

N = int(input())
mo = []
for _ in range(N):
    x, u = input().split()
    x = float(x)
    mo.append([x, u])
okz = 0
for i in mo:
    if i[1] == "JPY":
        okz += i[0]
    else:
        okz += i[0]*380000

print(okz)


Example test case(s):
input: 2
10000 JPY
0.10000000 BTC

output: 48000.0
Language: Python

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)
s = sorted(readline().rstrip())
t = sorted(readline().rstrip())[::-1]
print("Yes" if s < t else "No")


Example test case(s):
input: yx
axy

output: Yes
Language: Python

R, G, B, N = map(int, input().split())

score = 0
for i in range(N // R + 1):
    for j in range((N-i * R) // G + 1):
        if N - i * R - j * G >= 0 and (N - i * R - j * G) % B == 0:
            score += 1

print(score)


Example test case(s):
input: 1 2 3 4

output: 4
Language: Python

import sys


from bisect import bisect_left, bisect_right


input = sys.stdin.readline


def getS(): return input().strip()
def getN(): return int(input())
def getList(): return list(map(int, input().split()))
def getZList(): return [int(x) - 1 for x in input().split()]


INF = 10 ** 20
MOD = 1000000007


def solve():
    n = getN()
    dp = [-INF]
    for i in range(n):
        num = getN()
        num = -num
        if num >= dp[-1]:
            dp.append(num)
        else:
            idx = bisect_right(dp, num)
            dp[idx] = num

    print(len(dp) - 1)
    return


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":

    solve()


Example test case(s):
input: 5
2
1
4
5
3

output: 2
Language: Python

from collections import deque
N, M = map(int, input().split())
G = {i: [] for i in range(1, N+1)}
for _ in range(M):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
col = [-1 for _ in range(N+1)]
cnt = 0
for i in range(1, N+1):
    if col[i] < 0:
        col[i] = cnt
        que = deque([i])
        while que:
            x = que.popleft()
            for y in G[x]:
                if col[y] < 0:
                    col[y] = cnt
                    que.append(y)
        cnt += 1
cmax = max(col)
print(cmax)


Example test case(s):
input: 3 1
1 2

output: 1
Language: Python

a, b = map(int, input().split())
print(a+b if a == b else max(a, b)*2-1)


Example test case(s):
input: 5 3

output: 9
Language: Python

memTime = int(input())
memLate = input().split()
memLate = [int(i) for i in memLate]
colorList = []
memColor = 0
highLate = 0
for color in range(memTime):
    member = memLate[color]
    if member // 400 >= 8:
        highLate += 1
    elif ((member // 400) in colorList) == False:
        colorList.append(member // 400)
maxColor = len(colorList) + highLate
minColor = len(colorList)
if minColor == 0:
    minColor = 1
print(str(minColor) + " " + str(maxColor))


Example test case(s):
input: 4
2100 2500 2700 2700

output: 2 2
Language: Python

def main():
    A, B, C, X, Y = map(int, input().split())
    ans = 10 ** 10

    for k in range(max(X, Y) + 1):
        total = 2 * C * k + A * max(0, X - k) + B * max(0, Y - k)
        if total < ans:
            ans = total

    print(ans)


if __name__ == "__main__":
    main()


Example test case(s):
input: 1500 2000 1600 3 2

output: 7900
Language: Python

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    s = {1, 2, 4, 8, 16, 32, 64}
    ans = 0

    for i in range(1, N + 1):
        if i in s:
            ans = i

    print(ans)


if __name__ == '__main__':
    main()


Example test case(s):
input: 7

output: 4
Language: Python

n = input()
n = int(n[-1])

if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
    print("pon")
else:
    print("bon")


Example test case(s):
input: 16

output: pon
Language: Python

x = int(input())
print("ai1333{}".format("3"*(x // 100)))


Example test case(s):
input: 0

output: ai1333
Language: Python

N = int(input())
S = input()

ans = 1
tmp = S[0]
for s in S:
    if s != tmp:
        ans += 1
        tmp = s

print(ans)


Example test case(s):
input: 10
aabbbbaaca

output: 5
Language: Python

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

b = max(l)
s = sum(l)

if b < s - b:
    print('Yes')
else:
    print('No')


Example test case(s):
input: 4
3 8 5 1

output: Yes