Problem:


Score : 100 points

Problem Statement

You are given a 4-character string S consisting of uppercase English letters.
Determine if S consists of exactly two kinds of characters which both appear twice in S.

Constraints

The length of S is 4.

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.

Sample Input 1

ASSA

Sample Output 1

Yes

S consists of A and S which both appear twice in S.

Sample Input 2

STOP

Sample Output 2

No

Sample Input 3

FFEE

Sample Output 3

Yes

Sample Input 4

FREE

Sample Output 4

No



Sample input:
ASSA


Sample output:
Yes

Submission status: Runtime Error

Solution code:
n,k = map(int, input().split())
mod = 10**9+7
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in range(1,k+1):
        a = cmb(n-k+1,i)
        b = cmb(k-1,i-1)
        print((a*b)%mod)

Submission status: Runtime Error

Solution code:
    s=list(input())
    s.sort()
    if s[0] == s[1] and s[2]==s[3] and s[0]!=s[2]:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
d = sorted(list(map(int,input().split())))
print(d[n//2]-d[n//2-1])

Submission status: Runtime Error

Solution code:
import math
 
stri = input()
ary = stri.split()
n = int(ary[0])
k = int(ary[1])
 
ans1 = 1 * (n-k +1 )
ansi:int = 0
ansi = ans1
print(ansi)
 
for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Submission status: Runtime Error

Solution code:
import re
import numpy as np
from scipy.sparse import lil_matrix, csr_matrix

N, M = [int(i) for i in re.split(" ", input())]
G = lil_matrix((N, N), dtype=np.bool)

for i in range(M):
    u, v = [int(i) for i in re.split(" ", input())]
    G[u-1, v-1] = True
G = G.tocsr()
G = G.dot(G).dot(G)

S, T = [int(i) for i in re.split(" ", input())]

count = -1
G_tmp = G
for i in range(1, N+1):
    if i == 1:
        pass
    else:
        G_tmp = G_tmp.dot(G)
    if G_tmp[S-1, T-1]:
        count = i
        break

print(count)

Submission status: Runtime Error

Solution code:
import math
 
stri = input()
ary = stri.split()
n = int(ary[0])
k = int(ary[1])
 
ans1 = 1 * (n-k +1 )
ansi = ans1
print(ansi)
 
for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Submission status: Runtime Error

Solution code:
N = int(input())
d = list(map(int, input().split())) 
print(len(d))

if(len(d)%2!=0):
    print(0)
else: 
    print(d[int(len(d)/2)]-d[int(len(d)/2)-1])

Submission status: Runtime Error

Solution code:
import math

stri = input()
ary = stri.split()
n = int(ary[0])
k = int(ary[1])

ans1=int( 1 * (n-k +1 ))
ansi= int(ans1)
print(ansi)

for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Submission status: Runtime Error

Solution code:
# @author 

import sys

class DBlueAndRedBalls:
    def solve(self):
        MOD = 10 ** 9 + 7
        MAX_N = 2001
        C = [[0] * MAX_N for _ in range(MAX_N)]
        for i in range(MAX_N):
            C[0][i] = 1
        for i in range(1, MAX_N):
            C[i][i] = 1
            for j in range(i + 1, MAX_N):
                C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % MOD

        n, k = [int(_) for _ in input().split()]
        ans = [0] * (k + 1)
        if n == k:
            for i in range(1, k + 1):
                ans[i] = 1
        else:
            ans[1] = n - k + 1
            for i in range(2, min(n - k + 1, k) + 1):
                ans[i] = (C[i - 1][k - 1] * C[i - 1 - 1][n - k - 1] +
                          2 * (sum(C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(1, n - k - i + 1 + 1))) +
                          sum((ext - 1) * C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(2, n - k - i + 1 + 1))) % MOD

        for x in ans[1:]:
            print(x)

solver = DBlueAndRedBalls()
input = sys.stdin.readline

solver.solve()

Submission status: Runtime Error

Solution code:
# @author 

import sys

class DBlueAndRedBalls:
    def solve(self):
        MOD = 10 ** 9 + 7
        MAX_N = 2001
        C = [[0] * MAX_N for _ in range(MAX_N)]
        for i in range(MAX_N):
            C[0][i] = 1
        for i in range(1, MAX_N):
            C[i][i] = 1
            for j in range(i + 1, MAX_N):
                C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % MOD

        n, k = [int(_) for _ in input().split()]
        ans = [0] * (k + 1)
        if n == k:
            for i in range(k):
                ans[i] = 1
        else:
            ans[1] = n - k + 1
            for i in range(2, min(n - k + 1, k) + 1):
                ans[i] = (C[i - 1][k - 1] * C[i - 1 - 1][n - k - 1] +
                          2 * (sum(C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(1, n - k - i + 1 + 1))) +
                          sum((ext - 1) * C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(2, n - k - i + 1 + 1))) % MOD

        for x in ans[1:]:
            print(x)

solver = DBlueAndRedBalls()
input = sys.stdin.readline

solver.solve()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))


