TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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).

Submission attempts (in order):
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))

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

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



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
x = set(n)
cnt = 1

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n //=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)

n = int(input())
x = set(n)
cnt = 1

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n //=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        exit()
    else:
        x.add(n)

n = int(input())
x = set()
cnt = 1
x.add(n)

while True:
    
    cnt += 1
    
    if n%2 == 0:
        n /=2
        
    else:
        n = n * 3 + 1

    if n in x:
        print(cnt)
        break
    else:
        x.add(n)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
A = int(input())
p = A
count = 0
if A = 1:
  count == 0
else:
  count =2
while A != 1:
  if A % 2 == 0:
    A = A // 2
    count = count + 1
  else:
    A = A * 3 + 1
    count = count + 1
print(count)

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

A = int(input())
p = A
C = []
while A not in C:
  C.append(A)
  if A % 2 == 0:
    A = A//2
  else:
    A = A*3+1
print(len(C)+1)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = input()
l = []

while flag=False:
  if tmp in l:
    flag = True
  else:
    if s % 2 == 0:
      tmp = s / 2
      l.append(tmp)
      s = tmp
    else:
      tmp = 3*s +1
      l.append(tmp)
      s = tmp
      
l.sort()
print(l[-2])

s = int(input())
l = []
flag = False
cnt = 0
tmp = 0
while flag==False:
  if tmp in l:
    cnt += 1
    flag = True
  else:
    if s % 2 == 0:
      tmp = s / 2
      l.append(s)
      s = tmp
      cnt += 1
    else:
      tmp = 3*s +1
      l.append(s)
      s = tmp
      cnt += 1
      
print(cnt)



Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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)

a = int(input())
a_list = [a]
b = 0
for i in range(1000001):
    
    
    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)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s=int(input());ans=1
while s==4:
  ans+=1
  if s%2==0:s//=2
  else:s=s*3+1
print(ans+3)

n=int(input())
i=1
s=set()
while n not in s:
  s.add(n)
  i+=1
  if n%2:n=3*n+1
  else:n//=2
print(i)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
memo = [-1]
memo.append(s)
def a(n):
    if memo[n-1] % 2 == 0:
        pre = memo[n-1]/2
        for i in memo:
            if i == pre:
                return n
            else:
                memo.append(pre)
                return a(n+1)
    else:
        pre = 3 * memo[n-1] + 1
        for i in memo:
            if i == pre:
                return n
            else:
                memo.append(pre)
                return a(n+1)

print(a(2))

s = int(input())
memo = [-1]
memo.append(s)
def a(n):
    if memo[n-1] % 2 == 0:
        pre = memo[n-1]/2
        for i in memo:
            if i == pre:
                return n
        memo.append(pre)
        return a(n+1)
    else:
        pre = 3 * memo[n-1] + 1
        for i in memo:
            if i == pre:
                return n
        memo.append(pre)
        return a(n+1)

print(a(2))

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s=int(input())
tmp=[s]
for m in range(2,1000000):
  if tmp[-1]%2 == 0:
    if tmp[-1]/2 in tmp:
      print(tmp, m)
      exit()
    else:
      tmp.append(tmp[-1]/2)
  else:
    if 3*tmp[-1]+1 in tmp:
      print(tmp, m)
      exit()
    else:
      tmp.append(3*tmp[-1]+1)

s=int(input())
tmp=[s]
for m in range(2,1000000):
  if tmp[-1]%2 == 0:
    if tmp[-1]/2 in tmp:
      print(m)
      exit()
    else:
      tmp.append(tmp[-1]/2)
  else:
    if 3*tmp[-1]+1 in tmp:
      print(m)
      exit()
    else:
      tmp.append(3*tmp[-1]+1)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
A = [s]
ans = 1
while True:
    ans = +1
    s = (s/2 if s%2==0 else 3*s+1)
    if s in A:
        break
    A.append(s)

print(ans+1)

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

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())

f = [s]

for i in range(100000):
    if f[i] % 2 == 0:
        s /= 2
    else:
        s = 3 * s + 1
    if s in f:
        print(i)
        break
    else:
        f.append(s)


s = int(input())

f = [s]

for i in range(100000):
    if f[i] % 2 == 0:
        s /= 2
    else:
        s = 3 * s + 1
    if s in f:
        print(i + 2)
        break
    else:
        f.append(s)


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
ss = set()
ss.add(s)
k = 1
while True:
    if s%2 == 0:
        s = s/2
    else:
        s = 3*s + 1
    s = int(s)
    if s in ss:
