dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def newNode ( data ) :
    new_node = Node ( 0 )
    new_node . data = data
    new_node . next = None
    return new_node
def addWithCarry ( head ) :
    if ( head == None ) :
        return 1
    res = head . data + addWithCarry ( head . next )
    head . data = int ( ( res ) % 10 )
    return int ( ( res ) / 10 )
def addOne ( head ) :
    carry = addWithCarry ( head )
    if ( carry != 0 ) :
        newNode = Node ( 0 )
        newNode . data = carry
        newNode . next = head
        return newNode
    return head
def printList ( node ) :
    while ( node != None ) :
        print ( node . data , end = " " )
        node = node . next
    print ( " " )
head = newNode ( 1 )
head . next = newNode ( 9 )
head . next . next = newNode ( 9 )
head . next . next . next = newNode ( 9 )
print ( " List ▁ is ▁ " )
printList ( head )
head = addOne ( head )
print ( " Resultant list is   " )
printList ( head )

Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
        self . arbit = None
def reverse ( head ) :
    prev = None
    current = head
    next = None
    while ( current != None ) :
        next = current . next
        current . next = prev
        prev = current
        current = next
    return prev
def populateArbit ( head ) :
    head = reverse ( head )
    max = head
    temp = head . next
    while ( temp != None ) :
        temp . arbit = max
        if ( max . data < temp . data ) :
            max = temp
        temp = temp . next
    return reverse ( head )
def printNextArbitPointers ( node ) :
    print ( " Node Next Pointer Arbit Pointer " )
    while ( node != None ) :
        print ( node . data , " TABSYMBOL TABSYMBOL " , end = " " )
        if ( node . next != None ) :
            print ( node . next . data , " TABSYMBOL TABSYMBOL " , end = " " )
        else :
            print ( " None " , " TABSYMBOL TABSYMBOL " , end = " " )
        if ( node . arbit != None ) :
            print ( node . arbit . data , end = " " )
        else :
            print ( " None " , end = " " )
        print ( " " )
        node = node . next
def newNode ( data ) :
    new_node = Node ( 0 )
    new_node . data = data
    new_node . next = None
    return new_node
head = newNode ( 5 )
head . next = newNode ( 10 )
head . next . next = newNode ( 2 )
head . next . next . next = newNode ( 3 )
head = populateArbit ( head )
print ( " Resultant Linked List is : " )
printNextArbitPointers ( head )

Class/struct names: Node
Python program:
class newNode :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
        self . arbit = None
maxNode = newNode ( None )
def populateArbit ( head ) :
    global maxNode
    if ( head == None ) :
        return
    if ( head . next == None ) :
        maxNode = head
        return
    populateArbit ( head . next )
    head . arbit = maxNode
    if ( head . data > maxNode . data and maxNode . data != None ) :
        maxNode = head
    return
def printNextArbitPointers ( node ) :
    print ( " Node TABSYMBOL Next ▁ Pointer TABSYMBOL Arbit ▁ Pointer " )
    while ( node != None ) :
        print ( node . data , " TABSYMBOL TABSYMBOL " , end = " " )
        if ( node . next ) :
            print ( node . next . data , " TABSYMBOL TABSYMBOL " , end = " " )
        else :
            print ( " NULL " , " TABSYMBOL TABSYMBOL " , end = " " )
        if ( node . arbit ) :
            print ( node . arbit . data , end = " " )
        else :
            print ( " NULL " , end = " " )
        print ( )
        node = node . next
head = newNode ( 5 )
head . next = newNode ( 10 )
head . next . next = newNode ( 2 )
head . next . next . next = newNode ( 3 )
populateArbit ( head )
print ( " Resultant ▁ Linked ▁ List ▁ is : " )
printNextArbitPointers ( head )

Class/struct names: newNode
Python program:
class Node :
    def __init__ ( self , new_data ) :
        self . data = new_data
        self . next = None
def deleteLast ( head , x ) :
    temp = head
    ptr = None
    while ( temp != None ) :
        if ( temp . data == x ) :
            ptr = temp
        temp = temp . next
    if ( ptr != None and ptr . next == None ) :
        temp = head
        while ( temp . next != ptr ) :
            temp = temp . next
        temp . next = None
    if ( ptr != None and ptr . next != None ) :
        ptr . data = ptr . next . data
        temp = ptr . next
        ptr . next = ptr . next . next
    return head