count = 0
for i in range(len(A) - 2):
    if (A[i] > A[i + 1]) and (A[i + 1] > A[i + 2]):
       count += 1
    elif (A[i + 2] > A[i + 1]) and (A[i + 1] > A[i]):
        count += 1
    else: 
        pass
print(count)

Submission status: Runtime Error

Solution code:
# @author 

import sys

class DBlueAndRedBalls:
    def solve(self):
        MOD = 10 ** 9 + 7
        MAX_N = 2001
        C = [[0] * MAX_N for _ in range(MAX_N)]
        for i in range(MAX_N):
            C[0][i] = 1
        for i in range(1, MAX_N):
            C[i][i] = 1
            for j in range(i + 1, MAX_N):
                C[i][j] = (C[i][j - 1] + C[i - 1][j - 1]) % MOD

        n, k = [int(_) for _ in input().split()]
        ans = [0] * (k + 1)
        if n == k:
            for i in range(k):
                ans[i] = 1
        ans[1] = n - k + 1
        for i in range(2, min(n - k + 1, k) + 1):
            ans[i] = (C[i - 1][k - 1] * C[i - 1 - 1][n - k - 1] +
                      2 * (sum(C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(1, n - k - i + 1 + 1))) +
                      sum((ext - 1) * C[i - 1][k - 1] * C[i - 1 - 1][n - k - ext - 1] for ext in range(2, n - k - i + 1 + 1))) % MOD

        for x in ans[1:]:
            print(x)

solver = DBlueAndRedBalls()
input = sys.stdin.readline

solver.solve()

Submission status: Runtime Error

Solution code:
s=input().split()
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]:
  print('Yes')
elif s[0]==s[2] and s[1]!=s[2] and s[1]==s[3]:
  print('Yes')
elif s[0]==s[3] and s[0]!=s[1] and s[1]==s[2]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
import math

stri = input()
ary = stri.split()
n:int = int(ary[0])
k:int = int(ary[1])

ans1:int =int( 1 * (n-k +1 ))
ansi:int = int(ans1)
print(ansi)

for i in range(2,k+1):
    ansi = ansi * (k- i + 1) / ( i - 1 ) *  (n-k - i + 2) / i 
    print(int(ansi % 1000000007))

Submission status: Runtime Error

Solution code:
S = str(input())
s = list(S)
if s[0] == s[1]:
    if s[2] == s[3]:
        print("Yes")
    else:
        print("No")
else if s[0] == s[2]:
    if s[1] == s[3]:
        print("Yes")
    else:
        print("No")
else if s[0] == s[3]:
    if s[1] == s[2]:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
N,k=map(int,input().split())
R=N-k
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
    
for i in range(1,k+1):
  a= cmb(k-1,i-1)
  b= cmb(R+1,i)
  print(a*b)

Submission status: Runtime Error

