Language: C++

// prefix sum optimization
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long uull;

#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ull i=a;i<b;i++)
#define repb(i,a,b) for(ull i=a;i>=b;i--)
#define f(i,n) for (ull i=0;i<n;i++)
#define sieve(j,mp) for(ull j=2*i ; j<=mp ; j+=i)
#define pb(x) push_back(x)
#define mp(x,y) push_back(make_pair(x,y))
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ull t=1; while(t--)
#define F first
#define S second
main()
{
    flash
    clock_t launch=clock();
    test
    {
        ull n,k;
        cin>>n>>k;
        ull dp[n+1][k+1],psum[n+1][k+1],cd[n+1];
        mem(dp,0);mem(psum,0);
        f(i,k+1)psum[0][i]=1;
        rep(i,1,n+1) cin>>cd[i];
        rep(i,1,n+1)
        {
            f(j,k+1)
            {
            if(j-cd[i]<=0) dp[i][j]=psum[i-1][j];
            else dp[i][j]=psum[i-1][j]-psum[i-1][j-cd[i]-1];
            }
            f(j,k+1)
            {
                if(j) psum[i][j]=(psum[i][j-1]+dp[i][j])%INF;
                else psum[i][j]=1;
            }
        }
        cout<<dp[n][k]<<endl;
    }
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    return 0;
}


Compiler output:
a.cc:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   20 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:17:14: error: 'ull' was not declared in this scope; did you mean 'uull'?
   17 | #define test ull t=1; while(t--)
      |              ^~~
a.cc:24:5: note: in expansion of macro 'test'
   24 |     test
      |     ^~~~
a.cc:17:29: error: 't' was not declared in this scope; did you mean 'tm'?
   17 | #define test ull t=1; while(t--)
      |                             ^
a.cc:24:5: note: in expansion of macro 'test'
   24 |     test
      |     ^~~~
a.cc:26:12: error: expected ';' before 'n'
   26 |         ull n,k;
      |            ^~
      |            ;
a.cc:27:14: error: 'n' was not declared in this scope; did you mean 'yn'?
   27 |         cin>>n>>k;
      |              ^
      |              yn
a.cc:27:17: error: 'k' was not declared in this scope
   27 |         cin>>n>>k;
      |                 ^
a.cc:28:12: error: expected ';' before 'dp'
   28 |         ull dp[n+1][k+1],psum[n+1][k+1],cd[n+1];
      |            ^~~
      |            ;
a.cc:29:13: error: 'dp' was not declared in this scope; did you mean 'dup'?
   29 |         mem(dp,0);mem(psum,0);
      |             ^~
a.cc:8:26: note: in definition of macro 'mem'
    8 | #define mem(dp,a) memset(dp,a,sizeof dp)
      |                          ^~
a.cc:29:23: error: 'psum' was not declared in this scope
   29 |         mem(dp,0);mem(psum,0);
      |                       ^~~~
a.cc:8:26: note: in definition of macro 'mem'
    8 | #define mem(dp,a) memset(dp,a,sizeof dp)
      |                          ^~
a.cc:30:11: error: expected ';' before 'i'
   30 |         f(i,k+1)psum[0][i]=1;
      |           ^
a.cc:12:25: note: in definition of macro 'f'
   12 | #define f(i,n) for (ull i=0;i<n;i++)
      |                         ^
a.cc:30:11: error: 'i' was not declared in this scope
   30 |         f(i,k+1)psum[0][i]=1;
      |           ^
a.cc:12:29: note: in definition of macro 'f'
   12 | #define f(i,n) for (ull i=0;i<n;i++)
      |                             ^
a.cc:31:13: error: expected ';' before 'i'
   31 |         rep(i,1,n+1) cin>>cd[i];
      |             ^
a.cc:10:28: note: in definition of macro 'rep'
   10 | #define rep(i,a,b) for(ull i=a;i<b;i++)
      |                            ^
a.cc:31:13: error: 'i' was not declared in this scope
   31 |         rep(i,1,n+1) cin>>cd[i];
      |             ^
a.cc:10:32: note: in definition of macro 'rep'
   10 | #define rep(i,a,b) for(ull i=a;i<b;i++)
      |                                ^
a.cc:31:27: error: 'cd' was not declared in this scope
   31 |         rep(i,1,n+1) cin>>cd[i];
      |                           ^~
a.cc:32:13: error: expected ';' before 'i'
   32 |         rep(i,1,n+1)
      |             ^
a.cc:10:28: note: in definition of macro 'rep'
   10 | #define rep(i,a,b) for(ull i=a;i<b;i++)
      |                            ^
a.cc:32:13: error: 'i' was not declared in this scope
   32 |         rep(i,1,n+1)
      |             ^
a.cc:10:32: note: in definition of macro 'rep'
   10 | #define rep(i,a,b) for(ull i=a;i<b;i++)
      |                                ^
a.cc:34:15: error: expected ';' before 'j'
   34 |             f(j,k+1)
      |               ^
a.cc:12:25: note: in definition of macro 'f'
   12 | #define f(i,n) for (ull i=0;i<n;i++)
      |                         ^
a.cc:34:15: error: 'j' was not declared in this scope; did you mean 'jn'?
   34 |             f(j,k+1)
      |               ^
a.cc:12:29: note: in definition of macro 'f'
   12 | #define f(i,n) for (ull i=0;i<n;i++)
      |                             ^
a.cc:36:18: error: 'cd' was not declared in this scope
   36 |             if(j-cd[i]<=0) dp[i][j]=psum[i-1][j];
      |                  ^~
a.cc:39:15: error: expected ';' before 'j'
   39 |             f(j,k+1)
      |               ^
a.cc:12:25: note: in definition of macro 'f'
   12 | #define f(i,n) for (ull i=0;i<n;i++)
      |                         ^
a.cc:39:15: error: 'j' was not declared in this scope; did you mean 'jn'?
   39 |             f(j,k+1)
      |               ^
a.cc:12:29: note: in definition of macro 'f'
   12 | #define f(i,n) for (ull i=0;i<n;i++)
      |                             ^