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())
for i in range(N, N + 111):
    if str(i).count(str(i)[0]) == 3:
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = input()

print(str(int(N[0]) + 1) * 3 if int(N[0] * 3) < int(N) else 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:
N = int(input())
while True:
    if len(set(str(N))) == 1:
        break
    N += 1

print(N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
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
# input = sys.stdin.readline 
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()

Submission status: Accepted

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


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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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)
    break

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:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
x = (n - 1) // 111 + 1
print(x * 100 + x * 10 + x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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=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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# input
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B - AtCoder Beginner Contest 111

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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
for i in range(n,1111):
    i = str(i)
    if len(set(i))==1:
        print(i)
        break

Submission status: Accepted

Solution code:
import bisect

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys
def input(): return sys.stdin.readline().strip()

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

resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, 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 operator import itemgetter              # itemgetter(1), itemgetter('key')
# 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 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 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 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 copy import deepcopy                    # to copy multi-dimentional matrix without reference
# 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())
    
    
    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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,10):
    if int(n)>int(str(i)*3):
        continue
    print(str(i)*3)
    break

Submission status: Accepted

Solution code:

n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

t = 0
    
while t*111 < n  and n > (t+1)*111:
    t += 1
    
print((t+1)*111)

Submission status: Accepted

Solution code:
N = int(input())
S = str(N)

if S[0] == S[1] == S[2]:
    print(N)
else:
    print(111 * (N // 111 + 1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
if n % 100 <= n // 100 * 11:
  print(n // 100 * 111)
else:
  print((n // 100 + 1) * 111)

Submission status: Accepted

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

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 n in [111, 222, 333, 444, 555, 666, 777, 888, 999]:
  if n >= N:
    print(n)
    break

Submission status: Accepted

Solution code:
N=input()
if len(set(N))==1:
    print(int(N))
else:
    for i in range(111,1110,111):
        if i>=int(N):
            print(i)
            exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
for i in [str(i)*3 for i in range(10)]:
    if int(i) >= n:
        print(int(i))
        break

Submission status: Accepted

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


def solve(N: int):
    print(-(-N // 111) * 111)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
l = []
for i in range(1, 10):
    x = int(str(i) + str(i) + str(i))
    if x >= n:
        print(x)
        exit()

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:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

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

Submission status: Accepted

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

Submission status: Accepted

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

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)
        break

Submission status: Accepted

Solution code:
N = int(input())

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

ans = 999

for i in lst:
    if i >= N:break
print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
for i in range(0,11):
    if 111*i<n and n<=111*(i+1):
        print(111*(i+1))

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
answer = ''
for x in range(N, 1000):
    temp = str(x)
    if len(set(temp)) == 1:
        answer = x
        break

print(answer)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

while 1:
    if N % 111 == 0:
        print(N)
        break
    N += 1

Submission status: Accepted

Solution code:
n = int(input())
contest = [int(str(i)+str(i)+str(i)) for i in range(1, 10)]
for i in range(9):
    if n <= contest[i]:
        print(contest[i])
        break

Submission status: Accepted

Solution code:
n = int(input())
apple = []

number = [111, 222, 333, 444, 555, 666, 777, 888, 999]
for i in number:
    if i - n >= 0:
        apple.append(i)

print(min(apple))