Solution code:
from math import factorial
n,k = map(int, input().split())
mod = 10**9+7
# a = comb(n, r)
for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    else:
        a = factorial(n-k+1) //factorial(i) //factorial(n-k+1 - i)
        print((a*(i**(k-i)))%mod)

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
H=10 ** 9 + 7
ans=N-K+1
print(ans)
for i in range(1,K):
    P=(N-K-i+1)/(i+1)
    Q=(K-i)/i
    if ans< H :
        ans=int(ans*P*Q)
        print(ans)
    else:
        ans=int(ans*P*Q % H)
        print(ans)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split(' '))
red = N-K
p = 10**9+7


def comb(n, k, p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 or k == 0:
        return 1
    a = factorial(n) % p
    b = factorial(k) % p
    c = factorial(n-k) % p
    return (a*power_func(b, p-2, p)*power_func(c, p-2, p)) % p


def power_func(a, b, p):
    """a^b mod p を求める"""
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b//2, p)
        return d*d % p
    if b % 2 == 1:
        return (a*power_func(a, b-1, p)) % p


def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)


for i in range(1, K+1):
    print(comb(red+1, i, p)*comb(K-1, i-1, p) % p)

Submission status: Runtime Error

Solution code:
s=input().split()
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]:
  print('Yes')
elif s[0]==s[2] and s[1]!=s[2] and s[1]==s[3]:
  print('Yes')
elif s[0]==s[3] and s[0]!=s[1] and s[1]==s[2]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
import math
def P(p, q):
  return math.factorial(p)//math.factorial(p-q)

def cmb(p, q):
  return P(p, q)//math.factorial(q)

n,k = map(int,input().split())
#print(n,k)

ans = []

x = 0
a = 1
if n-k == 1:
  b = 2
elif n-k > 1:
  b = cmb(n-k-1, 1)
else:
  b = 0
x = (2 + a * b)%(1000000007)
ans.append(x)

x = 0
if k == 1:
  a = 1
else:
  a = cmb(k-1, 1)
if n-k == 1:
  b = 1
elif n-k == 2:
  b = cmb(n-k-1, 1) * 2 + 1
else:
  b = cmb(n-k-1, 2) + cmb(n-k-1, 1) * 2 + 1
x = (a * b)%(1000000007)
ans.append(x)

#print(ans)

 
for i in range(3,k+1):
  x = 0
  a = cmb(k-1, i-1)#青玉の並べ方
  if n-k-1 < i-2:
    b = 0
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-2)
  elif n-k-1 < i-1:
    b = cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  else:
    b = cmb(n-k-1,i) + cmb(n-k-1, i-1) * 2 + cmb(n-k-1, i-2)
  x = (a * b)%(1000000007)
  ans.append(x)

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

Submission status: Runtime Error

Solution code:
import math

n, k = map(int, input().split())
if n > k:
	if n+1 >= 2*k:
		for i in range(k):
			j = i+1
			c_blue = (math.factorial(n-k+1))//((math.factorial(j))*(math.factorial(n-k+1-j)))
			c_div = (math.factorial(k-1))//((math.factorial(j-1))*(math.factorial(k-1-j+1)))
			comb = c_blue * c_div
			print(comb % 1000000007)
			
	else :
		for i in range(n-k+1):
			j = i+1
			c_blue = (math.factorial(n-k+1))//((math.factorial(j))*(math.factorial(n-k+1-j)))
			c_div = (math.factorial(k-1))//((math.factorial(j-1))*(math.factorial(k-1-j+1)))
			comb = c_blue * c_div
			print(comb % 1000000007)
		for _ in range(2*k -n -1):
			print(0)
else:
	print(1)
	for i in range(n-1):
		print(0)

Submission status: Runtime Error

Solution code:
import itertools

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



bits = [format(i,'b').zfill(N) for i in range(2**N)]

ans = [0 for i in range(k)]

for item in bits:
    if item.count('1') != k:
        continue;
    else:
        i_prev = "0"
        count = 0
        for i in item:
            if i == "1" and i_prev == "0":
                count += 1
            i_prev = i
        ans[count-1] += 1