#         print(s,s)
        break
    ss.add(s)
#     print(s)
    k+=1
    print(s)
print(k+1)

s = int(input())
ss = set()
ss.add(s)
k = 1
while True:
    if s%2 == 0:
        s = s/2
    else:
        s = 3*s + 1
    s = int(s)
    if s in ss:
#         print(s,s)
        break
    ss.add(s)
#     print(s)
    k+=1
#     print(s)
print(k+1)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
lst = []
s = int(input())

while s not in lst:
  lst.append(s)
  if lst[-1] % 2 == 0:
    s = lst[-1] // 2
  else:
    s = 3 * lst[-1] + 1
print(len(lst) + 2)

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

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

while s not in lst:
  lst.append(s)
  if lst[-1] % 2 == 0:
    s = lst[-1] // 2
  else:
    s = 3 * lst[-1] + 1
print(len(lst) + 1)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s=int(input())
l=[]
while(s not in 1):
  l.append(s)
  if s%2==0:s//=2
  else:s=s*3+1
print(len(l)+1)

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

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

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

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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())

li = []
for i in range(200):
    if n%2 == 0:
        n//=2
        li.append(n)
        if len(li) != len(set(li)):
            print(len(li))
            exit()
    else:
        n = 3*n+1
        li.append(n)
        if len(li) != len(set(li)):
            print(len(li))
            exit()

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def col(a):
  if a % 2 == 0:
    return a//2
  else:
    return a*3 + 1

s = int(input())

an = [a]
i = 1
while True:
  i += 1
  an_1 = col(an[-1])
  if an_1 in an:
    break
  an.append(an_1)

print(i)

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

s = int(input())

an = [a]
i = 1
while True:
  i += 1
  an_1 = col(a)
  if an_1 in an:
    break
  an.append(an_1)

print(i)

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

s = int(input())

an = [s]
i = 1
while True:
  i += 1
  an_1 = col(an[-1])
  if an_1 in an:
    break
  else:
    an.append(an_1)

print(i)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
# coding: utf-8

s = int(input())

i = 0
while n > 0:
    if n % 2 = 0:
        n = n / 2
    else:
        n = 3n+1
    if n == 4:
        break
    else:
        i += 1

print(i+4)

# coding: utf-8

s = int(input())

i = 0
while n > 0:
    if n % 2 == 0:
        n = n / 2
    else:
        n = 3n+1
    if n == 4:
        break
    else:
        i += 1

print(i+4)

# coding: utf-8

n = int(input())

i = 1
while n > 0:
    if n == 4 or n == 2 or n == 1:
        break
    i += 1
    if n % 2 == 0:
        n = n / 2
    else:
        n = n*3+1

print(i+3)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())

if s == 1 || s == 2:
    print(4)
elif:
    for i in range(1000000):
        if s == 4:
            print(i + 4)
            break

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







        



s = int(input())

if s == 1 or s == 2:
    print(4)
elif:
    for i in range(1000000):
        if s == 4:
            print(i + 4)
            break

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







        



s = int(input())

if s == 1 or s == 2:
    print(4)
else:
    for i in range(1000000):
        if s == 4:
            print(i + 4)
            break

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







        



Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
res = [s]
idx = 1

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

s = int(input())
res = [s]
idx = 1

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

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

for i in range(2, 1000001):
  if s % 2 == 0:
    s = s / 2
  else:
    s = 3 * s + 1
  
  if s in a:
    print(i)
    break
   
  s.append(s)

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

for i in range(2, 1000001):
  if s % 2 == 0:
    s = s / 2
  else:
    s = 3 * s + 1
  
  if s in a:
    print(i)
    break
   
  a.append(s)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
# ABC116b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = int(input())


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


a = [0, s]

for i in range(2, 10**6):
    num = f(a[i-1])
    a.append(num)
    idx = a.index(num)
    print(a)
    if(idx+1 < i):
        print(i)
        exit()

# ABC116b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = int(input())


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


a = [0, s]

for i in range(2, 10**6):
    num = f(a[i-1])
    a.append(num)
    idx = a.index(num)
    #print(a)
    if(idx+1 < i):
        print(i)
        exit()

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
a = n
b = 0
i = 1
while True:
  if a%2==0:
    b = n//2
  else:
    b = 3*n+1
  i+=1
  a = b
  if b ==4:
    break
print(i)

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

