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

if N[0] == "1":
    if int(N) <= 111:
        print(111)
    else:
        print(222)
elif N[0] == "2":
    if int(N) <= 222:
        print(222)
    else:
        print(333)
elif N[0] == "3":
    if int(N) <= 333:
        print(333)
    else:
        print(444)
elif N[0] == "4":
    if int(N) <= 444:
        print(444)
    else:
        print(555)
elif N[0] == "5":
    if int(N) <= 555:
        print(555)
    else:
        print(666)
elif N[0] == "6":
    if int(N) <= 666:
        print(666)
    else:
        print(777)
elif N[0] == "7":
    if int(N) <= 777:
        print(777)
    else:
        print(888)
elif N[0] == "8":
    if int(N) <= 888:
        print(888)
    else:
        print(999)
else:
    print(999)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def is_all_same(S):
    pre_s = S[0]
    for s in (S):
        if s != pre_s:
            return False
    return True

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])

    while 1:
        if is_all_same(str(N)):
            print N
            exit()
        N += 1

if __name__ == '__main__':
    main()

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:
N = int(input())
num = []
while N != 0:
  num.append(N%10)
  N -= N%10
  N /= 10
a=num[2]
b=num[1]
c=num[0]
if a==b>=c:
  print(int(100*a+11*b))
if a==b<c or a<b:
  print(int((a+1)*111))
if a>b:
  print(int(a*111))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
length = len(n)
x = n[0]

# 10のくらいがｘ未満の場合はｘのゾロ目でよい
if n[1] < x:
    x = x*length
# 10の位がxより大きい場合はx+1のゾロ目
elif n[1] > x:
    x = str(int(x) + 1)*length
# 10の位がxと同じ場合は1の位を調べる
else:
    # 1に位がx未満ならばのゾロ目
    if n[2] < x:
        x = x *length
    # 1の位がxより大きい場合はx+1のゾロ目
    elif n[2] > x:
        x = str(int(x)+1)*length

    else:
        x = x * length
# 999の場合は別処理
if int(n) == 999:
    x = '999'

print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(input())

i = n
while(True):
    if len(set(list(str(i)))) == 1:
        print(i)
        sys.exit(0)
    i += 1

Submission status: Accepted

Solution code:
N = raw_input()

s = N[0] if max(map(int, N)) == int(N[0]) else int(N[0]) + 1
print str(s) * 3

Submission status: Accepted

Solution code:
n = input()

if int(n[0]) <= int(n[1]):
    if int(n[0]) == int(n[1]) and int(n[0]) >= int(n[2]):
        temp=int(n[0])
        print(temp*100+temp*10+temp)
    else:
        temp=int(n[0])+1
        print(temp*100+temp*10+temp)
else:
    temp=int(n[0])
    print(temp*100+temp*10+temp)

Submission status: Accepted

Solution code:
N = input()
if len(set(N)) == 1:
    ans = N
else:
    ans = str(int(N[0]))*3

if int(ans) < int(N):
    ans = str(int(ans)+111)
    
print(ans)

Submission status: Accepted

Solution code:
num = int(input())
list_1 = [999, 888, 777, 666, 555, 444, 333, 222, 111]
num_list = []
for l in list_1:
    if l >= num:
        num_list.append(l)
print(min(num_list))

Submission status: Accepted

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

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:
        ans = i
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
a = list(n)
if a[0] == a[1] ==a[2]:
    print(n)
else:
    if int(a[0])> int(a[1]):
        a[1] = a[0]
        a[2] = a[0]  
        for i in range(3):
            print(a[i] ,end="")

    elif a[0]==a[1] and int(a[0]) <int(a[2]):
         a[0] = str(int(a[0]) +1)
         a[1] =a[0]
         a[2] = a[0]

         for i in range(3):
            print(a[i] ,end="")
    elif a[0]==a[1] and int(a[0]) >int(a[2]):
         a[2] = a[0]
         for j in range(3):  
            print(a[j] ,end="")         


    else:
        a[0] = str(int(a[0]) +1)
        a[1] =a[0]
        a[2] = a[0]

        for j in range(3):  
            print(a[j] ,end="")

Submission status: Accepted

Solution code:
A = list(input())
x = int(A[0])
y = int(A[1])
z = int(A[2])

ans = ''
a = 0
if x > y:
    a = str(x)
    ans = a + a + a
elif x == y:
    if y >= z:
        a = str(x)
        ans = a + a + a
    else:
        a = str(x + 1)
        ans = a + a + a
