Problem:


Score : 200 points

Problem Statement

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 1

111

Sample Output 1

111

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

Sample Input 2

112

Sample Output 2

222

The next ABC to be held is ABC 112, which means Kurohashi can no longer participate in ABC 111.
Among the ABCs where Kurohashi can make his debut, the earliest one is ABC 222.

Sample Input 3

750

Sample Output 3

777



Sample input:
111


Sample output:
111

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import sys
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)
        sys.exit()

Submission status: Accepted

Solution code:
n = int(input())

if n % 111 ==0:
    print(n)
    exit()

while n % 111 != 0:
    n += 1
    if n % 111 == 0:
        print(n)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1, 10):
    if (100*i + 10*i + i ) >= n:
        print(100*i + 10*i + i)
        exit()

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

if N[0] == N[1] == N[2]:
    print(int(N))

else:
    if 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)

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [input() for _ in range(n)]

n = int(input())

q, mod = divmod(n,111)

if mod == 0:
    print(q*111)
else:
    print((q+1)*111)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
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)
        exit()

Submission status: Accepted

Solution code:
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
else:
    if x > z:
        ans = x*100+x*10+x
    elif x < z:
        x += 1
        ans = x*100+x*10+x
    else:
        ans = N
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
for i in range(n,1000):
    if len(set(str(i))) == 1:
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for n in range(N,N+111):
    if n%111==0:
        print(n)
        exit()

Submission status: Accepted

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

Submission status: Accepted

Solution code:
val = [111*i for i in range(1, 10)]
N = int(input())
while not N in val:
  N += 1
