Problem:


Score : 200 points

Problem Statement

A sequence a=\{a_1,a_2,a_3,......\} is determined as follows:

The first term s is given as input.

Let f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.

a_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.

Find the minimum integer m that satisfies the following condition:

There exists an integer n such that a_m = a_n (m > n).

Constraints

1 \leq s \leq 100

All values in input are integers.

It is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.

Input

Input is given from Standard Input in the following format:

s

Output

Print the minimum integer m that satisfies the condition.

Sample Input 1

8

Sample Output 1

5

a=\{8,4,2,1,4,2,1,4,2,1,......\}. As a_5=a_2, the answer is 5.

Sample Input 2

7

Sample Output 2

18

a=\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\}.

Sample Input 3

54

Sample Output 3

114



Sample input:
8


Sample output:
5

Submission status: Wrong Answer

Solution code:
def f(n):
    # 数列の規則
    if n % 2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1
 
if __name__ == "__main__":
    s = int(input())

    for m in range(0, 1000000): # m < 1000000となるので
        if s == 4:
            print(m + 3)
            break
        s = f(s)

Submission status: Wrong Answer

Solution code:
def f(n):
    # 数列の規則
    if n % 2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1
 
if __name__ == "__main__":
    s = int(input())

    for m in range(1, 1000000): # m < 1000000となるので
        if s == 4:
            print(m + 3)
            break
        s = f(s)

Submission status: Wrong Answer

Solution code:
s = int(input())
count=1
memoL=[]

while True:
    if s%2==0:
        s//=2
        count+=1
    else:
        s=3*s+1
        count+=1
    if s in memoL:
        print(count)
        break
    else:
        memoL.append(s)

Submission status: Wrong Answer

Solution code:
s = int(input())
count=1

while True:
    if s%2==0:
        s//=2
        count+=1
    else:
        s=3*s+1
        count+=1
    if s == 4:
        break
print(count+3)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
s = int(input())


def f(n):
    return n // 2 if n % 2 == 0 else 3 * n + 1


def g():
    for i in range(len(a)):
        for j in range(i + 1, len(a)):
            if a[i] == a[j]:
                return j + 1
    return len(a) + 1


a = [s]
while a[-1] > 1:
    a += [f(a[-1])]

print(g())

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
s = int(input())


def f(n):
    return n // 2 if n % 2 == 0 else 3 * n + 1


def g():
    for i in range(len(a)):
        for j in range(i + 1, len(a)):
            if a[i] == a[j]:
                return j + 1
    return len(a) + 1


a = [s]
while a[-1] > 1:
    a += [f(a[-1])]

for i in range(len(a)):
    for j in range(i + 1, len(a)):
        if a[i] == a[j]:
            print(j + 1)

print(g())

Submission status: Wrong Answer

Solution code:
nums = []
nums.append(int(input()))

