akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int main(void){
        int i,j;
        int n,k;
        int p[200000];
        double ans;
        double m;

        scanf("%d%d",&n,&k);
        for(i=0;i<n;i++){
               scanf("%d",&p[i]);
        }
        
        m=0;
        for(i=0;i<k;i++){
                m += p[i]+1;
        }
        ans = m;

        for(i=k;i<n;i++){
                m -= p[i-k];
                m += p[i];
                if(ans < m){
                        ans = m;
                }
        }

        printf("%f\n", ans/2);
        return 0;
}



Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;

  if(2*b == a+c)
    {
      cout << "YES" << endl;
    }
  else
    {
      cout << "NO" << endl;
    }
  return 0;
}


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

int main() {
	int n;
	vector<int> b;
	bool flag_rev = false;
	cin >> n;
	rep(i,n) {
		int x;
		cin >> x;
		if (flag_rev) b.insert(b.begin(),x);
		else b.push_back(x);
		flag_rev = !flag_rev;
	}
	rep(i,n) {
		if (flag_rev) printf("%d ", b[n-1-i]);
		else printf("%d ", b[i]);
	}
	return 0;
}


Measured memory_bytes: 3060
#!/usr/bin/env python3

import sys

def main():
    sys.setrecursionlimit(10 ** 6)
    n = int(input())
    adjs = [[] for i in range(n)]
    for i in range(n - 1):
        u, v, w = map(int, input().split())
        adjs[u - 1].append((v - 1, w))
        adjs[v - 1].append((u - 1, w))
    colors = [None for i in range(n)]
    visited = [False for i in range(n)]
    dfs(0, 0, adjs, visited, colors)
    for i in range(n):
        print(colors[i])

def dfs(i, color, adjs, visited, colors):
    visited[i] = True
    colors[i] = color
    for v, w in adjs[i]:
        if visited[v]:
            continue
        dfs(v, (color + w) % 2, adjs, visited, colors)

if __name__ == "__main__":
    main()


Measured memory_bytes: 80812
#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;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  ll N;
  cin >> N;

  mint s = 0;
  mint ss = 0;
  rep(i, N) {
    mint a;
    cin >> a;
    s += a;
    ss += a * a;
  }
  mint ans;
  ans = s * s - ss;
  ans /= 2;

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


Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 500
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int N;
int C[MAX_N], S[MAX_N], F[MAX_N];
int dp[MAX_N * 100000 + 5];

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  REP(i, N) cin >> C[i] >> S[i] >> F[i];
  deque<int> ans;
  ans.push_back(0);

  // C, S, F
  // S後に C掛けて到達、F ごとに出発

  for (int i = 0; i < N; i++) {
    int t = 0;
    for (int j = i; j < N - 1; j++) {
      if (t < S[j])
        t = S[j];
      else if (t % F[j] == 0)
        ;
      else
        t = t + F[j] - t % F[j];
      t += C[j];
    }
    printf("%d\n", t);
  }

  return 0;
}