# for i in ans:
#     print(i % 1000000007 )

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
d = map(int, input().split())
d = list(d)

import statistics
t = len(d) / 2
k_low = statistics.median_low(d)
k_high = statistics.median_high(d)

c = 0
C = 0
for i in d:
    if i < k_low:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0

c = 0
for i in d:
    if i >= k_high:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0
    
print(C)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())

def combination(a, b):
    minb = min(a-b, b)
    r = 1
    for i in range(1, b+1):
        r = r * (a-b+i)/i
    return r

if K == N:
    print(0)
    import sys
    sys.exit()

for i in range(1, K+1):
    if i-1 == 0:
        must = 1
    else:
        must = combination(K-1, i-1)
    left_ball = N-K-i+1
    if left_ball < 0:
        print(0)
        continue
    elif left_ball == 0:
        print(1)
        continue
    can = combination(left_ball+i, i)
    print(int((must*can)%(1000000007)))

Submission status: Runtime Error

Solution code:
n = input()
p = input().split()


n = int(n)

cnt=0

for i in range(1,n-1):
  if(p[i]<p[i+1] and p[i]>p[i-1]) or (p[i]>p[i+1] and p[i]<p[i-1]):
    cnt+=1;


   
  
print(cnt)

Submission status: Runtime Error

Solution code:
n = input()
p = input().split()


n = int(n)

cnt=0

for i in range(1,n-1):
  if(p[i]<p[i+1] and p[i]>p[i-1]) or (p[i]>p[i+1] and p[i]<p[i-1]):
    cnt+=1;

  
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
    if sum1==n-sum1:
        count+=1
    sum1=0
    sum2=0
print(count)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())

def conbi(arg1, arg2):
    k=1
    l=1
    for i in range(arg2):
        k=k*(arg1-i)
        l=l*(i+1)
    if arg1==0:
        k=1
    return k/l
        
for i in range(1,m+1):
    print(int(conbi(n-m+1,i)*conbi(m-1,i-1))%(1000000007))

Submission status: Runtime Error

Solution code:
n=int(input())
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
        else:
            sum2+=1
    if sum1==sum2:
        count+=1
    sum1=0
    sum2=0
print(count)

Submission status: Runtime Error

Solution code:

from math import lgamma
lfact = lambda n: lgamma(n + 1)
cmb = lambda n, r: lfact(n) - lfact(n - r) - lfact(r)

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

#def cmb(n, k):
#    m = 1
#    if n < 2 * k:
#        k = n - k
#    for i in range(1, k + 1):
#        m = m * (n - i + 1) / i    
#    return m

for i in range(1,k+1):
    print(
            int(cmb(k-1, i-1) * cmb(n-k+1, i) % (10**9+7))
            )

Submission status: Runtime Error

Solution code:
a,b,c,d=input()
count=0

if(a==b):
    count+=1
    if(c==d and a!=c):
        count+=1
elif(a==c):
    count+=1
    if(b==d and a!=b):
        count+=1
elif(a==d):
    count+=1
    if(b==c ana a!=b):
        count+=1

if(count==2):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a,b,c,d=input()
count=0

if(a==b):
    count+=1
    if(c==d):
        count+=1
else if(a==c):
    count+=1
    if(b==d):
        count+=1
else if(a==d):
    count+=1
    if(b==c):
        count+=1

if(count==2):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())

C = N-K+1
D = 1
for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
    else:
        ans = (C*D)%(10**9+7)
        print(ans)
    #print(C,D)
    C = C*(N-K-i+1)//(i+1)
    D = D*(K-i)//i

Submission status: Runtime Error

Solution code:
n=int(input())
p=list(map(int,input().split()))

c=0
for i in range(1,n-1):
  if (p[i-1]<p[i]<p[i+1]) or  (p[i-1]>p[i]>p[i+1]):
    c=c+1

print(c)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
p=str(input())
if p[0] ==p[1] ==p[2] ==p[3]:
    print("No") 
elif p[0] ==p[3] and p[1] == p[2]:
    print("Yes")
