Problem:


Score : 600 points

Problem Statement

Given is an integer N.
Find the minimum possible positive integer k such that (1+2+\cdots+k) is a multiple of N.
It can be proved that such a positive integer k always exists.

Constraints

1 \leq N \leq 10^{15}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer in a line.

Sample Input 1

11

Sample Output 1

10

1+2+\cdots+10=55 holds and 55 is indeed a multple of N=11.
There are no positive integers k \leq 9 that satisfy the condition, so the answer is k = 10.

Sample Input 2

20200920

Sample Output 2

1100144



Sample input:
11


Sample output:
10

Submission status: Wrong Answer

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

# 素因数分解、辞書で返すやつ
# mathをimportする
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
        if num > n:
            break
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

# (x, y) of ax + by = 1
def oneOfSolution(a, b):
    if b == 1:
        return 0, 1
    d = a//b
    p, q = oneOfSolution(b, a%b)
    return q, p-d*q

def solution(a, b):
    if b > a:
        y0, x0 = oneOfSolution(b, a)
    else:
        x0, y0 = oneOfSolution(a, b)
    x = x0%b
    if a*x < 2:
        x += b
    return a*x-1

N = int(input())

N_prime = prime(N)
W = []
for num, cnt in N_prime.items():
    if num == 2:
        W.append(num**(cnt+1))
    else:
        W.append(num**cnt)

M = len(W)
ans = N
for bit in range(1<<M):
    a = 1; b = 1
    for i, m in enumerate(W):
        if bit&(1<<i):
            a *= m
        else:
            b *= m
    ans = min(ans, solution(a, b))

print(ans)

Submission status: Wrong Answer

Solution code:
def Ftest(x): #2**64まで
    prime=[2, 325, 9375, 28178, 450775, 9780504, 1795265022]
    for i in prime:
        y=pow(i,x-1,x)
        if y!=1:
            return False
    return True

n=int(input())
if Ftest(n):
    print(n-1)
else:
    for i in range(1,n-1):
        t=((i+1)*i)//2
        if t%n==0:
            print(i)
            exit()

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/09/20

