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())
x=list(int(100*i+10*i+i) for i in range(1,10))
y=list(t for t in x if t>=N)
print(min(y))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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=input()
if int(n[0])>int(n[1]):
  out=int(n[0])
elif int(n[0])==int(n[1]):
  if int(n[1])>=int(n[2]):
    out=int(n[0])
  else:
    out=int(n[0])+1
else:
    out=int(n[0])+1
print(str(out)*3)

Submission status: Accepted

Solution code:
n = str(input())

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

Submission status: Accepted

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

    result = 0
    if 0 <= N <= 111:
        result = 111
    elif 111 < N <= 222:
        result = 222
    elif 222 < N <= 333:
        result = 333
    elif 333 < N <= 444:
        result = 444
    elif 444 < N <= 555:
        result = 555
    elif 555 < N <= 666:
        result = 666
    elif 666 < N <= 777:
        result = 777
    elif 777 < N <= 888:
        result = 888
    elif 888 < N <= 999:
        result = 999

    print(result)
    

main()

Submission status: Accepted

Solution code:
N = int(input())
for i in range(1,10):
    s0 = int(str(i-1)*3)
    s = int(str(i)*3)
    if s0 < N <=s:
        print(s)
        break

Submission status: Accepted

Solution code:
x=list(map(int,input()))
print(str(x[0])*3 if (x[0] >= x[1] and x[0] >= x[2]) else str(x[0]+1) * 3)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N=int(input())
#N,T=map(int,input().split())
for i in range(1000):
    if (N+i)%111==0:
        print(N+i)
        break

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1, 10):
    n = i * 100 + i * 10 + i
    if n >= N:
        print(n)
        break

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:
import bisect
N = int(input())
candidate = [int(i*111) for i in range(1,10)]
print(candidate[bisect.bisect_left(candidate, N)])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

def check(n):
  s=str(n)
  for i in range(1,len(s)):
    if s[i] != s[i-1]:
      return False
  return True

while True:
  if check(N):
    print(N)
    break
  else:
    N+=1

Submission status: Accepted

Solution code:
def abc111(N: int) -> int:
    d = N // 100
    n1 = d * 111
    n2 = (d+1) * 111

    if N <= n1:
        return n1
    return n2


if __name__ == "__main__":
    N = int(input())
    ans = abc111(N)
    print(ans)

Submission status: Accepted

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

