AtCoder Beginner Contest 111 - AtCoder Beginner Contest 111

Kurohashi has never participated in AtCoder Beginner Contest (ABC).
The next ABC to be held is ABC N (the N-th ABC ever held).
Kurohashi wants to make his debut in some ABC x such that all the digits of x in base ten are the same.
What is the earliest ABC where Kurohashi can make his debut?

-----Constraints-----
 - 100 \leq N \leq 999
 - N is an integer.

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
If the earliest ABC where Kurohashi can make his debut is ABC n, print n.

-----Sample Input-----
111

-----Sample Output-----
111

The next ABC to be held is ABC 111, where Kurohashi can make his debut.

Difficulty: EASY

Starter code:

Solutions:
n = input()
a = int(n[0] * 3)
if int(n) <= a:
	print(a)
else:
	print(str(int(n[0]) + 1) * 3)


n = int(input())
a = (n - 1) / 111
b = (a + 1) // 1
print(int(100 * b + 10 * b + b))


a = int(input())
print(111 * ((a - 1) // 111 + 1))


num = int(input())
print(111 * ((num + 110) // 111))


a = int(input())
for i in range(1, 9 + 1):
	if a <= (t := (i * 111)):
		print(t)
		return


n = int(input())
if n <= 111:
	print(111)
elif n <= 222:
	print(222)
elif n <= 333:
	print(333)
elif n <= 444:
	print(444)
elif n <= 555:
	print(555)
elif n <= 666:
	print(666)
elif n <= 777:
	print(777)
elif n <= 888:
	print(888)
elif n <= 999:
	print(999)


n = int(input())
for i in range(n, 1000):
	x = list(str(i))
	if len(set(x)) == 1:
		print(i)
		break


for i in range(int(input()), 1000):
	if i % 111 == 0:
		print(i)
		exit()


print(-int(input()) // 111 * -111)


s = input()
if int(s[0]) < int(s[1]):
	print(111 * (int(s[0]) + 1))
elif int(s[0]) == int(s[1]) < int(s[2]):
	print(111 * (int(s[0]) + 1))
else:
	print(111 * int(s[0]))


N = int(input())
if N % 111 == 0:
	print(N)
else:
	for i in range(110):
		N += 1
		if N % 111 == 0:
			break
	print(N)


n = int(input())
ans = n // 111 * 111
print(ans if ans == n else ans + 111)


n = input()
k = int(n) % 111
if k == 0:
	print(n)
elif n[0] > n[1] or (n[0] == n[1] and n[1] > n[2]):
	print(n[0] * 3)
else:
	print(str(int(n[0]) + 1) * 3)


print((9 - (999 - int(input())) // 111) * 111)


n = int(input())
ans = 0
flag = 0
for i in range(n, 1000):
	s = str(i)
	n_list = list(s)
	if n_list[0] == n_list[1] and n_list[1] == n_list[2] and (flag == 0):
		flag = 1
		ans = i
print(ans)


print((110 + int(input())) // 111 * 111)


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	N = int(readline())
	for x in range(N, 1000):
		if len(set(str(x))) == 1:
			print(x)
			return
	return

def __starting_point():
	main()
__starting_point()


N = int(input())
print(str((N - 1) // 111 + 1) * 3)


n = int(input())
div_n = -(-n // 111)
print(111 * div_n)


n = int(input())
a = 111
for _ in range(9):
	if n <= a:
		print(a)
		return
	a += 111


print(((int(input()) - 1) // 111 + 1) * 111)


n = int(input())
ret = (n - 1) // 111 + 1
print(ret * 111)


n = int(input())
a = 0
if n % 111:
	a = 1
print(111 * (n // 111 + a))


import math
n = int(input())
print(math.ceil(n / 111) * 111)


N = int(input())
print(-N % 111 + N)


n = int(input())
for i in range(n, 1000):
	if i % 111 == 0:
		print(i)
		return


N = int(input())
while len(set(str(N))) != 1:
	N += 1
print(N)


N = int(input())
x = 111 * ((N - 1) // 111 + 1)
print(x)


a = int(input())
b = a % 100
c = a // 100
if b <= c * 11:
	print(c * 111)
else:
	print((c + 1) * 111)


def main():
	n = input()
	if n[0] == '0':
		print('111')
	elif n[0] < n[1] or n[0] < n[2]:
		print((int(n[0]) + 1) * 111)
	else:
		print(int(n[0]) * 111)

def __starting_point():
	main()
__starting_point()


n = int(input())
print((0 - -n // 111) * 111)


n = int(input())
li = [int(str(i) * 3) for i in range(10)]
import bisect
x = bisect.bisect_left(li, n)
print(li[x])


from math import ceil
print(ceil(int(input()) / 111) * 111)


a = int(input())
print(a if a % 111 == 0 else 111 * (1 + a // 111))


x = input()
if int(x[0]) > int(x[1]):
	print(x[0] * 3)
elif int(x[0]) == int(x[1]):
	if int(x[0]) >= int(x[2]):
		print(x[0] * 3)
	else:
		print(str(int(x[0]) + 1) * 3)
else:
	print(str(int(x[0]) + 1) * 3)


x = int(input())
for i in range(x, 1000):
	if i // 100 == i % 10 and i // 100 == i // 10 % 10:
		break
print(i)


N = int(input())
if N % 111:
	print(111 * (N // 111 + 1))
else:
	print(111 * int(N / 111))


n = int(input())
for i in range(1, 10):
	if n <= i * 111:
		print(i * 111)
		return


(q, m) = divmod(int(input()), 111)
print((q + 1 * (m > 0)) * 111)


import math
N = int(input())
print(math.ceil(N / 111.0) * 111)


n = int(input())
a = -(-n // 111)
if a == 10:
	print(1111)
else:
	print(a * 111)


t = 111
n = int(input())
while t < n:
	t += 111
print(t)


n = int(input())
print((n // 111 + 1) * 111 if n % 111 else n)


N = input()
max_digit = N[0]
min_tmp = ''
max_tmp = ''
for i in range(len(N)):
	min_tmp += max_digit
	max_tmp += str(int(max_digit) + 1)
if int(min_tmp) >= int(N):
	print(min_tmp)
else:
	print(max_tmp)


N = int(input())
result = (N + 110) // 111 * 111
print(result)


N = int(input())
S = ((N - 1) // 111 + 1) * 111
print(S)


N = int(input())
now = 111
while now < N:
	now += 111
print(now)


N = int(input())
x = 111
while x < N:
	x += 111
print(x)


N = int(input())
ans = 0
while ans < N:
	ans += 111
print(ans)


n = int(input())
h = n // 100
x = h * 100 + h * 10 + h
print(x) if n <= x else print(x + 111)


N = int(input())
res = 0
while N > res:
	res += 111
print(res)


n = int(input())
while n % 111 != 0:
	n = n + 1
print(n)


n = int(input())
a = n // 100 * 111
print(a if a >= n else a + 111)


n_list = list(input())
n = [int(i) for i in n_list]
ans = str(n[0] + 1) * 3
if n[0] > n[1]:
	ans = str(n[0]) * 3
elif n[0] == n[1]:
	if n[1] >= n[2]:
		ans = str(n[0]) * 3
print(ans)


n = int(input())
print(-n // 111 * -111)


n = int(input())
a = -(-n // 111)
print(a * 111)


A = input()
for i in range(int(A), 1000):
	if len(set(str(i))) == 1:
		print(i)
		return


n = input()
if int(n[1]) < int(n[0]):
	ans = int(n[0] * 3)
elif int(n[0]) == int(n[1]) and int(n[2]) <= int(n[1]):
	ans = int(n[0] * 3)
else:
	ans = int(str(int(n[0]) + 1) * 3)
print(ans)


n = int(input())
for i in range(n, 1000):
	a = i // 100
	b = (i - a * 100) // 10
	c = i - a * 100 - b * 10
	if a == b == c:
		print(i)
		return


n = int(input())
if n % 111 == 0:
	print(n)
else:
	print(n + 111 - n % 111)


def isSame(n):
	if n[0] == n[1] and n[1] == n[2]:
		return True
	else:
		return False
n_s = input()
n_i = int(n_s)
while True:
	if isSame(n_s):
		print(n_s)
		break
	else:
		n_i += 1
		n_s = str(n_i)


def main():
	n = int(input())
	for i in range(n, 1000):
		if len(set(list(str(i)))) == 1:
			print(i)
			return
main()


import math
i = int(input())
print(111 * int(math.ceil(i / 111)))


s = input()
print(str(int(s[0]) + 1) * 3 if s[0] * 3 < s else s[0] * 3)


n = int(input())
i = n // 111
if n % 111:
	i += 1
print(i * 111)


import sys
input = sys.stdin.readline

def main():
	N = int(input())
	for i in range(N, 1111111):
		x = set(list(str(i)))
		if len(x) == 1:
			print(i)
			return

def __starting_point():
	main()
__starting_point()


a = int(input())
print(a + (a % 111 != 0) * 111 - a % 111)


N = input()
if N[0] == N[1] == N[2]:
	print(int(N))
elif int(N[0]) < int(N[1]):
	x = (int(N[0]) + 1) * 100 + (int(N[0]) + 1) * 10 + int(N[0]) + 1
	print(x)
elif N[0] == N[1] and int(N[1]) > int(N[2]):
	x = int(N[0]) * 100 + int(N[0]) * 10 + int(N[0])
	print(x)
elif N[0] == N[1] and int(N[1]) < int(N[2]):
	x = (int(N[0]) + 1) * 100 + (int(N[0]) + 1) * 10 + int(N[0]) + 1
	print(x)
elif int(N[0]) > int(N[1]):
	x = int(N[0]) * 100 + int(N[0]) * 10 + int(N[0])
	print(x)


N = int(input())
lst = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in lst:
	if N <= i:
		print(i)
		break


n = int(input())
ans = 111
while ans < n:
	ans += 111
print(ans)


s = input()
while len(set(s)) > 1:
	s = str(int(s) + 1)
print(s)


a = int(input())
ans = 111
while a > ans:
	ans += 111
print(ans)


n = int(input())
print((n // 100 + (1 if n // 100 * 111 < n else 0)) * 111)


N = int(input())
for i in range(N, 1000):
	moji = str(i)
	if moji[0] == moji[1] and moji[1] == moji[2]:
		break
print(i)


n = int(input())
if n % 111 == 0:
	print(n)
	return
while n % 111 != 0:
	n += 1
	if n % 111 == 0:
		print(n)
		return


n = int(input())
print(int((n + 110) / 111) * 111)


N = int(input())
S = str(N)
x = int(S[0])
y = int(S[1])
z = int(S[2])
if x > y:
	ans = x * 100 + x * 10 + x
elif x < y:
	x += 1
	ans = x * 100 + x * 10 + x
elif x > z:
	ans = x * 100 + x * 10 + x
elif x < z:
	x += 1
	ans = x * 100 + x * 10 + x
else:
	ans = N
print(ans)


a = int(input())
a += 110
a //= 111
a *= 111
print(a)


N = list(input())
n = int(''.join(N))
ck = int(N[0] * 3)
if n - ck <= 0:
	print(int(N[0] * 3))
else:
	print(int(str(int(N[0]) + 1) * 3))
pass


n = int(input())
hyaku = (n - n % 100) / 100
if n % 100 > hyaku * 10 + hyaku:
	hyaku += 1
	print(int(hyaku * 100 + hyaku * 10 + hyaku))
else:
	print(int(hyaku * 100 + hyaku * 10 + hyaku))


n = int(input())
s = (n - 1) // 111
print(111 * (s + 1))


n = int(input())
for i in range(n, n + 111):
	s = str(i)
	if s[0] == s[1] and s[1] == s[2]:
		print(i)
		break


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7

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

def I():
	return int(input())
n = I()
for i in range(n, 1000):
	s = str(i)
	if s[0] == s[1] == s[2]:
		print(i)
		return


n = int(input())
ans = 111
for i in range(9):
	if n <= ans:
		print(ans)
		return
	else:
		ans += 111


N = int(input())
X = ((N - 1) // 111 + 1) * 111
print(X)


N = int(input())
n = int((N - 1) / 111)
print(111 * (n + 1))


N = int(input())
if N < 111:
	print(111)
else:
	for i in range(1, 10):
		if N <= 111 * i:
			ans = 111 * i
			break
	print(ans)


n = int(input())
i = 1
while n > 111 * i:
	i += 1
print(111 * i)


N = int(input())
for i in range(1, 10):
	if 111 * i >= N and N > 111 * (i - 1):
		print(111 * i)
		return


n = int(input())
p = 1 + (n - 1) // 111
print(p * 111)


a = int(input())
u = 111
print((a // u + (a % u > 0) or 0) * u)


n = int(input())
while True:
	if len(set(str(n))) == 1:
		print(n)
		break
	n += 1


N = int(input())
while N % 111 != 0:
	N += 1
print(N)


N = int(input())
ans = -(-N // 111) * 111
print(ans)


N = int(input())
f = N
while True:
	x = str(f)
	if all((x[i] == x[0] for i in range(len(x)))):
		print(x)
		return
	else:
		f += 1


n = int(input())
(q, mod) = divmod(n, 111)
if mod == 0:
	print(q * 111)
else:
	print((q + 1) * 111)


url = 'https://atcoder.jp//contests/abc111/tasks/abc111_b'

def main():
	s = input()
	for n in range(int(s), 1000):
		str_n = str(n)
		if len(str_n) == str_n.count(str_n[0]):
			print(n)
			return

def __starting_point():
	main()
__starting_point()


N = int(input())
ans_N = 111
while True:
	if ans_N >= N:
		break
	ans_N += 111
print(ans_N)


import math
a = int(input())
b = math.ceil(a / 111)
print(b * 111)


m = int(input())
print(((m - 1) // 111 + 1) * 111)


N = int(input())
i = 1
while i * 111 < N:
	i += 1
print(i * 111)


N = int(input())
zorome_contest = [111 * i for i in range(1, 10)]
diff_min = 10 ** 10
ans = 0
for contest in zorome_contest:
	if contest - N >= 0 and contest - N < diff_min:
		diff_min = contest - N
		ans = contest
print(ans)


n = int(input())
i = 0
m = 0
while m < n:
	i = i + 1
	m = 111 * i
print(m)


import sys
import math
sys.setrecursionlimit(500000)
INF = float('inf')

def main():
	n = int(input())
	for i in range(n, 1000):
		flag = True
		for (j, c) in enumerate(str(i)):
			if j == 0:
				continue
			elif c != str(i)[0]:
				flag = False
				break
		if flag:
			return i

def __starting_point():
	print(main())
__starting_point()


n = int(input())
num = (n - 1) // 111
print(111 * (num + 1))


N = int(input())
count = 0
for i in range(1, 10):
	if (N - 1) // int(str(i) * 3) >= 1:
		count = i
print(str(count + 1) * 3)


N = int(input())
res = (N + 111 - 1) // 111
print(res * 111)


n = int(input())
print(str((n - 1) // 111 + 1) * 3)


a = int(input())
while len(set(str(a))) != 1:
	a += 1
print(a)


n = int(input())
ct = 0
while ct < n:
	ct += 111
print(ct)


n = int(input())
while True:
	n = str(n)
	if n[0] == n[1] == n[2]:
		break
	n = int(n) + 1
print(n)


n = int(input())
x = (n - 1) // 111 + 1
print(x * 100 + x * 10 + x)


n = int(input()) - 1
print(int(n - (n % 111 + 1) + 112))


n = input()
while len(set(list(n))) > 1:
	n = str(int(n) + 1)
print(n)


N = int(input())
list_ = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in list_:
	if i >= N:
		print(i)
		return


print(0 - -int(input()) // 111 * 111)


n = int(input())
d = int((n - 1) / 111) + 1
print(*[d, d, d], sep='')


n = int(input())
if n <= 111:
	print(111)
elif 112 <= n <= 222:
	print(222)
elif 223 <= n <= 333:
	print(333)
elif 334 <= n <= 444:
	print(444)
elif 445 <= n <= 555:
	print(555)
elif 556 <= n <= 666:
	print(666)
elif 667 <= n <= 777:
	print(777)
elif 778 <= n <= 888:
	print(888)
elif 889 <= n <= 999:
	print(999)


N = int(input())
(q, mod) = divmod(N, 111)
print((q + int(mod > 0)) * 111)


N = int(input()) - 1
x = N // 111 + 1
print(x * 100 + x * 10 + x)


n = int(input())
t = 111
c = 1
while t < n:
	c += 1
	t = 111 * c
print(t)


import sys
N = int(input())
for i in range(N, 1000):
	s = list(str(i))
	if s[0] == s[1] == s[2]:
		print(i)
		return


n = int(input())
a = 0
while a < n:
	a += 111
print(a)


n = int(input())
i = 0
while i < n:
	i += 111
print(i)


print(111 * (10 - (1110 - int(input())) // 111))


n = list(input())
x = int(n[0] * 3)
y = int(n[0] + n[1] + n[2])
if x >= y:
	print(x)
else:
	print(x + 111)


a = int(input())
for i in range(10):
	if i * 111 >= a:
		print(i * 111)
		break
	else:
		continue


a = input()
zyun = len(a) * 9 + int(a[0])
zoro = 0
z = zyun // 9
af = zyun % 9
if af == 0:
	if int(a) <= int(str(9) * (z - 1)):
		print(int(str(9) * (z - 1)))
	else:
		print(str(1) * z)
elif int(a) <= int(str(af) * z):
	print(int(str(af) * z))
else:
	print(int(str(af + 1) * z))


n = input()
x = n[0] * 3
print(int(x) + 111 if n > x else int(x))


n = int(input())
z = -(-n // 111) * 111
print(z)


N = int(input())
ans = N // 111
if N % 111 > 0:
	ans += 1
print(ans * 111)


N = int(input())

def ans111(N: int):
	while N <= 999:
		if str(N)[0] == str(N)[1] == str(N)[2]:
			break
		else:
			N += 1
	return N
print(ans111(N))


n = int(input())
k = 111
while n > k:
	k += 111
print(k)


N = int(input())
ans = ''
for i in range(1, 10):
	ans = str(i) * 3
	if int(ans) >= N:
		print(int(ans))
		return


n = input()
for i in range(int(n), 1000):
	if str(i).count(str(i)[0]) == 3:
		print(i)
		return


n = int(input())
print(min((i for i in range(111, 1000, 111) if i >= n)))


N = int(input())
for i in range(N, 1000):
	if i % 111 == 0:
		print(i)
		break


print(min(range(999, int(input()) - 1, -111)))


n = str(input())
for i in ['111', '222', '333', '444', '555', '666', '777', '888', '999']:
	if i == n:
		print(n)
		break
	elif n < i:
		print(i)
		break


n = int(input())
for i in range(1, 10):
	l = [i, i, i]
	num = int(''.join(map(str, l)))
	if n <= num:
		print(num)
		break


N = int(input())
n = 111
while n < N:
	n += 111
print(n)


N = int(input())
k = (N - 1) // 111 + 1
print(k * 111)


n = int(input())
x = (n - 1) // 111 + 1
print(x * 111)


N = int(input())
a = 1
while a * 111 < N:
	a += 1
print(a * 111)


def answer(n: int) -> int:
	q = n // 111
	if n % 111 != 0:
		q += 1
	return 111 * q

def main():
	n = int(input())
	print(answer(n))

def __starting_point():
	main()
__starting_point()


import sys
n = input()
n = list(n)
if n[0] > n[1]:
	print(n[0] * 3)
	return
if n[0] < n[1]:
	print(str(int(n[0]) + 1) * 3)
	return
if n[0] == n[1] >= n[2]:
	print(n[0] * 3)
	return
if n[0] == n[1] < n[2]:
	print(str(int(n[0]) + 1) * 3)
	return


n = int(input())
c = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in range(9):
	if c[i] >= n:
		print(c[i])
		break


N = int(input())
n = N // 100
n = n * 100 + n * 10 + n
print(n + 111 if N > n else n)


N = input()
print([str(i) * 3 for i in range(10) if str(i) * 3 >= N][0])


N = int(input())
print(N + 111 - N % 111 if N % 111 != 0 else N)


N = int(input())
print(111 * (0 - -N // 111))


N = int(input())
lst = [i + i * 10 + i * 100 for i in range(1, 10)]
for l in lst:
	if N <= l:
		print(l)
		break


n = int(input())
str_n = str(n)
keta = len(str_n)
suji = [str(i) for i in range(10)]
ans = 0
for i in range(int(str_n[0]), 10):
	tmp = ''
	for j in range(keta):
		tmp += suji[i]
	if int(tmp) >= n:
		ans = int(tmp)
		break
print(ans)


N = int(input())
a = N // 111
b = N % 111
if b > 0:
	a += 1
print(111 * a)


n = input()
if int(n[0] * len(n)) >= int(n):
	print(n[0] * len(n))
else:
	print(str(int(n[0]) + 1) * len(n))


X = int(input())
print((X + 110) // 111 * 111)