elif p[0] == p[1] and p[2] == p[3]:
    print("Yes")
elif p[0] ==p[2] and p[1] == p[3]:
else:
    print("No")

Submission status: Runtime Error

Solution code:
import math
MOD = 1000000007
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)

N, K = map(int, input().split())
num_0 = N - K
num_1 = K

for i in range(1, K+1):
    print(C(num_0+1, i)%MOD*C(num_1-1, i-1)%MOD)

Submission status: Runtime Error

Solution code:
S = input()
S=str(S)

if S[0]==S[1]:
  if S[2]==S[3]:
    if S[0] != S[2]:
    	print('Yes')
    else:
      print('No')
  else:
  	print('No')
elif S[0]==S[2]:
  if S[1]==S[3]:
    if S[0] != S[1]:
    	print('Yes')
    else:
      print('No')
  else:
  	print('No')
elif S[0]==S[3]:
  if S[1]==S[2]:
    if S[0] != S[1]:
    print('Yes')
    else:
      print('No')
  else:
  	print('No')
else:
	print('No')

Submission status: Runtime Error

Solution code:
facts = [1]
mod =  10**9 + 7
for i in range(1, 2010):
	facts.append((i*facts[-1])%mod)
modinv = []
for i in facts:
	modinv.append(pow(i, mod - 2, mod))

def choose(p, r):
	return (((facts[p]*modinv[r])%mod)*modinv[p-r])%mod

n, k = map(int, raw_input().split())
blue = k
red = n - k
for i in range(1, k+1):
	if i <= n - k + 1:
		print (choose(red + 1, i)*choose(k - 1, i - 1))%mod
	else:
		print 0

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
p=str(input())
if p[0] ==p[1] ==p[2] ==p[3]:
    print("No") 
elif p[0] ==p[3] and p[1] == p[2]:
    print("Yes")
elif p[0] == p[1] and p[2] == p[3]:
    print("Yes")
elif p[0] ==p[2] and p[1] == p[3]
else:
    print("No")

Submission status: Runtime Error

Solution code:
a = list(input())
s  = set(a)
if len(s) == 2 and a.count(s[0]) == a.count(s[1]):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
a,b,c,d=input()
count=0

if(a==b or a==c or a==d):
    count+=1

if(b==c or b==d or c==d):
    if(b!=a and c!=a and d!=a):
    count+=1

if(count==2):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
 s=input()
if s[0]!=s[1] and s[1]!=[2] and s[2]!=[3]:print("No")
>>> else:print("Yes")

Submission status: Runtime Error

Solution code:
a,b,c,d=input()
count=0

if(a==b or a==c or a==d):
    count+=1

if(b==c or b==d or c==d):
    if(b!=a and c!=a and d!=a)
    count+=1

if(count==2):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import math
all ,blue = map(int,input().split())
red = all - blue

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,blue+1):
    if (red+1) < i:
        print('0')
    else:
        print((combinations_count(blue-1,i-1)*combinations_count(red+1,i))%(10**9+7))

Submission status: Runtime Error

Solution code:
cnt = 0
for moji in s:
    #print(moji)
    num = s.count(moji)
    #print(num)
    if num == 2:
        cnt+=1
    else:
        break
        
if cnt == 4:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
S = input()

if S[0]==S[1] and S[2]==S[3]　and S[0]!=S[2]:
        print('Yes')

elif S[1]==S[2] and  S[0]==S[3] and S[0]!=S[1]:
        print('Yes')
        
elif S[1]==S[3] and  S[0]==S[2] and S[0]!=S[1]:
        print('Yes')

else :
    print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
if N % 2 == 1:
  print("0")
else:
  lis = input().split()
  lis.sort()
  if lis[int(N / 2 - 1)] == lis[int(N / 2)]:
    print("0")
  else:
    ans = []
    for i in range(int(lis[int(N / 2)]), int(lis[int(N / 2 + 1)])): 
      ans.append(i)
    print(len(ans))

Submission status: Runtime Error

Solution code:
>>> s=input()
if s[0]!=s[1] or s[1]!=[2] or s[2]!=[3]  :print("No")
>>> else:print("Yes")

Submission status: Runtime Error

Solution code:
import heapq
def sol(inp=input):
    n,m=map(int,inp().split())
    G={i+1:set() for i in range(n)}
    for _ in range(m):
        i,j=map(int,inp().split())
        G[i].add(j)
    s,t=map(int,inp().split())
    cache_kenken={}
    cache_kenkenpa={}
    def kenken(v):
        if v not in cache_kenken:
            cache_kenken[v]=[v2 for v1 in G[v] for v2 in G[v1]]
        return cache_kenken[v]
    def kenkenpa(v):
        if v not in cache_kenkenpa:
            cache_kenkenpa[v]=[v3 for v2 in kenken(v) for v3 in G[v2]]
        return cache_kenkenpa[v]
    visited={s}
    que=[]
    heapq.heappush(que,(0,s))
    while len(que)>0:
        step,u=heapq.heappop(que)
        for v in kenkenpa(u):
            #print('{}:{}->{}'.format(step,u,v))
            if v==t:
                return step+1
            if v not in visited:
                heapq.heappush(que,(step+1,v))
                visited.add(v)
    return -1
print(sol())

Submission status: Runtime Error

Solution code:
S = input()
ans = 0

for i in range(4):
    if S[i] == S[i + 1]:
        ans += 1

if ans == 2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S = input()
a = S[0]
b = S[1]
c = S[2]
d = S[3]
l = []
l.append(a)
l.append(b)
l.append(c)
l.append(d)
k = list(set(l))
if len(k) == 2:
  if count(a) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Runtime Error

Solution code:
S = list(input())
A = S[0]
while A in S :
    S.remove(A)
B = S[0]
if len(S) == 2 :
    if B in S :
        print("Yes")
    else :
        print("No")
else :
    print("No")

Submission status: Runtime Error

Solution code:
import sys
import collections

input = sorted(sys.argv[1])
a = collections.Counter(input)
if len(a) == 2 and a.most_common()[0][1] == 2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S = input()
a = S[0]
b = S[1]
c = S[2]
d = S[3]
l = []
l.append(a)
l.append(b)
l.append(c)
l.append(d)
k = set(l)
if len(k) == 2:
  if count(a) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s=input()
if s[0]!=s[1] and s[1]!=[2] and s[2]!=[3]  :print("No")
>>> else:print("Yes")

Submission status: Runtime Error

Solution code:
A,B,C,D = input()
S = (A+B+C+D)
S1 = []
if A == B == C== D:
    print('No')
    exit()
for i in S:
    if i.strip(A) !='':
        S1.append(i.strip(A))
if S1[0] == S1[1] and len(S1) == 2 and len(S2) == 2:
    print("Yes")
else :
    print("No")

Submission status: Runtime Error

Solution code:
A,B,C,D = input()
S = (A+B+C+D)
S1 = []
if A == B == C== D:
    print('No')
    ezxt()
for i in S:
    if i.strip(A) !='':
        S1.append(i.strip(A))
if S1[0] == S1[1] and len(S1) == 2 and len(S2) == 2:
    print("Yes")
else :
    print("No")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# A - Fifty-Fifty

s = input()
c = []
dict = {}
for i in s:
    if i in dict:
        dict[i] +=1
    else:
        dict[i] = 1
        c.append(i)
if dict[c[0]] == dict[c[1]] == 2 and len(dict) == 2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A,B,C,D = input()
S = (A+B+C+D)
S1 = []
for i in S:
    if i.strip(A) !='':
        S1.append(i.strip(A))
if S1[0] == S1[1] and len(S1) == 2:
    print("Yes")