ans = [111,222,333,444,555,666,777,888,999]
import bisect
N = ri()
i = bisect.bisect_left(ans,N)
print(ans[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
for i in range(n, 2000):
    l=list(str(i))
    if all (j==l[0] for j in l):
        print(i)
        break

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc111/tasks/abc111_b
print(((int(input()) - 1) // 111 + 1) * 111)

Submission status: Accepted

Solution code:
N = input()
N_list = [int(i) for i in N]
top_num = N_list[0]
length = len(N_list)
flag = True
for i in range(length-1):
  if top_num == 9:
    flag = True
    break
  if N_list[i]>N_list[i+1]:
    flag = True
    break
  elif N_list[i]==N_list[i+1]:
    flag = True
  else:
    flag = False
    break

if flag:
  print(str(top_num)*length)
else:
  print(str(top_num+1)*length)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = input()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

ansers = [i * 111 for i in range(1, 10)]

ret = 999
for a in ansers:
    if N <= a:
        ret = a
        break

print(ret)

Submission status: Accepted

Solution code:
strn = input()
n = int(strn)
head = strn[0]
if(n <= int(head*len(strn))):
    print(int(head*len(strn)))
elif(int(head) <= 8):
    print(int(str(int(head)+1)*len(strn)))
else:
    print(int("1"*(len(strn)+1)))

Submission status: Accepted

Solution code:
n = input()
a,b,c = [int(n[i]) for i in range(len(n))]

if a > b:
  print(a*111)
elif a == b:
  if b >= c:
    print(a*111)
  else:
    print((a+1)*111)
else:
  print((a+1)*111)

Submission status: Accepted

Solution code:
n = int(input())

l = []

for i in range(1,10):
	l.append(i*111)

l.append(0)
l.sort()

for i in range(9):
	if l[i] < n <= l[i+1]:
		print(l[i+1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N=int(stdin.readline().rstrip())
ans=0
tmp=1000
for i in range(1,10):
    for j in range(3,5):
        num=int(str(i)*j)
        if num-N >= 0 and tmp > num-N:
            tmp = num-N
            ans=num
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8

N = int(input())

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

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:
n=int(input())
i=1
while n>111*i:
    i+=1
print(111*i)

Submission status: Accepted

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

N = int(input())

ans = N
while True:
    if len(set(str(ans))) == 1:
        print(ans)
        exit()
    ans += 1

Submission status: Accepted

Solution code:
def solve(string):
    if int(string[0]) == int(string[1]) == int(string[2]):
        return string
    elif int(string[0] * 3) > int(string):
        return string[0] * 3
    else:
        return str(int(string[0]) + 1) * 3


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

Solution code:

# coding: utf-8

# In[18]:


N = int(input())


# In[19]:


if str(N)[0] > str(N)[1]:
    tmp = str(N)[0]
elif str(N)[0] == str(N)[1]:
    if str(N)[1] >= str(N)[2]:
        tmp = str(N)[0]
    else:
        tmp = str(int(str(N)[0]) + 1)
else:
    tmp = str(int(str(N)[0]) + 1)


# In[20]:


print(int("".join([tmp for _ in range(3)])))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
arr = [111,222,333,444,555,666,777,888,999]
tgt = [N-111*(i+1) for i in range(9)]
for i,sub in enumerate(tgt):
  if sub <= 0:
    print(arr[i])
    break

Submission status: Accepted

Solution code:
N = int(input())
ABC = [int("{0}{0}{0}".format(i)) for i in range(10)]
for abc in ABC:
  if N <= abc:
    print(abc)
    break

Submission status: Accepted

Solution code:
#cording: utf-8

N = int(input())

while True:
    List = list(str(N))
    if len(list(set(List))) == 1:
        print(N)
        exit()
    N += 1

Submission status: Accepted

Solution code:
A = list(input())
if A[0] == A[1] == A[2]:
  print(A[0]+A[0]+A[0])
else:
  if A[0] == A[1]:
    if A[1]>A[2]:
      print(A[0]+A[0]+A[0])
    else:
      A[0] = str(int(A[0])+1)
      print(A[0]+A[0]+A[0])
  else:
    if A[0]>A[1]:
      print(A[0]+A[0]+A[0])
    else:
      A[0] = str(int(A[0])+1)
      print(A[0]+A[0]+A[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

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

Submission status: Accepted

Solution code:
N = input()
n= int(N)
while(n<=999):
    ans = n
    if len(set(str(n))) == 1:
        break
    else:
        n += 1
print(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
  
for d in range(1, 10):
  if str(d) * len(N) >= N:
    print(str(d) * len(N))
    break

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[1]))):
    ans = int(a[0] * 3)
elif(int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1]) and a[-1] != '0'):
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

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 l[i]>=n:
        ans=l[i]
        break
    else:
        pass
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
li = [111,222,333,444,555,666,777,888,999]
nn = []
for i in range(len(li)):
  if li[i] - n >= 0:
    nn.append(li[i]-n)
  else:
    nn.append(1000)
  
print(li[nn.index(min(nn))])

Submission status: Accepted

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

Submission status: Accepted

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

    for i in range(1, 10):
        a = 111 * i
        if a >= N:
            return a

ans = main()
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
len_N = len(str(N))
num = int(str(N)[0])
if int(str(num) * len_N) < N:
  print(str(num + 1) * len_N)
else:
  print(str(num) * (len(str(N))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**7) 
 
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())
 
# h,w = li()
# ss = [ns() for _ in range(h)]

ls = [2222,1111,999,888,777,666,555,444,333,222,111]

X = int(input())
ans = 111
for s in ls:
    if X <= s:
        ans = s

print(ans)

Submission status: Accepted

Solution code:
n=list(input())
if max(n)==n[0]:
    print(n[0]*len(n))
else:
    print(str((int(n[0])+1))*len(n))

Submission status: Accepted

Solution code:
n = int(input())
s = [111,222,333,444,555,666,777,888,999]

for index,item in enumerate(s):
    if n <= item:
        print(item,end='')
        break

Submission status: Accepted

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

N = int(input())

i = 1
while True:
    v = i * 100 + i * 10 + i
    if N <= v:
        print(v)
        break
    i += 1

Submission status: Accepted

Solution code:
a = list(map(int, list(input())))
print([str(a[0])*3, str(a[0]+1)*3][a[0] < a[1] or a[0] < a[2]])

Submission status: Accepted

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

import math
import sys
import heapq
from operator import itemgetter
import itertools
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

ans_st = [111, 222, 333, 444, 555, 666, 777, 888, 999]
n = int(input().rstrip())
i = 0
while n > ans_st[i]:
	i += 1
print(ans_st[i])

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
n = list(input())
while(1):
  if (n[0] == n[1]) and (n[1] == n[2]):
    break
  else:
    n = list(str(int(''.join(n)) + 1))
print(''.join(n))

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()

start = n[0]

if all([start >= i for i in n]):
    print(n[0] * len(n))
else:
    print((str(int(n[0]) + 1)) * len(n))

Submission status: Accepted

Solution code:
n = int(input())

a = 1
while True:
    b = 111 * a
    if n <= b:
        print(b)
        break
    a += 1

Submission status: Accepted

Solution code:
n = input()

a = n[0] + n[0] + n[0]
b = str(int(n[0]) + 1)
c = b + b + b

if int(n) <= int(a):
    print(a)
else:
    print(c)

Submission status: Accepted

Solution code:
N = input()
ans = []
for i in range(len(N)):
  ans.append(N[0])
if int(''.join(ans)) >= int(N):
    print(''.join(ans))
    exit()
ans = []
for i in range(len(N)):
  ans.append(str(int(N[0]) + 1))
print(''.join(ans))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())

while True:
    if N%111==0:
        break
    N=N+1

print(N)

Submission status: Accepted

Solution code:
N = int(input())

for i in '123456789':
    if int(i+i+i) >= N:
        print(i+i+i)
        break

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N,999+1):
    n = list(str(i))
    if n.count(n[0]) == 3:
        print(i)
        break

Submission status: Accepted

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

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 = input()
x = N[0] * len(N)
if int(x) >= int(N):
    print(x)
    exit()
x = str(int(N[0]) + 1) * len(N)
print(x)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
# B
N = int(input())
result = ''

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

Submission status: Accepted

Solution code:
def main() -> None:
    n = int(input())
    for i in range(n, 1000):
        a,b,c = map(str, str(i))
        if a==b and b==c:
            print("{}".format(i))
            break


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
while True:
    for i in range(len(str(n))-1):
        if not str(n)[i]==str(n)[i+1]:
            break
        if i==len(str(n))-2:
            print(n)
            import sys
            sys.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)

Submission status: Accepted

Solution code:
n = list(input())
a = int(str(n[0])+str(n[1]))
b = int(str(n[1])+str(n[2]))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
  input = sys.stdin.readline
  N = str(input().strip())
  L = len(N)
  f = N[0]
  a = f * L
  b = str(int(f) + 1) * L
  
  if int(a) >= int(N):
    print(int(a))
  else:
    print(int(b))


if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
zoro = []
for i in range(1, 4):
    for j in range(1, 10):
        string = str(j) * i
        zoro.append(string)
zoro.append("1111")
#   print(zoro)
candidate = [i for i in zoro if int(i) >= N]
print(candidate[0])

Submission status: Accepted

Solution code:
n=int(input())
for count in range(10):
    if 100*count+10*count+count>n-1:
        print(100*count+10*count+count)
        break
    else:
        pass

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
if  111 >= N:
    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')
elif 888 < N <= 999:
    print('999')

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:
n=int(input())
print(n) if n%111 == 0 else print(n+111-n%111)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())|	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

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

