dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . left = self . right = None
v = [ ]
def inorder ( root ) :
    global v
    if ( root == None ) :
        return
    inorder ( root . left )
    v . append ( root . data )
    inorder ( root . right )
def bTreeToCList ( root ) :
    global v
    if ( root == None ) :
        return None
    v = [ ]
    inorder ( root )
    head_ref = Node ( v [ 0 ] )
    curr = head_ref
    i = 1
    while ( i < len ( v ) ) :
        temp = curr
        curr . right = Node ( v [ i ] )
        curr = curr . right
        curr . left = temp
        i = i + 1
    curr . right = head_ref
    head_ref . left = curr
    return head_ref
def displayCList ( head ) :
    print ( " Circular ▁ Doubly ▁ Linked ▁ List ▁ is ▁ : " , end = " " )
    itr = head
    while ( True ) :
        print ( itr . data , end = " ▁ " )
        itr = itr . right
        if ( head == itr ) :
            break
    print ( )
root = Node ( 10 )
root . left = Node ( 12 )
root . right = Node ( 15 )
root . left . left = Node ( 25 )
root . left . right = Node ( 30 )
root . right . left = Node ( 36 )
head = bTreeToCList ( root )
displayCList ( head )

Index/key variables: i
Class/struct names: Node
Python program:
class Node :
    def __init__ ( self ) :
        self . data = 0
        self . next = None
def printMinMax ( head ) :
    if ( head == None ) :
        return ;
    current = head ;
    min = 1000000000
    max = - 1000000000 ;
    while True :
        if ( current . data < min ) :
            min = current . data ;
        if ( current . data > max ) :
            max = current . data ;
        current = current . next ;
        if ( current == head ) :
            break
    print ( ' Minimum ▁ = ▁ { } , ▁ Maximum ▁ = ▁ { } ' . format ( min , max ) )
def insertNode ( head , data ) :
    current = head ;
    newNode = Node ( )
    if not newNode :
        print ( " Memory Error " ) ;
        return head
    newNode . data = data ;
    if ( head == None ) :
        newNode . next = newNode ;
        head = newNode ;
        return head
    else :
        while ( current . next != head ) :
            current = current . next ;
        newNode . next = head ;
        current . next = newNode ;
    return head
def displayList ( head ) :
    current = head ;
    if ( head == None ) :
        print ( " Display List is empty " ) ;
        return ;
    else :
        while True :
            print ( current . data , end = ' ▁ ' ) ;
            current = current . next ;
            if ( current == head ) :
                break
    print ( )
if __name__ == ' _ _ main _ _ ' :
    Head = None ;
    Head = insertNode ( Head , 99 ) ;
    Head = insertNode ( Head , 11 ) ;
    Head = insertNode ( Head , 22 ) ;
    Head = insertNode ( Head , 33 ) ;
    Head = insertNode ( Head , 44 ) ;
    Head = insertNode ( Head , 55 ) ;
    Head = insertNode ( Head , 66 ) ;
    print ( " Initial ▁ List : ▁ " , end = ' ' )
    displayList ( Head ) ;
    printMinMax ( Head ) ;

Class/struct names: Node
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def push ( head_ref , data ) :
    ptr1 = Node ( data )
    temp = head_ref
    ptr1 . data = data
    ptr1 . next = head_ref
    if ( head_ref != None ) :
        while ( temp . next != head_ref ) :
            temp = temp . next
        temp . next = ptr1
    else :
        ptr1 . next = ptr1
    head_ref = ptr1
    return head_ref
def deleteNode ( head_ref , delete ) :
    temp = head_ref
    if ( head_ref == delete ) :
        head_ref = delete . next
    while ( temp . next != delete ) :
        temp = temp . next
    temp . next = delete . next
def deleteEvenNodes ( head ) :
    ptr = head
    next = None
    next = ptr . next
    ptr = next
    while ( ptr != head ) :
        if ( ptr . data % 2 == 0 ) :
            deleteNode ( head , ptr )
        next = ptr . next
        ptr = next
    return head
def prList ( head ) :
    temp = head
    if ( head != None ) :
        print ( temp . data , end = " ▁ " )
        temp = temp . next
        while ( temp != head ) :
            print ( temp . data , end = " ▁ " )
            temp = temp . next
