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:
S = list(input())
ans = 'Yes'
count = list(S.count(i) for i in set(S))
if count[0] == count[1] and count[0] == 2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
water=list(map(int,input().split()))
x=[]
temp=0
for i in range(1,n,2):
    temp+=water[i]
x.append(sum(water)-2*temp)
for j in range(n-1):
    x.append(2*water[j]-x[-1])
res=map(str,x)
print(' '.join(res))

Submission status: Runtime Error

Solution code:
from collections import Counter
s = input()
s_list = list(s)
counter = Counter(s_list)
values = list(counter.values())
if values[0]==values[1]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#dp[i][j]: iまでからj枚えらんで和がkになるのは何通り
def main():
	n,a,b = map(int,input().split())
	print(b if b>n*a else n*a)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Runtime Error

Solution code:
S = input()
mozi = dict()
for i in range(4):
  try:
    mozi(S[i]) += 1
  except:
    mozi(S[i]) = 1
    
num = 0
for i in mozi:
  num += 1
  if S[i] != 2:
    print("No")
    exit()

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

Submission status: Runtime Error

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

Red = N-K
Blue = K
mod = 1000000007

ans = 1
for i in range(Blue):
    if Red < i:
            ans = 0
    elif i != 0:
        ans = (ans * (Red + 1 - i) * (Blue - i) // ((i + 1) * i))
    else:
        ans = (ans * (Red + 1 - i) // (i + 1))
    print(int(ans) % mod)

Submission status: Runtime Error

Solution code:
S = input()

S = S.split()

S = list(set(S))

if len(S == 2:
    print("Yes)
else:
    print("No")

Submission status: Runtime Error

Solution code:
def OrdinaryNumber(n,p,flag=None):
    
    #リストの要素数が3未満なら０を返す（再帰終了）
    if n < 3:
        return 0
    
    #p[0]<p[1]の場合
    if flag == "LessThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")+1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            
    #p[0]>p[1]の場合
    elif flag == "GreaterThan":
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")+1
    
    #最初のみ
    else:
        if p[1] < p[2]:
            count = OrdinaryNumber(n-1, p[1:], "LessThan")
            if p[0] < p[1]:
                count +=1
        else:
            count = OrdinaryNumber(n-1, p[1:], "GreaterThan")
            if p[0] > p[1]:
                count +=1
                
    return count

n = int(input())
print(OrdinaryNumber(n,list(map(int,input().split()))))

Submission status: Runtime Error

Solution code:
import collections
S = input()
L = collections.Counter(S)
if len(L) == 2 and L[0][1] == 2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
from collections import Counter
c = True
for (k, v) in Counter(input()):
  if v != 2:
    c = False
if c:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s = (input()

s1 = s[0]
if s.count(s1) == 2:
    s = s.replace(s1, "")
    s2 = s[0]
    if s.count(s2) == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Runtime Error

Solution code:
s = str(input())

if str.count(s[0]) == str.count(s[1]) == str.count(s[2]) == str.count(s[3]) == 2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
s=input()
cnt=0;a=0
res = []
for i in s:
    if i not in res:
        res.append(i)
for i in s:
    if res[0]==i:
        cnt+=1
    if res[1]==i:
        a+=1
if a==2 and cnt==2:
    print("Yes")
else:print("No")

Submission status: Runtime Error

Solution code:
s = input()
first = s[0]
count = 0
s_count = 0
for i in range(1,len(s)):
    if s[i] == first:
        count += 1
    else:
        second =s[i]  
        num = i
for i in range(1,len(s)):
    if num == i:
        m = 0
    elif second == s[i]:
        s_count += 1

if count == 1 and s_count == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
first = s[0]
count = 0
s_count = 0
for i in range(1,len(s)):
    if s[i] == first:
        count += 1
    else:
        second =s[i]  
        num = i
for i in range(len(s)):
    if num == i:
        continue
    elif second == s[i]:
        s_count += 1

if count == 1 and s_count == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import io
import sys
from functools import lru_cache

sys.setrecursionlimit(10 ** 7)
HOGE = 10 ** 9 + 7


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
2000 3
'''


def MAIN():
  # T_IN()
  A()


def A():
  x = IN_L_I()
  n = x[0]
  k = x[1]

  for i in range(1, k + 1):
    blue = f(k, i)

    # red = 0
    # red += f(n - k, i - 1)
    # red += f(n - k, i)
    # red += f(n - k, i)
    # red += f(n - k, i + 1)
    red = f2(n - k - (i - 1), i + 1)

    res = int((blue * red) % HOGE)
    print(res)
  return None


def f(x: int, y: int):
  if x < y:
    return 0
  if x == y == 0:
    return 1
  if y < 1:
    return 0
  return f2(x - y, y)


def f2(x: int, y: int):
  return c(x + y - 1, y - 1)


def c(a: int, b: int):
  return pascal(a, b)


@lru_cache(maxsize=None)
def pascal(x, y):
  if x < 0 or y < 0:
    return 0
  if x < y:
    return 0

  if x == 0 or y == 0 or x == y:
    return 1
  else:
    return (pascal(x - 1, y - 1) + pascal(x - 1, y)) % HOGE


MAIN()

Submission status: Runtime Error

Solution code:
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
2000 3
'''


def MAIN():
  # T_IN()
  init()
  A()


def A():
  n, k = IN_L_I()

  for i in range(1, k + 1):
    blue = f(k, i)

    red = 0
    red += f(n - k, i - 1)
    red += f(n - k, i)
    red += f(n - k, i)
    red += f(n - k, i + 1)

    res = int((blue * red) % (10 ** 9 + 7))
    print(res)
  return None


def f(x: int, y: int):
  if x < y:
    return 0
  if x == y == 0:
    return 1
  if y < 1:
    return 0
  return f2(x - y, y)


def f2(x: int, y: int):
  return c(x + y - 1, y - 1)


def c(a: int, b: int):
  global hoge
  return hoge[a][b]


hoge = [[0 for i in range(4004)] for j in range(4004)]


def init():
  global hoge
  hoge[0][0] = 1
  for i in range(0, 4000):
    for j in range(0, i + 1):
      hoge[i + 1][j] += (hoge[i + 1][j] + hoge[i][j]) % (10 ** 9 + 7)
      hoge[i + 1][j + 1] += (hoge[i + 1][j + 1] + hoge[i][j]) % (10 ** 9 + 7)


MAIN()

Submission status: Runtime Error

Solution code:
print('YES' if len(set(input())==2 else 'NO')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import Counter
s=list(input())
a=Counter(s).most_common(2)
print("Yes" if a[0][1]==a[1][1]==2 else "No")

Submission status: Runtime Error

Solution code:
N=int(input())
L=list(input().split())
NL=sorted(L)
P=int(NL[int(N/2)-1])
Q=int(NL[int(N/2)])
print(Q+1-P)

Submission status: Runtime Error

Solution code:
N=int(input())
L=list(input().split())
NL=sorted(L)
P=int(NL[int(N/2)-1])
Q=int(NL[int(N/2)])
print(Q+1-P)
print(L[1])

Submission status: Runtime Error

Solution code:


import sys
sys.setrecursionlimit(10000)

n, k = map(int,input().split())
nck = {}

def c(n,k):
    if k == 0 or n==k:
        return 1
    elif n<k:
        return 0
    elif k == 1:
        return n  
    elif (n,k) in nck:
        return nck[(n,k)]
    else:
        nck[n,k] = c(n-1,k-1)+c(n-1,k)
        return nck[n,k]

for j in range(1,k+1):
    r = (c(n-k+1,j)*c(k-1,j-1))%(10**9+7)
    print(r)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()

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

Submission status: Runtime Error

Solution code:
import sys
s = input()
a = s[0]
if s.count(a) != 2:
  print("No")
  sys.exit()
s.replace(a)
b = s[0]
if s.count(b) != 2:
  print("No")
  sys.exit()
print("Yes")

Submission status: Runtime Error

Solution code:
s = input()
a = s[0]
if s.count(a) != 2:
  print("No")
  sys.exit()
s.strip(a)
b = s[0]
if s.count(b) != 2:
  print("No")
  sys.exit()
print("Yes")

Submission status: Runtime Error

Solution code:
s = input()
a = s[0]
if s.count(a) != 2:
  print("No")
  sys.exit()
s.remove(a)
s.remove(a)
b = s[0]
if s.count(b) != 2:
  print("No")
  sys.exit()
print("Yes")

Submission status: Runtime Error

Solution code:
S = input()
chars = []
for i in range(len(S)):
    chars.append(S[i])
if chars.count(chars[0]) == 2:
    for i in range(1, len(S) + 1):
        if chars[i] == 2:
            print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
four = input()

four = sorted(four)
if four[1] = four[2] and four[3] = four[4] and four[2] != four[3]:
	print ("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
S = input()

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

Submission status: Runtime Error

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

for i in range(1,4):
  s=t
  if s[0]==s[i]:
    z=s[0]
    s.pop(i)
    s.pop(0)
    if z!=s[0] and s[0]==s[1]:
      print("Yes")
      
print("No")

Submission status: Runtime Error

Solution code:
t=list(input())

for i in range(1,4):
  s=t
  if s[0]==s[i]:
    z=s[0]
    s.pop(i)
    s.pop(0)
    if z=!s[0] and s[0]==s[1]:
      print("Yes")
      
print("No")

Submission status: Runtime Error

Solution code:
s = list(input())

s.sort()
if s[0]==s[1] and s[2]==s[4]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

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

n=int(n[0])
p=p.split()
p=[int(p) for p in p]

output=0
for i in range(n-2):
    if p[i]<p[i+1] and p[i+1]<p[i+2]:
        output=output+1
    elif p[i+2]<p[i+1] and p[i+1]<p[i]:
        output=output+1
    else:
        output=output+0
    
print(output)

Submission status: Runtime Error

Solution code:
n=input()
ps=input()

n=int(n[0])
ps=ps.split()
ps=[int(ps) for ps in ps]

output=0
for i in range(n-2):
    if ps[i]<ps[i+1] and ps[i+1]<ps[i+2]:
        output=output+1
    elif ps[i+2]<ps[i+1] and ps[i+1]<ps[i]:
        output=output+1
    else:output=output+0
    
print(output)

Submission status: Runtime Error

Solution code:
from collections import defaultdict as dedict
counter = dedict(int)

a = input()
for i in list(a):
  counter[i] += 1
  
if ( len(counter) == 2) and (  counter [counter.keys()[0]] == 2):
  print ("Yes")
  
else:
  print('No')

Submission status: Runtime Error

Solution code:
s = input()

letters = []
for i in range(n):
  if not s[0] in letters:
    letters.append(s[0])
  
if len(letters)==2 and letters.count(s[0])==2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
import math

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

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

for i in range(1, n-k+2):
  ans = comb(n-k+1, i) * comb(k-1, i-1)
  ans %= mod
  print(int(ans))

Submission status: Runtime Error

Solution code:
s=list(input())
count(s)=0
v=0
i=0
while True:
  count(s[i])=count(s[i])+1
  i=i+1
  if count(s[i])==2:
    v=v+1
  if i==5:
    break
 
if v==2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n= input()

n_list=list(n)

a=(n_list.count(n_list[0]))
b=(n_list.count(n_list[1]))
c=(n_list.count(n_list[2]))
d=(n_list.count(n_list[3]))
print(a,b,c,d)
if (a==3 and c==and b==2 and d==2):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
def nCr(n,r):
    com = 1
    for i in range (1,r+1):
        com =com*(n+1-i)//i
    return com
N,K = map(int,input().split())
mod = (10**2)+7
for i in range(1,K+1):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%mod)

Submission status: Runtime Error

Solution code:
def nCr(n,r):
    com = 1
    for i in range (1,r+1):
        com =com*(n+1-i)//i
    return com
N,K = map(int,input().split())
print(nCr(N,K))
for i in range(1,K+1):
    com1 = nCr(N - K + 1, i)
    com2 = nCr(K-1,i-1)
    print((com1*com2)%(10**9+7))

Submission status: Runtime Error

Solution code:
S = list(input())
r = S[0]
for i in range(4):
 S.remove(r)
if S[0] == S[1] and len(S) == 2:
 print('Yes')
else:
 print('NO')

Submission status: Runtime Error

Solution code:
S = list(input())
r = S[0]
for i in range(4)
 S.remove(r)
if S[0] == S[1] and len(S) == 2:
 print('Yes')
else:
 print('NO')

Submission status: Runtime Error

Solution code:
S = list(input())
r = S[0]
S.remove(r)
S.remove(r)
if S[0] == S[1] and len(S) == 2:
 print('Yes')
else:
 print('NO')

Submission status: Runtime Error

Solution code:
s = int (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[2]:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# function which return reverse of a string
def reverse(s):
    return s[::-1]

def isPalindrome(s):
    # Calling reverse function
    rev = reverse(s)

    # Checking if both string are equal or not
    if (s == rev):
        return True
    return False


# Driver code
s = map(int, raw_input().split())
s = s[0]
ans = isPalindrome(s)

if ans == 1:
    print "Yes"
else:
    print "No"

Submission status: Runtime Error

Solution code:
# function which return reverse of a string
def reverse(s):
    return s[::-1]

def isPalindrome(s):
    # Calling reverse function
    rev = reverse(s)

    # Checking if both string are equal or not
    if (s == rev):
        return True
    return False


# Driver code
s = map(int, raw_input().split())
s = s[0]
ans = isPalindrome(s)

if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
value = list(map(int,input().split()))
value.sort()
print(value)
print(value[(int(N/2))]-value[(int(N/2))-1])

Submission status: Runtime Error

Solution code:
	from itertools import groupby

s = input()
result = True

for k, g in groupby(s):
        print(k, list(g))
        if s.count(k) is not 2:
                result = False

if result:
        print('Yes')
else:
        print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S=str(input())
L=[]
for S in range(4):
  L.append(S)
L.sort()

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

Submission status: Runtime Error

Solution code:
s=input()
if(s[0]==s[1] & s[2]==s[3]):
  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:
s = input()

d = {}
for	c in s:
  if c in d:
    d[c] = d[c]+1
  else:
    d[c] = 0
    
if len(c.keys())==2 and all([v==2 for k,v in c.items()]):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
S = input()
for i in S:
    if S.count(a[i]) == 2:
        ans += 1
if ans == 4:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:

S = str(input())
Si = [0]*4

for i in range(0,3):
    Si[i] = S[i]

Si.sort()

if ((Si[0]== Si[1]) & (Si[2]== Si[3])) & (not(Si[1]==Si[2])):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:

S = str(input())
Si = [0]*4

for i in range(0,3):
    Si[i] = S[i]

Si.sort()

if (Si[0]== Si[1]) & (Si[2]== Si[3]) & not(Si[1]==Si[2]):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:

S = str(input())
Si = [0]*4

for i in range(0,3):
    Si[i] = S[i]

Si.sort()

if (Si[0]== Si[1]) & (Si[2]== Si[3]):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
from collections import deque
 
N, M = map(int, input().split())
 
vec = [[] for _ in range(N)]
for _ in range(M) :
    u, v = map(int, input().split())
    vec[u-1].append(v-1)
 
S, T = map(int, input().split())
S, T = S - 1, T - 1
 
visited = [[False] * N for _ in range(3)]
visited[0][S] = True
queue = deque([(S, 0)])
 
while queue :
    #print(queue)
    q, cost = queue.popleft()
    #print(q,cost)
    #print("vec[q] =",vec[q])
    p = (cost + 1) % 3
    for i in vec[q] :
        if p == 0 and i == T :
            
            print((cost + 1) // 3)
            exit()
        if not visited[p][i] :
            visited[p][i] = True
            #print(visited)
            #print(i)
            queue.append((i, cost + 1))
 
print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
b=list(map(int,input().split()))
c=0
d=0
while c<=n-3 :
    if (b[c+1]>b[c] and b[c+1]<b[c+2]) or (b[c+1]<b[c] and b[c+1]>b[c+2]):
        d +=1
        c +=1
    else:
        c+=1

print(d)

Submission status: Runtime Error

Solution code:
n = int(input())

ls = list(map(int, input().split()))
 
count = 0

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

print (count)

Submission status: Runtime Error

Solution code:
n = int(input())

ls = list(map(int, input().split()))
 
count = 0

for i in range(1,n-1):
    if ls[i-1] < ls[i] and ls[i+1] > ls[i]:
        count+=1
    else:
        if ls[i-1] > ls[i] and ls[i+1] < ls[i]:
            count += 1

print count

Submission status: Runtime Error

Solution code:
n = int(input())

ls = list(map(int, input().split()))
 
count = 0

for i in range(n-2):
    if ls[i-1] < ls[i] and ls[i+1] > ls[i]:
        count+=1
    else:
        if ls[i-1] > ls[i] and ls[i+1] < ls[i]:
            count += 1

print count

Submission status: Runtime Error

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

con = True
for i in ss:
  con = False if ss.count(i) != 2 
  
  
if con:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
from collections import Collecter; print('YNeos'[Counter(sorted(list(input()))).values() != [2,2]::2])

Submission status: Runtime Error

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

#print(n)
#print(P_list)
print(count)

Submission status: Runtime Error

Solution code:
n,*a=Input.split()
#print(n,a)
l=list(n)
l.sort()
if (l[0]==l[1] and l[2]==l[3]):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = list(input().split())
s.sort()

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

Submission status: Runtime Error

Solution code:
import sys
arg = sys.argv
char = [*arg[1]]
if len(char) == 4:
    if char[0] == char[1] and char[1] != char[2] and char[2] == char[3]:
        print('Yes')
    elif char[0] != char[1] and char[1] == char[2] and char[2] != char[3]:
        print('Yes')
    elif char[0] == char[2] and char[1] == char[3] and char[0] != char[1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Runtime Error

Solution code:
list1 = [0,0]
S=""

a1 = S[0]
a2 = "NUM"

if S[1] == a1:
    list1[0]=2
else:
    a2 = S[1]

if S[2]==a1:
    list1[0]=2
else:
    if S[1]==a1:
        a2 =S[2]
    else:
        if S[2]==a2:
            list1[1]=2
        else:
            pass

if S[3]==a1:
    list1[0]=2
else:
    if S[2]==a1:
        a2 = S[3]
    else:
        if S[3]==a2:
            list1[1]=2
        else:
            pass

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

Submission status: Runtime Error

Solution code:
S = input().strip()
listS = list(S)
listS.sort()
if listS[0] == listS[1] and listS[2] == listS[3] and listS[0] != listS[2] and l\
istS[1] != listS[3]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

def resolve():
    S = list(raw_input())
    S.sort()
    print "Yes" if S[0] == S[1] and S[2] == S[3] else "No"

Submission status: Runtime Error

Solution code:
import sys

S = list(raw_input())
S.sort()
print "Yes" if S[0] == S[1] and S[2] == S[3] else "No"

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()

sorted_S = sorted(S)

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

Submission status: Runtime Error

Solution code:
s = input()

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

Submission status: Runtime Error

Solution code:
s = input()

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

Submission status: Runtime Error

Solution code:
list_a=[]
if len(list_a) !=AABB:
  print('ok')
else:
  print('no')

Submission status: Runtime Error

Solution code:
n = int(input())
p = list(map(int,input().split()))
i = 1
ans = 0
while i <= n-2:
  if (p[i]-p[i-1])*(p[i]-p[i+1]) < 0:
    ans += 1
  if (p[i]-p[i-1])*(p[i]-p[i+1]) == 0:
    if p[i] < p[i-1] or p[i] < p[i+1]:
      ans += 1
  i += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
mod = 1e9 + 7
def comb(n, r):
    if n == 0 or r == 0:
        return 1
    elif n < r:
        return 0
    else:
        m = n - r
        u = max(m, r)
        mul_sum = 1
        for j in range(u):
            loc_sum = (m - j) / (j + 1)
            mul_sum = mul_sum * loc_sum
        asr = int(mul_sum % mod)
        return asr



n, k = map(int, input().split())
ans = 0
red = n - k


for i in range(k):
    b_c = comb(k-1, i)
    r_c = comb(red+1, i+1)
    mlt = int(b_c * r_c)
    ans = mlt % mod
    print(int(ans))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)
from collections import Counter
input = sys.stdin.readline

S=input[:-1]
C=Counter(S)
if all([v==2 for key,v in C.items()]):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
def comb(n, r):
  if n < 0 or r < 0:
    return 0
  r = min(r, n - r)
  if n == 0 or r == 0:
    return 1
  return (n - r + 1) * comb(n, r - 1) // r

N, K = list(map(int, input().split()))
for i in range(K):
  print(comb(N - K + 1, i + 1) * comb(K - 1, i) % (10 ** 9 + 7))

Submission status: Runtime Error

Solution code:
n=int(input())
li = list(map(int,input().slice()))
cnt=0
for i in range(1,n-1):
    if li[i-1]<li[i]<li[i+1]:
        cnt+=1
    elif li[i-1]>li[i]>li[i+1]:
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
L = list(map(int, input().split()))
 
L_sorted= L.sort()
 
target_num = N/2
if L_sorted[target_num-1] = L_sorted[target_num]:
	ans = 0
else:
  	ans= L_sorted[target_num]-L_sorted[target_num-1]

print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
d=input().split()
d=[int(i) for i in d]
d_max=max(d)

ans=0

for j in range(d_max):
    arc=0
    abc=0
    for i in range(len(d)):
        if(j > d[i]):
            abc+=1
        if(j <= d[i]):
            arc+=1
        if(abc > len(d)/2+2):
            break
        if(arc > len(d)/2+2):
            break

        #print(arc,abc,ans,j,d[i])
    if abc==arc:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
  
  z = int(input())
  if 20 >= z and z >= 3:
    num_list = list(map(int, input().strip().split()))
    count = 0
    for i in range(z-2):
      hoge = num_list[i:i+3]
      hoge_sort = sorted(hoge)
      if hoge[1]==hoge_sort[1]:
        count += 1
    print(count)

Submission status: Runtime Error

Solution code:
import collections
x=input
s=list(x)
c=collections.Counter(s)
if(len(c.values(c))) == 2:
    if(c.values())[0]==2:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
import collections
x=input
s=list(x)
c=collections.Counter(s)
if(c.values(len(c))) == 2:
    if(c.values())[0]==2:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
import collections
s=input
c=collections.Counter(s)
if(c.values(len(c))) == 2:
    if(c.values())[0]==2:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
import sys


s = sys.argv[1]

if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")
exit()

Submission status: Runtime Error

Solution code:
import sys

""" print('sys.argv         : ', sys.argv)
print('type(sys.argv)   : ', type(sys.argv))
print('len(sys.argv)    : ', len(sys.argv))

print('sys.argv[0]      : ', sys.argv[0])
print('sys.argv[1]      : ', sys.argv[1])
print('type(sys.argv)   : ', type(sys.argv[1]))
 """
s = sys.argv[1]
# print(len(s))

if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")
exit()

Submission status: Runtime Error

Solution code:
# xの逆元は、x*y = 1 mod pとなるようなy
N, K = map(int, input().split())
mod = 10**9 + 7
a = N - K + 1
print(a)
for i in range(K-1):
    a = a * (N - K - i) * (K - (i + 1)) // ((i+2) * (i+1))
    a %= mod
    print(a)

Submission status: Runtime Error

Solution code:
# xの逆元は、x*y = 1 mod pとなるようなy
N, K = map(int, input().split())
mod = 10**9 + 7
a = N - K + 1
print(a)
for i in range(K-1):
    a = (a * (N - K - i) * (K - (i + 1)) // ((i+2) * (i+1))) % mod
    print(a)

Submission status: Runtime Error

Solution code:
# xの逆元は、x*y = 1 mod pとなるようなy
N, K = map(int, input().split())
mod = 10**9 + 7
a = N - K + 1
print(a)
for i in range(K-1):
    a = a * (N - K - i) * (K - (i + 1)) // ((i+2) * (i+1)) % mod
    print(a)

Submission status: Runtime Error

Solution code:
s = input()
ans = False
if s[0] == s[1] :
  if s[0] != s[2] and s[2] ==s[3] :
    ans = True
elif s[0] == s[2] :
  if s[0] != s[1] and s[1] ==s[3] :
    ans = True
else s[0] == s[3] :
  if s[0] != s[1] and s[2] ==s[1] :
    ans = True
if ans :
  print('Yse')
else:
  print('No')

Submission status: Runtime Error

Solution code:
s = input()
ans = False
if s[0] == s[1] :
  if s[0] != s[2] and s[2] ==s[3] :
  ans = True
elif s[0] == s[2] :
  if s[0] != s[1] and s[1] ==s[3] :
  ans = True
else s[0] == s[3] :
  if s[0] != s[1] and s[2] ==s[1] :
  ans = True
if ans :
  print('Yse')
else:
  print('No')