Problem:


Score : 200 points

Problem Statement

There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0.
During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right.
That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i.
The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible.
Find the earliest possible time to reach coordinate X.

Constraints

X is an integer.

1≤X≤10^9

Input

The input is given from Standard Input in the following format:

X

Output

Print the earliest possible time for the kangaroo to reach coordinate X.

Sample Input 1

6

Sample Output 1

3

The kangaroo can reach his nest at time 3 by jumping to the right three times, which is the earliest possible time.

Sample Input 2

2

Sample Output 2

2

He can reach his nest at time 2 by staying at his position during the first second, and jumping to the right at the next second.

Sample Input 3

11

Sample Output 3

5



Sample input:
6


Sample output:
3

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x = int(input())

l = 0
for i in range(x+1):
  if i + i + 1 > x - l > i:
    # stay
    pass
  else:
    l += i
    if l == x:
      break
if x == 1:
  print(x)
else:
  print(i)

Submission status: Wrong Answer

Solution code:
x=int(input())

num=0
cnt=0

for i in range(10**9):
  num+=i
  cnt+=1
  if num>=x:
    break
    
if num==x:
  print(cnt)
else:
  print(cnt-1)

Submission status: Wrong Answer

Solution code:
X = int(input())
Sum = 0
t = 0

while Sum + (t + 1) <= X:
    t += 1
    Sum += t

if (X - Sum) <= (Sum + t + 1 - X) + 1:
    print(t + (X - Sum))
else:
    t += 1
    Sum += t
    print(t + (Sum - X))

Submission status: Wrong Answer

Solution code:
X = int(input())
Sum = 0
t = 0
while Sum + (t + 1) <= X:
    t += 1
    Sum += t
print(t + (X - Sum))

Submission status: Wrong Answer

Solution code:
X=int(input())
N=1
while N*(N+1)//2<X:
    N+=1