import sys
n = int(input())
if n==4:
    print(4)
    sys.exit()
elif n==2:
    print(4)
    sys.exit()
elif n==1:
    print(4)
    sys.exit()
a = n
b = 0
i = 1
while True:
    if a%2==0:
        b = a//2
    else:
        b = 3*a+1
    i+=1
    a = b
    # print(a)
    if b ==4:
        break
print(i+3)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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
  

from collections import defaultdict

s = int(input())

A = defaultdict(int)

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
# input
s = int(input())


fn = {1: s}
lim = 1000001
for m in range(2, lim):
    if m - 1 % 2 == 0:
        fn[m] = fn[m - 1] // 2
    else:
        fn[m] = 3 * fn[m - 1] + 1
    
    if s not in fn.keys():
        continue
    else:
        if fn[m] == fn[s]:
            print(m)
            break

# input
s = int(input())


fn = {1: s}
lim = 1000001
fs = None
for m in range(2, lim):
    if m % 2 == 0:
        fn[m] = fn[m - 1] // 2
    else:
        fn[m] = 3 * fn[m - 1] + 1

    print(m, fn[m])

    if not fs and m == s: 
        fs = fn[m]
    
    if fs in [fn[k] for k in fn.keys() if k != s]:
        print(m)
        break

# input
s = int(input())


fn = [s] + ([-1] * 999999)
lim = 1000001
fs = None
for m in range(2, lim):
    if m % 2 == 0:
        fn[m] = fn[m - 1] // 2
    else:
        fn[m] = 3 * fn[m - 1] + 1

    print(m, fn[m])

    if not fs and m == s:
        fs = fn[m]

    if fs in (fn[:s] + fn[s + 1:m]):
        print((fn[:s] + fn[s + 1:m]).index(fs))
        break

# input
s = int(input())


fn = [s] + ([-1] * 999999)
lim = 1000001
fs = None
for m in range(2, lim):
    if m % 2 == 0:
        fn[m] = fn[m - 1] // 2
    else:
        fn[m] = 3 * fn[m - 1] + 1

    if not fs and m == s:
        fs = fn[m]

    if fs in (fn[:s] + fn[s + 1:m]):
        print((fn[:s] + fn[s + 1:m]).index(fs))
        break

# input
s = int(input())


lim = 1000001
fn = [-1] * lim 
fn[1] = s
for m in range(2, lim):
    if m % 2 == 0:
        fn[m] = fn[m - 1] // 2
    else:
        fn[m] = 3 * fn[m - 1] + 1

    if fn[m] in fn[1:m]:
        print(fn[1:m].index(fn[m]))
        break

# input
s = int(input())


lim = 1000001



if s == 1 or s == 2:
  print(4)
else:

    c4 = 0
    c = 1
    for m in range(2, lim):
        
        if s == 4:
            c4 += 1

        
        if c4 == 2:
            print(c)
            exit()

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

        
        c += 1

Verdicts: Wrong Answer

Time Limit Exceeded

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
ans = 1
nums = set()
while s not in nums:
  ans += 1
  if s % 2 == 0: s // = 2
  else: s = s * 3 + 1
  nums.add(s)
print(ans)


s = int(input())
ans = 1
nums = set()
while s not in nums:
    ans += 1
    nums.add(s)
    if s % 2 == 0: s //= 2
    else: s = s * 3 + 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
a = [int(input())]
def fc(n):
    if n%2:
        p = 3*n+1
    else:
        p = n//2
    return p

for i in range(1000000):
    f = fc(a[i])
    if f in a:
        m = i+2
        break
    else:
        a.append(f)
        print(a)
print(m)

a = [int(input())]
def fc(n):
    if n%2:
        p = 3*n+1
    else:
        p = n//2
    return p

for i in range(1000000):
    f = fc(a[i])
    if f in a:
        m = i+2
        break
    else:
        a.append(f)
print(m)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

a = int(input())

num_list = [a]
init_flag = True
result = 1
while True:
	result += 1
	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))
		print(result)
		break
	num_list.append(new_num)
	init_flag = False
	

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
ansli = [s]
flg = True
cnt = 2
def f(n):
    if n%2 == 0:
        return int(n/2)
    else:
        return (3*n)-1
while flg:
    cur = f(cnt)
    if cur in ansli:
        print(cnt)
        flg = False
    else:
        ansli.append(cur)
        cnt += 1

s = int(input())
ansli = [s]
flg = True
cnt = 2
def f(n):
    if n%2 == 0:
        return int(n/2)
    else:
        return (3*n)+1
cnt = 2
cur = s
while flg:
    cur = f(cur)
    if cur in ansli:
        print(cnt)
        flg = False
    else:
        ansli.append(cur)
        cnt += 1

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
ans = 1
for i in range(10**6):
    ans += 1
    if s%2==0:
        s = s/2
    else:
        s = 3*s+1
        
    if s == 1:
        break
if s==1 or s==2:
    print(ans)
else:
    print(ans+1)

s = int(input())
ans = 1
l = []
for i in range(10**6):
    ans += 1
    l.append(s)
    
    if s%2==0:
        s = s/2
    else:
        s = 3*s+1
    
    if s in l:
        break
        
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
if s==1:
    print(4)
elif s==2:
    print(4)
else:
    print(func(s))

def func(n):
    count = 1
    while(n!=4):
        if n%2==0:
            n = n // 2
        else:
            n = 3*n + 1
        count += 1
    return count + 3


s = int(input())
if s==1:
    print(4)
elif s==2:
    print(4)
else:
    print(func(s))

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
import copy

n = int(input())
h = []
for i in range(n):
    h.append(int(input()))

h = h.sort()

cnt = 1
now = copy.deepcopy(h[0])
h.pop(0)

while not len(h) == 0:
    if h[0] != now:
        cnt += 1
        now = copy.deepcopy(h[0])
    h.pop(0)

s = int(input())

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

a = {}
a[1] = s

i = 2
while True:
    tmp = func(a[i-1])
    if tmp in a.values():
        print(i)
        break
    else:
        a[i] = tmp
        i += 1

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s = int (input ())
l = []
a = 0
l.append (s)
for i in range (1000000):
  a += 1
  if s%2 == 0:
    s = round(s/2)
  else:
    s = s*3+1
  if l.count (s) != 0:
    print (a+1)
    break
  


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

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

Verdicts: Wrong Answer

Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
i = 1
while s>1:
    if s%2==0:
        s //= 2
    else:
        s = 3*s+1
    i += 1
if s>2:
    print(i+1)
else:
    print(4)

s = int(input())
if s<=2:
    print(4)
else:
    i = 1
    while s>1:
        if s%2==0:
            s //= 2
        else:
            s = 3*s+1
        i += 1
    print(i+1)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
l = [int(i) for i in input().split()]
if 2 * max(l) - sum(l) < 0:
    print("Yes")
else:
    print("No")

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

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s=int(input())
l=[]
while (s not in l):
    l.append(s)
    if s%2==0:
        s//=2
    else:
        s=3*s+1
print(l)
print(len(l)+1)

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

s = int(input())

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

print(lsn(ls))



#! /usr/bin/env python3
# -*- coding: utf-8 -*-

s = int(input())

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

print(len(ls))



#! /usr/bin/env python3
# -*- coding: utf-8 -*-

s = int(input())

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

print(len(ls)+1)



Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
x=[int(input())]

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

s=int(input())
l=[s]
for i in range(1000001):
    if s%2==0:
        s=s//2
    else:
        s=3*s+1
    if s in l:
        print(i+2)
        break
    l.append(s)    

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

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


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

s = int(input())

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

s = int(input())
l=[]
count = 1

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

print(count)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
l = []
l.append(s)
count = 1
while True:
  if count%2 == 1:
    a = l[-1]*3+1
  else:
    a = l[-1]//2
    
  count += 1
  if a in l:
    print(count)
    exit()
  else:
    l.append(a)

s = int(input())
l = []
l.append(s)
count = 1
while True:
  if l[-1]%2 == 1:
    a = l[-1]*3+1
  else:
    a = l[-1]//2
    
  count += 1
  if a in l:
    print(count)
    exit()
  else:
    l.append(a)


