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:
A=list(input().split())

if A[0]==A[1] and A[2]==A[3]:
    print("Yes")
elif A[0]==A[2] and A[1]==A[3]:
    print("Yes")
elif A[0]==A[3] and A[1]==A[2]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

if A[0]==A[1] and A[2]==A[3]:
    print("Yes")
elif A[0]==A[2] and A[1]==A[3]:
    print("Yes")
elif A[0]==A[3] and A[1]==A[2]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s=int(input())
s.sort()
flag=True
if s[0]==s[1]:
    if s[1]!=s[1]:
        if s[2]==s[3]:
            print("Yes")
            flag=False
if flag:
    print("No")

Submission status: Runtime Error

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

ans = 0

#+2まで考慮してるから、nの数を-2にして調整しろ
for i in range(n-2):
	if p[i] < p[i + 1] < p[i + 2] or p[i + 2] < p[i + 1] < p[i]:
		ans = ans + 1

print(ans)

Submission status: Runtime Error

Solution code:
import collections
S = input()
S2 = collections.counter(S)
c = True
for i,v in S2.items():
  if v == 2:
    continue
  else:
    c = False
if c:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
s = input()

if len(set(s)) == 2 and l.count(s[0]) == 2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
s = raw_input
ans = 0
for i in range(3):
    if s[i] == s[i+1]:
        ans = 1
if ans == 1:
    print "Bad"
else:
    print "Good"

Submission status: Runtime Error

Solution code:
from math import ceil
mod=10**9+7
def comb(a,b):
	if a<b:
		return 0
	fac=[1]
	for i in range(a):
		fac.append(fac[i]*(i+1))
	r=pow(fac[b]*fac[a-b]%mod,mod-2,mod)
	return fac[a]*r%mod
n,k=map(int,input().split())
for i in range(1,k+1):
	q=comb(n-k+1,i)
	qq=comb(k-i+i-1,i-1)
	print(q*qq%mod)

Submission status: Runtime Error

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

count = 0

for i in range(n-1):
  if p[i]<p[i+1]<p[i+2] or p[i+2]<p[i+1]<p[i]:
    ans += 1
    
print(ans)

Submission status: Runtime Error

Solution code:
S = sort(list(input()))

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

Submission status: Runtime Error

Solution code:
s = input()
sCnt = s.count('S')
if sCnt != 2:
    print('No')
else:
    s = s.sort()
    if s[0]=='S':
        if s[2]==s[3]:
            print('Yes')
        else:
            print('No')
    elif  s[3]=='S':
        if s[0]==s[1]:
            print('Yes')
        else:
            print('No')
    else:
        if s[1]==s[2]:
            print('Yes')
        else:
            print('No')

Submission status: Runtime Error

Solution code:
s = sorted(input())
    if s[0] == s[1] and s[2] == s[3] and s[0] != s[3]:
        print("yes")
    else:
        print("no")

Submission status: Runtime Error

Solution code:
s = sorted(list(input()))
if len(s) == 4 
    if s[0] == s[1]:
        if s[2] == s[3] and s[1] != s[2]:
            print("yes")
        else:
            print("no")

    else:
        print("no")
else:
    print("no")

Submission status: Runtime Error

Solution code:
s=input()
u = set()
for let in s:
  u.add(let)
count=0
for let in s:
  if s[0] == let:
    count += 1
if count ==2 and u.size()==2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s=input()
u = set()
for let in s:
  u.add(let)
count=0
for let in s:
  if s[0] == let:
    count += 1
if count ==2 and u.size()==2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
s=input()
import colletions
s=dict(collections.Counter(s))
if len(s)==2:
  flag=True
  for k in s.values():
    if k!=2:
      flag=False
  if flag:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = list(map(int ,input().split()))
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:
S=input()
L=[]
for i in range(3):
    L.apend(S.count(S[i]))
if sum(L)==6:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s=input()
s=sorted(s)

if s[1]==s[2] and s[3]==s[4] and s[1]!=s[3]:
	print('Yes')
else:
  	print('No')

Submission status: Runtime Error

Solution code:
a = input()
a.sort()

if a[0]==a[1] and a[2]==a[3] and a[1]!=a[3]:
    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[1]!=S[2])or (S[1]==S[2] and S[0]==S[3] and S[0]!=S[1])or (S[0]==S[2] and S[1]==S[3] and S[1]!=S[2]):
  print(Yes)
else:
  print(No)

Submission status: Runtime Error

Solution code:

N, M = [int(x) for x in input().strip().split(" ")]