while (N*(N+1)//2-X)%2==1:
    N+=1
print(N)

Submission status: Wrong Answer

Solution code:
x = int(input())
place = 0
i = 1
i_all = []

while 1:
    if place + i == x:
        i_all.append(i)
        break
    elif (i + i+1) > (x - place):
        i += 1
    else:
        place += i
        i += 1

place = 0
i = 1

while 1:
    if place + i == x:
        i_all.append(i)
        break
    elif (place + i) > x:
        i += (place + i) - x + 1
        i_all.append(i)
        break
    else:
        place += i
        i += 1

print(min(i_all))

Submission status: Wrong Answer

Solution code:
x = int(input())
place = 0
i = 1

while 1:
    if place + i == x:
        print(i)
        exit()
    elif (i + i+1) > (x - place):
        i += 1
    else:
        place += i
        i += 1

Submission status: Wrong Answer

Solution code:
X = int(input())
if X <= 2:
    print(X)
    exit()
n = 1
special = 500000000
while True:
    if X - n*(n+1)//2 >= n+1:
        special = min(special,X - n*(n+1)//2)
    if n*(n+1) > 2*X:
        break
    n += 1
diffOver = abs(n*(n+1)//2 - X)
diffUnder = abs(n*(n-1)//2 - X)
#print(diffOver,diffUnder)
if diffOver >= n+1:
    ot = diffOver
else:
    ot = diffOver + n + 1

print(min(ot,special))

Submission status: Wrong Answer

Solution code:
X = int(input())
if X <= 2:
    print(X)
    exit()
n = 1
special = 500000000
while True:
    if X - n*(n+1)//2 >= n+1:
        special = min(special,X - n*(n+1)//2)
    if n*(n+1) > 2*X:
        break
    n += 1
diffOver = abs(n*(n+1)//2 - X)
diffUnder = abs(n*(n-1)//2 - X)
#print(diffOver,diffUnder)
if diffOver >= n+1:
    ot = diffOver
else:
    ot = diffOver + n + 1

if diffUnder + n >= n+1:
    ut = diffUnder+n
elif diffUnder == 0:
    ut = n-1
else:
    ut = diffUnder+n+n+1
print(min(ot,ut,special))

Submission status: Wrong Answer

Solution code:
x=abs(int(input()))
t=1
while x>0:
  if x-t>=t+1:
    x-=t
    t+=1
  elif x-t<t+1 and x-t!=0:
    t+=1
  elif x-t<t+1 and x-t==0:
    break
print(t)

Submission status: Wrong Answer

Solution code:
x = int(input())
min_dt = 1001001001
min_i = 0
for i in range(1, int(x**0.5)):
    dt = abs(x - (i+1)*i//2)
    if dt<min_dt:
        min_dt = dt
        min_i = i
    if min_dt == 0:
        print(i)
        break
else:
    print(min_i+min_dt)

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

import string

def main():
    x = i_input()
    l = [0]
    for i in range(1,10):
        l.append(l[i-1]+i)

    for i,k in enumerate(l):
        if x <= k:
            print(i)
            exit()




if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
X = int(input())
N = math.floor((2*X)**(0.5))
if X==1 or X==2: print(X)
else: print(N+(2*X-N*(N+1))//2)

Submission status: Wrong Answer

Solution code:
def get_index(n):
    i=1
    while True:
        if n<piramid(i):
            return i-1
        i+=1

def piramid(n):
    return n*(n+1)//2

n=int(input())
index=get_index(n)

print(min(index+n-piramid(index),index+2+piramid(index+1)-n))

Submission status: Wrong Answer

Solution code:
def get_index(n):
    i=1
    while True:
        if n<piramid(i):
            return i-1
        i+=1

def piramid(n):
    return n*(n+1)//2

n=int(input())
index=get_index(n)

print(min(index+n-piramid(index),index+2+piramid(index+1)-n))

Submission status: Wrong Answer

Solution code:
def get_index(n):
    i=1
    while True:
        if n<piramid(i):
            return i-1
        i+=1

def piramid(n):
    return n*(n+1)//2

n=int(input())
index=get_index(n)

print(min(index+n-piramid(index),index+1+piramid(index+1)-n))

Submission status: Wrong Answer

Solution code:
def get_index(n):
    i=1
    while True:
        if n<piramid(i):
            return i-1
        i+=1

def piramid(n):
    return n*(n+1)//2

n=int(input())
index=get_index(n)

print(index+n-piramid(index))

Submission status: Wrong Answer

Solution code:
x = int(input())

time = 1
total = 0
while True:
    total += time
    if total > x:
        total -= time
        time -= 1
        print(time + (x - total))
        break
    elif total == x:
        print(time)
        break
    time += 1

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    X = INT()

    MAX = int(sqrt(X)) + 10
    for i in range(MAX):
        X -= i + 1
        if X <= 0:
            break

    print(i + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

A = []
tmp = 0
for i in range(1, X):
    tmp += i
    A.append(tmp)
    if tmp >= X:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    X = INT()

    for i in range(int(sqrt(X)) + 2):
        X -= i + 1
        if X <= 0:
            break

    print(i + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

A = []
tmp = 0
for i in range(1, X):
    tmp += i
    A.append(tmp)
    if tmp > X:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    X = INT()

    ans = 0
    for i in range(int(sqrt(X)) + 2):
        X -= i + 1
        ans += 1
        if X <= 0:
            break

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
for i in range(1,N//2+10):
	tmp=((i+1)*(i))//2
	if N-tmp<i+1:
		print(i+1)
		exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
for i in range(1,N//2+10):
	tmp=((i+1)*(i))//2
	if N-tmp<i+1:
		print(N-tmp+i)
		exit()

Submission status: Wrong Answer

Solution code:
x=int(input())
a=0
for i in range(x):
  if a+i>=x:
    print(i)
    break
  else:
    a+=i

Submission status: Wrong Answer

Solution code:
x = int(input())

index = 0
for i in range(1,x+1):
  if i*(i+1) < (x-index):
    index+=i
  else:
    ans = x-index
    break
#  print(i,index)
print(ans)

Submission status: Wrong Answer

Solution code:
x = int(input())

index = 0
for i in range(1,x+1):
  if (i+1)*2 < (x-index):
    index+=i
  else:
    ans = x-index
    break
#  print(i,index)
print(ans)

Submission status: Wrong Answer

Solution code:
x = int(input())

index = 0
for i in range(1,x+1):
  if i*2 < (x-index):
    index+=i
  else:
    ans = x-index
    break
    #  elif i == (x-index):
#    break
#  print(i,index)
print(ans)

Submission status: Wrong Answer

Solution code:
x = int(input())

index = 0
for i in range(1,x+1):
  if (i+1)*2 < (x-index):
    index+=i
  elif i == (x-index):
    break
  print(i,index)
print(i)

Submission status: Wrong Answer

Solution code:
x = int(input())

index = 0
for i in range(1,x+1):
  if i*2< (x-index):
    index+=i
  elif i == (x-index):
    break
#  print(i,index)
print(i)

Submission status: Wrong Answer

Solution code:
x = int(input())

index = 0
for i in range(1,x+1):
  if index*2<x:
    index+=i
  elif i == (x-index):
    break
#  print(index)
print(i)

Submission status: Wrong Answer

Solution code:
import math
X = int(input())
n = math.floor((math.sqrt(1+8*X) - 1)/2)
ans = X - n*(n-1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
import math
X = int(input())
n = math.floor((math.sqrt(1+8*X) - 1)/2)
ans = X - sum(range(n))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
X = int(input())
time = X
for i in range(X+1):
    j = X - i
    if j > time: continue
    n = - 1 + math.sqrt(1+8*X-j)
    if n < 2*j and math.floor(n) == n:
        time = min(time, j)
print(time)

Submission status: Wrong Answer

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    x = ni()
    d = 0
    for i in range(1, x):
        d += i
        if d >= x:
            print(i)
            return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
X=int(input())
m=0
for i in range(1,X+1):
    if X<=m:
        break
    if m+i<X:
        m+=1
print(m)

Submission status: Wrong Answer

Solution code:
x = int(input())

if x == 1:
    print(1)
else:
    cur = 0
    for i in range(0, 44720):
        cur += i
        if x <= cur:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
x = int(input())

if x == 1:
    print(1)
else:
    cur = 0
    for i in range(0, 44720):
        cur += i
        if x > cur and x <= cur + i + 1:
            print(i+1)
            break

Submission status: Wrong Answer

Solution code:
x = int(input())
f = True
ans = 0
if x%2!=0:
  ans += 1
while f:
  ans+=1
  a = x//2
  if a < 1:
    f = False
  x = a
print(ans)

Submission status: Wrong Answer

Solution code:
x = int(input())
f = True
ans = 0
while f:
  ans+=1
  a = x//2
  if a < 1:
    f = False
  x = a
if x%2!=0:
  ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
x = int(input())
f = True
ans = 0
while f:
  ans+=1
  a = x//2
  if a < 1:
    f = False
  x = a
if x%2==0:
  ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
X=int(input())

ans = 0
tmp = X

for i in range(1,X+1):
    if tmp-i == 0:
        print(i)
        sys.exit()
    if tmp-i >= i+1:
        tmp = tmp-i
        ans += 1

Submission status: Wrong Answer

Solution code:
import math

x = int(input())

y = int(math.sqrt(2*x))
for i in range(y+1, 0, -1):
    if i * (i + 1) < 2 * x:
        print(i + 1)
        break

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X = int(input())
fac = {}
fac[0] = 0
for i in range(1, 50000):
    fac[i] = fac[i-1]+i
    if fac[i]>=10**9:
        break

for i in range(1, 50000):
    f = fac[i]
    if f==X:
        print(i)
        break
    if f>X:
        print((X-fac[i-1])+i-1)
        break

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X = int(input())
fac = {}
fac[0] = 0
for i in range(1, 50000):
    fac[i] = fac[i-1]+i
    if fac[i]>=10**9:
        break

for i in range(1, 15):
    f = fac[i]
    if f==X:
        print(i)
        break
    if f>X:
        print((X-fac[i-1])+i-1)
        break

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

X = int(input())
fac = {}
fac[0] = 0
for i in range(1, 15):
    fac[i] = fac[i-1]+i

for i in range(15):
    f = fac[i]
    if f==X:
        print(i)
        break
    if f>X:
        print((X-fac[i-1])+i-1)
        break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-31 13:48:14 +0900
# LastModified: 2020-07-31 14:20:23 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import sqrt


def main():
    X = abs(int(input()))
    s = (-1+sqrt(1+8*X))/2
    if s.is_integer():
        pass
    else:
        s = int(s) + 1
    print(s)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    X+i+(i+1)+(i+2)+..
    
    X < n*(n+1)//2

    n*(n+1)//2-(n-1)*n//2 > n ?
    n//2(2) > n ? false
    """
    X = read_int()
    low, high = 1, 10**9
    while high-low > 1:
        mid = low+(high-low)//2
        if mid*(mid+1)//2 >= X:
            high = mid
        else:
            low = mid
    if high*(high+1)//2 == X:
        return high
    return high


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

Submission status: Wrong Answer

Solution code:
X = int(input())
ans = -1
for i in range(1, 10**6):
    if X-i > i or X == i:
        X -= i
    if X == 0:
        ans = i
        break
print(ans)

Submission status: Wrong Answer

Solution code:
X = int(input())
t = 1
for t in range(1,X):
  total = t*(t+1)/2
  if total>=X:
    break
print(t)

Submission status: Wrong Answer

Solution code:
X=int(input())
a=0
b=1
while a<X:
  a+=b
  b+=1
print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
for i in range(1, n + 1):
    if n <= i // 2 * (i + 1):
        ans = i
        break
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 1:
    print(1)
elif n == 2:
    print(2)
else:
    for i in range(n):
        if n <= i // 2 * (i + 1):
            break

    print(i)

Submission status: Wrong Answer

Solution code:
import math
X = int(input())
m = math.sqrt(X * 2)
if int(m) * (int(m) + 1) == X * 2:
  print(int(m))
else:
  print(math.ceil(m))

Submission status: Wrong Answer

Solution code:
X = int(input())
i = 1
cnt = 0
n = X
while cnt+i<=X:
    cnt += i
    if X-cnt==0:
        n = i
        break
    if X-cnt>i:
        n = min(n,X-cnt)
    i += 1
print(n)

Submission status: Wrong Answer

Solution code:
X = int(input())
i = 1
cnt = 0
while cnt+i<=X:
    cnt += i
    i += 1
n = i-1
y = X-cnt
if y>0:
    n = n+y
print(n)

Submission status: Wrong Answer

Solution code:
x = int(input())
for i in range(100000):
    if x<i*(i+1)//2:
        print(i)
        exit(0)

Submission status: Wrong Answer

Solution code:
X=int(input())
ans=[0]
for i in range(1,10**9):
    temp=ans[-1]+i
    if temp>=X:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
# ABC056_C
X = int(input())

sum = 0
for i in range(1,X+1):
    sum = sum + i
    if sum > X:
        break

print(i)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
n=int(input())
x=[]
for i in range(1,33000):
  x+=[i]
y=list(accumulate(x))
for i in range(32999):
  if y[i]>=n:
    print(i+1)
    break

Submission status: Wrong Answer

Solution code:
n=int(input())
for i in range(int(pow(n*2,0.5)//1)+1,0,-1):
  if i*(i-1)>=n:
    continue
  else:
    print(i+1)
    break

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

x = INT()
i = 1
while(x-i>i):
    x -= i
    i += 1
print(x)

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

x = INT()
pos = 0
i = 1
while(pos+i+1<x):
    pos += i
    i += 1
print(x-pos)

Submission status: Wrong Answer

Solution code:
X = int(input())
i = 1
N = 0
while N <= X:
    N += i
    i += 1
i -= 1
N -= i
i -= 1
N -= i
X -= N
while X != i:
    i += 1
print(i)

Submission status: Wrong Answer

Solution code:
#ABC056-C
import bisect
x = int(input())
a = [int(0.5*(i+i**2)) for i in range(10**3)]

if x in set(a):
    print(a.index(x))
else:
    print(bisect.bisect_left(a,x))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# BFS
from collections import deque

x = int(input())
q = deque()
q.append((0, 0))
visited = []

while q:
    u = q.popleft()
    if u[0] == x:
        print(u[1])
        break
    visited.append(u)
    if ((u[0]-1, u[1]+1)) not in visited:
        q.append((u[0]-(u[1]+1), u[1]+1))
        visited.append((u[0]-(u[1]+1), u[1]+1))
    if ((u[0], u[1]+1)) not in visited:
        q.append((u[0], u[1]+1))
        visited.append((u[0], u[1]+1))
    if ((u[0]+1, u[1]+1)) not in visited:
        q.append((u[0]+(u[1]+1), u[1]+1))
        visited.append((u[0]+(u[1]+1), u[1]+1))

Submission status: Wrong Answer

Solution code:
n=int(input())
if n <= 2:
  print(n)
else:
  print(n//2)

Submission status: Wrong Answer

Solution code:
X = int(input())
current = 0
for i in range(1,X+1):
	if X - (current+i) > i + 1:
		current += i
	elif X - (current+i) == i + 1:
		print(i+1)
		break
	elif X - (current+i) == 0:
		print(i)
		break

Submission status: Wrong Answer

Solution code:
import sys

def tousa(n):
    return int((n*(n-1))/2)

X = int(input())

kyori = 0
count = 0
x = 0

if X < 3:
    print(X)
else:
    while tousa(x) < X:
        x += 1
        count+=1

if tousa(x) == X:
    print(count)
else:
    a = X-tousa(x-1)
    ans = count -2 + a
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

def tousa(n):
    return int((n*(n-1))/2)

X = int(input())

kyori = 0
count = 0
x = 0

if X < 3:
    print(X)
else:
    while tousa(x) < X:
        x += 1
        count+=1
    
a = X-tousa(x-1)
ans = count -2 + a
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

X = int(input())

kyori = 0
count = 0

if X < 3:
    print(X)
else:
    for i in range(1, X+1):
        kyori += i
        count += 1
        if kyori == X:
            print(count)
            sys.exit()
        elif kyori > X:
            a = i-1
            x = kyori-i
            y = kyori-i+1
            break
    count = count -2
    ans = count + X-x +1
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

X = int(input())

kyori = 0
count = 0

if X < 3:
    print(X)
else:
    for i in range(1, X+1):
        kyori += i
        count += 1
        if kyori == X:
            print(count)
            sys.exit()
        elif kyori > X:
            a = i
            x = kyori-a
            break
    count = count -2
    ans = count + X-x +1
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

X = int(input())

kyori = 0
count = 0

if X < 3:
    print(X)
else:
    for i in range(1, X+1):
        kyori += i
        count += 1
        if kyori == X:
            print(count)
            sys.exit()
        elif kyori > X:
            a = i
            x = kyori-a
            break
    count = count -1
    ans = count + X-x
    print(ans)

Submission status: Wrong Answer

Solution code:
S=int(input())
t=0
for i in range(S):
    t+=i
    if t>=S:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
X=int(input())
time=0
p=0
j=1
while True:
    if p+j==X:
        time+=1
        break
    elif X-(p+j)>=j+1:
        p+=j
    j+=1
    time+=1
print(time)

Submission status: Wrong Answer

Solution code:
import math
x=int(input())
a=10**5
b=0

while abs(a-b)>0.01:
	y=(a+b)/2
	if (y**2+y)/2>x:
		a=y
	else:
		b=y
print(math.ceil(b))

Submission status: Wrong Answer

Solution code:
X = int(input())

i = 0
while X > 0:
  i += 1
  if X-i >= i + 1:
    X -= i
  else:
    break

if 2*X <= 3*i + 3:
  print(X)
else:
  print(3*i + 3 - X)

Submission status: Wrong Answer

Solution code:
X = int(input())

i = 0
while X > 0:
  i += 1
  if X-i >= i + 1 or X == i:
    X -= i

print(i)

Submission status: Wrong Answer

Solution code:
x= int(input())


cnt=1
iterate=2
while cnt<x:
    cnt+=iterate

    if x<=cnt:
        break
    iterate+=1


print(iterate)

Submission status: Wrong Answer

Solution code:
x = int(input())
d = 0
for j in range(10 * 5):
	d += j
	if d >= x:
		print(j)
		exit()

Submission status: Wrong Answer

Solution code:
x = int(input())
d = 0
for j in range(10 * 9):
	d += j
	if d >= x:
		print(j)
		exit()

Submission status: Wrong Answer

Solution code:
X = int(input())
pos = 0
for i in range(1, 10):
    pos += i
    if pos > X:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
X = int(input())
pos = 0
for i in range(1, 100001):
    if pos + i == X:
        break
    if X < pos + i + i + 1:
        continue
    pos += i
print(i)

Submission status: Wrong Answer

Solution code:
X = int(input())
pos = 0
for i in range(1, 10):
    if pos + i == X:
        break
    if X < pos + i + i + 1:
        continue
    pos += i
print(i)

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)

X=l()[0]
i=1
while(X-i>=0):
    X-=i
    i+=1
print(i)

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
#sys.stdin = open("input.txt", "r")
#sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)
X=l()[0]
i=1
while(X-i>=0):
    X-=i
    i+=1
i-=1
i+=X
print(i)

Submission status: Wrong Answer

Solution code:
X = int(input())

ans = X
m = int(X ** .5)
t = m * (m + 1) // 2
while True:
  if X <= t and t % 2 == 0:
    break
    
  m += 1
  t = m * (m + 1) // 2

print(m)

Submission status: Wrong Answer

Solution code:
from math import sqrt

x = int(input())

ans = int((sqrt(8*x+1))//2)

print(ans)

Submission status: Wrong Answer

Solution code:
x = int(input())
z = 0
if x == 1:
    print(0)
else:
    for i in range(1,10**5):
        s = i*(i+1)//2
        if x - s < i+1:
            z =  x - s
            break
    print(i+z)

Submission status: Wrong Answer

Solution code:
x = int(input())
z = 0
for i in range(1,10**5):
    s = i*(i+1)//2
    if s > x:
        z = x - s + i 
        break
print(i-1+z)

Submission status: Wrong Answer

Solution code:
X = int(input())

for t in range(1, X+1):
  if X >= 2*t + 1:
    X -= t
  else:
    print(X)
    quit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x = int(input())
time = 0

for i in range(1,10**10):
  time += 1
  if time >= x:
    print(time)
    exit()

Submission status: Wrong Answer

Solution code:
x = int(input())
dis = 0
time = 0

for i in range(1,10**10):
  if x - dis -i>= i+1:
    time += 1
    dis += i
  else:
    print(x-dis)
    exit()

Submission status: Wrong Answer

Solution code:
x = int(input())
dis = 0
time = 0

for i in range(1,10**10):
  if x - dis -i> i+1:
    time += 1
    dis += i
  elif x - dis -i== i+1:
    print(time+2)
    exit()
  else:
    print(x-dis)
    exit()

Submission status: Wrong Answer

Solution code:
def main():
    x = int(input())
    n = 0
    i = 0
    while n <= x:
        i += 1
        n += i
    print(i)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

X = int(input())

for i in range(1, int(math.sqrt(X)) + 10):
    if i * (i + 1) // 2 >= X:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
X = int(input())
x = 0
time = 0

for i in range(1,10**9):
    x += i
    time +=1
    if x == X:
        print(time)
        break
    elif x > X:
        print(time-1+X-x+i)
        break

Submission status: Wrong Answer

Solution code:
x = int(input())
import itertools 
l = list(itertools.accumulate(range(1,600)))
for i in range(len(l)):
    if l[i] == x:
        print(len(l[:i+1]))
        break
    elif l[i] > x:
        print(len(l[:i])+x-l[i-1])
        break