akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  int k;
  cin >> s >> k;
  rep(i,s.size()) {
    if(s[i]=='a') continue;
    int x=('z'-s[i])+1;
    if(x<=k) {
      k-=x;
      s[i]='a';
    }
  }
  string t="";
  t+='z'+1;
  rep(i,s.size()) {
    string r=s;
    r[i]='a'+(k+r[i]-'a')%26;
    t=min(t,r);
  }
  pr(t);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
int h[(int)10e5+2];
int dp[(int)10e5+2];
int n;
int recur(int pos)
{
	if(pos==0)
	return 0;
	if(pos<0)
	return INT_MAX;
	if(dp[pos]!=INT_MAX)
	return dp[pos];
	dp[pos]=min(abs(h[pos]-h[pos-1])+recur(pos-1),abs(h[pos]-h[pos-2])+recur(pos-2));
	return dp[pos];
}
signed main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>h[i];
	for(int i=0;i<n;i++)
	dp[i]=INT_MAX;
	cout<<recur(n-1)<<endl;
}

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

using namespace std;

int h, w, n;
set<int> S[200010];

int main(){
    scanf("%d %d %d", &h, &w, &n);
    for(int i = 1, x, y; i <= n; i++){
        scanf("%d %d", &x, &y);
        S[y].insert(x);
    }

    int x = 1, y = 1, ans = h;
    while(true){
        auto it = S[y].lower_bound(x);
        if(it != S[y].end()) ans = min(ans, *it - 1);

        if(x == h || S[y].find(x + 1) != S[y].end()) break;
        x++;
        if(!(y == w || S[y + 1].find(x) != S[y + 1].end())) y++;
    }
    printf("%d\n", ans);
    return 0;
}

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

int f[1000010],s[1000010],s1[1000010],n;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
	
}

int main()
{
	n=rd();
	if (n==1) { puts("1");return 0; }
	f[1]=s[1]=s1[1]=1;
	for (int i=2;i<=n;i++)
	{
		f[i]=((i>2?s1[i-3]:0)+1)%mod;
		s[i]=(s[i-1]+f[i])%mod;
		s1[i]=(s1[i-1]+s[i])%mod;
	}
	int ans=0;
	for (int i=1;i<n;i++) ans=(ll)(ans+(ll)f[i]*(n-1)%mod*n)%mod;
	ans=(ll)(ans+(ll)f[n]*(n-1))%mod;
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
using namespace std;

typedef long long int ll;

int main(){
    ll A, Count=20000000000001;
    cin >> A;
    for(ll i=1; i*i<=A; i++){
        if(A%i==0){
            if(Count > i+A/i-2){
                Count = i + A/i-2;
                }
            }
        }
    cout << Count;


}

Measured memory_bytes: 256
from math import hypot

n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3 = map(float, input().strip().split())

    d = lambda x, y: x*x + y*y
    t21 = [2*(x2-x1), 2*(y2-y1), d(x2,y2) - d(x1,y1)]
    t31 = [2*(x3-x1), 2*(y3-y1), d(x3,y3) - d(x1,y1)]

    det = lambda i, j: t21[i]*t31[j] - t21[j]*t31[i]
    a = det(2,1) / det(0,1)
    b = det(0,2) / det(0,1)
    r = hypot(x1-a, y1-b)

    print('{:.3f} {:.3f} {:.3f}'.format(a, b, r))

Measured memory_bytes: 6836
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    REP(i, K) {
        if (A >= B) {
            B <<= 1;
        } else if (B >= C) {
            C <<= 1;
        }
    }
    if (A < B && B < C) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
}

Measured memory_bytes: 3636
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int a[10];
    rep(i,1,5){
        cin>>a[i];
        if(a[i]==0) return cout<<i,0;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <ctime>
#include <queue>
#include <set>
using namespace std;

#define N 200010
#define M 500010
	
typedef long long ll;
const int INF = 1 << 30;
const int mod = 1000000007;

int n, k, cnt;
int a[N], c[N];
ll s[N], t[N], b[N];

map<ll, int> mp;

inline int Lowbit(int x){return x & (-x);}

void Insert(int x)
{
	while (x <= cnt)
	{
		c[x]++;
		x += Lowbit(x);
	}
}

int Sum(int x)
{
	int res = 0;
	while (x)
	{
		res += c[x];
		x -= Lowbit(x);
	}
	return res;
}

int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);
 	
 	ll ans = 0;
 	scanf("%d %d", &n, &k);
 	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), s[i] = s[i - 1] + a[i];
 	for (int i = 0; i <= n; ++i) t[i] = s[i] - 1ll * k * i, b[i] = t[i];
 	sort(b, b + n + 1);
 	
 	for (int i = 0; i <= n; ++i) if (!mp[b[i]]) mp[b[i]] = ++cnt;
 	for (int i = 0; i <= n; ++i) t[i] = mp[t[i]];
 	//for (int i = 0; i <= n; ++i) cout << t[i] <<" ";
 	//cout << endl;
 	for (int i = 0; i <= n; ++i)
 	{
 		ans += Sum(t[i]);
 		Insert(t[i]);
 	//	cout << ans << endl;
	}
	cout << ans << endl;
	return 0; 
}

