AtCoder Beginner Contest 096 - Day of Takahashi

In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.

For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  
In this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.

How many days from 2018-1-1 through 2018-a-b are Takahashi?

-----Constraints-----
 - a is an integer between 1 and 12 (inclusive).
 - b is an integer between 1 and 31 (inclusive).
 - 2018-a-b is a valid date in Gregorian calendar.

-----Input-----
Input is given from Standard Input in the following format:
a b

-----Output-----
Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.

-----Sample Input-----
5 5

-----Sample Output-----
5

There are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.

Source: atcoder | Difficulty: EASY


Solutions:
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):

	def assertIO(self, input, output):
		(stdout, stdin) = (sys.stdout, sys.stdin)
		(sys.stdout, sys.stdin) = (StringIO(), StringIO(input))
		resolve()
		sys.stdout.seek(0)
		out = sys.stdout.read()[:-1]
		(sys.stdout, sys.stdin) = (stdout, stdin)
		self.assertEqual(out, output)

	def test_入力例_1(self):
		input = '5 5'
		output = '5'
		self.assertIO(input, output)

	def test_入力例_2(self):
		input = '2 1'
		output = '1'
		self.assertIO(input, output)

	def test_入力例_3(self):
		input = '11 30'
		output = '11'
		self.assertIO(input, output)

def resolve():
	(a, b) = list(map(int, input().split()))
	if a > b:
		print(a - 1)
	else:
		print(a)

def __starting_point():
	resolve()
__starting_point()


(M, D) = map(int, input().split())
if D >= M:
	print(M)
else:
	print(M - 1)


(a, b) = [int(_) for _ in input().split()]
print(a - 1 if a > b else a)


(a, b) = map(int, input().split())
if a <= b:
	print(a)
else:
	print(a - 1)


(A, B) = [int(i) for i in input().split()]
print(A if B >= A else A - 1)


(a, b) = map(int, input().split())
ans = a
if b < a:
	ans -= 1
print(ans)


(a, b) = map(int, input().split())
a -= a > b
print(a)


(a, b) = map(int, input().split())
c = a - 1
if b >= a:
	c += 1
print(c)


(A, B) = input().split()
if B >= A:
	print(int(A))
else:
	print(int(A) - 1)


(a, b) = map(int, input().split())
day = a - 1
if a <= b:
	day += 1
print(day)


(a, b) = map(int, input().split())
if 1 <= b < a:
	print(a - 1)
elif a <= b:
	print(a)


(m, d) = map(int, input().split())
print([m - 1, m][d >= m])


(a, b) = map(int, input().split())
n = a
if b < a:
	n -= 1
print(n)


def resolve():
	(a, b) = map(int, input().split())
	if a <= b:
		c = a
	else:
		c = a - 1
	print(c)
resolve()


(a, b) = (int(i) for i in input().split(' '))
print(a if a <= b else a - 1)


import math
(a, b) = map(int, input().split())
print(a if b >= a else a - 1)


(b, c) = map(int, input().split())
if c >= b:
	print(b)
else:
	print(b - 1)


(t, h) = map(int, input().split())
a = t
if t > h:
	a = a - 1
print(a)


(a, b) = map(int, str(input()).split(' '))
print(a - 1 + (1 if a <= b else 0))


(a, b) = map(int, input().split())
ans = 0
for i in range(1, a):
	for j in range(1, 13):
		if i == j:
			ans += 1
for i in range(a, a + 1):
	for j in range(1, b + 1):
		if i == j:
			ans += 1
print(ans)


(a, b) = map(int, input().split())
th = a - 1
if b >= a:
	th += 1
print(th)


(A, B) = map(int, input().split())
print(A - int(B < A))


(a, b) = map(int, input().split())
t = 0
if a <= b:
	t = a
else:
	t = a - 1
print(t)


(a, b) = map(int, input().split())
s = a - 1
if b >= a:
	s += 1
print(s)


(m, d) = map(int, input().split())
print(m if m <= d else m - 1)


