akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	string S;
	cin >> S;
	
	int n = S.size();
	vector<int> answer(n);
	
	int count = 0;
	// S[0]からRのカウント数からLの値の計算
	for (int i = 0; i < n; i++)
	{
		if (S[i] == 'R')
		{
			count++;
		}
		// Lが見つかった場合
		else {
			// 右側は切り捨て
			answer[i] += count / 2;
			// 左側は切り上げ
			answer[i - 1] += (count + 1) / 2;
			count = 0;
		}
	}
	
	
	// S[n - 1]からLのカウント数からRの値の計算
	for (int i = n - 1; i >= 0; i--)
	{
		if (S[i] == 'L')
		{
			count++;
		}
		// Rが見つかった場合
		else {
			// 左側は切り捨て
			answer[i] += count / 2;
			// 右側は切り上げ
			answer[i + 1] += (count + 1) / 2;
			count = 0;
		}
	}
	
	// 出力
	for (int i = 0; i < n; i++)
	{
		cout << answer[i] << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

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

    ll dp[100][2];
    rep(i, 100) {
        dp[i][0] = dp[i][1] = -1; //-1にしておけば更新したか、してないかがわかる(大きいbitを見ている段階ではsmaller == 1 のものは存在しない可能性がある)
    }
    dp[50][0] = 0;

    for(int d = 49; d >= 0; --d) {
        ll mask = 1LL << d;
        int num = 0;
        rep(i, n) if(a[i] & mask) ++num;

        if(dp[d+1][1] >= 0) chmax(dp[d][1], dp[d+1][1] + mask * max(num, n - num));

        if(dp[d+1][0] >= 0) {
            if(k & mask) {
                chmax(dp[d][0], dp[d+1][0] + mask * (n - num));
                chmax(dp[d][1], dp[d+1][0] + mask * num);
            } else {
                chmax(dp[d][0], dp[d+1][0] + mask * num);
            }
        }
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 1024
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const int M=1000000007;
const int MM=998244353;
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=5e5+5;

ll sp[N];

void fill(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      for(int j=i;j<N;j+=i){
        if(sp[j]==j)sp[j]=i;
      }
    }
}

bool prime(ll x){
  if(x==2)return true;

for(ll i=2;i*i<=x;i++){
  if(x%i==0)return false;
}

  return true;
}

ll fac[N];

ll inv[N];

void gg(){
  fac[0]=inv[0]=1;

  for(int i=1;i<N;i++){
    fac[i]=fac[i-1]*i%M;
    inv[i]=powM(fac[i],M-2,M);
  }
}

ll c(ll a,ll b,ll M){
  if(b>a)return 0;

  return (fac[a]*inv[a-b]%M)*(inv[b])%M;
}

pll f(ll x){
  ll b=x%10;
  while(x>=10){
    x/=10;
  }
  return {x%10,b};
}

int main()
{ 

IOS;

ll n,k;

cin>>n>>k;

vl a(n),f(n),p(n);
FOR(i,n)cin>>a[i];

FOR(i,n)cin>>f[i];

sort(all(a));

rev(a);

sort(all(f));

ll mx=0;

FOR(i,n){
  p[i]=a[i]*f[i];
  mx=max(mx,p[i]);
 // d1(p[i]);
}




ll ans=1e18;

ll l=0,r=mx,m;

while(l<=r){
  m=(l+r)/2;

  ll cnt=0;


  for(int i=0;i<n;i++){
    ld temp=(p[i]-m)/(1.0*f[i]);

    ll x=ceil(temp);
    cnt+=max(x,0ll);
if(cnt>k)break;
  }

//  cout<<m<<" "<<cnt<<endl;

if(cnt<=k){
  ans=min(ans,m);
  r=m-1;
}
else l=m+1;

}

cout<<ans;


//end_routine();

return 0;
 
}


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

#define F first
#define S second
#define ll long long
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()

using namespace std;

typedef pair<int,int> pi;
typedef pair<int,pair<int,int>> pii;
typedef vector<int> vi;

int n,cnt,a[100500],b[100500];

vi g[100500];

map<pi,int> col;

void dfs(int v,int p,int c){
	int j = 0;
	for(auto to : g[v]){
		if(to == p) continue;
		j++;
		if(j == c) j++;
		col[mp(v,to)] = j;
		col[mp(to,v)] = j;
		dfs(to,v,j);
	}	
}

main(){
     cin >> n;
     for(int i = 1; i < n; i++){
     	cin >> a[i] >> b[i];	
     	g[a[i]].pb(b[i]);
     	g[b[i]].pb(a[i]);
     }
     for(int i = 1; i <= n; i++){
     	cnt = max(cnt,(int)g[i].size());
     }
     dfs(1,-1,0);
	cout << cnt << endl;
	for(int i = 1; i < n; i++){
		cout << col[mp(a[i],b[i])] << endl;
	}
	return 0;
}

Measured memory_bytes: 20480
#include <stdio.h>
int main(void){
int a,b,c,d;
  scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
  if(a*b>c*d){printf("%d",a*b);}
  else{printf("%d",c*d);}
  
return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<typeinfo>
#include<typeindex>
#include<type_traits>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);
  
  cin>>n>>m; Int v[3][n],a[3][n],su[n],ans=-1e18,co; rep(i,n)rep(j,3)cin>>v[j][i];
  for(int i=0; i<(1<<3); i++){
    rep(j,3){
      if((i>>j)&1)rep(k,n)a[j][k]=-v[j][k];
      else rep(k,n)a[j][k]=v[j][k];
    }
    rep(j,n)su[j]=a[0][j]+a[1][j]+a[2][j];
    sort(su,su+n); co=0;
    rep(j,m)co+=su[n-j-1];
    cmax(ans,co);
  }
  END
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>=13){
    cout<<b<<endl;
  }
  if(a<=12&&a>=6){
    cout<<b/2<<endl;
  }
  if(a<=5){
    cout<<"0"<<endl;
  }
}

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

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

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

    if (a > 12)
    {
        cout << b << endl;
    }
    else if (a > 5)
    {
        cout << b / 2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
/**************
*	Shell Sort
*************/

#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>	//??£?¨?
using namespace std;

void insertionSort(vector<int>* A, int g, int* cnt  ){

	for(unsigned int i=g ; i<(A->size()); i++){
		int v = (*A)[i];
		int j = i-g;
		while(j>=0 && (*A)[j]>v){
			(*A)[j+g] = (*A)[j];
			j = j-g;
			(*cnt)++;
		}
		(*A)[j+g] =v;
	}
	return ;
}
//---------------------------------------------------------
void shellSort(vector<int>* A, vector<int>* G, int* cnt){
//	*cnt =0;
//	int m = A->size();
//	vector<int> G(1,m);
	for(unsigned int i=0; i<(G->size()); i++){
		insertionSort(A, (*G)[i], cnt);
	}

	return;
}
//--<<???????????¢??°>>-------------------------------------------------------
int main(){

	//??\???
	int n;
	cin >> n;
	vector<int> A;
	A.resize(n);
	for(unsigned int i=0; i< A.size(); i++){
		cin >> A[i];
	}

	//??????
	vector<int> G;
	int sum = 1;
	while(sum <= n){
	    G.push_back(sum);
		sum = sum * 3 + 1;
	}
	reverse(G.begin(), G.end());

	int cnt = 0;
	shellSort(&A, &G, &cnt);

	//??????
	cout << G.size() << endl;
	for(unsigned int i=0; i<(G.size()); i++){
		cout << G[i];
		if(i!=(G.size()-1)){
			 cout <<" " ;
		}
	}
	cout << endl;
	cout << cnt << endl;
	for(int i=0; i< n; i++){
		cout << A[i]<< endl;
	}

	return 0;
}
//-----------------------------------------------

Measured memory_bytes: 6752
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define fst	first
#define scn second
#define bucnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl;

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	int n;	cin >> n;
	vint a(n);
	rep(i, n)	cin >> a[i];
	sort(all(a));
	if (a[n - 1] - a[0] > 1)	cout << "No" << endl;
	else if (a[0] == a[n - 1]) {
		if (a[0] == n - 1)	cout << "Yes" << endl;
		else if (a[0] * 2 <= n)	cout << "Yes" << endl;
		else	cout << "No" << endl;
	}
	else {
		int cnt = lower_bound(all(a), a[n - 1]) - a.begin();
		if (cnt > a[0])	cout << "No" << endl;
		else {
			int l = a[0] * 2 + 2 - cnt;
			if (l <= n)	cout << "Yes" << endl;
			else	cout << "No" << endl;
		}
	}
	return 0;
}
/*
2 3 3 3 3
2 2 3 3

3 4 4 4 4 4 4
3 3 4 4 4 4
3 3 3 4 4
*/

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    
    int a, b;
    cin >> a >> b;

    for (int i = 1; i <= 3; i++) {
        if (i == a || i == b)continue;
        cout << i << endl;
        return 0;
    }



    return 0;

}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#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
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N;
    cin>>N;
    vector<int> A(N),B(N);
    rep(i,N){
        cin>>A.at(i);
        B.at(i)=A.at(i);
    }
    sort(B.rbegin(),B.rend());
    rep(i,N){
        if(A.at(i)==B.at(0)){
            cout<<B.at(1)<<endl;
        }
        else{cout<<B.at(0)<<endl;}
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int D = 0;
    int B = 0;
    char prev = 'R';
    for(int i = 0; i < N; i++) {
        if(prev == 'R' && S[i] == 'L') {
            if(i == 0) B++;
            else D++;
        }
        prev = S[i];
    }
    if(prev == 'R') B++;
    i64 ans = N - (2 * D + B);
    int i = 0;
    while(D > 1 && i < K) {
        ans += 2;
        i++;
        D--;
    }
    if(i < K && D <= 1) {
        if(D > 0 && B > 0) {
            ans += 2;
            i++;
            D--;
        }
        if(i < K && (B > 1 || (B >= 0 && D == 1) ) ) {
            ans += 1;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	// your code goes here
	
	int N;
	cin >> N;
	int a[N];
	for(int i=0;i < N;i++){
		cin >> a[i];
	}
	int M,m;
	M = a[0];
	m = a[0];
	for(int i=0;i<N;i++){
		if(a[i] > M){
			M = a[i];
		}
		if(a[i] < m){
			m = a[i];
		}
	}
	
	cout << M-m << endl;
	
	
	return 0;
}

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

struct team{
	int t, c, m;
	int p[10];
};

bool operator<(const team team1, const team team2){
	bool rep;
	if(team1.c == team2.c){
		rep = (team1.m == team2.m) ? team1.t > team2.t : team1.m < team2.m;
	}else{
		rep = (team1.c > team2.c);
	}
	return rep;
}

int main(){
	int M, T, P, R;
	while( cin >> M >> T >> P >> R, M || T || P || R ){
		vector<team> teams(T);
		for(int i = 0; i < T; i++){
			teams[i].t = i+1;
			teams[i].c = 0;
			teams[i].m = 0;
		}
		for(int i = 0; i < R; i++){
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			if( j == 0 ){
				teams[t-1].c++;
				teams[t-1].m += (m + 20 * teams[t-1].p[p-1]);
			}else{
				teams[t-1].p[p-1]++;
			}
		}
		sort(teams.begin(), teams.end());
		cout << teams[0].t;
		for(int i = 1; i < T; i++){
			if( teams[i].c == teams[i-1].c && teams[i].m == teams[i-1].m ) cout << "=";
			else cout << ",";
			cout << teams[i].t;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1224
#include <iostream>
#include <stdio.h>
using namespace std;


int main()
{
	int nW, nH;
	while (cin >> nH >> nW)
	{
		int nSum = 0;
		if (0 == nH && 0 == nW)
		{
			break;
		}
		for (int i = 0; i < nH; i++)
		{
			for (int j = 0; j < nW; j++)
			{
				nSum = i + j;
				if (nSum & 1)
				{
					cout << ".";
				}
				else
				{
					cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
#define M 2010
#define LL long long
#define MOD 1000000007
#define rep(i, x, y) for(int i = (x); i <= (y); ++ i)
inline int read() {
	char ch = getchar(); int x = 0, f = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}
struct Edge{
	int u, v, w;
	inline bool operator < (const Edge& rhs) const {
		return w < rhs.w;
	}
} G[M];
int fa[M];
inline int Find(int x) {
	return fa[x] == x ? x : fa[x] = Find(fa[x]);
}
int main() {
	//freopen("in.txt", "r", stdin);
	int n = read(), m = read();
	LL X; scanf("%lld", &X);
	rep(i, 1, m) G[i].u = read(), G[i].v = read(), G[i].w = read();
	sort(G + 1, G + m + 1);
	int num = 0, Big = 1;
	rep(i, 2, m) {
		LL Ans = G[i].w;
		rep(j, 1, n) fa[j] = j;
		fa[G[i].u] = G[i].v;
		rep(j, 1, m) {
			if(Find(G[j].u) == Find(G[j].v)) continue;
			fa[Find(G[j].u)] = Find(G[j].v);
			Ans += G[j].w;
		}
		if(Ans == X) num ++;
		if(Ans > X) Big ++;
	}
	LL ans = 1;
	rep(i, 1, num) ans <<= 1, ans %= MOD;
	ans += MOD - 1;
	ans %= MOD;
	rep(i, 1, Big) ans <<= 1, ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>

using namespace std;

int main(){
	int n;
	int i;
	while(true){
		double s=0.0;
		cin >> n;
		if(n==0) break;
		bool flag=false;
		//約数列挙
		for(i=1;i<sqrt(n);i++){
	//		cout << i;
			if(n%i==0){
				s+=i;
				s+=(n/i);
				if(s<0){
					flag = true;
					break;
				}
//				cout << i << endl;
//				cout << (n/i) << endl;
			}
		}
		s-=n;
		if((double)n<s || flag) cout << "abundant number" << endl;
		else if((double)n>s) cout << "deficient number" << endl;
		else if((double)n==s) cout << "perfect number" << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(void)
{
    int N;
    string S;
    cin >> N >> S;

    set<char> x;

    int ans = 0;;
    for(int i = 0; i < N - 1; ++i)
    {
        x.insert(S[i]);
        int count = 0;
        for(const auto& e : x)
        {
            if(string::npos != S.find(e, i + 1)) count++;
        }
        if(ans < count) ans = count;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    int i, j, k;
    int n;
    cin >> n;
    vector<int> vec(n);
    for (i = 0; i < n; i++)
        cin >> vec[i];
    sort(vec.begin(), vec.end());
    int frt = n / 2 - 1;
    int fre = n / 2;
    cout << vec[fre] - vec[frt] << endl;
}


Measured memory_bytes: 640
{$asmmode intel}
var a,b,c:longint;
    _11,_12,_13,_21,_22,_23,_31,_32,_33:longint;
begin
  readln(a,b,c);
  asm
    mov eax,a;
    mov _11,eax;
    mov eax,b;
    mov _12,eax;
    mov eax,c;
    mov ebx,c;
    add eax,ebx;
    add eax,ebx;
    mov ebx,a;
    sub eax,ebx;
    mov ebx,b;
    sub eax,ebx;
    mov _13,eax;
    mov eax,c;
    add eax,eax;
    add eax,eax;
    sub eax,ebx;
    mov ebx,a;
    add ebx,ebx;
    sub eax,ebx;
    mov _21,eax;
    mov eax,c;
    mov _22,eax;
    mov eax,a;
    mov ebx,c;
    sub eax,ebx;
    add eax,eax;
    mov ebx,b;
    add eax,ebx;
    mov _23,eax;
    mov eax,a;
    mov ebx,b;
    add eax,ebx;
    mov ebx,c;
    sub eax,ebx;
    mov _31,eax;
    mov eax,c;
    add eax,eax;
    mov ebx,b;
    sub eax,ebx;
    mov _32,eax;
    add eax,ebx;
    mov ebx,a;
    sub eax,ebx;
    mov _33,eax;
  end;
  writeln(_11,' ',_12,' ',_13);
  writeln(_21,' ',_22,' ',_23);
  writeln(_31,' ',_32,' ',_33);
end.

Measured memory_bytes: 128
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 110
#define MaxM 
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;

LL N,W;
LL w[MaxN], v[MaxN];
LL DP[MaxN][4*MaxN][MaxN];
void solve()
{
    LL W1 = w[1]-1;
    for(int i=1;i<=N;i++) w[i] = w[i] - W1;
    for(int i=1;i<=N;i++)
    {
        for(int j=0;j<=400;j++)
        {
            for(int k=1;k<=N;k++)
            {
                if( j >= w[i] ) 
                    DP[i][j][k] = max( DP[i-1][j][k], DP[i-1][j-w[i]][k-1]+v[i]);
                else 
                    DP[i][j][k] = DP[i-1][j][k];
            }
        }
    }
    LL ans = 0;
    for(int j=0;j<=400;j++)
    {
        for(int k=0;k<=N;k++)
        {
            if( k*W1+j<=W)
            {
                ans = max(ans, DP[N][j][k]);
            }
        }
    }
    printf("%lld\n", ans);
}

int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%lld%lld", &N, &W);
    for(int i=1;i<=N;i++) scanf("%lld%lld", &w[i], &v[i]);
    solve();
    //system("pause");
}


Measured memory_bytes: 38656
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define rrep(i,n) for(int i=n ; i>=0 ; i--)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

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

int main(){
    int n; cin >> n;
    int ans;
    rep(i,n){
        int x; cin >> x;
        if(check(x)) ans++;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3100
n,q=map(int,input().split())
s=list(input())
value=[0]*n
ans_list=[]
length=[]
     
for i in range(len(s)-1):
  value[i+1]=value[i]+(1 if s[i]=='A' and s[i+1]=='C' else 0)
  
for i in range(q):
  l,r=map(int,input().split())
  print(value[r-1]-value[l-1])

Measured memory_bytes: 8436
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        long H = sc.nextLong();
        int N = sc.nextInt();
        int[] a = new int[N];
        long sum=0;
        for(int i=0;i<N;i++) {
        	a[i]=sc.nextInt();
        	sum=sum+a[i];
        }
        if(H<=sum) {
    	    System.out.println("Yes");
        } else {
    	    System.out.println("No");
        }
        
		
    }
}

Measured memory_bytes: 50632
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int i;
    int k, n;

    scanf("%d%d", &k, &n);

    int a[n+1];
    for ( i=0; i<n; i++ )
        scanf("%d", &a[i]);
    a[n] = k + a[0];

    int dist, max_dist = 0;
    for ( i=0; i<n; i++ ) {
        dist = a[i+1] - a[i];
        if ( max_dist < dist )
            max_dist = dist;
    }

    printf("%d\n", k - max_dist);

    return EXIT_SUCCESS;
}


Measured memory_bytes: 896
#include<iostream>
int main(){
	int a,b,c,d;
	while(1){
		std::cin>>a>>b;
		if(std::cin.eof())break;
		c=a+b;
		     if(c>=1000000)d=7;
		else if(c>=100000)d=6;
		else if(c>=10000)d=5;
		else if(c>=1000)d=4;
		else if(c>=100)d=3;
		else if(c>=10)d=2;
		else if(c>=0)d=1;
		std::cout<<d<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N=gets.to_i
x,y,h=N.times.map{gets.split.map &:to_i}.transpose

(0..100).each do |cx|
  (0..100).each do |cy|

    ch=[]
    N.times do |i|
      next if h[i] == 0
      ch << h[i] + (x[i]-cx).abs + (y[i]-cy).abs
    end
    next unless ch.uniq.size == 1
    ch = ch[0]

    ok = true
    N.times do |i|
      next unless h[i] == 0
      ok = false unless h[i] == [ch - (x[i]-cx).abs - (y[i]-cy).abs, 0].max
    end
    next unless ok

    puts [cx, cy, ch]*" "
    exit
  end
end


Measured memory_bytes: 4092
#include<bits/stdc++.h>
#define maxn 200100
using namespace std;
map<int,int> m;
int seg[maxn], t[maxn], n, Q;
int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; i ++){
		scanf("%d",&seg[i]);
		m[seg[i]] ++;
	}
	scanf("%d",&Q);
	bool flag = true;
	for(int i = 1; i <= Q; i ++){
		scanf("%d",&t[i]);
		if(m[t[i]] > 0){
			m[t[i]] --;
		}
		else{
			flag = false;
			break;
		}
	}
	printf("%s",flag ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int dfs(vector<vector<int>>&a,vector<bool>&vis,int pos){
    int sum=1;
    vis[pos]=true;
    for(int i:a[pos]){
        if(!vis[i]){
            int temp=dfs(a,vis,i);
            sum+=temp;
        }
    }
    return sum;
}
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<int>>a(n+1);
    vector<bool>vis(n+1,false);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    vector<int>Count;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            int sum=dfs(a,vis,i);
            Count.push_back(sum);
        }
    }
    sort(Count.begin(),Count.end(),greater<int>());
    int sum=0;
    Count[0]-=Count[1];
    sum=Count[1]+Count[0];
    cout<<sum;
}

Measured memory_bytes: 26652
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int A, B;
    cin >> A >> B;
    cout << (B + A - 3) / (A - 1) << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int n;
  scanf("%d", &n);

  vector<int> v(n);
  REP (i, n) {
    scanf("%d", &v[i]);
  }

  bool decided = false;
  bool up;
  int ans = 1;
  REP (i, n - 1) {
    if (v[i] == v[i + 1]) continue;
    else if (!decided) {
      decided = true;
      if (v[i] < v[i + 1]) up = true;
      else if (v[i] > v[i + 1]) up = false;
    } else if (up && v[i] > v[i + 1]) {
      decided = false;
      ans++;
    } else if (!up && v[i] < v[i + 1]) {
      decided = false;
      ans++;
    }
  }
  printf("%d\n", ans);
}


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

ll a[maxn];
ll b[maxn];


int main(){
	ll n;
	cin>>n;
	for(int i=2;i<=n;i++){
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		cout<<b[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;
 
int main(){
    int M;
    cin >> M;
    cout << 48 - M << "\n";

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))
from math import sqrt
from bisect import bisect


def primes2(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
      if sieve[i]:
        k=3*i+1|1
        sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
        sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

X, Y = inpl()

P = primes2(2*int(sqrt(10**9)))

if X%Y == 0:
    print(-1)
else:
    for p in P:
        if Y%p != 0:
            print(X*p)
            break

Measured memory_bytes: 3824
import collections
S = input()
T = input()
s_alp = [chr(i) for i in range(97, 97+26)]
s_ = ['']*26
t_alp = [chr(i) for i in range(97, 97+26)]
t_ = ['']*26
for i in range(len(S)):
  if s_[s_alp.index(S[i])] == '':
    s_[s_alp.index(S[i])] = T[i]
  else:
    if s_[s_alp.index(S[i])] != T[i]:
      print('No')
      break
  if t_[t_alp.index(T[i])] == '':
    t_[t_alp.index(T[i])] = S[i]
  else:
    if t_[t_alp.index(T[i])] != S[i]:
      print('No')
      break
else:
  print('Yes')

Measured memory_bytes: 4144
use proconio::input;

fn main() {
    input! {
        ss: String, tt: String,
    }
    let s = ss.chars().collect::<Vec<char>>();
    let t = tt.chars().collect::<Vec<char>>();

    let mut ans = t.len();
    for i in 0..(s.len()-t.len()+1) {
        let mut dist = 0;
        for (j, &c_t) in (&t).iter().enumerate() {
            if s[i+j] != c_t { dist+=1 }
        }
        if dist < ans { ans = dist }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int N;
    cin >> N;
    ll ans = 2;
    while (ans <= N)
    {
        ans = ans * 2;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){ if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chMin(T& a, T b){ if (a > b) { a = b; return true; } return false; }

int main(){
	ll N, D, X;
	vector<ll> A;
	cin >> N >> D >> X;

	rep(i, 0, N){
		ll temp;
		cin >> temp;
		A.push_back(temp);
	}
	ll sum = X;
	rep(i, 0, N){
		sum += ((D / A[i]) + 1);
		if (D % A[i] == 0) sum--;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
import re

S=input()

if re.fullmatch('([a-z]*)keyence',S):
  print('YES')
elif re.fullmatch('k([a-z]*)eyence',S):
  print('YES')
elif re.fullmatch('ke([a-z]*)yence',S):
  print('YES')
elif re.fullmatch('key([a-z]*)ence',S):
  print('YES')
elif re.fullmatch('keye([a-z]*)nce',S):
  print('YES')
elif re.fullmatch('keyen([a-z]*)ce',S):
  print('YES')
elif re.fullmatch('keyenc([a-z]*)e',S):
  print('YES')
elif re.fullmatch('keyence([a-z]*)',S):
  print('YES')
else:
  print('NO')

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

bool compareTrio(int a, int b, int c)
{
  if ((a < b) && (b < c) || (c < b) && (b < a)) return true;
  else return false;
}

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

  vector<int> P(N);

  int numOrdinary = 0;
  
  for(int i = 0; i < P.size(); i++)
  {
    cin >> P.at(i);
  }
  
  for(int i = 1; i < P.size() - 1; i++)
  {
    if (compareTrio(P.at(i - 1), P.at(i), P.at(i + 1))) numOrdinary++;
  }
   
  cout << numOrdinary << endl;
}


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

using namespace std;

#define ll long long
#define  ON_THE_WAY_TO_SPECIALIST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

int main()
{
	double t, x;
	
	scanf("%lf %lf", &t, &x);
	
	printf("%.10lf\n", t/x);
	
	return 0;
}


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

int main() {
  char ch;
  int alpha_size = 'z' - 'a' + 1;
  vector<int> counter(alpha_size, 0);
  while (1) {
    cin >> ch;

    // NOTE: EOF は control + d で送信
    if (cin.eof()) { break; } // 終端の場合、終了する
    if (!isalpha(ch)) { continue; } // アルファベット以外は集計しない
    if (isupper(ch)) { ch = tolower(ch); } // 大文字は小文字に変換

    int alpha_num = ch - 'a';
    counter.at(alpha_num)++;
  }

  for (int i = 0; i < alpha_size; i++) {
    char c = 'a' + i;
    cout << c << " : " << counter.at(i) << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
N = int(input())
input_list = [int(input()) for i in range(N)]

def is_prime(x):
    if x == 2:
        return True
    
    if x == 1 or x % 2 == 0:
        return False
    
    i = 3
    while i <= x ** 0.5:
        if x % i == 0:
            return False
        i += 2

    return True

if __name__ == '__main__':
    count = 0
    for num in input_list:
        #print(is_prime(num))
        if is_prime(num):
            count += 1
    print(count)


Measured memory_bytes: 5992
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = Long.parseLong(sc.next());
        long k = Long.parseLong(sc.next());
        long d = Long.parseLong(sc.next());
        if (x > 0 && (x * 1.0 / k >= d)) {
            System.out.println(x - k * d);
            return;
        } else if (x < 0 && (x * (-1.0)) / k >= d) {
            System.out.println(Math.abs(x + k * d));
            return;
        }
        if (x > 0) {
            long num = (long)Math.ceil(x * 1.0 / d);
            long xx = x - ((num - 1) * d);
            if ((k - (num - 1)) % 2 == 0) {
                System.out.println(xx);
            } else {
                System.out.println(Math.abs(xx - d));
            }
        } else if (x < 0) {
            long num = (long)Math.ceil(x * (-1.0) / d);
            long xx = x + ((num - 1) * d);
            if ((k - (num - 1)) % 2 == 0) {
                System.out.println(Math.abs(xx));
            } else {
                System.out.println(Math.abs(xx + d));
            }
        } else {
            if (k % 2 == 0) {
                System.out.println(0);
            } else {
                System.out.println(d);
            }
        }
    }
}

Measured memory_bytes: 35408
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x)
{
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
const int MAXN = 55;
int n,m,sum,val[MAXN];
ll dp[MAXN][2505],ans;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m);dp[0][0]=1;
	for(ri i=1;i<=n;i++) read(val[i]),sum+=val[i];
	for(ri i=1;i<=n;i++)
		for(ri j=sum;j>=val[i];j--)
			for(ri k=1;k<=n;k++)
				dp[k][j]+=dp[k-1][j-val[i]];
	for(ri i=1;i<=n;i++){
		if(i*m>sum) break;
		ans+=dp[i][i*m];
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

#define watch(x) cout << (#x) << " is " << (x) << endl
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)

typedef unsigned long long int ll;
typedef long double ld;
typedef long int li;

const int inf=1e9+5;

int main()
{
    fio;
    int n;cin>>n;
    int k;cin>>k;
    vector<int> h(n);
    for(int i=0;i<n;i++)cin>>h[i];
    vector<int> dp(n,inf);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    double a, b, h, m, c;
    cin >> a >> b >> h >> m;
    h = h * 30 + m / 2;
    m = m * 6;
    c = min(abs(h - m), 360 - abs(h - m));
    c /= 180 / 3.14159265358979;
    cout << setprecision(13) << sqrt(a * a + b * b - 2 * a * b * cos(c));
}


Measured memory_bytes: 4276
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <cmath>
#define endl "\n"
using namespace std;

void solve()
{
    int a=5,b=1,c;
    while(a--)
    {
        cin >> c; if(!c) cout <<b;++b;
    }
}
const int mxn=1e3;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3516
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,k = na()
a = na()
s = n*n


for p in range(k):
    b = [0]*n
    for i in range(n):
        k = i+a[i]+1
        w = i-a[i]
        if k < n:
            b[k] -= 1
        if 0 <= w:
            b[w] += 1
        else:
            b[0] += 1

    for j in range(1,n):
        b[j] = b[j]+b[j-1]
    a = b
    if sum(a) == s:
        break

print(*a)

Measured memory_bytes: 151520
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

const ll MAX = 510000;
// const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll solve()
{
    ll n;
    cin >> n;
    cout << n * (n + 1) / 2 << endl;

    return 0;
}

int main()
{
    //cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
l = [int(i) for i in input().split()]
l2 = [0 for _ in range(n+1)]
l2[0] = l[0]

for i in range(n-1):
    l2[i+1] += l2[i] + l[i+1] 
    
c = Counter(l2)

ans = 0
for _,v in c.items():
    if v > 1:
        ans += v * (v-1)//2
print(ans)




Measured memory_bytes: 40776
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T> bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T> bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ab = a + b;
    int cd = c + d;
    if (ab > cd)
        cout << "Left" << endl;
    else if (ab < cd)
        cout << "Right" << endl;
    else
        cout << "Balanced" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define repr(i,n) for(int i=0, i##_len=(n); i<i##_len; --i)
#define REP(i,m,n) for(int i=int(m), i##_len=(n); i<i##_len; ++i)
#define VV(T) vector<vector<T>>
#define pb push_back
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;;
typedef long long ll;
typedef double D;

int main(){
  int N;
  cin >> N;
  if(N/100==N-N/10*10) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

int N;
vector<pii> G[100010];
signed int color[100010];

signed main()
{
  iostreamBooster();

  cin >> N;
  rep(i, 0, N-1) {
    int s, t, c;
    cin >> s >> t >> c;
    G[s].emplace_back(t, c & 1);
    G[t].emplace_back(s, c & 1);
  }

  // F:node, S:color
  queue<pii> que;
  auto paintNode = [&](int u, int ink) {
    que.emplace(u, ink);
    color[u] = ink;
  };

  memset(color, -1, sizeof(color));
  paintNode(1, 0);

  while(!que.empty()) {
    const auto nowNode = que.front().first;
    const auto nowColor = que.front().second;
    que.pop();

    for (const auto &e : G[nowNode]) {
      const int nxt = e.first;
      const bool odd = e.second;
      if (color[nxt] == -1) {
        paintNode(e.first, (odd) ? (1 - nowColor) : (nowColor));
      }
    }
  }


  rep(i, 1, N+1) {
    cout << color[i] << '\n';
  }

  return 0;
}



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

int main() {
  int x_1,y_1,x_2,y_2,x_3,y_3,x_4,y_4;
  cin >> x_1 >> y_1 >> x_2 >> y_2;
  
  x_3=x_2+y_1-y_2;
  y_3=y_2-x_1+x_2;
  x_4=x_1+y_1-y_2;
  y_4=y_1-x_1+x_2;
  cout << x_3 << " " << y_3 << " " << x_4 << " " << y_4 << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    class Program
    {
        static void Main(string[] args)
        {
            string ans;
            string[] HorD =Console.ReadLine().Split();
            if (HorD[0] == "H")
            {
                if (HorD[1] == "H") { ans = "H"; }
                else { ans = "D"; }
            }
            else
            {
                if (HorD[1] == "H") { ans = "D"; }
                else { ans = "H"; }
            }
            Console.WriteLine(ans);
        }
    }



Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>

using namespace std;

int main() {

  int a, b, c;
  cin >> a >> b >> c;
  double ans, ra, rb;
  string dolphinManJotaro;
  if(c <= b){
    cout << "delicious";//Joseph : Next you're going to say "NIIICEE..." Also Joseph : "NIIICEE..."
  }else if(c - b <= a){
    cout << "safe";//OKAY MASTER! LET'S KILL DA HO !BEETCH!
  }else{
    cout << "dangerous";//S H I T     ACTO FREE FTH!WRRRYYY!ZEE
  }
  return 0;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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



int main(void)
{
  ll x, t;
  cin >> x >> t;
  cout << ((x>t)?x-t:0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define li long long int
#define ld long double
#define F first
#define S second
const li M = 1000000007;
#define ld long double
li dx[]={-1,1,0,0};
li dy[]={0,0,-1,1};

int main()
{
	li N,K,k,i,j; 
	li t; 
	cin>>t;
	N = t + t*t + t*t*t;
	cout<<N;
	
			
}



Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f


int main()
{
    ll n,m;
    scanf("%lld%lld",&n,&m);
    printf("%lld\n",n*(n-1)/2+m*(m-1)/2);
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

#define N 200001

double dp[N];
double tmp[N];

double func(double a) {
    if (a<0) return -a;
    return a;
}
int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i=0; i<n; ++i) {
        cin >> a[i];
    }
    for (int j=0;j<N; ++j) {
        dp[j] = 1<<29;
    }
    vector<int> v[N];
    for(int i=1; i<N; ++i) {
        for (int j=i; j<N; j+=i) {
            v[j].push_back(i);
        }
    }
     
    
    dp[1] = 0;
    for (int i=1; i<=n; ++i) {
        for (int j=0; j<N; ++j)
            tmp[j] = 1<<29;
        for (int j=0;j<N; ++j) {
            for (int k=0; k<v[j].size(); ++k) {
                tmp[j] = min(tmp[j], max(dp[v[j][k]], func(a[i-1]-j)/a[i-1]));
            }
            // if (j<=12) {
            //     cout << dp[i][j];
            //     printf("(%d) ", j);
            // }
        }
        for (int j=0; j<N; ++j)
            dp[j] = tmp[j];

//        cout << endl;
    }
    double ans = 1<<29;
    for (int i=0; i<N; ++i) {
        if (ans > dp[i]) {
//            printf("%d %f\n", i, dp[n][i]);
            ans = dp[i];
        }
        //ans = min(ans, dp[n][i]);
    }
    printf("%.12f\n", ans);

    // printf("ans = %.12f\n", 5.0/99999);
    // printf("ans = %.12f\n", 1.0/50002);
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		@SuppressWarnings("unchecked") ArrayList<Integer>[] jobs = new ArrayList[m + 1]; // 遅延日数ごとに仕事をグルーピングする
		for ( int i = 0; i <= m; i++ ) {
			ArrayList<Integer> a = new ArrayList<>();
			a.add(0); // ダミー要素
			jobs[i] = a;
		}

		for ( int i = 0; i < n; i++ ) {
			int d = in.nextInt();
			int f = in.nextInt();
			if ( d > m ) continue; // 遅延日数的に候補になりえない仕事は除外
			jobs[d].add(f);
		}

		long total = 0;
		PriorityQueue<Integer> pool = new PriorityQueue<Integer>(Collections.reverseOrder()); // job候補のプール
		pool.add(0); // ダミー

		// m日目をゼロとして考え後退していく days:残り日数
		for ( int today = 0; today <= m; today++ ) {

			pool.addAll(jobs[today]);
			int daypay = (int) pool.poll();

			// System.out.println("days:" + today + " earn +=" + daypay);
			// System.out.println("pool" + pool);
			total += daypay;
		}

		System.out.println(total);
		in.close();
	}
}


Measured memory_bytes: 100544