criyle/codenet-compile-errors huggingface dataset:
Language: C

#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


//////////////////////////////////////
ll f(ll n,ll k){
    ll a=k*(n-k)+1;
}

int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    if(k>n)ans=1;
    arep(i,k,n+2){
        ans+=(i*(n-i+1)+1);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.util.Scanner;

public class D {
	static final long M = 1000000007;
	public static void main(String[] args) {
		long N, K, res = 0;
		Scanner sc = new Scanner(System.in);
		N = sc.nextLong();
		K = sc.nextLong();
		for(long i=K; i<=N+1; i++) {
			res = (res + (N*i%M -i*i%M + i +1)%M)%M;
		}
		System.out.println(res);
	}
}


Compiler output:
Main.java:3: error: class D is public, should be declared in a file named D.java
public class D {
       ^
1 error
Language: C++

#include<bits/stdc++.h>
const long int p=1e9+7;

using namespace std;

void fun()
{
    long long int n,k;
    cin>>n>>k;

   for (int x = k; x <= n + 1; x++) {
        long minsum = (long)x * (x - 1) / 2; //0 + 1 + .. + x - 1
        long maxsum = (long)n * x - minsum;  //n + (n - 1) + ... + (n - (x - 1));
        res += (maxsum - minsum + 1);
        res %= 1000000007;
    }
    cout << res << "\n";
 
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    fun();
    return 0;
}


Compiler output:
a.cc: In function 'void fun()':
a.cc:14:9: error: 'res' was not declared in this scope
   14 |         res += (maxsum - minsum + 1);
      |         ^~~
a.cc:17:13: error: 'res' was not declared in this scope
   17 |     cout << res << "\n";
      |             ^~~
Language: C++

#include<iostream>
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    long long tmpmin=0,tmpmax=0;
    long lomg sum=1;
    for(int i=k;i<=n;i++){
        int tmpmin=0,tmpmax=0;
        tmpmin=(i*(i-1))/2;
        tmpmax=(i*(2*n-i+1))/2;
        
        sum=(sum+(tmpmax-tmpmin+1))%1000000007;
        //cout<<"max="<<tmpmax<<"\n";
        //cout<<"min="<<tmpmin<<"\n";
        //cout<<sum<<"\n";
    }
    cout<<sum<<"\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: expected initializer before 'sum'
    8 |     long lomg sum=1;
      |               ^~~
a.cc:14:9: error: 'sum' was not declared in this scope
   14 |         sum=(sum+(tmpmax-tmpmin+1))%1000000007;
      |         ^~~
a.cc:19:11: error: 'sum' was not declared in this scope
   19 |     cout<<sum<<"\n";
      |           ^~~
Language: C++

#include<iostream>
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int tmpmin=0,tmpmax=0;
    int sum=1;
    for(int i=k;i<=n;i++){
        int tmpmin=0,tmpmax=0;
        tmpmin=(i*(i-1))/2
        tmpmax=(i*(2*n-i+1))/2;
        
        sum=(sum+(tmpmax-tmpmin+1))%100000007;
        //cout<<"max="<<tmpmax<<"\n";
        //cout<<"min="<<tmpmin<<"\n";
        //cout<<sum<<"\n";
    }
    cout<<sum<<"\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:27: error: expected ';' before 'tmpmax'
   11 |         tmpmin=(i*(i-1))/2
      |                           ^
      |                           ;
   12 |         tmpmax=(i*(2*n-i+1))/2;
      |         ~~~~~~
Language: C++

#include<iostream>
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    int tmpmin=0,tmpmax=0;
    int sum=1;
    for(int i=k;i<=n;i++){
        int tmpmin=0,tmpmax=0;
        tmpmin=(i*(i-1))/2
        tmpmax=(i*(n2*n-m+1))/2;
        
        sum=(sum+(tmpmax-tmpmin+1))%100000007;
        //cout<<"max="<<tmpmax<<"\n";
        //cout<<"min="<<tmpmin<<"\n";
        //cout<<sum<<"\n";
    }
    cout<<sum<<"\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:27: error: expected ';' before 'tmpmax'
   11 |         tmpmin=(i*(i-1))/2
      |                           ^
      |                           ;
   12 |         tmpmax=(i*(n2*n-m+1))/2;
      |         ~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    ll mod=1000000007;
    ll n,k;
	cin >> n>> k;
    ll ans=0;
    fro(i,k,n+2){
      ans+=(n+1-i)*i+1
      ans%=mod;
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:23: error: expected ';' before 'ans'
   16 |       ans+=(n+1-i)*i+1
      |                       ^
      |                       ;
   17 |       ans%=mod;
      |       ~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll sum(ll a, ll b) {
    return (a+b)*(b-a+1)/2;
}

int main() {
  long long mod = 1000000007;
  long long n, k; cin >> n >> k;
　long long ans;

  for (long long i=k; i<=n+1; i++){
    ll l = sum(0,i-1)/*小さい方からk個の和(=min)*/, r = sum(n-i+1,n);/*大きい方からk個の和(=max)*/
    ans += r-l+1;
  }   
    cout << ans%mod << "\n";
    return 0;
}


Compiler output:
a.cc:12:1: error: extended character 　 is not valid in an identifier
   12 | 　long long ans;
      | ^
a.cc: In function 'int main()':
a.cc:12:1: error: '\U00003000long' was not declared in this scope; did you mean 'ulong'?
   12 | 　long long ans;
      | ^~~~~~
      | ulong
a.cc:16:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |     ans += r-l+1;
      |     ^~~
      |     abs
a.cc:18:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |     cout << ans%mod << "\n";
      |             ^~~
      |             abs
Language: C++

#include<stio.h>
#define MOD 1000000007
int main(void){
  long long int n,k,ans=0;
  scanf("%lld %lld",&n,&k);
  for(long long int i=k;i<=n+1;i++){
    ans=(ans+(n-i+1)*i+1)%MOD;
  }
  printf("%lld\n",ans);
}

Compiler output:
a.cc:1:9: fatal error: stio.h: No such file or directory
    1 | #include<stio.h>
      |         ^~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#define MOD (10e9+7)

using namespace std;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); 
 
  int n, k;
  int ans = 0;
  cin >> n >> k;
  for(; k <= n+1; k++){
      int tmp =  (((long long)k*(n-k)) % MOD + k + 1) % MOD;
      ans = (ans+tmp) % MOD;
  }

  cout << ans;

     



    
    return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:40: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   15 |       int tmp =  (((long long)k*(n-k)) % MOD + k + 1) % MOD;
      |                   ~~~~~~~~~~~~~~~~~~~~ ^
      |                                |
      |                                long long int
a.cc:16:23: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   16 |       ans = (ans+tmp) % MOD;
      |             ~~~~~~~~~ ^
      |                 |
      |                 int
Language: C++

#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	long N,K; cin >> N >> K;
	
	long minSum = 0;
	long maxSum = 0;
	long ans = 0;
	for (long i = K; i <= N + 1; i++) {
		minSum = (i * (i - 1) / 2) % MOD;	
		minSum *= 2;
		minSum %= MOD;
		ans += (i * N) % MOD  - minSum + 1;
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:24:18: error: expected '}' at end of input
   24 |         return 0;
      |                  ^
a.cc:8:34: note: to match this '{'
    8 | int main(int argc, char *argv[]) {
      |                                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 1000000009
int main(void)
{
  int n,k;
  cin >> n >> k;
  ll c = 0;
  ll m=k*(k-1)/2;,M=k*(2*n-k+1)/2;
  c+=(M - m+ 1)%MAX;
  for(int i=k;i<n+1;i++)
  {
    m += i%MAX;
    M += (n-i)%MAX;
    c+=(M - m+ 1)%MAX;
  }
  cout << c << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: expected primary-expression before ',' token
   10 |   ll m=k*(k-1)/2;,M=k*(2*n-k+1)/2;
      |                  ^
a.cc:10:19: error: 'M' was not declared in this scope
   10 |   ll m=k*(k-1)/2;,M=k*(2*n-k+1)/2;
      |                   ^
Language: C++

#include<iostream>
#include<vector>
#include<set>
using namespace std;
#define ll long long
#define C 1000000009

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> nums(N+1);
  set<ll> S;
  for (int i = 0; i < N+1; ++i) nums[i] = i;
  for (int bit = 0; bit < (2 << N); ++bit){
    int count = 0;
    ll sum = 0;
    for (int i = 0; i < N; i++){
      if (bit & (1 << i)) ++count;
    }
    if (count < K) continue;
    for (int i = 0; i < N; i++){
      if (bit & (1 << i)){
        sum += nums[i];
        sum %= C;
      }
    }
    S.insert(sum);
  }
  
  cout << sum.size() << endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:30:11: error: 'sum' was not declared in this scope
   30 |   cout << sum.size() << endl;
      |           ^~~
Language: C

#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans,cnt;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n,k;
	cin >> n >> k;
	
	for (ll i = k; i <= n + 1; i++) {
		ll l = (i * (i - 1)) / 2;
		ll r = (2 * n - i + 1) * i / 2;
		ans += r - l + 1;
	}
	
	cout << ans % MOD << endl;

	return 0;
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  ll ans=0;
  ireps(i,k,n+1){
    ll min=i*(i-1)/2;
    ll max=(n+1)*n/2-(n-i+1)*(n-i)/2;
    // cout<<min<<' '<<max<<endl;
    (ans+=(max-min+1)%MOD)%=MOD;
  }
  cout<<ans<<endl;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N,K ;
    cin >> N >> K ;
    long long  mod = 1000000007 ;
    int s = 0 ;
    int ans = 0 ;
    for(int idx = K;idx <= N+1 ;idx++){
        int min_val = idx * (2 * s + idx - 1) / 2;
        int max_val = idx * (2 * s + 2 * N - idx + 1) / 2 ;
        ans += (max_val - min_val + 1);
    }
    cout << ans << endl ;
    
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  int N, K; cin >> N >> K;

  int min_num = 0;
  int max_num = 0;
  ll cnt = 0;
  for(int i = 0; i < K; ++i) {
    min_num += i;
    max_num += (N - i);
  }

  cnt += max_num - min_num + 1;

  for(int i = K; i <= N; ++i) {
    min_num += i;
    max_num += (N - i);

    cnt += max_num - min_num + 1;
  }

  cout << cnt << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;
typedef long long ll;
ll f(ll n){
  return n*(n+1)/2;
}

int main(){
  ll n,k;
  cin>>n>>k;
  ll mod=pow(10,9)+7;
  ll sum=0;
  for(ll i=k;i<=k;i++){
    sum+=f(n+1)-f(n+1-i)-f(i)+1;
    sum%=mod;
  }
  cout<<sum<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: 'pow' was not declared in this scope
   11 |   ll mod=pow(10,9)+7;
      |          ^~~
Language: C++

#include <bits/stdc++.h>
using namespace;
int main(){
  int64_t N, K, A, x,answer;
  answer=0;
  cin >> N >> K;
  for(x=K;x<N+2;x++){
    A=x*N+1;
  for(int i=1;i<x;i++){
    A-=2*i;
  }
    answer+=A
  }
  cout << answer%1000000007 << endl;
}
  
  
  

Compiler output:
a.cc:2:16: error: expected identifier before ';' token
    2 | using namespace;
      |                ^
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |   cin >> N >> K;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:12:14: error: expected ';' before '}' token
   12 |     answer+=A
      |              ^
      |              ;
   13 |   }
      |   ~           
a.cc:14:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   14 |   cout << answer%1000000007 << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:14:32: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   14 |   cout << answer%1000000007 << endl;
      |                                ^~~~
      |                                std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C

#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct mint {
  ll x;
  mint(ll x=0) : x(x%mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x -= a.x) < 0) x += mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) {
    mint res(*this);
    return res*=a;
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  ll l = 0, r = 0;
  mint ans = 1;
  rep(i, k) l += i, r += (n-i);
  srep(i, k, n+1) {
    ans += r-l+1;
    l += i, r += (n-i);
  }
  std::cout << ans.x << "\n";
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,k; cin>>n>>k;
  ll ans=0;
  ireps(i,k,n+1){
    ll l=i*(i-1)/2;
    ll r=n*(n+1)/2-(n-i+1)*(n-i)/2;
    // cout<<l<<" "<<r<<endl;
    ans+=(r-l+1)%MOD;
    ans=(ans+MOD)%MOD;
  }
  cout<<ans<<endl;
 }

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main(){
  	int n,k,i;
  	cin>>n>>k;
  	int sum = 0;
  	for(i=k;i<=n+1;i++){
    	sum += (n*i - i*(i-1) + 1) %= mod;
    }
    cout<<sum<<"\n";
}	


Compiler output:
a.cc: In function 'int main()':
a.cc:9:31: error: lvalue required as left operand of assignment
    9 |         sum += (n*i - i*(i-1) + 1) %= mod;
      |                ~~~~~~~~~~~~~~~^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main(){
  	int n,k,i;
  	cin>>n>>k;
  	int sum = 0;
  	for(i=k;i<=n+1;i++){
    	sum += (n*i - i*(i-1) + 1) %= mod;
    cout<<sum<<"\n";
}	


Compiler output:
a.cc: In function 'int main()':
a.cc:9:31: error: lvalue required as left operand of assignment
    9 |         sum += (n*i - i*(i-1) + 1) %= mod;
      |                ~~~~~~~~~~~~~~~^~~~
a.cc:11:8: error: expected '}' at end of input
   11 | }
      |  ^      
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C

#include "bits/stdc++.h"
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MOD 1000000007
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  long long n;
  cin>>n;

  long long k;  
  cin>>k;  
  //for each interval of i numbers>=k,we can compose every sum from min to max of this size
  long long ans=0; 


 for(long long i=k;i<=n+1;i++){
   		ans+=i*n-i*(i-1)/2 -(i-1)*i/2 +1;  //max sum - min sum+1,max sum being the sum of last i numbers 


 }  

cout<<ans%MOD<<endl;
     
  return 0;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include "bits/stdc++.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;

ll sum(ll l, ll r) { return (l + r) * (r - l + 1) / 2; }

int main() {
  int N, K;
  cin >> N >> K;
  ll ans = 0;
  for (int i = K; i <= N + 1; i++) {
    ll l = sum(0, i - 1), r = sum(N - i + 1, N);
    ans += r - l + 1;
    ans = ans % 1000000007;
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

def sum_start(k):
    return (k-1) * k / 2

def sum_end(n,k):
    return sum_start(n+1) - sum_start(n-k+1)


N,K = map(int, input().split())

total = 0
while((N + 1) >= K):
    start = sum_start(K)
    end = sum_end(N,K)
    total += end - start + 1
    K += 1

print(int(total % (10 ** 9 + 7)))

Compiler output:
main.c:1:1: error: unknown type name 'def'
    1 | def sum_start(k):
      | ^~~
main.c: In function 'sum_start':
main.c:1:17: error: expected declaration specifiers before ':' token
    1 | def sum_start(k):
      |                 ^
main.c:1:5: error: type of 'k' defaults to 'int' [-Wimplicit-int]
    1 | def sum_start(k):
      |     ^~~~~~~~~
Language: C

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define MOD 1000000007

int main() {
    int n, k;
    cin >> n >> k;

    vector<ll> a(n + 2);

    for (int i = 1; i <= n; i++) {
        a[i + 1] = a[i] + i;
    }

    int ans = 0;
    for (int i = k; i <= n; i++) {
        ans = (ans + a[n + 1] - a[n + 1 - i] - a[i] + 1) % MOD;
    }

    cout << ans + 1 % MOD << endl;

    return 0;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1000000007;

int main() {
  ll N, K;
  cin >> N >> K;
  
  //累積和
  vector<ll> sum(N+2);
  for( ll i = 0; i <= N; i++ ) sum.at(i+1) = sum.at(i)+i;
  
  ll ans = 0;
  for( ll i = K; i <= N+1; i++ ){
    ll MIN = sum.at(i);
    ll MAX = sum.at(N+1) - sum.at(N+1-i);
    ans += (MAX-MIN)+1;
    ans %= MOD;
  }
  cout << ans << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

n, k = map(int, input().split())
l = [_ for _ in range(n + 1)]

x = 0
for i in range(k, n+2):
    x += sum(l[-1:-i-1:-1]) - sum(l[0:i]) + 1

print(x % (10**9+7))


Compiler output:
main.c:1:1: warning: data definition has no type or storage class
    1 | n, k = map(int, input().split())
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:1:4: error: type defaults to 'int' in declaration of 'k' [-Wimplicit-int]
    1 | n, k = map(int, input().split())
      |    ^
main.c:1:8: error: implicit declaration of function 'map' [-Wimplicit-function-declaration]
    1 | n, k = map(int, input().split())
      |        ^~~
main.c:1:12: error: expected expression before 'int'
    1 | n, k = map(int, input().split())
      |            ^~~
main.c:2:1: error: expected ',' or ';' before 'l'
    2 | l = [_ for _ in range(n + 1)]
      | ^
Language: C

#include <cstdio>
#include <algorithm>
#include <cmath>

using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
template<class T>bool CHMAX(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool CHMIN(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)


int main() {
	ll n,k;
	scanf("%lld", &n);
	scanf("%lld", &k);
	ll sum=0;
	FOR(i, k, n+1) {
		sum += (2 * n - i + 1) * i / 2 - (i - 1) * i / 2 + 1;
	}
	ll res = sum % MOD;
	printf("%lld\n", res);
	return(0);
}

Compiler output:
main.c:1:10: fatal error: cstdio: No such file or directory
    1 | #include <cstdio>
      |          ^~~~~~~~
compilation terminated.
Language: C

#include<iostream>
#define int long long
#define mod 1000000007
#define puts(x) cout << x << endl
using namespace std;
int ans, n, k;
signed main() {
	cin >> n >> k;
	for (int i = k; i <= n + 1; i++)ans = (ans + i * (n - i + 1) + 1) % mod;
	puts(ans);
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include <cstdio>
using namespace std;
const int mod = 1000000007;
int N,K,ans;
int main() {
    scanf("%d%d",&N,&K);
    for (int i = K;i <= N + 1;i++) {
        ans += (((1LL * (N - i + 1 + N) * i) >> 1) - ((1LL * (i - 1) * i) >> 1) + 1) % mod;
        ans %= mod;
    }
    printf("%d\n",ans);
}


Compiler output:
main.c:1:10: fatal error: cstdio: No such file or directory
    1 | #include <cstdio>
      |          ^~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint choose(ll n, ll a){
    mint x, y;
    x = 1; y = 1;
    rep(i,a){
        x *= (a - i);
        y *= (n - i);
    }
    y /= x;
    return y;
    }

int main(){
    ll n, k;
    cin >> n >> k;
    mint ans;
    for (int i = k; i < n + 2; i ++){
        ans += (mint(n) - mint(i) + 1) * mint(i) + 1;
    }
    cout << ans.x << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

void load(void);
void calc(void);
void output(void);

long long N, K, countt;

int main(){
	load();
	calc();
	output();
	return 0;
}

void load(void){
	cin >> N >> K;
}

void calc(void){
	countt = (N+1)*(((N+2)*5*N/6) + 1) - K*(K-1)*(N/2 + 5/6 - K/3) - K + 1;
}

void output(void){
	cout << countt;
}

Compiler output:
main.c:2:10: fatal error: iostream: No such file or directory
    2 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll>Q;

ll suml[200010];
ll sumr[200010];

int main(void){
    ll n,k;
    cin>>n>>k;
    ll ans = 0;
    for(ll i=0;i<=n;i++){
        suml[i+1]=suml[i]+i;
    }
    for(ll i=0;i<=n;i++){
        sumr[i+1]=sumr[i]+n-i;
    }
    for(ll i=k;i<=n+1;i++){
        ll mi = suml[i];
        ll ma = sumr[i];
        ll tmp = (ma-mi+1)%N;
        ans = (ans+tmp+N)%N;
        ans = (ans+N)%N;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	ll N, K; cin>>N>>K;
	ll ans = 0;
	for(ll i = K; i<=N+1; ++i){
		ll max = (2*N-i+1)*i/2 % MOD;
		ll min = (i-1)*i/2 % MOD;
		// cout<<max<<' '<<min<<endl;
		ans += (max-min)+1;
		ans %= MOD;
	}
	if(ans<0)ans += MOD;
	cout<<ans<<endl;
	return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;
int main() {
	int N, K;
	uint64_t  mod=pow(10, 9) + 7;
	cin >> N >> K;
	
	long long  total = 0;
	for (int i = K; i < N + 2; i++) {

		total += N * (N + 1) / 2 - (N - i)*(N - i + 1) / 2 - ((i - 1)*i) / 2 + 1;
	}
	cout << total%mod;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:9: error: 'uint64_t' was not declared in this scope
    5 |         uint64_t  mod=pow(10, 9) + 7;
      |         ^~~~~~~~
a.cc:2:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    1 | #include<iostream>
  +++ |+#include <cstdint>
    2 | using namespace std;
a.cc:13:23: error: 'mod' was not declared in this scope
   13 |         cout << total%mod;
      |                       ^~~
Language: C

#include <iostream>

using namespace std;

static long long sum (long long min, long long max) {
    return (min + max) * (max - min + 1) / 2;
}

int main (void) {
    int N, K;
    cin >> N >> K;

    long long ans = 0;
    long long min, max;

    for ( int i=K; i<=N+1; i++ ) {
        min = sum(0, i-1);
        max = sum(N-i+1, N);
        ans += (max - min + 1);
        ans %= 1000000007;
    }

    cout << ans << endl;
    return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
using namespace std;
int main() {
	int N, K;
	long  mod=pow(10, 9) + 7;
	cin >> N >> K;
	
	long long  total = 0;
	for (int i = K; i < N + 2; i++) {

		total += N * (N + 1) / 2 - (N - i)*(N - i + 1) / 2 - ((i - 1)*i) / 2 + 1;
	}
	cout << total%mod;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:19: error: 'pow' was not declared in this scope
    5 |         long  mod=pow(10, 9) + 7;
      |                   ^~~
Language: C++

#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

ll sum(ll l, ll r) {
    return (l+r)*(r-l+1)/2;
}

int main(){
    int n, k;
    cin >> n >> k;
    for ( int i = k; i <= n + 1; ++i ) {
        ll l = sum(0, i-1), r = sum(n-i+1, n);
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:74:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   74 |         ans += r - l + 1;
      |         ^~~
      |         abs
a.cc:76:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   76 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C

#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n + 1);
    rep(i, n + 1)a[i] = i;
    vector<ll> a_sum(n + 2);
    a_sum[0] = 0;
    _rep(i, 1, n + 2){
        a_sum[i] = a_sum[i - 1] + a[i - 1];
        //cout << a_sum[i] << endl;
    }

    ll ans = 0;
    rep(i, n - k + 2){
        ans += (a_sum[n + 1] - a_sum[(n + 1 - k) - i]) - a_sum[k + i] + 1;    
        ans %= mod;
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;

int main() {
  long long int n, k, ans = 0, mod = 1000000007;
  cin >> n >> k;

  for (long long int i = k; i <= n + 1; i++) {
    ans += (n * i - i * (i - 1) + 1) % mod;
  }
  cout << ans % mod << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL N,K;cin >> N >> K;
    LL ans = 0;

    for(LL i = K;i <= N+1;i++){
        LL st = (i-1)*i/2;
        LL en = (N)*(N+1)/2;
        en -= ((N-i)*(N-i+1)/2);
        
        ans += (en - st +1);
        ans %= MOD;
    }

    cout << ans << endl;
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const double PI = acos(-1);
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n, k;
  cin >> n >> k;

  ll ans = 0;
  for(ll i = k; i <= n+1; i++){
    ans = (ans + i*(2*n-i+1)/2 - i*(i-1)/2 + 1) % mod;
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for(int i = k; i <= n+1; i++){
        ans  += (ll)(n-i+1)*i+1;
        ans %= mod;
    }
    cout << ans <<  endl;
        
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
  ll n,k,ans = 0,mod = 1e9+7;
  cin >> n >> k;
  for(int i = k;i <= n+1;i++){
    ans += i*(n-i+1)+1;
    ans %= mod;
  }
  cout << ans << endl;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (ll i = 0;i < (a);++i)
#define FOR(i,a,b) for (ll i = (a);i < (b); ++i)
#define FORR(i,a,b) for (ll i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,k;
    cin >> n >> k;
    ll answer = 0;

    ll min_sum = 0,max_sum = 0;
    REP(j,k-1){
        min_sum=(min_sum+j)%MOD;
    }
    FORR(j,n,n-k+2){
        max_sum=(max_sum+j)%MOD;
    }
    FOR(i,k,n+2){
        min_sum=(min_sum+(i-1))%MOD;
        max_sum=(max_sum+(n-i+1))%MOD;
        answer = (answer+(max_sum-min_sum)+1)%MOD;
    }
    while(answer < 0){
        answer += MOD;
    }
    cout << answer << endl;
    return 0;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N, K;
	cin >> N >> K;
	ll ans = 0;
	vector<ll> R(N+1);
	R[0] = 0;
	for (ll i = 1; i < N+1; i++)
		R[i] = R[i-1] + i;
	for (int i = K; i <= N+1; i++)
	{
		ll mn = R[i-1];
		int idx = max(0, N-i);
		ll mx = R[N] - R[idx];
		ans += (mx - mn + 1);
	}
	cout << ans << endl;
}



Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n, k;
  cin >> n >> k;
  mint ans = 0;
  rep2(i, k, n+2){
    ll l = (ll)(i-1)*(i)/2;
    ll r = (ll)i*(n+(n-i+1))/2;
    // cerr << l << " " << r << endl;
    ans += r - l + 1;
  }
  cout << ans.x << endl;
  return 0;
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
    bool operator<(const mint a){
        return x < a.x;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<mint> a(n+1);
    rep(i,n+1) a[i] = i;
    vector<mint> left(n+2, 0), right(n+2, 0);
    rep(i,n+1) left[i+1] = left[i] + a[i];
    rep(i,n+1) right[i+1] = right[i] + a[n-i];
    mint ans = 0;
    for(int i = k; i <= n+1; i++){
        mint add = right[i] - left[i] + 1;
        if(add < 0) continue;
        ans += add;
    }
    cout << ans.x << endl;
    return 0;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include "bits/stdc++.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  exrep(i,k,n+1){
    ans=ans+(i*(n-i+1))%MOD+1;
    ans%=MOD;
  }
  cout << ans << endl;
}


Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.