(a, b) = [int(m) for m in input().split(' ')]
print(a - 1 + bool(b // a))


(a, b) = map(int, input().split())
cnt = a - 1
if a <= b:
	cnt += 1
print(cnt)


(x, y) = map(int, input().split())
if x > y:
	print(x - 1)
else:
	print(x)


(A, B) = input().split()
a = int(A)
b = int(B)
if b - a >= 0:
	print(a)
else:
	print(a - 1)


(a, b) = map(int, input().split(' '))
num = a
if a > b:
	num -= 1
print(num)


(a, b) = list(map(int, input().split()))
ans = 0
for i in range(1, 13):
	if i < a:
		ans += 1
	elif i == a:
		if i <= b:
			ans += 1
print(ans)


(month, day) = map(int, input().split())
takahashi_days = month
if day >= month:
	print(takahashi_days)
elif month > day:
	print(takahashi_days - 1)


def main():
	(a, b) = list(map(int, input().split()))
	if a <= b:
		print(a)
	else:
		print(a - 1)

def __starting_point():
	main()
__starting_point()


(A, B) = map(int, input().split())
if B < A:
	A -= 1
print(A)


(a, b) = map(int, input().split())
print(a + min(1, b // a) - 1)


(n, m) = [int(x) for x in input().split()]
if n <= m:
	print(n)
else:
	print(n - 1)


(x, y) = map(int, input().split())
a = [x - 1, x]
print(a[int(y >= x)])


(a, b) = [int(x) for x in input().split()]
print(a - 1 + (b >= a))


(a, b) = list(map(int, input().split()))
res = a - 1
if a <= b:
	res += 1
print(res)


(M, D) = map(int, input().split())
print(M - 1 + (0, 1)[D >= M])


(a, b) = list(map(int, input().split()))
print(a - 1 + (b // a >= 1))


l = input().split()
(a, b) = (int(l[0]), int(l[1]))
print(a if a <= b else a - 1)


(n, m) = map(int, input().split())
if n <= m:
	print(n)
else:
	print(n - 1)


(a, b) = list(map(int, input().split()))
if a <= b:
	ans = a
else:
	ans = a - 1
print(ans)


(a, b) = map(int, input().split())
r = a - 1
if b - a >= 0:
	r += 1
print(r)


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

def I():
	return int(input())

def F():
	return float(input())

def SS():
	return input()

def LI():
	return [int(x) for x in input().split()]

def LI_():
	return [int(x) - 1 for x in input().split()]

def LF():
	return [float(x) for x in input().split()]

def LSS():
	return input().split()

def resolve():
	(a, b) = LI()
	if a <= b:
		print(a)
	else:
		print(a - 1)

def __starting_point():
	resolve()
__starting_point()


(a, b) = map(int, input().split())
k = a - 1
if b >= a:
	k += 1
print(k)


(a, b) = map(int, input().split())
takahashi = a - 1
if b >= a:
	takahashi += 1
print(takahashi)


(m, d) = [int(i) for i in input().split()]
if d < m:
	m = m - 1
print(m)


(a, b) = map(int, input().split())
print([max(1, a - 1), a][b >= 5])


(a, b) = [int(_) for _ in input().split()]
print('{}'.format(a - (b < a)))


(a, b) = list(map(int, input().split(' ')))
r = a - 1
if a <= b:
	r += 1
print(r)


(a, b) = [int(x) for x in input().split()]
print(a - 1) if a > b else print(a)


(a, b) = map(int, input().split())
print(a - 1 + max(min(b // a, 1), 0))


(a, b) = map(int, input().split())
c = 1 if int(a - b) > 0 else 0
print(a - c)


(y, m) = map(int, input().split())
print(y - 1 + (1 if y <= m else 0))


(a, b) = map(int, input().split())
if a <= b:
	print(a)
	exit()
print(a - 1)


(a, b) = [int(s) for s in input().split()]
if a <= b:
	print(a)
else:
	print(a - 1)


(a, b) = (int(X) for X in input().split())
if b >= a:
	print(a)
else:
	print(a - 1)


lst = input().split()
a = int(lst[0])
b = int(lst[1])
if a <= b:
	print(a)
else:
	print(a - 1)


(a, b) = map(int, input().split())
cnt = a - (1 if a > b else 0)
print(cnt)


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(a, b) = Input()
	if a - b <= 0:
		print(a)
	else:
		print(a - 1)
main()


(A, B) = map(int, input().split())
n = 0
if A <= B:
	n = 1
print(A - 1 + n)


(a, b) = map(int, input().split())
if a > b:
	flag = 1
else:
	flag = 0
print(a - flag)


(a, b) = list(map(int, input().split()))
ans = a - (a > b)
print(ans)


(a, b) = map(int, input().split())
print(min(a, 12) if a <= b else a - 1)