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

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

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

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

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

Solution (Python):
n = int(input())

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

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

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

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

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

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

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

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

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

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

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

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

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

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

if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):



n = int(input())

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

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

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

Solution (Python):
n = int(input())

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

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

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

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

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

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

Solution (Python):
n = int(input())

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n = int(input())

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n = int(input())

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

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

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

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

Solution (Python):
N = int(input())
for i in range(N, N + 111):
    if str(i).count(str(i)[0]) == 3:
        print(i)
        break

Solution (Python):
N = int(input())
a = N//100
if N >(a*111):
    b = a+1
    print(b*111)
else:
    print(a*111)

Solution (Python):
check=[99, 111, 222, 333, 444, 555, 666, 777, 888, 999]

n=int(input())

if n in check:
    print(n)
else:
    for i in range(20):
        if check[i]<n<check[i+1]:
            print(check[i+1])
            exit()

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

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

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    list =[111,222,333,444,555,666,777,888,999]
    for i in list:
        if i>= n:
            print(i)
            break

Solution (Python):
n = int(input())

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

if n <= lis[0]:
    print(lis[0])
elif n <= lis[1]:
    print(lis[1])
elif n <= lis[2]:
    print(lis[2])
elif n <= lis[3]:
    print(lis[3])
elif n <= lis[4]:
    print(lis[4])
elif n <= lis[5]:
    print(lis[5])
elif n <= lis[6]:
    print(lis[6])
elif n <= lis[7]:
    print(lis[7])
elif n <= lis[8]:
    print(lis[8])

Solution (Python):
def actual(n):
    is_zorome = lambda num: len(set(str(num))) == 1

    for i in range(100, 1000):
        if i >= n and is_zorome(i):
            return i

n = int(input())
print(actual(n))

Solution (Python):
n=int(input())
if n%111==0:
    print(n)
else:
    x=n//111
    print((x+1)*111)

Solution (Python):
n=int(input())
if 100<=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)
else:print(999)

Solution (Python):
n = int(input())
l = list(range(111,1000,111))

if n % 111 == 0:
    print(n)
