Problem:


Score : 200 points

Problem Statement

The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9.

You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.

Constraints

1≤A,B≤5

|S|=A+B+1

S consists of - and digits from 0 through 9.

Input

Input is given from Standard Input in the following format:

A B
S

Output

Print Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise.

Sample Input 1

3 4
269-6650

Sample Output 1

Yes

The (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.

Sample Input 2

1 1
---

Sample Output 2

No

S contains unnecessary -s other than the (A+1)-th character, so it does not follow the format.

Sample Input 3

1 2
7444

Sample Output 3

No



Sample input:
3 4
269-6650


Sample output:
Yes

Submission status: Accepted

Solution code:
import re
a, b = map(int, input().split())
s = input()
if s[a] == '-' and len(s) == a + b + 1:
  s = re.sub(r'-', '', s)
  if re.fullmatch(r'[0-9]+', s) and len(s) == a + b:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
def solve():
    A,B = map(int,input().split())
    S = input()
    seq = [str(x) for x in range(10)]

    for i in range(A+B+1):
        if i== A:
            if S[i] != "-":
                return False
        else:
            if not(S[i] in seq):
                return False
    return True

if __name__ == '__main__':
    cond = solve()
    if cond:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
# 2020/06/03
# AtCoder Beginner Contest 084 - B

# Input
a, b = map(int,input().split())
s = input()

# Calc
is_a_dec = str.isdecimal(s[0:a])
is_b_dec = str.isdecimal(s[a+1:len(s)])
is_hy = (s[a] == '-')

if is_a_dec and is_b_dec and is_hy:
    ans = 'Yes'
else:
    ans = 'No'

# Output
print(ans)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()

print('Yes') if s[a:a+1] == '-' and '-' not in s[:a] and '-' not in s[a+1:] else print('No')

Submission status: Accepted

Solution code:

def resolve():
    a, b = map(int, input().split())
    s = input()
    if s.count("-") != 1:
        print("No")
        return

    c = s.split("-")
    if len(c) != 2:
        print("No")
        return
    if len(c[0]) == a and len(c[1]) == b:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = list(input())

flag1 = False
if s[a] == '-':
    flag1 = True

flag2 = False
if not '-' in s[:a - 1] and not '-' in s[a + 1:]:
    flag2 = True

if flag1 and flag2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()
count = s.count("-")
idx = s.find("-")

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

Submission status: Accepted

Solution code:
a, b = (int(i) for i in input().split())
s = input()
for i in range(a+b+1):
    if i == a:
        if not s[i] == '-':
            print('No')
            exit()
    else:
        if not s[i] >= '0' or not s[i] <= '9':
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
#ABC084-B
a,b = map(int,input().split())
s = input()

mae = s[:a]
usiro = s[a+1:a+b+1]
#print(mae)
#print(usiro)
if mae.isdecimal() and usiro.isdecimal() and s[a] == '-':
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A,B=map(int,input().split())
S=list(str(input()))
if S.count('-')==1 and S[A]=='-':
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import re

A, B = input().split()
S = input()

p = r"^[0-9]{" + A + r"}-[0-9]{" + B + "}$"

if re.fullmatch(p, S):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
S = list(input())
if S[A] != '-':
    print('No')
    exit()
S.pop(A)
for s in S:
    if s == '-':
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    A, B = map(int, input().split())
    S = input().rstrip()

    is_valid = True
    for s in S[:A]:
        if s not in "0123456789":
            is_valid = False
    if S[A] != "-":
        is_valid = False
    for s in S[A + 1:]:
        if s not in "0123456789":
            is_valid = False

    ans = "Yes" if is_valid else "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()
ans = 'Yes'
for i in range(a+b+1):
    if(i == a and s[i] != '-'):
        ans = 'No'
    elif(i != a and s[i] == '-'):
        ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
import re

def li():
    return list(map(int, input().split()))
def mi():
    return map(int, input().split())
def ii():
    return int(input())
def lim(N):
    return [int(input()) for i in range(N)]

A, B = mi()
S = input()

pattern = "[0-9]+"
c = re.compile(pattern)

if c.match(S[:A]) and S[A:A+1] == "-" and c.match(S[A+1:A+1+B]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, S: str):
    is_mid = True if S[A] == "-" else False
    is_num = (S[:A] + S[A + 1 :]).find("-") == -1
    print(YES if is_mid and is_num else NO)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(A, B, S)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, S: str):
    is_hyphen = True if S[A : A + 1] == "-" else False
    before = S[:A]
    after = S[A + 1 :]
    try:
        int(before)
        int(after)
        if is_hyphen:
            print(YES)
        else:
            print(NO)
    except:
        print(NO)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(A, B, S)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=input()