for i in range(1,100):
    if nums[i - 1] % 2 == 0:
        nums.append(nums[i - 1] // 2)
    else:
        nums.append(nums[i - 1] * 3 + 1)

for i in range(100):
    for j in range(i + 1,100):
        if nums[i] == nums[j]:
            print(j + 1)
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
s=int(input())

cnt = 1
dic = {}
while(1):
    cnt += 1
    if(s%2==0):
        s = s//2
    else:
        s=3*s+1
    if(s in dic.keys()):
        print(cnt)
        exit()
    dic[s] = True

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n = int(input())
a = {}
cnt = 1

while True:
    cnt += 1
    if n % 2 == 0:
        n /= 2
    else:
        n = 3 * n + 1
    n = int(n)
    # print(n)
    if n in a:
        print(str(cnt))
        exit()
    else:
        a[n] = 1

Submission status: Wrong Answer

Solution code:
s =int(input())
cnt = 1
while (True):
    cnt += 1
    if s%2 == 0:
        s = int(s/2)
    else:
        s = int(3*s+1)
    if s in [1,2,4]:
        cnt += 3
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
s = int(input())
if s == 1 or s == 2:
    print(4)
    res = 1
    while True:
        if s == 4:
            break
        else:
            if s % 2 == 0:
                s = s // 2
            else:
                s = 3 * s + 1
            res += 1

    print(res+3)

Submission status: Wrong Answer

Solution code:
s = int(input())
res = 1
while True:
    if s == 4:
        break
    else:
        if s % 2 == 0:
            s = s // 2
        else:
            s = 3 * s + 1
        res += 1

print(res+3)

Submission status: Wrong Answer

Solution code:
s = int(input())
L = set([s])
now = s
for i in range(1,1000000):
  if now%2 == 0:
    now = now // 2
  else:
    now = 3 * now + 1
  if now in L:
    print(s)
    break
  else:
    L.add(now)

Submission status: Wrong Answer

Solution code:
s = int(input())
L = set([s])
now = s
for i in range(1000000):
  if now%2 == 0:
    now = now // 2
  else:
    now = 3 * now + 1
  if now in L:
    print(s)
    break
  else:
    L.add(now)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [n]
count = 0
while 1:
    if n % 2 == 0:
        a.append(int(n/2))
        n = n/2
    else:
        a.append(int(3*n + 1))
        n = 3*n + 1
    if a[count-1] == 1 and a[count] == 4:
        break
    count += 1
if n==1 or n==2:
    print(4)
else:
    print(count+1)

Submission status: Wrong Answer

Solution code:
s = int(input())
l = [s]
tmp = 0
ans = 0
for i in range(1,1000000):
  if l[-1] % 2 == 0:
    tmp = l[-1]/2
    l.append(tmp)
    if l.count(tmp) == 2:
      ans = len(l)-1
      break
  else:
    tmp = 3*l[-1]+1
    l.append(tmp)
    if l.count(tmp) == 2:
      ans = len(l)-1
      break
print(ans)

Submission status: Wrong Answer

Solution code:
s=int(input())
l=[]
l.append(s)
ans=[]
c=1
for i in range(10000000000):
    if l[c-1]%2==0:
        l.append(int(l[c-1]/2))
    else:
        l.append(int(l[c-1]*3+1))
    for v in range(len(l)):
        ans.append(l.count(l[v]))
    if 2 in ans:
        break
    c+=1
print(c)

Submission status: Wrong Answer

Solution code:
s = int(input())

def cou(a):
    if a % 2 == 0:
        a /= 2
    else:
        a = 3*a +1
    return a

a_list = []
a = cou(s)
while True:
    if a in a_list:
        print(len(a_list)+2)
        break
    else:
        a_list.append(a)
    a = cou(a)

Submission status: Wrong Answer

Solution code:
def func(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3 * n + 1

s = int(input())
a = dict()
a[0] = s
a[1] = a[0]

b = dict()
b[0] = s

for i in range(1,1000001):
  a[i] = func(a[i-1]) 
  if a[i] in b.keys():
    print(i+1)
    break
  else:
    b[a[i]] = 1

Submission status: Wrong Answer

Solution code:
s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

while (len(l)==len(set(l))):
  i+=1
  s = func(s)
  l.append(func(s))
print(i+1)

Submission status: Wrong Answer

Solution code:
s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

while (len(l)==len(set(l))):
  i+=1
  l.append(func(s))
print(i)

Submission status: Wrong Answer

Solution code:
s = int(input())

a_list = []
a_list.append(s)
while True:
    if s%2 ==0:
        if s/2 in a_list:
            print(len(a_list)+1)
            break
        else: 
            a_list.append(s/2)
            s = s/2
    elif s%2 !=0:
        if (3*s)+1 in a_list:
            print(len(a_list)+1)
            break
        else:
            a_list.append((3*s)+1)
            n = (3*s)+1

Submission status: Wrong Answer

Solution code:
s = int(input())
f = [s]
i = 1
n = s
while(i<=1000000):
  if n % 2 == 0:
    f.append(int(n/2))
  else:
    f.append(int(3*n+1))
  n = int(f[i])
  i = i + 1  
f_ = list(set(sorted(set(f), key=f.index)) - set([i for i in list(set(f)) if f.count(i) == 1]))
count = 0
for i in range(len(f)):
  if f[i] == f_[0]:
    count = count + 1
    if count == 2:
      break
print(i-1)

Submission status: Wrong Answer

Solution code:
inp = int(input())
li = [0]
i = 0
while True:
  if inp % 2 == 0:
    te = inp/2
    te = int(te)
    pass
  else:
    te = int(inp * 3 + 1)
  if te in li:
    print(int(len(li)+1))
    break
  else:
    li.append(te)
    inp = te

Submission status: Wrong Answer

Solution code:
s = int(input())
f = [s]
i = 1
n = s
while(i<1000000):
  if n % 2 == 0:
    f.append(int(n/2))
  else:
    f.append(3*n+1)
  n = f[i]
  i = i + 1
f_ = list(set(sorted(set(f), key=f.index)) - set([i for i in list(set(f)) if f.count(i) == 1]))
count = 0
ans = []
for i in range(len(f)):
  if f[i] == f_[0]:
    count = count + 1
    if count == 2:
      ans.append(i)
print(min(ans)-1)

Submission status: Wrong Answer

Solution code:
a = int(input())
i = 1
while True:
    if a%2 == 1:
        a = 3*a + 1
    else:
        a = a/2
    i += 1
    if a == 4:
        break
print(i+3)

Submission status: Wrong Answer

Solution code:
s = int(input())
f = [s]
i = 1
n = s
while(i<=1000000):
  if n % 2 == 0:
    f.append(int(n/2))
  else:
    f.append(3*n+1)
  n = f[i]
  i = i + 1  
f_ = list(set(sorted(set(f), key=f.index)) - set([i for i in list(set(f)) if f.count(i) == 1]))
count = 0
for i in range(len(f)):
  if f[i] == f_[0]:
    count = count + 1
    if count == 2:
      break
print(i-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [n]
count = 0
while 1:
    if n % 2 == 0:
        a.append(int(n/2))
        n = n/2
    else:
        a.append(int(3*n + 1))
        n = 3*n + 1
    count += 1
    if count > 0:
        if a[count-1] == 1:
            if a.count(4) == 2:
                break

print(count+1)

Submission status: Wrong Answer

Solution code:
s=int(input())

line=[]
count=1

while  s not in line:
    line.append(s)
    count+=1
    if s%2==0:
        s=s//2
    else:
        s=3*s +1

print(s)

Submission status: Wrong Answer

Solution code:
l=[]
s=int(input())
l.append(s)
c=1
i=0
a=0
kari_1=0
kari_2=0
while i==0:
    a=l[c-1]
    if a%2==0:
       kari_1=int(a/2)
       l.append(kari_1)
    elif a%2==1:
        kari_2=int(a*3+1)
        l.append(kari_2)
    if kari_1 in l[:-1] or kari_2 in l[:-1]:
        i+=1
    c+=1
print(c)

Submission status: Wrong Answer

Solution code:
s = int(input())
f = [s]
i = 1
n = s
while(i<1000000):
  if n % 2 == 0:
    f.append(int(n/2))
  else:
    f.append(3*n+1)
  n = f[i]
  i = i + 1  
f_1 = [i for i in list(set(f)) if f.count(i) == 1]
f_2 = sorted(set(f), key=f.index)
f_ = list(set(f_2) - set(f_1))
ans = [j for j, x in enumerate(f) if x == f_[0]]
print(ans[1]-1)

Submission status: Wrong Answer

Solution code:
from sys import stdin

def func(n):
    if n % 2:
        ret = 3 * n + 1
    else:
        ret = n // 2
    return ret

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

    if S == 4:
        print(4)
    elif S == 2:
        print(5)
    elif S == 1:
        print(6)
    else:
        prev = S
        i = 2
        while 1:
            n = func(prev)
            if n == 4:
                print(i + 3)
                break
            prev = n
            i += 1

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
inp = int(input())
li = [0]
i = 0
while True:
  te = inp/2
  if te.is_integer():
    te = int(te)
    pass
  else:
    te = int(inp * 3 + 1)
  if te in li:
    print(int(len(li)+1))
    break
  else:
    li.append(te)
    inp = te

Submission status: Wrong Answer

Solution code:
s = int(input())
a = []
a.append(s)

for i in range(1, 1000000, 1):
    if(a[i-1] % 2 == 0):
        a.append(a[i-1] / 2)
    else:
        a.append((3 * a[i-1]) + 1)
    for j in range(i-1, 0, -1):
        if(a[j] == a[i]):
            print(int(i+1))
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
c = 1
if n < 3:
  print(4)
else:
  while n != 4:
    if n % 2 == 0:
      n //= 2
    else:
      n = 3*n + 1
    c += 1
print(c+3)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [n]
count = 0
while 1:
    if n % 2 == 0:
        a.append(int(n/2))
        n = n/2
    else:
        a.append(int(3*n + 1))
        n = 3*n + 1
    if count > 0:
        if a[count-1] == 1 and a[count] == 4:
            break
    count += 1
print(count+1)

Submission status: Wrong Answer

Solution code:
s = int(input())

a = []
a.append(s)
count = 0
while True:
  count+=1
  if s %2 == 0:
    s=s//2
  else:
    s= 3*s+1
  if s in a:
    print(count)
    break
  a.append(s)

Submission status: Wrong Answer

Solution code:
s = int(input())

a = []
a.append(s)
count = 0
while True:
  count+=1
  if s %2 == 0:
    s=s//2
  else:
    s= 3*s+1
  if s in a:
    print(count)
    break
  a.append(s)
print(a)

Submission status: Wrong Answer

Solution code:
s = int(input())

a = []
a.append(s)
count = 1
while True:
  count+=1
  if s %2 == 0:
    s=s//2
  else:
    s= 3*s+1
  if s in a:
    print(count)
    break
  a.append(s)
print(a)

Submission status: Wrong Answer

Solution code:
from sys import stdin

def func(n):
    if n % 2:
        ret = 3 * n + 1
    else:
        ret = n // 2
    return ret

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

    prev = S
    i = 2
    while 1:
        n = func(prev)
        if n == 4:
            print(i + 3)
            break
        prev = n
        i += 1

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
inp = int(input())
li = [0]
i = 0
while True:
  te = inp/2
  if te.is_integer():
    te = int(te)
    pass
  else:
    te = int(inp * 3 + 1)
  if te in li:
    print(int(len(li)+1))
    break
  li.append(te)
  inp = te

Submission status: Wrong Answer

Solution code:
s = int(input())
s = max(min(s, 100), 1)

f = lambda x: x * 0.5 if x % 2 == 0 else 3*x + 1
array = [s]
while s != 1:
    s = f(int(s))
    array.append(s)
array.append(4)
freq = len(array)
idx = 0
for n, i in enumerate(array):
    for j in array[n:]:
        if i == j:
            idx = n + 1
            break
print(idx)

Submission status: Wrong Answer

Solution code:
s = int(input())
a = []
a.append(s)

for i in range(10000000):
    if(a[i] % 2 == 0):
        a.append(a[i] / 2)
    else:
        a.append((3 * a[i]) + 1)
    for j in range(i, 0, -1):
        if(a[j] == a[i+1]):
            print(int(i+2))
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [n]
count = 0
while 1:
    if n % 2 == 0:
        a.append(int(n/2))
        n = n/2
    else:
        a.append(int(3*n + 1))
        n = 3*n + 1
    if a[count-1] == 1 and a[count] == 4:
        break
    count += 1
print(count+1)

Submission status: Wrong Answer

Solution code:
s = int(input())
a = []
a.append(s)

for i in range(1000000):
    if(a[i] % 2 == 0):
        a.append(a[i] / 2)
    else:
        a.append((3 * a[i]) + 1)
    for j in range(i, 0, -1):
        if(a[j] == a[i+1]):
            print(int(i+2))
            exit()

Submission status: Wrong Answer

Solution code:
s=int(input())
a=[s]
while(True):
  i=0
  n=0
  if a[i]%2==0:
    n=a[i]//2
  else:
    n=a[i]*3+1
  if n in a:
    print(a.index(n)+1)
    break
  i+=1
  a.append(n)

Submission status: Wrong Answer

Solution code:
s = int(input())
s = max(min(s, 100), 1)

f = lambda x: x * 0.5 if x % 2 == 0 else 3*x + 1
array = [s]
while s != 1:
    s = f(int(s))
    array.append(s)
array.append(4)
freq = len(array)
idx = 0
for n, i in enumerate(array):
    for j in array[n:]:
        if s == j:
            idx = n + 2
            break
print(idx)

Submission status: Wrong Answer

Solution code:
a=int(input())
count=1
if a==1:
  count+=3
elif a==2:
  count+=2
else:
  count+=1
  while a!=1:
    if a%2==0:
        a=a/2
        count+=1
    else:
        a=3*a+1
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [n]
count = 0
while 1:
    if n % 2 == 0:
        a.append(int(n/2))
        n = n/2
    else:
        a.append(int(3*n + 1))
        n = 3*n + 1
    if count > 1:
        if a[count-1] == 1 and a[count] == 4:
            break
    count += 1
print(count+1)

Submission status: Wrong Answer

Solution code:
n=int(input())
count=1
while(n!=4):
    if(n%2==0):
        n=n/2
        count+=1
    if(n%2==1):
        n=3*n+1
        count+=1
if(n>2):
    print(count+3)
else:
    print(4)

Submission status: Wrong Answer

Solution code:
s = int(input())
ls = [s]
for i in range(1, 1000010, 1):
  if ls[-1]%2 == 1:
    ls.append(int(ls[-1]*3+1))
  else:
    ls.append(int(ls[-1]/2))
print(ls.index(4)+4)

Submission status: Wrong Answer

Solution code:
s = int(input())
ls = [s]
for i in range(1, 120, 1):
  if ls[-1]%2 == 1:
    ls.append(int(ls[-1]*3+1))
  else:
    ls.append(int(ls[-1]/2))
print(ls.index(4)+4)

Submission status: Wrong Answer

Solution code:
n=int(input())
count=1
if(n>2):
    while(n!=4):
        if(n%2==0):
            n=n/2
            count+=1
        if(n%2==1):
            n=3*n+1
            count+=1
else:
    print(4)
print(count+3)

Submission status: Wrong Answer

Solution code:
s=int(input())
#print(s)

def add(x):
    y=int(x/2)
    return y

def even(x):
    y=3*x+1
    return y

cnt=0
flag=0
for i in range(1000000):
    if flag==0:
        if s%2==0:
            s=add(s)
            cnt+=1
            if s==4:
                flag=1
        else:
            s=even(s)
            cnt+=1
            if s==4:
                flag=1

print(cnt+4)

Submission status: Wrong Answer

Solution code:
a=int(input())
count=1
while a!=1:
    if a%2==0:
        a=a//2
        count+=1
    else:
        a=3*a+1
        count+=1
print(int(count+1))

Submission status: Wrong Answer

Solution code:
inp = int(input())
li = [0]
i = 0
while True:
  te = inp/2
  if te.is_integer():
    pass
  else:
    te = inp * 3 + 1
  if te in li:
    print(int(len(li)+1))
    break
  li.append(te)
  inp = te

Submission status: Wrong Answer

Solution code:
from sys import stdin

def func(n):
    if n % 2:
        ret = 3 * n + 1
    else:
        ret = n // 2
    return ret

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

    a = [0, S]
    for _ in range(2, 100):
        n = func(a[-1])
        a.append(n)
        if n == 1:
            a.append(4)
            break

    for i, n in enumerate(a):
        try:
            m = a.index(n, i + 1)
            print(m)
            break
        except:
            pass

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
s = int(input())

a = []
count = 1
while True:
  count+=1
  if s %2 == 0:
    s=s//2
  else:
    s= 3*s+1
  if s in a:
    print(count)
    break
  a.append(s)

Submission status: Wrong Answer

Solution code:
s=int(input())
dic={}
count=0
while True:
        if s%2==0:
                if str(s//2) not in dic:
                        dic[str(s//2)]=1
                        count+=1
                        s=s//2
                else:
                        break
        else:
                if str(s*3+1) not in dic:
                        dic[str(s*3+1)]=1
                        count+=1
                        s=s*3+1
                else:
                        break
print(count+2)

Submission status: Wrong Answer

Solution code:
si = int(input())
s = si
li = []
i = 1

while True:
    i += 1
    li.append(s)

    if s == 1:
        s = si 
    elif s % 2 == 0:
        s = s / 2
    elif s % 2 != 0:
        s = 3 * s + 1

    if s in li:
        break

print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
c = 0
while n != 4:
  if n % 2 == 0:
    n //= 2
  else:
    n = 3*n + 1
  c += 1
if n == 4: 
  print(4)
else:
  print(c)

Submission status: Wrong Answer

Solution code:
s = []
s.append(int(input()))
A = set()
i = 0

while True:
    if s[i] % 2 == 0:
        s.append(s[i] // 2)
    else:
        s.append(3*s[i] + 1)
    if s[i + 1] in A:
        print(i + 2)
        break
    else:
        A.add(s[i + 1])
    i += 1

Submission status: Wrong Answer

Solution code:
inp = int(input())
li = [0]
i = 0
while i == 0:
  te = inp/2
  if te.is_integer():
    pass
  else:
    te = inp * 3 + 1
  if te in li:
    print(int(len(li)+1))
    i = 1
  li.append(te)
  inp = te

Submission status: Wrong Answer

Solution code:
s = int(input())


memo = {}
memo[s] = 1
 
memo = {}
for i in range(10000000):
  if s%2==0:
    s = s//2
    if s in memo:
      print(i+2)
      break
    memo[s] = 1
  else:
    s = 3*s+1
    if s in memo:
      print(i+2)
      break
    memo[s] = 1

Submission status: Wrong Answer

Solution code:
n=int(input())
count=1
while(n!=4):
    if(n%2==0):
        n=n/2
        count+=1
    if(n%2==1):
        n=3*n+1
        count+=1
print(count+3)

Submission status: Wrong Answer

Solution code:
i = int(input())
count = 0

def func1(n):
  return n / 2

def func2(n):
  return 3 * n + 1

while i > 1:
  if i % 2 == 0:
    i = func1(i)
    count = count + 1
  elif i % 2 == 1:
    i = func2(i)
    count = count + 1
else:
  print(count + 2)

Submission status: Wrong Answer

Solution code:
s = int(input())

a = []
a.append(s)
b = {}

ans = 1000000
for i in range(1, 1000000):
    if a[i - 1] % 2 == 0:
        a.append(int(a[i - 1] / 2))
        if a[i - 1] in b:
            b[a[i - 1]] = b[a[i - 1]] + 1
            if b[a[i - 1]] > 1:
                ans = i
                break
        else:
            b[a[i - 1]] = 1

    else:
        a.append(3 * a[i - 1] + 1)

print(ans)

Submission status: Wrong Answer

Solution code:
s = int(input())
s = max(min(s, 100), 1)

f = lambda x: x * 0.5 if x % 2 == 0 else 3*x + 1
s2 = s
array = list()
while s2 != 1:
    s2 = f(int(s2))
    array.append(s2)
freq = len(array)
init = 1000000
for n, v in enumerate(array):
    if s == v:
        init = n
        break
length = min(freq + 2, init + 2)
print(length)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(200000)


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


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


def solve():
    s = ii()
    d = {}
    for i in range(1, 10000000):
        s = f(s)
        if d.get(s) is None:
            d[s] = 0
        else:
            return i + 1


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

Submission status: Wrong Answer

Solution code:
a = int(input())

num_list = [a]
init_flag = True
while True:
	num = num_list[-1]
	if num%2 == 0:
		new_num = int(num/2)
	else:
		new_num = int(3*num+1)

	if not init_flag and new_num in num_list:
		print(num_list.index(num))
		break
	num_list.append(new_num)
	init_flag = False
	print(num_list)

Submission status: Wrong Answer

Solution code:
s = int(input())
a = [s]

counter = 2
while True:
    if a[-1] % 2 == 0:
        temp = int(a[-1] / 2)
    else:
        temp = int(3 * a[-1] + 1)
        
    print(temp)
    
    if temp in a:
        break
        
    counter += 1
    a.append(temp)
    
print(counter)

Submission status: Wrong Answer

Solution code:
def f(n):
  if n % 2 == 0:
    return n/2
  else:
    return 3 * n + 1

s = int(raw_input())
i = 1
while s != 4:
  s = f(s)
  i += 1
print i+3

Submission status: Wrong Answer

Solution code:
s = int(input())
s = max(min(s, 100), 1)

f = lambda x: x * 0.5 if x % 2 == 0 else 3*x + 1
s2 = s
array = list()
while s2 != 1:
    s2 = f(int(s2))
    array.append(s2)
freq = len(array)
init = 1000000
for n, v in enumerate(array):
    if s == v:
        init = n
        break
length = min(freq + 2, init)
print(length)

Submission status: Wrong Answer

Solution code:
s=int(input())
#print(s)

def add(x):
    y=int(x/2)
    return y

def even(x):
    y=3*x+1
    return y

cnt=0
flag=0
for i in range(120):
    if flag==0:
        if s%2==0:
            s=add(s)
            cnt+=1
            if s==4:
                flag=1
        else:
            s=even(s)
            cnt+=1
            if s==4:
                flag=1

print(cnt+4)

Submission status: Wrong Answer

Solution code:
s = int(input())
a = [s]

counter = 2
while True:
    if a[-1] % 2 == 0:
        temp = int(3 * a[-1] + 1)
    else:
        temp = int(a[-1] / 2)
        
    print(temp)
    
    if temp in a:
        break
        
    counter += 1
    a.append(temp)
    
print(counter)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(200000)


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


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


memo = []


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


def solve():
    s = ii()
    d = {}
    for i in range(1, 10000000):
        s = f(s)
        if d.get(s) is None:
            d[s] = i + 1
        else:
            return d[s]


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

Submission status: Wrong Answer

Solution code:
s=int(input())
a=[s]
k=1
while k>0:
    if s%2==0:
        x=int(s/2)
        s=x
        a.append(x)
    else:
        x=int(3*s+1)
        s=x
        a.append(int(3*s+1))
    for i in range(len(a)-1):
        if a[len(a)-1]==a[i]:
            print(len(a)-1)
            k=0

Submission status: Wrong Answer

Solution code:
S=int(input())
l=[0]*1000000
l[0]=0
l[1]=S
for i in range(2,1000000):
    if l[i-1]%2==0:
       l[i]=l[i-1]//2
    else:
        l[i]=3*l[i-1]+1
    print(l[i])
    for j in range(1,i-1):
        if l[i]==l[j]:
            print(i)
            exit()

Submission status: Wrong Answer

Solution code:
# import sys
x = int(input())
nums = []
ans = 1
while True:
    if x % 2 == 0:
        ans += 1
        if x/2 in nums:
            print(ans)
            # sys.exit()
            break
        nums.append(x/2)
        x = x/2
    if x % 2 == 1:
        ans += 1
        if x*3+1 in nums:
            print(ans)
            # sys.exit()
            break
        nums.append(x*3+1)
        x = x*3+1

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(200000)


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


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


memo = []


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


def solve():
    s = ii()
    d = {}
    for i in range(1, 1000001):
        s = f(s)
        if d.get(s) is None:
            d[s] = 0
        else:
            return i + 1


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

Submission status: Wrong Answer

Solution code:
def f(a):
  if a%2 == 0:
    return a//2
  else:
    return 3*a+1

s = int(input())
a = [s]

for i in range(2, 101):
  a.append(f(a[i-2]))
  if a[i-1] in a[:i-1]:
    print(i)
    break

Submission status: Wrong Answer

Solution code:


A = [0, 5, 5, 9, 5, 7, 10, 18, 5, 21, 8, 16, 11, 11, 19, 19, 6, 14, 22, 22, 9, 9, 17, 17, 12,25, 12, 113, 20, 20, 20, 108, 7, 28, 15, 15, 23, 23, 23, 36, 10, 111, 10, 31, 18, 18, 18,106, 13, 26, 26, 26, 13, 13, 114, 114, 21, 34, 21, 34, 21, 21, 109, 109, 8, 29, 29, 29, 16, 16, 16, 104, 24, 117, 24, 16, 24, 24, 37, 37, 11, 24, 112, 112, 11, 11, 32, 32, 19, 32,19, 94, 19, 19, 107, 107, 14, 120, 27, 27, 27]

print(A[int(input())])

Submission status: Wrong Answer

Solution code:
s = int(input())
s = max(min(s, 100), 1)

f = lambda x: x * 0.5 if x % 2 == 0 else 3*x + 1
array = list()
while s != 1:
    s = f(int(s))
    array.append(s)
print(len(array) + 2)

Submission status: Wrong Answer

Solution code:
s = int(input())

f = lambda x: x * 0.5 if x % 2 == 0 else 3*x + 1
array = list()
while s != 1:
    s = f(int(s))
    array.append(s)
print(len(array) + 2)

Submission status: Wrong Answer

Solution code:
def fn(num):
    if num % 2 == 0:
        return num / 2
    else:
        return 3 * num + 1

s = int(input())
c4 = 0
cnt = 1
while True:
    if s == 4:
        c4 += 1
        if c4 == 2: break
    cnt += 1
    s = fn(s)
print(cnt)

Submission status: Wrong Answer

Solution code:
s = int(raw_input())

i = 1
a = s

while True:
    if a == 1:
        print(i+1)
        break
    if a % 2 == 0:
        a = a/2
    else:
        a = 3*a +1
    i += 1

Submission status: Wrong Answer

Solution code:
import sys
s=int(input())
a=[0]*100
for i in range(100):
    if i==0:
        a[0]=s
    else:
        if a[i-1]%2==0:
            a[i]=a[i-1]/2
        else:
            a[i]=3*a[i-1]+1

for i in range(100):
    for j in range(i+1,100):
        if a[i]==a[j]:
            print(j+1)
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
s = int(input())
a = [s]
m = 0
for i in range(1, 1000001):
    if a[i-1] == 1:
        m = i+1
        break
    elif a[i-1]%2 == 0:
        a.append(int(a[i-1]/2))
    else:
        a.append(3*a[i-1]+1)
print(m)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
s=int(input())
count=1
while s != 4:
    if s % 2 == 1:
        s = 3*s + 1
    else:
        s = s // 2
    count+=1
print(count + 3)

Submission status: Wrong Answer

Solution code:
s = int(input())

l = []

for i in range(10000000):

    if s%2 == 0:
        if s//2 in l:
            res = i
            break
        l.append(s // 2)
        
        s = s // 2
        
    else:
        if 3*s+1 in l:
            res = i
            break
        l.append(3*s+1)
        s = 3*s + 1
        
print(res+2)

Submission status: Wrong Answer

Solution code:
s = int(input())
list = []
for i in range(100000):
    if i == 0:
        list.append(s)
    else:
        if list[i-1] % 2 == 0:
            temp = int(list[i-1] / 2)
        else:
            temp = int(list[i-1]) * 3 + 1
        list.append(temp)
    if list[i] == 4:
        break
print(len(list)+3)

Submission status: Wrong Answer

Solution code:
s = int(input())

for i in range(1000000):
    if s % 2 == 0:
        s /= 2
    elif s % 2 == 1:
        s = 3 * s + 1

    if s == 4:
        print(i+5)
        break

Submission status: Wrong Answer

Solution code:
s = int(input())
count = 1
while s != 4:
	if s % 2 == 0:
		s /= 2
	else:
		s = 3 * s + 1
	count += 1
print(count + 3)

Submission status: Wrong Answer

Solution code:
s = int(input())
list = []
for i in range(1000):
    if i == 0:
        list.append(s)
    else:
        if list[i-1] % 2 == 0:
            temp = int(list[i-1] / 2)
        else:
            temp = int(list[i-1]) * 3 + 1
        list.append(temp)
    if list[i] == 4:
        break
print(len(list)+3)

Submission status: Wrong Answer

Solution code:
s = int(input())
a = []
a.append(s)
while not 1 in a:
    if s % 2 == 0:
        s /= 2
        a.append(round(s))
    else:
        s = 3 * s + 1
        a.append(round(s))
print(len(a)+1)

Submission status: Wrong Answer

Solution code:
now = int(input())
ans = 0
if now == 1:
    ans = 2
elif now == 2:
    ans = 3
else:
    for i in range(1000000):
        if now == 4:
            ans = i + 4
            break
        if now % 2 == 0:
            now = now // 2
        else:
            now = 3 * now + 1
print(ans)

Submission status: Wrong Answer

Solution code:
s = int(input())
count=0
flag=0
n = s
while flag<2:
    count+=1
    if n%2 ==0:
        n/=2
    else:
        n=3*n+1

    if n ==4:
        flag+=1
    if flag==2:
        break
        
    
    
print(count+1)