else :
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
d = map(int, input().split())
d = sorted(d)
l = []
now = 0
ans = 0
for i in range(n-1):
    if d[i] != d[i+1]:
        a = d.index(d[i])
        b = d.count(d[i])
        index = a+b-1
        #print(index)
        if index+1 == n/2:
            #print(d[i+1], d[i])
            ans = d[i+1]-d[i]
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
  if ((p[i]>p[i+1]) and (p[i+1]>p[i+2]) and (p[i]>p[i+2])) or ((p[i]<p[i+1]) and (p[i+1]<p[i+2]) and (p[i]<p[i+2])):
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
dif = np.array(list(map(int, input().split())))
divide = 0
for k in range(min(dif), max(dif)+1):
    count_over = 0
    count_under = 0
    for i in range(len(dif)):
        if dif[i] >= k:
            count_over += 1
        else:
            count_under += 1
    if count_over == count_under:
        divide += 1
print(divide)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# A - Fifty-Fifty

s = input()
c = []
dict = {}
for i in s:
    if i in dict:
        dict[i] +=1
    else:
        dict[i] = 1
        c.append(i)
if dict[c[0]] == dict[c[1]] and len(dict) == 2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
S = input()

if (S[0]==S[1] and S[2]==S[3}) or (S[0]==S[2] and S[1]==S[3]) or (S[0]==S[3] and S[1]==S[2]):
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
a=map(str, input())
char=list(a)
b=set(char)
c=len(b)
if c=2:
	print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
p = set(map(int, input().split()))
p = list(p)
p.sort()
if len(p) % 2 == 1 and n % 2 == 1:
    print(0)