@author: harurun
'''
import math
import sys

pin=sys.stdin.readline 

N=int(pin())

j=1
while 1:
  i=N*j
  t=1+8*i
  s=math.sqrt(t)
  if t%2==1:
    if s.is_integer():
      print(int((s-1)//2))
      break
  j+=1

Submission status: Wrong Answer

Solution code:
def solv_quadratic_equation(a, b, c):
    """ 2次方程式を解く  """
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)
    x_2 = (-b - D) / (2 * a)

    return x_1, x_2
N = int(input())
a = N
flag = False

while True:
    x_1,x_2 = solv_quadratic_equation(float(1),float(1),float(-2*N))
    if x_1.is_integer() and x_1 > 0:
        flag = True
    elif x_2.is_integer() and x_2 > 0:
        flag = True
    if flag:
        break
    N += a
if  x_1 > 0 and x_2 > 0:
    print(min(x_1,x_2))
elif x_1 > 0 and x_2 < 0:
    print(int(x_1))
else:
    print(int(x_2))

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 1
while True:
    tmp = (-1+(1+8*i*N)**0.5)/2
    if tmp == int(tmp):
        print(int(tmp))
        break
    i += 1

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

def extgcd(a, b):
    if b:
        d, y, x = extgcd(b, a%b)
        y -= (a//b)*x
        return d, x, y
    else:
        return a, 1, 0

ans = float("inf")
n = int(input())
n = 2*n
P = primeFactor(n)
K = P.keys()
l = len(K)
for i in range(1<<l):
    temp = 1
    for j, k in enumerate(K):
        if i>>j & 1:
            temp *= k**P[k]
    if temp == 1 or temp == n:
        continue
    other = n // temp
    S = extgcd(temp, other)[1:]
    p, q = S
    if p > q:
        p, q = q, p
        temp, other = other, temp
    ans = min(ans, p*temp*(-1))
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
i = 1
while True:
    tmp = (-1+(1+8*i*N)**0.5)/2
    if tmp == int(tmp):
        print(tmp)
        break
    i += 1

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
num = int(math.sqrt(20200920)/4)
while True:
    ans = num**2/2 + num/2
    if (ans) % N == 0:
        print(num)
        break
    num += 1

Submission status: Wrong Answer

Solution code:
a=int(input())


sum=0

if a==0:
  print(a)


def solv_quadratic_equation(a, b, c):
    """ 2次方程式を解く  """
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)
    x_2 = (-b - D) / (2 * a)

    if int(x_1)<int(x_2):
      return int(x_2)
    elif int(x_1)>int(x_2):
      return int(x_1)

harf=solv_quadratic_equation(1,1,-2*a)

#print(harf)

sum=1/2*harf*(harf+1)

sum=int(sum)

for i in range(harf+1,a):
  sum+=i
  print(sum)
  if sum%a==0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
k=1
k_min = int(n**(1/2))
for k in range(k_min, n):
    sum_k = k*(k+1)/2
    if sum_k%n == 0:
        print(k)
        exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import typing
def _is_prime(n: int) -> bool:
    '''
    Reference:
    M. Forisek and J. Jancina,
    Fast Primality Testing for Integers That Fit into a Machine Word
    '''

    if n <= 1:
        return False
    if n == 2 or n == 7 or n == 61:
        return True
    if n % 2 == 0:
        return False

    d = n - 1
    while d % 2 == 0:
        d //= 2

    for a in (2, 7, 61):
        t = d
        y = pow(a, t, n)
        while t != n - 1 and y != 1 and y != n - 1:
            y = y * y % n
            t <<= 1
        if y != n - 1 and t % 2 == 0:
            return False
    return True


def _inv_gcd(a: int, b: int) -> typing.Tuple[int, int]:
    a %= b
    if a == 0:
        return (b, 0)

    # Contracts:
    # [1] s - m0 * a = 0 (mod b)
    # [2] t - m1 * a = 0 (mod b)
    # [3] s * |m1| + t * |m0| <= b
    s = b
    t = a
    m0 = 0
    m1 = 1

    while t:
        u = s // t
        s -= t * u
        m0 -= m1 * u  # |m1 * u| <= |m1| * s <= b

        # [3]:
        # (s - t * u) * |m1| + t * |m0 - m1 * u|
        # <= s * |m1| - t * u * |m1| + t * (|m0| + |m1| * u)
        # = s * |m1| + t * |m0| <= b

        s, t = t, s
        m0, m1 = m1, m0

    # by [3]: |m0| <= b/g
    # by g != b: |m0| < b/g
    if m0 < 0:
        m0 += b // s

    return (s, m0)


def _primitive_root(m: int) -> int:
    if m == 2:
        return 1
    if m == 167772161:
        return 3
    if m == 469762049:
        return 3
    if m == 754974721:
        return 11
    if m == 998244353:
        return 3

    divs = [2] + [0] * 19
    cnt = 1
    x = (m - 1) // 2
    while x % 2 == 0:
        x //= 2

    i = 3
    while i * i <= x:
        if x % i == 0:
            divs[cnt] = i
            cnt += 1
            while x % i == 0:
                x //= i
        i += 2

    if x > 1:
        divs[cnt] = x
        cnt += 1

    g = 2
    while True:
        for i in range(cnt):
            if pow(g, (m - 1) // divs[i], m) == 1:
                break
        else:
            return g
        g += 1
        
def factorize(n):
    dd = defaultdict(int)
    for i in range(2,int(n**0.5)+1):
        while n%i==0 and n>0:
            dd[i]+=1
            n//=i
    if n>1:
        dd[n]+=1
    return dd

def crt(r: typing.List[int], m: typing.List[int]) -> typing.Tuple[int, int]:
    assert len(r) == len(m)

    n = len(r)

    # Contracts: 0 <= r0 < m0
    r0 = 0
    m0 = 1
    for i in range(n):
        assert 1 <= m[i]
        r1 = r[i] % m[i]
        m1 = m[i]
        if m0 < m1:
            r0, r1 = r1, r0
            m0, m1 = m1, m0
        if m0 % m1 == 0:
            if r0 % m1 != r1:
                return (0, 0)
            continue

        # assume: m0 > m1, lcm(m0, m1) >= 2 * max(m0, m1)

        '''
        (r0, m0), (r1, m1) -> (r2, m2 = lcm(m0, m1));
        r2 % m0 = r0
        r2 % m1 = r1
        -> (r0 + x*m0) % m1 = r1
        -> x*u0*g % (u1*g) = (r1 - r0) (u0*g = m0, u1*g = m1)
        -> x = (r1 - r0) / g * inv(u0) (mod u1)
        '''

        # im = inv(u0) (mod u1) (0 <= im < u1)
        g, im = _inv_gcd(m0, m1)

        u1 = m1 // g
        # |r1 - r0| < (m0 + m1) <= lcm(m0, m1)
        if (r1 - r0) % g:
            return (0, 0)

        # u1 * u1 <= m1 * m1 / g / g <= m0 * m1 / g = lcm(m0, m1)
        x = (r1 - r0) // g % u1 * im % u1

        '''
        |r0| + |m0 * x|
        < m0 + m0 * (u1 - 1)
        = m0 + m0 * m1 / g - m0
        = lcm(m0, m1)
        '''

        r0 += x * m0
        m0 *= u1  # -> lcm(m0, m1)
        if r0 < 0:
            r0 += m0

    return (r0, m0)

N = int(input())
D = factorize(N)
D[2] += 1
key = list(D.keys())

m = [k**D[k] for k in key]
ans = 2*N
for i in range(2**len(key)):
    j = 1
    r = []
    while j < 2**len(key):
        if j&i>0:
            r.append(-1)
        else:
            r.append(0)
        j*=2
    y,z = crt(r,m)
    
    if y==0:
        y = z
    if y==1:
        continue
    ans = min(ans,y)

print(ans)

Submission status: Wrong Answer

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

m = 1
k = 1
while True:
  k = math.sqrt(2*m*n+0.25) - 0.5
  m += 1
  if k.is_integer():
    print(int(k))
    print("\n")
    break

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

i = 1
while True:
    root = math.sqrt(8 * N * i + 1)
    if root.is_integer():
        print(int((root - 1) / 2))
        exit()

    i += 1

Submission status: Wrong Answer

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from collections import Counter
n = int(input())
prime_list = prime_factorize(n)
if n == 1:
    print(1)
    exit()

cnt = Counter(prime_list)
cnt_values = list(cnt.values())
value_list = [range(i + 1) for i in cnt_values]
iter_list = list(value_list[0])
iter_list = [[i] for i in iter_list]
for v_list in value_list[1:]:
    tmp = []
    for v in v_list:
        for i in iter_list:
            tmp.append(i + [v])
    iter_list = tmp
    
key_list = list(cnt.keys())
ans = n - 1
mod = 2 * n
for i_list in iter_list:
    tmp = 1
    for key, value in zip(key_list, i_list):
        tmp = tmp * pow(key, value)
    if tmp == 1:
        continue
    if tmp * (tmp - 1) % mod == 0:
        ans = min(ans, tmp - 1)
    if tmp * (tmp + 1) % mod == 0:
        ans = min(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
a=int(input())


sum=0

if a==0:
  print(a)


def solv_quadratic_equation(a, b, c):
    """ 2次方程式を解く  """
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)
    x_2 = (-b - D) / (2 * a)

    if int(x_1)<int(x_2):
      return int(x_2)
    elif int(x_1)>int(x_2):
      return int(x_1)

harf=solv_quadratic_equation(1,1,-2*a)

#print(harf)

sum=1/2*harf*(harf+1)

for i in range(harf+1,a):
  sum+=i
  if sum%a==0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
for i in range(1,n):
  if (i*(i+1)//2) % n==0:
    print(i)
    break



"""
n = k()
zahyo = []
count = [1]*n

for i in range(n):
  x,y = I()
  for j in range(len(zahyo)):
    if (x>zahyo[j][0] and y>zahyo[j][1]) or (x<zahyo[j][0] and y<zahyo[j][1]):
      count[i] += 1
      count[j] += 1
      count[i] = max(count[i],count[j])
      count[j] = max(count[i],count[j])
  zahyo.append([x,y])
  count

for i in count:
  print(i)
"""

Submission status: Wrong Answer

Solution code:
def factorize(n):
    out=[]
    i = 2
    while 1:
        if n%i==0:
            out.append(i)
            n //= i
        else:
            i += 1
        if n == 1:break
        if i > int(n**.5+3):
            out.append(n)
            break
    
    return out
  
N = int(input())
if N == 1:
  print(1)
  exit()
elif N == 2:
  print(3)
  exit()
f = factorize(N)[-1]
for i in range(1,10**7):
  if (f*i-1)*(f*i)%(2*N)==0:
    print(f*i-1)
    exit()
  elif (f*i)*(f*i+1)%(2*N)==0:
    print(f*i)
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
	if (b==0):
		return a
	else:
		return gcd(b,a%b)

def main():

	n = int(input())
	for k in range(n):
		sum = (k+1)*(k+2)/2
		g = gcd(n,sum)
		if (n < sum) and g == n:
			print(k+1)
			return

main()

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = (-1 + math.sqrt(1 + 8 * N))/2
A_m = (-1 - math.sqrt(1 + 8 * N))/2

B = N
while not A.is_integer() | A_m.is_integer():
    B = B + N
    A = (-1 + math.sqrt(1 + 8 * B))/2
    A_m = (-1 + math.sqrt(1 + 8 * B))/2
    
if A.is_integer():
    print(int(A))
else:
    print(int(A_m))

Submission status: Wrong Answer

Solution code:
import time


def gcd(a, b):
	if (b==0):
		return a
	else:
		return gcd(b,a%b)

def main():

	n = int(input())

	start = time.time()

	for k in range(n):
		sum = (k+1)*(k+2)/2
		g = gcd(n,sum)
		if (n < sum) and g == n:
			print(k+1)
			end = time.time()
			print(end-start)
			return

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
factor = 0
temp = False
for i in range(2, int(n**(0.5))):
    if n % i == 0:
        factor = i
        temp = True
if temp == False:
    print(n-1)
else:
    res = 1
    counter = 1
    while res % n != 0:
        counter += 1
        res += counter
    print(counter)

Submission status: Wrong Answer

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)

    for i in range(1, N):
        ac = 1 + 8 * i * N

        r = int(ac**.5)
        if ac != r**2 or r&1 == 0: continue
        print((r-1)//2)
        break




if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

m = 1

while True:
    k_dash = (math.sqrt(8*m*N + 1) - 1) / 2
    k = int(k_dash)
    m += 1
    if k_dash == k:
        break

print(k)

Submission status: Wrong Answer

Solution code:
n = int(input())
import math
p = round(math.sqrt(n))
for i in range(p,n):
  if i*(i+1)/2%n == 0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
N = int(input())
k = 1
for i in range(2 * N):
    k += i + 1
    if k * (k + 1) % (2 * N) == 0:
        print(k)
        break

Submission status: Wrong Answer

Solution code:
n = int(input())

if n % 2 == 1:
  if n == 1:
    print(2)
  else:
    print(n-1)

else:
  print(2*n-1)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = (-1 + math.sqrt(1 + 8 * N))/2
A_m = (-1 - math.sqrt(1 + 8 * N))/2

B = N
while not A.is_integer() | A_m.is_integer():
    B = B + N
    A = (-1 + math.sqrt(1 + 8 * B))/2
    A_m = (-1 + math.sqrt(1 + 8 * B))/2
    
print(int(A))

Submission status: Wrong Answer

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

m = 1
k = 1
while True:
  k = math.sqrt(2*m*n+0.25) - 0.5
  m += 1
  if k.is_integer():
    print(int(k))
    break

Submission status: Wrong Answer

Solution code:
n=int(input())
s=1
for i in range(2,n+1):
    s+=i
    
    if(s%n==0):
        print(i)
        break

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/09/20

@author: harurun
'''
import math
import sys

