akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

//set many funcs template
//Ver.20181228
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;
  int  cnt;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}


int main()
{
  int64 N,M;
  int64 c;

  get_NK(&N, &M);

  c = llnCr(N, 2);
  c += llnCr(M, 2);

  printf("%lld", c);
  return 0;
}



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

using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
#define inf 1ll<<60
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
#define int llong
#define be(x) x.begin(), x.end()
typedef pair<int, int> P;


signed main(){
	int A, B, Q;
	vector<int>a,b,ans;

	cin >> A >> B >> Q;
	a.resize(A), b.resize(B);
	for(int i = 0; i < A; i++)
		cin >> a[i];
	for(int i = 0; i < B; i++)
		cin >> b[i];

	int x;
	for(int i = 0; i < Q; i++){
		cin >> x;
		auto leftA = lower_bound(be(a), x);
		auto rightA = leftA;
		auto leftB = lower_bound(be(b), x);
		auto rightB = leftB;

		int lA, rA, lB, rB;
		if(leftA == a.begin()){
			lA = -inf;
		}else{
			leftA--;
			lA = *leftA;
		}
		if(leftB == b.begin()){
			lB = -inf;
		}else{
			leftB--;
			lB = *leftB;
		}
		rA = rightA == a.end() ? inf : *rightA;
		rB = rightB == b.end() ? inf : *rightB;

		int dlA, dlB, drA, drB;
		dlA = abs(x - lA);
		dlB = abs(x - lB);
		drA = abs(x - rA);
		drB = abs(x - rB);

		// cerr << x << endl;
		// cerr << lA << " " << rA << endl;
		// cerr << lB << " " << rB << endl << endl;

		ans.pb(min({max(dlA, dlB), max(drA, drB), dlA*2 + drB, dlA + drB*2, dlB*2 + drA, dlB + drA*2}));
	}

	for(int i = 0; i < ans.size(); i++)
		cout << ans[i] << endl;


	return 0;
}

Measured memory_bytes: 3828
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#n=int(input())
#li=input().split()
#import fractions
#lis=list(map(int,input().split()))

n=int(input())
S=[]
ans=0
firstB,lastA,bothAB=0,0,0

for i in range(n):
    S.append(input())
    flag=0
    for j in range(len(S[-1])-1):
        if S[-1][j:j+2]=="AB":
            ans+=1
    if S[-1][0]=="B":
        firstB+=1
        flag+=1
    if S[-1][-1]=="A":
        lastA+=1
        flag+=1
    if flag==2:
        bothAB+=1
        firstB-=1
        lastA-=1

if firstB==lastA:
    if firstB==0 and bothAB!=0:
        ans+=bothAB-1
    else:
        ans+=(bothAB+firstB)
else:
    ans+=min(firstB,lastA)+bothAB

print(ans)


Measured memory_bytes: 3700
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>

using namespace std;

int n, m, a, b, ans;
int num[11];
bool edge[11][11], vis[11];

void dfs(int u, int rem) {
    if(rem == 0) {
        ++ans;
        return;
    }
    for(int i = 1; i <= n; ++i) {
        if(!vis[i] && edge[u][i]) {
            vis[i] = true;
            dfs(i, rem - 1);
            vis[i] = false;
        }
    }
}

int main() {
    while(2 == scanf("%d%d", &n, &m)) {
        memset(num, 0, sizeof(num));
        memset(edge, false, sizeof(edge));
        memset(vis, false, sizeof(vis));
        for(int i = 0; i < m; ++i) {
            scanf("%d%d", &a, &b);
            edge[a][b] = edge[b][a] = 1;
        }
        ans = 0;
        vis[1] = true;
        dfs(1, n - 1);
        printf("%d\n", ans);
    }
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string a,b;
    cin>>a>>b;
    ll m,n;
    cin>>m>>n;
    string in;
    cin>>in;
    if(in==a)
    {
        m--;
    }
    else
    {
        n--;
    }
    cout<<m<<" "<<n;
    return 0;
}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    ll xorr = 0;
    for(ll i=0;i<n;i++)
    {
        cin >> a[i];
        xorr ^= a[i];
    }
    for(ll i=0;i<n;i++)
    {
        cout<<(xorr^a[i])<<" ";
    }
}