vs = set()
def dfs_w(v, d, t):
    # dfs while版 
    r = -1
    stack = [v]
    path = []
    while True:
        if len(stack) == 0:
            break
        v = stack.pop()
        if v < 0:
            path.pop()
        else:
            path.append(v)
            vs.add(v)
            for u in d[v]:
                if u == t:
                    if r != -1:
                        r = min(len(path)//3, r)
                    else:
                        r = len(path)//3
                if u in vs:
                    continue
                stack += [-v, u]
    return r

d = [set() for _ in range(3*N+1)]
for _ in range(M):
    a, b = [int(x) for x in input().strip().split(" ")]
    d[a].add(N+b)
    d[N+a].add(2*N+b)
    d[2*N+a].add(b)

s, t = [int(x) for x in input().strip().split(" ")]
print(dfs_w(s, d, t))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
n = 0
if S[1] not in S[0]:
  n += 1
if S[2] not in S[0,1]:
  n += 1
if S[3] not in S[0,2]:
  n += 1
if n == 2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = sorted(list(input()))

if a[0] == a[1] and a[2] == a[3] and a[0] != a[2]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s = input()
first = s[0]
cnt_f = 0
cnt_s = 0
for i in range(len(s)):
    if s[i] != first:
        second = s[i]
        break
for i in range(len(s)):
    if s[i] == first:
        cnt_f+=1
    if s[i] == second:
        cnt_s+=1
if cnt_f == 2 and cnt_s == 2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A = list(input())
if len(set(A) == 2 & A.count(A[0]) == 2:
       print('Yes')
else:
       print('No')

Submission status: Runtime Error

Solution code:
A = input()
if len(set(A) == 2 & A.count(A[0]) == 2:
       print('Yes')
else:
       print('No')

Submission status: Runtime Error

Solution code:

s = input()
c = collections.Counter(s)

if [2,2] == [x for x in c.values()]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
p = [int(i) for i in input().split()]
ctn = 0
for j in range(1, n-1):
    if p[j - 1] < p[j] < p[j + 1] or p[j + 1] < p[j] < p[j - 1]:
        ctn += 1
print(ctn)

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
mod = 10**9+7

a = [1 for i in range(2010)]

memo = 1
for i in range(1,2001):
    memo *= i
    a[i] = memo



for i in range(1,k+1):
    if not((n-k+2 > i)):
        print(0)

    else:
        memo1 = a[n-k+1]*a[k-1]
        memo2 = a[i]*a[n-k+1-i]*a[i-1]*a[k-i]

        ans2 = memo1//memo2
        print(ans2%mod)

Submission status: Runtime Error

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



for i in range(1,k+1):
    if (n-k < i):
        print(1)

    else:
        total = 1
        total2 = 1
        total3 = 1
        for j in range(i+1):
            total *= n-k+1-j
            total2 *= j+1
            total3 = int(total/total2)
            
        ww = i**(k-i-2)
        ans = ww * total3

        ans2 = ans % 1000000007

        print(ans2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
sorted = list(S).sort()
if sorted[0] == sorted[1] && sorted[2]==sorted[3]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()
ans = []
for i in range(4):
    ans.append(s[i])

ans.sort()
print('Yes' if ans[0] == ans[1] and ans[2] == ans[3] ans ans[0] != ans[2] else 'No')

Submission status: Runtime Error

Solution code:
S = input()
n=0
if S[0] == S[1]== S[2] or S[1]== S[2]== S[3] or S[0]== S[1]== S[3] or S[0]== S[2]== S[3]:
print('No')
else:
    for i in range 3:
        for t in ( i+1, 4):
            if S[i] == S[t]:
                n+ = 1
    if n == 2:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
from math import factorial

def comb(n, r):
    if n < r:
        return 0
    return (factorial(n) // (factorial(n-r) * factorial(r)))

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

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

Submission status: Runtime Error

Solution code:
from math import factorial

def comb(n, r):
    if n < r:
        return 0
    return factorial(n) // (factorial(n-r) * factorial(r))

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


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

Submission status: Runtime Error

Solution code:
s=input()
asdf=True
deta=tuple(s)
if len(data)==2:
  print("No")
else:
  if s.count(data[0])==2:
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
s.sorted()
if s.count(s[0]) == s.count(s[-1]):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
s = input()
s.sort()
if s.count(s[0]) == s.count(s[-1]):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
n, k =map(int, input().split())
mod = 10 ** 9 + 7
def com(a, b):
  b = min(b, a-b)
  sum = 1
  for i in range(a-b+1, a+1):
    sum *= i
  for j in range(1, b+1):
    sum //= j
  return sum % mod
for i in range(1, k+1):
  ans = com(n-k+1, i) * com(k-1, i-1) % mod
  print(ans)

Submission status: Runtime Error

Solution code:
a = list(map(str,input()))
if a[0] = a[1] and a[2] = a[3] and a[0] != a[2]:
    print("Yes")
elif a[0] = a[3] and a[1] = a[2] and a[0] != a[1]:
    print("Yes")
elif a[0] = a[2] and a[1] = a[3] and a[0] != a[1]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s= input()
if s.count(s[0]) == 2 && s.count(s[1]) == 2:
  print("Yes")
else :
  print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S=sorted(input())
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:
s = list(input())
t = list(set(s))
if s.count(t[0]) == s.count(t[1]):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
S=input()

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

Submission status: Runtime Error

Solution code:
S=input()

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#include <iostream>
#include <map>
using namespace std;

int main()
{
    string s;
    cin >> s;
    map<char, int> mp;
    for (int i = 0; i < 4; i++)
    {
        mp[s[i]] += 1;
    }
    if (mp.size() != 2)
    {
        cout << "No" << endl;
        return 0;
    }

    for (auto i = mp.begin(); i != mp.end(); i++)
    {
        // cout << i->first << " " << i->second << "\n";
        if (i->second != 2)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = list(input())
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:
s = input()
if s[0] == s[1] and s[2] == s[3] or s[1] == s[2] and s[0] == s[3] or s[0] == s[2] and s[1] == s[3] and (a[0] != a[1] and a[1] != a[2] and a[2] != a[3]):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
a = set()
for i in s: a.add(i)
if len(a) == 2 and s.count(a[0]) == 2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] = 1
  else:
    dic[i] += 1
if len(dic) == 2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] = 1
  else:
    dic[i] += 1

Submission status: Runtime Error

Solution code:
S = 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:
s = str(input())
l = set(list(s))
if range(l) == 2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import Counter


s = input()
c = Counter(s)
if len(c) == 2 and c.most_common(1)[1] == 2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()
cnt = 0
for i in renge(4 - 1) :
  if s[i] != s[i + 1] :
    cnt += 1
if cnt != 0 && cnt <= 2 :
  print("Yes")
else :
  print("No")

Submission status: Runtime Error

Solution code:
n=int(input())

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

ans= 0

for i in range(1,n-1):
    lis= sorted([li[i],li[i-1],li[i+1]])
    #print(lis)
    if lis[1]==li[i]:
        ans +=1
print(ans)

Submission status: Runtime Error

Solution code:
S = int(input()).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:
s = input()
lis = list(s)
count = 0
if s.count(lis[0]) == 2:
   count+=1
else:
    if s.count(lis[1]) == 2:
        count+=1
    else:
        if s.count(lis[2]) == 2:
            count+=1
        else if count == 3:
            print("YES")
        else:
            print("NO")

Submission status: Runtime Error

Solution code:
s = input()
lis = list(s)
count_str = 0
if s.count(lis[0]) == 2:
   count+=1
else:
    if s.count(lis[1]) == 2:
        count+=1
    else:
        if s.count(lis[2]) == 2:
            count+=1
        else if count == 3:
            print("YES")
        else:
            print("NO")

Submission status: Runtime Error

Solution code:
S = input()
if len(set(S)) == 2:
  ans = 'Yes'  
else ans = 'No'
print(ans)

Submission status: Runtime Error

Solution code:
S = input()
if len(set(S)) == 2:
	ans = 'Yes'  
else ans = 'No'
print(ans)

Submission status: Runtime Error

Solution code:
S=input()
T=sorted(S.split())
print("Yes" if T[0] == T[1] and T[2]=T[3] and T[0] != T[2] else "No")

Submission status: Runtime Error

Solution code:
a=set(list(map(input().split())))
print("Yes" if len(a)==2 else "No")

Submission status: Runtime Error

Solution code:
import math
a, b, c, d = map(int, input().split())
e = (c*d)/math.gcd(c,d)
bb = b-(b//c + b//d- b//e)
aa = a-1-((a-1)//c+(a-1)//d-(a-1)//e)
z = bb-aa
print(z)

Submission status: Runtime Error

Solution code:
S = input()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
l=[i for i in input()]

ans='No'

con=len(unique(l))
if (con==2) and (l.count(l[0])==2):
  ans='Yes'

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
li = list(map(int,input().split()))
cnt=0
for x in range(n-2): #for xxx in ~~の~~はrange()をいれる
    if (max(li[x],li[x+1],li[x+2])!=li[x+1])and(min(li[x],li[x+1],li[x+2]!=li[x])):
        cnt+=1
    else:
        pass
print(cnt)

Submission status: Runtime Error

Solution code:
S = input()
dic = {}
for s in S:
	if not dic[s]:
		dic[s] = 1
	if dic[s]:
		dic[s] += 1
judge = 'Yes'
for k, v in dic.items():
	if v != 2:
		judge = 'NO'
print(judge)

Submission status: Runtime Error

Solution code:
s = input()
s1 = s[:1]
for i in range(1, 4):
  if(s[i:i+1] != s1):
    s[i:i+1] = s2
if(s.count(s1) == 2 and s.count(s2) == 2):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
S = input()

ans="No"
if S[0] == S[1] and S[0] != S[2] and S[0] != S[3] and S[2] == S[3]:
  ans = "Yes"
elif S[1] == S[2] and S[1] != S[0] and S[1] != S[3] and S[0] == S[3]:
  ans = "Yes"
elif S[2] == S[3] and S[2] != S[0] and S[2] != S[1] and S[0] == S[1]:
  ans = "Yes"
elif S[3] == S[0] and S[3] != S[1] and S[3] != S[2] and S[1] == S[2]:
  ans = "Yes"
elif S[1] == S[3] and S[1] != S[0] and S[1] != S[2] and S[2] == S[4]:
  ans = "Yes"

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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] and S[0] != S[1]:
    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] and S[0]!=S[1]:
  print(Yes)
else:
  print(No)

Submission status: Runtime Error

Solution code:
S = input()
if len(set(s)) == 2:
    for i in list(set(s)):
        if not S.count(i) == 2:
            print('No')
        else:
            print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

a=n-k+1

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

Submission status: Runtime Error

Solution code:
N = int(input())
Plist = list(map(int,input().split()))
ctr = 0
 
for i in range(1,N-2):
  if (Plist[i] > Plist[i-1]) or (Plist[i] > Plist[i+1]):
    ctr += 1
 
print(ctr)

Submission status: Runtime Error

Solution code:
S = input()


temp1 = S[1]
temp2 = S[2]
temp3 = S[3]
temp4 = S[4]


if temp1 == temp2 and temp3 == temp4 and len(set(S))==2:
    print("Yes")
elif temp1 == temp3 and temp2 == temp4 and len(set(S))==2:
    print("Yes")
elif temp1 == temp4 and temp2 == temp3 and len(set(S))==2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
four = input()
four_set = set(four)

if len(four_set) != 2:
  print("No")
else:
  if four.count(four_set[0]) != 2:
    print("No")
  else:
    print("Yes")

Submission status: Runtime Error

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


print(d)

Submission status: Runtime Error

Solution code:
A = input().split()
print(count(A[0]))

Submission status: Runtime Error

Solution code:
S = list(input())
result = []
if len(set(S))==2:
  for s in S:
    result.append(S.count(s))
    if result[0]==result[1]:
      print("Yes")
    else:
      print("No")
else:
  print("No")

Submission status: Runtime Error

Solution code:
S = list(input())
result = []
if len(set(S))==2:
  for s in S:
    result.append(S.count(s))
    if result[0]==result[1]:
      print("Yes")
      exit()
print("No")

Submission status: Runtime Error

Solution code:
S = list(input())
result = []
if len(set(S))==2:
  for s in S:
    result.append(S.count(s))
    if (result[0]==result[1]) == 2:
      print("Yes")

Submission status: Runtime Error

Solution code:
 S = [x for x in input().rstrip()]

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[2]!=S[3] and S[1]==S[2]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
y = sorted(input().split())
if (y[0] == y[1]) and(y[2]== y[3]):
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
s = list(input().split())
y = sorted(s)

if (y[0] == y[1]) and(y[2]== y[3]):
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
import math
n,k=input().split()
n=int(n)
k=int(k)
for i in range(1,k+1):
    x=math.factorial(n-k+1)/(math.factorial(n-k+1-i)*math.factorial(i))
    y=math.factorial(k-1)/(math.factorial(k-i)*math.factorial(i-1))
    ans=x*y%(10**9+7)
    print(int(ans))

Submission status: Runtime Error

Solution code:
n=int(input())
p=[int(i) for i in input().split()]
ans=0
for x in range(1,n-1):
    a=p[x-1]
    b=p[x]
    c=p[x+1]
    if a<b<c or c<b<a:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
s = input()
ans = 'No'
a = {x for x in s}
if len(a) == 2:
  if a.count(a[0]) == 2 and a.count(a[1]) == 2:
    ans = 'Yes'
    
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()
cmp = s[0]
cnt = 0
for i in range(1, n):
    if s[i] == cmp:
        cnt += 1
    else:
        cnt -= 1
if cnt == 0:
    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]

i = 0

if a == b:
  i += 1
if a == c:
  i += 1
if a == d:
  i += 1
  
if b == c:
  i += 1
if b == d:
  i += 1
if c == d:
  i += 1

if i == 2:
  print(YES)
else:
  print(NO)
S = input()

a = S[0]
b = S[1]
c = S[2]
d = S[3]

i = 0

if a == b:
  i += 1
if a == c:
  i += 1
if a == d:
  i += 1
  
if b == c:
  i += 1
if b == d:
  i += 1
if c == d:
  i += 1

if i == 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]

i = 0

if a == b:
  i += 1
if a == c:
  i += 1
if a == d:
  i += 1
  
if b == c:
  i += 1
if b == d:
  i += 1
if c == d:
  i += 1

if i == 2:
  print(YES)
else:
  print(NO)

Submission status: Runtime Error

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

c = 0
for i in range(1, n-1):
  if ls[i] > ls[i-1] and ls[i] < ls[i+1]:
    c += 1
  elif  ls[i] < ls[i-1] and ls[i] > ls[i+1]:
    c += 1
    
print(c)

Submission status: Runtime Error

Solution code:
w=input()
s=list(set(list(w)))

if len(s) = 2 and w.count(s[0]) = 2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
w=input()
s=set(list(w))

if len(s) = 2 and w.count(s[0]) = 2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
lis = []
for i in range(4):
  a = input()
  a = a.upper()
  lis += a

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

Submission status: Runtime Error

Solution code:
lis = []
for i in range(4):
  a = input()
  a = a.upper()
  lis += a
    
if lis[0] == lis[1] and lis[0] != lis[2] and lis[2] == lis[3]:
  print('Yes')
elif lis[0] == lis[2] and lis[0] != lis[1] and lis[1] == lis[3]:
  print('Yes')
elif lis[0] == lis[3] and lis[0] != lis[1] and lis[1] == lis[2]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
lis = []
for i in range(4):
  a = input()
  a = a.upper()
  lis += a

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

Submission status: Runtime Error

Solution code:
lis = []
for i in range(4):
  a = input().upper()
  lis += a

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

Submission status: Runtime Error

Solution code:
lis = []
for i in range(4):
  a = str(input())
  a = a.upper()
  lis += a
    
if lis[0] == lis[1]:
  print('Yes')
elif lis[0] == lis[2]:
  print('Yes')
elif lis[0] == lis[3]:
  print('Yes')
elif lis[1] == lis[2]:
  print('Yes')
elif lis[1] == lis[3]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
lis = []
for i in range(4):
  a = str(input())
  lis += a
    
if lis[0] == lis[1]:
  print('Yes')
elif lis[0] == lis[2]:
  print('Yes')
elif lis[0] == lis[3]:
  print('Yes')
elif lis[1] == lis[2]:
  print('Yes')
elif lis[1] == lis[3]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
for i in range(4):
  a = str(input())

lis = [ moji for moji in a ]

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

Submission status: Runtime Error

Solution code:
S = int(input())
# S = "SASA"
arr = []
for s in S:
    arr.append(s)
if (arr[0] == arr[1]):
    if (arr[2] == arr[3]):
        ans = "Yes"
    else:
        ans = "No"
else:
    if (arr.count(arr[0]) == 2 and arr.count(arr[1]) == 2):
        ans = "Yes"
    else:
        ans = "No"

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
p=list(map(int,input().split()))
#print(n)
#print(p)
i=1
l=[]
while i<n-1:
  if p[i-1]<p[i]<p[i+1] or p[i-1]>p[i]>p[i+1]:
    l.append(i)
  else:
    pass
  i+=1
print(len(l))

Submission status: Runtime Error

Solution code:
S=sorted(list(input()))
if S[0]==S[1] and S[1]!=S[2] and S[2]=S[3]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
n = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(1, n-1):
  A = [P[i-1], P[i], P[i+1]]
  sort = sorted(A)
  if sort[1] = A[1]:
    count += 1

print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
P = [int(input()) for _ in range(n)]
count = 0
for i in range(1, n-1):
  A = [P[i-1], P[i], P[i+1]]
  sort = sorted(A)
  if sort[1] = A[1]:
    count += 1

print(count)

Submission status: Runtime Error

Solution code:
s = input()
a = set()
for i in len(s):
  a.add(s[i])
if len(a) == 2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
s = input()
a = set()
for i in len(s):
  a.add(i)
if len(a) == 2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
S = list(input())
count = list(S.count(i) for i in set(S))
if count[0] == count[1] and count[0] == 2:
    print('Yes')
else:
    print('No')