def newNode ( x ) :
    node = Node ( 0 )
    node . data = x
    node . next = None
    return node
def display ( head ) :
    temp = head
    if ( head == None ) :
        print ( " None " )
        return
    while ( temp != None ) :
        print ( temp . data , " ▁ - > ▁ " , end = " " )
        temp = temp . next
    print ( " None " )
head = newNode ( 1 )
head . next = newNode ( 2 )
head . next . next = newNode ( 3 )
head . next . next . next = newNode ( 4 )
head . next . next . next . next = newNode ( 5 )
head . next . next . next . next . next = newNode ( 4 )
head . next . next . next . next . next . next = newNode ( 4 )
print ( " Created ▁ Linked ▁ list : ▁ " )
display ( head )
head = deleteLast ( head , 4 )
print ( " List ▁ after ▁ deletion ▁ of ▁ 4 : ▁ " )
display ( head )

Class/struct names: Node
Python program:
def flattenList2 ( head ) :
    headcop = head
    save = [ ]
    save . append ( head )
    prev = None
    while ( len ( save ) != 0 ) :
        temp = save [ - 1 ]
        save . pop ( )
        if ( temp . next ) :
            save . append ( temp . next )
        if ( temp . down ) :
            save . append ( temp . down )
        if ( prev != None ) :
            prev . next = temp
        prev = temp
    return headcop

Accumulator variables: save
Python program:
class Node :
    def __init__ ( self ) :
        self . data = 0
        self . next = None
def newNode ( data ) :
    new_node = Node ( )
    new_node . data = data
    new_node . next = None
    return new_node
def partition ( head , x ) :
    smallerHead = None
    smallerLast = None
    greaterLast = None
    greaterHead = None
    equalHead = None
    equalLast = None
    while ( head != None ) :
        if ( head . data == x ) :
            if ( equalHead == None ) :
                equalHead = equalLast = head
            else :
                equalLast . next = head
                equalLast = equalLast . next
        elif ( head . data < x ) :
            if ( smallerHead == None ) :
                smallerLast = smallerHead = head
            else :
                smallerLast . next = head
                smallerLast = head
        else :
            if ( greaterHead == None ) :
                greaterLast = greaterHead = head
            else :
                greaterLast . next = head
                greaterLast = head
        head = head . next
    if ( greaterLast != None ) :
        greaterLast . next = None
    if ( smallerHead == None ) :
        if ( equalHead == None ) :
            return greaterHead
        equalLast . next = greaterHead
        return equalHead
    if ( equalHead == None ) :
        smallerLast . next = greaterHead
        return smallerHead
    smallerLast . next = equalHead
    equalLast . next = greaterHead
    return smallerHead
def printList ( head ) :
    temp = head
    while ( temp != None ) :
        print ( temp . data , end = " ▁ " )
        temp = temp . next
head = newNode ( 10 )
head . next = newNode ( 4 )
head . next . next = newNode ( 5 )
head . next . next . next = newNode ( 30 )
head . next . next . next . next = newNode ( 2 )
head . next . next . next . next . next = newNode ( 50 )
x = 3
head = partition ( head , x )
printList ( head )

Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def getLoopstart ( loop_node , head ) :
    ptr1 = loop_node
    ptr2 = loop_node
    k = 1
    i = 0
    while ( ptr1 . next != ptr2 ) :
        ptr1 = ptr1 . next
        k = k + 1
    ptr1 = head
    ptr2 = head
    i = 0
    while ( i < k ) :
        ptr2 = ptr2 . next
        i = i + 1
    while ( ptr2 != ptr1 ) :
        ptr1 = ptr1 . next
        ptr2 = ptr2 . next
    return ptr1
def detectAndgetLoopstarting ( head ) :
    slow_p = head
    fast_p = head
    loop_start = None
    while ( slow_p != None and fast_p != None and fast_p . next != None ) :
        slow_p = slow_p . next
        fast_p = fast_p . next . next
        if ( slow_p == fast_p ) :
            loop_start = getLoopstart ( slow_p , head )
            break
    return loop_start
def isPalindromeUtil ( head , loop_start ) :
    ptr = head
    s = [ ]
    count = 0
    while ( ptr != loop_start or count != 1 ) :
        s . append ( ptr . data )
        if ( ptr == loop_start ) :
            count = 1
        ptr = ptr . next
    ptr = head
    count = 0
    while ( ptr != loop_start or count != 1 ) :
        if ( ptr . data == s [ - 1 ] ) :
            s . pop ( )
        else :
            return False
        if ( ptr == loop_start ) :
            count = 1
        ptr = ptr . next
    return True
