Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10**7)

modulus = 10 ** 9 + 7
s = input()


def dp(i, j):
    """
    dynamic programming for abc 104
    :param i: index of the given string
    :param j: count of letters of composed string (like 'ABC')
    :return: the number of cases
    """
    if i == n:
        if j == 3:
            return 1
        else:
            return 0

    if i < n and j == 3:
        m = 3 if s[i] == '?' else 1
        return m * dp(i + 1, 3) % modulus

    if i < n and j < 3:
        m1 = 3 if s[i] == '?' else 1
        m2 = 1 if s[i] == '?' or s[i] == 'ABC'[j] else 0

        _pass = m1 * dp(i + 1, j) % modulus
        _take = m2 * dp(i + 1, j + 1) % modulus

        return _pass + _take


print(dp(0, 0))


### FIXED CODE ###

if __name__ == "__main__":
    modulus = 10 ** 9 + 7
    s = input()
    n = len(s)
    dp = [[0] * 4 for _ in range(n + 1)]

    for i in range(n + 1)[::-1]:
        for j in range(4)[::-1]:
            if i == n:
                if j == 3:
                    dp[i][j] = 1
                else:
                    dp[i][j] = 0
            else:
                is_wildcard = s[i] == '?'
                if j == 3:
                    m = 3 if is_wildcard else 1
                    dp[i][j] = m * dp[i + 1][3] % modulus

                else:
                    m1 = 3 if is_wildcard else 1
                    m2 = 1 if is_wildcard or s[i] == 'ABC'[j] else 0

                    dp[i][j] = (m1 * dp[i + 1][j] + m2 * dp[i + 1][j + 1]) % modulus
            # print(i, j, dp[i][j])
    print(dp[0][0])
n, k = map(int, input().split(" "))
a = [-1] + list(map(int, input().split(" ")))

i = 1
head = []
used = {}
roop = []

inte=False
index = 0
for _ in range(k):
    index += 1
    i = a[i]
    if i in used:
        head = [ k for k, v in used.items() if v < used[i]]
        roop = [ k for k, v in sorted(used.items())]
        inte =True
        break
    else:
        used[i] = index

if inte:
    if len(head) >= k:
        print(head[k-1])
    else:
        x = (k - 1 - len(head)) % len(roop)
        print(roop[x])
else:
    print(used[k-1])

### FIXED CODE ###

import sys

n, k = map(int, input().split(" "))
a = [-1] + list(map(int, input().split(" ")))

i = 1
head = []
used = {}
roop = []

index = 0
for _ in range(k):
    index += 1
    i = a[i]
    if i in used:
        head = [ k for k, v in sorted(used.items(), key=lambda x:x[1]) if v < used[i]]
        roop = [ k for k, v in sorted(used.items(), key=lambda x:x[1]) if v >= used[i]]
        if len(head) >= k:
            print(head[k-1])
        else:
            x = (k - 1 - len(head)) % len(roop)
            print(roop[x])
            sys.exit()
    else:
        used[i] = index

print([ k for k, v in sorted(used.items(), key=lambda x:x[1])][k-1])
a = input()
b = input()
nums = "123"
nums.remove(a)
nums.remove(b)
print(nums)

### FIXED CODE ###

a = int(input())
b = int(input())
nums = [1,2,3]
nums.remove(a)
nums.remove(b)
print(*nums)
N = int(input())
ans = [0]*(N)

M = int((N-2)**0.5)

for x in range(1, M+1):
  for y in range(1, M+1):
    for z in range(1, M+1):
      a = (x+y+z)**2 - (x*y + y*z + z*x)
      if a <= N:
      	ans[a-1] += 1

for i in range(N):
  print(ans[i])

### FIXED CODE ###

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

if N <= 3:
  for i in range(N):
    print(0)
  exit()

M = int((N-2)**0.5)
 
for x in range(1, M+1):
  for y in range(1, M+1):
    for z in range(1, M+1):
      a = (x+y+z)**2 - (x*y + y*z + z*x)
      if a <= N:
      	ans[a-1] += 1
 
for i in range(N):
  print(ans[i])
N, K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range (N-1)]

import sys
sys.setrecursionlimit(10**10)
edge = [[] for _ in range(N)]
for u,v in AB:
    edge[u-1].append(v-1)
    edge[v-1].append(u-1)

MOD = 10**9+7
mod = 10 ** 9 + 7
MAX = K+10
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX
def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
cominit()