Measured memory_bytes: 384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll x, y;
  cin >> x >> y;
  bool ok = false;
  repLRE(i, 0, 100) { ll j = x - i;
    if (j < 0) continue;
    if (2 * i + 4 * j == y) ok = true;
  }
  string ans = ok ? "Yes" : "No";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin >> p[i];
    int ans = 0;
    int curMin = 1e9;
    for(int i=0; i<n; i++){
        curMin = min(curMin, p[i]);
        if(curMin == p[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s,ans="";
	int w;	

	cin >>s >>w;
	for(int i=0;i<(int)s.size();i++){
		if(i%w==0)ans+=s[i];
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>   
#include <functional>

#define lnd '\n'
#define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mkp make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

void solution();

template <class T>
T GCD (T a, T b) {
  if(b == 0) return a;
  return GCD(b, a%b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
    int n;
    cin >> n;
    vector<pair<int,int>> x(n);
    from(i,n){
        int a,b;
        cin >> a >> b;
        x[i] = make_pair(a+b, a-b);
    }

    sort(ALL(x));
    int ans = 0;
    vector<int> counts(n);
    
    int p = 0;
    from(i, n){
        if(i == 0){
            p = i;
            ans += 1;
        }else{
            if(x[i].second >= x[p].first){
                ans += 1;
                p = i;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
//#include <iomanip.h>
#include <limits.h>
//#include <strstrea.h>
//#include <fstream.h>
#define ll long long
#define ull unsigned long long
//#define int64 long long
#define INF  0x3f3f3f3f

using namespace std;

const int maxn = 1e6 + 5;
ll n;

int main() {
    cin >> n;
    ll ans = 0;
    if (n % 11 == 0) {
        ans = (n / 11) * 2;
    } else {
        ans = (n / 11) * 2;
        int res = n % 11;
        if (res <= 6) ans++;
        else ans += 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int w[10],k[10],wscore,kscore;
  for(int i=0;i<10;i++){ scanf("%d",&w[i]); }
  for(int i=0;i<10;i++){ scanf("%d",&k[i]); }

  for(int i=0;i<10;i++){
    for(int j=i+1;j<10;j++){
      if(w[i]>w[j]){
        int a = w[i];
        w[i] = w[j];
        w[j] = a;
      }
    }
  }
  for(int i=0;i<10;i++){
    for(int j=i+1;j<10;j++){
      if(k[i]>k[j]){
        int a = k[i];
        k[i] = k[j];
        k[j] = a;
      }
    }
  }
  //for(int i=0;i<10;i++){ printf("w[%d]=%d\tk[%d]=%d\n",i,w[i],i,k[i]); }
  wscore=w[7]+w[8]+w[9];
  kscore=k[7]+k[8]+k[9];
  printf("%d %d\n",wscore,kscore);
  return 0;
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1010;


int main()
{
    string s;
    cin >> s;

    int st, ed;

    for(int i = 0; i < s.size(); i++)
        if(s[i] == 'A')
        {
            st = i;
            break;
        }

    for(int i = s.size() - 1; i >= 0; i--)
        if(s[i] == 'Z')
        {
            ed = i;
            break;
        }

    cout << ed - st + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.*;
  public class Main
{
	public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in);
		int i;
		int n=sc.nextInt();
		int h[]=new int[n];
		for(i=0;i<n;i++)
			h[i]=sc.nextInt();
		int dp[]=new int[n];
		//Arrays.fill(dp, );
		for(i=0;i<n;i++)
		{
			if(i-1>=0&&i-2>=0)
				dp[i]+=Math.min(Math.abs(h[i-2]-h[i])+dp[i-2],Math.abs(h[i-1]-h[i])+dp[i-1]);
			else if(i-1>=0)
				dp[i]+=Math.abs(h[i-1]-h[i]+dp[i-1]);
		}
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 59840
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	vector<int> vec; int an, tn, fn1, fn2, fn3; int set = 0;
	cin >> an; vec.resize(an); 
	for (int i = 0; i < an; i++) cin >> vec[i];
	cin >> tn;
	for (int i = 0; i < tn; i++) {
		cin >> fn1 >> fn2 >> fn3;
		rotate(vec.begin() + fn1, vec.begin() + fn2, vec.begin() + fn3);
	}
	for (int i : vec) cout << (set++ ? " " : "") << i;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3168
n = int(input())
p = [[0]*10 for _ in range(10)]
x, y = int(str(n)[0]), int(str(n)[-1])
keta = len(str(n))
ans = 0

for a in range(1, 10):
    for b in range(1, 10):
        for k in range(1, keta+1):
            if k == 1:
                if a == b and a <= n:
                    p[a][b] += 1
            elif k == 2:
                if int(str(a)+str(b)) <= n:
                    p[a][b] += 1
            elif k >= 3 and k < keta:
                p[a][b] += 10 ** (k-2)
            else:
                if a < x:
                    p[a][b] += 10 ** (k-2)
                elif a == x and b <= y:
                    p[a][b] += int(str(n)[1:-1]) + 1
                elif a == x and b > y:
                    p[a][b] += int(str(n)[1:-1])
                    
for a in range(1, 10):
    for b in range(1, 10):
        ans += p[a][b] * p[b][a]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;

int main(void){
  int A, B, K;
  cin >> A >> B >> K;

  int max = A > B ? A : B;
  int count = 0;
  for (int i = max; i > 0; i--){
    if(A%i == 0 && B%i ==0){
      count++;
      if(count==K){
        cout << i << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = []
ans = 0

for i in range(K):
  d = int(input())
  a = list(map(int, input().split()))
  for j in range(d):
    A.append(a[j])

A.sort

for k in range(1, N+1):
  if k in A:
    continue
    
  else:
    ans += 1
        
print(ans)


Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {

	int a,b,c;

	cin >> a >> b >> c;

	if (b - a == c - b) {
		puts("YES");
	}

	else {
		puts("NO");
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define sort_all(x) sort((x).begin(),(x).end())
using ll = long long;
using P = pair<int,int>;



int main() {
	
	
	ll n, k; cin >> n >> k;
	
	vector<ll> a(n); rep(i,n) cin >> a[i];

	int ng = 0;
	int ok = 1000000001;

	while(1){
		int len = (ng + ok) / 2;
		int cnt = 0;
		rep(i,n) cnt += (a[i] + len - 1) / len - 1;
		// cout << cnt << endl;
		if(cnt > k) ng = len;
		else ok = len;
		if(ok == ng + 1){
			cout << ok << endl;
			// cout << ng << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define loop(a, b, inc) for (int i = a; i <= b; i += inc)
typedef pair<int, int> pii;
typedef pair<int, string> ps;
typedef unsigned long long int llu;
typedef long long int ll;
typedef unsigned u;
const int MOD = 1e7+9, MAXK = 1e6+100;
int n, minimo;
bool dp[MAXK], vis[MAXK];
vector<int> a;

bool solve(int k)
{
	if (k < minimo) return false;
	if (!vis[k]) {
		for (int i = 0; i < a.size(); ++i) {
			if (k-a[i] >= 0) {
				dp[k-a[i]] = solve(k-a[i]);
				if (!dp[k-a[i]]) {
					dp[k] = true;
					break;
				} 
			}
		}
		vis[k] = true;
	}
	return dp[k];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k, aux;
	cin >> n >> k;
	cin >> aux;
	a.pb(aux);
	minimo = aux;
	loop(2, n, 1) {
		cin >> aux;
		a.pb(aux);
		minimo = min(minimo, aux);
	}
	if (solve(k)) cout << "First" << endl;
	else cout << "Second" << endl;
	
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define inf         2e9+5
#define mp          make_pair
#define ll          long long
#define pii         pair<int,int >
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define sf          scanf
#define pf          printf
/*------------------------------Graph Moves----------------------------*/
const int fx[]= {+1,-1,+0,+0};
const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
using namespace std;
//using namespace __gnu_pbds;
//
//template <typename T>  using orderedSet =
//    tree<T, null_type, less<T>,
//    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key
//
int n;
int arr[100005];
void solve()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    int ans=0;
    for(int i=0;i<=arr[n-1] ;i++)
    {
        int x=upper_bound(arr,arr+n,i)-arr;
        if(x==n/2) ans++;
    }
    cout<<ans<<endl;
}

int main()
{
    solve();
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
 
N=int(input())
An = list(map(int,input().split()))
MOD = 10**9+7

ans=0
for i in range(60):
  ones,zeros=0,0
  for A in An:
    if (A>>i)%2 == 1:
      ones+=1
    else:
      zeros+=1
  ans+=2**i * ones * zeros
  ans%=MOD

print(ans)

Measured memory_bytes: 123132
#include <bits/stdc++.h>
#define ll long long
#define sf scanf
#define pf printf
using namespace std;

int main(){
    int one=0,zero=0;
    string s;
    cin>>s;

    int len=s.size();
    for(int i=0; i<len; i++){
        if(s[i]=='0') zero++;
        else one++;
    }
    cout<<min(zero,one)*2<<endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s; cin >> s;
    int n = s.size();
    reverse(all(s));

    ll x = 1;
    ll sum = 0;
    vector<int> a;
    rep(i,n){
        if(s[i] == '?'){
            a.emplace_back(x);
        }else{
            ll y = s[i] - '0';
            sum += x*y;
            sum %= 13;
        }
        x *= 10;
        x %= 13;
    }

    int m = a.size();
    vector<vi> dp(m+1, vi(13,0));
    dp[0][sum] = 1;
    for(int i=0;i<m;i++){
        for(int j=0;j<13;j++){
            for(int k=0;k<10;k++){
                dp[i+1][(j+k*a[i])%13] += dp[i][j];
                dp[i+1][(j+k*a[i])%13] %= mod;
            }
        }
    }
    cout << dp[m][5] << endl;
}


Measured memory_bytes: 12332
#include<stdio.h>
int main(void)
{
	int n;
	int	ans = 0;
	scanf("%d", &n);
	int p[90];
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &p[i]);

	}
		for (int i = 1; i < n - 1; i++)
		{
			if (p[i - 1] < p[i] && p[i] < p[i + 1])
			{
				ans++;
			}
			else
			{
				if (p[i + 1] < p[i] && p[i] < p[i - 1])ans++;
					
			}
		
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;






int main() {

    string s;
    cin >> s;

    bool flag = true;
    if (s.size() % 2 == 0) {
        for (int i = 0; i < s.size(); i += 2) {
            if (s[i] != 'h' || s[i+1] != 'i') flag = false;
        }
    }
    else flag = false;
    
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}




//              g++ -std=c++1z






Measured memory_bytes: 760
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std; // 575;

int n;
string str[10005];
vector<int> pre_list[32];
vector<int> suf_list[32];

vector<int> vs;
bool used[100005];

void dfs(int v);
void rdfs(int v, int k);
int scc(void);

bool is_ok(void);

int main()
{
    while (scanf("%d", &n), n != 0) {

        // init
        for (int i = 0; i < 32; i++) {
            pre_list[i].clear();
            suf_list[i].clear();
        }
        for (int i = 0; i < 10005; i++) {
            str[i].clear();
        }

        for (int i = 0; i < n; i++) {
            cin >> str[i];
        }

        sort(str, str + n);
                
        for (int i = 0; i < n; i++) {
            char s = str[i][0];
            char t = str[i][str[i].size() - 1];

            pre_list[s - 'a'].push_back(i);
            suf_list[t - 'a'].push_back(i);
        }

        if (scc() == 1) {
            /*
            memset(used, 0, sizeof(used));
            vs.clear();
            dfs(0);
            */

            if (is_ok()) {
                puts("OK");
            }
            else {
                puts("NG");
            }
        }
        else {
            puts("NG");
        }
    }
}

void dfs(int v)
{
    used[v] = true;
    char ch = str[v][str[v].size() - 1] - 'a';

    for (int i = 0; i < pre_list[ch].size(); i++) {
        if (!used[pre_list[ch][i]]) {
            dfs(pre_list[ch][i]);
        }
    }

    vs.push_back(v);
}

void rdfs(int v, int k)
{
    used[v] = true;

    char ch = str[v][0] - 'a';

    for (int i = 0; i < suf_list[ch].size(); i++) {
        if (!used[suf_list[ch][i]]) {
            rdfs(suf_list[ch][i], k);
        }
    }
}

int scc(void)
{
    memset(used, 0, sizeof(used));

    vs.clear();

    for (int v = 0; v < n; v++) {
        if (!used[v]) {
            dfs(v);
        }
    }

    memset(used, 0, sizeof(used));
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--) {
        if (!used[vs[i]]) {
            rdfs(vs[i], k);
            k++;
        }
    }

    return k;
}

bool is_ok(void)
{
    int suf_cnt[32] = {};
    int pre_cnt[32] = {};

    for (int i = 0; i < n; i++) {
        pre_cnt[str[i][0] - 'a']++;
        suf_cnt[str[i][str[i].size() - 1] - 'a']++;
    }

    for (int i = 0; i < 32; i++) {
        if (pre_cnt[i] != suf_cnt[i]) {
            return false;
        }
    }

    return true;
}



Measured memory_bytes: 4892
using System;

namespace testes
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);

            if (A < 10 && B < 10) Console.WriteLine(A * B);
            else Console.WriteLine(-1);
        }
    
    /*
        public static void func(int L, int R, bool x, bool y)
        {
        }
        public static int LIS(int[] c)
        {
            // 部分数列和
            int count = 1;
            int N = c.Length;
            int[] array = new int[N];
            array[0] = c[0];

            for (int i = 1; i < N; i++)
            {
                //for (int p = 0; p < N; p++) Console.Write($"{array[p]},");
                // Console.WriteLine("");
                if (array[count - 1] < c[i])
                {
                    array[count] = c[i];
                    count++;
                    continue;
                }
                for (int j = count - 2; j >= 0; j--)
                {
                    if (array[j] < c[i])
                    {
                        array[j + 1] = c[i];
                        break;
                    }
                }
                if (array[0] > c[i]) array[0] = c[i];
            }
            return count;
        }
        public static void Rotation(char[] array, int l, int r)
        {


        }

    */


    }


}

/*
int a, b, c;
int a = int.Parse(Console.ReadLine()); 
string[] str = Console.ReadLine().Split(' ');
int b = int.Parse(str[0]);  
int c = int.Parse(str[1]);
string S = Console.ReadLine();
char[] C = new char[N];
C = S.ToCharArray();
Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力

string[] str = Console.ReadLine().Split(' ');
int[] a = new int[N];
for(int i = 0; i < N; i++) a[i] = int.Parse(str[i]);
 */


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  int N, K;
  cin >> N >> K;
  vector<llong> H(N);
  for(int i=0; i<N; ++i) cin >> H.at(i);
  if(N<=K) {
    cout << 0 << endl;
    return 0;
  }else{
    llong sum=0;
    sort(H.begin(), H.end());
    for(int i=0; i<N-K; ++i) sum += H.at(i);
    cout << sum << endl;
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define For( i, j, k ) for( int i = j; i <= k; ++i )
const int mod = 1e9 + 7, Maxn = 5002;
int f[ Maxn ][ Maxn ];
int main( )
{
	int n, len;
	std::string str;
	std::cin >> n >> str;
	len = str.size( );
	f[ 0 ][ 0 ] = 1;
	For( i, 0, n ) For( j, 0, i )
	{
		if( j == 0 )
			f[ i + 1 ][ j ] = ( f[ i + 1 ][ j ] + f[ i ][ j ] ) % mod;
		else
			f[ i + 1 ][ j - 1 ] = ( f[ i ][ j ] * 2 % mod + f[ i + 1 ][ j - 1 ] ) % mod;
		f[ i + 1 ][ j + 1 ] = ( f[ i + 1 ][ j + 1 ] + f[ i ][ j ] ) % mod; 
	}
	std::cout << f[ n ][ len ];
	return 0; 
} 

Measured memory_bytes: 70400
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  char s[n + 1];
  scanf("%s", s);
  int ans = 1;
  for(int i = 1; i < n; i++){
    ans += (s[i] != s[i - 1]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using namespace atcoder;
const int MAX_A = 300005;
int op(int a, int b) {return max(a,b);}
int e() {return 0;}
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    segtree<int,op,e> dp(MAX_A);
    rep(i,n) {
        int x = a[i];
        int l = max(0,x-k);
        int r = min(x+k+1,MAX_A);
        int now = dp.prod(l,r)+1;
        dp.set(x,now);
    }
    int ans = dp.prod(0,MAX_A);
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 9576
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int a = 0;
    int b = 0;
    REPS(c, s) {
        if (c == 'A') a++;
        else b++;
    }
    cout << (a > 0 && b > 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

int a,b,ans;

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
	
	cin >> a >> b;
	ans = 1;
	int cur = a;
	while(cur<b){
		cur+=a-1;
		ans++;
	}
	if(b==1)ans = 0;
	cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 256
S = input()

if 1 <= int(S[:2]) <= 12:
    if 1 <= int(S[2:4]) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1 <= int(S[2:4]) <= 12:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 2940
//besmellah
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")

#define int long long
typedef pair <int, int> pii;
const int maxn = 3005, mod = 998244353;
int pd[maxn], dp[maxn], a[maxn];

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	pd[0] = 1;
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = s; j >= 0; j--) {
			if (j >= a[i])
				pd[j] += pd[j - a[i]];
			pd[j] %= mod;
		}
		pd[0]++;
		for (int j = s; j >= 0; j--) {
			dp[j] += pd[j];
			dp[j] %= mod;
		}
	}
	cout << dp[s];
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;

#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

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

const ll INF=1e9+7;

int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	int n,d;
	int a[100][100];
	int ans=0;
	cin>>n>>d;
	rep(i,n){
		rep(j,d){
			cin>>a[i][j];
		}
	} 
	rep(i,n){
		for(int j=i+1;j<=n;j++){
			int h=0;
			rep(k,d){
				h+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			}
			//cout<<h<<endl;
			int g=sqrt(h);
			if(g*g==h){
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
sys.setrecursionlimit(10**7)

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

x = ni()
ct = 0
t = 100
while True:
    ct += 1
    t *= 1.01
    t = math.floor(t)
    if t >= x:
        print(ct)
        break

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll fastpow(ll a, ll b){
    ll calc=1;
    for(;b>=1LL;b/=2LL){
        if((b&1LL))calc=mult(calc,a);
        a=mult(a,a);
    }
    return calc;
}
ll soma(ll a,ll b){
    if(a+b>MOD)return a+b-MOD;
    else return a+b;
}
ll subt(ll a,ll b){
    if(a-b<0)return a-b+MOD;
    else return a-b;
}
ll add_self(ll &a, ll b){
    a+=b;
    if(a>=MOD)a-=MOD;
    return a;
}
ll dp[10001][102+2][2];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string k;
    ll d;
    cin>>k>>d;
    ll cont = 0;
    vector<int> nums;
    rep(i,0,sz(k)){
        cont++;
        nums.push_back(k[i]-'0');
    }
    memset(dp,0,sizeof dp);
    rep(i,0,nums[0]) add_self(dp[0][i%d][1],1);
    add_self(dp[0][nums[0]%d][0],1);
    rep(i,1,cont){
        rep(soma,0,d){
            rep(j,0,10){
                if(j>nums[i]){
                    add_self(dp[i][(j+soma)%d][1],dp[i-1][soma][1]);
                }
                else if(j<nums[i]){
                    add_self(dp[i][(j+soma)%d][1],dp[i-1][soma][1]);
                    add_self(dp[i][(j+soma)%d][1],dp[i-1][soma][0]);
                }
                else{
                    add_self(dp[i][(j+soma)%d][0],dp[i-1][soma][0]);
                    add_self(dp[i][(j+soma)%d][1],dp[i-1][soma][1]);
                }
            }
        }
    }
    ll ans=0;
    add_self(ans,dp[cont-1][0][1]);
    add_self(ans,dp[cont-1][0][0]);
    cout<<subt(ans,1)<<"\n";
    return 0;  
}   

Measured memory_bytes: 19996
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

int main() {
    int n;
    cin >> n; // 200'000
    assert(n % 2 == 0);

    auto a = vector<int>(n);
    for (auto& a_i : a)
        cin >> a_i;

    auto xor_total = accumulate(a.begin(), a.end(), 0, [](auto sum, auto item) { return sum xor item; });
    for (auto i = 0; i < n; ++i) {
        auto orig = a[i] ^ xor_total;
        printf("%d%c", orig, (i + 1 == n ? '\n' : ' '));
    }
    return 0;
}


Measured memory_bytes: 3952
#include <cstdio>

int main()
{
	int n,mx=0,sum=0;
	int a[10];
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]>mx) mx=a[i];
		sum+=a[i];
	}
	sum-=mx;
	if (mx<sum) printf("Yes");
	else printf("No");
		
	return 0;
}

Measured memory_bytes: 128
/*
Problem : https://atcoder.jp/contests/abc145/tasks/abc145_f
Algorithm : dp + BIT
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const ll INF = 1e18;
const int MAXN = 305;

int n,k;
int id[MAXN];
ll a[MAXN],f[MAXN][MAXN],b[MAXN];

bool cmp(const int &x,const int &y){
	return a[x] < a[y];
}

class BIT2{
	private:
		ll c[MAXN];
		
		int lowbit(int x){
			return x & -x;
		}
	public:
		BIT2(){
			for(int i = 0;i < MAXN;i++)
			    c[i] = INF;
		}
		
		ll Query(int x){
			ll res = INF;
			while(x >= 1){
				res = min(res,c[x]);
				x -= lowbit(x);
			}
			return res;
		}
		
		void Add(int x,ll val){
			while(x <= n){
				c[x] = min(c[x],val);
				x += lowbit(x);
			}
		}
		
		void print(){
			for(int i = 1;i <= n;i++)
			    printf("%lld ",c[i]);
			printf("\n");
		}
} bit2[MAXN];

class BIT1{
	private:
		ll c[MAXN];
		
		int lowbit(int x){
			return x & -x;
		}
	public:		
		BIT1(){
			for(int i = 0;i < MAXN;i++)
			    c[i] = INF;
		}
		
		ll Query(int x){
			ll res = INF;
			while(x <= n){
				res = min(res,c[x]);
				x += lowbit(x);
			}
			return res;
		}
		
		void Add(int x,ll val){
			while(x >= 1){
				c[x] = min(c[x],val);
				x -= lowbit(x);
			}
		}
		
		void print(){
			for(int i = 1;i <= n;i++)
			    printf("%lld ",c[i]);
			printf("\n");
		}
} bit1[MAXN];

int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	scanf("%d%d",&n,&k);
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= n;j++)
		    f[i][j] = INF;
	}
	for(int i = 1;i <= n;i++){
		scanf("%lld",&a[i]);
		b[i] = a[i];
	}
	sort(b + 1,b + 1 + n);
	int m = unique(b + 1,b + 1 + n) - b - 1;
	for(int i = 1;i <= n;i++){
		f[i][0] = 0;
		f[i][1] = a[i];
		id[i] = lower_bound(b + 1,b + 1 + n,a[i]) - b;
	}
	for(int j = 2;j <= n - k;j++){
//		printf("%d : \n",j);
		for(int i = 1;i < j;i++){
			bit1[j - 1].Add(id[i],f[i][j - 1]);
			bit2[j - 1].Add(id[i],f[i][j - 1] - a[i]);
//			bit1[j - 1].print();
//			bit2[j - 1].print();
//			printf("\n");
		}
		for(int i = j;i <= n;i++){
			f[i][j] = min(f[i][j],bit1[j - 1].Query(id[i]));
			f[i][j] = min(f[i][j],bit2[j - 1].Query(id[i] - 1) + a[i]);
			bit1[j - 1].Add(id[i],f[i][j - 1]);
			bit2[j - 1].Add(id[i],f[i][j - 1] - a[i]);			
//			bit1[j - 1].print();
//			bit2[j - 1].print();
//			printf("\n");
		}
//		printf("\n");
	}
	ll ans = INF;
	for(int i = 1;i <= n;i++)
	    ans = min(ans,f[i][n - k]);
//	for(int i = 1;i <= n;i++){
//		for(int j = 0;j <= n;j++)
//		    printf("%lld ",f[i][j]);
//		printf("\n");
//	}
	printf("%lld\n",ans);
	return 0;
}
/*f[i][j] = min(f[i][j],f[l][j - 1] + max(0,a[i] - a[l])
  a[i] > a[l] --> f[l][j - 1] - a[l] + a[i]
  a[i] <= a[l] --> f[l][j - 1]
*/

Measured memory_bytes: 2432
MAX_V = 100000
INF = 10 ** 10

n,w = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(n)]
dp = [[INF] * (MAX_V + 5) for i in range(n + 1)]
dp[0][0] = 0
for i in range(n):
	for j in range(MAX_V + 1):
		if j + wv[i][1] <= MAX_V:
			dp[i + 1][j + wv[i][1]] = min(dp[i + 1][j + wv[i][1]],dp[i][j] + wv[i][0])
		dp[i + 1][j] = min(dp[i + 1][j],dp[i][j])
ma = 0
for i in range(MAX_V + 1):
	if dp[n][i] <= w:
		ma = max(ma,i)
print(ma)

Measured memory_bytes: 120812
#include "bits/stdc++.h"
using namespace std;

constexpr long long MOD = 998244353;

int main() {
	int N, S;
	cin >> N >> S;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	vector<vector<long long> > DP(N + 1, vector<long long>(S + 1, 0));
	for (int i = 0; i < N; i++) {
		for (int j = 1; j < S; j++) {
			DP[i + 1][j] = (DP[i + 1][j] + DP[i][j]) % MOD;
			if (j + A[i] <= S) DP[i + 1][j + A[i]] = (DP[i + 1][j + A[i]] + DP[i][j]) % MOD;
		}
		if (A[i] <= S) DP[i + 1][A[i]] = (DP[i + 1][A[i]] + i + 1) % MOD;
	}
	long long ANS = 0;
	for (int i = 0; i <= N; i++) {
		ANS = (ANS + DP[i][S] * (N - i + 1)) % MOD;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;



int main()
{
  cin>>n;
  cout<<180*(n-2)<<endl;
	
	
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
using LL = int_fast64_t;
LL a,b,c;
int main(){
    cin >> a >> b >> c;
    if(a<b) swap(a,b);
    if(c-a-b<0){
        cout << "No" << endl;
        return 0;
    }
    if(4*a*b<(c-a-b)*(c-a-b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();

            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = in.nextInt();
            }

            long ans = 0;
            long sum = A[0];
            long xor = A[0];
            long prevLeft = -1;
            long prevRight = -1;

            for (int left = 0, right = 0; left < N && right < N; ) {
                while (sum != xor) {
                    sum -= A[left];
                    xor ^= A[left];
                    left++;
                }

                while (right + 1 < N && (sum + A[right + 1]) == (xor ^ A[right + 1])) {
                    sum += A[right + 1];
                    xor ^= A[right + 1];
                    right++;
                }

                long len = right - left + 1;

                long poprz = 0;

                if (prevRight != -1 && left <= prevRight) {
                    long plen = prevRight - left + 1;
                    poprz = plen * (plen + 1) / 2;
                }

                ans += len * (len + 1) / 2 - poprz;

                prevLeft = left;
                prevRight = right;

                if (++right < N) {
                    sum += A[right];
                    xor ^= A[right];
                }
            }

            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 46036
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;

    int n = s.length();

    int res = 0;
    string t = "ACGT";
    for (int i = 0; i < n; ++i) {
        if (t.find(s[i]) != string::npos) {
            int cnt = 1;
            while (i + 1 < n && t.find(s[i + 1]) != string::npos) {
                ++i;
                ++cnt;
            }
            res = max(res, cnt);
        }
     }
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  int N;
  cin >> N;
  vector<int> C(N);
  vector<vector<int>> mp(2*1e5);
  REP(i, N){
    cin >> C[i];
    C[i]--;
    mp[C[i]].push_back(i);
  }
  vector<int> id(2*1e5, 1);
  vector<ll> sum(N+1, 0);
  sum[0] = 1;
  REP(i, N){
    sum[i+1] += sum[i];
    sum[i+1] %= mod;
    int idx = id[C[i]];
    id[C[i]]++;
    if(idx < (int)mp[C[i]].size()){
      int nidx = mp[C[i]][idx];
      if(nidx - i ==1) continue;
      sum[nidx] += sum[i];
    }
  }
  cout << sum[N] << endl;
  return 0;
}

Measured memory_bytes: 17188
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  cout << S.at(0) << N - 2 << S.at(N - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b, c, d;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c >> d;
	if(a + b == c + d) cout << "Balanced\n";
	else if(a + b > c + d) cout << "Left\n";
	else cout << "Right\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        x = x-a;
        x = x-b*(x/b);
        System.out.println(x);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<cmath>
using namespace std;

int main(){
  int n;
  
  cin >> n;
  int p = 100;
  int a[3];
  
  for(int i = 0; i < 3; i++){
    a[i] = n / p;
    n %= p;
    p /= 10;
    
  }
  
  for(int i = 0; i < 3; i++){
    if(a[i] == 1){
      a[i] = 9;
      cout << a[i];
    } else if(a[i] == 9){
      a[i] = 1;
      cout << a[i];
    }
  }
  
  cout << endl;

  return 0;
}

  

Measured memory_bytes: 256