if __name__ == ' _ _ main _ _ ' :
    head = None
    head = push ( head , 61 )
    head = push ( head , 12 )
    head = push ( head , 56 )
    head = push ( head , 2 )
    head = push ( head , 11 )
    head = push ( head , 57 )
    print ( " List ▁ after ▁ deletion ▁ : ▁ " , end = " " )
    head = deleteEvenNodes ( head )
    prList ( head )

Class/struct names: Node
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def push ( head , data ) :
    if not head :
        head = Node ( data )
        head . next = head
        return head
    lnode = head
    while ( lnode and lnode . next is not head ) :
        lnode = lnode . next
    ptr1 = Node ( data )
    ptr1 . next = head
    lnode . next = ptr1
    head = ptr1
    return head
def sumOfList ( head ) :
    temp = head
    tsum = temp . data
    temp = temp . next
    while ( temp is not head ) :
        tsum += temp . data
        temp = temp . next
    return tsum
if __name__ == ' _ _ main _ _ ' :
    head = None
    head = push ( head , 12 )
    head = push ( head , 56 )
    head = push ( head , 2 )
    head = push ( head , 11 )
    print ( " Sum ▁ of ▁ circular ▁ list ▁ is ▁ = ▁ { } " . format ( sumOfList ( head ) ) )

Accumulator variables: tsum
Class/struct names: Node
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def prList ( head ) :
    if ( head == None ) :
        return
    temp = head
    print ( temp . data , end = " - > " )
    temp = temp . next
    while ( temp != head ) :
        print ( temp . data , end = " - > " )
        temp = temp . next
    print ( head . data )
def deleteK ( head_ref , k ) :
    head = head_ref
    if ( head == None ) :
        return
    curr = head
    prev = None
    while True :
        if ( curr . next == head and curr == head ) :
            break
        prList ( head )
        for i in range ( k ) :
            prev = curr
            curr = curr . next
        if ( curr == head ) :
            prev = head
            while ( prev . next != head ) :
                prev = prev . next
            head = curr . next
            prev . next = head
            head_ref = head
        elif ( curr . next == head ) :
            prev . next = head
        else :
            prev . next = curr . next
def insertNode ( head_ref , x ) :
    head = head_ref
    temp = Node ( x )
    if ( head == None ) :
        temp . next = temp
        head_ref = temp
        return head_ref
    else :
        temp1 = head
        while ( temp1 . next != head ) :
            temp1 = temp1 . next
        temp1 . next = temp
        temp . next = head
    return head
if __name__ == ' _ _ main _ _ ' :
    head = None
    head = insertNode ( head , 1 )
    head = insertNode ( head , 2 )
    head = insertNode ( head , 3 )
    head = insertNode ( head , 4 )
    head = insertNode ( head , 5 )
    head = insertNode ( head , 6 )
    head = insertNode ( head , 7 )
    head = insertNode ( head , 8 )
    head = insertNode ( head , 9 )
    k = 4
    deleteK ( head , k )

Iterator variables: i
Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . prev = None
        self . next = None
def getNode ( ) :
    return ( Node ( 0 ) )
def displayList ( temp ) :
    t = temp
    if ( temp == None ) :
        return 0
    else :
        print ( " The ▁ list ▁ is : ▁ " , end = " ▁ " )
        while ( temp . next != t ) :
            print ( temp . data , end = " ▁ " )
            temp = temp . next
        print ( temp . data )
        return 1
def countList ( start ) :
    temp = start
    count = 0
    while ( temp . next != start ) :
        temp = temp . next
        count = count + 1
    count = count + 1
    return count
def insertAtLocation ( start , data , loc ) :
    temp = None
    newNode = None
    i = 0
    count = 0
    newNode = getNode ( )
    temp = start
    count = countList ( start )
    if ( temp == None or count < loc ) :
        return start
    else :
        newNode . data = data
        i = 1 ;
        while ( i < loc - 1 ) :
            temp = temp . next
            i = i + 1
        newNode . next = temp . next
        ( temp . next ) . prev = newNode
        temp . next = newNode
        newNode . prev = temp
        return start
    return start
