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:
s = int(input())
moto = s
count = 0
while s!=1:
  if s%2==0:
    s /= 2
  else:
    s = s*3+1
  count += 1
if moto == 1:
  print(4)
elif moto == 2:
  print(2)
else:
  print(count+2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def I(): return int(input())
N = I()
ans = 0
a = [N]
set_a =set()
i = 0
while 1:
    i += 1
    if a[i-1]%2==0:
        a.append(a[i-1]//2)
    else:
        a.append(a[i-1]*3+1)
    if a[i] in set_a:
        print(i+1)
        break
    else:
        set_a.add(a[i])

Submission status: Wrong Answer

Solution code:

import numpy as np
import sys

input = sys.stdin.readline

s = int(input())

ans = 1

while s != 4:
    if s%2 == 0 :
        s = s/2
    else:
        s = 3*s + 1
    
    ans+=1


print(ans+3)

Submission status: Wrong Answer

Solution code:

import numpy as np
import sys

input = sys.stdin.readline

s = int(input())

ans = 1

while s != 4:
    if s%2 == 0 :
        s = s/2
    else:
        s = 3*s + 1
    
    ans+=1
    print(s)
    if ans == 10:
        break


print(ans+3)

Submission status: Wrong Answer

Solution code:

import numpy as np
import sys

input = sys.stdin.readline

s = int(input())

ans = 1
cnt = 0
if s == 4:
    cnt +=1
i = 0
while (s != 4 or cnt < 2):
    ans +=1
    if s % 2 == 0:
        s = int(s/2)
    else:
        s = 3*s + 1
    
    if s == 4:
        cnt +=1


print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
d = defaultdict(int)
import sys
sys.setrecursionlimit(10**8)
def f(n,i):
  d[n]+=1
  if d[n]==2:
    return i
  if n%2==0:
    x=n//2
  else:
    x=3*n+1
  return f(x,i+1)
print(f(int(input()),0))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
d = defaultdict(int)
import sys
sys.setrecursionlimit(10**8)
def f(n,i):
  if n%2==0:
    x=n//2
  else:
    x=3*n+1
  d[x]+=1
  if d[x]==2:
    return i+1
  return f(x,i+1)
print(f(int(input()),1))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
d = defaultdict(int)
import sys
sys.setrecursionlimit(10**8)
def f(n,i):
  if n%2==0:
    x=n//2
  else:
    x=3*n+1
  d[x]+=1
  if d[x]==2:
    return i+1
  f(x,i+1)
print(f(int(input()),0))

Submission status: Wrong Answer

Solution code:
s = int(input())

List = []
List.append(s)



for i in range(1000000):
    if List[i]%2 == 0:
        List.append(List[i]/2)
    else:
        List.append(List[i]*3+1)
    if List[i+1] == 4:
        Answer=i+5
        break

print(Answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())

count = 1

x = [0] * 1000000
while True:
    if s % 2 == 0:
        s = s / 2
    else:
        s = 3 * s + 1
    count += 1
    if x[int(s)] == 1:
        print(count)
        break
    else:
        x[int(s)] = 1

Submission status: Wrong Answer

Solution code:
s = int(input())

a = []
i = 1
while s not in a:
    a.append(s)
    if s%2 == 1:
        s=3*s+1
    else:
        s=s/2
    i+=1
    if i >= 10:
        break

print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N == 1 or N == 2:
	print(3)
else:
	m = 0
	while N > 1:
		if N % 2 == 0:
			N = N // 2
		else:
			N = 3 * N + 1
		m += 1
	print(m+2)

Submission status: Wrong Answer

Solution code:
N = int(input())

m = 0

while 2 < N:
	if N % 2 == 0:
		N = N // 2
	else:
		N = 3 * N + 1
	m += 1

print(m+3)

Submission status: Wrong Answer

Solution code:
s = int(input())

def odd(i):
    return 3*i+1

def even(i):
    return i/2

lib = {}

index = 1

while True:
    if s % 2 == 0:
        s = even(s)
    else:
        s = odd(s)
    
    if s not in lib.keys():
        lib[s] = index
        index += 1
    else:
        break

print(index+1)

Submission status: Wrong Answer

Solution code:
def Collatz_Problem(n):

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

    return ans

def main():
    n = int(input())
    print(Collatz_Problem(n))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    s = int(input())
    a_set = set()
    a = s
    for i in range(1, 1000000):
        if a % 2 == 0:
            a = a // 2
        else:
            a = a * 3 + 1
        if a in a_set:
            print(i + 1)
            exit()
        a_set.add(a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
s = int(input())

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

a = []
a.append(s)
for i in range(100):
    tmp = collatz(a[i])
    if tmp in a:
        print(len(a)+1)
        exit()
    a.append(tmp)

Submission status: Wrong Answer

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

def gold(x):
    if x % 2 == 0:
        return int(x/2)
    else:
        return int(3*x + 1)

while lst[-1] != 1:
    lst.append(gold(int(lst[-1])))

print(len(lst) + 1 )

Submission status: Wrong Answer

Solution code:
s = int(input())
check = [0]*(10**6)
check[s] == 1
i = 2
while True:
  if s % 2 == 0:
    s //= 2
  else:
    s = 3*s+1
  if check[s]:
    break
  check[s] = 1
  i += 1
print(i)

Submission status: Wrong Answer

Solution code:
s = int(input())
ans = [s]
fr = 0
for i in range(1,10**4):
    if s  == 2:
        print(4)
        break
    if fr > 0:
        break
    if ans[i-1] % 2 == 0:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(ans[i-1]//2)
    else:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(3*ans[i-1]+1)

Submission status: Wrong Answer

Solution code:
s = int(input())
ans = [s]
fr = 0
for i in range(1,10**12):
    if fr > 0:
        break
    if ans[i-1] % 2 == 0:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(ans[i-1]//2)
    else:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(3*ans[i-1]+1)

Submission status: Wrong Answer

Solution code:
s = int(input())
ans = [s]
fr = 0
for i in range(1,10**4):
    if fr > 0:
        break
    if ans[i-1] % 2 == 0:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(ans[i-1]//2)
    else:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(3*ans[i-1]+1)

Submission status: Wrong Answer

Solution code:
s = int(input())
sl = [s]
count = 2
for i in range(100):
  s_next = 0
  if sl[i]%2 == 0:
    s_next = sl[i]//2
    sl.append(s_next)
  else:
    s_next = 3*sl[i]+1
    sl.append(s_next)
  if sl.count(s_next) > 1:
    print(count)
    break
  count += 1

Submission status: Wrong Answer

Solution code:
s=int(input())
S=[]
x=0
y=0
z=0
m=0
while True:
    if s%2==0:
        s=s//2
        x+=1
        if s==4:
            y+=1
        elif s==2:
            z+=1
        elif s==1:
            m+=1
    else:
        s=3*s+1
        x+=1
        if s==4:
            y+=1
        elif s==2:
            z+=1
        elif s==1:
            m+=1
    if y==2 or z==2 or m==2:
        break

print(x+1)

Submission status: Wrong Answer

Solution code:
s=int(input())
S=[]
x=0
y=0
while True:
    if s%2==0:
        s=s//2
        x+=1
        if s==4:
            y+=1
    else:
        s=3*s+1
        x+=1
        if s==4:
            y+=1
    if y==2:
        break

print(x+1)

Submission status: Wrong Answer

Solution code:
s=int(input())
S=[]
x=0
y=0
for i in range(500):
    if s%2==0:
        s=s//2
        x+=1
        if s==4:
            y+=1
    else:
        s=3*s+1
        x+=1
        if s==4:
            y+=1
    if y==2:
        break
print(x+1)

Submission status: Wrong Answer

Solution code:
s = int(input())
a = set([s])
p = s
n = 0
cnt = 1
while True:
  if n in a:
    print(cnt)
    exit()
  if p&1:
    n = 3*p +1
  else:
    n = p//2
  cnt += 1
  a.add(n)
  p = n

Submission status: Wrong Answer

Solution code:
s = int(input())
a = set([s])
p = s
n = 0
cnt = 0
while True:
  if n in a:
    print(cnt)
    exit()
  if p&1:
    n = 3*p +1
  else:
    n = p//2
  cnt += 1
  a.add(n)
  p = n

Submission status: Wrong Answer

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

s = int(input())
p = 1
a = False#二回目の4の判断
while True:
    s = ABC116B(s)
    p += 1
    if s == 4:
        if a:
            print(p)
            break
        else:
            a = True

Submission status: Wrong Answer

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

s = int(input())
p = 1
while True:
    s = ABC116B(s)
    p += 1
    if s == 1:
        print(p+1)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = int(input())
a_list = [a]
b = 0
for i in range(1000000):
    
    if a_list[i] % 2== 0:
        b = (a_list[i])/2
        if b in a_list:
            print(i+1)
            break
        else:
            a_list.append(b)
    else:
        b = 3 * a_list[i] + 1
        if b in a_list:
            print(i+2)
            break
        else:
            a_list.append(b)

Submission status: Wrong Answer

Solution code:
s = int(input())

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

a = [s]
for i in range(100):
    a_nxt = f(a[i])
    if a_nxt in a:
        print(i+2)
        break
    a.append(a_nxt)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


def func(x):
    global cnt
    cnt += 1
    if x % 2:
        if f[3*x+1]: 
            print(cnt)
            quit()
        else:
            f[3*x+1] = 1
            func(3*x+1)
    else:
        if f[x//2]:
            print(cnt)
            quit()
        else:
            f[x//2] = 1
            func(x//2)


s = I()
f = defaultdict(int)
cnt = 1
func(s)

Submission status: Wrong Answer

Solution code:
S = input()
s = int(S)
lis = [s]

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=1:
    s = func(s)
    lis.append(s)

if S == "1":
    print(4)
elif s == "2":
    print(4)
elif s == "4":
    print(4)
else:
    print(len(lis)+2)

Submission status: Wrong Answer

Solution code:
S = input()
s = int(S)
lis = [s]

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=1:
    print(func(s))
    s = func(s)
    lis.append(s)

if S == "1":
    print(4)
elif s == "2":
    print(4)
elif s == "4":
    print(4)
else:
    print(len(lis)+2)

Submission status: Wrong Answer

Solution code:
S = input()
s = int(S)
lis = [s]

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=1:
    s = func(s)
    lis.append(s)

if S == "1":
    print(4)
elif s == "2":
    print(4)
else:
    print(len(lis)+2)

Submission status: Wrong Answer

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

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=1:
    s = func(s)
    lis.append(s)
    
print(len(lis)+2)

Submission status: Wrong Answer

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

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=4:
    s = func(s)
    lis.append(s)
    
print(len(lis)+4)

Submission status: Wrong Answer

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

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=4:
    print(func(s))
    s = func(s)
    lis.append(s)
    
print(len(lis)+4)

Submission status: Wrong Answer

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

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=4:
    print(func(s))
    s = func(s)
    lis.append(s)
    
print(len(lis)+5)

Submission status: Wrong Answer

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

def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1
 
while func(s) !=4:
    print(func(s))
    s = func(s)
    lis.append(s)
    
print(len(lis)+5)

Submission status: Wrong Answer

Solution code:
def main():
  s = int(input())
  #s = input()
  #s = input().split()
  #s = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  #a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  
  while s >= 1:
    if s == 1:
      count += 1
      break
    elif s % 2 == 0:
      s //= 2
      count += 1
    else:
      s = s*3 + 1
      count += 1
  print(count+1)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
s = int(input())


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


pre = s
result = set()
for i in range(1000005):
    current = f(pre)
    if current in result:
        print(i+2)
        break
    result.add(current)
    pre = current

Submission status: Wrong Answer

Solution code:
s = int(input())

tmp_list = [0]*1000000

for i in range(1000000):
    if i == 0:
        tmp = s
        tmp_list[tmp] == 1

    else:
        #print(tmp)
        if tmp % 2 == 0:
            tmp = tmp//2
        else:
            tmp = 3*tmp+1
        
        if tmp_list[tmp] == 0:
            #print('tmp_list')
            #print(tmp_list[tmp])
            tmp_list[tmp] = 1

        elif tmp_list[tmp] == 1:
            #print('break')
            print(i+1)
            break

Submission status: Wrong Answer

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


s = int(input())
i = 1
k = 0
old = []

while 1:
    k = f(s) if i == 1 else f(k)

    if k in old:
        break
    else:
        old.append(k)
        i += 1

print(i+1)

Submission status: Wrong Answer

Solution code:
s = int(input())
l=[]
count = 2

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

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = input().split()
a = int(k[0])

def b(n):
    return int(n/2)
def c(n):
    return int((3*n)+1)

Counter = 0

flag = True
IntSet = set()
IntSet.add(a)
Buffer = int(a)
for i in range(1,1000000+1):
    if Buffer%2 == 0:
        Buffer = b(Buffer)
        Counter+=1
    else:
        Buffer = c(Buffer)
        Counter+=1
    print(Buffer)
    if Buffer in IntSet:
        print(Counter+1)
        break
    else:
        IntSet.add(Buffer)

Submission status: Wrong Answer

Solution code:

import math
import itertools
import statistics
#import collections

#n =  list(map(int, input().split()))
s = int(input())

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

count1 = 0

a = [s]
while count1<2:
    s = calc_f(s)
    a.append(s)
    if s==1:
        count1+=1
    
#print(a)
print(a.index(1)+2)

Submission status: Wrong Answer

Solution code:
s = int(input())
co = []
ans = 1
count = 1
while count == 1:
    if s % 2 == 0:
        s /= 2
        co.append(s)
        ans += 1
       
    else:
        s = 3*s + 1
        co.append(s)
        ans += 1
        
    count = co.count(s)
    if count == 2:
      print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = int(input())

ar = []
flag = 0
count = 0

while flag == 0:
	count = count +1
	if s % 2 == 0:
		s = s//2
	else:
		s = 3* s +1
	if s in ar:
		flag = 1
	else:
		ar.append(s)
#		print(s)

print(count+1)

Submission status: Wrong Answer

Solution code:
s = int(input())

ar = []
flag = 0
count = 0

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

print(count+1)

Submission status: Wrong Answer

Solution code:
s = int(input())

ar = []
flag = 0
count = 0

while flag == 0:
	count = count +1
	if s % 2 == 0:
		s = s//2
	else:
		s = 3* s +1
	if s in ar:
		flag = 1
	else:
		ar.append(s)
#		print(s)

print(count)

Submission status: Wrong Answer

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

a = int(input())
count = 0
i=0
while(count!=2):
    i+=1
    # print("{}".format(a),end=",")
    if a==4:
        count+=1
    a = int(f(a))
print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    s = int(input())
    i = 1
    save_num = []
    while True:
        i += 1

        if s % 2 == 0:
            s = s // 2
        else:
            s = 3 * s + 1

        if s not in save_num:
            save_num.append(s)
        else:
            ans = i
            break

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

test = set()
before = N
for i in range(1, 10**6 + 1):
  current = f(before)
  if(current in test):
    print(i+1)
    exit()
  before = current
  test.add(current)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

s = int(input())

A = defaultdict(int)

n = 1
while True:
  if A[s]:
    print(A[s])
    exit()
  A[s] = n
  if s % 2:
    s = 3 * s + 1
  else:
    s //= 2
  n += 1

Submission status: Wrong Answer

Solution code:
a = int(input())
als = [0]*(100000)
for i in range(0,10**6+2):
    als[a] = 1
    if a%2 == 0:
        a = a//2
    else:
        a = 3*a+1
    if als[a] == 1:
        print(i+2)
        exit()
    print(a)

Submission status: Wrong Answer

Solution code:
s = int(input())

a = [0]*1000000
a[0] = s
i = 1
d = {}
while True:
    if a[i-1] % 2 == 0:
        a[i] = a[i-1] // 2
    else:
        a[i] = 3 * a[i-1] + 1

    if d.get(a[i]) is None:
        d[a[i]] = 1
    else:
        print(i+1)
        exit()

    i += 1

Submission status: Wrong Answer

Solution code:
s = int(input())
def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n + 1
a = s
dp = [a]
li = [0 for i in range(10**6)]
for i in range(1,10**6):
    a = f(dp[i-1])
    dp.append(a)
    li[a]+=1
    if li[a]>1:
        break
print(i+1)

Submission status: Wrong Answer

Solution code:
s = int(input())
def f(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n + 1
a = s
dp = [a]
li = [0 for i in range(10**6)]
for i in range(10**6):
    a = f(dp[i])
    dp.append(a)
    li[a]+=1
    if li[a]>1:
        break
print(i+2)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[]
L.append(N)
i=0
while(1):
	if L[i]==4:
		break
	if L[i]%2==0:
		L.append(L[i]//2)
	if L[i]%2==1:
		L.append(L[i]*3+1)
	i+=1
print(i+4)

Submission status: Wrong Answer

Solution code:
s = int(input())

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

cnt = 1
k = s
while(True):
  if k == 4:
    ans = cnt+3
    break
  k = f(k)
  cnt += 1

print(ans)

Submission status: Wrong Answer

Solution code:
s = int(input())

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

cnt = 1
k = s
while(True):
  k = f(k)
  cnt += 1
  if k == 4:
    ans = cnt+3
    break

print(ans)

Submission status: Wrong Answer

Solution code:
s = int(input())

no=1
cnt=0

if s==4:
    cnt+=1

for i in range(1000000):
    no+=1
    if s%2==0:
        s=int(s/2)
    else:
        s=3*s+1
    #print(s)

    if s==4:
        cnt+=1
    if cnt==2:
        break
print(no)

Submission status: Wrong Answer

Solution code:
s=int(input())
#S=[-1]*200
#S[0]=s
S=[];A=[];f=-1
S.append(s)
i=1;p=-1
while p!=1:
  if S[i-1]%2==0:
    S.append(S[i-1]//2)
    #print(S[i])
  else:
    S.append(S[i-1]*3+1)
    #print(S[i])
  p=S[-1]
  i=i+1
#S.sort()
#print(i,S)
for i in range(len(S)-1):
  for j in range(i+1,len(S)):
    if S[i]==S[j]:
      f=1
      print(j)
      break
if f==-1:
  print(len(S)+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a=[int(input())]
for i in range(1000000):
    n=a[i]
    if n%2==0:
        a.append(n/2)
    else:
        a.append(3*n+1)
    if a[i+1]==4:
        print(i+5)
        break

Submission status: Wrong Answer

Solution code:
a=[int(input())]
for i in range(1000000):
    n=a[i]
    if n%2==0:
        a.append(n/2)
    else:
        a.append(3*n+1)
    if a[i+1]==4:
        print(i+5)
        break
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=int(input())
a=[]
def f(n):
    flag=0
    a.append(n)
    if a[-3:]==[4,2,1]:
        flag=1
    if flag==0:
        if n%2==0:
            n=n//2
            f(n)
        else:
            n=3*n+1
            f(n)
f(s)

for i in range(1,len(a)-1):
    if a[i-1:i+2]==[4,2,1]:
        print(i+3)

Submission status: Wrong Answer

Solution code:
s=int(input())
a=[]
def f(n):
    flag=0
    a.append(n)
    if a[-3:]==[4,2,1]:
        flag=1
    if flag==0:
        if n%2==0:
            n=n//2
            f(n)
        else:
            n=3*n+1
            f(n)
f(s)

for i in range(len(a)):
    if a[i]==4:
        print(i+4)
        exit()

Submission status: Wrong Answer

Solution code:
s=int(input())
i=0
a=[]
def f(n):
    a.append(n)
    if a[-3:]==[4,2,1]:
        print(len(a)+1)
        exit()
    if n%2==0:
        n=n//2
        f(n)
    else:
        n=3*n+1
        f(n)
f(s)

Submission status: Wrong Answer

Solution code:
s=int(input())
i=0
a=[]
def f(n):
    a.append(n)
    print(a)
    if a[-3:]==[4,2,1]:
        print(len(a)+1)
        exit()
    if n%2==0:
        n=n//2
        f(n)
    else:
        n=3*n+1
        f(n)
f(s)

Submission status: Wrong Answer

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

s = int(input())

box = [-1]*(int(1e6+1))

i = 1

while 1:
    if box[collaz(s)] == 1:
        print(i+1)
        break
    else:
        box[collaz(s)] = 1
        s = collaz(s)
        i += 1

Submission status: Wrong Answer

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

s = int(input())

box = [-1]*(int(1e8))

i = 1

while 1:
    if box[collaz(s)] == 1:
        print(i+1)
        break
    else:
        box[collaz(s)] = 1
        s = collaz(s)
        i += 1

Submission status: Wrong Answer

Solution code:
def collatz(n):
    if n%2==0:
        return int(n/2)
    else:
        return 3*n+1
    
a=int(input())
cnt=1
while a !=4:
    a=collatz(a)
    cnt+=1

ans=cnt+3  
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    if s in a:
        print(i+2)
        break
    a[i]=s

Submission status: Wrong Answer

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

    if s in a:
        print(i+2)
        break
    a[i]=s

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=int(input())
count=0
for i in range(10000000):
    if s%2==1:
        s=s*3+1
    else:
        s=s//2
    if s==4:
        count+=1
    if count==2:
        print(i+2)
        break

Submission status: Wrong Answer

Solution code:
s=int(input())
count=0
for i in range(1000):
    if s%2==1:
        s=s*3+1
    else:
        s=s//2
    if s==4:
        count+=1
    if count==2:
        print(i+2)
        break

Submission status: Wrong Answer

Solution code:
s=int(input())
def f(n):
	if n % 2 ==0:
		return int(n/2)
	else:
		return int(3*n+1)
a=[s]
while len(set(a)) == len(a):
		a.append(f(a[-1]))
		print(a)
print(len(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3*n + 1
s = int(input())
a = [0]
a.append(s)
for i in range(1,10**8):
    x = a[-1]
    y = f(x)
    if y in a:
        print(i)
        break
    a.append(y)

Submission status: Wrong Answer

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

def ff(a1, history, n):
    a2 = f(a1)
    n += 1
    if a2 in history:
        return n

    history.append(a2)

    return ff(a2, history, n)

s = int(input())
print(ff(s,[],1))

Submission status: Wrong Answer

Solution code:
s = int(input())

n = s
cnt = 1
while n != 4:
    cnt += 1
    if n % 2 == 0:
        n = n // 2
    else:
        n = (3 * n) + 1

print(cnt + 3)

Submission status: Wrong Answer

Solution code:
s = int(input())

n = s
cnt = 0
ant = 0
while True:
    cnt += 1
    if n % 2 == 0:
        n = n // 2
    else:
        n = (3 * n) + 1
    if n == 4:
        ant += 1
    if ant == 2:
        break

print(cnt + 1)

Submission status: Wrong Answer

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

s = ni()

def collatz(x, i, f):
    if x == 4:
        if f is True:
            return i
        else:
            return collatz(x / 2, i + 1, True)
    if x % 2 == 0:
        return collatz(x / 2, i + 1, f)
    else:
        return collatz(3 * x + 1, i + 1, f)

print(collatz(s, 1, False))