pin=sys.stdin.readline 

N=int(pin())

j=1
while 1:
  i=N*j
  t=1+8*i
  s=math.sqrt(t)
  if t%2==1:
    if s.is_integer():
      print(int((s-1)//2))
    break
  print(s)
  j+=1

Submission status: Wrong Answer

Solution code:
import math
try:
    N=int(input())
    for i in range(1,100000):
        sum=math.ceil(i*(i+1)/2)
        if sum%N==0:
            print(i)
            break
except:
    pass

Submission status: Wrong Answer

Solution code:
try:
    N=int(input())
    sum=0
    i=1
    for i in range(1,100000):
        sum=sum+i
        if sum%N==0:
            print(i)
            break
except:
    pass

Submission status: Wrong Answer

Solution code:
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
facN = factorization(N)
if len(facN) == 1 and facN[0][1] == 1:
    ans = N-1
else:
    La = facN[-1][0]
    for i in range(1,2*10**7+1):
        if (La*i*(La*i+1))%(2*N) == 0:
            ans = La*i
            break
print(ans)

Submission status: Wrong Answer

Solution code:
def euclid(x, y):
    c0, c1 = x, y
    a0, a1 = 1, 0
    b0, b1 = 0, 1
 
    while c1 != 0:
        m = c0 % c1
        q = c0 // c1
 
        c0, c1 = c1, m
        a0, a1 = a1, (a0 - q * a1)
        b0, b1 = b1, (b0 - q * b1)
 
    return a0, b0

n=int(input())
n*=2
soinsu=[]

num=n
for i in range(2,max(10,n)):
    if(i*i>n):
        if(num!=1):
            soinsu.append([num,1])
        break
    if(num%i!=0):
        continue
    cnt=0
    while(num%i==0):
        cnt+=1
        num//=i
    soinsu.append([i,cnt])

kazu=len(soinsu)
#print(soinsu,kazu)


ans=[]
for i in range(2**(kazu-1)):
    a=1
    for j in range(kazu):
        if((i&1<<j)!=0):
            a*=soinsu[j][0]**soinsu[j][1]
    b=n//a
    c,d=euclid(a,b)
    if(c*d==0):
        c+=b
        d+=a
    ans.append(max(a*c,b*d))
    #print(a,b,c,d)

print(min(ans)-1)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = (-1 + math.sqrt(1 + 8 * N))/2
B = N
while not A.is_integer():
    B = B + N
    A = (-1 + math.sqrt(1 + 8 * B))/2
    
print(int(A))

Submission status: Wrong Answer

Solution code:
N = int(input())

for i in range(1, N):
  if (i*(i+1)) % (2*N) == 0:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

def K(a):
    return (1 + 8 * N * a) ** 0.5

m = 1
while (K(m) - 1) % 2 != 0:    
    m += 1

k = int((- 1 + K(m)) / 2)
print(k)

Submission status: Wrong Answer

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

if N == 1:
    print(1)
    exit()

a = 1
while True:
    a_8 = 8 * N * a
    i = 1 + a_8
    sm = math.sqrt(i)
    if sm % 1 == 0:
        if (sm - 1) % 2 == 0:
            k = (sm - 1) / 2
            break
    a += 1

print(int(k))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = (-1 + math.sqrt(1 + 8 * N))/2
B = N
while not A.is_integer():
    B = B + N
    A = (-1 + math.sqrt(1 + 8 * B))/2
    
print(A)

Submission status: Wrong Answer

Solution code:
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from heapq import heapify, heappop, heappush
from math import ceil, log, floor, sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*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)]