def createList ( arr , n , start ) :
    newNode = None
    temp = None
    i = 0
    while ( i < n ) :
        newNode = getNode ( )
        newNode . data = arr [ i ]
        if ( i == 0 ) :
            start = newNode
            newNode . prev = start
            newNode . next = start
        else :
            temp = ( start ) . prev
            temp . next = newNode
            newNode . next = start
            newNode . prev = temp
            temp = start
            temp . prev = newNode
        i = i + 1 ;
    return start
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 , 4 , 5 , 6 ]
    n = len ( arr )
    start = None
    start = createList ( arr , n , start )
    displayList ( start )
    start = insertAtLocation ( start , 8 , 3 )
    displayList ( start )

Index/key variables: i
Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . prev = None
        self . next = None
def getNode ( ) :
    return ( Node ( 0 ) )
def displayList ( temp ) :
    t = temp
    if ( temp == None ) :
        return 0
    else :
        print ( " The ▁ list ▁ is : ▁ " , end = " ▁ " )
        while ( temp . next != t ) :
            print ( temp . data , end = " ▁ " )
            temp = temp . next
        print ( temp . data )
        return 1
def createList ( arr , n , start ) :
    newNode = None
    temp = None
    i = 0
    while ( i < n ) :
        newNode = getNode ( )
        newNode . data = arr [ i ]
        if ( i == 0 ) :
            start = newNode
            newNode . prev = start
            newNode . next = start
        else :
            temp = ( start ) . prev
            temp . next = newNode
            newNode . next = start
            newNode . prev = temp
            temp = start
            temp . prev = newNode
        i = i + 1
    return start
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 , 4 , 5 ]
    n = len ( arr )
    start = None
    start = createList ( arr , n , start )
    displayList ( start )

Index/key variables: i
Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def newNode ( data ) :
    node = Node ( data )
    return node
def alivesol ( Num ) :
    if ( Num == 1 ) :
        return 1 ;
    last = newNode ( 1 ) ;
    last . next = last ;
    for i in range ( 2 , Num + 1 ) :
        temp = newNode ( i ) ;
        temp . next = last . next ;
        last . next = temp ;
        last = temp ;
    curr = last . next ;
    temp = None
    while ( curr . next != curr ) :
        temp = curr ;
        curr = curr . next ;
        temp . next = curr . next ;
        del curr ;
        temp = temp . next ;
        curr = temp ;
    res = temp . data ;
    del temp ;
    return res ;
if __name__ == ' _ _ main _ _ ' :
    N = 100 ;
    print ( alivesol ( N ) )

Iterator variables: i
Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , d ) :
        self . data = d
        self . left = None
        self . right = None
def finddepth ( root ) :
    if ( not root ) :
        return 0
    left = finddepth ( root . left )
    right = finddepth ( root . right )
    return 1 + max ( left , right )
def dfs ( root , curr , depth ) :
    if ( not root ) :
        return None
    if ( curr == depth ) :
        return root
    left = dfs ( root . left , curr + 1 , depth )
    right = dfs ( root . right , curr + 1 , depth )
    if ( left != None and right != None ) :
        return root
    return left if left else right
def lcaOfDeepestLeaves ( root ) :
    if ( not root ) :
        return None
    depth = finddepth ( root ) - 1
    return dfs ( root , 0 , depth )
if __name__ == ' _ _ main _ _ ' :
    root = Node ( 1 )
    root . left = Node ( 2 )
    root . right = Node ( 3 )
    root . left . left = Node ( 4 )
    root . left . right = Node ( 5 )
    root . right . left = Node ( 6 )
    root . right . right = Node ( 7 )
    root . right . left . left = Node ( 8 )
    root . right . left . right = Node ( 9 )
    print ( lcaOfDeepestLeaves ( root ) . data )

Class/struct names: Node
Python program:
def filter ( x , y , z ) :
    if ( x != - 1 and y != - 1 ) :
        return z
    return y if x == - 1 else x
def samePathUtil ( mtrx , vrtx , v1 , v2 , i ) :
    ans = - 1
    if ( i == v1 or i == v2 ) :
        return i
    for j in range ( 0 , vrtx ) :
        if ( mtrx [ i ] [ j ] == 1 ) :
            ans = filter ( ans , samePathUtil ( mtrx , vrtx , v1 , v2 , j ) , i )
    return ans