Measured memory_bytes: 18944
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<long long ,long long >
#define ppll pair < pll , pll >
#define mod 1000000007
unsigned int bp(int n) // built_in_pop_count // 
{ 
    unsigned int count = 0; 
    while (n) { 
        n &= (n - 1); 
        count++; 
    } 
    return count; 
} 
int32_t main(){
    SPEED;
    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
    }
    sort(arr, arr + n);
    int sum = 0;
    for(int i = 0; i < k; ++i){
        sum += arr[i];
    }
    cout << sum;
}

Measured memory_bytes: 3652
//

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

int main(){
	int S, W;
	cin >> S >> W;

	string ans;

	if (S > W) ans = "safe";
	else ans = "unsafe";

	cout << ans << endl;

	return 0;
}

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

int N;
int V[270000], W[270000];
int Q;
int dp[550][100100];

void dfs(int v, int d) {
    if (v>N || d>9) return;
    rep(i, 100100) {
        dp[v][i] = dp[v/2][i];
        if (i>=W[v-1]) dp[v][i] = max(dp[v][i], dp[v/2][i-W[v-1]]+V[v-1]);
    }
    dfs(2*v, d+1);
    dfs(2*v+1, d+1);
}

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N;
    rep(i, N) cin >> V[i] >> W[i];
    rep(i, 550) rep(j, 100100) dp[i][j] = 0;
    dfs(1, 1);
    rep(i, 550) for (int j=1; j<100100; j++) dp[i][j] = max(dp[i][j], dp[i][j-1]);
    
    cin >> Q;
    while (Q--) {
        int v, L; cin >> v >> L;
        if (v<=511) cout << dp[v][L] << endl;
        else {
            vector<int> vl, wl;
            while (v>511) {
                vl.pb(V[v-1]);
                wl.pb(W[v-1]);
                v /= 2;
            }
            int ans = 0;
            rep(S, 1<<(vl.size())) {
                int now_v = 0, now_w = 0;
                rep(i, vl.size()) {
                    if ((S>>i)&1) {
                        now_v += vl[i];
                        now_w += wl[i];
                    }
                }
                if (now_w>L) continue;
                ans = max(ans, now_v+dp[v][L-now_w]);
            }
            cout << ans << endl;
        }
    }
}

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

int main(){
    int N;  cin>>N;
    double x[N],sum=0.0;
    string u[N];
    
    for(int i=0;i<N;i++){
        cin>>x[i]>>u[i];
        if(u[i]=="JPY")
            sum+=x[i];
        else
            sum+=x[i]*380000.0;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define I inline
#define OP operator
#define pb push_back
#define mp make_pair
#define RT return *this
#define dbg(x) cerr<<#x" = "<<x<<endl
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef long long ll;typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=((TT=but)+fread(but,1,1<<15,stdin)),TT==mo))?-1:*TT++)
I bool IS(char x){return x==10||x==13||x==' ';}
struct Cg{I char OP()(){return getchar();}};struct Cp{I void OP()(char x){putchar(x);}};
#define RX char c,f=1;while(!isdigit(c=P()))f=c!='-';x=c-'0';while(isdigit(c=P()))x=x*10+c-'0';x=f?x:-x
#define TR *this,x;return x
struct Fr{Cg P;I Fr&OP,(int&x){RX;RT;}I OP int(){int x;TR;}I Fr&OP,(ll &x){RX;RT;}I OP ll(){ll x;TR;}
I Fr&OP,(char&x){while(IS(x=P()));RT;}I OP char(){char x;TR;}
I Fr&OP,(char*x){char t=P();for(;IS(t);t=P());if(~t){for(;!IS(t)&&~t;t=P())*x++=t;}*x++=0;RT;}}in;
#define WI if(x){if(x<0)P('-'),x=-x;char s[22],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')
struct Fw{Cp P;I Fw&OP,(int x){WI;RT;}I Fw&OP,(ll x){WI;RT;}I Fw&OP,(char x){P(x);RT;}
I Fw&OP,(const char *x){while(*x)P(*x++);RT;}}out;
const int N=1e5+11;
struct Edge{
	int v;Edge *nxt;
}pl[N<<1],*cur=pl,*G[N];
I void ins(int u,int v){*cur=(Edge){v,G[u]},G[u]=cur++;}
priority_queue<pii> H;
int n,f[N];
int main(){
	in,n;
	rep(i,1,n)f[i]=inf;
	int u,v;
	rep(i,2,n){
		in,u,v;
		ins(u,v),ins(v,u);
	}
	int m=in;
	rep(i,1,m){
		in,u,v;
		f[u]=v;
		H.push(mp(v,u));
	}
	while(!H.empty()){
		int x=H.top().y;H.pop();
//		out,x,'\n';
		Es(x,i)if(f[i->v]==inf){
			H.push(mp((f[i->v]=f[x]-1),i->v));
		} else if(abs(f[i->v]-f[x])!=1) {
			return puts("No"),0;
		}
	}
	puts("Yes");
	rep(i,1,n)out,f[i],'\n';
}

