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

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

int N, K;

int Sum[200010];
map<int,int> counter[200010];

int f(int a)
{
	a += K * (int)1e9;
	return a % K;
}

signed main()
{
	cin >> N >> K;

	int ans = 0;

	rep1(i, N) {
		cin >> Sum[i];
		Sum[i] += Sum[i-1];
		Sum[i] %= K;
	}

	counter[Sum[0] - 0]++;

	rep1(i, N) {
		if (i - K >= 0) counter[f(Sum[i - K] - (i - K))]--;
		ans += counter[f(Sum[i] - i)];
		counter[f(Sum[i] - i)]++;
	}

	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:28: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
   39 |         counter[Sum[0] - 0]++;
      |         ~~~~~~~~~~~~~~~~~~~^~
a.cc:42:65: error: no 'operator--(int)' declared for postfix '--' [-fpermissive]
   42 |                 if (i - K >= 0) counter[f(Sum[i - K] - (i - K))]--;
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
a.cc:43:21: error: no match for 'operator+=' (operand types are 'long long int' and 'std::map<long long int, long long int>')
   43 |                 ans += counter[f(Sum[i] - i)];
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:44:39: error: no 'operator++(int)' declared for postfix '++' [-fpermissive]
   44 |                 counter[f(Sum[i] - i)]++;
      |                 ~~~~~~~~~~~~~~~~~~~~~~^~
Language: C++

#include <bits/stdc++.h>
#include <map>
#include <iostream>

using namespace std;

int main() {
    int n, k;
  
    cin >> n >> k;
  
    vector<int> a(n), d(n + 1);
    
    for(int i=0;i<n;i++)
      cin >> a[i];
  
    for(int i=0;i<n;i++) {
        d[i + 1] = d[i] + a[i];
        d[i + 1] %= k;
    }
    map<int, int> m;
  
    int ans = 0;
  
    queue<int> q;

    int (int i=0;i<=n;i++) {
        int t = (d[i] - i) % k;
      
        if (t < 0) t += k;
        
        ans += m[t];
        m[t]++;
        
        q.push(t);
        if (q.size() >= k) {
            m[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
   

Compiler output:
a.cc: In function 'int main()':
a.cc:27:5: error: expected primary-expression before 'int'
   27 |     int (int i=0;i<=n;i++) {
      |     ^~~
a.cc:27:18: error: 'i' was not declared in this scope
   27 |     int (int i=0;i<=n;i++) {
      |                  ^
a.cc:41:25: error: expected '}' at end of input
   41 |     cout << ans << endl;
      |                         ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll sum[200009];
map<ll,ll>mp;

int main(){
  ll n,k;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    sum[i+1]=sum[i]+a;
    sum[i+1]%=k;
  }
  ll ans=0;
  for(int i=0;i<=n;i++){
    sum[i]=sum[i]-i;
    sum[i]%=k
    if(i-k>=0){
      mp[sum[i-k]]--;
    }
    ans+=mp[sum[i]];
    mp[sum[i]]++;
  }
  cout<<ans<<endl;
  return(0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:14: error: expected ';' before 'if'
   19 |     sum[i]%=k
      |              ^
      |              ;
   20 |     if(i-k>=0){
      |     ~~
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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 int INF = 1001001001;
using namespace std;
vector<int> g[100005];
int c[100005][100005];
int cc = 0;
void dfs(int n, int p, int pc) {
    int ref = 1;
    for(auto i: g[n]) {
        if (i == p) continue;
        if (ref == pc) ref++;
        c[n][i] = ref;
        c[i][n] = ref;
        dfs(i, n, ref);
        ref++;
    }
    chmax(cc, ref-1);
}

int main(){
    int N;
    cin >> N;
    int a[N], b[N];
    rep(i, N-1) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }

    dfs(0, -1, 0);
    cout << cc << endl;
    rep(i, N-1){
        cout << c[a[i]][b[i]] << endl;
    }

}

Compiler output:
/tmp/cc58NZpz.o: in function `dfs(int, int, int)':
a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `cc' defined in .bss section in /tmp/cc58NZpz.o
/tmp/cc58NZpz.o: in function `main':
a.cc:(.text+0x331): relocation truncated to fit: R_X86_64_PC32 against symbol `cc' defined in .bss section in /tmp/cc58NZpz.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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 int INF = 1001001001;
using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i]--;
    vector<int> s(n+1);
    rep(i, n) {
        s[i+1] = (s[i] + a[i]) % k;
    }
    map<int, int> mp;
    ll ans = 0;
    rep(j, n) {
        ans += mp[s[j]];
        mp[s[j]]++;
        if (q.size() == k) {
            mp[q.front()]--;
            q.pop();
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:13: error: 'q' was not declared in this scope
   30 |         if (q.size() == k) {
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if(flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
vl A,B(MAX_N,0),dp(MAX_N,0;
int main() {
    cin >> n >> k;
    rep(i, n) {
        cin >> a;
        a--;
        A.push_back(a);
    }

    rep(i, n) {
        B[i+1] = B[i];
        B[i+1] += A[i];
    }

    ans = 0;
    auto ite1 = A.begin(), ite2 = A.begin();
    while (ite2 != A.end()) {
        dp[B[ite2 - A.begin()] % k]++;
        ite2++;
        while (ite2-ite1>=k) {
            dp[B[ite1 - A.begin()] % k]--;
            ite1++;
        }
        ans += dp[B[ite2 - A.begin()]%k];
    }
    cout << ans << endl;
}


Compiler output:
a.cc:25:27: error: expected ')' before ';' token
   25 | vl A,B(MAX_N,0),dp(MAX_N,0;
      |                   ~       ^
      |                           )
Language: C++


#include <bits/stdc++.h>
typedef long long ll;
const int mod=1e9+7;
const int maxn=2e6+16;
const ll INF=100000000000005;
const double eps=1e-11;
using namespace std;
ll n,m,p;
map<ll,ll>mp;
ll sum[maxn];
ll num[maxn];
int main()
{
    ll res=0;//记录最终答案
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&num[i]);
        sum[i]=sum[i-1]+num[i];
    }
    for(int i=1;i<=n;i++)
        sum[i]=(sum[i]-i%m+m)%m;//预处理前缀和
    ll low=min(m-1,n);
    for(int i=0;i<=low;i++)
    {
        res+=mp[sum[i]];
        mp[sum[i]]++;
    }
    for(int i=low+1;i<=n;i++)
    {
        mp[sum[i-m]]--;
        res+=mp[sum[i]];
        mp[sum[i]]++;
    }
    printf("%lld\n",res);
    return 0;



Compiler output:
a.cc: In function 'int main()':
a.cc:37:14: error: expected '}' at end of input
   37 |     return 0;
      |              ^
a.cc:14:1: note: to match this '{'
   14 | {
      | ^
Language: C++

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

int main()
{
	ll N,K;
	cin>>N>>K;
	vector<ll> A(N+1);
	rep(i,N){
		ll tmp;
		cin>>tmp;
		A[i+1]=A[i]+tmp-1;
	}

	ll res=0;
	map<ll,ll> mp;	
	const ll start = min(K, (ll)A.size())+1:
	rep(i,start){
		mp[A[i]%K]++;
		//cout<<"debug "<<i<<" "<<A[i]<<endl;
	}
	for(auto& itr:mp){
		res+=itr.second*(itr.second-1)/2;
	}
	/*
	for(auto num:A)cout<<num<<" ";
	cout<<endl;
	*/
	REP(i,start,N+1){
		const ll l = i-start;
		const ll r = i;
		const ll tgt = A[r] % K;
		/*
		for(auto itr:mp){
			cout<<itr.first<<" "<<itr.second<<endl;
		}
		*/
		mp[A[l]%K]--;
		mp[A[r]%K]++;
		res += mp[tgt] * (mp[tgt]-1)/2;
	}

	cout<<res<<endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:48: error: expected ',' or ';' before ':' token
   20 |         const ll start = min(K, (ll)A.size())+1:
      |                                                ^
a.cc:21:13: error: 'i' was not declared in this scope
   21 |         rep(i,start){
      |             ^
a.cc:4:36: note: in definition of macro 'REP'
    4 | #define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
      |                                    ^
a.cc:21:9: note: in expansion of macro 'rep'
   21 |         rep(i,start){
      |         ^~~
Language: C++

#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef map<int, int> mii;

int main() {
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    long long ans = 0;
    mii c;
    int ps[n+1];
    ps[0] = 0;
    c[0]++;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        a = (a + k - 1) % k;

        if (i >= k) {
            c[ps[i-k]]--;
        }

        ps[i] = (ps[i-1] + a) % k;
        ans += c[ps[i]];

        c[ps[i]]++;
    }

    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc:8:9: error: 'vector' does not name a type
    8 | typedef vector<pii> vp;
      |         ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f[200009],sm,x,cnt,k,smm,xx,j;
long long pas;
unodrered_map <int, vector <int> > v;
vector <int>::iterator it;
unodrered_map <int, int> kl;
int mod(int q){
	if(q>=0) return q%k; else return (k+q%k)%k;
}
void rec(int q, int w){
	cnt++;
	if(q==w){
		if(f[q]%k==1) pas++;
//		cout<<q<<" "<<w<<" "<<pas-e<<endl;
		return;
	}
	int mid=(q+w)/2;
	if(k==1){
		rec(q,mid);
		rec(mid+1,w);
		return;
	}
	smm=0;xx=0;
/*	for(int i=mid+1; i<=w; i++){
		sm+=f[i];x++;
		sm%=k;
		if(x>=k) break;
		c=mod(x-sm);
		if(kl[c]!=cnt){
			kl[c]=cnt;
			v[c].clear();
		}
//		if(cnt==1){
//			cout<<i<<" "<<c<<" "<<x<<endl;
//		}
		v[c].push_back(x);
	}*/
	sm=0;x=0;
	for(int i=max(q,mid-k+3); i<=mid; i++){
		j=i;i=i+k-2;
		if(i<=w){
		smm+=f[i];xx++;
		smm%=k;
		if(xx>=k) break;
		c=mod(xx-smm);
		if(kl[c]!=cnt){
			kl[c]=cnt;
			v[c].clear();
		}
/*		if(cnt==1){
//			cout<<i<<" "<<c<<" "<<x<<endl;
		}*/
		v[c].push_back(xx);
	}
//	for(int i=mid; i>=q; i--){
i=j;
		sm+=f[i];x++;
		if(x>=k) break;
		sm%=k;
		c=mod(sm-x);
//		if(q==1&&w==3) cout<<i<<" "<<c<<" "<<it-v[c].begin()<<endl;
		if(kl[c]!=cnt) continue;
		pas+=v[c].size();
	}
//	cout<<q<<" "<<w<<" "<<pas-e<<endl;
	rec(q,mid);
	rec(mid+1,w);
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>k;
	for(int i=1; i<=a; i++) cin>>f[i];
	if(k==2){
		for(int i=1; i<=a; i++){
			sm=0;
			for(j=i; j<=min(a,i+1); j++){
				sm+=f[j];
				if(sm%k==j-i+1){
					pas++;
				}
			}
		}
		cout<<pas<<endl;
		return 0;
	}
//	cout<<mod(-24)<<endl;
	rec(1,a);
	cout<<pas;
	return 0;
}

Compiler output:
a.cc:5:1: error: 'unodrered_map' does not name a type
    5 | unodrered_map <int, vector <int> > v;
      | ^~~~~~~~~~~~~
a.cc:7:1: error: 'unodrered_map' does not name a type
    7 | unodrered_map <int, int> kl;
      | ^~~~~~~~~~~~~
a.cc: In function 'void rec(int, int)':
a.cc:47:20: error: 'kl' was not declared in this scope; did you mean 'k'?
   47 |                 if(kl[c]!=cnt){
      |                    ^~
      |                    k
a.cc:49:25: error: 'v' was not declared in this scope
   49 |                         v[c].clear();
      |                         ^
a.cc:54:17: error: 'v' was not declared in this scope
   54 |                 v[c].push_back(xx);
      |                 ^
a.cc:63:20: error: 'kl' was not declared in this scope; did you mean 'k'?
   63 |                 if(kl[c]!=cnt) continue;
      |                    ^~
      |                    k
a.cc:64:22: error: 'v' was not declared in this scope
   64 |                 pas+=v[c].size();
      |                      ^
Language: C++

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

typedef long long LL;
const int M=2e5+5;

int k;
int add(int x,int y)
{
	x+=y;
	if(x>=k) x-=k;
	return x;
}
int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=k;
	return x;
}
int a[M],sum[M];

unordered_map<int,int> ma;

// a        1 4 2  3  5
// sum    0 1 5 7 10 15
// mod    0 1 1 3  2  3
// id     0 1 2 3  4  5
// mod-id 0 0 3 0  2  2

int main()
{
	int n; 
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	LL ans=0;
	ma[0]++;
	for(int i=1;i<=n;i++)
	{
		sum[i]=add(sum[i-1],a[i]%k);
		ans+=ma[sub(sum[i],i%k)];
		ma[sub(sum[i],i%k)]++;
		// length of window < k
		if(i>=k-1)
			ma[sub(sum[i-k+1],(i-k+1)%k)]--;
	}
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: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() {
  int A;
  int B;
  cin >> A;
  cin >> B;
  vec<int> C(A);
  int i = 0;
  int D;
  int E = 0;
  int F = B - 1;
  while(i < A){
    cin >> C.at(i);
    i = i + 1;
  }
  if(A < B){
    B = A;
  }
  int j;
  while(F > 0){
    i = 1;
    while(i <= A - F - 1){
      j = i;
      D = 0;
      while(j <= F){
        D = D + C.at(i + j - 2);
        j = j + 1;
      }
      if(D % B == j){
        
      i = i + 1;
    }
    B = B - 1;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'vec' was not declared in this scope
    9 |   vec<int> C(A);
      |   ^~~
a.cc:9:7: error: expected primary-expression before 'int'
    9 |   vec<int> C(A);
      |       ^~~
a.cc:15:12: error: 'C' was not declared in this scope
   15 |     cin >> C.at(i);
      |            ^
a.cc:28:17: error: 'C' was not declared in this scope
   28 |         D = D + C.at(i + j - 2);
      |                 ^
a.cc:36:4: error: expected '}' at end of input
   36 |   }
      |    ^
a.cc:22:15: note: to match this '{'
   22 |   while(F > 0){
      |               ^
a.cc:36:4: error: expected '}' at end of input
   36 |   }
      |    ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: Java

import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		final int n=sc.nextInt();
		final int k=sc.nextInt();
		
		int[] sum=new int[n];
		
		long ans=0;
		
		long[] map=new int[k];
		
		for(int i=0;i<n;i++){
			int m=sc.nextInt();
			int a=(m-1)%k;
			
			if(i==0){
				sum[i]=a;
			}else{
				sum[i]=(sum[i-1]+a)%k;
			}
			
			map[sum[i]]++;
			if(i>=k-1)map[sum[i-k+1]]--;
			      //System.out.println(" sum:"+sum[i]+" map:"+map[sum[i]]);
			if(i<k-1){
				if(sum[i]==0)ans++;
			}
			ans=ans+map[sum[i]]-1;
			
	
			//System.out.println(" m:"+m+" a:"+a+" sum:"+sum[i]+" ans:"+ans);
			
		}
		System.out.println(ans);
	}
}
		
	

Compiler output:
Main.java:14: error: incompatible types: int[] cannot be converted to long[]
		long[] map=new int[k];
		           ^
1 error
Language: C++

#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
int main(){
  int n, k, A, count;
  vector<int> a(n);
  cin >> n >> k;
  count = 0;
  for(int i = 0; i < n; i++){
    cin >> A;
    a[i] = A;
  }
  
  for(int i = 0; i < n; i++){
    for(int j = i; j < n; j++){
      if(accumulate(i, i + j, 0) % k == j - i + 1){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Compiler output:
In file included from /usr/include/c++/14/numeric:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_numeric.h: In instantiation of '_Tp std::accumulate(_InputIterator, _InputIterator, _Tp) [with _InputIterator = int; _Tp = int]':
a.cc:17:20:   required from here
   17 |       if(accumulate(i, i + j, 0) % k == j - i + 1){
      |          ~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:141:48: error: invalid type argument of unary '*' (have 'int')
  141 |         __init = _GLIBCXX_MOVE_IF_20(__init) + *__first;
      |                                                ^~~~~~~~
Language: C++

#include<iostream>
#include<vector>
#include<numeric>
using namespace std;
int main(){
  int n, k, A, count;
  vector<int> a(n);
  cin >> n >> k;
  count = 0;
  for(int i = 0; i < n; i++){
    cin >> A;
    a[i] = A;
  }
  
  for(int i = 0; i < n; i++){
    for(int j = i; j < n; j++){
      if(accumulate(i, i + j) % k == j - i + 1){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:20: error: no matching function for call to 'accumulate(int&, int)'
   17 |       if(accumulate(i, i + j) % k == j - i + 1){
      |          ~~~~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n, k, A, count;
  vector<int> a(n);
  cin >> n >> k;
  count = 0;
  for(int i = 0; i < n; i++){
    cin >> A;
    a[i] = A;
  }
  
  for(int i = 0; i < n; i++){
    for(int j = i; j < n; j++){
      if(accumulate(i, i + j) % k == j - i + 1){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:10: error: 'accumulate' was not declared in this scope
   16 |       if(accumulate(i, i + j) % k == j - i + 1){
      |          ^~~~~~~~~~
Language: C++

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,ans=0,tmp,a;
  cin >> n >> k;
  vector<ll>b(n+1);
  for(int i=1;i<=n;i++){
  	cin >> a;
  	b[i]=(b[i-1]+a-1+k)%k;
  }
  for(int i=1;i<=n;i++){
  	for(ll j=i;j<=n;j++){
  		if((b[j]-b[i-1]+k)%k==0 ans++;
  	}
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:40: error: expected ';' before 'ans'
   17 |                 if((b[j]-b[i-1]+k)%k==0 ans++;
      |                                        ^~~~
      |                                        ;
a.cc:18:9: error: expected primary-expression before '}' token
   18 |         }
      |         ^
a.cc:17:47: error: expected ')' before '}' token
   17 |                 if((b[j]-b[i-1]+k)%k==0 ans++;
      |                   ~                           ^
      |                                               )
   18 |         }
      |         ~                                      
a.cc:18:9: error: expected primary-expression before '}' token
   18 |         }
      |         ^
Language: C++

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;



class ERemOfSumIsNum {
public:
    int dy[4]={-1,1,0,0};
    int dx[4]={0,0,1,-1};

	void solve(std::istream& in, std::ostream& out) {
        ll N, K;
        // vector<ll> factorSum = vector<ll>(N, 0);
        unordered_map<ll, ll> d;
        in >> N >> K;
        ll fsum = 0;
        vector<ll> fuctorSum(N+1);
        fuctorSum[0]=0;
        REP(i, N) {
            ll a;
            in >> a;
            fsum += a;
            fsum %= K;
            ll key = fsum - (i+1);
            while(key < K) {
                key += K;
            }
            key %= K;
            fuctorSum[i+1]=key;
        }

        ll ans = 0;
        REP(i, N+1) {
            auto idx = N - i;
            auto f = fuctorSum[idx];
            if (K <= i) {
                d[fuctorSum[idx + K]]--;
            }
            ans += d[fuctorSum[idx]];
            d[f]++;
        }
        out << ans << endl;
	}
};


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

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

int main() {
  ll n,k,ans=0,tmp,cnt,a;
  cin >> n >> k;
  vector<ll>b(n+1);
  for(int i=1;i<=n;i++){
  	cin >> a;
  	b[i]=(b[i-1]+a)%=k;
  }
  for(int i=1;i<=n;i++){
  	for(ll j=i;j<=n;j++){
  		cnt=j-i+1;
  		tmp=(b[j]-b[i-1])%k;
  		if(tmp<0) tmp+=k;
  		if(cnt==tmp) ans++;
  	}
  }
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:21: error: lvalue required as left operand of assignment
   11 |         b[i]=(b[i-1]+a)%=k;
      |              ~~~~~~~^~~
Language: C++

efine rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

int main() {
  ll n,k,ans=0,tmp,cnt;
  cin >> n >> k;
  vector<ll>a(n);
  vector<ll>b(n);
  rep(i,n){
  	cin >> a[i];
  	a[i]%=k;
  }
  b[0]=a[0];
  for(int i=1;i<n;i++){
  	b[i]=a[i]+b[i-1];
  	b[i]%=k;
  }
  rep(i,n){
  	for(ll j=i;j<n;j++){
  		cnt=j-i+1;
  		if(i==0) tmp=b[j];
  		else tmp=b[j]-b[i-1];
  		tmp%=k;
  		if(tmp<0) tmp+=k;
  		if(cnt==tmp) ans++;
  	}
  }
  cout << ans <<endl;
}


Compiler output:
a.cc:1:1: error: 'efine' does not name a type
    1 | efine rep(i,n) for(ll i=0;i<(n);i++)
      | ^~~~~
a.cc:1:27: error: 'i' does not name a type
    1 | efine rep(i,n) for(ll i=0;i<(n);i++)
      |                           ^
a.cc:1:33: error: 'i' does not name a type
    1 | efine rep(i,n) for(ll i=0;i<(n);i++)
      |                                 ^
a.cc: In function 'int main()':
a.cc:6:3: error: 'll' was not declared in this scope
    6 |   ll n,k,ans=0,tmp,cnt;
      |   ^~
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> n >> k;
      |   ^~~
a.cc:7:10: error: 'n' was not declared in this scope
    7 |   cin >> n >> k;
      |          ^
a.cc:7:15: error: 'k' was not declared in this scope
    7 |   cin >> n >> k;
      |               ^
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<ll>a(n);
      |   ^~~~~~
a.cc:8:13: error: 'a' was not declared in this scope
    8 |   vector<ll>a(n);
      |             ^
a.cc:9:13: error: 'b' was not declared in this scope
    9 |   vector<ll>b(n);
      |             ^
a.cc:10:7: error: 'i' was not declared in this scope
   10 |   rep(i,n){
      |       ^
a.cc:10:3: error: 'rep' was not declared in this scope
   10 |   rep(i,n){
      |   ^~~
a.cc:29:3: error: 'cout' was not declared in this scope
   29 |   cout << ans <<endl;
      |   ^~~~
a.cc:29:11: error: 'ans' was not declared in this scope
   29 |   cout << ans <<endl;
      |           ^~~
a.cc:29:17: error: 'endl' was not declared in this scope
   29 |   cout << ans <<endl;
      |                 ^~~~
Language: C++

#include<iostream>
#include<cstring>
#include<map>
#define N 200005
typedef long long ll;
using namespace std;
ll a[N],sum[N],n,K,res=0,mini;
map<ll,ll> s;
int main(){
	memset(a,0,sizeof(a));
	memset(sum,0,sizeof(sum));
	s.clear();
	scanf("%lld%lld",&n,&K);
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		a[i]%=K;
		//sum[i]=(sum[i-1]+a[i])%K;
		sum[i]=sum[i-1]+num[i];
	}
	for (int i=1;i<=n;i++)
		sum[i]=(sum[i]+K-i%K)%K;
	mini=min(n,K-1);
	/*
	map<int,int>::iterator iter;
	for (iter=s.begin();iter!=s.end();iter++)
		res+=(iter->second)*((iter->second)-1)/2;
	cout<<res<<endl;
    */
	for (int i=1;i<=mini;i++){
        res+=s[sum[i]];
        s[sum[i]]++;
    }
    for (int i=mini+1;i<=n;i++){
        s[sum[i-K]]--;
        res+=s[sum[i]];
        s[sum[i]]++;
    }
	printf("%lld",res);
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:18:33: error: 'num' was not declared in this scope; did you mean 'sum'?
   18 |                 sum[i]=sum[i-1]+num[i];
      |                                 ^~~
      |                                 sum
Language: C++

#include <stdio.h>
#include <stdlib.h>

int main()
{
  int N,K;
  int A[200000];
  int len;
  int lenmax;
  int start=0;
  int count=0;
  int sum;
  int i;

  scanf("%d %d\n", &N, &K);
  for (i=0;i<N;++i){
    scanf("%d", &A[i]);
    A[i]=A[i]%K;
    if (A[i]==1){
      ++count;
    }
  }
  
  while (start<N){
    sum=A[start];
    lenmax=K-1;
    if (N-start < lenmax){
      lenmax=N-start;
    }
    for(len=2;len<=lenmax;++len){
      if ((sum=sum+A[start+len-1])%K)==len){
        ++count;
      }
    }
    ++start;
  }
  
  printf("%d", count);
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:38: error: expected primary-expression before '==' token
   31 |       if ((sum=sum+A[start+len-1])%K)==len){
      |                                      ^~
Language: C++

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> csum(N+1, 0);
    rep(i, 0, N)
    {
        cin >> csum[i+1];
        csum[i+1] += csum[i];
    }
    rep(i, 0, N)
    {
        csum[i+1] -= i+1;
        csum[i+1] %= K;
        if (csum[i+1] < 0)
            csum[i+1] += K;
    }

    map<ll, int> n_cnts;
    for (int i=0; i<K-1 and i<N; ++i)
        ++n_cnts[csum[i+1]];
    
    int res = 0;
    rep(i, 0, N)
    {
        res += n_cnts[csum[i]];
        --n_cnts[csum[i+1]];
        if (i+K <= N)
      s      ++n_cnts[csum[i+K]];
    }
    cout << res << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:7: error: 's' was not declared in this scope
   35 |       s      ++n_cnts[csum[i+K]];
      |       ^
Language: C++

#include <iostream>
#include <vector>
#include <map>
using namespace std;
const int maxn=2e5+10;
typedef long long ll;

map<int,vector<int>> mp;
ll s[maxn];

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%lld",&s[i]),s[i]+=s[i-1];
    for(int i=1;i<=n;i++)
        s[i]=(s[i]-i)%k;
    ll ans=0;
    for(int i=0;i<=n;i++){
        if(mp.count(s[i])){
            auto v=mp[s[i]];
            ans+=(v.end()-upper_bound(v.begin(),v.end(),i-k));
        }
        mp[s[i]].push_back(i);
    }
    printf("%lld\n",ans);
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:27: error: 'upper_bound' was not declared in this scope
   22 |             ans+=(v.end()-upper_bound(v.begin(),v.end(),i-k));
      |                           ^~~~~~~~~~~
Language: C++

include <stdio.h>
#include <stdlib.h>

int main()
{
	int N,K;
	int A[200000];
	int len;
	int start=0;
	int count=0;
	int sum;
	int i;

	scanf("%d %d\n", &N, &K);
	for (i=0;i<N;++i){
		scanf("%d", &A[i]);
		A[i]=A[i]%K;
	}

	while (start<N){
		len=1;
		sum=0;
		for(i=start;len<K;++len){
			if (i+len-1<N){
				sum=(sum+A[i+len-1])%K;
				if (sum%K==len){
					++count;
				}
			}
		}
		++start;
	}

	printf("%d", count);

	return 0;
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <stdio.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:14:9: error: 'scanf' was not declared in this scope
   14 |         scanf("%d %d\n", &N, &K);
      |         ^~~~~
a.cc:34:9: error: 'printf' was not declared in this scope
   34 |         printf("%d", count);
      |         ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include <stdlib.h>
  +++ |+#include <cstdio>
    3 |
Language: C++

#include<iostream>
#include<map>
using namespace std;
const int max_N=100010;
int K,N,ans;
long long A[max_N],S[max_N];
int main()
{
    cin>>N>>K;
    for(int i=0; i<=N; i++){
        cin >> A[i];
        A[i]--;
        S[i+1] = (S[i] + A[i]+k) % K;
    }
    map<int,int>mp;
    for(int i=0;i<=N;i++)
    {
        if(i>=K)mp[S[i-K]]--;
        ans+=mp[S[i]];
        mp[S[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:31: error: 'k' was not declared in this scope
   13 |         S[i+1] = (S[i] + A[i]+k) % K;
      |                               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a;
    vector<ll> sum_a;
    sum_a.push_back(0);

    ll sum_tmp = 0;
    rep(i, n){ 
        int tmp; 
        cin >> tmp;
        sum_tmp += tmp;
        sum_a.push_back(sum_tmp);
    }

    map<int, int> amari;
//    rep(i, k) amari.insert(make_pair(i, 0));

    //show(sum_a);
 
    ll ans = 0;
    for (int j = 1; j <= n; j++)
    {
        int itr = (sum_a[j] - (ll)j) % (ll)k;


        int itr_plus = (sum_a[j - 1] - (ll)(j - 1)) % (ll)k;
        if (amari.count(itr_plus) == 0) amari.insert(make_pair(itr_plus, 0));
        amari[itr_plus]++;

        if ((j - k) >= 0) {
            int itr_minus = (sum_a[j - k] - (ll)(j - k)) % (ll)k;   
            if (amari.count(itr_minus) == 0) amari.insert(make_pair(itr_minus, 0));
            amari[itr_minus]--;
        }
        //cout << itr << " "<< amari[itr] << endl;
        if (amari.count(itr) == 0) amari.insert(make_pair(itr, 0));
        ans += amari[itr];

    }
    

    cout << ans << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:52:25: error: expected '}' at end of input
   52 |     cout << ans << endl;
      |                         ^
a.cc:10:1: note: to match this '{'
   10 | {
      | ^
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


ll digit(ll num){
	ll ret=0;
	string s=to_string(num);
	return s.length();
}
	
class Edge{
public:
	ll num;
	ll a;
	ll b;
	ll color=0;
	Edge(ll _num,ll _a,ll _b){
		num=_num;
		a=_a;
		b=_b;
	}
};
	
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	ll N,K;
	cin>>N>>K;
	vector<ll>A(N);
	vector<ll>dp(N+1);
	dp[0]=0;
	for(int i=0;i<N;i++){
		cin>>A[i];
		A[i]--;
		A[i]%=K;
		dp[i+1]=(dp[i]+A[i])%K;
	}
	
	map<ll,ll>mp;
	ll ans=0;
	queue<ll>que;
	for(int i=0;i<=N;i++){
		
		ans+=mp[dp[i]];
		mp[dp[i]]++;		
		
		que.push(dp[i]);
		if(que.size()==K){
			mp[que.front()]--;
			que.pop();
		}
	}
	cout<<ans<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:74:9: error: 'map' was not declared in this scope
   74 |         map<ll,ll>mp;
      |         ^~~
a.cc:10:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    9 | #include <queue>
  +++ |+#include <map>
   10 | #include <string>
a.cc:74:15: error: expected primary-expression before ',' token
   74 |         map<ll,ll>mp;
      |               ^
a.cc:74:18: error: expected primary-expression before '>' token
   74 |         map<ll,ll>mp;
      |                  ^
a.cc:74:19: error: 'mp' was not declared in this scope; did you mean 'dp'?
   74 |         map<ll,ll>mp;
      |                   ^~
      |                   dp
Language: C

int N,K;
ll A[202020];
ll S[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	map<ll,int> M;
	ll ret=0;
	M[0]=1;
	FOR(i,N) {
		cin>>A[i];
		S[i+1]=S[i]+A[i]+K-1;
		if(i+1-K>=0) M[S[i+1-K]%K]--;
		ret+=M[S[i+1]%K];
		M[(S[i+1])%K]++;
	}
	cout<<ret<<endl;
}

Compiler output:
main.c:2:1: error: unknown type name 'll'
    2 | ll A[202020];
      | ^~
main.c:3:1: error: unknown type name 'll'
    3 | ll S[202020];
      | ^~
main.c: In function 'solve':
main.c:6:28: error: unknown type name 'string'
    6 |         int i,j,k,l,r,x,y; string s;
      |                            ^~~~~~
main.c:8:9: error: 'cin' undeclared (first use in this function)
    8 |         cin>>N>>K;
      |         ^~~
main.c:8:9: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:9: error: 'map' undeclared (first use in this function)
    9 |         map<ll,int> M;
      |         ^~~
main.c:9:13: error: 'll' undeclared (first use in this function); did you mean 'l'?
    9 |         map<ll,int> M;
      |             ^~
      |             l
main.c:9:16: error: expected expression before 'int'
    9 |         map<ll,int> M;
      |                ^~~
main.c:10:11: error: expected ';' before 'ret'
   10 |         ll ret=0;
      |           ^~~~
      |           ;
main.c:11:9: error: 'M' undeclared (first use in this function)
   11 |         M[0]=1;
      |         ^
main.c:12:9: error: implicit declaration of function 'FOR' [-Wimplicit-function-declaration]
   12 |         FOR(i,N) {
      |         ^~~
main.c:12:17: error: expected ';' before '{' token
   12 |         FOR(i,N) {
      |                 ^~
      |                 ;
Language: Java

int N,K;
ll A[202020];
ll S[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	map<ll,int> M;
	ll ret=0;
	M[0]=1;
	FOR(i,N) {
		cin>>A[i];
		S[i+1]=S[i]+A[i]+K-1;
		if(i+1-K>=0) M[S[i+1-K]%K]--;
		ret+=M[S[i+1]%K];
		M[(S[i+1])%K]++;
	}
	cout<<ret<<endl;
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
int N,K;
^
Main.java:2: error: class, interface, enum, or record expected
ll A[202020];
^
Main.java:3: error: class, interface, enum, or record expected
ll S[202020];
^
Main.java:8: error: not a statement
	cin>>N>>K;
	      ^
Main.java:13: error: not a statement
		cin>>A[i];
		   ^
Main.java:19: error: not a statement
	cout<<ret<<endl;
	         ^
Main.java:5: error: unnamed classes are a preview feature and are disabled by default.
void solve() {
^
  (use --enable-preview to enable unnamed classes)
Main.java:12: error: ';' expected
	FOR(i,N) {
	        ^
8 errors
Language: C++

int N,K;
ll A[202020];
ll S[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	map<ll,int> M;
	ll ret=0;
	M[0]=1;
	FOR(i,N) {
		cin>>A[i];
		S[i+1]=S[i]+A[i]+K-1;
		if(i+1-K>=0) M[S[i+1-K]%K]--;
		ret+=M[S[i+1]%K];
		M[(S[i+1])%K]++;
	}
	cout<<ret<<endl;
}

Compiler output:
a.cc:2:1: error: 'll' does not name a type
    2 | ll A[202020];
      | ^~
a.cc:3:1: error: 'll' does not name a type
    3 | ll S[202020];
      | ^~
a.cc: In function 'void solve()':
a.cc:6:28: error: 'string' was not declared in this scope
    6 |         int i,j,k,l,r,x,y; string s;
      |                            ^~~~~~
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin>>N>>K;
      |         ^~~
a.cc:9:9: error: 'map' was not declared in this scope
    9 |         map<ll,int> M;
      |         ^~~
a.cc:9:13: error: 'll' was not declared in this scope; did you mean 'l'?
    9 |         map<ll,int> M;
      |             ^~
      |             l
a.cc:9:16: error: expected primary-expression before 'int'
    9 |         map<ll,int> M;
      |                ^~~
a.cc:10:11: error: expected ';' before 'ret'
   10 |         ll ret=0;
      |           ^~~~
      |           ;
a.cc:11:9: error: 'M' was not declared in this scope
   11 |         M[0]=1;
      |         ^
a.cc:12:9: error: 'FOR' was not declared in this scope
   12 |         FOR(i,N) {
      |         ^~~
a.cc:19:9: error: 'cout' was not declared in this scope
   19 |         cout<<ret<<endl;
      |         ^~~~
a.cc:19:15: error: 'ret' was not declared in this scope
   19 |         cout<<ret<<endl;
      |               ^~~
a.cc:19:20: error: 'endl' was not declared in this scope
   19 |         cout<<ret<<endl;
      |                    ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){

int n, k;

cin>> n >> k;

vector <long long> a(n), sa(n+1);

sa[0] = 0;

map<long long, int> amap;
amap[0] = 1;
long long ans = 0;

for(int i=0; i<n; i++){
int tmp;
cin >> tmp;
a[i] = tmp - 1;
sa[i+1] = (sa[i] + a[i]) % k;
ans += map[a[i+1]];
amap[sa[i+1]] += 1;
if(i-k+2>=0) amap[sa[i-k+2]]--;
}

cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:11: error: missing template arguments before '[' token
   26 | ans += map[a[i+1]];
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main(){

int n, k;

cin>> n >> k;

vector <long long> a(n), sa(n+1);

sa[0] = 0;

map<long long, int> amap;
amap[0] = 1;
long long ans = 0;

for(int i=0; i<n; i++){
int tmp;
cin >> tmp;
a[i] = tmp - 1;
sa[i+1] = (sa[i] + a[i]) % k;
ans += map[a[i+1]]:
amap[sa[i+1]] += 1;
if(i-k+2>=0) amap[sa[i-k+2]]--;
}

cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:11: error: missing template arguments before '[' token
   26 | ans += map[a[i+1]]:
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main{

int n, k;

cin>> n >> k;

vector <long long> a(n), sa(n+1);

sa[0] = 0;

map<long long, int> amap;
amap[0] = 1;
long long ans = 0;

for(int i=0; i<n; i++){
int tmp;
cin >> tmp;
a[i] = tmp - 1;
sa[i+1] = (sa[i] + a[i]) % k;
ans += map[a[i+1]]:
amap[sa[i+1]] += 1;
if(i-k+2>=0) amap[sa[i-k+2]]--;
}

cout << ans << endl;
}


Compiler output:
a.cc:7:5: error: cannot declare '::main' to be a global variable
    7 | int main{
      |     ^~~~
a.cc:9:1: error: expected primary-expression before 'int'
    9 | int n, k;
      | ^~~
a.cc:9:1: error: expected '}' before 'int'
a.cc:7:9: note: to match this '{'
    7 | int main{
      |         ^
a.cc:11:1: error: 'cin' does not name a type
   11 | cin>> n >> k;
      | ^~~
a.cc:13:22: error: 'n' was not declared in this scope
   13 | vector <long long> a(n), sa(n+1);
      |                      ^
a.cc:13:29: error: 'n' was not declared in this scope
   13 | vector <long long> a(n), sa(n+1);
      |                             ^
a.cc:15:1: error: 'sa' does not name a type
   15 | sa[0] = 0;
      | ^~
a.cc:18:1: error: 'amap' does not name a type
   18 | amap[0] = 1;
      | ^~~~
a.cc:21:1: error: expected unqualified-id before 'for'
   21 | for(int i=0; i<n; i++){
      | ^~~
a.cc:21:14: error: 'i' does not name a type
   21 | for(int i=0; i<n; i++){
      |              ^
a.cc:21:19: error: 'i' does not name a type
   21 | for(int i=0; i<n; i++){
      |                   ^
a.cc:31:1: error: 'cout' does not name a type
   31 | cout << ans << endl;
      | ^~~~
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

#include<stdio.h>

typedef long long ll;

bool m(int l,int r);

ll N,K,A[100002];
ll Asum[100002];
int main(){
  int i,j;
  int ans;
  scanf("%lld%lld",&N,&K);
  Asum[0]=0;
  for(i=0;i<N;i++){
    scanf("%lld",A+i);
    Asum[i+1] = Asum[i] + A[i];
  }
  ans = 0;
  for(i=0;i<N+1;i++){
    for(j=i+1;j<N+1 && j-i < K;j++){
      if(m(i,j)) ans++;
    }
  }
  printf("%d",ans);
}

Compiler output:
/usr/bin/ld: /tmp/cc9cxuyy.o: in function `main':
a.cc:(.text+0x105): undefined reference to `m(int, int)'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

  int N, K; cin>>N>>K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i > 0)
      A[i] += A[i-1];
    A[i] -= 1;
    A[i] %= K;
  }

  unordered_map<int, size_t> cands;
  for (int i = 0; i < min(K-1, N); i++)
    cands[A[i]]++;
  int ans = cands[0];
  for (int i = 0; i < N-1; i++) {
	if (i+K-1 < N)
	  cands[A[i+K-1]]++;
    ans += --cands[A[i]]
  }

  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:25: error: expected ';' before '}' token
   25 |     ans += --cands[A[i]]
      |                         ^
      |                         ;
   26 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

  int N, K; cin>>N>>K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i > 0)
      A[i] += A[i-1];
    A[i] -= 1;
    A[i] %= K;
  }

  unordered_map<int, size_t> cands;
  for (int i = 0; i < min(K-1, N); i++)
    cands[A[i]]++;
  int ans = cands[0];
  for (int i = 0; i < N-1; i++) {
	if (i+K-1 < N)
	  cands[A[i+K-1]]++;
	auto& cc = cands[A[i]];
    ans += --cc
  }

  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:16: error: expected ';' before '}' token
   26 |     ans += --cc
      |                ^
      |                ;
   27 |   }
      |   ~
Language: C++

#include <bits/stdc++.h>

using namespace std;

long main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);

  double N, K; cin>>N>>K;
  vector<double> A(N);
  for (double i = 0; i < N; i++) {
    cin >> A[i];
    if (i > 0)
      A[i] += A[i-1];
    A[i] -= 1;
    A[i] %= K;
  }

  multiset<double> cands;
  for (double i = 0; i < min(K-1, N); i++)
    cands.insert(A[i]);
  double ans = cands.count(0);
  for (double i = 0; i < N-1; i++) {
	if (i+K-1 < N)
	  cands.insert(A[i+K-1]);
	cands.erase(cands.find(A[i]));
    ans += cands.count(A[i]);
  }

  cout << ans << endl;

  return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:15:10: error: invalid operands of types '__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type' {aka 'double'} and 'double' to binary 'operator%'
   15 |     A[i] %= K;
a.cc:15:10: note:   in evaluation of 'operator%=(__gnu_cxx::__alloc_traits<std::allocator<double>, double>::value_type {aka double}, double)'
Language: C++

#include <bits/stdc++.h>

using namespace std;
#define ull unsigned long long
#define ll long long
const int MAXN = 2e5 + 1;

vector<ll> arr(0);
vector<ll> prefsumm(0);
map<ll, int> ost;
void solve() {
    int n;
    ll k;
    cin>>n>>k;
    if(k==1) {
        cout<<0;
        return 0;
    }
    ll summ=0;
    if(n<=k-1) ost[0]++;
    //ost[0]=1;
    ll allost=0;
    for(int i=0;i<n;i++) {
        ll a;
        cin>>a;
        --a;
        summ+=a;
        summ%=k;
        prefsumm.push_back(summ);
        if(i<n-1 && i>=n-k) ost[summ]++;
        arr.push_back(a);
    }
    allost=summ;
    //cout<<allost<<endl;
    //cout<<allost<<endl;
    ll ans=0;
    ll rsumm=0;
    for(int r=arr.size()-1;r>=1;r--){
        //cout<<r<<" "<<ost[(allost-rsumm+k)%k]<<" "<<(allost-rsumm+k)%k<<endl;
        ans+=ost[(allost-rsumm+k)%k];
        ost[prefsumm[r-1]]--;
        rsumm+=arr[r];
        rsumm%=k;
        if(r-k>=0) ost[prefsumm[r-k]]++;
        if(r-k==-1) ost[0]++;
    }
    ans+=((arr[0]%k==0)?1:0);
    cout<<ans;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:17:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   17 |         return 0;
      |                ^
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  long long n,k;
  cin>>n>>k;
  long long a[n];
  REP(i,n){
    cin>>a[i];
    a[i]--;
    a[i] %= k;
  }
  long long asum[n];
  REP(i,n){
    if(i==0){
      asum[i] = a[i];
    }else{
      asum[i] = asum[i-1] + a[i];
      asum[i] %= k;
    }
  }
  /*
  map<long long, long long> cnt;
  REP(i,n){
    cnt[asum[i]]++;
  }
  long long ans = 0;
  for(auto p:cnt){
    if(p.second > 1){
      ans += p.second*(p.second - 1)/2;
    }
  }
  */
  map<long long, long long> cnt;
  REP(i,n){
    if(i == 0){
      int l = min(n , k-1);
      REP(i,l){
        cnt[asum[i]]++;
      }
    }else{
      cnt[asum[i-1]]--;
      if(i+k-1 < n){
        cnt[asum[i+k-1]]++;
      }
    }
    ans += cnt[asum[i]] - 1;
  }
  REP(i,n){
    if(n >= k-1)break;
    if(asum[i] == 0){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:96:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   96 |     ans += cnt[asum[i]] - 1;
      |     ^~~
      |     abs
a.cc:101:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
  101 |       ans++;
      |       ^~~
      |       abs
a.cc:104:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
  104 |   cout<<ans<<endl;
      |         ^~~
      |         abs