int main()
{
    FAST;
    ll t = 1;
   // cin >> t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 5196
#include <stdio.h>

int main(void) {
	int a, b, x, y;

	scanf("%d\n%d\n%d", &x, &a, &b);

	y = (x - a) / b ;
	printf("%d", x - a - y * b);
	getchar;
	getchar;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    vector<int64_t> plus;
    int64_t sumOfMinus = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int64_t diff = a[i] - b[i];
        if (diff < (int64_t)0) {
            sumOfMinus -= diff;
            ans++;
        } else if (diff > (int64_t)0) {
            plus.push_back(diff);
        }
    }
    sort(plus.rbegin(), plus.rend());
    for (int i = 0; i < plus.size() && sumOfMinus > (int64_t)0; i++) {
        sumOfMinus -= plus[i];
        ans++;
    }
    if (sumOfMinus > (int64_t)0) ans = -1;
    cout << ans << endl;
}

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

using namespace std;
#define rep(j,n) for(int j=0;j<(n);j++)

using ll = long long;
using P = pair<int, int>;

int main(int, char**)
{
  int n;
  cin >> n;

  ll ans = (ll)n * (n+1) * (n+2) / 6;

  int u, v;
  rep(i,n-1) {
    cin >> u >> v;
    if (u > v) swap(u,v);
    ans -= (ll)u * (n-v+1);
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec[i];
    }

    int min, max;
    min = *min_element(vec.begin(), vec.end());
    max = *max_element(vec.begin(), vec.end());

    cout << max - min << endl;

}

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

#define MAX_N 100000

vector<vector<int> > graph;
int dist[MAX_N];

int dfs(int s, int step) {
    dist[s] = step;

    int nodes = 0;
    for (const auto dst: graph.at(s)) {
        if (dist[dst] == -1) {
            nodes += dfs(dst, step + 1);
        }
    }
    return nodes + 1;
}

bool visited[MAX_N];
bool find_route(int now, int g, vector<int>& route) {
    visited[now] = true;
    if (now == g) {
        route.push_back(g);        
        return true;
    }
    for (const auto dst: graph.at(now)) {
        if (!visited[dst] && find_route(dst, g, route)) {
            route.push_back(now);
            return true;
        }
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    graph = vector<vector<int> >(N);

    memset(dist, -1, sizeof(dist));

    for (int i=0; i<N-1; i++) {
        int a, b;
        cin >> a >> b;
        graph.at(a-1).push_back(b-1);
        graph.at(b-1).push_back(a-1);
    }

    vector<int> route;
    find_route(0, N-1, route);
    reverse(route.begin(), route.end());
    dfs(0, 0);

    int d = dist[N-1] / 2;

    int u = route.at(d);
    int v = route.at(d+1);
    graph.at(v).erase(remove(graph.at(v).begin(), graph.at(v).end(), u), graph.at(v).end());
    graph.at(u).erase(remove(graph.at(u).begin(), graph.at(u).end(), v), graph.at(u).end());

    // init
    memset(dist, -1, sizeof(dist));
    int fn = dfs(0,0);

    if (fn > N - fn) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }

    return 0;
}

Measured memory_bytes: 11516
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

int main(void){
	int n,p,a,i;
	ll ans,dp[55][2];
	fill(dp[0],dp[55],0ll);
	dp[0][0] = 1ll;
	cin >> n >> p;
	for(i=0; i<n; ++i){
		cin >> a;
		dp[i+1][0] += dp[i][0];
		dp[i+1][1] += dp[i][1];
		dp[i+1][a%2] += dp[i][0];
		dp[i+1][(1+a%2)%2] += dp[i][1];
	}
	cout << (dp[n][p]) << endl;
	return 0;
}

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