n = int(data())
i = 1
while True:
    temp = n * i
    s = (-1 + sqrt(1 + 8 * temp)) / 2
    if s == int(s):
        out(int(s))
        exit()
    i += 1

Submission status: Wrong Answer

Solution code:
N = int(input())

def K(a):
    return (1 + 8 * N * a) ** 0.5

m = 1
while (K(m) - 1) % 2 != 0:    
    m += 1

k = (- 1 + K(m)) / 2
print(int(k))

Submission status: Wrong Answer

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

if N == 1:
    print(1)
    exit()

a = 1
while True:
    a_8 = 8 * N * a
    i = 1 + a_8
    sm = math.sqrt(i)
    if sm % 1 == 0:
        k = (sm - 1) / 2
        break
    a += 1

print(int(k))

Submission status: Wrong Answer

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

for i in range(1,len(nums)+1):
      work = ((1+i)*i)/2         # 等差数列の総和は (初項+末項)*項数/2
      if work%n == 0:
            print(nums[i-1])

Submission status: Wrong Answer

Solution code:
def solv_quadratic_equation(a, b, c):
    """ 2次方程式を解く  """
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)
    x_2 = (-b - D) / (2 * a)

    return x_1, x_2

N = int(input())
a = 8*N
while True:
    target = (a+1)**0.5
    if target == int(target) and target%2==1:
        ans = (target-1)//2
        print(int(ans))
        break
    a += 8*N