print(N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
for i in range(1,10):
  x = 111*i
  if x >= n:
    print(x)
    break

Submission status: Accepted

Solution code:
n = int(input())
for i in range(111, 1000, 111):
    if i >= n:
        print(i)
        break

Submission status: Accepted

Solution code:
n = int(input())
for i in range(100, 1000):
    tmp = str(i) 
    if len(set(tmp)) == 1 and i >= n:
        print(i)
        break

Submission status: Accepted

Solution code:
N = int(input())

if N % 111 == 0:
    print(N)
    exit()
else:
    print((N // 111 + 1) * 111)

Submission status: Accepted

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    dif = 999
    ans = ''
    for i in range(1, 10):
        tmp = str(i) * 3
        if dif > int(tmp) - n >= 0:
            dif = abs(n - int(tmp))
            ans = tmp
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = input()
if n[0] >= n[1] and (n[0] >= n[2] or n[1] >= n[2]):
    print(n[0]+n[0]+n[0])
else:
    print(str(int(n[0])+1) + str(int(n[0])+1) + str(int(n[0])+1))

Submission status: Accepted

Solution code:
print(((int(input())-1) // 111 + 1) * 111 )

Submission status: Accepted

Solution code:
n = int(input())
a = n // 111
b = n % 111
if b > 0:
    ans = (a + 1) * 111
else:
    ans = a * 111   
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

print(-(-N//111)*111)

Submission status: Accepted

Solution code:
n=int(input())
k=n//100
nex=111*k
if nex>=n:
    print(nex)
else:
    print(nex+111)

Submission status: Accepted

Solution code:
N=int(input())
for i in range(1,10):
  if N<=100*i+10*i+i :
    print(100*i+10*i+i)
    exit()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
for i in range(10):
    num = 100*i+10*i+i
    if num>=N:
        print(num)
        break

Submission status: Accepted

Solution code:
x = [i * 111 for i in range(1, 10)]
N = int(input())
for j in range(len(x)):
  if 0 <= x[j] - N <= 110:
    print(x[j])
    break

Submission status: Accepted

Solution code:
N = input()
if int(N) > int(N[0]*3):
    print(str((int(N[0])+1))*3)
else:
    print(N[0]*3)

Submission status: Accepted

Solution code:
N = input()
if int(N) > int(N[0]*3):
    print(str((int(N[0])+1))*3)
else:
    print(N[0]*3)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    while True:
        if len(set(str(N))) == 1:
            print(N)
            break
        else:
            N += 1


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X = int(input())

while True:
  if len(set(str(X))) == 1:
    break
  X += 1
  
print(X)

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N,1000):
    if len(set(list(str(i)))) == 1:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=[111,222,333,444,555,666,777,888,999]
for i in range(1000):
    if n in l:
        print(n)
        exit()
    n+=1

Submission status: Accepted

Solution code:
s = input()
n = int(s)

m = []

y = n
while y > 0:
    z = y % 10
    m.append(z)
    y = int(y / 10)
    
p = m[len(m) - 1]


max_num = 0
for i in range(len(m)):
    max_num = max(max_num, m[i])

if p < max_num:
    p += 1


for i in range(len(m)):
    m[i] = p
    print(m[i], end='')

print('')

Submission status: Accepted

Solution code:
print(0--int(input())//111*111)

Submission status: Accepted

Solution code:
print(-(-int(input())//111*111))

Submission status: Accepted

Solution code:
n=input();print([int(str(int(n[0])+1)*3),int(n[0]*3)][int(n[0]*3)>=int(n)])

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	
	n = int(input())


	for i in range(n,1000):
		tmp = set(str(i))

		if len(tmp) == 1:
			print(i)
			break

Submission status: Accepted

Solution code:
print(-(-int(input())//111)*111)

Submission status: Accepted

Solution code:
a=[111,222,333,444,555,666,777,888,999]

n=int(input())

for i in a:
  if n>i:
    continue
    
  else:
    print(i)
    exit()

Submission status: Accepted

Solution code:
N=int(input())
a=[111,222,333,444,555,666,777,888,999,1111]
for x in a:
  if N<=x:
    print(x)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    divide = N // 111
    rest = N % 111
    if rest > 0:
        print((divide+1)*111)
    else:
        print(divide*111)
main()

Submission status: Accepted

Solution code:
N = int(input())
for i in range(10):
    if N <= i * 111:
        print(i * 111)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r = input()
n = list(r)
x = int(n[0])*100 + int(n[0])*10 + int(n[0])

if x < int(r):
  print( ((int(n[0])+1)*100 + (int(n[0])+1)*10 + int(n[0])+1))
else:
  print(x)

Submission status: Accepted

Solution code:
N = int(input())
a = 0
for i in range(N,1000):
  if i == 111 or i == 222 or i == 333 or i ==444 or i ==555 or i == 666 or i ==777 or i ==888 or i == 999:
    a = i
    break
print(a)

Submission status: Accepted

Solution code:
import math
N = int(input())
print(111*math.ceil(N/111))

Submission status: Accepted

Solution code:
n = int(input())
for i in range(111, 1000, 111):
    if n<=i:
        print(i)
        exit()

Submission status: Accepted

Solution code:
# abc111_b.py
# https://atcoder.jp/contests/abc111/tasks/abc111_b

# B - AtCoder Beginner Contest 111 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 黒橋君は，AtCoder Beginner Contest (ABC) にまだ参加したことがありません．
# 次に行われる ABC は第 N回です． 
# 黒橋君は，初めて参加する ABC を第 x 回としたときに，xの十進法表記でのすべての桁の数字が同じであるようにしたいです．
# 黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回でしょうか？

# 制約
#     100≤N≤999
#     Nは整数

# 入力
# 入力は以下の形式で標準入力から与えられる．
# N

# 出力
# 黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第何回かを出力せよ．

# 入力例 1
# 111

# 出力例 1
# 111

# 次に行われる ABC は第 111回です． これは黒橋君が初めて参加する ABC としてふさわしいです．

# 入力例 2
# 112

# 出力例 2
# 222

# 次に行われる ABC は第 112回です．そのため，第 111 回の ABC にはもう参加することはできません． 
# 黒橋君が初めて参加する ABC としてふさわしいもののうち，最も早いものは第 222回です．

# 入力例 3
# 750

# 出力例 3
# 777


def calculation(lines):
    N = int(lines[0])
    # X, Y = list(map(int, lines[0].split()))
    # n = lines[0]

    if N % 111 == 0:
        result = N
    else:
        result = -(-N//111) * 111 

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['111']
        lines_export = [111]
    if pattern == 2:
        lines_input = ['112']
        lines_export = [222]
    if pattern == 3:
        lines_input = ['750']
        lines_export = [777]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

n = int(readline())

for i in range(111, 1000, 111):
    if i >= n:
        print(i)
        exit()

Submission status: Accepted

Solution code:
n = input()
r = int(n[0]*3)
if r < int(n):
  print(str(int(n[0])+1)*3)
else:
  print(r)

Submission status: Accepted

Solution code:
n = int(input())

l =[111,222,333,444,555,666,777,888,999]


while n not in l:
    n += 1
print(n)

Submission status: Accepted

Solution code:
n = int(input())

num = [111,222,333,444,555,666,777,888,999]

for i in num:
    if i >= n:
        print(i)
        exit()

Submission status: Accepted

Solution code:
N = int(input())

def checkDigit(n):
  a = n % 10
  n = (n-a)//10
  b = n % 10
  c = (n-b)//10
  if a == b and b == c:
    return True
  else:
    return False

for i in range(1000):
  if checkDigit(N):
    print(N)
    break
  N += 1

Submission status: Accepted

Solution code:
# 初期入力
import sys
#input = sys.stdin.readline  #文字列では使わない
N = int(input())
num =[111,222,333,444,555,666,777,888,999]
for i in range(8):
    if N <= num[0]:
        ans =111
        break
    elif  num[i] < N <= num[i+1]:
        ans =num[i+1] 

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(n,1000):
    s=str(i)
    if s[0]==s[1]==s[2]:
        print(i)
        break

Submission status: Accepted

Solution code:
N = int(input())

for i in range(10):
    if 111*i < N <= 111*(i+1):
        print(111*(i+1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print((((int(input()) - 1) // 111) + 1) * 111)

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
if n%111==0:
  print(n)
else:
  print(111*((n+110)//111))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
for i in range(n,1000):
    a = str(i)
    if a[0] == a[1] and a[0] == a[2]:
        print(i)
        break

Submission status: Accepted

Solution code:
import sys
N = int(input())

for i in range(1,10):
    if N <= int(str(i)*3):
        print(str(i)*3)
        sys.exit()

Submission status: Accepted

Solution code:
import math
def main():
  n=int(input())
  a=int(n/100)
  if a*100+a*10+a>=n:
    print(a*100+a*10+a)
  else:
    print((a+1)*100+(a+1)*10+a+1)
main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
for i in range(9):
  if n<=i*111:
    print((i)*111)
    break
else:
  print(999)

Submission status: Accepted

Solution code:
n = input()
if n.count(n[0]) == 3:
    print(n)
else:
    num = int(str(n[0])+str(n[0])+str(n[0]))
    if int(n) > num:
        a = min(int(n[0])+1, 9)
        print("%d%d%d" % (a, a, a))
    else:
        print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    d =(N-1)//111
    print((d+1)*111)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
import itertools

def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    d,m = divmod(N-1,111)

    print((d+1)*111)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

for i in range(111, 1000, 111):
    if i >= n:
        break
print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = str(input())
memo = int( n[0] + n[0] + n[0] )
if int(n) <= memo:
	print(memo)
else:
	print(memo + 111)

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())

N = I()
A = [111*i for i in range(1,10)]

for i in range(9):
    if N <= A[i]:
        print(A[i])
        break

Submission status: Accepted

Solution code:
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N = int(input())
for i in range(N, 1000):
	if i//100==(i//10)%10:
		if i//100==i%10:
			print(i)
			sys.exit()

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Accepted

Solution code:
N=int(input())
X=set(str(N))
Y=len(X)
if Y==1:
  print(N)
if Y!=1:
  Z=0
  for i in range(111,1000,111):
    if N-i<0:
      Z+=i
      break
  print(Z)

Submission status: Accepted

Solution code:
import sys
N = int(input())
if not (100 <= N <= 999):
    sys.exit()

answer = [111,222,333,444,555,666,777,888,999]
for I in range(N,1000):
    for J in answer:
        if I == J:
            print(I)
            sys.exit()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0

while n > ans:
    ans += 111
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 999
for i in range(1,10):
    if 111*i-n>=0:
        ans = min(ans,111*i-n)
print(ans+n)

Submission status: Accepted

Solution code:
n = int(input())
a = n//100
b = 100*a+10*a+a
if b >= n:
    print(b)
else:
    print(b+111)

Submission status: Accepted

Solution code:
n = int(input())
div, mod = divmod(n, 111)
ans = div * 111 if mod == 0 else (div + 1) * 111
print(ans)

Submission status: Accepted

Solution code:
def main():
    s=int(input())
    for n in range(111, 1000, 111):
        if s <= n:
            print(n)
            return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    s=int(input())
    for n in range(s, 1000):
        ns=str(n)
        if ns[0] == ns[1] == ns[2]:
            print(ns)
            return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
mul = lambda x: x * 100 + x * 10 + x
if mul(n//100)>=n:ans = mul(n//100)
else :ans = mul(n//100+1)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n=input();l=[int(x) for x in n]
for i in range(min(set(l)),max(set(l))+1):
  ans=int(str(i)*3)
  if ans>=int(n):
    print(ans)
    break

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    for i in range(1, 10):
        if int(str(i) * 3) >= N:
            print(str(i) * 3)
            break

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
N=input()
c=len(N)
N=int(N)
t=((10**c)-1)//9
for i in range(1,10):
  if t*i>=N:
    print(t*i)
    sys.exit()

Submission status: Accepted

Solution code:
n = int(input())
count = 0

while n > count:
  count = count + 111
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ok(n):
    v=n%10
    ret=True
    while n>0:
        ret&=n%10==v
        n//=10
    return ret

N=int(input())
while not(ok(N)):
    N+=1
print(N)

Submission status: Accepted

Solution code:
l=[111*i for i in range(1,10)]
n=int(input())
for i in range(n,1000):
    if n in l:
        print(n)
        exit()
    else:
        n+=1

Submission status: Accepted

Solution code:
def resolve():
    cands = [111,222,333,444,555,666,777,888,999]
    N = int(input())
    import bisect
    print(cands[bisect.bisect_left(cands, N)])

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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


n = int(input())

base = int("1"*len(str(n)))

for i in range(1, 10):
    if n <= base*i:
        print(base*i)
        exit()

Submission status: Accepted

Solution code:
def not_xxx(N):
    X = list(str(N))
    if len(set(X)) == 1:
        return False
    else:
        return True

N = int(input())

while not_xxx(N):
    N += 1

print(N)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
i = N // 111
if N%111 != 0:
    i += 1
print(i*111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
a = n // 100
b = a * 100 + a * 10 + a
if(n > b):
  ans = (a + 1) * 100 + (a + 1) * 10 + (a + 1)

else:
  ans = a * 100 + a * 10 + a
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
Min = 100000
for i in range(1,10):
  Dif = i * 111 - N
  if min(Min,Dif) == Dif and i * 111 >= N:
    ans = i * 111
    Min = Dif
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
print(111*-(-N//111))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    N = int(input())

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
while True:
    if n%111==0:
        print(n)
        break
    n+=1

Submission status: Accepted

Solution code:
n = int(input())
while len(set(str(n)))!=1:
	n+=1
print(n)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

N = int(input())

lis = [111, 222, 333, 444, 555, 666, 777, 888, 999]

for num in lis:
    if num >= N:
        print(num)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 111, 222, 333, 444, 555, 666, 777, 888, 999]
    for i in range(len(x)):
        if n <= x[i]:
            print(x[i])
            exit()



if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

while 1:
  l = []
  for i in range(len(N)):
    l.append((int(N[i])))
  
  if min(l) == max(l):
    print(N)
    break
  else:
    N = str(int(N) + 1)

Submission status: Accepted

Solution code:
n = int(input())

a = 0
for i in range(1, 10):
    ans = [str(i)]*3
    ans_ = "".join(ans)
    if int(ans_) >= n:
        a = ans_
        if a != 0:
            break

print(int(a))

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1000):
  if n % 111 == 0:
    print(n)
    exit()
  n += 1

Submission status: Accepted

Solution code:
a=int(input())
n=[i*111 for i in range(1,10)]
if a in n:
    print(a)
    exit()

n.append(a)
n=sorted(n)
print(n[n.index(a)+1])

Submission status: Accepted

Solution code:
n = int(input())

while True:
    a, b, c = str(n)
    if a == b and b == c:
        print(a+b+c)
        exit()
    else:
        n += 1

Submission status: Accepted

Solution code:
n = int(input())
a = [111,222,333,444,555,666,777,888,999]
ans = 0
for i in a:
  if n > i:
    continue
  ans = i
  break

print(ans)

Submission status: Accepted

Solution code:
import sys
N = int(input())
for i in range(0,112):
  n = list(str(N+i))
  if n[0] == n[1] == n[2]:
    print(N+i)
    sys.exit()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = s()
if int(N) <= int(N[0]*len(N)):
    print(N[0]*len(N))
else:
    if N[0] == 9:
        print('1'+0*len(N))
    else:
        print(str(int(N[0])+1)*len(N))

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
ans = 0
for i in range(N, 1000):
    s = str(i)
    if s[0] == s[1] == s[2]:
        ans = i
        break
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
for i in range(1,10):
  if 111*i>=N:
    print(111*i)
    break

Submission status: Accepted

Solution code:
n=[x for x in input()]
if n[1]<n[2]:n[1]=str(int(n[1])+1)
if n[0]<n[1]:n[0]=str(int(n[0])+1)
print(n[0]*3)

Submission status: Accepted

Solution code:
n = int(input())
for x in range(0, 1000, 111):
    if x >= n:
        print(x)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=[111,222,333,444,555,666,777,888,999]
p=0
while a[p]<n:
    p+=1
print(a[p])

Submission status: Accepted

Solution code:
import bisect

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

def ii():
    return int(input())

def main():
    N = int(input())
    l = [111, 222, 333, 444, 555, 666, 777, 888, 999]
    i = bisect.bisect_left(l, N)
    print(l[i])



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

for i in range(10):
  if 111* i < n and n <= 111*(i+1):
    print(111*(i+1))

Submission status: Accepted

Solution code:
N=int(input())
for i in range(N,999+1):
  if i%111==0:
    print(i)
    exit()

Submission status: Accepted

Solution code:
N=int(input())
for i in range(N,999+1):
  check=str(N)
  if check[0]==check[1]==check[2]:
    print(N)
    exit()
  N+=1

Submission status: Accepted

Solution code:
n = int(input())
for i in range(1000):
  if i < 100:
    continue
  else:
    tmp = i
    if (tmp%10 == (tmp//10)%10 == (tmp//100)%10) and i >= n:
      print(i)
      break
    else:
      continue