def isPalindrome ( head ) :
    loop_start = detectAndgetLoopstarting ( head )
    return isPalindromeUtil ( head , loop_start )
def newNode ( key ) :
    temp = Node ( 0 )
    temp . data = key
    temp . next = None
    return temp
head = newNode ( 50 )
head . next = newNode ( 20 )
head . next . next = newNode ( 15 )
head . next . next . next = newNode ( 20 )
head . next . next . next . next = newNode ( 50 )
head . next . next . next . next . next = head . next . next
if ( isPalindrome ( head ) == True ) :
    print ( " Palindrome " )
else :
    print ( " Not ▁ Palindrome " )

Accumulator variables: s
Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def countCommon ( a , b ) :
    count = 0
    while ( a != None and b != None ) :
        if ( a . data == b . data ) :
            count = count + 1
        else :
            break
        a = a . next
        b = b . next
    return count
def maxPalindrome ( head ) :
    result = 0
    prev = None
    curr = head
    while ( curr != None ) :
        next = curr . next
        curr . next = prev
        result = max ( result , 2 * countCommon ( prev , next ) + 1 )
        result = max ( result , 2 * countCommon ( curr , next ) )
        prev = curr
        curr = next
    return result
def newNode ( key ) :
    temp = Node ( 0 )
    temp . data = key
    temp . next = None
    return temp
head = newNode ( 2 )
head . next = newNode ( 4 )
head . next . next = newNode ( 3 )
head . next . next . next = newNode ( 4 )
head . next . next . next . next = newNode ( 2 )
head . next . next . next . next . next = newNode ( 15 )
print ( maxPalindrome ( head ) )

Class/struct names: Node
Python program:
if __name__ == ' _ _ main _ _ ' :
    list = [ ]
    list . append ( 1 )
    list . append ( 2 )
    list . append ( 3 )
    for it in list :
        print ( it , end = ' ▁ ' )

Iterator variables: it
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def newNode ( x ) :
    temp = Node ( 0 )
    temp . data = x
    temp . next = None
    return temp
def printList ( head ) :
    temp = head
    while ( temp != None ) :
        print ( temp . data , end = " ▁ " )
        temp = temp . next
    print ( )
def moveToEnd ( head , key ) :
    pKey = head
    pCrawl = head
    while ( pCrawl != None ) :
        if ( pCrawl != pKey and pCrawl . data != key ) :
            pKey . data = pCrawl . data
            pCrawl . data = key
            pKey = pKey . next
        if ( pKey . data != key ) :
            pKey = pKey . next
        pCrawl = pCrawl . next
    return head
head = newNode ( 10 )
head . next = newNode ( 20 )
head . next . next = newNode ( 10 )
head . next . next . next = newNode ( 30 )
head . next . next . next . next = newNode ( 40 )
head . next . next . next . next . next = newNode ( 10 )
head . next . next . next . next . next . next = newNode ( 60 )
print ( " Before moveToEnd ( ) , the Linked list is " )
printList ( head )
key = 10
head = moveToEnd ( head , key )
print ( " After moveToEnd ( ) , the Linked list is " )
printList ( head )

Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def newNode ( x ) :
    temp = Node ( x )
    return temp
def keyToEnd ( head , key ) :
    tail = head
    if ( head == None ) :
        return None
    while ( tail . next != None ) :
        tail = tail . next
    last = tail
    current = head
    prev = None
    prev2 = None
    while ( current != tail ) :
        if ( current . data == key and prev2 == None ) :
            prev = current
            current = current . next
            head = current
            last . next = prev
            last = last . next
            last . next = None
            prev = None
        else :
            if ( current . data == key and prev2 != None ) :
                prev = current
                current = current . next
                prev2 . next = current
                last . next = prev
                last = last . next
                last . next = None
            elif ( current != tail ) :
                prev2 = current
                current = current . next
    return head
def printList ( head ) :
    temp = head
    while ( temp != None ) :
        print ( temp . data , end = ' ▁ ' )
        temp = temp . next
    print ( )
if __name__ == ' _ _ main _ _ ' :
    root = newNode ( 5 )
    root . next = newNode ( 2 )
    root . next . next = newNode ( 2 )
    root . next . next . next = newNode ( 7 )
    root . next . next . next . next = newNode ( 2 )
    root . next . next . next . next . next = newNode ( 2 )
    root . next . next . next . next . next . next = newNode ( 2 )
    key = 2
    print ( " Linked ▁ List ▁ before ▁ operations ▁ : " )
    printList ( root )
    print ( " Linked ▁ List ▁ after ▁ operations ▁ : " )
    root = keyToEnd ( root , key )
    printList ( root )

Class/struct names: Node
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def freeList ( node ) :
    while ( node != None ) :
        next = node . next
        node = next
    return node
def deleteKthNode ( head , k ) :
    if ( head == None ) :
        return None
    if ( k == 1 ) :
        freeList ( head )
        return None
    ptr = head
    prev = None
    count = 0
    while ( ptr != None ) :
        count = count + 1
        if ( k == count ) :
            prev . next = ptr . next
            count = 0
        if ( count != 0 ) :
            prev = ptr
        ptr = prev . next
    return head
def displayList ( head ) :
    temp = head
    while ( temp != None ) :
        print ( temp . data , end = ' ▁ ' )
        temp = temp . next
def newNode ( x ) :
    temp = Node ( x )
    temp . data = x
    temp . next = None
    return temp
if __name__ == ' _ _ main _ _ ' :
    head = newNode ( 1 )
    head . next = newNode ( 2 )
    head . next . next = newNode ( 3 )
    head . next . next . next = newNode ( 4 )
    head . next . next . next . next = newNode ( 5 )
    head . next . next . next . next . next = newNode ( 6 )
    head . next . next . next . next . next . next = newNode ( 7 )
    head . next . next . next . next . next . next . next = newNode ( 8 )
    k = 3
    head = deleteKthNode ( head , k )
    displayList ( head )

Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , d ) :
        self . data = d
        self . next = None
        self . head = None
    def LinkedListLength ( self ) :
        while ( self . head != None and self . head . next != None ) :
            self . head = self . head . next . next
        if ( self . head == None ) :
            return 0
        return 1
    def push ( self , info ) :
        node = Node ( info )
        node . next = ( self . head )
        ( self . head ) = node
head = Node ( 0 )
head . push ( 4 )
head . push ( 5 )
head . push ( 7 )
head . push ( 2 )
head . push ( 9 )
head . push ( 6 )
head . push ( 1 )
head . push ( 2 )
head . push ( 0 )
head . push ( 5 )
head . push ( 5 )
check = head . LinkedListLength ( )
if ( check == 0 ) :
    print ( " Even " )
else :
    print ( " Odd " )

Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
head = None
n = 0
sum = 0
def push ( head_ref , new_data ) :
    global head
    new_node = Node ( 0 )
    new_node . data = new_data
    new_node . next = head_ref
    head_ref = new_node
    head = head_ref
def sumOfLastN_NodesUtil ( head , n ) :
    global sum
    if ( n <= 0 ) :
        return 0
    st = [ ]
    sum = 0
    while ( head != None ) :
        st . append ( head . data )
        head = head . next
    while ( n ) :
        n -= 1
        sum += st [ 0 ]
        st . pop ( 0 )
    return sum
head = None
push ( head , 12 )
push ( head , 4 )
push ( head , 8 )
push ( head , 6 )
push ( head , 10 )
n = 2
print ( " Sum ▁ of ▁ last " , n , " nodes ▁ = " , sumOfLastN_NodesUtil ( head , n ) )

Accumulator variables: n, st, sum
Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , x ) :
        self . data = x
        self . next = None
head = None
def push ( head_ref , new_data ) :
    new_Node = Node ( new_data )
    new_Node . data = new_data
    new_Node . next = head_ref
    head_ref = new_Node
    head = head_ref
    return head
def reverseList ( ) :
    global head ;
    current , prev , next = None , None , None ;
    current = head ;
    prev = None ;
    while ( current != None ) :
        next = current . next ;
        current . next = prev ;
        prev = current ;
        current = next ;
    head = prev ;
def sumOfLastN_NodesUtil ( n ) :
    if ( n <= 0 ) :
        return 0 ;
    reverseList ( ) ;
    sum = 0 ;
    current = head ;
    while ( current != None and n > 0 ) :
        sum += current . data ;
        current = current . next ;
        n -= 1 ;
    reverseList ( ) ;
    return sum ;