if s[a]=='-' and s.count('-')==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
S = input()

for i in range(A):
  if(S[i] == '-'):
    print('No')
    exit()
if(S[A] != '-'):
  print('No')
  exit()
for i in range(A+1, A+B+1):
  if(S[i] == '-'):
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
s = input()
f = 0
for i in range(a):
    if s[i]=="-":
        f = 1
if s[a]!="-":
    f = 1
for i in range(a+1,a+b+1):
    if s[i]=="-":
        f = 1
if f==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=input()
s1=s[:a]
s2=s[(a+1):]
if s1.isdecimal()==True and s2.isdecimal()==True and s[a]=="-":
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A,B=map(int,input().split())
S=input()
for s in S[:A]:
    if s not in "0123456789":
        print("No")
        exit()
if S[A]!="-":
    print("No")
    exit()
for s in S[A+1:]:
    if s not in "0123456789":
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import re
A, B = map(int, input().split())
S = input()
c1 = re.search(r"\D", S[:A] + S[-B:]) is None
c2 = S[A] == "-"
print("Yes" if c1 and c2 else "No")

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()
print("Yes" if s[a] == "-" and s.count("-") == 1 else "No")

Submission status: Accepted

Solution code:
A,B = map(int, input().split())
S = list(map(str, input().split("-")))
if len(S) != 2:
    print('No')
elif len(S[0]) == A and len(S[1]) == B:
    print("Yes")
else:
    print('No')

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
S = input()

print('Yes' if S.count('-')==1 and S[A] == '-' else 'No')

Submission status: Accepted

Solution code:
def ABC_84_B():
    A,B=map(int, input().split())
    S=input()
    f=1

    for i in range(len(S)):
        if  S[i]!='-' and i<A and int(S[i])>=0 and int(S[i])<=9:
            f+=0
        elif i == A and S[i] =='-':
            f-=1
        elif S[i]!='-' and int(S[i])>=0 and int(S[i])<=9:
            f+=0
        else:
            f+=1

    if f==0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':

    ABC_84_B()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())

    def made_of_digits(s):
        """
        Args:
            s (str)
        """
        # print(s)
        digits = set(map(lambda x: str(x), range(10)))
        for char in s:
            if char not in digits:
                return False
        return True


    n, m = mi()
    s = input()
    print('Yes') if len(s) == n + m + 1 and made_of_digits(s[:n]) and s[n] == '-' and made_of_digits(s[n+1:]) else print('No')


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
S = input()

def judge(S):
	if S[A] != "-":
		return False
	if len(S) != A+B+1:
		return False

	S = S[:A] + S[A+1:]

	if not S.isdigit():
		return False
	return True

print("Yes") if judge(S) else print("No")

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()

if s[:a].isdigit() and s[a] == "-" and s[a + 1:].isdigit() and len(s) == a + b + 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A, B = list(map(int, input().split()))
S = input()
a = S[:A]
b = S[A+1:]
if S[A] == '-' and a.isalnum() and b.isalnum():
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
s = input()
if s.count("-") == 1 and s[a] == "-":
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()

