Linked List K append showing TLE

#include
#include
using namespace std;
class node{
public:
int data;
node*next;
node(int d){
data=d;
next=nullptr;
}
};

void insertAtHead(node* &head, int data){
noden=new node(data);
n->next=head;
head=n;
}
void insertAtTail(node
&head, int data){
if(head==nullptr){
head=new node(data);
return;
}

nodetail=head;
while(tail->next!=nullptr){
tail=tail->next;
}
tail->next=new node(data);
return;
}
void printList(node
head){
nodetemp=head;
while(temp!=nullptr){
cout<data<<" ";
temp=temp->next;
}
}
node
nodeFromLast(node head, int k){
node
fast=head;
nodeslow=head;
node
cSlow=head;
nodecFast=head;
int i=1;
while(i<=k){
fast=fast->next;
i++;
}
while(fast!=nullptr){
cFast=fast;
fast=fast->next;
cSlow=slow;
slow=slow->next;
}
cSlow->next=nullptr;
cFast->next=head;
head=slow;
return head;
}
int main(){
node
head=nullptr;
int n;
int data;
cin>>n;
for(int i=0;i<n;i++){
cin>>data;
insertAtTail(head,data);
}
int k;
cin>>k;
node* headF=nodeFromLast(head,k);
printList(headF);
return 0;
}