def isVertexAtSamePath ( mtrx , vrtx , v1 , v2 , i ) :
    lca = samePathUtil ( mtrx , vrtx , v1 - 1 , v2 - 1 , i )
    if ( lca == v1 - 1 or lca == v2 - 1 ) :
        return True
    return False
vrtx = 7
edge = 6
mtrx = [ [ 0 , 1 , 1 , 1 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 , 1 , 0 , 0 ] , [ 0 , 0 , 0 , 0 , 0 , 1 , 0 ] , [ 0 , 0 , 0 , 0 , 0 , 0 , 1 ] , [ 0 , 0 , 0 , 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ]
v1 = 1
v2 = 5
if ( isVertexAtSamePath ( mtrx , vrtx , v1 , v2 , 0 ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i, j
Iterator variables: j
Python program:
MAX = 1000
lg = 10
level = [ 0 for i in range ( MAX ) ]
lca = [ [ 0 for i in range ( lg ) ] for j in range ( MAX ) ]
dist = [ [ 0 for i in range ( lg ) ] for j in range ( MAX ) ]
graph = [ [ ] for i in range ( MAX ) ]
def addEdge ( u , v , cost ) :
    global graph
    graph [ u ] . append ( [ v , cost ] )
    graph [ v ] . append ( [ u , cost ] )
def dfs ( node , parent , h , cost ) :
    lca [ node ] [ 0 ] = parent
    level [ node ] = h
    if ( parent != - 1 ) :
        dist [ node ] [ 0 ] = cost
    for i in range ( 1 , lg ) :
        if ( lca [ node ] [ i - 1 ] != - 1 ) :
            lca [ node ] [ i ] = lca [ lca [ node ] [ i - 1 ] ] [ i - 1 ]
            dist [ node ] [ i ] = ( dist [ node ] [ i - 1 ] + dist [ lca [ node ] [ i - 1 ] ] [ i - 1 ] )
    for i in graph [ node ] :
        if ( i [ 0 ] == parent ) :
            continue
        dfs ( i [ 0 ] , node , h + 1 , i [ 1 ] )
def findDistance ( u , v ) :
    ans = 0
    if ( level [ u ] > level [ v ] ) :
        temp = u
        u = v
        v = temp
    i = lg - 1
    while ( i >= 0 ) :
        if ( lca [ v ] [ i ] != - 1 and level [ lca [ v ] [ i ] ] >= level [ u ] ) :
            ans += dist [ v ] [ i ]
            v = lca [ v ] [ i ]
        i -= 1
    if ( v == u ) :
        print ( ans )
    else :
        i = lg - 1
        while ( i >= 0 ) :
            if ( lca [ v ] [ i ] != lca [ u ] [ i ] ) :
                ans += dist [ u ] [ i ] + dist [ v ] [ i ]
                v = lca [ v ] [ i ]
                u = lca [ u ] [ i ]
            i -= 1
        ans += ( dist [ u ] [ 0 ] + dist [ v ] [ 0 ] )
        print ( ans )
if __name__ == ' _ _ main _ _ ' :
    n = 5
    addEdge ( 1 , 2 , 2 )
    addEdge ( 1 , 3 , 3 )
    addEdge ( 2 , 4 , 5 )
    addEdge ( 2 , 5 , 7 )
    for i in range ( 1 , n + 1 ) :
        for j in range ( lg ) :
            lca [ i ] [ j ] = - 1
            dist [ i ] [ j ] = 0
    dfs ( 1 , - 1 , 0 , 0 )
    findDistance ( 1 , 3 )
    findDistance ( 2 , 3 )
    findDistance ( 3 , 5 )

Index/key variables: i, j, node, u, v
Accumulator variables: ans
Iterator variables: i, j
Python program:
MAX = 1000
weight = [ 0 for i in range ( MAX ) ]
level = [ 0 for i in range ( MAX ) ]
par = [ 0 for i in range ( MAX ) ]
prime = [ True for i in range ( MAX + 1 ) ]
graph = [ [ ] for i in range ( MAX ) ]
def SieveOfEratosthenes ( ) :
    for p in range ( 2 , MAX + 1 ) :
        if p * p > MAX + 1 :
            break
        if ( prime [ p ] == True ) :
            for i in range ( p * p , MAX + 1 , p ) :
                prime [ i ] = False
def dfs ( node , parent , h ) :
    par [ node ] = parent
    level [ node ] = h
    for child in graph [ node ] :
        if ( child == parent ) :
            continue
        dfs ( child , node , h + 1 )
def findPrimeOnPath ( u , v ) :
    count = 0
    if ( level [ u ] > level [ v ] ) :
        u , v = v , u
    d = level [ v ] - level [ u ]
    while ( d ) :
        if ( prime [ weight [ v ] ] ) :
            count += 1
        v = par [ v ]
        d -= 1
    if ( v == u ) :
        if ( prime [ weight [ v ] ] ) :
            count += 1
        return count
    while ( v != u ) :
        if ( prime [ weight [ v ] ] ) :
            count += 1
        if ( prime [ weight [ u ] ] ) :
            count += 1
        u = par [ u ]
        v = par [ v ]
    if ( prime [ weight [ v ] ] ) :
        count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    SieveOfEratosthenes ( )
    weight [ 1 ] = 5
    weight [ 2 ] = 10
    weight [ 3 ] = 11
    weight [ 4 ] = 8
    weight [ 5 ] = 6
    graph [ 1 ] . append ( 2 )
    graph [ 2 ] . append ( 3 )
    graph [ 2 ] . append ( 4 )
    graph [ 1 ] . append ( 5 )
    dfs ( 1 , - 1 , 0 )
    u = 3
    v = 5
    print ( findPrimeOnPath ( u , v ) )

Index/key variables: i, node, p, u, v
Accumulator variables: count, d
Iterator variables: child, i, p
Python program:
import sys
MAX = 1000
log = 10
level = [ 0 for i in range ( MAX ) ] ;
lca = [ [ - 1 for j in range ( log ) ] for i in range ( MAX ) ]
minWeight = [ [ sys . maxsize for j in range ( log ) ] for i in range ( MAX ) ]
maxWeight = [ [ - sys . maxsize for j in range ( log ) ] for i in range ( MAX ) ]
graph = [ [ ] for i in range ( MAX ) ]
weight = [ 0 for i in range ( MAX ) ]
def addEdge ( u , v ) :
    graph [ u ] . append ( v ) ;
    graph [ v ] . append ( u ) ;
def dfs ( node , parent , h ) :
    lca [ node ] [ 0 ] = parent ;
    level [ node ] = h ;
    if ( parent != - 1 ) :
        minWeight [ node ] [ 0 ] = ( min ( weight [ node ] , weight [ parent ] ) ) ;
        maxWeight [ node ] [ 0 ] = ( max ( weight [ node ] , weight [ parent ] ) ) ;
    for i in range ( 1 , log ) :
        if ( lca [ node ] [ i - 1 ] != - 1 ) :
            lca [ node ] [ i ] = lca [ lca [ node ] [ i - 1 ] ] [ i - 1 ] ;
            minWeight [ node ] [ i ] = min ( minWeight [ node ] [ i - 1 ] , minWeight [ lca [ node ] [ i - 1 ] ] [ i - 1 ] ) ;
            maxWeight [ node ] [ i ] = max ( maxWeight [ node ] [ i - 1 ] , maxWeight [ lca [ node ] [ i - 1 ] ] [ i - 1 ] ) ;
    for i in graph [ node ] :
        if ( i == parent ) :
            continue ;
        dfs ( i , node , h + 1 ) ;
def findMinMaxWeight ( u , v ) :
    minWei = sys . maxsize
    maxWei = - sys . maxsize
    if ( level [ u ] > level [ v ] ) :
        u , v = v , u
    for i in range ( log - 1 , - 1 , - 1 ) :
        if ( lca [ v ] [ i ] != - 1 and level [ lca [ v ] [ i ] ] >= level [ u ] ) :
            minWei = min ( minWei , minWeight [ v ] [ i ] ) ;
            maxWei = max ( maxWei , maxWeight [ v ] [ i ] ) ;
            v = lca [ v ] [ i ] ;
    if ( v == u ) :
        print ( str ( minWei ) + ' ▁ ' + str ( maxWei ) )
    else :
        for i in range ( log - 1 , - 1 , - 1 ) :
            if ( lca [ v ] [ i ] != lca [ u ] [ i ] ) :
                minWei = ( min ( minWei , min ( minWeight [ v ] [ i ] , minWeight [ u ] [ i ] ) ) ) ;
                maxWei = max ( maxWei , max ( maxWeight [ v ] [ i ] , maxWeight [ u ] [ i ] ) ) ;
                v = lca [ v ] [ i ] ;
                u = lca [ u ] [ i ] ;
        minWei = min ( minWei , min ( minWeight [ v ] [ 0 ] , minWeight [ u ] [ 0 ] ) ) ;
        maxWei = max ( maxWei , max ( maxWeight [ v ] [ 0 ] , maxWeight [ u ] [ 0 ] ) ) ;
        print ( str ( minWei ) + ' ▁ ' + str ( maxWei ) )
if __name__ == " _ _ main _ _ " :
    n = 5 ;
    addEdge ( 1 , 2 ) ;
    addEdge ( 1 , 5 ) ;
    addEdge ( 2 , 4 ) ;
    addEdge ( 2 , 3 ) ;
    weight [ 1 ] = - 1 ;
    weight [ 2 ] = 5 ;
    weight [ 3 ] = - 1 ;
    weight [ 4 ] = 3 ;
    weight [ 5 ] = - 2 ;
    dfs ( 1 , - 1 , 0 ) ;
    findMinMaxWeight ( 1 , 3 ) ;
    findMinMaxWeight ( 2 , 4 ) ;
    findMinMaxWeight ( 3 , 5 ) ;

Index/key variables: i, node, parent, u, v
Iterator variables: i
Python program:
from typing import List
from sys import maxsize
INT_MAX = maxsize
INT_MIN = - maxsize
T = 1
def dfs ( node : int , parent : int , g : List [ List [ int ] ] , level : List [ int ] , t_in : List [ int ] , t_out : List [ int ] ) -> None :
    global T
    if ( parent == - 1 ) :
        level [ node ] = 1
    else :
        level [ node ] = level [ parent ] + 1
    t_in [ node ] = T
    for i in g [ node ] :
        if ( i != parent ) :
            T += 1
            dfs ( i , node , g , level , t_in , t_out )
    T += 1
    t_out [ node ] = T
def findLCA ( n : int , g : List [ List [ int ] ] , v : List [ int ] ) -> int :
    level = [ 0 for _ in range ( n + 1 ) ]
    t_in = [ 0 for _ in range ( n + 1 ) ]
    t_out = [ 0 for _ in range ( n + 1 ) ]
    dfs ( 1 , - 1 , g , level , t_in , t_out )
    mint = INT_MAX
    maxt = INT_MIN
    minv = - 1
    maxv = - 1
    for i in v :
        if ( t_in [ i ] < mint ) :
            mint = t_in [ i ]
            minv = i
        if ( t_out [ i ] > maxt ) :
            maxt = t_out [ i ]
            maxv = i
    if ( minv == maxv ) :
        return minv
    lev = min ( level [ minv ] , level [ maxv ] )
    node = 0
    l = INT_MIN
    for i in range ( n ) :
        if ( level [ i ] > lev ) :
            continue
        if ( t_in [ i ] <= mint and t_out [ i ] >= maxt and level [ i ] > l ) :
            node = i
            l = level [ i ]
    return node
if __name__ == " _ _ main _ _ " :
    n = 10
    g = [ [ ] for _ in range ( n + 1 ) ]
    g [ 1 ] . append ( 2 )
    g [ 2 ] . append ( 1 )
    g [ 1 ] . append ( 3 )
    g [ 3 ] . append ( 1 )
    g [ 1 ] . append ( 4 )
    g [ 4 ] . append ( 1 )
    g [ 2 ] . append ( 5 )
    g [ 5 ] . append ( 2 )
    g [ 2 ] . append ( 6 )
    g [ 6 ] . append ( 2 )
    g [ 3 ] . append ( 7 )
    g [ 7 ] . append ( 3 )
    g [ 4 ] . append ( 10 )
    g [ 10 ] . append ( 4 )
    g [ 8 ] . append ( 7 )
    g [ 7 ] . append ( 8 )
    g [ 9 ] . append ( 7 )
    g [ 7 ] . append ( 9 )
    v = [ 7 , 3 , 8 ]
    print ( findLCA ( n , g , v ) )

Index/key variables: i, int, maxv, minv, node, parent
Accumulator variables: T
Iterator variables: i