flag = True
for i in range(a + b + 1):
    if i == a:
        if s[i] != "-":
            flag = False
    else:
        if not s[i].isdecimal():
            flag = False

print("Yes" if flag else "No")

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=input()
flag=0
if len(s)==(a+b+1):
    flag+=1
if s.count('-')==1:
    flag+=1
    if a==len(s[0:(s.index('-'))]):
        flag+=1
if flag==3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
s = input()
print('Yes' if s.count('-')==1 and s[a]=='-' else 'No' )

Submission status: Accepted

Solution code:
A, B=map(int, input().split())
s=input()
c1=s[A]=="-"
c2="-" not in s[:A]
c3="-" not in s[A+2:]
if c1 and c2 and c3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()
if s[a] != '-':
	print("No")
	exit()
for i in range(a):
	if s[i] < '0' or s[i] > '9':
		print("No")
		exit()
for i in range(a + 1, a + b + 1):
	if s[i] < '0' or s[i] > '9':
		print("No")
		exit()
print("Yes")

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
s = list(input())

if s[a] == '-' and '-' not in s[:a] and '-' not in s[a+1:]:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=input()
print("Yes" if s[a]=="-" and s.count("-")==1 else "No")

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
S = input()
flag = 0
if S[a] != "-":
    flag += 1
for i in range(0,a):
    if S[i]== "-":
        flag += 1
for i in range(a+1,a+b+1):
    if S[i] == "-":
        flag += 1
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
S = input().split('-')
if len(S) == 2 and len(S[0]) == A and len(S[1]) == B:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()

ans = 'Yes'

length = len(s)

for x in range(length):
    if x == a:
        if s[x] != '-':
            ans = 'No'
            break
        else:
            continue

    if ('0' > s[x] and s[x] > '9') or s[x] == '-':
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
import re


A, B = input().split()
print('Yes') if re.fullmatch(r'[0-9]{' + A + r'}-[0-9]{' + B + r'}', input()) else print('No')

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b = map(int, readline().split())
s = readline().decode()
bl = '-' == s[a] and '-' not in s[:a:]+s[-b::]
print('Yes' if bl else 'No')

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()

ans = 'No'
if s[a] == '-':
    if s[: a].isdecimal() and s[a + 1 :].isdecimal():
        ans = 'Yes'
        
print(ans)

Submission status: Accepted

Solution code:

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

checkset = [str(x) for x in range(10)]

def main():
    SA = S[:A]; SB = S[A+1:]
    for i in SA:
        if i not in checkset:
            print('No')
            return

    if S[A] != '-':
        print('No')
        return

    for i in SB:
        if i not in checkset:
            print('No')
            return

    print('Yes')

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
n = list(input())
 
if n[a] == '-' and '-' not in n[:a] and '-' not in n[a+1:]:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
A,B= map(int,input().split())
S = input()
flag = 0
#フラグ関数。　条件を満たしているかどうかを判定する。 0以外なら条件を満たしていない。
if S[A] == "-":
  for i in range(0,A):
    if 48<=ord(S[i])<=57:
      #ここではasciiコード (0 = 48, 9 = 57)を用いていますが、整数をリストにした解法でも大丈夫です。
      continue
    else:
      flag += 1
      break
  for i in range(A+1,A+B+1):
    if 48<=ord(S[i])<=57:
      continue
    else:
      flag += 1
      break
else:
  flag += 1
if flag == 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
S = list(input())
flag = True
num = ['0','1','2','3','4','5','6','7','8','9']

for i in range(A+B+1):
    if i != A:
        if S[i] not in num:
            flag = False
            break
    else:
        if S[i] != '-':
            flag = False
            break

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()
ok = True
for i in range(a):
    if s[i] not in [str(j) for j in range(10)]:
        ok = False
if s[a] != '-':
    ok = False
for i in range(a+1, a+b+1):
    if s[i] not in [str(j) for j in range(10)]:
        ok = False
if ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import re

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

pattern = r'^\d{}-\d{}$'.format('{' + str(A) + '}', '{' + str(B) + '}')

if re.match(pattern, S):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A, B = map(int, input().split(' '))
S = input()

numbers = {str(n) for n in range(10)}


def resolve(s):
    for i in range(A):
        if s[i] not in numbers:
            print('No')
            return

    if s[A] != '-':
        print('No')
        return

    s = s[A + 1:]
    for i in range(B):
        if s[i] not in numbers:
            print('No')
            return

    print('Yes')


resolve(S)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()

num = list(map(str, range(0, 10)))

ans = 'No'

if s[a] == '-':
    w = s[:a]+s[a+1:]
    if str.isdecimal(w):
        ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
import sys
a,b = map(int,input().split())
s = list(input())
if len(s) != a + b + 1:
    print("No")
else:
    if s[a] != "-":
        print("No")
    else:
        for i in range(a):
            if s[i] == "-":
                print("No")
                sys.exit()
        for j in range(a+1,len(s)):
            if s[j] == "-":
                print("No")
                sys.exit()
        print("Yes")

Submission status: Accepted

Solution code:
a,b = list(map(int,input().split(" ")))
s = input()
postal_code_len = a+b+1

num_list = list(map(str, range(0,10)))