Measured memory_bytes: 6132
using System;

public class Program
{ 
  private static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    
    string[] input = Console.ReadLine().Split(' ');
    int[] D = new int[N];
    
    for(int i = 0; i < N; i++)
      D[i] = int.Parse(input[i]);
    
    int sum = 0;
    
    for(int i = 0; i < N; i++)
    {
      for(int j = i + 1; j < N; j++)
        sum += D[i] * D[j];
    }
    
    Console.WriteLine(sum.ToString());
  }
}


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

using namespace std;
#define fast	ios::sync_with_stdio(0);cin.tie(0);
#define ll 		long long int
#define INF     1e18L
#define precision(x)	fixed << setprecision(x)
const ll mod = 1e9 + 7;

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


ll powm(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)
			res = (res * 1LL * a) % mod;
		b >>= 1LL;
		a = (a * 1LL * a) % mod;
	}
	return res;
}
const int N = 1e6 + 5;

//--------------------------------------------------------------------------------------------------------------------------//



void solve() {

	int n; cin >> n;
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		int rem = n - i;
		for (int j = 1; j * j <= rem; j++) {
			if (rem % j == 0) {
				if (j * j == rem)ans++;
				else ans += 2;
			}
		}
	}
	cout << ans << endl;
}

int main() {
	fast
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int tc = 1;
	// cin >> tc;

	int _ = 0;
	while (_++ < tc) {
		solve();
	}

	return 0;
}






Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

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

    return 0;
}
int clue() {

    int a,b;
    cin>>a>>b;
    
    
    (a>=10||b>=10)?cout<<-1<<endl:cout<<a*b<<endl;
    
    return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"

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

#define rep(i,n) for (ll i = 0; i < (n); i++)
#define ru(a,b) (((a)+((b)-1)) / (b))   //切り上げ(a/b)
#define dump(x)  cout << #x << " = " << (x) << endl;

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

	int q;
	cin >> q;

	bool rev = false;

	rep(i, q) {
		int t;
		cin >> t;
		if (t == 1) {
			//文字列の前後反転
			//reverse(s.begin(), s.end());
			if (rev) rev = false;
			else
				rev = true;
		}
		else if (t == 2) {
			int f;
			char c;
			cin >> f >> c;
			if (f == 1) {
				//文字列の先頭にcを追加
				if (!rev)
					s.insert(s.begin(), c);
				else
					s.push_back(c);
			}
			else if (f == 2) {
				//文字列の末尾にcを追加
				if (!rev)
					s.push_back(c);
				else
					s.insert(s.begin(), c);
			}
		}
	}

	if (rev)
		reverse(s.begin(), s.end());




	cout << s << endl;
	return 0;
}

Measured memory_bytes: 900
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e17
using namespace std;
typedef pair<ll, ll> P;

double dp[3010][3010];