else:
    a = str(x + 1)
    ans = a + a + a

print(ans)

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:
n = int(input())
for t in range(1,10):
    if n <= t*100 + t*10 + t:
        res = t*100 + t*10 + t
        break 

print(res)

Submission status: Accepted

Solution code:
#coding:utf-8
import math
n = int(input())
print (math.ceil(n/111)*111)

Submission status: Accepted

Solution code:
b = str(input())
num = list(b)
appear = b.count(num[0])
if appear == 3:
    print(b)
elif num[0]>num[1]:
    c = num[0]
    d=str(c)
    print(d*3)
elif num[0] == num[1]:
    if num[1]<num[2]:
        c = int(num[0])+1
        d=str(c)
        print(d*3)
    else:
        c = num[1]
        d=str(c)
        print(d*3)
else:
    c = int(num[0])+1
    d=str(c)
    print(d*3)

Submission status: Accepted

Solution code:
n = input()
ans = int(n[0]) * 111
if ans < int(n):
    ans += 111
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 math
a = int(input())

b = math.ceil(a/111)

print(b*111)

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:
n = list(input())

ans = ''

if n[0] > n[1]:
    for i in range(3):
        ans += n[0]
elif n[0] == n[1] and n[0] >= n[2]:
     for i in range(3):
        ans += n[0]
else:
    n[0] = int(n[0]) + 1
    for i in range(3):
        ans += '{}'.format(n[0])
        

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
res = ''

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

print(res)

Submission status: Accepted

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

h, t, o = N[0], N[1], N[2]

if int(h) < int(t):
  print(str(int(h) + 1) * 3)
elif int(h) > int(t):
  print(h * 3)
else:
  if int(t) < int(o):
    print(str(int(h) + 1) * 3)
  elif int(t) >= int(o):
    print(h * 3)

Submission status: Accepted

Solution code:
# coding: utf-8
n=int(input())
a=0
while(a<n):
  a+=111
print(a)

Submission status: Accepted

Solution code:
number = int(input())

while number % 111 != 0:
  number += 1
  
print(number)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = input()
num = int(n)
ans = 0
for digit in range(1,10):
    if num/digit == float(111):
        ans = num
        break
    elif num/digit < float(111):
        ans = digit*100+digit*10+digit
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
if len(set(str(n)))==1:
    print(n)
else:

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8

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

for i in range(len(zorome)-1):
    if n == zorome[i]:
        print(zorome[i])
        break
    elif (n > zorome[i]) & (n<=zorome[i+1]):
        print(zorome[i+1])
        break
    else:
        pass

Submission status: Accepted

Solution code:

import sys
    
n = input()
num = list(n)
n100 = num[0]
n10 = num[1]
n1 = num[2]
if (num[0] == num[1]) and (num[0] == num[2]):
    print(n)
    sys.exit()

if int(n) < int(n100)*100 + int(n100)*10 + int(n100):
    print(int(n100)*100 + int(n100)*10 + int(n100))