int main(){
    int n, m;
    int tmp[100] = {};
    cin >> n >> m;

    int k, a;
    for(int i = 0;i < n;i++){
        cin >> k;
        for(int i = 0;i < k;i++){
            cin >> a;
            a--;
            tmp[a]++;
        }
    }

    int ans = 0;
    for(int i = 0;i < m;i++){
        if(tmp[i] == n){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi  3.14159265358979323846
#define mod 1000000007
#define pf push_front
#define pb push_back
#define flush fflush(stdout);
#define null NULL
#define test cout<<"#";
 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(null);
    ll n;
    cin>>n;
    ll a = n/500;
    ll b = n%500;
    cout<<a*1000+(b/5)*5;
}

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

using namespace std;

#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)
#define ll long long int

void solve()
{
    int n,k;
    cin>>n>>k;
    maxpq s;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        s.push(temp);
    }
    if(k>=n)
    cout<<"0";
    else{
    while(k--)
    {
        s.pop();
    }
    ll sum=0;
    while(!s.empty())
    {
        sum+=s.top();
        s.pop();
    }
    cout<<sum;
    }  

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4148
#include<cstdio>
const int maxn=100005;
struct edge{
  int to,next;
}lst[maxn<<1];int len=1,first[maxn];
void addedge(int a,int b){
  lst[len].to=b;lst[len].next=first[a];first[a]=len++;
}
int depth[maxn],sz[maxn],prt[maxn];
void dfs(int x,int p){
  sz[x]=1;
  for(int pt=first[x];pt;pt=lst[pt].next){
    if(lst[pt].to==p)continue;
    depth[lst[pt].to]=depth[x]+1;
    prt[lst[pt].to]=x;
    dfs(lst[pt].to,x);
    sz[x]+=sz[lst[pt].to];
  }
}
int main(){
  int n;scanf("%d",&n);
  for(int i=1,a,b;i<n;++i){
    scanf("%d%d",&a,&b);
    addedge(a,b);
    addedge(b,a);
  }
  depth[1]=1;
  dfs(1,0);
  int d=depth[n];
  int D=d/2;
  int v=n;
  for(int i=1;i<D;++i)v=prt[v];
  int a=n-sz[v],b=sz[v];
  if(a>b){
    printf("Fennec\n");
  }else{
    printf("Snuke\n");
  }
  return 0;
}


Measured memory_bytes: 7936
#include <algorithm>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long> vl;
typedef vector<vector<long>> vvl;
typedef vector<string> vs;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec)
{
    os << "[";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template <typename T>
T input()
{
    T t;
    cin >> t;
    return t;
}

template <typename T>
vector<T> input(const int N)
{
    vector<T> v(N);
    repeat(i, N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b)
{
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod)
{
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod)
{
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod)
{
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod)
{
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod)
{
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x)
    {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    char keep = S[K - 1];
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] == keep) {
            cout << keep;
        } else {
            cout << '*';
        }
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

struct mint {
    constexpr static int mod = 1000000007;
    long long x;
    mint(long long 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(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    // dp[見た数][0が存在][9が存在]
    vector<vector<vector<mint>>> dp(n + 1, vector<vector<mint>>(2, vector<mint>(2, 0)));
    dp[0][0][0] = 1;
    rep(i, n) {
        dp[i + 1][0][0] = dp[i][0][0] * 8;
        dp[i + 1][0][1] = dp[i][0][0] + dp[i][0][1] * 9;
        dp[i + 1][1][0] = dp[i][0][0] + dp[i][1][0] * 9;
        dp[i + 1][1][1] = dp[i][0][1] + dp[i][1][0] + dp[i][1][1] * 10;
    }
    cout << dp[n][1][1].x << endl;
    return 0;
}


Measured memory_bytes: 151504
n = gets.to_i
a = gets.split.map(&:to_i)

$mod = 10**9+7

def pow(a,b)
  if b == 1
    a
  elsif b%2 == 0
    (pow(a,b/2)**2)%$mod
  else
    (a*pow(a,b/2)**2)%$mod
  end
end

def create_fact(n)
  for i in 2..n
    $fact[i] = ($fact[i-1]*i)%$mod
  end
end

def create_fact_inv(n)
  $fact_inv[n] = pow($fact[n],$mod-2)
  n.downto(1) do |i|
    $fact_inv[i-1] = ($fact_inv[i]*i)%$mod
  end
end

def create_table(n)
  $fact = Array.new(n+1,1)
  $fact_inv = Array.new(n+1,1)
  create_fact(n)
  create_fact_inv(n)
end

def combi(a,b)
    if a < b
        0
    else
        (($fact[a]*$fact_inv[b])%$mod)*$fact_inv[a-b]%$mod
    end
end

create_table(n+1)

b = Hash.new(0)
k = 0
(n+1).times do |i|
    b[a[i]] += 1
    k = a[i] if b[a[i]] == 2
end

c = a.index(k)
d = n-a.rindex(k)

for i in 1..n+1
    puts (combi(n+1,i)-combi(c+d,i-1))%$mod
end

Measured memory_bytes: 19724
#include <iostream>
//#include <math.h>


using namespace std;

int main(void){
    int tmp;
    int X,Y,Z;
    cin >> X >> Y >> Z;

    tmp = X;
    X = Y;
    Y = tmp;
    tmp = X;
    X = Z;
    Z = tmp;

    cout << X <<" "<< Y <<" "<< Z <<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,k;
double p[200005];
double s[200005];
int a;
double ans;
double M;
double T;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]=(p[i]+1)/2;
        //cout<<p[i]<<endl;
        s[i+1]=s[i]+p[i];
    }
    for(int i=k;i<=n;i++){
        T=s[i]-s[i-k];
        //cout<<T<<endl;
        if(M<T){
            a=i;
            ans=T;
            M=T;
        }
    }
    cout<<fixed<<setprecision(18)<<ans<<endl;
    
}



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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n,W; cin >> n >> W;
    int w[n],v[n];
    forn(i,n) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(n+1);
    forn(i,n+1) dp[i] = vector<ll>(W+1);
    dforn(i,n) forsn(j,1,W+1){
        ll skip = dp[i+1][j];
        ll take = j >= w[i] ? v[i] + dp[i+1][j-w[i]] : 0;
        dp[i][j] = max(skip, take); 
    }
    cout << dp[0][W] << endl;
    return 0;
}


Measured memory_bytes: 79488
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0123
{
    public class Program

    {
        public struct Lank
        {
            public string Name { get; set; }
            public double Border0500 { get; set; }
            public double Border1000 { get; set; }
            public Lank(string name, TimeSpan _500, TimeSpan _1000)
            { Name = name; Border0500 = _500.TotalSeconds; Border1000 = _1000.TotalSeconds; }
        }
        public static List<Lank> borders = new List<Lank>();

        public static void Main(string[] args)
        {
            borders.Add(new Lank("AAA", new TimeSpan(0, 0, 0, 35, 500), new TimeSpan(0, 0, 1, 11, 000)));
            borders.Add(new Lank("AA" , new TimeSpan(0, 0, 0, 37, 500), new TimeSpan(0, 0, 1, 17, 000)));
            borders.Add(new Lank("A"  , new TimeSpan(0, 0, 0, 40, 000), new TimeSpan(0, 0, 1, 23, 000)));
            borders.Add(new Lank("B"  , new TimeSpan(0, 0, 0, 43, 000), new TimeSpan(0, 0, 1, 29, 000)));
            borders.Add(new Lank("C"  , new TimeSpan(0, 0, 0, 50, 000), new TimeSpan(0, 0, 1, 45, 000)));
            borders.Add(new Lank("D"  , new TimeSpan(0, 0, 0, 55, 000), new TimeSpan(0, 0, 1, 56, 000)));
            borders.Add(new Lank("E"  , new TimeSpan(0, 0, 1, 10, 000), new TimeSpan(0, 0, 2, 28, 000)));

            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;

                double[] times = Array.ConvertAll(line.Trim().Split(' '), e => double.Parse(e));
                Console.WriteLine(GetLankName(times));
            }          
        }

        private static string GetLankName(double[] times)
        {
            foreach (var item in borders)
            {
                if (times[0] < item.Border0500 && times[1] < item.Border1000) return item.Name;
            }
            return "NA";
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 18004
use std::io::*;
use std::str::FromStr;
use std::f64;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
	let goal: f64 = read();
    let mut year = 0;
    let mut sum = 100.0;
    loop {
        year +=1;

        sum *= 1.01;
        sum = f64::floor(sum);

        if sum >= goal {
            println!("{}", year);
            break;
        }
    }
}


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

int main()
{
    int ans = 0;
    char s[3];
    for(int i = 0; i < 3; i++)
    {
        cin >> s[i];
        if(s[i] == '1')
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N,M,K;
ll A[100005];

ll dp[20005];

const ll INF = 1000000000000000000LL;

ll solve(){
  fill(dp,dp+N+1,INF);
  dp[0] = 0;
  for(ll i=1;i<=N;i++){
    ll a = -INF, b= INF;      
    for(ll j=i-1;j>=max(0LL,i-M);j--){
      b = min( A[j], b );
      a = max( A[j], a );
      ll c = K + (i-j)*(a-b);
      assert( c >= 0 );
      dp[i] = min( dp[i], dp[j] + c );
    }
  }
  return dp[N];
}

int main(){
  cin >>N >> M >> K;
  assert( N <= 20000 );
  for(int i=0;i<N;i++)
    cin >> A[i];
  cout << solve() << endl;
}

Measured memory_bytes: 3412
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  for(char c:s){
    cout<<char((c+n<='Z')? c+n:c+n-'Z'+'A'-1);
  }
  cout<<endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
  b.append(a[i]-i-1)
  
b.sort()

center = n//2
c1 = b[center]

ans = 0
for i in range(n):
  ans += abs(b[i]-c1)
print(ans)

Measured memory_bytes: 25200
#include <stdio.h>

typedef long long int64;
typedef unsigned long long uint64;

int fbcheck(int i)
{
	if (i % 3 == 0 || i % 5 == 0)
	{
		return 0;
	}
	return i;
}

int main()
{
	int n;
	uint64 l = 0;
	scanf("%d", &n);
	for (int i = 1; i != n + 1; i++)
	{
		l += fbcheck(i);
	}
	printf("%lld", l);
	return 0;
}


Measured memory_bytes: 1728
day = input()
if day == 'SUN':
    print(7)
elif day == 'MON':
    print(6)
elif day == 'TUE':
    print(5)
elif day == 'WED':
    print(4)
elif day == 'THU':
    print(3)
elif day == 'FRI':
    print(2)
elif day == 'SAT':
    print(1)

Measured memory_bytes: 2940
class AtCoder {
  // 入力系
  input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);
  input_i=-1;

  N=this.input[0];
  M=this.input[1];
  SN=String(this.input[0]);
  SM=String(this.input[1]);

  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n:number):number[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n:number):string[]{
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }

  // コンソール
  o(...a:any){
    console.log(...a);
  }

  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }

  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }

  // 自作
  gcd(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr:number[]):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
  f(roop:number, callback:any){
    for(let i=0;i<roop;i++){
      callback(i);
    }
  };
  Yes(){
    console.log('Yes');
  }
  No(){
    console.log('No');
  }
  YES(){
    console.log('YES');
  }
  NO(){
    console.log('NO');
  }
}
const m = () => {
  const o = new AtCoder()
  let g=0n;
  for(let i=1;i<=o.N;i++){
    if(i % 3 == 0 || i % 5 == 0)continue
    g+=BigInt(i);
  }
  o.o(g.toString())
}
m();

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