visited = [False]*N
visited[0] = True
def dfs(s,ans):
    M = len(edge[s])-1*(s!=0)
    if M==0:
        return ans
    if s==0:
        ans *= fac[K-1] * finv[K-1-M]
        ans %= MOD
    else:
        ans *= fac[K-2] * finv[K-2-M]
        ans %= MOD

    for nv in edge[s]:
        if visited[nv]:continue
        visited[nv] = True
        ans = dfs(nv, ans)
    
    return ans

print(dfs(0,K))





### FIXED CODE ###

N, K = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range (N-1)]

import sys
sys.setrecursionlimit(10**9)
edge = [[] for _ in range(N)]
for u,v in AB:
    edge[u-1].append(v-1)
    edge[v-1].append(u-1)

MOD = 10**9+7
mod = 10 ** 9 + 7
MAX = K+10
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX
def cominit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
def cmb(n,r):
    if n < 0 or r < 0 or r > n:return 0
    if r > n/2: r = n-r        
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod

def permu(n,r):
    if n<=0 or r<=0 or r>n: return 0
    return (fac[n]*finv[n-r])%MOD
cominit()



visited = [False]*N
visited[0] = True
def dfs(s,ans):
    M = len(edge[s])-1*(s!=0)
    if M==0:
        return ans
    if s==0:
        ans *= permu(K-1, M)
        ans %= MOD
    else:
        ans *= permu(K-2, M)
        ans %= MOD

    for nv in edge[s]:
        if visited[nv]:continue
        visited[nv] = True
        ans = dfs(nv, ans)
    
    return ans

print(dfs(0,K)%MOD)
c=input()
a=input()
b=0
if c%2==1:
  print("No")
else:
  for i in range(c/2):
    if a[i]!=a[i+int(c/2)]:
      b=b+1
  if b==0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

c=input()
c=int(c)
a=input()
b=0
if c%2==1:
  print("No")
else:
  for i in range(int(c/2)):
    if a[i]!=a[i+int(c/2)]:
      b=b+1
  if b==0:
    print("Yes")
  else:
    print("No")
n, a, b = list(map(int, input().split(' ')))
ab = ''

for i in range(n):
    ab = ab + ('a' * a) + ('b' * b)
    if len(ab) == 0:
        break

print(ab[:n].count('a'))


### FIXED CODE ###

n, a, b = list(map(int, input().split(' ')))
blueBall = 0
answer = []

if a == 0:
    print(a)
else:
    if n / (a + b):
        answer = divmod(n, (a + b))
        blueBall = answer[0] * a
        if answer[1] > a:
            blueBall = blueBall + a
        else:
            blueBall = blueBall + answer[1]

        print(blueBall)
    else:
        if n <= a:
            print(n)
        elif n <= b:
            print(a)
t = input()
for i in range(len(t)):
  if t[i] == '?':
    t[i] = 'D'
print(t)

### FIXED CODE ###

t = input()
a = []
for i in range(len(t)):
    if t[i] == '?':
        a.append('D')
    else:
        a.append(t[i])
print(''.join(a))
k = int(input())
a,b = int(input())
ans = "NG"
for i in range(a,b+1):
  if(i%k==0):
    ans = "OK"
print(ans)
    
  

### FIXED CODE ###

k = int(input())
a,b = map(int,input().split())
ans = "NG"
for i in range(a,b+1):
  if(i%k==0):
    ans="OK"
print(ans)
a,b=list(int(input().split()))
print(max(a+b,a-b,a*b)

### FIXED CODE ###

a,b=list(map(int,input().split()))
print(max(a+b,a-b,a*b))
import stdin

year, month, date = stdin.readline().rstrip().split(sep='/')

y = int(year)
m = int(month)
d = int(date)

heisei_y = 2019
heisei_m = 4
heisei_d = 1

if y < heisei_y:
  print('Heisei');
elif  m < heisei_m:
  print('Heisei');
elif  d < heisei_d:
  print('Heisei');
else:
  print('TBD');



### FIXED CODE ###

from sys import stdin


year, month, date = stdin.readline().rstrip().split(sep='/')

y = int(year)
m = int(month)
d = int(date)

heisei_y = 2019
heisei_m = 4
heisei_d = 30

if y < heisei_y:
  print('Heisei')
elif  (y == heisei_y) and (m < heisei_m):
  print('Heisei')
elif  ((y == heisei_y) and m == heisei_m) and (d <= heisei_d):
  print('Heisei')
else:
  print('TBD')
input()
ms=[int(i) for i in input().split()]
c=0
for m in ms:
 if m<=c:
  c=m
  d+=1
print(d)

### FIXED CODE ###

input()
ms=[int(i) for i in input().split()]
c=d=0
for m in ms:
 if c<=m:
  c=m
  d+=1
print(d)
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

def change(a, x, y, h, w):
    ct = 0
    if x > 0:
        if a[x - 1][y] == '.':
            a[x - 1][y] = '#'
            ct += 1
    if y > 0:
        if a[x][y - 1] == '.':
            a[x][y - 1] = '#'
            ct += 1
    if x < w - 1:
        if a[x + 1][y] == '.':
            a[x + 1][y] = '#'
            ct += 1
    if y < h - 1:
        if a[x][y + 1] == '.':
            a[x][y + 1] = '#'
            ct += 1
    return ct


h, w = na()
a = [list(input()) for i in range(h)]
ct = 0
ds = h * w
trial = 0
for y in range(h):
    for x in range(w):
        if a[x][y] == '#':
            ct += 1
#print(ct)
while ct != ds:
    li = []
    for y in range(h):
        for x in range(w):
            if a[x][y] == '#':
                li.append([x, y])
    for p in li:
        ct += change(a, p[0], p[1], h, w)
    #print(ct)
    trial += 1

print(trial)




### FIXED CODE ###

import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

h, w = na()
maze = [list(input()) for _ in range(h)]
que = deque()
d = [[-1] * w for i in range(h)]
for i in range(h):
    for j in range(w):
        if maze[i][j] == "#":
            d[i][j] = 0
            que.append((i, j))
l = 0

while que:
    x, y = que.popleft()
    l = d[x][y]
    for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        nx = x + dx
        ny = y + dy
        if not 0 <= nx < h or not 0 <= ny < w or d[nx][ny] != -1:
            continue
        d[nx][ny] = l + 1
        que.append((nx, ny))
print(l)
import math , sys

N = int( input() )
A = list( map( int, input().split() ))
A.sort()
Cs = [0 for _ in range(10**6+1)]
M = A[-1]
#print(A)
i=0
while i < N:
    e = A[i]
    j=i+1
    if j < N and A[j]==e:
        while A[j] == A[i]:
            i+=1
        i = j
    else:
        Cs[e] = 1
        i+=1
#print(Cs[:30])
for e in A:
    i = 2
    while e*i < M+1:
        Cs[e*i] = 0
        i+=1
ans = sum(Cs)
print(ans)


### FIXED CODE ###

import math , sys

N = int( input() )
A = list( map( int, input().split() ))
A.sort()
Cs = [0 for _ in range(10**6+1)]
M = A[-1]
#print(A)
i=0
M = max(A)
for i in range(N):
    e = A[i]
    if Cs[e]==1:
        Cs[e]=2
    elif Cs[e]==0:
        Cs[e]=1

for i in range(len(Cs)):
    Cs[i] = Cs[i]%2

for e in A:
    i = 2
    while e*i <= M:
        Cs[e*i] = 0
        i+=1
ans = sum(Cs)
print(ans)
S == input()
if S[1] == 'R':
	print('ABC')
else:
    print('ARC')

### FIXED CODE ###

S = input()
if S[1] == 'R':
	print('ABC')
else:
    print('ARC')
# -*- coding: utf-8 -*-

import math

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

a.sort()
b.sort()
c.sort()

cnum = []

takadaka = math.ceil(k ** 0.75)

for i in range(min(takadaka,x)):
    for j in range(min(takadaka,y)):
        for l in range(min(takadaka,z)):
            cnum.append(a[i] + b[j] + c[l])

cnum.sort()
cnum.reverse()

for i in range(k):
    print(cnum[i])


### FIXED CODE ###

# -*- coding: utf-8 -*-

a = [0]*5
n = int(input())
a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())
a[4] = int(input())

bottle = min(a[0],a[1],a[2],a[3],a[4])

time = 0

if n % bottle == 0:
    time = int(n / bottle)