if int(n) > int(n100)*100 + int(n100)*10 + int(n100):
    print((int(n100)+1)*100 + (int(n100)+1)*10 + (int(n100)+1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()

a = n[0]
comp = ""

for i in range(len(n)):
    comp += a

if int(n) == int(comp):
    print(n)
elif int(n) < int(comp):
    print(comp)
else:
    b = str(int(a) + 1)
    ans = ""
    for i in range(len(n)):
        ans += b
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

def decideContest(inNum, inList):
    for num in zoromeList:
        if inNum <= num:
            print(num)
            return

decideContest(n, zoromeList)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

for i in range(9,-1,-1):
    if n > 111*i :
        print(111*(i+1))
        break

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())

k = 111
while k < 999:
    if a > k:
        k += 111
    if a == k:
        print(a)
        break
    if a < k:
        a = k
        print(a)
        break

Submission status: Accepted

Solution code:
n = input()

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

Submission status: Accepted

Solution code:
N = int(input())
print(min([x for x in [int(str(i) * 3) - N for i in range(1, 10)] if x >= 0]) + N)

Submission status: Accepted

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

zoros = [int(str(i)*3) for i in range(1,10)]
#print(zoros)

def minzoro(x):
    return min(filter(lambda i: i >= x, zoros))

print(minzoro(n))

Submission status: Accepted

Solution code:
N = int(input())
l = [100*i+10*i+i for i in range(1,10)]
l.append(N),l.sort()
if l.count(N) == 2:
  print(N)
else:
  print(l[l.index(N) + 1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
ct = 111
while True:
    if ct >= num:
        break
    ct += 111
print(ct)

Submission status: Accepted

Solution code:
import numpy as np

x = input()
x = str(x)
y = 0
z = len(x)
for i in range(1, z):
  if int(x[0]) < int(x[i]):
    y = 1
if y == 0:
  w = int(x[0])
else:
  w = int(x[0]) + 1
y = 0
for i in range(z):
  y = y + int(w) * (10 ** (z - i - 1))
print(y)

Submission status: Accepted

Solution code:
N = int(input())

tmp = N // 100
result = tmp * 100 + tmp * 10 + tmp
if result < N:
    tmp = tmp + 1
result = tmp * 100 + tmp * 10 + tmp

print(result)

Submission status: Accepted

Solution code:
n = int(input()) 

num =int(n/100)


x = num* 111
if n <= x:
    print(x)
else:
    print(x+111)

Submission status: Accepted

Solution code:
n = int(input())

if n <= 111:
    ans = 111
elif n <= 222:
    ans = 222
elif n <= 333:
    ans = 333
elif n <= 444:
    ans = 444
elif n <= 555:
    ans = 555
elif n <= 666:
    ans = 666
elif n <= 777:
    ans = 777
elif n <= 888:
    ans = 888
elif n <= 999:
    ans = 999

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
x = 111
for i in range(1,10):
    a = 111 *i
    if N <= a:
        x = a
        print (x)
        break

Submission status: Accepted

Solution code:
n = int(input())
k = 1
N = 100*k + 10*k + 1*k
while n > N:
    k += 1
    N = 100 * k + 10 * k + 1 * k
print(N)

Submission status: Accepted

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

if N[0] > N[1]:
    l = [N[0]] * 3
    print(''.join([str(i) for i in l]))
elif N[0] == N[1] >= N[2]:
    l = [N[0]] * 3
    print(''.join([str(i) for i in l]))
elif N[0] == N[1] < N[2]:
    l = [N[0]+1] * 3
    print(''.join([str(i) for i in l]))
elif N[0] < N[1]:
    l = [N[0]+1] * 3
    print(''.join([str(i) for i in l]))

Submission status: Accepted

Solution code:
N = int(input())

for n in [111, 222, 333, 444, 555, 666, 777, 888, 999]:
    if N <= n:
        print(str(n))
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

for i in range(1, 10, 1):
    str_i = str(i)
    str_x = "{}{}{}".format(str_i, str_i, str_i)
    x = int(str_x)
    if x >= N:
        break
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
kotae = 0

if n <= 9:
    kotae = n
elif n <= 99:
    while n % 11 != 0:
        n = n + 1
    kotae = n
else:
    while n % 111 != 0:
        n = n + 1
    kotae = n

print(kotae)

Submission status: Accepted

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

for i in range(10):
 if a <= check:
  print(check)
  exit()
 check += 111

Submission status: Accepted

Solution code:
c = int(input())
check = []
for i in range(1,10):
    check.append(str(i)*3)

for i in range(9):
    if c<=int(check[i]):
        print(check[i])
        exit()

Submission status: Accepted

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

for i in range(n[0],10):
    if(n[0]==i):
        for i2 in range(n[1],10):
            for i3 in range(n[2],10):
                if(i==i2==i3):
                    print(i*100+i2*10+i3)
                    exit(0)
    else:
        for i2 in range(1,10):
            for i3 in range(1,10):
                if(i==i2==i3):
                    print(i*100+i2*10+i3)
                    exit(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()
n = list(N)
str = n[0] + n[0] + n[0]
num = int(str)
big = int(n[0]) + 1
big_num = 100 * big + 10 * big + big
number = int(N)
if number <= num:
  print(num)
else:
  print(big_num)

Submission status: Accepted

Solution code:
N = int(input())

for i in range(9):
	if N <= (i+1)*111:
		print((i+1)*111)
		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())
if 100 <= n <= 111:
    print(111)
if 112 <= n <= 222:
    print(222)
if 223 <= n <= 333:
    print(333)
if 334 <= n <= 444:
    print(444)
if 445 <= n <= 555:
    print(555)
if 556 <= n <= 666:
    print(666)
if 667 <= n <= 777:
    print(777)
if 778 <= n <= 888:
    print(888)
if 889 <= n <= 999:
    print(999)

Submission status: Accepted

Solution code:
N = list(input())
if len(set(N)) == 1:
    print(''.join(N))
else:
    b = int(N[0])*100+int(N[0])*10+int(N[0])
    real_n = int(N[0])*100+int(N[1])*10+int(N[2])
    
    if real_n < b:
        print(b)
    else:
        print(str(int(N[0])+1)*3)

Submission status: Accepted

Solution code:
n = input()

if len(set(n)) == 1:
    print(n)
else:
    l = [111,222,333,444,555,666,777,888,999]
    l.append(int(n))
    l.sort()
    print(l[l.index(int(n))+1])

Submission status: Accepted

Solution code:
def main():
    N = [x for x in input()]
    if len(set(N)) == 1:
        print("".join(N))
    else:
        print(nex(N))


def nex(n):
    result = int(n[0] * 3)
    if int("".join(n)) > result:
        result = int(str(int(n[0]) + 1) * 3)
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = input()
if n[0]==n[1]==n[2]:
    print(n)
elif n[0]>n[1]:
    print(n[0]+n[0]+n[0])
elif n[0]<n[1]:
    t = str(int(n[0])+1)
    print(t+t+t)
elif n[0]==n[1]>n[2]:
    print(n[0]+n[0]+n[0])
elif n[0]==n[1]<n[2]:
    t = str(int(n[0])+1)
    print(t+t+t)

Submission status: Accepted

Solution code:
n=int(input())
while True:
  flag=0
  a=n
  while a!=0:
    now=a%10
    if flag==0:
      pre=now
      flag=1
    if now!=pre:
      flag=2
      break
    pre=now
    a=a//10
  if flag==1:
    print(n)
    break
  n+=1

Submission status: Accepted

Solution code:
now = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(str(n))
m = int(a[0])*100 + int(a[0])*10 + int(a[0]) 
o = (int(a[0])+1)*100 + (int(a[0])+1)*10 + (int(a[0])+1)
if m < n: 
 print(o)
else:
 print(m)

Submission status: Accepted

Solution code:
#coding:utf-8

N = int(input())

ans = 0

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

Submission status: Accepted

Solution code:
n = int(input())


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

Submission status: Accepted

Solution code:
from sys import stdin


def fun(n, l):
    a = 0
    for i in range(l):
        a += n * (10**i)

    return a


N = stdin.readline().rstrip()

if int(N[0]) < 9:
    a = fun(int(N[0]), len(N))
    if (a >= int(N)):
        print(a)
    else:
        a = fun(int(N[0]) + 1, len(N))
        print(a)
else:
    a = fun(9, len(N))
    if (a >= int(N[0])):
        print(a)
    else:
        a = fun(1, len(N) + 1)
        print(a)

Submission status: Accepted

Solution code:
N = int(input())
s = int((N - 1) / 111)

x = (s + 1) * 111
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

def is_zorome(Nstr):
    init = Nstr[0]
    for n in Nstr[1:]:
        if n != init:
            return False
    return True

def find_min_zorome(Nstr):
    init = Nstr[0]
    candidate = ""
    for _ in range(len(Nstr)):
        candidate += init

    if int(Nstr) < int(candidate):
        return candidate
    else:
        candidate = ""
        if init == "9":
            for _ in range(len(Nstr)+1):
                candidate += "1"
        else:
            for _ in range(len(Nstr)):
                candidate += str(int(init)+1)
        return candidate

if is_zorome(N):
    print(N)
else:
    print(find_min_zorome(N))

Submission status: Accepted

Solution code:
n=int(input())

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

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

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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

input = raw_input()

while True:
    if input[0] == input[1] and input[1] == input[2]:
        print int(input)
        break
    else:
        input = int(input) + 1
        input = str(input)

Submission status: Accepted

Solution code:
a = int(input())
if 100 <= a <= 111:
    print(111)
elif 112 <= a <= 222:
    print(222)
elif 223 <= a <= 333:
    print(333)
elif 334 <= a <= 444:
    print(444)
elif 443 <= a <= 555:
    print(555)
elif 556 <= a <= 666:
    print(666)
elif 667 <= a <= 777:
    print(777)
elif 778 <= a <= 888:
    print(888)
else:
    print(999)

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:
    v = n1
else:
    v = n1 + 1
print(str(v)+str(v)+str(v))

Submission status: Accepted

Solution code:
N = int(input())

if N <100:
    m = N//10
    k = m+m*10
    if N <= k:
        print(k)
    else:
        k = m+1 + (m+1)*10
        print(k)
else:
    m = N//100
    k = m+m*10+m*100
    if N <= k:
        print(k)
    else:
        k=m+1 +(m+1)*10+ (m+1)*100
        print(k)

Submission status: Accepted

Solution code:
s = input()

l = len(s)

m = s[0]

def check(s, t):
    for i, j in zip(s, t):
        if i != j:
            return i > j

    return 1


if (check(m*l, s)):
    print(m*l)
else:
    print(chr(ord(m)+1)*l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
if n[0] == n[1] and n[1] == n[2] and n[2] == n[0]:
    print(n)
else:
    n1 = int(n)
    n_tmp = int(n[0])
    n2 = n_tmp*100 + n_tmp*10 + n_tmp
    n3 = (n_tmp+1)*100 + (n_tmp+1)*10 + n_tmp+1
    if n2 >= n1:
        print(n2)
    else:
        print(n3)

Submission status: Accepted

Solution code:
import sys 

n = int(input())
ans = 111
if n <= 111:
  print(ans)
elif n <= 222:
  print(ans*2)
elif n <= 333:
  print(ans*3)
elif n <= 444:
  print(ans*4)
elif n <= 555:
  print(ans*5)
elif n <= 666:
  print(ans*6)
elif n <= 777:
  print(ans*7)
elif n <= 888:
  print(ans*8)
elif n <= 999:
  print(ans*9)

Submission status: Accepted

Solution code:
n = int(input())

nn = n // 111
mod = n % 111
if mod > 0:
  nn = nn + 1
print(111 * nn)

Submission status: Accepted

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

if max(a, b, c) == a:
    ans = 100*a + 10*a + a
elif max(a, b, c) == b:
    a_ = a + 1
    ans = 100*a_ + 10*a_ + a_
else:
    if a > b:
        ans = 111 * a
    elif a == b:
        a_ = a + 1
        ans = 111 * a_
    else:
        a_ = a + 1
        ans = 100*a_ + 10*a_ + a_

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
result = n
for x in range(n, 1000):
	k = []
	for _ in range(3):
		k.append(x%10)
		x//=10
	if k[0]==k[1]==k[2]:
		result = k
		break
result = "".join(str(x) for x in result)
print(result)

Submission status: Accepted

Solution code:
a = int(input())

while True:
    b = a % 10
    d = a //100
    c = (a-d*100)//10
    if d == c == b:
        break
    a += 1
print(a)

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = input()
big = max([int(x) for x in N[1:]])
if big > int(N[0]):
    ans = str(int(N[0])+1) * len(N)

else:
    ans = N[0] * len(N)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

k = n // 100
if n - k * 100 <= k * 10 + k:
    ans = k * 100 + k * 10 + k
else:
    ans = (k+1) * 100 + (k+1) * 10 + (k+1)

print(ans)

Submission status: Accepted

Solution code:
s = raw_input()

num = int(s)

keta = num//100

if num <= keta*111:
    print keta * 111
elif num > keta*111:
    print (keta+1)*111

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# vim: set fileencoding=utf-8:


def main():
    N = raw_input()
    a = N[0] + N[0] + N[0]

    if N == a:
        print(N)
    elif int(N) > int(a):
        b = str(int(N[0]) + 1)
        b = b + b + b
        print(b)
    else:
        print(a)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

n = input()

if n[0] == '9':
	m = ''.join(['9']*len(n))
	if int(n) > int(m):
		print(''.join(['1']*(len(n)+1)))
		sys.exit()
	else:
		print(m)
		sys.exit()
else:
	s = n[0]
	m = ''.join([s]*len(n))
	if int(n) > int(m):
		print(''.join([str(int(s)+1)]*len(n)))
		sys.exit()
	else:
		print(m)
		sys.exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
 
ans=0

while(True):
  ans+=111
  if(ans>=N):
    print(ans)
    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())
while True:
    n=str(N)
    if len(set(n))==1:
        break
    N+=1
print(N)

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())
# A = list(map(int, input().split()))
l = [111,222,333,444,555,666,777,888,999]

for i in l:
	if N <= i:
		print(i)
		break

Submission status: Accepted

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

n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

while(True):
    tho = N//1000
    hun = (N%1000)//100
    ten = (N%100)//10
    one = N%10
    if tho ==0:
        if hun ==ten and ten ==one:
            break
        else:
            N += 1
    else:
        if tho==hun and hun==ten and ten==one:
            break
        else:
            N += 1

print(N)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 111 20180929
# Question:B
 
def main(nums):
	
	ref = nums[0]*len(nums)
	
	if int(ref) >= int(nums):
		return int(ref)
	else:
		ref2 = '1'*len(nums)
		
		return int(ref)+int(ref2)
	
nums = input()
print(main(nums))