SPOJ problem - The last digit of a number to a power (follow up) As a follow up to my post here. Please refer to the problem statement in that post.

I have edited this code to make it time efficient, but doing so the size of the source file has crossed the limit of 700 bytes. How do I reduce the file size?

#include &lt;stdio.h&gt;

int main()
{
    int t;
    scanf("%d",&amp;t);
    while(t--)
    {
        long long int base,exponent;
        scanf("%lld%lld",&amp;base,&amp;exponent);
        if(exponent==0)
        {
            printf("1\n");
        }
        else
        {
            int i;
            int dig[5];
            dig[0]=1;
            for(i=1;i&lt;=4;i++)
            {
                dig[i]=(base*dig[i-1])%10;
            }
            if(exponent%4==0)
                printf("%d\n",dig[4]);
            else if(exponent%4==1)
                printf("%d\n",dig[1]);
            else if(exponent%4==2)
                printf("%d\n",dig[2]);
            else if(exponent%4==3)
                printf("%d\n",dig[3]);
        }
    }
    return 0;
}
It really isn't that hard to bring your code under 700 bytes.  Just replacing base and exponent with a and b, respectively, would do the trick.  Normally, such renaming would hurt readability.  But here, you are just matching the terminology in the question, which arguably improves intelligibility.

You can also trim obvious fat, such as


eliminating the implicit return 0
long instead of long long int
switching to a more efficient brace style


The cases at the end can all be collapsed using a bit of modulo arithmetic.

There is plenty of room within 700 bytes for writing nice code.  You can expand dig into digit.  You can add customary spaces around operators for readability.  You can even write a long explanatory comment.

#include &lt;stdio.h&gt;

/*
The last digit of pow(a, b) cycles with b modulo 4.

0, 0, 0, 0, 0, ...
1, 1, 1, 1, 1, ...
2, 4, 8, 6, 2, ...
3, 9, 7, 1, 3, ...
4, 6, 4, 6, 4, ...
5, 5, 5, 5, 5, ...
6, 6, 6, 6, 6, ...
7, 9, 3, 1, 7, ...
8, 4, 2, 6, 8, ...
9, 1, 9, 1, 9, ...
*/
int main() {
    int t;
    scanf("%d", &amp;t);
    while (t--) {
        long a, b;
        scanf("%ld%ld", &amp;a, &amp;b);
        if (b == 0) {
            printf("1\n");
        } else {
            int i;
            int digit[4];
            digit[0] = 1;
            for (i = 1; i &lt;= 4; i++) {
                digit[i % 4] = (a * digit[i - 1]) % 10;
            }
            printf("%d\n", digit[b % 4]);
        }
    }
}


And we haven't even touched truly nefarious tricks like replacing spaces with tabs, which would save another hundred bytes!