else:
    time = int(n // bottle) + 1

if bottle >= n:
    print(5)
else:
    print(time+4)
print(TODO)

### FIXED CODE ###

s = input()
r = 0
c = 0
for i in range(len(s)):
    if s[i]=='B':
        c += 1
    else:
        r += c
print(r)
def dfs(i):
    if dp[i] != -1:
        return dp[i]
    if i == n - 1:
        return 0
    cost = 0
    if i == n - 2:
        cost = dfs(i + 1) + abs(h[i] - h[i + 1])
    else:
        cost = min(dfs(i + 1) + abs(h[i] - h[i + 1]), dfs(i + 2) + abs(h[i] - h[i + 2]))
    dp[i] = cost
    return cost

print(dfs(0))

### FIXED CODE ###

import sys
n = int(input())
h = list(map(int, input().split()))
dp = [-1] * n

sys.setrecursionlimit(n + 2)
def dfs(i):
    if dp[i] != -1:
        return dp[i]
    if i == n - 1:
        return 0
    cost = 0
    if i == n - 2:
        cost = dfs(i + 1) + abs(h[i] - h[i + 1])
    else:
        cost = min(dfs(i + 1) + abs(h[i] - h[i + 1]), dfs(i + 2) + abs(h[i] - h[i + 2]))
    dp[i] = cost
    return cost

print(dfs(0))
N, T = map(int, input().split())

c = set()
for i in range(0, N):
    ci, ti = map(int, input().split())
    if ti > T:
        continue
    c.add(ci)

print(min(c))


### FIXED CODE ###

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

c = set()
for i in range(0, N):
    ci, ti = map(int, input().split())
    if ti > T:
        continue
    c.add(ci)

if c:
    print(min(c))
else:
    print('TLE')
p.q,r = map(int,input().split())
a = int(p+q)
b = int(q+r)
c = int(r+p)
l = []
l.append(a)
l.append(b)
l.append(c)
print(min(l))

### FIXED CODE ###

p,q,r = map(int,input().split())
a = int(p+q)
b = int(q+r)
c = int(r+p)
l = []
l.append(a)
l.append(b)
l.append(c)
print(min(l))
from collections import deque
H, W = map(int, input().split())
G = [list(input()) for i in range(H)]

black = 0
for g in G:
    black += g.count("#")


que = deque()
que.append([0, 0, 0])
direction = [(0, 1), (0, -1), (1, 0), (-1, 0)]

while que:
    nh, nw, cost = que.pop()
    G[nh][nw] = cost
    if nh == H - 1 & nw == W - 1:
        break

    for dh, dw in direction:
        if (0 <= nh + dh < H) & (0 <= nw + dw < W):
            if G[nh + dh][nw + dw] == ".":
                que.appendleft((nh + dh, nw + dw, cost + 1))

print(H * W - black - int(G[H - 1][W - 1]) - 1)


### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
Field = [list(input()) for i in range(H)]

que = deque()
que.append([0, 0])
Field[0][0] = 0

while que:
    now = que.popleft()
    if now == [H-1, W-1]:
        break

    if now[0]+1 <= H -1:
        if Field[now[0]+1][now[1]] == ".":
            Field[now[0]+1][now[1]] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0]+1, now[1]])

    if now[0]-1 >= 0:
        if Field[now[0]-1][now[1]] == ".":
            Field[now[0]-1][now[1]] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0]-1, now[1]])

    if now[1] + 1 <= W -1:
        if Field[now[0]][now[1]+1] == ".":
            Field[now[0]][now[1]+1] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0], now[1]+1])

    if now[1] -1 >= 0:
        if Field[now[0]][now[1]-1] == ".":
            Field[now[0]][now[1]-1] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0], now[1]-1])
else:
    print(-1)
    exit()
Z = int(Field[H-1][W-1])

sharp_cnt = 0
for f in Field:
    sharp_cnt += f.count("#")

print(H*W - sharp_cnt - Z - 1)
import sys
sys.setrecursionlimit(20000)
N, M = [int(i) for i in input().split()]
parent = [i for i in range(N+1)]
node_num = [1 for i in range(N+1)]
def find(x):
    if parent[x] == x:
        return x
    else:
        parent[x] = find(parent[x])
        return parent[x]

bridge = []
for i in range(M):
    A, B = [int(i) for i in input().split()]
    bridge.append([A, B])