Submission status: Wrong Answer

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

for i in range(1,n):
    s=s+i
    if (s%n)/2==0:
            print(i)    
            break;

Submission status: Wrong Answer

Solution code:
import math

def solve_naive(N):
    sqrtN = math.floor(math.sqrt(N))
    tmp = (sqrtN * (sqrtN + 1) // 2) % N
    for i in range(sqrtN + 1, N):
        tmp = (tmp+i)%N
        if tmp % N == 0:
            return i

N = int(input())
ans = solve_naive(N)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
sum=0
i=1
while(i<=N):
    sum=sum+i
    if sum%N==0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
from operator import itemgetter

N = int(readline())

res = []
for i in range(1, N):
  if i*i > N:
    break
  if N%i:
    continue
  res.append(N//i)

ans = 2*N

for r in res:
    for k in range(1, ans):
        if (k*r*(k*r-1))%(2*N) == 0:
            ans = k*r-1
            break
        if (k*r*(k*r+1))%(2*N) == 0:
            ans = k*r
            break

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())


i=0
sum=0

for _ in range(N):
    i=i+1
    sum=sum+i
    if i == N-1:
        print(sum)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    x = 0
    for i in range(1, N):
        x += i
        x = x % N
        if x == 0:
            print(i)
            break

        	

    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(1,len(nums)+1):
      work = sum(nums[0:i])         # 累積和を求める
      if work%n == 0:
            print(nums[i-1])

Submission status: Wrong Answer

Solution code:
import math

val = int(input())

i = int(math.sqrt(2*val - 0.25) - 0.5)-1
while(True):
    tmp = i*(1+i) / 2
    if tmp%val == 0:
        print(i)
        break
    i += 1

Submission status: Wrong Answer

Solution code:
N = int(input())

def K(a):
    return (1 + 8 * N * a) ** 0.5

m = 1
k = (- 1 + K(m)) / 2
while K(m).is_integer() == False and k % 2 == 1:
    m += 1

print(int(k))

Submission status: Wrong Answer

Solution code:
n = int(input())
c = 0
a = 1
b = 2
while c == 0:
  if a%n == 0 and n <= a:
    c = 1
  a += b
  b += 1
print(b)

Submission status: Wrong Answer

Solution code:
a=int(input())


sum=0

if a==0:
  print(a)

for i in range(1,a):
  sum+=i
  if sum%a==0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/09/20

@author: harurun
'''
import math
import sys

pin=sys.stdin.readline 

N=int(pin())

j=1
while 1:
  i=N*j
  s=math.sqrt(1+8*i)
  if s.is_integer() and int(s)%2==1:
    print(int((s-1)//2))
    break
  j+=1

Submission status: Wrong Answer

Solution code:
a=int(input())


sum=0

if a==0:
  print(a)

for i in range(1,a):
  sum+=i
  print(sum)
  if sum%a==0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
N = int(input())
x = 1

import math as m
import decimal as d
N = d.Decimal(N)
while x < N:
  target = N*x
  a = m.floor(m.sqrt(target*2))
  check = a*(a+1)/2
  #print(check,target)
  if check == target:
    print(a)
    exit(0)
  x += 1

Submission status: Wrong Answer

Solution code:
N = int(input())
x = 1

import math as m
import decimal as d
N = d.Decimal(N)
while x < N:
  target = N*x
  a = int(m.floor(m.sqrt(target*2)))
  check = int(a*(a+1)/2)
  #print(check,target)
  if check == target:
    print(a)
    exit(0)
  x += 1

Submission status: Wrong Answer

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

for i in range(1, N):
    a = (-1 + math.sqrt(1 + 8 * N * i)) / 2
    if (a.is_integer()):
        print(int(a))
        break

Submission status: Wrong Answer

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

a = 1
while math.modf(((math.sqrt(8*N*a+1)-1)/2))[0]!=0:
    a+=1

print(int(((math.sqrt(8*N*a+1)-1)/2)))

Submission status: Wrong Answer

Solution code:
N=int(input())
sum=0
for i in range(N):
    sum=sum+i
    if sum%N==0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def sum(k):
    result = 0
    result = (1+k)*int(k/2 + 1/2)
    return result
N = int(input("N"))
cont = True
_n = 0

while(cont):
    _n += 1
    if(int(sum(_n)/N) == sum(_n)/N):
        print(_n)
        cont = False

Submission status: Wrong Answer

Solution code:
#   ==========     //\\       //||     ||====//||
#       ||        //  \\        ||     ||   // ||
#       ||       //====\\       ||     ||  //  ||
#       ||      //      \\      ||     || //   ||
#   ========== //        \\  ========  ||//====|| 
#  code

def solve():
    from math import sqrt
    n = int(input())
    for i in range(1, 10 ** 7 + 1):
        k = 1 + 8 * i * n
        k = sqrt(k)
        if k == int(k):
            print((-1 + int(k)) // 2)
            break
    return

def main():
    t = 1
    # t = int(input())
    for _ in range(t):
        solve()

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#   ==========     //\\       //||     ||====//||
#       ||        //  \\        ||     ||   // ||
#       ||       //====\\       ||     ||  //  ||
#       ||      //      \\      ||     || //   ||
#   ========== //        \\  ========  ||//====|| 
#  code

def solve():
    from math import sqrt
    n = int(input())
    for i in range(1, 10 ** 6 + 1):
        k = 1 + 8 * i * n
        k = sqrt(k)
        if k == int(k):
            print((-1 + int(k)) // 2)
            break
    return

def main():
    t = 1
    # t = int(input())
    for _ in range(t):
        solve()

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
x = 1

import math as m
while x < N:
  target = N*x
  a = int(m.floor(m.sqrt(target*2)))
  check = int(a*(a+1)/2)
  #print(check,target)
  if check == target:
    print(a)
    exit(0)
  x += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l = int(input())
s = 0
for i in range(1,10000000):
  s += i
  if s % l == 0:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
N = int(input())
for a in range(1,10**15):
    n = (-1 + (1 + 4 * 1 * 2*a*N)**0.5) / 2
    if n.is_integer():
        print(int(n))
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
i=0
sum=0
counter=0
for _ in range(N):
    if sum == N:
        print(sum)
    i=+1
    sum=sum+i