akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  string s;
  cin >> s;
  i64 ans = 0;
  for (i64 i = 0; i < s.size() / 2; i++)
    if (s[i] != s[s.size() - i - 1])
      ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;

int n, s, ans, a[200];
int main(){
	scanf("%d", &n);
	REP(i,n) scanf("%d", &a[i]);
	REP(i,n) s += a[i];
	s = round(double(s)/n);
	REP(i,n) ans += (a[i]-s)*(a[i]-s);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	ll ans = 0;
	for(int i = 0; i < n; ++i) { 
		ans += (ll)(a[i] / 2);
		a[i] %= 2;
		
		if( i < n - 1 && a[i + 1] && a[i] ) { 
			ans++;
			a[i]--;
			a[i + 1]--;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
def coll(n):
  cnt = 0
  while n > 1:
    if n % 2:
      n = n * 3 + 1
      cnt += 1
    while n % 2 == 0:
      n = n // 2
      cnt += 1
  return cnt

while True:
  n = int(input())
  if n == 0:
    break
  print(coll(n))


Measured memory_bytes: 5588
#include <iostream>

using namespace std;

int is_even(int a) { return a%2 == 0; }


int main()
{
	string s;
	cin >> s;
	int cnt = 0;
	int fir = s[0];
	for ( int i = 1 ; s[i] ; i++ )
	{
		if ( is_even(i) && s[i]!=fir ) cnt++;
		if ( !is_even(i) && s[i]==fir ) cnt++;
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 512
n,m = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = [int(x)-1 for x in input().split()]
    g[a].append(b)
    g[b].append(a)
ans = 0
for i in range(n):
    flag = 1
    for j in g[i]:
        if h[i]<=h[j]:
            flag = 0
    if flag:
        ans+=1
print(ans)

Measured memory_bytes: 92536
using System;
using System.Linq;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var sp = Console.ReadLine().Split(' ');
            int n = int.Parse(sp[0]);
            int k = int.Parse(sp[1]);
            var d = new int[k];
            var a = new int[k][];
            for (int c = 0; c<k; c++)
            {
                d[c] = int.Parse(Console.ReadLine());
                a[c] = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            }

            var sn = new int[n];
            for (int c = 0; c<k; c++)
            {
                foreach(var cc in a[c])
                {
                    sn[cc - 1]++;
                }
            }

            Console.WriteLine(sn.Count(c=>c==0));

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28768
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int A,B,K; cin >> A >> B >> K;
	set<int> ans;
	repr(i,A,min(B+1,A+K)){
		ans.insert(i);
	}
	for(int i = B; i >= max(B-K+1,A); i--){
		ans.insert(i);
	}
	for(int i : ans) cout << i << endl;
}



Measured memory_bytes: 256
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))

s=input()
p_a=int(s[:2])
p_b=int(s[2:])
yymm=(0<p_b<13)
mmyy=(0<p_a<13)


if yymm and mmyy:
    print("AMBIGUOUS")
    exit()

if yymm:
    print("YYMM")
    exit()
if mmyy:
    print("MMYY")
    exit()

print("NA")

Measured memory_bytes: 3316
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    if (x < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define Rajpoot ios_base::sync_with_stdio(0);   cin.tie(0);  cout.tie(0);
#define ll long long
#define loo(i,n) for(i=0;i<n;i++)
#define go(i,sp)  for(auto i=sp.begin();i!=sp.end();i++)
#define pb push_back
#define lb lower_bound
#define mo 1000000007
#define pi 3.14159265358979323846264338327950288419716939937510582
#define exp 2.71828182845904523536028747135266249775724709369995957
#define endl "\n"
using namespace std;



int main() 
{
   Rajpoot
      //    freopen("input.txt","r",stdin);
      // freopen("output.txt","w",stdout);

   // int t; cin>>t; 
    int t=1;
    while(t--)
    { 
        ll n; cin>>n;  ll d; cin>>d;
        ll c=0;
        ll i; ll x,y;
        loo(i,n)
        {
            cin>>x>>y;
            double r=sqrt((x*x)+(y*y));
            //cout<<r<<" ";
           if(r<=d)
            c++;
        }
        cout<<c;
    }    

	return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int N,K;
const int INF=1e9;
vector<vector<int> > G(2020);
vector<pair<int,int> > E;
int d[2020];

int bfs(int v,int u){
  int res=0;
  rep(i,N) d[i]=INF;
  queue<int> que;
  if(v!=-1){
    d[v]=0;
    que.push(v);
  }
  if(u!=-1){
    d[u]=0;
    que.push(u);
  }
  while(que.size()){
    int x=que.front(); que.pop();
    if(d[x]*2>K) res++;
    rep(i,G[x].size()){
      int y=G[x][i];
      if(d[y]==INF){
        d[y]=d[x]+1;
        que.push(y);
      }
    }
  }
  return res;
}

int main(){
  cin>>N>>K;
  rep(i,N-1){
    int a,b; cin>>a>>b; a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
    E.push_back(make_pair(a,b));
  }
  int ans=INF;
  if(K%2==0){
    rep(v,N){
      ans=min(ans,bfs(v,-1));
    }
  }else{
    rep(e,N-1){
      pair<int,int> P=E[e];
      ans=min(ans,bfs(P.first,P.second));
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int ope(int a, int b, int i){
    if(i == 0)
        return a + b;
    else if(i == 1)
        return a - b;
    else
        return a * b;
}

void solve(vector<int> a)
{
    char c[] = {'+', '-', '*'};

    sort(a.begin(), a.end());
    do{
        for(int i=0; i<27; ++i){
            int b1 = i % 3;
            int b2 = i / 3 % 3;
            int b3 = i / 9;
            if(ope(ope(a[0], a[1], b1), ope(a[2], a[3], b2), b3) == 10){
                cout << "((" << a[0] << c[b1] << a[1] << ')' << c[b3] << '(' << a[2] << c[b2] << a[3] << "))" << endl;
                return;
            }
            if(ope(ope(ope(a[0], a[1], b1), a[2], b2), a[3], b3) == 10){
                cout << "(((" << a[0] << c[b1] << a[1] << ')' << c[b2] << a[2] << ')' << c[b3] << a[3] << ')' << endl;
                return;
            }
            if(ope(ope(a[0], ope(a[1], a[2], b1), b2), a[3], b3) == 10){
                cout << "((" << a[0] << c[b2] << '(' << a[1] << c[b1] << a[2] << "))" << c[b3] << a[3] << ')' << endl;
                return;
            }
        }
    }while(next_permutation(a.begin(), a.end()));

    cout << '0' << endl;
}

int main()
{
    for(;;){
        vector<int> a(4);
        for(int i=0; i<4; ++i){
            cin >> a[i];
            if(a[i] == 0)
                return 0;
        }

        solve(a);
    }
}

Measured memory_bytes: 0
#include <stdio.h>


int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	if (a < b) {
		for (int i = 0; i < b; ++i) {
			printf("%d", a);
		}
	}
	else {
		for (int i = 0; i < a; ++i) {
			printf("%d", b);
		}
	}

	return 0;
}

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

namespace AtCoder.Abc
{
    // 問題:
    class A_160_Coffee
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            char[] check = s.ToCharArray();

            if(check[2] == check[3] && check[4] == check[5])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25848
#include <stdio.h>
#include <string.h>

int main(void)
{
  char s[100001];
  long long a = 0;
  long long b = 0;
  scanf("%s", s);
  for (int i = 0; i < strlen(s); i++) {
    if (i % 2) {
      if (s[i] == '0')
	a++;
      else
	b++;
    } else {
      if (s[i] == '0')
	b++;
      else
	a++;
    }
  }
  if (a > b)
    printf("%lld\n", b);
  else
    printf("%lld\n", a);
}


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

int main(){
  int K,N;
  cin >> K >> N;
  vector<int> iti(N);
  for (int i = 0; i < N; i++) {
    cin >> iti.at(i); 
  }
  vector<int> kyori(N);
  for (int i = 0; i < N-1; i++){
    kyori.at(i) = iti.at(i+1)-iti.at(i);
  }
  kyori.at(N-1)=iti.at(0)+K-iti.at(N-1);
 
  sort(kyori.begin(), kyori.end());
  cout <<K-kyori.at(N-1) <<endl;
  
}

Measured memory_bytes: 1792
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    INF = 10**10
    dp = [INF] * (N+1)
    dp[0] = 0
    bk = set([1])
    for i in range(100):
        if pow(6,i)>N:
            break
        bk.add(pow(6,i))
    for i in range(100):
        if pow(9,i)>N:
            break
        bk.add(pow(9,i))

    for i in range(N):
        for j in bk:
            if (i+j)<=N:
                dp[i+j] = min(dp[i+j], dp[i]+1)
    print(dp[N])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 998244353;

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

	int ab, bc, ca;
	cin >> ab >> bc >> ca;
	cout << ab * bc / 2 << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
	
	#define 	ll 						long long int
	#define 	REP(i,a,b)				for(i=a;i<=b;i++)
	#define 	REPr(i,b,a)				for(i=b;i>=a;i--)
	#define 	pb 						push_back
    #define 	mp 						make_pair
    #define 	f  						first
   	#define 	s  						second
   	#define 	umap(type1,type2)		unordered_map<type1,type2>

int mod = pow(10,9)+7;

void solve(){
	long double n,d,i;	cin>>n>>d;
	long double ans=0;

	while(n--){
		long double x,y;	cin>>x>>y;
		long double dist= sqrt((x*x)+(y*y));
		if(dist<=d)	ans++;
	}
	cout<<ans<<endl;
}

void pb_18(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	/***************************

		FuCk RATINGS I am in love with EXPERIENCE.

	***************************/

	int t;	t=1;
	while(t--)	solve();
}

int main(){
	pb_18();
}

Measured memory_bytes: 3768
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jun  9 13:46:43 2019

@author: YudNK
"""
n = int(input())
rest = [(input().split()) for i in range(n)]
for i in range(n):
    rest[i].append(i)
rest.sort(key= lambda x:(x[0],-1*int(x[1])))
for i in rest:
    print(i[2]+1)

Measured memory_bytes: 3060
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	stack<int> S1;
	stack<pair<int,int>> S2;
	int sum=0;
	char ch;
	for (int i = 0; cin>>ch; ++i)
	{
		if(ch=='\\')
		{
			S1.push(i);
		}
		else if(ch=='/'&&S1.size()>0)
		{
			int j=S1.top();
			S1.pop();
			int a=i-j;
			sum+=a;
			while(S2.size()>0&&S2.top().first>j)
			{
				a=S2.top().second+a;
				S2.pop();
			}
			S2.push(make_pair(j,a));
		}
	}

	vector<int> ans;
	while(S2.size()!=0)
	{
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(),ans.end());
	cout<<sum<<endl;
	int s=ans.size();
	cout<<s;
	for (int i = 0; i < s; ++i)
	{
		cout<<" "<<ans[i];
	}
	cout<<endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int x[N];
  for (int i = 0; i < N; i++) cin >> x[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += min(abs(0 - x[i]) * 2, abs(K - x[i]) * 2);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

void solve()
{
    ll n; cin>>n;
    ll x = n*n*n;
    cout<<x;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int M=16;
const int N=100010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,ans,tot;
int p[N];
int w[N],c[M],a[M];
int dp[N];
int main()
{
	int x,y,z;
	file();
	read(n);
	For(i,2,n)
	{
		read(x),read(y),read(z);
		x++,y++;
		w[x]^=z,w[y]^=z;
	}
	For(i,1,n)c[w[i]]++;
	For(i,1,15)
	{
		ans+=(c[i]>>1)+(c[i]&1);
		if(c[i]&1)a[tot++]=i;
	}
	For(i,1,(1<<tot)-1)
	{
		int ret=0;
		For(j,0,tot)if((i>>j)&1)ret^=a[j];
		if(!ret)dp[i]=1;
	}
	For(x,1,(1<<tot)-1)
		for(int y=(x-1)&x;y;y=(y-1)&x)
			chkmax(dp[x],dp[y]+dp[x^y]);
	printf("%d\n",ans-dp[(1<<tot)-1]);
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e18;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n, k;
    cin >> n >> k;
    vl a(n+2);
    a[0] = 0;
    for(ll i=1;i<=n;i++){
        cin >> a[i];
    }
    if(k>=1000){
      for (ll i = 1; i <= n;i++){
        cout << n << " ";
      }
      cout << endl;
      return 0;
    }
    vl dp(n + 1, 0);
    rep(i,k){
      for (ll j = 1; j <= n;j++){
        ll in = j - a[j];
        if(in<=0)in = 1;
        ll out = j + a[j]+1;
        if(out>n)out = n + 1;
        dp[in]++;
        dp[out]--;
      }
      ll count = 0;
      for (ll j = 1; j <= n; j++){
        count += dp[j];
        a[j] = count;
        dp[j] = 0;
      }
    }
    for (ll i = 1; i <= n;i++){
      cout << a[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 6412
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll c[30], s[370][30];
ll score[30], last_day[30];
int t[370];
int D;

set<int> st[30];

ll calc(int day, int contest) {
    score[contest] += s[day][contest];
    last_day[contest] = day;

    rep(i, 1, 27) score[i] -= c[i]*(day-last_day[i]);
    
    ll sum = 0;
    rep(i, 1, 27) sum += score[i];
    return sum;
}

ll calc_diff(int day, int contest) {
    int next, prev;
    auto itr = st[contest].upper_bound(day);
    next = *itr, prev = *(--itr);

    ll x =((next-day-1)*(next-day))/2;
    ll y =((day-prev-1)*(day-prev))/2;
    ll z =((next-prev-1)*(next-prev))/2;
    
    ll res = s[day][contest] + c[contest]*(-x-y+z);
    return res;

}

int main(void) {
    int m;
    cin >> D;
    rep(i, 1, 27) cin >> c[i];
    rep(i, 1, D+1) rep(j, 1, 27) cin >> s[i][j];
    rep(i, 1, D+1) cin >> t[i];

    rep(i, 1, D+1) calc(i, t[i]);

    ll sum = 0;
    rep(i, 1, 27) sum += score[i];
    
    rep(i, 1, 27) {
      st[i].insert(0);
      st[i].insert(D+1);
    }
    rep(i, 1, D+1) st[t[i]].insert(i);

    cin >> m;
    rep(i, 0, m) {
        int d, q;
        cin >> d >> q;
        int con = t[d];
        
        st[con].erase(d);
        sum -= calc_diff(d, con);

        sum += calc_diff(d, q);
        st[q].insert(d);
        t[d] = q;

        printf("%lld\n", sum);

        

    }


    return 0;
}




Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define MAXN	100005
#define INF	1e9
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int a[MAXN];
int main() {
	int n; read(n);
	int mx = 0, mn = INF;
	for (int i = 1; i <= n; i++) {
		read(a[i]);
		mx = max(mx, a[i]);
		mn = min(mn, a[i]);
	}
	if (mx - mn >= 2) {
		printf("No\n");
		return 0;
	}
	if (mx == mn) {
		if (mx == n - 1 || mx <= n / 2) printf("Yes\n");
		else printf("No\n");
		return 0;
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		if (a[i] == mx) cnt++;
	mx -= n - cnt;
	mn -= n - cnt;
	if (mx >= 1 && mx <= cnt / 2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

const int N = 6*4;
char dp[1 << N];
int cover[N];
int x[N], y[N], r[N], c[N];
int n;

int rec(int bits){
	if (bits == 0) return 0;

	char &res = dp[bits];
	if (res >= 0) return res;
	res = 0;
	for (int i = 0; i < n; ++i){
		if (~bits&(1 << i)) continue;
		if (bits&cover[i]) continue;
		for (int j = i+1; j < n; ++j){
			if (~bits&(1 << j)) continue;
			if (bits&cover[j]) continue;
			if (c[i] != c[j]) continue;
			res = max((int)res, 2 + rec(bits&~(1 << i)&~(1 << j)));
		}
	}
	return res;
}

int main(){
	auto sq = [](int x){return x*x; };
	while (cin >> n, n){
		memset(dp, -1, sizeof(dp));
		for (int i = 0; i < n; ++i){
			cin >> x[i] >> y[i] >> r[i] >> c[i];
			cover[i] = 0;
		}
		for (int i = 0; i < n; ++i){
			for (int j = 0; j < i; ++j){
				if (sq(x[i] - x[j]) + sq(y[i] - y[j]) >= sq(r[i] + r[j])) continue;
				cover[i] |= 1<<j;
			}
		}

		cout << rec((1 << n) - 1) << '\n';
	}


	return 0;
}

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

int main(){
    int L,R;
    cin >> L >> R;
    int num;
    if(R-L+1 > 2019){
        cout << 0 << endl;
        return 0;
    }
    else{
        num = R-L+1;
        int X[num];
        for(int i=0; i<num; i++){
            X[i] = (L+i) % 2019;
        }
        int res = 2018;
        for(int i=0; i<num-1; i++){
            for(int j=i+1; j<num; j++){
                int kouho = (X[i]*X[j]) % 2019;
                if(kouho < res){
                    res = kouho;
                }
            }
        }
        cout << res << endl;
    }
}


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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vector<int>> cnt(h,vector<int>(w));
  
  rep(i,h){
    vector<int> done(w);
    rep(j,w){
      if(s[i][j]=='#')continue;
      if(done[j])continue;
      int l = 0;
      
      while(j+l<w){
        if(s[i][j+l]=='#')break;
        l++;
      }
      
      rep(k,l){
        cnt[i][j+k] += l;
        done[j+k] = 1;
      }
    }
  }
  
  rep(i,w){
    vector<int> done(h);
    rep(j,h){
      if(s[j][i]=='#')continue;
      if(done[j])continue;
      int l = 0;
      
      while(j+l<h){
        if(s[j+l][i]=='#')break;
        l++;
      }
      
      rep(k,l){
        cnt[j+k][i] += l;
        done[j+k] = 1;
      }
    }
  }
  int ans = 0;
  
  rep(i,h){
    rep(j,w){
      ans = max(ans,cnt[i][j]-1);
    }
  }
  cout << ans << endl;
}


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

int main(){
  string s;
  cin >> s;
  int a = s.length();
  cout << s[0] << a-2 << s[a-1] << endl;
}

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

const int N = 2e5 + 5;


int n, a[N];
vector < pair < int, int > > b;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        if(a[i]){
            b.push_back(make_pair(a[i], 1));
            continue;
        }
        int cur = 1;
        while(i + 1 <= n && a[i + 1] == 0){
            i++;
            cur++;
        }
        b.push_back(make_pair(a[i], cur));
    }
    long long ans = 0;
    for(int i = 0; i < b.size(); i++){
        int xsum = b[i].first, sum = b[i].first, cur = b[i].second;
        ans += 1ll * cur * (cur + 1) / 2;
        for(int j = i - 1; j >= 0; j--){
            xsum ^= b[j].first;
            sum += b[j].first;
            if(sum == xsum){
                ans += 1ll * b[j].second * cur;
            }
            else{
                break;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <set>
#include <map>
#include <list>

using namespace std;

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

const ll MOD = 1000000007;
const int inf = (int) 1e9;

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

  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    for (int j = 0; j < b[i]; j++) {
      int box;
      cin >> box;
      c[i] |= (1 << (box - 1));
    }
  }

  vector<vector<int> > dp(M+1, vector<int>(1 << N, inf));
  for (int i = 0; i < M+1; i++) dp[i][0] = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < (1 << N); j++) {
      dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
      dp[i+1][j|c[i]] = min(dp[i+1][j|c[i]], min(dp[i][j|c[i]], dp[i][j] + a[i]));
    }
  }
  
  if (dp[M][(1<<N)-1] == inf) {
    cout << -1 << endl;
  }
  else {
    cout << dp[M][(1<<N)-1] << endl;
  }

  return 0;
}


Measured memory_bytes: 16384
a, b, c = map(int, input().split())

xflag = False
yflag = False
for i, j in ([a,b],[b,c],[c,a]):
    if i == j:
        xflag = True
    else:
        yflag = True

if xflag and yflag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
N = int(input())
A = list(int(input())for i in range(N))
H = [A[0]]
for i in range(1,N):
    if A[i] <= H[-1]:
        H.append(A[i])
    else:
        l,r =0,len(H)
        while l != r :
            if H[(l+r)//2]>=A[i]:
                l = (l+r)//2+1
            else:
                r = (l+r)//2
        H[l] = A[i]
print(len(H))


Measured memory_bytes: 57688
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#define maxn 100000+10
using namespace std;
const double eps=0.00000001;
struct node{
	double x,y;
}w[maxn],o;
double r;
double dis(node x,node y){
	return sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y));
}
inline void neww(node a1,node a2,node a3){
	//cout<<a1.x<<" "<<a2.x<<" "<<a3.x<<endl;
	//cout<<a1.y<<" "<<a2.y<<" "<<a3.y<<endl;
	double a,b,c,d,e,f;
	a=a2.y-a1.y;
	b=a3.y-a1.y;
	c=a2.x-a1.x;
	d=a3.x-a1.x;
	e=(a2.x*a2.x-a1.x*a1.x+a2.y*a2.y-a1.y*a1.y)/2;
	f=(a3.x*a3.x-a1.x*a1.x+a3.y*a3.y-a1.y*a1.y)/2;
	//cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;
	o.x=(a*f-b*e)/(a*d-b*c);
	o.y=(d*e-c*f)/(a*d-b*c);
	r=dis(o,a1);
	//cout<<o.x<<" "<<o.y<<" "<<r<<endl<<endl;
	return;
}
int main(){
	int k,m,n;
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)scanf("%lf%lf",&w[i].x,&w[i].y);
	random_shuffle(w+1,w+n+1);
	o=w[1];r=0;
	//for(register int i=1;i<=n;i++){
	//	cout<<i<<" "<<w[i].x<<" "<<w[i].y<<endl;
	//}
	for(register int i=2;i<=n;i++){
		if(dis(w[i],o)-r>eps){
			o=w[i];r=0;
			for(register int j=1;j<i;j++){
				if(dis(w[j],o)-r>eps){
					o.x=(w[i].x+w[j].x)/2;
					o.y=(w[i].y+w[j].y)/2;
					r=dis(o,w[i]);
					for(register int k=1;k<j;k++){
						if(dis(w[k],o)-r>eps){
							//cout<<i<<" "<<j<<" "<<k<<" "<<r<<" "<<o.x<<" "<<o.y<<endl;
							neww(w[i],w[j],w[k]);
						}
					}
				}
			}
		}
	}
	printf("%.10lf\n",r);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vs vector<string>
typedef pair<string,int> card;
#define mark first
#define kazu second
const int inf=1e9+1;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846

class Tree{
public:
	Tree(){}
	int id;
	int degree;
	int parent;
	int sibling;
	int left;
	int right;
};

void preorder(vector<Tree> &tree,int id);
void inorder(vector<Tree> &tree,int id);
void postorder(vector<Tree> &tree,int id);

int main(){
	int n,i,j,k;
	cin>>n;
	vector<Tree> tree(n);
	loop(i,0,n){
		tree[i].id=i;
		tree[i].parent=-1;
	}
	int id,left,right;
	loop(i,0,n){
		cin>>id>>left>>right;
		tree[id].left=left;
		tree[id].right=right;
		tree[left].parent=id;
		tree[right].parent=id;
	}
	loop(i,0,n){
		if(tree[i].parent==-1){
			id=i;
			break;
		}
	}
	cout<<"Preorder"<<endl;
	preorder(tree,id);
	cout<<endl<<"Inorder"<<endl;
	inorder(tree,id);
	cout<<endl<<"Postorder"<<endl;
	postorder(tree,id);
	cout<<endl;
}
void preorder(vector<Tree> &tree,int id){
	cout<<" "<<id;
	if(tree[id].left!=-1){
		preorder(tree,tree[id].left);
	}
	if(tree[id].right!=-1){
		preorder(tree,tree[id].right);
	}
}

void inorder(vector<Tree> &tree,int id){
	if(tree[id].left!=-1){
		inorder(tree,tree[id].left);
	}
	cout<<" "<<id;
	if(tree[id].right!=-1){
		inorder(tree,tree[id].right);
	}
}

void postorder(vector<Tree> &tree,int id){
	if(tree[id].left!=-1){
		postorder(tree,tree[id].left);
	}
	if(tree[id].right!=-1){
		postorder(tree,tree[id].right);
	}
	cout<<" "<<id;
}

Measured memory_bytes: 3104
class Dice:
  def __init__(self, list1):
    self.f = list1
  def spin1(self):#(真上から見て反時計回り)
    self.f[0], self.f[1], self.f[4], self.f[5] = self.f[1], self.f[5], self.f[0], self.f[4]
    self.f[0], self.f[2], self.f[3], self.f[5] = self.f[3], self.f[0], self.f[5], self.f[2]
    self.f[0], self.f[1], self.f[4], self.f[5] = self.f[4], self.f[0], self.f[5], self.f[1]
    return self.f
  def spin2(self):#(方角Eから見て時計回り)
    self.f[0], self.f[1], self.f[4], self.f[5] = self.f[1], self.f[5], self.f[0], self.f[4]
    return self.f
  def spin3(self):#(方角Sから見て反時計回り)
    self.f[0], self.f[2], self.f[3], self.f[5] = self.f[2], self.f[5], self.f[0], self.f[3]
    return self.f

data_6 = []
n = int(input())
for m in range(0, n):
    data = list(map(int, input().split()))
    data_1 = []
    data_2 = []
    data_4 = []
    data_5 = []
    dice_1 = Dice(data)
    for i in range(0, 4):
        a = dice_1.spin2()
        b = a[:]
        data_1.append(b)
    for j in data_1:
        dice_2 = Dice(j)
        for k in range(0, 4):
            c = dice_2.spin1()
            d = c[:]
            data_2.append(d)
    data_3 = data_1 + data_2
    for l in data_3:
        dice_3 = Dice(l)
        for m in range(0, 4):
            e = dice_3.spin3()
            f = e[:]
            data_4.append(f)
            for o in data_4:
                if o not in data_5:
                    data_5.append(o)
    for p in data_5:
        data_6.append(p)

data_7 = []
for q in data_6:
    if q not in data_7:
        data_7.append(q)

if len(data_6) == len(data_7):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5896
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main() {
    int K;
    cin >> K;
    int now = 0;
    REP(i, K + K) {
        now = now * 10 + 7;
        now %= K;
        if(now % K == 0) {
            out(i + 1);
            return 0;
        }
    }
    out(-1);
}

Measured memory_bytes: 3632
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
S=0
b=0
if A[0]>B[0]:
    S+=B[0]
else:
    b=B[0]-A[0]
    S+=A[0]
for i in range(1,N):
    if b+B[i]<A[i]:
        S+=b+B[i]
        b=0
    elif b>=A[i]:
        S+=A[i]
        b=B[i]
    else:
        S+=A[i]
        b=b+B[i]-A[i]
if b>A[N]:
    S+=A[N]
else:
    S+=b
print(S)


Measured memory_bytes: 19004
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int mod=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	string l;cin>>l;
	ll top=1,below=0;
	int n=l.size();
	rep(i,0,n){
		if(l[i]=='1'){
			below=(3*below+top)%mod;
			top=2*top%mod;
		}else
			below=3*below%mod;
	}
		print((top+below)%mod);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });

const long long MOD = 2;


int main(){
	ll N, M;
	cin >> N >> M;
	vector<vector<ll>> s(M);
	REP(m, M) {
		ll K;
		cin >> K;
		s[m].resize(K);
		REP(k, K) {
			cin >> s[m][k];
			s[m][k]--;
		}
	}
	vector<ll> p(M);
	REP(m, M) cin >> p[m];

	ll res = 0;
	for (ll n=0; n<(1<<N); n++) {
		bool ok = true;
		REP(m, M) {
			ll c = 0;
			for (ll id : s[m]) {
				if ((n>>id)&1) c++;
			}
			c %= 2;
			if (c != p[m]) ok = false;
		}
		if (ok) res++;
	}
	cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,r,b;
  string s;
  
  cin >> n >> s;
  
  r=b=0;
  for (i=0;i<n;i++){
    if (s[i]=='R') r++;
    else b++;
  }
  
  if (r>b) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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


bool check(char b) {
    if (b == 'A' || b == 'T' || b == 'C' || b == 'G') {
        return true;
    }
    else {
        return false;
    }
}

int main() {

    string S;
    cin >> S;

    // int left, right;
    int tmp = 0;
    int max = 0;

    for (int i=0; i<S.length(); i++) {
        if (check(S[i])) {
            tmp++;
        } else {
            tmp = 0;
        }
        if (tmp > max) {
            max = tmp;
        }
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 256
# input
n = int(input())
A = list(map(int, input().split()))

for i in range(n - 1, (n + 1) % 2 - 1, -2):
    print(A[i], end = " ")
for j in range(n % 2, n - 1, 2):
    print(A[j], end = " ")


Measured memory_bytes: 26020
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
double a[3100];
double dp[3100][3100]; 
void solve()
{
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[0][0] = 1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            if(j)
            {
                dp[i][j] += dp[i-1][j-1]*a[i-1];
            }
            dp[i][j] += dp[i-1][j] * (1-a[i-1]);
        }
    }
    double res=0;
    for(int i=0;i<=n;i++)
    {
        int tails = n-i;
        if(i>tails)
        {
            res += dp[n][i];
        }
    }
    printf("%.12f",res);
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 72320
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long  ll;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define Yes_RTN s_cout("Yes");return 0
#define No_RTN  s_cout("No");return 0
#define YES_RTN s_cout("YES");return 0
#define NO_RTN  s_cout("NO");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);

int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

#pragma endregion



int main(void) {
	int N, i,cnt=0;
	int p[51],tmp[50];

	i_cin(N);
	i_cins(N, p);

	memcpy(tmp, p, sizeof(int) * 50);
	qsort(p, N, sizeof(int), s_asort);

	for (i = 0; i < N; i++) {
		if (p[i] == tmp[i]) continue;
		cnt++;
	}
	s_cout(cnt > 2 ? "NO" : "YES");
	return 0;
}



Measured memory_bytes: 128
#ifndef __cplusplus
    cat << EOF
#endif
#include <bits/stdc++.h>
using namespace std;

typedef long long lint;
constexpr int inf = (1 << 30) - 1;
constexpr lint linf = (1ll << 60) - 1;

#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define overload_rep(arg0, arg1, arg2, name, ...) name
#define all(box) box.begin(), box.end()

template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

int N, K;
int score[3];
string T;

int solve(const string& s) {
    int n = s.size();
    vector<vector<int>> dp(n + 1, vector<int>(3));
    rep(i, n) {
        rep(j, 3) {
            int maxi = 0;
            rep(k, 3) {
                if(j == k) continue;
                chmax(maxi, dp[i][k]);
            }
            dp[i + 1][j] = maxi;
        }
        dp[i + 1][s[i]] += score[s[i]];
    }
    int res = 0;
    rep(j, 3) chmax(res, dp[n][j]);
    return res;
}

int main() {

    cin >> N >> K;
    rep(i, 3) cin >> score[i];
    cin >> T;
    rep(i, N) {
        if(T[i] == 'r') T[i] = 2;
        else if(T[i] == 'p') T[i] = 1;
        else T[i] = 0;
    }

    int ans = 0;
    rep(i, K) {
        string now = "";
        for(int j = i; j < N; j += K) now += T[j];
        ans += solve(now);
    }
    cout << ans << '\n';
    return 0;

}


Measured memory_bytes: 5888
#include<stdio.h>
#include<ctype.h>
int main(void){

  char c;
  while(1){
    scanf("%c",&c);
    if(islower(c)){
      c=toupper(c);
    }else{
      c=tolower(c);
    }
    printf("%c",c);
    if(c=='\n')
      break;
  }
 return 0;
}

Measured memory_bytes: 1768
n,m=map(int,input().split())
def hashh(x,y,f):
    return (x*3000+y)*2+f
abc_l=[list(map(int,input().split()))for _ in range(n)]
def_l=[list(map(int,input().split()))for _ in range(m)]
x=[0]
y=[0]
for a,b,c in abc_l:
    x.append(a)
    x.append(b)
    y.append(c)
for d,e,f in def_l:
    x.append(d)
    y.append(e)
    y.append(f)
x=sorted(list(set(x)))
y=sorted(list(set(y)))
h=len(x)+1
w=len(y)+1
dicx={}
dicy={}
for i in range(len(x)):dicx[x[i]]=i
for i in range(len(y)):dicy[y[i]]=i
grid=[[0]*w for _ in range(h)]
dont=set()
for a,b,c in abc_l:
    for i in range(dicx[a],dicx[b]):
        dont.add(hashh(i+1,dicy[c],1))
for d,e,f in def_l:
    for j in range(dicy[e],dicy[f]):
        dont.add(hashh(dicx[d],j+1,0))
if dicx[0]==0 or dicx[0]==h-1 or dicy[0]==0 or dicy[0]==w-1:
    exit(print("INF"))
stack=[(dicx[0],dicy[0])]
grid[dicx[0]][dicy[0]]=1
ans=0
for sx,sy in stack:
    ans+=(x[sx]-x[sx-1])*(y[sy]-y[sy-1])
    for dx,dy in ((-1,0),(1,0),(0,-1),(0,1)):
        tx=sx+dx
        ty=sy+dy
        if grid[tx][ty]:continue
        if hashh(min(sx,tx),min(sy,ty),1 if sx==tx else 0) in dont:continue
        if tx==0 or tx==h-1 or ty==0 or ty==w-1:
            exit(print("INF"))
        grid[tx][ty]=1
        stack.append((tx,ty))
print(ans)

Measured memory_bytes: 818132
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

template<typename T>
vector <T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

typedef pair<int, int> P;

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

    int N, K;
    cin >> N >> K;

    vector<int> two(K + 1);
    two[0] = 1;
    REP(i, K) {
        two[i+1] = two[i] * 2;
    }

    double res = 0;
    FOR(i, 1, N) {
        int n = i;
        int cnt = 0;
        while (n < K) {
            n *= 2;
            cnt++;
        }
        res += 1.0f / (double)two[cnt];
    }
    res *= (double)1.0f / N;
    fcout << res << endl;

    return 0;
}


Measured memory_bytes: 1024