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

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

for i in lst:
    if n <= i:
        print(i)
        break

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    contests = []
    for i in range(1, 10):
        contests.append(100 * i + 10 * i + 1 * i)

    for c in contests:
        if c >= n:
            print(c)
            break


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

for rep in repdigit:
    if N <= rep:
        print(rep)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L=[111,222,333,444,555,666,777,888,999]
N=int(input())
M=[L[i]-N for i in range(len(L))]
O=[M[j] for j in range (len(M)) if M[j]>=0]
a=O[0]
num=M.index(a)
print(L[num])

Submission status: Accepted

Solution code:
X = int(input())
print((X + 110) // 111 * 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())
zorome = [0,111,222,333,444,555,666,777,888,999]
diff = [0]*10
for i in range(len(zorome)):
    if zorome[i] == N:
        print(zorome[i])
        break
    elif zorome[i] > N:
        print(zorome[i])
        break

Submission status: Accepted

Solution code:
N = int(input())
A = [999, 888, 777, 666, 555, 444, 333, 222, 111]
print(list(filter(lambda x: x >= N, A))[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N,1000):
    a = i//100
    b = (i - a*100)//10
    c = (i - a*100 - b*10)
    if a == b == c:
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(N, 1000):
    n = i % 10
    nn = (i % 100) // 10
    nnn = (i % 1000) // 100
    if n == nn and nn == nnn:
        print(i)
        break

Submission status: Accepted

Solution code:
N=input()

if N%100<=N/100*11:
    print (N/100)*111
else:
    print (N/100+1)*111

Submission status: Accepted

Solution code:
def piyo():
    n = int(input())
    hoge = n//100
    if int(str(hoge)+str(hoge))>=n%100:
        a = int(str(hoge)+str(hoge)+str(hoge))
    else:
        hoge+=1
        a = int(str(hoge)+str(hoge)+str(hoge))
    print(a)

if __name__ == '__main__':
    piyo()

Submission status: Accepted

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


def main():
    """Function."""
    n = int(input())

    nums = []
    for i in range(1, 10):
        nums.append(int(str(i)*3))

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

x = 1000

for i in range(x):
    if (N+i)//100 == ((N+i)%100)//10 == (N+i)%10:
        print(N+i)
        break

Submission status: Accepted

Solution code:
N = int(input())
i = 1
while i < 10:
    if 100 * i + 10 * i + i >= N:
        print(100 * i + 10 * i + i)
        break
    i += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

A = N/111
B = N%111

if B == 0:
    C = int(A)
    print(int(100*A+10*A+A))
else:
    C = int(A + 1)
    print(int(100*C+10*C+C))

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
MAX = 1000
for i in range(N, MAX):
    digit = str(i // 100)
    if all(x == digit for x in str(i)):
        print(i)
        break

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)
elif 888<N<=999:
	print(999)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
for i in range(10):
    if int(N[0]) == i:
        if int(N[1]) > i:
            ans = str(i+1)
        if int(N[1]) == i:
            if int(N[2]) > i:
                ans = str(i+1)
            else:
                ans = str(i)
        if int(N[1]) < i:
            ans = str(i)
print(int(ans+ans+ans))

Submission status: Accepted

Solution code:
a = int(input())
while True:
  b = str(a)
  if b[0] == b[1] == b[2]:
    print(b)
    exit()
  else:
    a += 1

Submission status: Accepted

Solution code:
a = int(input())

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

Submission status: Accepted

Solution code:
n = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
b = list(a)
k = int(''.join([b[0] for _ in range(len(b))]))
if k >= int(a):
    print(k)
else:
    if b[0] != '9':
        print(int(''.join([str(int(b[0]) + 1) for _ in range(len(b))])))
    else:
        print(int(''.join(['1' for _ in range(len(b)+1)])))

Submission status: Accepted

Solution code:
n=int(input())

if n%111==0:
  ans=n
else:
  while n%111>0:
    n+=1
    ans=n
    
print(ans)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import sys
import math
import fractions
def j(a):
    if a==1: print("Yes")
    else :print("No")


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              #入力整数1つ
#x,y = (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#a,b,c,k = (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
a =0
while a < x:
    a+=111
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
n = len(s)
ss = int(s)
i = ss//(10**(n-1))
def cal(k):
    res = int(k)*(10**(n-1))+ int(k)*(10**(n-2))+int(k)*(n-2)
    return res

if cal(i)<ss:
    print(cal(i+1))
else:
    print(cal(i))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

while(True):
    if n <= a:
        print(a)
        break
    else:
        a += 111

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(9):
    if(N>L[i] and N<=L[i+1]):
        print(L[i+1])
        break
    elif(N==L[i]):
        print(L[i])
        break
    elif(N<111):
        print(111)
        break
    else:
        continue

Submission status: Accepted

Solution code:
num = str(input())
a = []
x=[]
for i in str(num):
    a.append(i)
if a[1] <= a[0] and a[2] < a[0]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print(''.join(str(i) for i in x))
elif a[1] < a[0]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print(''.join(str(i) for i in x))
elif a[0] == a[1] == a[2]:
    x.append(a[0])
    x.append(a[0])
    x.append(a[0])
    print(''.join(str(i) for i in x))
else:
    z = int (a[0]) +1
    x.append(z)
    x.append(z)
    x.append(z)
    print(''.join(str(i) for i in x))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
 
for n in [111*c for c in range(1,10)]:
    if n < N:
        continue
    else:
        print(n)
        break

Submission status: Accepted

Solution code:
N = int(input())
 
x = 0
for n in [111*c for c in range(1,10)]:
    if n < N:
        continue
    else:
        x = n
        break
print(x)

Submission status: Accepted

Solution code:
N = int(input())
 
list = [111*c for c in range(1,10)]
list.sort()
 
x = 0
for n in list:
    if n < N:
        continue
    else:
        x = n
        break
print(x)

Submission status: Accepted

Solution code:
N = str(input())

list = [111*int(c) for c in '123456789']
list.sort()

x = 0
for number in list:
    if number < int(N):
        continue
    else:
        x = number
        break
print(x)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
lst=[0,0,0]
while n!=0:
    lst[cnt]=n%10
    n=n//10
    cnt+=1
if lst[2]>lst[1]:
    for i in range(cnt):
        print(lst[2],end="")
elif  lst[2]==lst[1]:
    if lst[1]>=lst[0]:
        for i in range(cnt):
            print(lst[2], end="")
    else:
        for i in range(cnt):
            print(lst[2]+1, end="")
else:
    for i in range(cnt):
        print(lst[2]+1,end="")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
while N % 111 != 0:
  N = N+1
else:
  print(N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())



# def numtost(n):
    
def ok(num):
    nmst = "{0:d}".format(num)
    # print(nmst)
    if len(nmst) == len(list(filter(lambda x:x==nmst[0], nmst[:]))):
        return True
    else:
        # p = len(nmst)
        # q = len(list(filter(lambda x:x==nmst[0], nmst[1:])))
        # print(p,q,p==q)
        # print("len nmst: ", len(nmst))
        # print("filter : ", list(filter(lambda x: x==nmst[0], nmst)))
        # print("len filter : ", len(list(filter(lambda x: x==nmst[0], nmst))))
        # print(" equal : ", len(nmst) == len(list(filter(lambda x:x==nmst[0], nmst[1:]))))
        return False

for i in range(N, int(1e9)):
    if ok(i):
        print(i)
        exit(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

N=int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
i = n
while True:
    if str(i).count(str(i)[0])==len(str(i)):
        break
    else:
        i += 1
print(i)

Submission status: Accepted

Solution code:
s = input()
top = s[0]
ng = False
for i in s:
    if top != i:
        ng = True
        break

if not (ng):
    print(s)
else:
    if int(top * len(s)) < int(s):
        print(str(int(top) + 1) * len(s))
    else:
        print(int(top * len(s)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=str(input())
k=True
kaku=n[0]
for i in n:
    if int(n[0])!=int(i):
        k=False
if k:
    print(n)
else:
    if int(n[0])>=int(n[1]) and int(n[0])>=int(n[2]):
        print(n[0]*3)
    else:
        s=int(n[0])+1
        print(str(s)*3)

Submission status: Accepted

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

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())
length=len(str(n))

if int(str(n)[0])>= int(str(n)[-1]) and int(str(n)[0])>= int(str(n)[1]):
  print((str(n)[0])*length)
else:
  print(str((int(str(n)[0]))+1)*length)

Submission status: Accepted

Solution code:
n = input()

t = int(n[0])
th = t*100+t*10+t

if th >= int(n) :
    print(th)
else :
    t = t+1
    th = t*100+t*10+t
    print(th)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for n in range(N,1000):
    str_n = str(n)
    first_keta = str_n[0]
    for keta in str_n:
        if keta == first_keta:
            continue
        break

    else:
        print(first_keta * 3)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
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 = 0
for i in range(10):
    if n <= 111*i:
        ans = 111*i
        break
        
print(ans)

Submission status: Accepted

Solution code:
n = input()

a = n[0]
if int(n) <= int(a + a + a):
    print(int(a + a + a))
else:
    b = str(int(a) + 1)
    print(int(b + b + b))

Submission status: Accepted

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


print(abc111_b())

Submission status: Accepted

Solution code:
# N回の取得
N = int(input())
# 数列に変換
num = list(map(int, str(N)))
# 計算処理
if num[0] >= num[1] and num[0] >= num[2]:
    print(num[0] * 111)
else:
    print((num[0] + 1) * 111)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1]  # s = s_in()


N = list(s_in())
if N[0] == N[1] and N[1] == N[2]:
    print(''.join(N))
else:
    if int(N[0]) > int(N[1]):
        x = int(N[0])
    elif int(N[0]) < int(N[1]):
        x = int(N[0]) + 1
    elif int(N[1]) >= int(N[2]):
        x = int(N[0])
    else:
        x = int(N[0]) + 1
    print(x * 111)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
if int(s) > int(s[0] + s[0] + s[0]):
    if s[0] == '9':
        print(1111)
    else:
        print(str(int(s[0])+1) + str(int(s[0])+1) + str(int(s[0])+1))
else:
    print(s[0] + s[0] + s[0])

Submission status: Accepted

Solution code:
def solution(s):
    n = len(s)
    k = s[0]
    for i in xrange(1, n):
        if s[i] > k:
            return chr(ord(k) + 1) * n
    return k * n

def main():
    d = int(raw_input().strip())
    print solution(str(d))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
h=n//100
t=(n%100)//10
o=n%10

while True:
 if h * 111 >= n:
     print(h * 111)
     break
 h+=1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

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)
        exit()

Submission status: Accepted

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

    while True:
        hund = n // 100
        ten = (n % 100) // 10
        one = n % 10
        if hund == ten and hund == one:
            print(n)
            break
        else:
            n += 1

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
l=len(n)
s1=str(n[0]*l)
s2=""
if n[0]=='9':
    s2="1"*(l+1)
else:
    s2=str(int(n[0])+1)*l

if n<=s1:
    print(s1)
else:
    print(s2)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

for x in abc:
    if n <= x:
        print(x)
        break

Submission status: Accepted

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

import math


def solve():
    i = int(input())
    print(math.ceil(i / 111) * 111)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = str(input())

while True:
    if x[0] == x[1] == x[2]:
        print(x)
        break

    x = str(int(x) + 1)

Submission status: Accepted

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

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())
 
n = N // 100
 
if( N % 100 <= n * 10 + n):
	print(n * 100 + n * 10 + n )
  
else:
  	print( (n + 1)* 100 + (n + 1)* 10 + (n + 1))

Submission status: Accepted

Solution code:
N = int(input())

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

for temp in candidate:
    if temp >= N:
        print(temp)
        break

Submission status: Accepted

Solution code:
s=(int)(input())
n = str(s//100)
if s >(int)(n*3):
    print(str((int)(n)+1)*3)
else:
    print(str(n*3))

Submission status: Accepted

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

Submission status: Accepted

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

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:
print((((int(input()) - 1) // 111) + 1) * 111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

out_str = ""
for i in range(10) :
	if (111 * i < N and N <= 111 * (i + 1)):
		out_str = str(111*(i+1))

print(out_str)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
if n[0] == n[1] == n[2]:
    print(int(n))
elif n[0] == n[1] and n[0] > n[2]:
    print(int(n[0]+n[1]+n[1]))
elif n[0] > n[1]:
    print(int(n[0]+n[0]+n[0]))
else:
    m = int(n[0])+1
    print(100*m+10*m+m)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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 S(): return input()
def pf(s): return print(s, flush=True)


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

    return -1


print(main())

Submission status: Accepted

Solution code:
N = int(input())
if N % 111 != 0:
  N = 111 - (N % 111) + N
print(N)

Submission status: Accepted

Solution code:
a = input()
b = list(a)
c = b[0] + b[0] + b[0]

if int(a) > int(c):
  print(int(c)+111)
else:
  print(int(c))

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:
Nstr = input()
N = int(Nstr)

ini = int(Nstr[0])

if ( ini*100+ini*10+ini<N ):
  ini+=1
  
print(ini*100+ini*10+ini)

Submission status: Accepted

Solution code:
N = int(input())
ans = ''
for i in range(N, 1000):
    if not(ans):
        for ch in str(i):
            if str(i).replace(ch, '') == '':
                ans = str(i)
                break
    else: break

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b

def main():
    N = int(input())
    for i in range(N, 10000):
        if len(set(str(i))) == 1:
            print(i)
            return 


if __name__ == '__main__':
    main()

Submission status: Accepted

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

result = 999
for i in range(len(t)):
    if n <= t[i]:
        result = t[i]
        break

print(result)

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 = input()
for ans in range(111, 1000, 111):
    if int(n) <= ans:
        break
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
num=int(input())
# nums=[int(i) for i in input().split()]
# str = input()
print((int((num-1)/111)+1)*111)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

for num in nums:
    if num >= n:
        print(num)
        break

Submission status: Accepted

Solution code:
import sys


def main():
    n = int(input())
    ans = (n + 110) // 111 * 111
    print(ans)


main()

Submission status: Accepted

Solution code:
N = int(input().strip())
for n in (111, 222, 333, 444, 555, 666, 777, 888, 999):
  if n >= N:
    print(n)
    break

Submission status: Accepted

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

制約
	100 ≤ N ≤ 999
	N  は整数

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

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

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

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

入力例 3 
	750
出力例 3 
	777

'''

def main():
	'''
	メイン関数
	'''
	
	# 次の回次を取得
	next = input()
	h = next[0] # 百の位
	d = next[1] # 十の位
	o = next[2] # 一の位
	
	# 百の位のぞろ目数
	zoro = int(h)*100 + int(h)*10 + int(h)

	# 次がぞろ目か判定
	if (h==d) and (d==o) :
		print(next)
	# ぞろ目でない場合　hdo < hhh ならば、hhh が次のぞろ目
	elif int(next) < zoro :
		print(zoro)
	else :
	# それ以外は、(h+1)(h+1)(h+1)
		print(zoro+111)


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
x=input()
#print(x)
#print(x[0])
if x[0]==x[1]==x[2]:
	print(int(x))
elif x[1]<=x[0] and x[2]<=x[0]:
	print(int(x[0]+x[0]+x[0]))
else:
	print(int(str(int(x[0])+1)+str(int(x[0])+1)+str(int(x[0])+1)))

Submission status: Accepted

Solution code:
N=int(input())
kurai=N//100
zorome=kurai*111
if(N-zorome>0):
    print(zorome+111)
else:
    print(zorome)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(n,n+111):
    x=str(i)
    m=i
    if x[0]==x[1]==x[2]:
        break
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
str_input = input()
num_list = list(str_input)
next_stage = 0

num1 = int(num_list[0])
num2 = int(num_list[1])
num3 = int(num_list[2])

def change_nums( num ):
    return num*100+num*10+num


if num1 > num2:
    next_stage = change_nums( num1 )
elif num1==num2==num3:
    next_stage = change_nums( num1 )
elif num1==num2 and num1 > num3:
    next_stage = change_nums( num1 )
else:
    next_stage = change_nums( num1+1 )

print(next_stage)

Submission status: Accepted

Solution code:
st=raw_input()
s=list(st)
if int(s[2])>int(s[1]):
  s[1]=str(int(s[1])+1)
  s[2]=s[1]
else:
  s[2]=s[1]
if int(s[1])>int(s[0]):
  s[0]=str(int(s[0])+1)
  s[1]=s[0]
  s[2]=s[1]
else:
  s[1]=s[0]
  s[2]=s[1]
unko=""
for i in s:
  unko+=i
print(unko)

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

Submission status: Accepted

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