int main(void) {
	string s;
	ll k;
	cin >> s >> k;
	for (ll i = 0;i < s.length();i++) {
		if (s[i] == '1') {
			k--;
			if (k == 0) {
				cout << s[i] << endl;
				return 0;
			}
		}
		else {
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    int a, b;
    cin >> a >> b;
    if(a * b % 2 == 0) PRINT("No");
    else PRINT("Yes");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int solve(int,int);
int A[20];
int n;
int main(){
  int i,j,B[200],m;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    }
  scanf("%d",&m);
    for(j=0;j<m;j++){
      scanf("%d",&B[j]);
      if(solve(0,B[j]))
	printf("yes\n");
      else 
	printf("no\n");
    }
  return 0;
}


int solve(int i, int m){
  int res;
  if (m == 0)
    return 1;
  if (i >= n)
    return 0;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

Measured memory_bytes: 580
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

int main()
{
    long long A, P;
    int BI, BD, B;

    scanf("%lld%d.%d", &A, &BI, &BD);
    B = BI * 100 + BD;
    P = A * B / 100;
    printf("%lld", P);

    return 0;
}


Measured memory_bytes: 1732
ans = 0
def do(x,c,index):
    global ans
    # print "c : " + str(c)
    # print "x : " + str(x)
    # print "index : "+ str(index)
    # print "###############"
    if index < 0:
        return
    if x < 0:
        return
    if c>=3 and x!=0:
        return
    if x == 0 and c!=3:
        return
    if c==3 and x==0:
        # print "detect!"
        ans += 1
        return
    for i in reversed(xrange(1,index+1)):
        # print "i : "+ str(i)
        do(x-i,c+1,i-1)
    return

while True:
    n,x = map(int,raw_input().split())
    if n==0 and x == 0:
        break
    # nlist = [i for i in xrange(1,n+1)]
    # print nlist
    do(x,0,n)
    # print "ans : "+str(ans)
    print ans
    ans = 0

Measured memory_bytes: 6460
#include <iostream>
#include <cassert>
#include <queue>

#define INF 922337203685477580
typedef long long ll;

using namespace std;


int solve(int i, int to, int target, int*A) {
  if (i >= to || target <= 0) return 0;

  if (A[i] == target) {
    return 1;
  }

  return max(solve(i + 1, to, target - A[i], A), solve(i + 1, to, target, A));
}

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

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

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int m;
    cin >> m;

    if (solve(0, n, m, A)) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}

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

int main(){
   ll N,M;
   cin>>N>>M;
   vector<vector<ll>> x(N);
   rep(i, M){
        ll A,B;
        cin>>A>>B;
        x[A-1].push_back(B-1);
        x[B-1].push_back(A-1);
   }

   queue<ll> q;
   q.push(0);
   vector<ll> dis(N, -1);
   dis[0] = 0;
   ll pre[N];
   while(!q.empty()){
       ll a = q.front();
       q.pop();
       for(ll next : x[a]){
           if(dis[next] == -1){
               q.push(next);
               dis[next] = dis[a]+1;
               pre[next] = a+1;
           }
       }
   }

    cout << "Yes" << endl;
   for(ll i=1; i<N; i++){
       cout << pre[i] << endl;
   }
}


Measured memory_bytes: 16708
#include <bits/stdc++.h>
using namespace std;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n, r, l, rc, lc, c;
string s, ans;
int main(){
    cin >> n;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(s[i] != s[i-1]){
            if(s[i] == '('){
                if(c < 0){
                    r += c;
                    c = 0;
                }
            }
        }
        if(s[i] == '(') ++c;
        else    --c;
    }

    for(int i = r; i < 0; i++)  cout << '(';
    for(int i = c; i < 0; i++)  cout << '(';
    for(int i = 0; i < n; i++)  cout << s[i];
    for(int i = c; i > 0; i--)  cout << ')';
    cout << endl;
}

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

int main(void){
	int h, w;
	string str;
	while (cin >> h >> w, h!=0 || w != 0){
		for (int i = 0; i < h; i++){
			if (i == 0 || i ==  h-1) str = string(w, '#');
			else str = '#' + string(w-2, '.') + '#';
			cout << str << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
/*-- ILSH --*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define viii vector < vii >
#define vlll vector < vll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=200000+6;
const ll inf=1e18+1e17;
void solve(){
	int a,b;
	cin>>a>>b;
	if ( a==b)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //    freopen ("INPUT.txt" , "r" , stdin);
    //    freopen ("OUTPUT.txt", "w" , stdout);
    // #endif	
    int t=1;
    //cin>>t;
    while ( t-- ){
    	solve();
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

vector<vector<int>> graph(2010, vector<int>());

void dfs(int n, int p, int d, vector<int> &dis) {
	dis[n] = d;
	for (int i : graph[n]) {
		if (i == p) continue;
		dfs(i, n, d + 1, dis);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n, k;
	cin >> n >> k;
	vector<int> x(n - 1), y(n - 1);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		graph[a].pb(b);
		graph[b].pb(a);
		x[i] = a; y[i] = b;
	}
	int ans = 0;
	if (k % 2 == 0) {
		k /= 2;
		rep(i, n) {
			int cnt = 0;
			vector<int> dis(n);
			dfs(i, -1, 0, dis);
			rep(j, n) {
				if (dis[j] <= k) cnt++;
			}
			chmax(ans, cnt);
		}
	}
	else {
		k /= 2;
		rep(i, n - 1) {
			int cnt = 0;
			vector<int> dis(n);
			dfs(x[i], y[i], 0, dis);
			dfs(y[i], x[i], 0, dis);
			rep(j, n) {
				if (dis[j] <= k) cnt++;
			}
			chmax(ans, cnt);
		}
	}
	cout << n - ans << endl;
}

Measured memory_bytes: 512
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
//#define int long long
#define inf 200000000
const int maxnodes=1005;
#define ll long long
#define N 501
#define EPS 0.01


int32_t main()
{
    IOS;

    int a,p;
    cin >> a >> p;
    cout << (a*3+p)/2;
    return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1024 * 512;
const LL mod = 998244353;

int n, m;

LL sil[M], odw[M];

LL poww(LL x, LL e)
{
	if (e == 0)
	{
		return 1;
	}
	if (e % 2 == 0)
	{
		return poww(x * x % mod, e / 2);
	}
	return poww(x, e - 1) * x % mod;
}

LL newt(int a, int b)
{
	assert(b >= 0 && b <= a);
	LL res = sil[a] * odw[b] % mod;
	return res * odw[a - b] % mod;
}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	sil[0] = 1;
	odw[0] = 1;
	FOR(i, 1, M - 1)
	{
		sil[i] = sil[i - 1] * i % mod;
		odw[i] = poww(sil[i], mod - 2);
	}
	
	scanf("%d%d", &n, &m);
	LL res = 0;
	
	FOR(i, 0, min(n, m))
	{
		LL tmp = newt(n, i) * newt(m, i) % mod;
		tmp = tmp * sil[i] % mod;
		tmp = tmp * poww(m + 1, n - i) % mod;
		tmp = tmp * poww(n + 1, m - i) % mod;
		res = (res + poww(-1, i) * tmp + mod) % mod;
	}
	
	printf("%lld\n", res);
	return 0;
}



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

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

vector<string> split(const string& str, const string& seps) {
  char *p, *str_buff = new char[str.size() + 1];
  vector<string> res;
  strcpy(str_buff, str.c_str());
  p = strtok(str_buff, seps.c_str());
  while (p) {
    res.emplace_back(p);
    p = strtok(NULL, seps.c_str());
  }
  delete str_buff;
  return res;
}

struct Puzzle {
  int f[8];
  int space;
  Puzzle() {}
  bool check() {
    for (int i = 0; i < 8; i++) {
      if (f[i] != i) return false;
    }
    return true;
  }
  bool operator < (const Puzzle& p) const {
    for (int i = 0; i < 8; i++) {
      if (f[i] == p.f[i]) continue;
      return f[i] < p.f[i];
    }
    return false;
  }
};

int dy[] = {-1, 0, 0, 1};
int dx[] = {0, -1, 1, 0};
map<Puzzle, int> dis;

void init() {
  Puzzle p;
  iota(p.f, p.f + 8, 0);
  p.space = 0;
  queue<Puzzle> que;
  que.emplace(p);
  dis[p] = 0;
  while (!que.empty()) {
    Puzzle u = que.front(); que.pop();
    int y = u.space / 4, x = u.space % 4;
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny >= 0 && ny < 2 && nx >= 0 && nx < 4) {
        Puzzle v = u;
        swap(v.f[y * 4 + x], v.f[ny * 4 + nx]);
        v.space = ny * 4 + nx;
        if (dis.find(v) != dis.end()) continue;
        dis[v] = dis[u] + 1;
        que.emplace(v);
      }
    }
  }
}

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

  init();
  string s;
  while (getline(cin, s)) {
    auto v = split(s, " ");
    Puzzle p2;
    for (int i = 0; i < 8; i++) {
      p2.f[i] = stoi(v[i]);
      if (p2.f[i] == 0) p2.space = i;
    }
    cout << dis[p2] << endl;
  }

  return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int a,b; cin >> a >> b;
    if((a>b && b!=1) || (a==1 && b!=1)) cout << "Alice" << endl;
    else if((a<b && a!=1)|| (b==1 && a!=1)) cout << "Bob" << endl;
    else cout << "Draw" << endl;
}

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

int x,y,A,B,C;
struct node{
	int c;
	long long p;
};
node a[300030];
int cnt;

bool cmp(node X,node Y){
	return X.p>Y.p;
}

int main(){
	cin>>x>>y>>A>>B>>C;
	
	for (int i=1;i<=A;i++){
		long long p;
		scanf("%lld",&p);
		node t;
		t.c=1;
		t.p=p;
		a[++cnt]=t;
	}
	for (int i=1;i<=B;i++){
		long long p;
		scanf("%lld",&p);
		node t;
		t.c=2;
		t.p=p;
		a[++cnt]=t;
	}
	for (int i=1;i<=C;i++){
		long long p;
		scanf("%lld",&p);
		node t;
		t.c=3;
		t.p=p;
		a[++cnt]=t;
	}
	sort(a+1,a+cnt+1,cmp);
	long long ans = 0;
	
	int nx=0,ny=0,num=0;
	for (int i=1;i<=cnt;i++){
		node t = a[i];
		if (t.c==1){
			if (nx==x) continue;
			nx++;
		}
		else if (t.c==2){
			if (ny==y) continue;
			ny++;
		}
		num++;
		ans+= t.p;
		if (num==x+y) break;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8464
n, k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
getpoint = {'r':p,'s':r,'p':s}
ans = 0
for i in range(k):
    point = getpoint[t[i]]
    ans += point
    j = i+k
    while j <= n-1:
        if t[j] == t[j-k] and point != 0:
            point = 0
            j += k
        else:
            point = getpoint[t[j]]
            ans += point
            j += k
print(ans)

Measured memory_bytes: 3316
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from numba import njit
def main():
    @njit
    def solve(n):
        r = 0
        for i1 in range(1, n + 1):
            for i2 in range(i1, n + 1, i1):
                r += i2
        return r
    no = int(input())
    print(solve(no))
if __name__ == '__main__':
    main()


Measured memory_bytes: 108924
n,m = gets.chomp.split.map(&:to_i)
xyz = []
n.times do
    xyz << gets.chomp.split.map(&:to_i)
end

ans = 0
0.upto(7) do |i|
    i1 = i2 = i3 = 1
    i1 = -1 if i & 1 == 1
    i2 = -1 if i & 2 == 2
    i3 = -1 if i & 4 == 4
    zyx = xyz.sort{|a, b| i1*a[0]+i2*a[1]+i3*a[2] <=> i1*b[0]+i2*b[1]+i3*b[2] }
    tmp = 0
    (n-1).downto(n-m) do |j|
        tmp += i1*zyx[j][0] + i2*zyx[j][1] + i3*zyx[j][2]
    end
    ans = tmp if ans < tmp
end
p ans

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

using namespace std;

int h[100010], cnt[100010];

int main()
{
    h[1] = 1;
    for(int i = 0; i < 100003; i++) {
        cnt[i] = 1;
    }

    int n, m, x, y;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        cin >> x >> y;
        if(h[x])
            h[y] = 1;
        if(cnt[x] == 1)
            h[x] = 0;
        cnt[x]--;
        cnt[y]++;



    }

    int ans = 0;

    for(int i = 1; i <= n; i++) {
        if(h[i])
            ++ans;
    }

    cout << ans;


	return 0;
}


Measured memory_bytes: 1024
#頂点の数をN、変の数をMとするとO(N+M)
#queueは遅いからdequeを使う
from collections import deque
from copy import deepcopy

q = deque()
h,w = map(int,input().split())
c = [['#' for _ in range(w+2)]]
for _ in range(h):
	c.append(list('#'+input()+'#'))
c.append(['#' for _ in range(w+2)])

ans = [[0 for _ in range(w+2)]for _ in range(h+2)]
c_copy = deepcopy(c)
ans_copy = deepcopy(ans)
def bfs(x,y):
	global q
	global c
	q.append([x,y])
	num = 0

	while q:
		x,y = q.popleft()
		if c[y][x-1] == '.':
			q.append([x-1,y])
			ans[y][x-1] = ans[y][x] + 1
			num = ans[y][x-1]
			c[y][x-1] = '#'
		if c[y][x+1] == '.':
			q.append([x+1,y])
			ans[y][x+1] = ans[y][x] + 1
			num = ans[y][x+1]
			c[y][x+1] = '#'
		if c[y-1][x] == '.':
			q.append([x,y-1])
			ans[y-1][x] = ans[y][x] + 1
			num = ans[y-1][x]
			c[y-1][x] = '#'
		if c[y+1][x] == '.':
			q.append([x,y+1])
			ans[y+1][x] = ans[y][x] + 1
			num = ans[y+1][x]
			c[y+1][x] = '#'
	return num

tmp = 0
for i in range(1,h+1):
	for j in range(1,w+1):
		c = deepcopy(c_copy)
		ans = deepcopy(ans_copy)
		if c[i][j] == '.':
			c[i][j] = '#'
			tmp = max(tmp,bfs(j,i))

print(tmp)


Measured memory_bytes: 3436
#include<bits/stdc++.h>
#define lowbit(x) (x&-x)
#define M 200005
using namespace std;
int n,now,ans,A[M],B[M],c[M];
void add(int x,int d) {
	while(x) {
		c[x]=max(c[x],d);
		x-=lowbit(x);
	}
}
int sum(int x) {
	int s=0;
	while(x<=200000) {
		s=max(s,c[x]);
		x+=lowbit(x);
	}
	return s;
}
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)scanf("%d",&A[i]),B[i]=A[i];
	sort(B+1,B+n+1);
	int num=unique(B+1,B+n+1)-B-1;
	for(int i=1; i<=n; i++)A[i]=lower_bound(B+1,B+num+1,A[i])-B;
	for(int i=1; i<=n; i++) {
		int now=sum(A[i])+1;
		add(A[i],now);
		ans=max(ans,now);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  ll W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<int> v(N);
  for(int i=0;i<N;i++)  cin >> w.at(i) >> v.at(i);

  vector<vector<vector<int>>> dp(N+1,vector<vector<int>>(N+1,vector<int>(3*(N+1),0)));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<3*N;k++){
        chmax(dp.at(i+1).at(j).at(k),dp.at(i).at(j).at(k));
        chmax(dp.at(i+1).at(j+1).at(k+w.at(i)-w.at(0)),dp.at(i).at(j).at(k)+v.at(i));
      }
    }
  }
  int ans=0;
  for(int j=0;j<N+1;j++){
    for(int k=0;k<3*(N+1);k++){
      if(j*w.at(0)+k>W) continue;
      chmax(ans,dp.at(N).at(j).at(k));
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 16060
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(string s) {
    auto a = s.map!(e => e - 'A').array;

    int ans = 0;
    int i = 0;
    while (i < a.length) {
        // writeln(ans, " | ", i, " : ", a.map!(text).join(" "));

        if (i + 2 >= a.length) break;

        if (a[i] == 1 || a[i] == 2) {
            i++;
            continue;
        }

        if (i + 3 < a.length) { // 0, 0, 1, 2
            if (a[i+1] == 0 && a[i+2] == 1 && a[i+3] == 2) {
                a[i+1] = 1;
                a[i+2] = 2;
                a[i+3] = 0;
                ans++;

                int j = i;
                while (j >= 0 && a[j] == 0) {
                    ans++;
                    j--;
                }
                i += 2;
                // if (i - 1 >= 0 && a[i - 1] == 0) i--;
                continue;
            }
        }

        if (a[i] == 0 && a[i+1] == 1 && a[i+2] == 2) {
            a[i] = 1;
            a[i+1] = 2;
            a[i+2] = 0;
            i++;
            ans++;
            continue;
        }

        i++;
    }

    return ans;
}

long calc2(string s) {
    auto a = s.map!(e => e - 'A').array;

    long ans = 0;
    int zero = 0;
    int p = 0;
    while (p < a.length) {
        if (a[p] == 0) {
            zero++;
            p++;
        }
        else if (a[p] == 1) {
            if (zero > 0 && p + 1 < a.length && a[p + 1] == 2) {
                ans += zero;
                a[p + 1] = 0;
                zero--;
                p++;
            }
            else {
                zero = 0;
                p++;
            }
        }
        else {
            zero = 0;
            p++;
        }
    }
    return ans;



}

void main() {
    string s = read!string;
    writeln(calc2(s));
}


Measured memory_bytes: 3256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<time.h>
#include<climits>
#include<string>
//#define IONAME "cttf"
//#define E_DEBUG
//#define TIMECOMP

int n,t,w,v,W;
long long dp[111000];

void marota(){
    std::cin>>n>>W;
    for (int i=1;i<=n;i++){
        std::cin>>w>>v;
        for (int i=0;i<=W-w;i++){
            dp[i]=std::max(dp[i],dp[i+w]+v);
        }
    }
    long long ans=0;
    for (int i=0;i<=W;i++){
        ans=std::max(dp[i],ans);
    }
    std::cout<<ans;

}

int main(){
    #ifdef TIMECOMP
    clock_t tStart = clock();
    #endif
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    #if defined(IONAME)
    freopen(IONAME".INP","r",stdin);
    freopen(IONAME".OUT","w",stdout);
    #endif
    marota();
    #ifdef TIMECOMP
    printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    #endif
    return 0;
}

Measured memory_bytes: 4392
#include<stdio.h>

int main(){
  int i;
  char s[4];
  scanf("%s",s);
  for(i=1;i<4;i++){
    if(s[i-1]==s[i]){
      printf("Bad\n");
      return 0;
    }
  }
  printf("Good\n");
  return 0;
}

Measured memory_bytes: 128
import sys
from itertools import accumulate

read = sys.stdin.read

N, K, *p = map(int, read().split())

p = [(1 + i) * i // 2 / i for i in p]
p = [0] + p
P = list(accumulate(p))
answer = 0

for i in range(K, N + 1):
    s = P[i] - P[i - K]
    if s > answer:
        answer = s

print(answer)


Measured memory_bytes: 25420
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <unordered_map>
#include<cstring>
#include<cstdlib>
using namespace std;

const long long mod=1000000007;
const long long inf=mod*mod;

vector<int> edges[110000];
int dp[110000];

int check(int x){
    if(dp[x]!=-1) return dp[x];
    int re=0;
    for(int i=0;i<edges[x].size();i++){
        re=max(re,check(edges[x][i])+1);
    }

    return dp[x]=re;
}


int main(){

int n,m;
cin>>n>>m;
int x,y;
for(int i=0;i<m;i++){
    cin>>x>>y;
    x-=1;y-=1;
    edges[x].push_back(y);
}
for(int i=0;i<n;i++) dp[i]=-1;
int re=0;
for(int i=0;i<n;i++){
    re=max(re,check(i));
}
cout<<re;

return 0;
}


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

int n;
int a[100005];
long long dp[100005][2];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;

	for(int i=1;i<=n;i++) cin>>a[i];
	dp[2][0]=a[1]+a[2];
	dp[2][1]=-(a[1]+a[2]);
	for(int i=3;i<=n;i++){
		dp[i][0]=max(dp[i-1][0],dp[i-1][1])+a[i];
		dp[i][1]=max(dp[i-1][0]-2*a[i-1]-a[i],dp[i-1][1]+2*a[i-1]-a[i]);
	}
	cout<<max(dp[n][0],dp[n][1]);

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<utility>
#include<vector>
#include<string>

using namespace std;

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

    vector<pair<string, int> > playList;
    int sleepTime = 0;
    for (int i = 0; i < N; i++) {
        string name;
        int time;
        cin >> name >> time;
        playList.push_back(make_pair(name, time));
        sleepTime += time;
    }

    string X;
    cin >> X;

    for (int i = 0; i < N; i++) {
        sleepTime -= playList[i].second;
        if (X == playList[i].first) {
            break;
        }
    }

    cout << sleepTime << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define INF 1<<25

using namespace std;

int edg[3], n;

int main()
{
	cin >> n;

	FOR(i, 0, n)
	{
		int flg = 0;

		FOR(j, 0, 3)
		{
			cin >> edg[j];
		}

		FOR(j, 0, 3)
		{
			if( edg[0]*edg[0] == edg[1]*edg[1] + edg[2]*edg[2] )
			{
				cout << "YES" << endl;
				flg = 1;
				break;
			}

			int tmp = edg[0];
			edg[0] = edg[1];
			edg[1] = edg[2];
			edg[2] = tmp;

		}

		if(!flg)
			cout << "NO" << endl;

	}

	return 0;

}

Measured memory_bytes: 0
n = gets.to_i
a = gets.split.map(&:to_i)
plus = []
minus = []
min_abs = 10 ** 9 + 1
a.each do |v|
  if v >= 0
    plus.push(v)
  else
    minus.push(v)
  end
  min_abs = v if v.abs < min_abs.abs
end
m = 0
if minus.size % 2 == 1
  m = (min_abs >= 0) ? (-2 * min_abs) : (2 * min_abs)
end
puts plus.inject(0){|r, v| r += v} - minus.inject(0){|r, v| r += v} + m


Measured memory_bytes: 9616
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    string x;
    cin >> x;
    int s = 0, ans = x.size();
    for (auto c: x) {
        if (c == 'S')
            s++;
        else if (s > 0) {
            s--;
            ans -= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

bool check(int g, vector<int> &arr, int k) {
  int c = 0;
  for (int x : arr) {
    c += (x - 1) / g;
  }

  return (c <= k);
}

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;
  int k;
  cin >> k;

  vector<int> arr(n);
  for (int &x : arr)
    cin >> x;

  int l = 1, r = 2e9;
  int ans = 0;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid, arr, k)) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  cout << ans << endl;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 4784
open System

let readInts () = stdin.ReadLine().Split(' ') |> Array.map int64

let args = readInts() |> Array.map int
let n, x, y = args.[0], args.[1]-1, args.[2]-1

let res = Array.create n 0
for i in 0..n-1 do
    for j in i+1..n-1 do
        let k = min (abs (j-i)) (min (abs (j-x) + abs (i-y) + 1) (abs (j-y) + abs(i-x) + 1))
        res.[k] <- res.[k] + 1
for k in 1..n-1 do
    printfn "%d" res.[k]



Measured memory_bytes: 14044
import math

N = int(input())

towns = []
townx = []
towny = []

for i in range(N):
    x, y = map(int, input().split(' '))
    townx.append(x)
    towny.append(y)

distances = [[math.sqrt((townx[i] - townx[j]) ** 2 + (towny[i] - towny[j]) ** 2) for j in range(N)] for i in range(N)]

fact = math.factorial(N)
res = sum([sum(distance) for distance in distances])

print(res/N)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 123450
#endif

string S;

void solve() {
    cin>>S;
    replace(ALL(S), '?', 'D');
    cout << S << endl;
}



Measured memory_bytes: 3772
a, b = map(int, input().split())
L = []
for i in range(a):
    A = list(map(int, input().split()))
    L.append(A)

for i in range(a):
    X = 0
    for k in range(b):
        X = X +L[i][k]
    L[i].append(X)

l = []
for k in range(b):
    X = 0
    for i in range(a):
        X = X +L[i][k]
    l.append(X)

Sum = sum(l)
for i in range(a):
    Sum = Sum + L[i][b]
l.append(Sum//2)

L.append(l)
for i in range(a+1):
    word = str(L[i][0])
    for k in range(1,b+1):
        if k < b+1:
            word = word +" "+str(L[i][k])
        else:
            word = word + str(L[i][k])
    print(word)



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

using db = double;
const db eps = 1e-9;
int sgn(db a, db b = 0) {
	a -= b;
	return (a > eps) - (a < -eps);
}

struct poi {
	db x, y;
	poi operator -(poi p) {
		return {x - p.x, y - p.y};
	}
	bool operator <(poi p) const {
		return tie(x, y) < tie(p.x, p.y);
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
	db len() {
		return sqrt(x * x + y * y);
	}
};
db xmul(poi a, poi b, poi c) {
	return (b - a).cross(c - a);
}

using vp = vector <poi>;
vp convex(vp v) {
	sort(v.begin(), v.end()); vp r;
	for(int i = 0; i < v.size(); i ++) {
		while(r.size() > 1 &&
			sgn(xmul(*++r.rbegin(), v[i], *r.rbegin())) >= 0)
			r.pop_back();
		r.push_back(v[i]);
	}
	int d = r.size();
	for(int i = (int)v.size() - 2; i >= 0; i --) {
		while(r.size() > d &&
			sgn(xmul(*++r.rbegin(), v[i], *r.rbegin())) >= 0)
			r.pop_back();
		if(i != 0) r.push_back(v[i]);
	}
	return r;
}

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(false);
	int n; cin >> n; vp v;
	for(int i = 0; i < n; i ++) {
		db x, y; cin >> x >> y;
		v.push_back({x, y});
	}
	v = convex(v);

	n = v.size();
	/*
	for(int i = 0; i < n; i ++)
		cout << v[i].x << ' ' << v[i].y << '\n';
		*/
	{
		db ans = 0;
		auto upd = [&](int i, int j) {
			db t = (v[i] - v[j]).len();
			if(t > ans) ans = t;
		};
		int j = 1 % n;
		for(int i = 0; i < n; i ++) {
			while(sgn(xmul(v[i], v[(i + 1) % n], v[j]),
				xmul(v[i], v[(i + 1) % n], v[(j + 1) % n])) < 0)
				j = (j + 1) % n;
			//cout << i << ' ' << j << '\n';
			upd(i, j); /*upd((i + 1) % n, j);*/
			/*upd(i, (j + 1) % n);*/ /*upd((i + 1) % n, (j + 1) % n);*/
		}
		cout << ans << '\n';
	}

	return 0;
}

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

int main() {
  int x, y, z;
  int tmp;
  cin >> x >> y >> z;
  tmp = x;
  x = y;
  y = tmp;
  tmp = x;
  x = z;
  z = tmp;
  cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256