else:
    print(l[n // 111])

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

Solution (Python):
def resolve():
    N = input()
    a, b, c = list(N)
    if a < b or (a == b and a < c):
        a = int(a) + 1
    print(a, a, a, sep="")


resolve()

Solution (Python):
N = int(input())

i=0
while True:
    listN = list(str(N))
    
    if listN[0]==listN[1] and listN[1]==listN[2]:
        print(N)
        break
    N+=1

Solution (Python):
N = list(map(int, list(input())))

if N[1] < N[0]:
  print(N[0] * 111)
elif N[1] > N[0]:
  print((N[0]+1) * 111)
else:
  if N[2] <= N[0]:
    print(N[0] * 111)
  else:
    print((N[0]+1) * 111)

Solution (Python):
n=int(input())
while 1:
    if len(set(str(n)))==1:
        print(n)
        exit()
    n+=1

Solution (Python):
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)
else:
    print(1111)

Solution (Python):
N = input()

print(str(int(N[0]) + 1) * 3 if int(N[0] * 3) < int(N) else N[0] * 3)

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

Solution (Python):
N = int(input())
while True:
    if len(set(str(N))) == 1:
        break
    N += 1

print(N)

Solution (Python):
N = int(input())
for n in range(N, 1000):
    if len(set(str(n))) == 1:
        print(n)
        break

Solution (Python):
N = int(input())

for i in range(N,N+111):
  if i%111 == 0:
    print(i)
    exit()

Solution (Python):
n =  list(input())
N = [int(n[i]) for i in range(len(n))]
if N[0] == max(N):
  print(max(N) * 100 + max(N)*10 + max(N))
else:
  m = N[0]+1
  print(m * 100 + m * 10 + m)

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

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    sn = s_input()
    n = int(sn)

    compare_num = int(sn[0]) * 100 + int(sn[0]) * 10 + int(sn[0])
    
    if n == compare_num:
        print(n)
    elif n > compare_num:
        tmp = int(sn[0]) + 1
        print(tmp * 100 + tmp * 10 + tmp)
    else:
        print(compare_num)

if __name__ == '__main__':
    main()

Solution (Python):



S = input()

if int(S[0]) >= int(S[1]) and int(S[0]) >= int(S[2]):
    print(S[0]*3)
else:
    print(str(int(S[0])+1)*3)

Solution (Python):
n=int(input())
tmp=(n+110)//111
print(111*tmp)

Solution (Python):
def resolve():
    N = int(input())
    for i in range(1, 10):
        if N <= i*111:
            print(i*111)
            exit()
resolve()

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

Solution (Python):
n=int(input())

while(1):
  a=str(n)
  if a.count(a[0])==3:
    break
  n+=1
print(n)

Solution (Python):
n=list(input())

if int(n[0])>int(n[1]):
    ans = [n[0]]*3
elif int(n[0])==int(n[1]) and int(n[1])>=int(n[2]):
    ans = [n[0]]*3
else:
    ans = [int(n[0])+1]*3
print(*ans,sep="")

Solution (Python):
N = int(input())
for i in range(111, 999+1, 111):
    if i >= N:
        print(i)
        break

Solution (Python):
n = int(input())
i = 0

while True:
    x = n+i
    x = str(x)
    if x[0] == x[1] and x[1] == x[2]:
        print (x)
        exit ()
    else:
        i += 1

Solution (Python):
n = str(input())

ans_1 = 0
ans_2 = 0
x = int(n[0])
for i in range(len(n)):
    ans_1 += x * 10**i
    ans_2 += (x+1)*10**i
if ans_1 >= int(n):
    print(ans_1)
else:
    print(ans_2)

Solution (Python):
import sys
N = int(sys.stdin.readline().rstrip())
for i in range(N, 10**5):
    if len(set(list(str(i)))) == 1:
        print(i)
        exit()

Solution (Python):
n = int(input())

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

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

Solution (Python):
N = int(input())

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

Solution (Python):

import sys
input = sys.stdin.readline









N = int(input())

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

Solution (Python):
n = int(input())
for i in range(n, n + 112):
    i = str(i)
    for j in range(1, 10):
        j = str(j)
        if i.count(j) == len(i):
            print(i)
            exit()

Solution (Python):
n=int(input())
if n//100<(n%100)//10 or (n//100==(n%100)//10 and n//100<(n%10)):
  print(((n//100)+1)*111)
else:
  print((n//100)*111)

Solution (Python):
n = int(input())
for i in range(9):
    if n > 111*i and n <= 111*(i+1):
        ans = 111*(i+1)
        break
print(ans)

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

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

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

Solution (Python):
n = int(input())

for i in range(n,1000):
    one = i % 10
    ten = i //10 % 10
    hund = i // 100
    if one == ten and ten == hund:
        print(hund*100+ten*10+one)
        break

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

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

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

Solution (Python):
n=list(map(int,input()))
if n[0]<n[1] or (n[0]==n[1] and n[0]<n[2]):
  print(str(n[0]+1)*3)
else:
  print(str(n[0])*3)

Solution (Python):
n = int(input())
for i in range(1,10):
    if int(str(i)*3) >= n:
        print(str(i)*3)
        break

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

Solution (Python):

N = int(input())

for n in range(111, 1000, 111):
    if N <= n:
        print(n)
        exit(0)

Solution (Python):
import sys
from functools import lru_cache
def input(): return sys.stdin.readline().strip()


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



if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
ans=0
for i in range(n,n+200):
    N=str(i)
    if N[0]==N[1]==N[2]:
        ans=i
        break
print(ans)

Solution (Python):
N = int(input())
for i in range(10):
    if int(str(i)*3) < N <= int(str(i+1)*3):
        break
print(str(i+1)*3)

Solution (Python):
n = int(input())
for i in range(n, 1000):
    l = list(str(i))
    s = set(l)
    if len(s) == 1:
        print(i)
        exit()

Solution (Python):
n = int(input())
for i in range(n, 1000):
    l = list(str(i))
    s = set(l)
    if len(s) == 1:
        print(i)
        exit()

Solution (Python):


import bisect

N = int(input())
arr = [111, 222, 333, 444, 555, 666, 777, 888, 999]
ans_idx = bisect.bisect_left(arr, N)
print(arr[ans_idx])

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

Solution (Python):
str_n = str(input())

temp = int(str_n[0])
temp = 111*temp

int_n = int(str_n)

if int_n > temp:
  temp = int(str_n[0])
  temp = temp+1
  print(111*temp)
else:
  temp = int(str_n[0])
  print(111*temp)

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

Solution (Python):
s = input()
ans = 0
if int(s[0]) >= int(s[1]) and int(s[0]) >= int(s[2]):
    ans = int(s[0]) * 100 + int(s[0]) * 10 + int(s[0]) * 1
else:
    ans = int(s[0]) * 100 + int(s[0]) * 10 + int(s[0]) * 1 + 111
print(ans)

Solution (Python):
n = int(input())

print(-(-n//111)*111)

Solution (Python):
n = int(input())

for num in range(n, 1000):
    if num % 111 == 0:
        print(num)
        break

Solution (Python):
n=int(input())

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

for i in range(len(l)):
    if n<= l[i]:
        print(l[i])
        break

Solution (Python):
n = int(input())

print(-(-n//111)*111)

Solution (Python):
n = int(input())

for i in range(1000):
    if str(n)[0] == str(n)[1] ==str(n)[2]:
        print(n)
        exit()
    else:
        n+=1

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

Solution (Python):
N = int(input())

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

Solution (Python):
n = int(input())
m = list(str(n))
if m[0] == m[1] == m[2]:
    print(n)
else:
    for i in range(1, 10):
        if n<=i*111:
            print(i*111)
            break

Solution (Python):
import bisect

N = int(input())
A = [111, 222, 333, 444, 555, 666, 777, 888, 999]

print(A[bisect.bisect_left(A, N)])

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

Solution (Python):
n=int(input())
if 100<=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)

Solution (Python):
n = int(input())

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

print((n//111+1)*111)

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

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

Solution (Python):
n = int(input())
a = [str(i+1)*3 for i in range(9)]
for i in a:
    if n<=int(i):
        print(int(i))
        break

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

Solution (Python):
N = int(input())
a = int(str(N)[0] * 3)
if N == a:
    print(N)
elif N < a:
    print(a)
else:
    print(a + 111)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


n = I()
print(ceil(n/111)*111)

Solution (Python):
n = list(input())
i = n[0]
j = n[1]
k = n[2]
if int(j + k) <= int(i+i):
    print(i*3)
else:
    print(str(int(i)+1)*3)

Solution (Python):
import sys
import math
import bisect

def solve(n):
    while True:
        if len(set(list(str(n)))) == 1:
            return n
        n = n + 1

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

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
N = list(str(n))
ans = str()
res = N[0]
mn = True
bl = True
for x in N:
    if int(res) < int(x):
        mn = False
    if x != res:
        bl = False
if bl:
    print(n)
else:
    if not mn:
        for i in range(len(N)):
            ans += str(int(res) + 1)
        print(ans)
    else:
        for i in range(len(N)):
            ans += str(res)
        print(ans)

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

Solution (Python):
n = int(input())
for i in range(120):
    dum = str(n)
    set_dum = set(dum)
    if 1 == len(set_dum):
        break
    n += 1
print(n)

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

Solution (Python):
n = int(input())
for i in range(n,1111):
    i = str(i)
    if len(set(i))==1:
        print(i)
        break

Solution (Python):
import bisect

N = int(input())
A = [111, 222, 333, 444, 555, 666, 777, 888, 999]

print(A[bisect.bisect_left(A, N)])

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(input())
        x=999-n
        if str(n)[0]==str(n)[1]==str(n)[2]:
            return n
        for i in range(x+1):
            n+=1
            if str(n)[0]==str(n)[1]==str(n)[2]:
                return n
    print(main())
resolve()

Solution (Python):
n=int(input())
l = [111*i for i in range(1,10)]
for j in l:
  if j >= n:
    print(j)
    exit()

Solution (Python):
N = int(input())

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    print(-(-n // 111)*111)

resolve()

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

Solution (Python):
import bisect

inf = 10**15
mod = 10**9+7

kouho = [111, 222, 333, 444, 555, 666, 777, 888, 999]
n = int(input())
ind = bisect.bisect_left(kouho, n)
print(kouho[ind])

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

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    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())
    
    
    n = input()
    if int(n) > int(n[0]*3):
        print((int(n[0])+1) * 111)
    else:
        print(int(n[0]*3))

if __name__ == "__main__":
    main()

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

Solution (Python):
N = int(input())
L = [111*i for i in range(1,10)]
ans = 0
for l in L:
    if N <= l:
        ans = l
        break
print(l)

Solution (Python):
import sys
import collections

N = int(input())
Ans = 111

while True:
    if len(collections.Counter(list(str(Ans)))) == 1 and Ans >=  N:
        print(Ans)
        sys.exit()
    else:
        Ans += 1

Solution (Python):
N=int(input())
def f(n):
  n=str(n)
  if n[0]==n[1]==n[2]:
    return True
  else:
    return False

for i in range(N,1000):
  if f(i):
    print(i)
    exit(0)

Solution (Python):
import itertools
import math
import fractions
import functools
n = int(input())

i = math.ceil(n / 111)
print(i*100+i*10+i)