SPOJ problem - The last digit of a number to a power (follow up)
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!