if __name__ == ' _ _ main _ _ ' :
    head = push ( head , 12 )
    head = push ( head , 4 )
    head = push ( head , 8 )
    head = push ( head , 6 )
    head = push ( head , 10 )
    n = 2 ;
    print ( " Sum ▁ of ▁ last ▁ " , n , " ▁ Nodes ▁ = ▁ " , sumOfLastN_NodesUtil ( n ) ) ;

Accumulator variables: n, sum
Class/struct names: Node
Python program:
class Node :
    def __init__ ( self , x ) :
        self . data = x
        self . next = None
head = None
def push ( head_ref , new_data ) :
    new_Node = Node ( new_data )
    new_Node . data = new_data
    new_Node . next = head_ref
    head_ref = new_Node
    head = head_ref
    return head
def sumOfLastN_NodesUtil ( head , n ) :
    if ( n <= 0 ) :
        return 0
    sum = 0
    len = 0
    temp = head
    while ( temp != None ) :
        len += 1
        temp = temp . next
    c = len - n
    temp = head
    while ( temp != None and c > 0 ) :
        temp = temp . next
        c -= 1
    while ( temp != None ) :
        sum += temp . data
        temp = temp . next
    return sum
if __name__ == ' _ _ main _ _ ' :
    head = push ( head , 12 )
    head = push ( head , 4 )
    head = push ( head , 8 )
    head = push ( head , 6 )
    head = push ( head , 10 )
    n = 2
    print ( " Sum ▁ of ▁ last ▁ " , n , " ▁ Nodes ▁ = ▁ " , sumOfLastN_NodesUtil ( head , n ) )

Accumulator variables: c, len, sum
Class/struct names: Node
Python program:
class Node :
    def __init__ ( self ) :
        self . data = 0
        self . next = None
def push ( head_ref , new_data ) :
    new_node = Node ( )
    new_node . data = new_data
    new_node . next = ( head_ref )
    ( head_ref ) = new_node
    return head_ref
def mergeLists ( a , b ) :
    while ( a and b ) :
        if ( a . data > b . data ) :
            a . data , b . data = b . data , a . data
            temp = b
            if ( b . next and b . data > b . next . data ) :
                b = b . next
                ptr = b
                prev = None
                while ( ptr and ptr . data < temp . data ) :
                    prev = ptr
                    ptr = ptr . next
                prev . next = temp
                temp . next = ptr
        a = a . next
def printList ( head ) :
    while ( head ) :
        print ( head . data , end = ' - > ' )
        head = head . next
    print ( ' NULL ' )
if __name__ == ' _ _ main _ _ ' :
    a = None
    a = push ( a , 10 )
    a = push ( a , 8 )
    a = push ( a , 7 )
    a = push ( a , 4 )
    a = push ( a , 2 )
    b = None
    b = push ( b , 12 )
    b = push ( b , 3 )
    b = push ( b , 1 )
    mergeLists ( a , b )
    print ( " First ▁ List : ▁ " , end = ' ' )
    printList ( a )
    print ( " Second ▁ List : ▁ " , end = ' ' )
    printList ( b )

Class/struct names: Node
Python program:
class Node :
    def __init__ ( self ) :
        self . data = 0
        self . next = None
def countOfNodes ( head ) :
    count = 0
    while ( head != None ) :
        head = head . next
        count += 1
    return count
def deleteMid ( head ) :
    if ( head == None ) :
        return None
    if ( head . next == None ) :
        del head
        return None
    copyHead = head
    count = countOfNodes ( head )
    mid = count // 2
    while ( mid > 1 ) :
        mid -= 1
        head = head . next
    head . next = head . next . next
    return copyHead
def printList ( ptr ) :
    while ( ptr != None ) :
        print ( ptr . data , end = ' - > ' )
        ptr = ptr . next
    print ( ' NULL ' )
def newNode ( data ) :
    temp = Node ( )
    temp . data = data
    temp . next = None
    return temp
if __name__ == ' _ _ main _ _ ' :
    head = newNode ( 1 )
    head . next = newNode ( 2 )
    head . next . next = newNode ( 3 )
    head . next . next . next = newNode ( 4 )
    print ( " Gven ▁ Linked ▁ List " )
    printList ( head )
    head = deleteMid ( head )
    print ( " Linked ▁ List ▁ after ▁ deletion ▁ of ▁ middle " )
    printList ( head )

Accumulator variables: count, mid
Class/struct names: Node