bridge = bridge[::-1]
ans_rev = [N*(N-1)//2]
combi = 0
for i in range(M-1):
    A, B = bridge[i]
    r_A = find(A)
    r_B = find(B)
    if r_A != r_B:
        parent[r_B] = r_A
        combi += node_num[r_B] * node_num[r_A]
        node_num[r_A] += node_num[r_B]
    ans_rev.append(N*(N-1)//2-combi)

ans = ans_rev[::-1]
print(*ans, sep="\n"

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N, M = [int(i) for i in input().split()]
parent = [i for i in range(N+1)]
node_num = [1 for i in range(N+1)]
def find(x):
    if parent[x] == x:
        return x
    else:
        parent[x] = find(parent[x])
        return parent[x]

bridge = []
for i in range(M):
    A, B = [int(i) for i in input().split()]
    bridge.append([A, B])

bridge = bridge[::-1]
ans_rev = [N*(N-1)//2]
combi = 0
for i in range(M-1):
    A, B = bridge[i]
    r_A = find(A)
    r_B = find(B)
    if r_A != r_B:
        parent[r_B] = r_A
        combi += node_num[r_B] * node_num[r_A]
        node_num[r_A] += node_num[r_B]
    ans_rev.append(N*(N-1)//2-combi)

ans = ans_rev[::-1]
print(*ans, sep="\n")
import numpy as np
n , k = map(int,input().strip().split())
if k == 2:
    n = bin(n)[2:]
    print(len(n))
elif k==8:
    n = oct(n)[2:]
    print(len(n))
elif k == 3:
    n = np.base_repr(n, base=3)
    print(len(n))
elif k == 4:
    n = np.base_repr(n, base=4)
    print(len(n))
elif k == 5:
    n = np.base_repr(n, base=5)
    print(len(n))
elif k == 6:
    n = np.base_repr(n, base=6)
    print(len(n))
elif k == 7:
    n = np.base_repr(n, base=7)
    print(len(n))
elif k == 9:
    n = np.base_repr(n, base=9)
    print(len(n))

else:
    print(len(n))

### FIXED CODE ###

import numpy as np
n , k = map(int,input().strip().split())
n = np.base_repr(n, base=k)
print(len(n))
S=input()
S[3]="8"
print(S)


### FIXED CODE ###

print("2018"+input()[4:])
n=raw_input()
a=[]
for i in range(n):
   a.append(int(raw_input()))
print '%d %d %d' % (min(a), max(a), sum(a))

### FIXED CODE ###

n=input()
a=map(int,raw_input().split())
print "%d %d %d" % (min(a), max(a), sum(a))
from math import gcd

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
AA = [a//2 for a in A]
K = [1 for i in range(len(AA))]
'''
def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return(y)
'''
def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return(ans)
l = 1
g = AA[0]

for i in range(len(AA)):
    g = gcd(g, AA[i])
    l = lcm(l, AA[i])
AAA = [a // g for a in AA]
C = [a % 2 for a in AAA]

if C == K:
    ans = M // l
    print((ans+1)//2)
else:
    print(0)


### FIXED CODE ###


N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return(y)

def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return(ans)
l = 1
cnt = [0 for i in range(len(A))]
for i in range(len(A)):
    a = A[i]
    l = lcm(l, a)
    count = 0
    while True:
        if a % 2 == 0:
            a //= 2
            count += 1
        else:
            cnt[i] = count
            break
count = cnt[0]
flag = True
for i in range(len(A)):
    if cnt[i] != count:
        flag = False
        break
if flag:
    l = l // 2
    ans = M // l
    print((ans+1)//2)
else:
    print(0)
# n, m, l = map(int, input().split())

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

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

A = int(input())
B = int(input())

if A > B:
    print("GREATER")
elif B > A:
    print("LESS")
else:
    Print("EQUAL")


### FIXED CODE ###

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

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

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

# import sys
# input = sys.stdin.readline

A = int(input())
B = int(input())

if A > B:
    print("GREATER")
elif B > A:
    print("LESS")
else:
    print("EQUAL")
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    # A >= Bの場合
    sum = k + 1
else:
    # A < B の場合
    diff = b - a
    if diff == 1:
        sum = k + 1
    elif diff == 2:
        sum = k + 1
    else:
        # a->bコンボが利潤を生み続けるパターン
        k = 1 + k - a
        if k % 2 == 0:
            sum = a + ((diff) * (k / 2))
        else:
            # 最後1回はコンボができないので、叩くパターン
            print("b")
            sum = a + ((diff) * ((k - 1) / 2)) + 1

print(sum)


### FIXED CODE ###

n,k = [int(i) for i in input().split()]

# n以下の奇数の数をカウント
cnt = 0
for i in range(1, n+1):
    if i % 2 == 1:
        cnt+=1

if cnt >= k:
    print('YES')
else:
    print('NO')
n = int(input())
s = str(input())
s += "A"
q = s[0]
ans = 0
for i in range(n+1):
  if(q==s[i]):
    None:
  else:
    ans += 1
    q = s[i]
print(ans)

### FIXED CODE ###

n = int(input())
s = str(input())
s += "A"
q = s[0]
ans = 0
for i in range(n+1):
  if(q==s[i]):
    None
  else:
    ans += 1
    q = s[i]
print(ans)
n,m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

a_count = [0]*110000
a_sum = [0]*110000

for i in range(n):
    a_count[a[i]] += 1
    a_sum[a[i]] += a[i]

for i in range(100005,0,-1):
    a_count[i] += a_count[i+1]
    a_sum[i] += a_sum[i+1]

def chk(x):
    case = 0
    for i in range(n):
        if x-a[i] <= 1:
            case += n
        else:
            case += a_count[x-a[i]]
    if case >= m:
        ch = True
    else:
        ch = False
    return ch


l = 2*a[-1]+1    #NG
r = 1 #OK

while abs(r-l) > 1:
    kk = (r+l)//2
    if chk(kk):
        r = kk
    else:
        l = kk

ans = 0
sm = sum(a)

l = r

for i in range(n):
    if l-a[i] <= 0:
        ans += sm + n*a[i]
    else:
        ans += a_count[l-a[i]]*a[i] + a_sum[l-a[i]]

case = 0
for i in range(n):
    if l-a[i] <= 1:
        case += n
    else:
        case += a_count[l-a[i]]

ans -= (case-m)*l

print(ans)

### FIXED CODE ###

from bisect import bisect_left
from bisect import bisect_right

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

a_count = [0]*110000
a_sum = [0]*110000

for i in range(n):
    a_count[a[i]] += 1
    a_sum[a[i]] += a[i]

for i in range(100005,0,-1):
    a_count[i] += a_count[i+1]
    a_sum[i] += a_sum[i+1]

def chk(x):
    case = 0
    for i in range(n):
        case += n-bisect_right(a,x-a[i]-1)
    if case >= m:
        ch = True
    else:
        ch = False
    return ch


l = 2*a[-1]+1    #NG
r = 1 #OK

while abs(r-l) > 1:
    kk = (r+l)//2
    if chk(kk):
        r = kk
    else:
        l = kk

ans = 0
sm = sum(a)

l = r

case = 0
for i in range(n):
    num = n-bisect_right(a,l-a[i]-1)
    case += num
    ans += num*a[i]*2

ans -= (case-m)*l

print(ans)
x = input()
le = len(x)
sum = 0
for i in range(le):
  sum+=int(x[i])
print(sum)


### FIXED CODE ###

import math
n,x,t = map(int,input().split())
c = t*math.ceil(n/x)
print(c)
print(int(input())/int(input())


### FIXED CODE ###

T,X=map(int,input().split())
print(T/X)
import itertools
import numpy as np 

exit_list = []
feature_fish = []
count=0
N = int(input())
num_fish = np.arange(N)
for i in range(N):
    A, B = (int(x) for x in input().split())
    feature_fish.append([A, B])

num_fish_seq = list(itertools.combinations(num_fish,2))
for i in range(len(num_fish_seq)):
    x = feature_fish[num_fish_seq[i][0]]
    y = feature_fish[num_fish_seq[i][1]]
    hontei = x[0]*y[0] + x[1]*y[1]
    if hontei != 0:
        count += 1
    else:
        exit_list.append(num_fish_seq[i])

for i in range(2, N):
    demo = list(itertools.combinations(num_fish, i+1))
    for k in range(len(demo)):
        check = 0
        for i in range(len(exit_list)):
            if not(set(exit_list[i]) <= set(demo[k])):
                check += 1
                if check == len(exit_list):
                    count += 1

result = count + len(num_fish)
answer = result % 1000000007
print(answer)


### FIXED CODE ###

a = input(str())

# print(a[-1])

hon = ['2', '4', '5', '7', '9']
pon = ['0', '1', '6', '8']

for h in hon:
    if a[-1] == h:
        print('hon')

for p in pon:
    if a[-1] == p:
        print('pon')

if a[-1] == '3':
    print('bon')
Num = int(input())
if "7" in Num:
  print("Yes")
else:
  print("No")
 

### FIXED CODE ###

Num = input()
if "7" in Num:
  print("Yes")
else:
  print("No")
a, b c, d = [int(input()) for i in range(4)]
print(min(a, b) + min(c, d))

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a, b) + min(c, d))