const int maxn=105;
const int mod=1e9+7;
int A,B,C,a,b,c,s;
int valAB,valAC,valBC,valABC;
int f[maxn],ch[maxn][maxn];
void Add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}
void Sub(int &a,int b){
	a-=b;
	if(a<0)a+=mod;
}
int power(int x,int pow){
	int res=1;
	for(;pow;pow>>=1){
		if(pow&1)res=1LL*res*x%mod;
		x=1LL*x*x%mod;
	}
	return res;
}

int main(){
	scanf("%d%d%d%d%d%d",&a,&b,&c,&A,&B,&C);
	if(A%a||B%b||C%c){
		puts("0");
		return 0;
	}
	Add(valAB,1LL*a*power(b,A/a)%mod);
	Add(valAB,1LL*b*power(a,B/b)%mod);
	Sub(valAB,1LL*a*b%mod);
	Add(valAC,1LL*a*power(c,A/a)%mod);
	Add(valAC,1LL*c*power(a,C/c)%mod);
	Sub(valAC,1LL*a*c%mod);
	Add(valBC,1LL*b*power(c,B/b)%mod);
	Add(valBC,1LL*c*power(b,C/c)%mod);
	Sub(valBC,1LL*b*c%mod);
	Add(valABC,1LL*a*power(valBC,A/a)%mod);
	Add(valABC,1LL*b*power(valAC,B/b)%mod);
	Add(valABC,1LL*c*power(valAB,C/c)%mod);
	Sub(valABC,1LL*a*b%mod*power(c,A/a*B/b)%mod);
	Sub(valABC,1LL*a*c%mod*power(b,A/a*C/c)%mod);
	Sub(valABC,1LL*b*c%mod*power(a,B/b*C/c)%mod);
	Add(valABC,1LL*a*b*c%mod);
	s=max(A/a,B/b);
	for(int i=0;i<=s;i++)ch[i][0]=1;
	for(int i=1;i<=s;i++)for(int j=1;j<=s;j++){
		ch[i][j]=ch[i-1][j-1];
		Add(ch[i][j],ch[i-1][j]);
	}
	for(int j=1;j<B/b;j++){
		for(int i=A/a-1;i>=1;i--){
			int coef=0;
			int cura=power(b,i),curb=power(a,j);
			Add(coef,power((cura+curb)%mod+mod-1,C/c));
			Sub(coef,power(cura,C/c));
			Sub(coef,power(curb,C/c));
			Add(coef,1);
			f[i]=1LL*power(power(c,A/a-i)+mod-1,B/b-j)*ch[A/a][i]%mod;
			for(int k=i+1;k<A/a;k++)Sub(f[i],1LL*f[k]*ch[k][i]%mod);
			Add(valABC,1LL*f[i]*ch[B/b][j]%mod*c%mod*coef%mod*a%mod*b%mod);
		}
	}
	printf("%d\n",valABC);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k;

int main() {
    cin >> n >> k;
    vector<int> v(n, 0);
    for(int i = 0; i < n; ++i) cin >> v.at(i);

    int limit = min(n, k);
    int left = 0; int right = 0;
    long long msum = 0;
    for(right = 0; right <= limit; ++right) {
        priority_queue<long long, vector<long long>, greater<long long>> rightque;
        for(int i = 0; i < right; ++i) {
            rightque.push(v.at(n-1-i));
        }

        priority_queue<long long, vector<long long>, greater<long long>> ansque;
        for(left = 0; left <= limit-right; ++left) {
            ansque = rightque;
            for(int j = 0; j < left; ++j) {
                ansque.push(v.at(j));
            }

            int pushcnt = k - right - left;
            int nowcnt = 0;
            long long sum = 0;
            while(!ansque.empty() && nowcnt < pushcnt) {
                if(ansque.top() < 0) {
                    ansque.pop();
                    nowcnt++;
                }else {
                    break;
                }
            }

            while(!ansque.empty()) {
                sum += ansque.top();
                ansque.pop();
            }

            msum = max(msum, sum);
        }
    }
    cout << msum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
//#define temo

using namespace std;
const int N = 1e5 + 5;

int n, m;
vector < int > v[N];
int main()
{
    cin>>n;
    for (m = 0; m * (m - 1) / 2 < n; m++){}
    if (m * (m - 1) / 2 > n){
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";
    cout<<m<<endl;
    int T = 1;
    for (int i = 1; i < m; i++){
        for (int j = i + 1; j <= m; j++){
            v[i].pb (T);
            v[j].pb (T);
            T++;
        }
    }
    for (int i = 1; i <= m; i++){
        cout<<v[i].size()<<" ";
        for (int j = 0; j < v[i].size(); j++)
            cout<<v[i][j]<<" ";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string s;
    cin >> s;
    bool fla = true;

    for(int i = 0;i < s.size()-1;i++)
        if(s.at(i) == s.at(i+1))
            fla = false;
    if(fla)
        cout << "Good" << endl;
    else
        cout << "Bad" << endl;
} 

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define iter(it,a) for(auto it=a.begin();it!=a.end();it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define preturn(X) cout<<X<<endl; return 0
typedef long long ll;




int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==1 || b%2==1 || c%2==1){
    	preturn(0);
    }
    if(a==b && b==c){
    	preturn(-1);
    }
    int ans = 0;
    int a1,b1,c1;
    while(a%2==0 && b%2==0 && c%2==0){
    	a1 = (b+c)/2;
    	b1 = (a+c)/2;
    	c1 = (b+a)/2;
    	a = a1;
    	b=b1;c=c1;
    	ans++;
    }
    preturn(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, x, i, s=1, ans=0;
    cin >> n >> x;
    vector <int> bo (n);
    bo[0]=0;
    for(i=1; i<=n; i++)
    {
        cin >> bo[i];
        ans+=bo[i];
        if(ans<=x)
            s++;
    }
    cout << s << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int sum=0,N,K,x;
  cin >> N >> K;
  for (int i=0;i<N;i++){
    cin >> x;
    if (x<=K-x){
      sum+=2*x;
    }
    else
      sum+=2*(K-x);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
if n > 1:
	p1 = int(input())
	p2 = int(input())
	maxi = p2 - p1
	mini = min(p1, p2)
	for i in range(n - 2):
		current = int(input())
		maxi = max(maxi, current - mini)
		mini = min(mini,  current)
	print(maxi)



Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define MAX 200000
using namespace std;

int main(void){
  vector<string> v;
  int N;
  cin >> N;
  string str[MAX];
  for(int i=0;i<N;i++){
    string tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  
  sort(v.begin(),v.end());

  int sum = 1;
  for(int n=1;n<N-1;n++){
    if(v[n] != v[n-1])
      sum++;
  }
  if(v[N-1] != v[N-2])
    sum++;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 17908
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;
ll f[1000001], res;

ll pw(ll x, int y) {
	ll a = 1;
	while (y) {
		if (y & 1) {
			a = a*x%mod;
		}
		x = x*x%mod;
		y /= 2;
	}
	return a;
}

ll modinv(ll x) {
	return pw(x, mod - 2);
}

ll comb(int n, int r) {
	return f[n] * modinv(f[r]) % mod*modinv(f[n - r]) % mod;
}

int main() {
	cin >> N;
	f[0] = 1;
	for (ll i = 1; i <= 1000000; ++i) {
		f[i] = f[i - 1] * i % mod;
	}
	if (N & 1) {
		res = comb((N - 1) / 2, 1)*((N - 1) / 2 + 1) % mod*f[(N - 1) / 2 + 1] % mod*f[N - 1 - ((N - 1) / 2 + 1)] % mod;
		for (int i = 3; i < N; i += 2) {
			res += (comb((N - i) / 2 + i - 1, i)*f[(N - i) / 2 + i] % mod*f[N - 1 - ((N - i) / 2 + i)] % mod + mod - comb((N - i + 2) / 2 + i - 3, i - 2)*f[(N - i + 2) / 2 + i - 2] % mod*f[N - 1 - ((N - i + 2) / 2 + i - 2)] % mod)*((N - i) / 2 + i) % mod;
			res %= mod;
		}
	}
	else {
		res = f[N / 2] * N / 2 % mod * f[N / 2 - 1] % mod;
		for (int i = 2; i < N; i += 2) {
			res += (comb(N / 2 + i / 2 - 1, i)*f[N / 2 + i / 2] % mod*f[N / 2 - i / 2 - 1] % mod + mod - comb(N / 2 + i / 2 - 2, i - 2)*f[N / 2 + i / 2 - 1] % mod*f[N / 2 - i / 2] % mod)*(N / 2 + i / 2) % mod;
			res %= mod;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if((B+C)>A) cout << C-(A-B) << endl;
    else cout << 0 << endl;

}

Measured memory_bytes: 888
count=int(raw_input())

for i in range(0,count):
    a,b,c=map(int,raw_input().split())
    if pow(a,2)+pow(b,2)==pow(c,2):
        print 'YES'
    elif pow(a,2)+pow(c,2)==pow(b,2):
        print 'YES'
    elif pow(b,2)+pow(c,2)==pow(a,2):
        print 'YES'
    else:
        print 'NO'

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

int main() {
  
  int N;
  int L;
  int num = 1;
  int num2 = 0;
  
  cin >> N >> L;
  
  vector<int> vec(N);
  
  for(int i = 0;i < N;++i){
    vec[i] = num + L - 1;
    num++;
  }
  
  for(int i = 0;i < N;++i){
    if(vec[i] == 0){
       for(int k = 0;k < N;++k){
         num2 = vec[k] + num2;
       }
      goto loop_end;
    }
  }
  
  for(int i = 0;i < N;++i){
    if(vec[i] > 0){
      num2 = vec[i + 1] + num2;
    }
    else{
      for(int k = 0;k < N - 1;++k){
        num2 = vec[k] + num2;
      }
      break;
    }
  }
  
  loop_end:
  
  cout << num2 << endl;
  
}


Measured memory_bytes: 256
int a(int x,int y){
	int i,j,k,count=0;
	
	for(i=1;i<=x;i++){
		for(j=1;j<=x;j++){
			for(k=1;k<=x;k++){
				if(i<j && j<k && y==i+j+k) count++;
			}
		}
	}
	return count;
}

int main(){
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		printf("%d\n",a(x,y));
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  ll a[n+1]={};
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

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

  ll b[n+1]={};
  for(int i=0;i<n;i++) b[i]=max(0ll,a[i]);
  for(int i=1;i<n;i++) b[i]+=b[i-1];

  ll ans=0;
  for(int i=k-1;i<n;i++){
    ll tmp=0;
    if(i==k-1) tmp=s[k-1];
    else tmp=s[i]-s[i-k];
    tmp=max(0ll,tmp);

    if(i==k-1) tmp+=b[n-1]-b[k-1];
    else tmp+=b[n-1]-b[i]+b[i-k];
    ans=max(ans,tmp);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 2560
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  ll n;cin>>n;
  n--;
  ll min1=1000000000000000;
  rep(i,5){
    ll a;
    cin>>a;
    min1=min(min1,a);
  }
  cout<<n/min1+5<<endl;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

vector<pair<ll, ll>> prime_factorize(ll n) {
	vector<pair<ll, ll>> res;
	for (ll i=2; i*i <=n; i++) {
		if (n%i != 0) continue;
		ll ex = 0;
		while (n%i==0) {
			ex++; n /= i;
		}
		res.push_back({i, ex});
	}
	if (n != 1) res.push_back({n, 1});
	return res;
}


int main(int, char**) {
	ll a, b; cin >> a >> b;
	ll m, x;
	if (a < b) {
		m = a;
		x = b;
	} else {
		m = b;
		x = a;
	}

	vector<pair<ll, ll>> mfac = prime_factorize(m);
	int ret = 0;
	for (auto p : mfac) {
		if (x%(p.first)==0) ret++;
	}
	cout << ret + 1 << endl;

	return 0;
}

Measured memory_bytes: 3568
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn binary_search(target: u64, target_vec: &Vec<u64>, left: i32, right: i32) -> usize {
    if right - left <= 1 {        
        return right as usize;
    }
    let mid = ((left+right)/2) as usize;
    if target < target_vec[mid] {
        return binary_search(target, target_vec, left, mid as i32);
    } else {
        return binary_search(target, target_vec, mid as i32, right);
    }
}

fn main() {
    let n: usize = input();
    let mut a_vec = input_vec();
    let mut b_vec = input_vec();
    let mut c_vec = input_vec();
    a_vec.sort();
    b_vec.sort();
    c_vec.sort();

    let mut a_to_b_indices: Vec<usize> = Vec::new();
    let mut b_to_c_indices: Vec<usize> = Vec::new();

    for a in &a_vec {
        let lower_bound = binary_search(*a, &b_vec, -1, n as i32);
        a_to_b_indices.push(lower_bound);
    }

    for b in &b_vec {
        let lower_bound = binary_search(*b, &c_vec, -1, n as i32);
        b_to_c_indices.push(lower_bound);
    }

    let mut c_cummulation: Vec<u64> = vec![0; n+1];
    for i in (0..n).rev() {
        c_cummulation[i] = c_cummulation[i+1] + (n - b_to_c_indices[i]) as u64;
    }
    // println!("{:?}", c_cummulation);

    let mut sum = 0;
    for b_idx in a_to_b_indices {    
        sum += c_cummulation[b_idx];
        // for i in b_idx..n {
        //     sum += n - b_to_c_indices[i];
        // }
    }
    // println!("{:?}", b_to_c_indices);

    println!("{}", sum);

}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)(x).size()
#define pb          push_back
#define eb          emplace_back
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    string s;
    cin >> s;
    int cnt = 0, mx = 0;
    rep(i, 3) {
        if (s[i] == 'R') cnt++, mx = max(mx, cnt);
        else cnt = 0;
    }
    cout << mx;
}


Measured memory_bytes: 3576
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct unionfind{
    vector<int> par, sz;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};
int main()
{
	int n, q; ll m;
	cin>>n>>m>>q;
	unionfind uf(n);
	int a[100010], b[100010], c[100010];
	for(int i=0; i<q; i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	set<P> stp;
	for(int i=0; i<q; i++){
		if(c[i]==0){
			if(a[i]>b[i]) swap(a[i], b[i]);
			if(stp.find({a[i], b[i]})!=stp.end()) continue;
			stp.insert({a[i], b[i]});
			uf.unite(a[i], b[i]);
		}
	}
	stp.clear();
	int cnt=0;
	for(int i=0; i<q; i++){
		if(c[i]==1){
			if(a[i]>b[i]) swap(a[i], b[i]);
			if(stp.find({a[i], b[i]})!=stp.end()) continue;
			stp.insert({a[i], b[i]});
			cnt++;
			if(uf.same(a[i], b[i])){
				cout<<"No"<<endl;
				return 0;
			}

		}
	}
	if(cnt==0 && m==n-1){
		cout<<"Yes"<<endl;
		return 0;
	}
	set<int> st;
	for(int i=0; i<n; i++){
		st.insert(uf.find(i));
	}
	ll x=st.size();
	if(n<=m && m<=n-x+x*(x-1)/2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main() {

  int N, K, L, M;
  cin >> N;
  cin >> K;
  
  for (int i = 0; i < N; i++) {
    cin >> L;

    if (L < K - L) {
      M += L * 2;
    } else {
      M += (K - L) * 2;
    }
  }
  
  cout << M << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

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

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

int main(){
    string s;
    cin>>s;
    if(s=="KIHBR"||s=="AKIHBR"||s=="KIHABR"||s=="KIHBAR"||s=="KIHBRA"||
    s=="AKIHABR"||s=="AKIHBAR"||s=="AKIHBRA"||s=="KIHABAR"||s=="KIHABRA"||
    s=="KIHBARA"||s=="AKIHABAR"||s=="AKIHBARA"||s=="AKIHABRA"||s=="KIHABARA"||
    s=="AKIHABARA")cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
	
	while (in.hasNext()) {
	  int a = in.nextInt();
	  int countOdd = a / 2 + a % 2;
	  
	  System.out.printf("%f\n", countOdd / (double)a);
	}
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int n; cin>>n;
vll A (n) , pr (n);
F (i,0,n,1) {
  cin>>A[i];
}
pr[0]=A[0];
F (i,1,n,1) pr[i]=A[i]+pr[i-1];
ll ans=0;
F (i,0,n-1,1) {
  ll sum= (A[i]*((pr[n-1]-pr[i])%MOD))%MOD;
  ans=(ans+sum)%MOD;  
}
cout<<ans;
return 0;
}


Measured memory_bytes: 6292