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 = input()
N = list(n)
if N[0] > N[1]:
    print(N[0] + N[0] + N[0])
elif N[0] == N[1]:
    if N[1] >= N[2]:
        print(N[0] + N[0] + N[0])
    else:
        b = int(N[0]) + 1
        print(b * 111)
else:
    b = int(N[0]) + 1
    print(b * 111)

Submission status: Accepted

Solution code:
N=int(input())
if  N//100 > (N//10)%10:
	print(111*(N//100))
	
elif N//100 == (N//10)%10 >= N%10 :
	print(111*(N//100))
	
else:
	print(111*((N//100)+1))

Submission status: Accepted

Solution code:
N=int(input().strip())

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

Submission status: Accepted

Solution code:
#B問題
N=int(input() )

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

Submission status: Accepted

Solution code:

n = int(input())
a = int(n/111.1)

print(int(111*(a+1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
cs = [1111, 999, 888, 777, 666, 555, 444, 333, 222, 111]
f = False
for i, c in enumerate(cs):
    if (c+1) <= n:
        print(cs[i-1])
        f = True
        break
if not f:
    print(cs[len(cs)-1])

Submission status: Accepted

Solution code:
s = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())


H = N // 100
T = (N % 100) // 10
O = N % 10

if T > H:   H += 1
elif T == H and O > H:  H += 1

print(H*111)

Submission status: Accepted

Solution code:
n=int(input())
while True:
  d=[]
  n0=n
  while n0>0:
    d.append(n0%10)
    n0//=10
  if d[0]==d[1] and d[1]==d[2]:
    break
  n+=1
print(n)

Submission status: Accepted

Solution code:
x=int(input())
z=[111,222,333,444,555,666,777,888,999]
for i in range(9):
  if x==z[i]:
    print(z[i])
    break
  elif i==0 and x<z[i]:
    print(z[i])
    break
  elif i!=8 and z[i]<x<z[i+1]:
    print(z[i+1])
    break
  elif i==8 and x<z[i]:
    print(z[i])
    break

Submission status: Accepted

Solution code:
N = int(input())
done = False

while not done:
    n = list(map(int,list(str(N))))
    if n[0] == n[1] and n[1] == n[2]:
        done = True
    else:
        N += 1

print(N)

Submission status: Accepted

Solution code:
N = input()

if int(N) <= int(''.join([N[0] for _ in range(3)])):
    print(int(''.join([N[0] for _ in range(3)])))
else:
    print(''.join(str(int(N[0]) + 1) for _ in range(3)))

Submission status: Accepted

Solution code:
N = int(input())
if N>=100 and N<=111:
    print(111)
if N>=112 and N<=222:
    print(222)
if N>=223 and N<=333:
    print(333)
if N>=334 and N<=444:
    print(444)
if N>=445 and N<=555:
    print(555)
if N>=556 and N<=666:
    print(666)
if N>=667 and N<=777:
    print(777)
if N>=778 and N<=888:
    print(888)
if N>=889 and N<=999:
    print(999)

Submission status: Accepted

Solution code:
n = raw_input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# abc_111_b

# if num % 111 == 0: return num

def solve(num):             # 750
    c = num // 100          # c = 7  
    du = num - c * 100      # du = 50
    if du <= c*11:          # du <= 777
        return c*111        # return 7*111
    else:
        return (c+1)*111    # return 8*111

if __name__ == "__main__":
    print (solve(int(input(""))))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
while N % 111:
    N += 1
print(N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math as M
n=input()
list = list(map(int,n))
max = sorted(list)[len(n)-1]
if int(n[0])==max:
    print(str(max)*len(n))
else:
    print(str(int(n[0])+1) * len(n))

Submission status: Accepted

Solution code:
import re
import sys

n = int(input())

for i in range(n, 1000):
    if re.match('^([0-9])\\1+$', str(i)):
        print(i)
        sys.exit(0)

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(1, 10):
    if((i-1)*111<N and N<=i*111):
        print(i*111)

Submission status: Accepted

Solution code:
n = input()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for i in range(1, 10):
  if 100*i + 10*i + i >= N:
    print('{}{}{}'.format(i, i, i))
    break

Submission status: Accepted

Solution code:
N=input()
n=list(map(int,str(N)))

if n[1]*10+n[2] > n[0]*11:
    print((n[0]+1)*111)
else:
    print(n[0]*111)

Submission status: Accepted

Solution code:
i = str(raw_input())
top = i[0]

if int(i[0])<int(i[1]):
	top = str(int(i[0])+1)
elif int(i[0])==int(i[1]):
	if int(i[1])<int(i[2]):
		top = str(int(i[0])+1)

print str(top)*3

Submission status: Accepted

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

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

else:
	print((N[0] + 1) * 111)

Submission status: Accepted

Solution code:
N = int(input())
j = 1
while j <= 9:
  if N <= (100*j+10*j+j):
    N = 100*j+10*j+j
    break;
  j = j + 1
print(N)

Submission status: Accepted

Solution code:
N = input()
length = len(N)
N = int(N)
detect = [111,222,333,444,555,666,777,888,999]

for i in range(9):
    if N <= detect[i]:
        print(detect[i])
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

ABC = 111
event_time = []
while 100 <= ABC <= 999:
    event_time.append(ABC)
    ABC += 111
#print(event_time)


N = int(input())
i = 0

for x in event_time:
    if N <= x:
        print(x)
        break

Submission status: Accepted

Solution code:
abcs = [111,222,333,444,555,666,777,888,999]
res = abcs[0]
i = int(input())

for abc in abcs:
  if i <= abc:
    res = abc
    break
print (res)

Submission status: Accepted

Solution code:
a_str = input()
a = int(a_str)
x, y, z = map(int, list(a_str))
if x*111==a:
    print(a)
elif x*111 > a:
    print(x*111)
else:
    print((x+1)*111)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n  = int( input())

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

Submission status: Accepted

Solution code:
# coding:utf-8


def main():
    n = int(input())
    numlist = [111, 222, 333, 444, 555, 666, 777, 888, 999]
    for num in numlist:
        if num >= n:
            print(num)
            break


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
c=n%10
b=int(((n-c)%100)/10)
a=int(((n-b-c)%1000)/100)
x=a*100+a*10+a
if b < a:pass
elif b==a and c<b:pass
elif a==b and b==c:pass
else:x+=111
print(x)

Submission status: Accepted

Solution code:
n = [int(i) for i in input()]

if(n[0] > n[1]):
    n[1] = n[0]
    n[2] = n[0]
elif(n[0] == n[1] and n[1] >= n[2]):
    n[2] = n[0]
elif(n[0] == n[1] and n[1] < n[2]):
    n[0] = n[0] + 1
    n[1] = n[0]
    n[2] = n[0]
elif(n[0] < n[1]):
    n[0] = n[0] + 1
    n[1] = n[0]
    n[2] = n[0]

print("{}{}{}".format(n[0],n[1],n[2]))

Submission status: Accepted

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

N = int(input())

for i in range(1000):
    n = N + i
    nums = []
    while n != 0:
        nums.append(n % 10)
        n //= 10

    f = True
    if all([n == nums[0] for n in nums]):
        print(N + i)
        break

Submission status: Accepted

Solution code:
k=int(input())
l=[]
p=[]
for i in range(1,10):
  l.append(111*i)
for i in l:
  if i-k>=0:
    p.append(i)
print(min(p))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n):
    for k in range(1, 10):
        x = k*111
        if x >= n:
            return x

assert solve(111) == 111
assert solve(112) == 222
assert solve(750) == 777
print solve(input())

Submission status: Accepted

Solution code:
import sys

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

for i in range(len(nl)):
    if(n == nl[i]):
        print(nl[i])
        sys.exit()
    elif(n < nl[i]):
        print(nl[i])
        sys.exit()
    else:
        continue

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
n=int(input())
for i in range(100,1000):
    if len(set(str(i)))==1 and n<=i:
        print(i)
        exit()

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
a=str(n)
while(a[0]!=a[1] or a[1]!=a[2]):  
    n+=1
    a=str(n)

print(n)

Submission status: Accepted

Solution code:
x = int(input())
a = [111*i for i in range(1,10)]
print(x+min([abs(x-y) for y in a if x<=y]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

a =int(input())
for i in range(1,10):
    if (i-1)+(i-1)*10 +(i-1)*100 < a <= i + 10*i + 100*i:
        print (i+i*100+i*10)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n =int(input())
p_100 = n // 100
tmp = n % 100
p_10 = tmp // 10
p_1 = tmp % 10
if p_100 == p_10:
    if p_10 == p_1:
        print(str(p_1) * 3)
    elif p_10 <= p_1:
        print(str(p_10+1) * 3)
    elif p_10 >= p_1:
        print(str(p_10) * 3)
elif p_100 <= p_10:
    print(str(p_100+1) * 3)
elif p_100 >= p_10:
    print(str(p_100) * 3)

Submission status: Accepted

Solution code:
n = int(input()) # 入力を受け付ける
match = 0

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

print(match)

Submission status: Accepted

Solution code:
n = int(input())
n1 = n//100
n2 = n//10 - n1*10
n3 = n - n1*100 -n2*10

if n<=n1*111:
    print(n1*111)
    exit()
else:
    print((n1+1)*111)
    exit()

Submission status: Accepted

Solution code:
S = list(input())

if S.count(S[0]) == len(S):
    print("".join(S))

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

Submission status: Accepted

Solution code:
#!/bin/env python

def main():
    s = raw_input().strip()
    retval = ""
    num = int(s[0])
    if int(s) <= num * 111:
        print num * 111
    else:
        print (num + 1) * 111

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

a = N % 111
if a == 0:
    print(N)
else:
    print((N - a + 111))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    if len(sys.argv) == 1:
        set_stdin(os.path.dirname(__file__) + '/test/' + 'sample-1.in')# }}}

def solve():
    N = int(input())
    for n in range(N, 1112):
        s = set()
        for c in str(n):
            s.add(c)
        if len(s)==1:
            print(n)
            return 0
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}

Submission status: Accepted

Solution code:
n = int(raw_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
else:
    print 999

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
x = 111

for i in range(9):
    if x >= n:
        print(x)
        break
    else:
        x += 111

Submission status: Accepted

Solution code:
n = int(input())

while True:

  temp = list(str(n))
  if temp.count(temp[0]) == len(temp):
    print(n)
    break
  
  n += 1

Submission status: Accepted

Solution code:
n = int(input())

for i in range(9):
    if 0<n-111*i<=111:
        print(111*(i+1))
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

    # See:
    # https://www.youtube.com/watch?v=fYS-rAUSD5o
    for i in range(111, 1000, 111):
        if i >= n:
            print(i)
            exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N = input()

ans = N[0]
for i in range(2):
    if N[i] != N[i+1]:
        if int(N[i]) < int(N[i+1]):
            ans = str(int(N[i]) + 1)
        break

for i in range(3):
    print(ans, end="")
print()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = (n - 1) // 111

print((a+1) * 111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n=int(arr_data[0][0])

arr=[int(str(x)*3) for x in range(1,10)]

print(min(list(filter(lambda x : x >=n, arr))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())


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

Submission status: Accepted

Solution code:
N = int(input())

n = N
for n in range(n, n+200):
    a = int(n / 100)
    b = int((n % 100) / 10)
    c = int(n % 10)
    if (a == b and b == c):
        print(str(a) * 3)
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

x = int(N[0]) * 111
if int(N) <= x:
    print(x)
else:
    print(x + 111)

Submission status: Accepted

Solution code:
s=input()
a=s[0]
b=a*len(s)
if int(s)<=int(b):
    print(b)
else:
    if int(a)!=9:
        print(str(int(a)+1)*len(s))
    else:
        print('1'*(len(s)+1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
a=[int(i) for i in a]
l=len(a)
m=max(a)
if a[0]==m:
    print(str(m)*l)
else:
    print(str(a[0]+1)*l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
r,q=divmod(N,100)
if r*11 >= q:
    print(r*111)
else:
    print((r+1)*111)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

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

Submission status: Accepted

Solution code:
N = int(input())

while True:
    if str(N)[0] == str(N)[1] and str(N)[1] == str(N)[2]:
        ans = N
        break
    N += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2018-10-05 18:48
x = raw_input()
# x = "123"
n = len(x)
if int(x[0] * n) >= int(x):
    print x[0] * n
else:
    print str(int(x[0]) + 1) * n

Submission status: Accepted

Solution code:
n = input()

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

Submission status: Accepted

Solution code:
n = int(input())

def isredigits(num):
    if len(set(list(str(num)))) is 1:
        return True

while not isredigits(n):
    n += 1

print(n)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
inp = int(input())

if inp <= 111:
  print("111")
elif inp <= 222:
  print("222")
elif inp <= 333:
  print("333")
elif inp <= 444:
  print("444")
elif inp <= 555:
  print("555")
elif inp <= 666:
  print("666")
elif inp <= 777:
  print("777")
elif inp <= 888:
  print("888")
elif inp <= 999:
  print("999")

Submission status: Accepted

Solution code:
a=list(input())
A = B = C = ''
if a[0] == a[1] and a[0] == a[2] or a[0] >= a[2] and a[0] == a[1]:
    for _ in range(3):
        A += str(a[0])
    print(A)
else:
    if a[1] >= a[0] :
       a[0] = int(a[0]) + 1
       for i in range(3):
        B += str(a[0])
    
       print(B)

    else:
       for i in range(3):
        C += str(a[0])
    
       print(C)

Submission status: Accepted

Solution code:
# -*- coding : utf-8 -*-

n = int(input())

shou = int(n / 111)
amari = int(n % 111)

ans = shou
if amari != 0:
    ans = shou + 1

print(ans * 111)

Submission status: Accepted

Solution code:
n=input()
a=n[0]
if a+a+a >= n:
    print(a+a+a)
else:
    print(*[int(a)+1]*3,sep='')

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = input()
stra = N[0]
strb = N[1]
strc = N[2]
a = int(stra)
b = int(strb)
c = int(strc)
if a > b:
    print(3 * stra)
elif a < b:
    print(3 * str((a + 1)))
else:
    if b >= c:
        print(3*strb)
    else:
        print(3* str(a + 1))

Submission status: Accepted

Solution code:
N = input()

n1 = int(N[0])
n2 = int(N[1])
n3 = int(N[2])

if n1 >= n2 and n1 >= n3:
    n1String = str(n1)
    print(n1String * 3)
else:
    n1StringPlus = str(n1+1)
    print(n1StringPlus * 3)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = str(input())
listed_N = list(N)

list_map  = list(map(int, listed_N))
 
if list_map[0]<list_map[1]:
    print("{}{}{}".format(list_map[0]+1,list_map[0]+1,list_map[0]+1))
elif list_map[0] == list_map[1]:
    if list_map[1]<list_map[2]:
        print("{}{}{}".format(list_map[0]+1,list_map[0]+1,list_map[0]+1))
    else:
        print("{}{}{}".format(list_map[0],list_map[0],list_map[0]))
else:
    print("{}{}{}".format(list_map[0],list_map[0],list_map[0]))

Submission status: Accepted

Solution code:
n = int(input())

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

for num in list:
    if (n <= num):
        print(num)
        break

Submission status: Accepted

Solution code:
n = int(input())

handret = n // 100
number = handret * 100 + handret * 10 + handret

if number < n:
    handret += 1
    number = handret * 100 + handret * 10 + handret

print(number)

Submission status: Accepted

Solution code:
n = list(input())
ori = ''.join(map(str, n))
n = set(n)

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

Submission status: Accepted

Solution code:
n = str(input())
minim = 1000
x = int(n)
for i in range(1, 10):
    nr = i*100 + i*10 + i
    if x <= int(nr) < minim:
        minim = int(nr)
print(minim)

Submission status: Accepted

Solution code:
n = int(input())
if n%111 == 0:
    check = True
else:
    check = False

while check == False:
    n += 1
    if n%111 == 0:
        check = True
    
print(n)

Submission status: Accepted

Solution code:
import sys
import numpy as np
a=[int(x)for x in list(sys.stdin.readline().rstrip())]+[0]
print(str(a[0]+(1if(np.trim_zeros(np.diff(a))[0]>0)else 0))*(len(a)-1))

Submission status: Accepted

Solution code:
import sys
import numpy as np
a=[int(x)for x in list(sys.stdin.readline()[:3])]+[0]
print((a[0]+(1if(np.trim_zeros(np.diff(a))[0]>0)else 0))*111)

Submission status: Accepted

Solution code:
import sys
import numpy as np
a=[int(x)for x in list(sys.stdin.readline()[0:3])]+[-1]
print(str(a[0]+(1if(np.trim_zeros(np.diff(a))[0]>0)else 0))*3)

Submission status: Accepted

Solution code:
print((10 -[1 if i%111==0 else 0 for i in range(1001)][int(input()):1001].count(1)) *111)

Submission status: Accepted

Solution code:
import math

N = int(input())

print(math.ceil(N / 111.0) * 111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
n = int(input())
if n%111 == 0:
    print(n)
else:
    print(111*(int(n/111)+1))

Submission status: Accepted

Solution code:
n = int(input())

ans = n
s = str(n)

flag = s[0] == s[1] and s[1] == s[2]

while not flag:
    n+=1
    s=str(n)
    flag = s[0] == s[1] and s[1] == s[2]

print(s)

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())
q = int(n / 111)
if n % 111 == 0:
  i = q
else:
  i = q + 1
print(i * 111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
for i in range(10):
    if ans >= n:
        break
    ans+=111

print(ans)

Submission status: Accepted

Solution code:
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(n):
    a = []
    b = str(n)
    a.append(b)
    for i in a:
        c = i
    d = c[0]
    e = int(d)*100 + int(d)*10 + int(d)
    if e >= n:
        return e
    else:
        return int(e)+111

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())

c=N%10
N//=10
b=N%10
N//=10
a=N%10

d=1
if((a==b and b>=c )or a>b):
    a=a-1
a=a+1
d=a*100+a*10+a
print(d)

Submission status: Accepted

Solution code:
s = int(input())
while(True):
    ss = str(s)
    if(max(ss) == min(ss)):
        print(s)
        break
    s += 1

Submission status: Accepted

Solution code:
n=list(input())
temp=""
temp=temp.join(map(str,n))
temp=int(temp)
if n[0]==n[1]==n[2]:
    temp=""
    temp=temp.join(map(str,n))
    temp=int(temp)
    print(temp)
else:
    a=n[0]*3
    a=int(a)
    b=(str(int(n[0])+1))*3
    b=int(b)
    if a<temp:
        print(b)
    else:
        print(a)

Submission status: Accepted

Solution code:
n = int(input())

a = int(n / 100)

zoro = (100 * a) + (10 * a) + a

if(n <= zoro):
    print(zoro)
else:
    a = a + 1
    zoro = (100 * a) + (10 * a) + a
    print(zoro)

Submission status: Accepted

Solution code:
N = int(input())

S = (((N-1)//111)+1)*111

print(S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
if n % 111 > 0:
    n = int((n - int(n / 100) * 11 + 100) / 100) * 111
print(n)

Submission status: Accepted

Solution code:
#coding: utf-8

nextContest = int(input())

for i in range(nextContest, 1000):
    dig1 = int(i / 100)
    dig2 = int((i % 100) / 10)
    dig3 = int((i % 100) % 10)
    if dig1 == dig2 and dig2 == dig3:
        print (str(i))
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = n//100
b = (n-100*a)//10
c = (n-100*a-10*b)

if a > b:
  print("{0}{0}{0}".format(a))
elif a==b and b>=c:
  print("{0}{0}{0}".format(a))
else:
  print("{0}{0}{0}".format(a+1))

Submission status: Accepted

Solution code:
N = int(input())
s = int(N/111) #整数部分
a = 0
if N%111 == 0:
    a = N
else:
    a = 111*(s+1)
print(a)

Submission status: Accepted

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