Verdicts: Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
s=int(input())
a=[s]
i=1
while len(a)==len(set(a)):
  if a[i-1]%2=0:
    a.append(a[i-1]//2)
  else:
    a.append(a[i-1]*3+1)
  i+=1
print(i)

s=int(input())
a=[s]
i=1
while len(a)==len(set(a)):
  if a[i-1]%2==0:
    a.append(a[i-1]//2)
  else:
    a.append(a[i-1]*3+1)
  i+=1
print(i)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
#n = map(int,input().split())
mlist = list(map(int,input().split()))

i=0
while(True):
    i=i+1
    if mlist[i] % 2 == 0:
        mlist.append(mlist[i]/2)
    else:
        mlist.append(3*mlist[i]+1)
    for item in range(1,i):
        if mlist[0]==item:
            break
print(i)


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

mlist=[n]
i=0
while(True):
    i=i+1
    if n % 2 == 0:
        mlist.append(n/2)
    else:
        mlist.append(3*n+1)
    for item in mlist:
        if mlist[0]==item:
            break

print(i)


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

i=0
while(True):

    if mlist[i] % 2 == 0:
        mlist.append(mlist[i]/2)
    else:
        mlist.append(3*mlist[i]+1)
    print(mlist[i+1])
    i=i+1
    
    if int(mlist[0])==int(mlist[i]):
        break
    
print(i)


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

i=0
while(True):
    if mlist[i] % 2 == 0:
        mlist.append(mlist[i]/2)
    else:
        mlist.append(3*mlist[i]+1)
    
    breakFlg = False
    for num in range(0,i):
        if int(mlist[num])==int(mlist[i]):
            if num!=i:
                breakFlg = True
    i=i+1
    if(breakFlg):
        break
print(i)


Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)




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)




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)



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)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
s = int(input())
lst = []
lst.append(s)
i = 2
while true:
  if i % 2 == 0:
    a = i / 2
  else:
    a = 3 * i + 1
  if a in lst:
    print(i)
    break
  lst.append(a)

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

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
n = int(input())
stpo = 0
num_list = []
while stop == 0:
  if n in num_list:
    stop = 1
    print(num_list.index(n)+1)
  else:
    num_list.append(n)
    if n % 2 == 0:
      n //= 2
    else:
      n = 3 * n + 1

n = int(input())
stop = 0
num_list = []
while stop == 0:
	if n in num_list:
		stop = 1
		print(num_list.index(n)+4)
	else:
		num_list.append(n)
		if n % 2 == 0:
			n //= 2
		else:
			n = 3 * n + 1

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
s=int(input())
a=[]
while True:
  if s not in a:
    a.append(s)
  else:
    break
  if s%2==0:
    s/=2
  else:
    s=3*s+1
print(len(a))

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

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
from sys import stdin
N=int(stdin.readline().rstrip())
a=[N]+[0]*10000000
for i in range(10000000):
    if i !=0:
        if a[i-1]%2==0:
            a[i]=int((a[i-1]/2))
        else:
            a[i]=int((3*a[i-1]+1))
cnt=1
tmp=[]
for j in a:
    if str(j) in tmp:
        break
    else:
        tmp.append(str(j))
        cnt+=1
print(cnt)

from sys import stdin
N=int(stdin.readline().rstrip())
a=[N]+[0]*10000
for i in range(10000):
    if i !=0:
        if a[i-1]%2==0:
            a[i]=int((a[i-1]/2))
        else:
            a[i]=int((3*a[i-1]+1))
cnt=1
tmp=[]
for j in a:
    if str(j) in tmp:
        break
    else:
        tmp.append(str(j))
        cnt+=1
print(cnt)

Verdicts: Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
def f(i):
  if i%2==0:
    return i//2
  else:
    return i*3+1

a=int(input())
i=1
while True:
  b=f(a[-1])
  i+=1
  if b in a:
    print(i)
    break
  a.append(b)

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

a=[]
a.append(int(input()))
i=1
while True:
  b=f(a[-1])
  i+=1
  if b in a:
    print(i)
    break
  a.append(b)


Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
an = int(input())

numbers = []
while True:
	if an%2 == 1:
		an = 3*an+1
	else:
		an = an//2
	if an in numbers:
		print(len(numbers)+1)
        break
    else:
		numbers.append(an)

an = int(input())

numbers = [an]
while True:
	if an%2 == 1:
		an = 3*an+1
	else:
		an = an//2
	if an in numbers:
		print(len(numbers)+1)
        break
    else:
		numbers.append(an)

an = int(input())

numbers = [an]
while True:
  if an%2 == 1:
    an = 3*an+1
  else:
    an = an*2
  if an in numbers:
    print(len(numbers)+1)
    break
  else:
    numbers.append(an)

an = int(input())

numbers = [an]
while True:
  if an%2 == 1:
    an = 3*an+1
  else:
    an = an//2
  if an in numbers:
    print(len(numbers)+1)
    break
  else:
    numbers.append(an)

Verdicts: Runtime Error

Runtime Error

Time Limit Exceeded

Accepted