else:
    p = list(p)
    cnt = p[len(p)//2] - p[len(p)//2 -1]
    print(cnt)

Submission status: Runtime Error

Solution code:
s = input()
s = s.replace(s[0],'')
if len(s) == 0:
    print('No')
    break
else:
    s = s.replace(s[0],'')
if len(s) == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import collections
s=list(input())
a=collections.Counter(s)
values, counts = zip(*a.most_common())
if counts[0]==counts[1]==2 and len(values)==2:
   print("Yes")
else:
   print("No")

Submission status: Runtime Error

Solution code:
import collections
s=list(input())
a=collections.Counter(s)
b=a.keys()
c=a.values()
values, counts = zip(*a.most_common())
if counts[0]==counts[1]==2 and len(values)==2:
    print("Yes")
else:
   print("No")

Submission status: Runtime Error

Solution code:
s = input()
s = s.replace(s[0],'')
s = s.replace(s[0],'')
if len(s) == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
text = input()

if len(text) > 0:
	text1 = text.replace(text[0], "")
	text2 = text1.replace(text1[0], "")

	if len(text) == 4 and len(text1) == 2 and len(text2) == 0:
	  print("Yes")
	else:
	  print("No")
else:
	print("No")

Submission status: Runtime Error

Solution code:
import collections
s=list(input())
a=collections.Counter(s)
b=a.keys()
c=a.values()
values, counts = zip(*a.most_common())
if counts[0]==counts[1] and len(values)==2:
    print("Yes")
else:
   print("No")

Submission status: Runtime Error

Solution code:
S = input()
if S[0] == S [1]:
	if S[2] == S[3]:
		print("Yes")
	else:
		print("No")
elif S[0] == S[2]:
	if S[1] == S[3]:
		print("Yes")
	else:
		print("No")
elif S[0] == S[3]:
	if S[1] == S[2]:
		print("Yes")
	else:
		print("No")
else:

Submission status: Runtime Error

Solution code:
str = input()

char_count = 1
for i in range(3):
    if str[0] == str[i+1]:
        char_count += 1
    else:
        char2 = i+1
        char2_count = 0
        
if char_count == 2:
    for char in str:
        if str[char2] == char:
            char2_count += 1
            
    if char2_count == 2:
        print("Yes")
        
    else:
        print("No")
        
else:
    ("No")
    
    
print(char_count, char2_count)

Submission status: Runtime Error

Solution code:
N=int(input())
num = list(map(int, input().strip().split()))

count = 0
for i in range(N-2):
    if((num[i]<num[i+1]<num[i+2])or(num[i]>num[i+1]>num[i+2])):
        count +=1
print(count)

Submission status: Runtime Error

Solution code:
text = input()

text1 = text.replace(text[0], "")
text2 = text1.replace(text1[0], "")

if len(text) == 4 and len(text1) == 2 and len(text2) == 0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
A,B,C,D = input()
S = (A+B+C+D)
if len(S.strip(A)) == len(S.strip(B)) and len(S.strip(C)) == len(S.sript(D)):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
s = s.replace(s[0],'')
s = s.replace(s[0],'')
if len(s) == 0:
    print('Yes')
else:
   print('No')

Submission status: Runtime Error

Solution code:
z = input()
char_list = list(z)
if(len(char_list) == 4 ):
    for(char in char_list):
        if(char.count(char) != 2):
            print("No")
            next
        else:
            print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

ans = 0

for k in range(min(l)+1, max(l)):
    l_abc = [i for i in l if i < k]
    l_arc = [i for i in l if i >= k]
    if len(l_abc) == len(l_arc):
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import collections
 
s = list(input().rstrip())
c = coll.Counter(s)
 
if len(c.keys()) != 2:
  print("No")
 
else:
  if c.most_common()[0][1] != 2:
    print("No")
  else:
    print("Yes")

Submission status: Runtime Error

Solution code:
import collections
s=list(input())
a=collections.Counter(s)
b=a.keys()
c=a.values()
values, counts = zip(*a.most_common())
if values[0]==values[1] and len(b)==2:
    print("Yes")
else:
   print("No")

Submission status: Runtime Error

Solution code:
import pandas
import math
import numpy
import collections

x = input()
TF =  x.isupper() and x.isalpha()
flg  = 0
if(TF):
    li = [i for i in x]
    count_dict = collections.Counter(li)
    list = [v for k, v in count_dict.items()]
    
    if(list == [2,2]):
        print("Yes")
        flg = 1

if(flg == 0):
    print("No")

Submission status: Runtime Error

Solution code:
x=list(input())
a=x[0]
b=x[1]
c=x[2]
d=x[3]
if a==b and a!=c:
  if c==d:
    print(Yes)
  else:
    print(No)
elif a==c and a!=b:
  if b==d:
    print(Yes)
  else:
    print(No)
elif a==d and a!=b:
  if b==c:
    print(Yes)
  else:
    print(No)
else:
  print(No)

Submission status: Runtime Error

Solution code:
import collections

s = list(input().rstrip())
c = colc.Counter(s)

if len(c.keys()) != 2:
  print("No")

else:
  if c.most_common()[0][1] != 2:
    print("No")
  else:
    print("Yes")

Submission status: Runtime Error

Solution code:
import pandas
import math
import numpy
import collections

x = input()
TF =  x.isupper() and x.isalpha()
if(TF):
    li = [i for i in x]
    count_dict = collections.Counter(li)
    list = [v for k, v in count_dict.items()]
    
    if(list == [2,2]):
        print("Yes")

elif(TF==False):
    print("No")

Submission status: Runtime Error

Solution code:
text = input()

text1 = text.strip(text[0])
text2 = text1.strip(text1[0])

if len(text) == 4 and len(text1) == 2 and len(text2) == 0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
S=input()
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:print('Yes')
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]:print('yes')
elif S[0]==S[3] and S[1]==S[2] andS[0]!=S[1]:print('Yes')
else:print('No')

Submission status: Runtime Error

Solution code:
import pandas
import math
import numpy
import collections

x = input()
TF =  x.isupper() and x.isalpha()
if(TF):
    li = [i for i in x]
    count_dict = collections.Counter(li)
    list = [v for k, v in count_dict.items()]
    
    if(list == [2,2]):
        print("Yes")
        
print("No")

Submission status: Runtime Error

Solution code:
S = list(input())
S_cnt = dict()

for s in S:
  if s in S_cnt.keys():
    S_cnt[s] += 1
  else:
    S_cnt[s] = 1
    
res = 'Yes'
for s in S_dict.keys():
  if S_dict[s] != 2:
    res = 'No'
print(res)