flag = True
#print([c in num_list for c in list(s[:a]+s[a+1:]) ])
if s[a] == "-" and all([ c in num_list for c in list(s[:a]+s[a+1:]) ]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=input()
print("Yes"if s.count("-")==1 and s[a]=="-" else "No")

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=input()
f=True

if s[a] != '-':
	f=False
	print('No')

if f:
	s=s[:a]+s[a+1:]
	if s.isdigit():
		print('Yes')
	else:
		print('No')

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()
try:
  ac, bc = int(s[:a]), int(s[a + 1:])
  flag = True
except ValueError:
  flag = False
print('Yes' if flag and s[a] == '-' else 'No')

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=input()
if len(s)==a+b+1 and "-" in s and s.index("-")==a and s.count("-")==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
S = input()
print('Yes' if S[:A].isdecimal() and S[A + 1:].isdecimal() and S[A] == '-' else 'No')

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
s = input()

for i in range(a):
    if not '0' <= s[i] and s[i] <= '9':
        print('No')
        exit()

if s[a] != '-':
    print('No')
    exit()

for i in range(a+1, a+b+1):
    if not '0' <= s[i] and s[i] <= '9':
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
s = input()
s_list = s
s_list = list(s_list)
num = ['0','1','2','3','4','5','6','7','8','9']
flg = False
cnt = 0

for i in range(len(s_list)):
    if i == a:
        if s_list[i] != '-':
            print('No')
            exit()
    elif s_list[i] not in num:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
#import numpy as np
#N = int(input())
A,B= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
S= str(input())

for i in range(len(S)):
    if i==A:
        if S[i]!='-':
            print("No")
            exit()


    elif S[i].isdigit() == False:
        print('No')
        exit()


print('Yes')

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
s = input()

def ifnum(v):
  for i in range(0,len(v)):
    if(v[i] == "0" or v[i] == "1" or v[i] == "2" or v[i] == "3" or v[i] == "4" or v[i] == "5" or v[i] == "6" or v[i] == "7" or v[i] == "8" or v[i] == "9"):
      continue
    else:
      return 0
  return 1
#print(s[a+1:])

if(ifnum(s[0:a]) == 1 and s[a] == "-" and ifnum(s[a+1:]) == 1):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=input()
if 1<=a<=5 and 1<=b<=5:
    if s[a]=="-":
        if s[0:a].isdecimal() and s[a+1:a+b+1].isdecimal():
            print("Yes")
            exit()
print("No")

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
S = input()
N = set(map(str, range(10)))

L = set(S[:A])
M = S[A]
R = set(S[-B:])

if (L | R) <= N and M == '-':
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

erro = 0

for i in range(A):
  if S[i] == '-':
    erro += 1
    
if S[A] != '-':
  erro += 1
  
for _ in range(A+1,A+B+1):
  if S[_] == '-':
    erro += 1

if erro > 0:
  print('No')
  
else:
  print('Yes')

Submission status: Accepted

Solution code:
def instr():
    s = input()
    return(list(s[:len(s)]))
# For taking space seperated integer variable inputs.


def invr():
    return(map(int, input().split()))


a, b = invr()
s = instr()

check = "1234567890-"
res = "Yes"

n = len(s)
if n != a+b+1:
    res = "No"
if s[a] != "-":
    res = "No"
for i in range(n):
    if s[i] not in check:
        res = "No"
        break
    if i != a and s[i] == "-":
        res = "No"
        break
print(res)

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()

def is_int(s):
    try:
        int(s)
        return True
    except ValueError:
        return False

ans = 0
if is_int(s[0:a]) == True:
    if s[a] == "-":
        if is_int(s[a+1:]) == True:
            print("Yes")
            ans = 1
if ans == 0:
    print("No")

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
S = input()
isOK = True
for i in range(len(S)):
  if i == A:
    if S[i] != "-":
      isOK = False
      break
  else:
    if S[i] == "-":
      isOK = False
      break
print("Yes" if isOK else "No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

A,B = inputIL()
S = inputS()

num = ["0","1","2","3","4","5","6","7","8","9",]

if len(S) != A+B+1:
  No()
  exit()
for i in range(A):
  if S[i] not in num:
    No()
    exit()
if S[A] != "-":
    No()
    exit()
for i in range(A+1,A+B+1):
  if S[i] not in num:
    No()
    exit()  
Yes()

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
s = input()
print('Yes' if s.count('-')==1 and s.index('-')==a else 'No')

Submission status: Accepted

Solution code:
A, B = map(int, input().split())
S = list(map(str, input().split('-')))

if len(S[0]) == A and len(S[1]) == B:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
s=input()
num=["0","1","2","3","4","5","6","7","8","9"]
left=s[:a]
right=s[a+1:]
if s[a] != '-':
    print('No')
    exit()
for i in left:
    if i in num:
        continue
    else:
        print('No')
        exit()
for j in right:
    if j in num:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())

A, B = mi()
S = input()
number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

if S[A] != '-':
    print('No')
    exit()

for i in range(A+B+1):
    if i != A and S[i] not in number:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()
if (s.count('-') == 1 
    and len(s.split('-')[0]) == a and  len(s.split('-')[1]) == b) :
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a, b = list(map(int, input().split()))
s = list(input())
if s[a] == '-' and '-' not in s[:a] + s[a + 1:]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

a,b=map(int,input().split())
s=input()
#print(s)
if s[a]!="-":
    print("No")
    #print(1)
elif s.count("-")>1:
    print("No")
    #print(2)
else:
    s=s.replace("-","")
    #print(3)
    #print(s)
    if s.isdigit()==True:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
s = input()
s_a = s[0:a]
s_b = s[(a+1):(a+2)+b]
minus = s[a]
if minus == "-" and s_a.isdecimal() and s_b.isdecimal():
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import re,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
A,B = LI()
S = S()
p = '[0-9]{{{0}}}-[0-9]{{{1}}}'.format(A,B)
print('Yes' if re.fullmatch(p,S) else 'No')

Submission status: Accepted

Solution code:
import re,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
A,B = LI()
S = S()
pattern_str = r'\d{{{}}}-\d{{{}}}'.format(A,B)
print('Yes' if re.fullmatch(pattern_str,S) else 'No')

Submission status: Accepted

Solution code:
import re,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
A,B = LI()
S = S()
print('Yes' if re.fullmatch(pattern=r'\d{'+str(A)+'}-\d{'+str(B)+'}',string=S) else 'No')