#### START
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

n = int(input())

for i in range(n, 1000):
    if str(i)[0] == str(i)[1] == str(i)[2]:
        print(i)
        sys.exit(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = list(input())
n_ = [int(x) for x in n]
num = max(n_)
if n_[0] < num:
  n = [n_[0] + 1 for x in n_]
else:
  n = [num for x in n_]

n = [str(x) for x in n]

print(int(''.join(n)))

Submission status: Accepted

Solution code:
n=int(input())

while 1:
    if n%111:
        n+=1
    else:
        print(n)
        break

Submission status: Accepted

Solution code:
a = input()

l = []
for i in range(len(a)):
    l.append(a[i])

if l.index(max(l)) == 0:
    for _ in range(len(l)):
        print(l[0],end='')
else:
    for _ in range(len(l)):
        print(int(l[0])+1,end='')

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
while True:
    if len(set(str(N)))==1:
        ans = N
        break
    else:
        N +=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
num_list = [111*i for i in range(1,10)]
nums = [num_list[i]-N for i in range(len(num_list)) if num_list[i]-N >= 0]
n = min(nums)
print(N+n)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(((N + 110) // 111) * 111)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
 
for i in range(N, 1000):
  string = list(str(i))
  flag = 0
  for s in string:
    if s != string[0]:
      flag = 1
  if flag == 0:
    answer = i
    break
 
print(answer)

Submission status: Accepted

Solution code:
s=int(input());l=[111*i for i in range(1,10) if 111*i>=s];print(l[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
data = [111*n for n in range(1, 10) if 111*n >= N]
print(data[0])

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
while True:
    n_str = sorted(str(N))
    if n_str[0] == n_str[-1]:
        break
    N += 1
print(N)

Submission status: Accepted

Solution code:
""" AtCoder """

import sys
input = sys.stdin.readline

N = int(input())

if N == 999:
    ans = "9"
else:
    ans = str(int((N-1)/111)+1)

print(ans+ans+ans)

Submission status: Accepted

Solution code:
N=str(input())
Comp=[]
for i in range(3):
    Comp.append(int(N[i]))
if Comp[0]-Comp[1]<0:
    A=Comp[0]+1
if Comp[0]-Comp[1]>0:
    A=Comp[0]
if Comp[0]-Comp[1]==0:
    if Comp[1]-Comp[2]<0:
        A=Comp[1]+1
    else:
        A=Comp[1]
for i in range(3):
    print(A,end='')

Submission status: Accepted

Solution code:
n = int(input())
A = [111, 222, 333, 444, 555, 666, 777, 888, 999]

for a in A:
    if n <= a:
        print(a)
        break

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N=input()
ans=0
if int(N)<=int(N[0]*len(N)):
    ans=N[0]*len(N)
elif N[0]=='9':
    ans='1'*(len(N)+1)
else:
    ans=str(int(N[0])+1)*len(N)
print(ans)

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:
def main():
    N = input()
    for i in range(10):
        n = int(str(i) * len(N))
        if n >= int(N):
            print(n)
            break


main()

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:
#!/usr/bin/env python3

def main():
    n = int(input())
    for i in range(100000):
        x = n + i
        se = set(list(str(x)))
        if len(se) == 1:
            print(x)
            return

main()

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:
# -*- coding: utf-8 -*-
n = int(input());

i = int(n/100)
next_n = 100*i + 10*i + i
if ( n <= next_n ):
    print(next_n)
else:
    print(next_n + 111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

contests = [111*i for i in range(1,10)]
for target in contests:
    if n <= target:
        print(target)
        break

Submission status: Accepted

Solution code:
def abc(lst:list)->str:
    if lst[0]<lst[1]or lst[0]==lst[1]<lst[2]:
        return (lst[0]+1)*111
    else:
        return lst[0]*111
lst=list(map(int,list(input())))
print(abc(lst))

Submission status: Accepted

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

for i in a:
    if i >= N:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B
def triple(n): return n*100 + n*10 + n

N = int(input())
n = triple(N//100)
#print(n)#
if n<N: n = triple(N//100+1)
print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

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

Submission status: Accepted

Solution code:
def notOk(x):
    s = x % 10
    x //= 10
    while x > 0:
        if(s != x % 10):
            return 1
        x //= 10
    return 0

n = int(input())
while(notOk(n)):
    n += 1
print(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
N0 = int(N[0])
N1 = int(N[1])
N2 = int(N[2])

if N0 > N1 or (N0 == N1 and N2 <= N0):
    answer = str(N0)*3
    print(answer)
else:
    N0 = N0 + 1
    answer = str(N0)*3
    print(answer)