#include <stdio.h>

int main() {
    int b=0;
    int a,c;
    int x[100][100];
    scanf("%d",&a);
    x[0][1]=0;
    x[0][2]=0;
    for(int i=1;i<a+1;i++)
    {
        scanf("%d",&x[i][1]);
        scanf("%d",&x[i][2]);
    }
    for(int i=0;i<a;i++)
    {
        b=x[i][1]-x[i+1][1];
        if(b<=-1)
        {
            b=b*-1;
        }
        c+=b;
        b=x[i][2]-x[i+1][2];
        if(b<=-1)
        {
            b=b*-1;
        }
        c+=b;
    }
    printf("%d",c);
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: