akhauriyash/Code-Regression huggingface dataset:
import sys
input=sys.stdin.readline
n=int(input())
a=input().split()
ans=[]

for i in range(n):
    if n%2==0:
        if i%2==0:
            ans.append(a[i])
    else:
        if i%2!=0:
            ans.append(a[i])
ans=ans[::-1]
for i in range(n):
    if n%2==0:
        if i%2!=0:
            ans.append(a[i])
    else:
        if i%2==0:
            ans.append(a[i]) 
ans=ans[::-1]
ans=' '.join(ans)
if n==1:
    ans=a[0]
'''
for j in range(n):
    ans.insert(0,a[j])
'''
print(ans)

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> city(n, 0);
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        city.at(a-1)++;
        city.at(b-1)++;
    }
    for (int i=0; i<n; i++) {
        cout << city.at(i) << endl;
    }
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-


use proconio::input;

// ABC086C - Traveling
// https://atcoder.jp/contests/abs/fasks/arc089_a
use itertools::Itertools;

fn main() {
/*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n: usize,
        k: usize,
    }
    let mut sunukes = vec![0; n];
    for i in 0..k {
        input! {
            d: usize,
            a: [usize; d]
        }
        for x in a.iter(){
            sunukes[x - 1] += 1;
        }

    }
    let result = sunukes.iter().filter(|x| **x == 0).count();
    
    println!("{}",result);
}


Measured memory_bytes: 2156
N = int(input())
H = [0] + list(map(int,input().split()))
A = [0]

for ii in range(N):
    i = ii + 1

    if i == 1:
        A.append(0)
    elif i == 2:
        A.append(abs(H[2] - H[1]))
    else:
        A.append(min(
            A[i-1] + abs(H[i] - H[i-1]),
            A[i-2] + abs(H[i] - H[i-2])
        ))

print(A[N])

Measured memory_bytes: 13980
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, input().rstrip('\n').split()))
    if a == b == c:
        if a == b == c == 1:
            print(0)
        else:
            print(-1)
    else:
        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            cnt = 0
            while True:
                if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
                    cnt += 1
                    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
                else:
                    break
            print(cnt)
        else:
            print(0)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
X, K, D = map(int, input().split())
cnt = 0
ans = 0

if abs(X) % D == 0:
    cnt = abs(X) // D
else:
    cnt = (abs(X) // D) + 1

if cnt >= K:
    ans = abs(X) - D * K
else:
    re = cnt - K
    if re % 2 == 0:
        ans = abs(X) - D * cnt
    else:
        ans = (abs(X) - D * cnt) + D

print(abs(ans))


Measured memory_bytes: 9180
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char buf[55][55];

int main() {
  int r, c;
  scanf("%d%d\n", &r, &c);
  for(int i = 0; i < r; i++) {
    scanf("%s", buf[i]);
  }
  for(int i = 0; i < r; i++) {
    for(int j = 0; j < c; j++) {
      if(buf[i][j] == '#') {
        printf("#");
      }
      else {
        int amt = 0;
        for(int dx = -1; dx <= 1; dx++) {
          for(int dy = -1; dy <= 1; dy++) {
            if(i+dx >= 0 && i+dx < r && j+dy >= 0 && j+dy < c && buf[i+dx][j+dy] == '#') {
              amt++;
            }
          }
        }
        printf("%d", amt);
      }
    }
    printf("\n");
  }
}


Measured memory_bytes: 256
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N =3e5+6;
bool comp( pii p1, pii p2){
	return p1.fi<p2.fi;
}
bool comp2( pii p1,pii p2){
	return p1.se>p2.se;
}
pii find ( string &s){
	int c1=0,c2=0,n=s.len();
	for ( int i=0;i<n;i++){
		if ( s[i]==')'&&c2==0)
			c1++;
		else
		if ( s[i]==')'&&c2>0)
			c2--;
		else
			c2++;
	}
	return mp( c1,c2);
}
void solve(){
	int n;
	cin>>n;
	vpi v;
	string s;
	for ( int i=0;i<n;i++){
		cin>>s;
		pii p=find ( s);
		v.pb( p);
	}
//	for ( int i=0;i<v.sz();i++)
//		cout<<v[i].fi<<' '<<v[i].se<<'\n';
	int ss=0;
	for ( int i=0;i<n;i++){
		if ( v[i].fi==0)
			ss+=v[i].se;
	}
	vpi vc,vd;
	for ( int i=0;i<n;i++)
		if ( v[i].fi!=0&&v[i].se-v[i].fi>=0)
			vc.pb( v[i]);
		else
		if ( v[i].fi!=0)
			vd.pb( v[i]);


	sort( vc.begin(),vc.end(),comp);
	for (int i=0;i<vc.sz();i++){
		ss-=vc[i].fi;
		if ( ss<0){
			cout<<"No\n";
			return;
		}
		ss+=vc[i].se;
	}

	sort( vd.begin(),vd.end(),comp2);
	for ( int i=0;i<vd.sz();i++){
		ss-=vd[i].fi;
		if ( ss<0){
			cout<<"No\n";
			return;
		}
		ss+=vd[i].se;
	}

	if ( ss==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
//	#ifndef ONLINE_JUDGE
//		cin.tie(NULL);
//		freopen ("INPUT.txt" , "r" , stdin);
//		freopen ("OUTPUT.txt", "w" , stdout);
//	#endif	
    ll t=1;
   // cin>>t;
    for (ll i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 34892
#include <iostream>
#include <stdlib.h>
using namespace std;
void DFS(int* arr, int pos, int* res, int index, bool& flag) {
    if (pos >= 10||flag)
    {
        return;
    }
    if ((index==0) || (index >= 1 && res[index - 1] < arr[pos]))
    {
        res[index] = arr[pos];
        arr[pos] = 0;
    }
    DFS(arr, pos+1, res, index+1, flag);
    if (flag)
    {
        return;
    }
    int pre = 0;
    int cur = 0;
    flag = true;
    for (int i = 0; i < 10; i++)
    {
        if (arr[i]!=0)
        {
            pre = pre == 0 ? arr[i] : cur;
            cur = arr[i];
            if (cur < pre)
            {
                flag = false;
                break;
            }
        }
    }
}

int main()
{
    int N, arr[11], res[10];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> arr[j];
        }
        bool flag = false;
        DFS(arr, 0, res, 0, flag);
        if (flag)
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
   // system("pause");
    return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <algorithm>
#include <map>
#include <string.h>
#include <stack>
using namespace std;
stack<char>l;
stack<char>r;

int main()
{

   char a[102];
    int n;
    while(cin>>n)
    {
        for(int i=0; i<n; i++) cin>>a[i];

        while(!l.empty()) l.pop();
        while(!r.empty()) r.pop();
        int Lcou=0,Rcou=0;
        for(int i=0; i<n; i++) //计算得在左边加几个
        {
            if(a[i]=='(') l.push(a[i]);
            if(a[i]==')')
            {
                if(l.empty())
                {
                    Lcou++;
                }
                else
                    l.pop();
            }
        }
        for(int i=n; i>=0; i--) //计算得在左边加几个
        {
            if(a[i]==')') r.push(a[i]);
            if(a[i]=='(')
            {
                if(r.empty())
                {
                    Rcou++;
                }
                else
                    r.pop();
            }
        }
        while(Lcou--)
        {
            cout<<'(';
        }
      for(int i=0; i<n; i++) cout<<a[i];
        while(Rcou--)
        {
            cout<<')';
        }
        cout<<endl;


    }

    return 0;
}


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

const int N = 111111;

int A[N] , n;

void print(int who) {
  if(who) puts("First");
  else puts("Second");
  exit(0);
}

int gcd(int x , int y) {
  return (!y) ? x : gcd(y , x % y);
}

int check(void) {
  for(int i = 1;i <= n;++ i) if(A[i] == 1) return 1;
  return 0;
}

int main(void) {
  cin >> n;
  int lsk = 0;
  for(int i = 1;i <= n;++ i) {
    cin >> A[i];
    lsk += A[i] & 1;
  }
  int pg = 1 , dead = check();
  while(1) {
    if((n - lsk) & 1) print(pg);
    if(lsk > 1 || dead) print(pg ^ 1);
    for(int i = 1;i <= n;++ i) if(A[i] & 1) -- A[i];
    int G = 0;
    for(int i = 1;i <= n;++ i) G = gcd(G , A[i]);
    for(int i = 1;i <= n;++ i) A[i] /= G;
    lsk = 0;
    for(int i = 1;i <= n;++ i) lsk += (A[i] & 1);
    dead = check();
    pg ^= 1;
  }
}


Measured memory_bytes: 640
n, p = map(int, input().split())
s = list(map(int, list(input())))[::-1]

sum = 0
cnt = [0] * p
cnt[0] = 1

ans = 0
if p in [2, 5]:
    if p == 2:
        ok_list = [0, 2, 4, 6, 8]
    if p == 5:
        ok_list = [0, 5]

    for i in range(n):
        d = s[i]
        if d in ok_list:
            ans += n - i

else:
    for i in range(n):
        d = s[i] * pow(10, i, p)
        sum = (sum + d) % p
        cnt[sum] += 1
    for i in range(p):
        ans += cnt[i] * (cnt[i]-1) // 2
print(ans)


Measured memory_bytes: 6560
#include <bits/stdc++.h>
using namespace std;
int n[] = {1, 2, 4, 8, 16, 32, 64};
int main(){
  int a;
  cin >> a;
  for(int i = 6; i >= 0; i--){
    if(n[i] <= a){
      cout << n[i] << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 K = 0;

	cin >> N;
	cin >> K;

	vector<SINT32> DATA(N);
	vector<SINT32> DP(N);
	
	for (SINT32 i = 0; i < N; i++) {
		cin >> DATA[i];
	}

	DP[0] = 0;
	for (SINT32 i = 1; i < N; i++) {
		DP[i] = 1000000001;
		for (SINT32 j = 1; j < K+1; j++) {
			if ((i-j) < 0) {
				break;
			}
			DP[i] = MIN(DP[i],DP[i-j] + ABS(DATA[i] - DATA[i-j]));
		}
	}

//	for (SINT32 i = 0; i < N; i++) {
//		cout << DP[i] << " ";
//	}
//	cout << endl;


	cout << DP[N-1] << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
using namespace std;

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

int main() {
    int H,W;
    cin>>H>>W;
    vector<vector<char> > s(H, vector<char>(W));
    for(int i=0; i<H; i++)
        for(int j=0; j<W; j++)
            cin>>s[i][j];

    bool can=true;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(s[i][j]=='#') {
                bool find=false;
                for(int k=0; k<4; k++) {
                    int nj=j+dx[k];
                    int ni=i+dy[k];
                    if(!(0<=ni&&ni<H)) continue;
                    if(!(0<=nj&&nj<W)) continue;
                    if(s[ni][nj]=='#') find=true;
                }
                if(find==false) can=false;
            }
        }
    }
    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
int main() {
	ll n, r;
	scanf("%lld %lld", &n, &r);
	if (n < 10) {
		ll k = 100 * (10 - n);
		printf("%lld", k + r);
	}
	else {
		printf("%lld", r);
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,j,n,m) for(int i=j;i<n;i+=m)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

int main(){
  IOS();
  ll a,b;
  cin>>a>>b;
  cout<<max({a+b,a-b,a*b})<<endl;
}


Measured memory_bytes: 256
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

# ans
print(dp[N-1])

Measured memory_bytes: 13928
import sys
input = sys.stdin.readline

N = int(input())
s = input().rstrip()

start = ["WS", "WW", "SS", "SW"]

for A in start:
    A = list(A)
    for i in range(1, N):
        if (A[i] == "W" and s[i] == "o") or (A[i] == "S" and s[i] == "x"):
            if A[i - 1] == "S":
                A.append("W")
            else:
                A.append("S")
        else:
            A.append(A[i - 1])
    if len(A) == N + 1 and A[0] == A[-1]:
        A = A[:N]
        if (A[0] == "W" and s[0] == "o") or (A[0] == "S" and s[0] == "x"):
            if A[1] != A[-1]:
                print("".join(A))
                sys.exit()
        else:
            if A[-1] == A[1]:
                print("".join(A))
                sys.exit()
print(-1)



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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[200005];
  int c[200005];
  for(int i=1;i<=n;i++){
    c[i]=0;
  }
  
  for(int i=2;i<=n;i++){
    
    cin>>a[i];
    int t=a[i];
    
      c[t]++;
    
  }
  
  for(int j=1;j<=n;j++){
    cout<<c[j]<<endl;
  }


}

Measured memory_bytes: 5172
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, k;
    cin >> n >> k;
    VL a(n);
    REP(i,n) cin >> a[i];
    ll ans = 1e18;
    REP(x,1<<n){
        int s = 0;
        REP(j,n) if ((x>>j) & 1) s++;
        if (s != k) continue;
        ll ma = 0, temp = 0;
        REP(i,n){
            if ((x>>i) & 1){
                if (a[i] <= ma){
                    temp += ma-a[i]+1;
                    ma += 1;
                }else{
                    ma = a[i];
                }
            }else{
                ma = max(ma, a[i]);
            }
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int N = 18;
const int INF = 1e18 + 239;

pair<int, int> conq(pair<int, int> a, pair<int, int> b) {
	if (a.first < b.first) swap(a, b);
	return make_pair(a.first, max(a.second, b.first));
}

int a[1 << N];
pair<int, int> mn[1 << N];

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

	int n;
	cin >> n;
	for (int i = 0; i < (1 << n); i++) {
		cin >> a[i];
		mn[i] = {a[i], -INF};
	}
	for (int i = 0; i < n; i++) {
		for (int j = (1 << n) - 1; j >= 0; j--) {
			if ((j >> i) & 1) {
				mn[j] = conq(mn[j], mn[j ^ (1 << i)]);
			}
		}
	}
	int c = 0;
	for (int i = 0; i < (1 << n); i++) {
		c = max(c, mn[i].first + mn[i].second);
		if (i > 0) cout << c << '\n';
	}
}


Measured memory_bytes: 9216
// ARC085C.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 110;

int n, m;

int main()
{
    scanf("%d%d", &n, &m);
    int ct = 1LL * m * 1900 + 1LL * (n - m) * 100;
    double ans = 0, bas = 1.0 - 1.0 / double(1LL << m), acc = 1.0 / double(1LL << m);
    for (int i = 1; i <= 100000; i++)
        ans += ct * i * acc, acc *= bas;
    printf("%.0lf\n", ans);
    return 0;
}

Measured memory_bytes: 3812
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// {{{
// source: https://github.com/raahii/algo
func MaxInts(nums []int) (int, int) {
	var maxIdx, maxVal int
	for i, e := range nums {
		if i == 0 || e > maxVal {
			maxIdx = i
			maxVal = e
		}
	}
	return maxVal, maxIdx
}

func MinInts(nums []int) (int, int) {
	var minIdx, minVal int
	for i, e := range nums {
		if i == 0 || e < minVal {
			minIdx = i
			minVal = e
		}
	}
	return minVal, minIdx
}

func SumInts(nums []int) int {
	s := 0
	for _, v := range nums {
		s += v
	}
	return s
}

func ReverseInts(nums []int) []int {
	rnums := make([]int, len(nums))
	for i := 0; i < len(nums); i++ {
		rnums[len(nums)-1-i] = nums[i]
	}
	return rnums
}

func ExtendInts(nums1 []int, nums2 []int) []int {
	for _, v := range nums2 {
		nums1 = append(nums1, v)
	}
	return nums1
}

func Ints2d(n_rows, n_cols int) [][]int {
	ints := make([][]int, n_rows)
	for i := 0; i < n_rows; i++ {
		ints[i] = make([]int, n_cols)
	}
	return ints
}

func MemsetInts1d(nums []int, val int) {
	for i := range nums {
		nums[i] = val
	}
}

func MemsetInts2d(nums [][]int, val int) {
	for i := range nums {
		for j := range nums[i] {
			nums[i][j] = val
		}
	}
}

func ContainsInt(nums []int, num int) bool {
	sort.Ints(nums)

	s, e := 0, len(nums)
	for {
		if s >= e {
			break
		}

		m := (e + s) / 2
		if nums[m] == num {
			return true
		} else if num > nums[m] {
			s = m + 1
		} else {
			e = m
		}
	}

	return false
}

func ReadInt(f *os.File) int {
	var n int
	fmt.Fscanf(f, "%d", &n)
	return n
}

func ReadInts(f *os.File, n int) []int {
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(f, "%d", &nums[i])
	}
	return nums
}

func ReadLines(f *os.File, n int) []string {
	var lines []string
	reader := bufio.NewReader(f)
	for i := 0; i < n; i++ {
		bytes, _, err := reader.ReadLine()
		if err != nil {
			break
		}
		lines = append(lines, string(bytes))
	}

	return lines
}

func ReadWords(f *os.File, n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(f, "%s", &strs[i])
	}
	return strs
}

func Pow(a, n int) int {
	c := 1
	for i := 0; i < n; i++ {
		c *= a
	}
	return c
}

// }}}

func main() {
	S := ReadLines(os.Stdin, 1)[0]

	s := strings.Split(S, "/")
	m, _ := strconv.Atoi(s[1])
	d, _ := strconv.Atoi(s[2])
	if (m == 4 && d == 31) || m > 4 {
		fmt.Println("TBD")
	} else {
		fmt.Println("Heisei")
	}
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(read())
	return v
}

func main() {
	sc.Split(bufio.ScanWords)
	var sum, max int

	times := make([]int, 5) //var times = []int{}
	for i := 0; i < 5; i++ {
		times[i] = nextInt()

		d := times[i] % 10
		// if d != 0 && d < lastTime {
		// 	lastTime = d
		// 	lasti = i
		// }
		if i == 0 {
			max = times[i] % 10 //最初の料理を仮に最後に注文する料理とする
		}
		if d == 0 {
			sum += times[i]
		} else {
			sum += times[i] + (10 - d)
			//times[i]=19なら19+(10-(19%10))で10分単位の切り上げが可能
		}

		if d != 0 && (10-d) > (10-max) { //maxより10分単位へ切り上げる際の値が大きい場合は、それをmaxとする
			max = times[i] % 10
		}

	}

	if max == 0 { //注文した料理が全て10分単位で注文可能な場合
		fmt.Println(sum)
	} else { //そうでない場合は、合計値から切り上げた分を引く
		fmt.Println(sum - (10 - max))
	}
}


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


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

#define mod 1000000007

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

typedef pair<int, int>P;

P f(int x) {
	int first = 0;
	int last = x%10;
	while (x) { //same as x!=0
		first = x;
		x /= 10;
	}
	return P(first, last);
}

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

	map <P, int> freq;
	rep1(i, n+1) {
		P p = f(i);
		freq[p]++;
	}

	int ans = 0;

	rep1(i, n+1) {
		P p = f(i);
		P q(p.second, p.first);
		ans += freq[q];
	}
	print(ans);
}

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

using namespace std;

int main()
{
    const unsigned int M=1000000007;
    unsigned long long res=1;
    int n;
    cin>>n;
    for( int i=1;i<=n;i++){
        res=(res*i)%M;
    }
    cout<<res<<endl;

    return 0;
}

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

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            //SolveA(args);
            //SolveB(args);
            SolveC(args);
        }


        static void SolveA(string[] args)
        {
            string sz = (Console.ReadLine());
            int num = 0;
            for(int i=0;i<sz.Length;++i)
            {
                char c = sz[i];
                if( c == '+')
                {
                    num++;
                }else
                {
                    num--;
                }
            }
            Console.WriteLine(num);
        }
        static void SolveB(string[] args)
        {
            string sz = Console.ReadLine();
            long n = long.Parse(sz);
            int sn = 0;
            for (int i = 0; i < sz.Length; ++i)
            {
                int tmp = int.Parse(sz[i].ToString());
                sn += tmp;
            }
            if( n % sn == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        static void SolveC(string[] args)
        {
            string[] szArr = Console.ReadLine().Split(' ');
            int n = int.Parse(szArr[0]);
            int k = int.Parse(szArr[1]);
            szArr = Console.ReadLine().Split(' ');
            int[] a = new int[szArr.Length];

            for (int i = 0; i < szArr.Length; ++i)
            {
                a[i] = int.Parse(szArr[i]);
            }
            int min = 1;

            if (n == k)
            {
                min = 1;
            }
            else
            {
                min = (int)Math.Ceiling((double)(n - 1) / (k-1));
            }
            Console.WriteLine(min);
            
        }


    }

}


Measured memory_bytes: 16864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;cin>>n;
    vi a(n);
    rep(i,n) cin>> a[i];
    vector<vector<ll>> dp(n+1,vector<ll>(2,0));
    dp[0][0] = 0;
    dp[0][1] = -LINF;
    for(int i=0;i<n-1;i++){
        dp[i+1][0] = max(dp[i][0]+a[i],dp[i][1]-a[i]);
        dp[i+1][1] = max(dp[i][0]-a[i],dp[i][1]+a[i]);
    }
    //cout << dp[n-1][0] << " " << dp[n-1][1] << endl;
    ll ans = max(dp[n-1][0] + a[n-1],dp[n-1][1] - a[n-1]);
    cout << ans << endl;
}

Measured memory_bytes: 6144
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
opr = ["+++", "++-", "+--", "---", "-++", "--+", "-+-", "+-+"]

ABCD = list(input())

for op in opr:
	ans = []
	ABCD_ = ABCD.copy()
	op = list(op)
	ans.append(ABCD_.pop(0))
	while ABCD_ != []:
		ans.append(op.pop(0))
		ans.append(ABCD_.pop(0))
	if eval("".join(ans)) == 7:
		print("".join(ans), "=7", sep="")
		exit()

Measured memory_bytes: 13672
import java.util.Scanner;

import javax.lang.model.util.ElementScanner6;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        //System.out.println(input);
        String[] cinput = input.split("");

        for(int i=0; i<input.length(); i++)
        {
            if(cinput[i].charAt(0)>='a' && cinput[i].charAt(0)<='z')
            {
                //System.out.println(i+" "+cinput[i].charAt(0));
                cinput[i] = cinput[i].toUpperCase();
                //System.out.println(i+" "+cinput[i].charAt(0));
            }
            else if(cinput[i].charAt(0)>='A' && cinput[i].charAt(0)<='Z')
            {
                //System.out.println(i+"oh yeah "+cinput[i].charAt(0));
                cinput[i] = cinput[i].toLowerCase();
                //System.out.println(i+"oh yeah "+cinput[i].charAt(0));
            }
        }

        for(int i=0; i<input.length(); i++)
        {
            System.out.printf("%s",cinput[i]);
        }
        System.out.printf("\n");
        sc.close();
    }
}


Measured memory_bytes: 29692
n = int(input())

dp = [0]*(n+10)

for i in range(n+1):
    dp[i+1] = dp[i] +1
    

for i in range(1,n+1):
    k = 6
    while k <=n:
        if i-k>=0:
            dp[i] = min(dp[i],dp[i-k]+1)
            #print(dp[i-1],dp[i-k])
        k *=6

        #print(dp)
    k = 9
    while k <=n:
        if i-k>=0:
            dp[i] = min(dp[i],dp[i-k]+1)
           
        k *=9

print(dp[n])

Measured memory_bytes: 12700
#include<iostream>
#include<string>
#include<algorithm>
#include<map>

int main(){

    std::string s;
    std::cin >> s;

    std::map<char, size_t> m;

    for(size_t i = 0; i < s.size(); i++){
        if(m.find(s[i]) != m.end()){
            m[s[i]]++;
        }else{
            m.emplace(s[i], 1);
        }
    }

    size_t min = s.size();
    for(const auto& e : m){
        std::string prev = s;
        char goal = e.first;
        while(!std::all_of(prev.begin(), prev.end(), [goal](char c){ return c == goal; })){
            std::string next(prev.size() - 1, ' ');
            for(size_t i = 0; i < next.size(); i++){
                if(prev[i] == goal || prev[i + 1] == goal){
                    next[i] = e.first;
                }else{
                    next[i] = prev[i];
                }
            }

            prev = next;
        }

        min = std::min(min, s.size() - prev.size());
    }

    std::cout << min << std::endl;

    return 0;
}

Measured memory_bytes: 256
import functools

N = int( input() )
T = [ int( input() ) for _ in range(N) ]


# 最小公倍数を求めたい
# aとbの最小公倍数 = a*b / aとbの最大公約数
# 最大公約数 (Greatest Common Divisor)
def GCD( a, b ):
    if b == 0: return a
    return GCD(b, a%b)

# 最小公倍数 (Least Common Multiple)
def LCM( a, b ):
    return a*b // GCD(a,b)


ans = functools.reduce( LCM, T ) 
print( ans )

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <set>
#include <stack>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <string.h>
#include <array>

using namespace std;

const int maxn=105;

set < int > s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, x;
	cin >> x >> n;
	for(int i=-1; i<=101; i++){
		s.insert(i);
	}
	int a;
	for(int i=0; i<n; i++){
		cin >> a;
		s.erase(a);
	}
	int mini=1e9, val;
	for(set < int >::const_iterator it=s.begin(); it!=s.end(); it++){
		if(abs((*it)-x)<mini){
			val=*it;
			mini=abs(val-x);
		}
	}
	cout << val << '\n';
	return 0;
}

Measured memory_bytes: 3684
#include <iostream>
    #include <cstdio>
    using namespace std;
    int main() {
        int a, b;
        cin >> a >> b;
        int count = 0;
        for (int i = a; i <= b; i++) {
            if (i/10000 == i%10 && (i/1000)%10 == (i/10)%10) {
                count++;
            }
        }
        cout << count << endl;
    }

Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

    fastread();

    ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

    bool flag=false;

    string str;

    cin>>str;


   r=0;

    p=0;



    for(i=0; str[i]; i++)
    {
        if(str[i]=='g')
        {
            if(r>p)
            {
                p++;
                cnt++;
            }
            else r++;

        }
        else
        {
            if(r>p)
            {
                p++;

            }
            else r++,cnt--;
        }


    }

    cout<<cnt<<endl;
}



Measured memory_bytes: 3720
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint p=998244353;
int main(){
  int N;
  cin>>N;
  int a[N];
  REP(i,N)cin>>a[i];
  int sum=0;
  REP(i,N)sum+=a[i];
  vector<lint> dp(sum+1);
  vector<lint> dp1(sum+1);
  dp[0]=1;
  dp1[0]=1;
  REP(i,N){
    vector<lint> temp(sum+1);
    vector<lint> temp1(sum+1);
    REP(j,sum+1){
      temp[j]=dp[j]*2+(j>=a[i]?dp[j-a[i]]:0);
      temp[j]%=p;
      temp1[j]=dp1[j]+(j>=a[i]?dp1[j-a[i]]:0);
      temp1[j]%=p;
    }
    dp=temp;
    dp1=temp1;
    // for(auto e:dp)cerr<<e<<" ";
    // cerr<<endl;
  }
  lint M=0;
  FOR(i,(sum+1)/2,sum+1){
    M+=dp[i];
    M%=p;
  }
  if(sum%2==0)M-=dp1[sum/2];
  while(M<0)M+=p;
  lint ans=1;
  REP(i,N){
    ans*=3;
    ans%=p;
  }
  ans-=M*3;
  while(ans<0)ans+=p;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#include<algorithm>
#include<vector>
#include <functional>
#include<stdio.h>
using namespace std;

int main() {
	int a;
	cin >> a;
	if (a == 3 || a == 5 || a == 7)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
def main():
  h,t,*s=open(0)
  h,w=map(int,h.split())
  a=b=x=y=t[0]=='#'
  d=[(b,a)]
  d_add=d.append
  for i in range(1,w):
    f=t[i]=='#'
    b+=a^f
    a=f
    d_add((b,a))
  for s in s:
    f=s[0]=='#'
    y+=x^f
    b=y
    a=x=f
    p=[(b,a)]
    p_add=p.append
    for i in range(1,w):
      f=s[i]=='#'
      b+=a^f
      c,g=d[i]
      c+=f^g
      if b>c:b=c
      a=f
      p_add((b,a))
    d=p
  print(b+1>>1)
main()

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

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

  string ans;
  auto it = count.begin();

  if(count.size() > 3) ans = "No";
  else if(count.size() == 3) {
    if(it->second == next(it)->second && it->second == next(it, 2)->second && (it->first ^ next(it)->first) == next(it, 2)->first) ans = "Yes";
    else ans = "No";
  }
  else if(count.size() == 2) {
    if((it->second * 2 == next(it)->second  && (next(it)->first ^ next(it)->first) == it->first) || (it->second == next(it)->second * 2 && (it->first ^ it->first) == next(it)->first)) ans = "Yes";
    else ans = "No";
  }
  else if(count.size() == 1) {
    if(it->first == 0) ans = "Yes";
    else ans = "No";
  }

  cout << ans << endl;
}

Measured memory_bytes: 3840
// ███▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓╬╬╬╬╬╬▓█
// ███▓███████▓▓╬╬╬╬╬╬╬╬╬╬╬╬▓███▓▓▓▓█▓╬╬╬▓█
// ███████▓█████▓▓╬╬╬╬╬╬╬╬▓███▓╬╬╬╬╬╬╬▓╬╬▓█
// ████▓▓▓▓╬╬▓█████╬╬╬╬╬╬███▓╬╬╬╬╬╬╬╬╬╬╬╬╬█
// ███▓▓▓▓╬╬╬╬╬╬▓██╬╬╬╬╬╬▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬╬╬╬▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓███████▓▓███▓╬╬╬╬╬╬▓███████▓╬╬╬╬▓█
// ████████████████▓█▓╬╬╬╬╬▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬█
// ███▓▓▓▓▓▓▓╬╬▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ████▓▓▓╬╬╬╬▓▓▓▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// ███▓█▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓▓█▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█
// █████▓▓▓▓▓▓▓██▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// █████▓▓▓▓▓████▓▓▓█▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓█▓▓▓▓██▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
// ████▓▓███▓▓▓▓▓▓▓██▓╬╬╬╬╬╬╬╬╬╬╬╬█▓╬▓╬╬▓██
// █████▓███▓▓▓▓▓▓▓▓████▓▓╬╬╬╬╬╬╬█▓╬╬╬╬╬▓██
// █████▓▓█▓███▓▓▓████╬▓█▓▓╬╬╬▓▓█▓╬╬╬╬╬╬███
// ██████▓██▓███████▓╬╬╬▓▓╬▓▓██▓╬╬╬╬╬╬╬▓███
// ███████▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬████
// ███████▓▓██▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓████
// ████████▓▓▓█████▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓█████
// █████████▓▓▓█▓▓▓▓▓███▓╬╬╬╬╬╬╬╬╬╬╬▓██████
// ██████████▓▓▓█▓▓▓╬▓██╬╬╬╬╬╬╬╬╬╬╬▓███████
// ███████████▓▓█▓▓▓▓███▓╬╬╬╬╬╬╬╬╬▓████████
// ██████████████▓▓▓███▓▓╬╬╬╬╬╬╬╬██████████
// ███████████████▓▓▓██▓▓╬╬╬╬╬╬▓███████████
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<ll,int> pli;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ff(i,a,b)  for(int i=a;i<=int(b);i++)
#define fr(i,a,b)  for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
string ys = "Yes\n";
string no = "No\n" ;
const double EPS = 1e-6;
const int inf = 2e9;
const ll M  = 1e9+7 ;
const int N = 100100;
/////  for (int i= -inf ; i < inf ; i++)   Hi  :P

string s;
int n;
int ans = 1e9;
int cnt(int n)
{
    int r = 0;
    while(n)
    {
        r += n%10;
        n/=10;
    }
    return r;
}
main()
{
    speed;
    cin >> n;
    ff(i,1,n-1)
    {
        int t = cnt(i)+cnt(n-i);
        if (t<ans)
        {
            ans = t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  vector<P> vec;
  ll ans=0;
  ll n;
  cin>>n;
  vec.push_back(P(0,0));
  set<ll> st,st_;
  for(int i=1;i<=n;i++){
    ll a;
    cin>>a;
    vec.push_back(P(a,i));
  }
  vec.push_back(P(n+1,n+1));
  sort(vec.begin(),vec.end());
  st.insert(n+1);
  st_.insert(0);
  for(int i=1;i<=n;i++){
    ll idx=vec[i].second;
    ll k=*(st.upper_bound(idx));
    ll j=*(st_.upper_bound(-idx));
    j*=-1;
    ans+=i*(idx-j)*(k-idx);
  //  cout<<vec[i].first<<" "<<vec[i].second<<" "<<i-j<<" "<<k-i<<" "<<i*(i-j)*(k-i)<<endl;
    st.insert(idx);
    st_.insert(-idx);
  }

  cout<<ans<<endl;
}


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

using namespace std;

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

	int n;
	cin >> n;

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

	vector<int> ans(n);

	for(int j = 30; j >= 0; --j) {
		vector<int> b(n);
		for(int x = 0; x < 2; ++x) {
			for(int i = 0; i < n; ++i) {
				b[i] = x ^ (a[i] >> j & 1);
			}
			int s = 0;
			for(int i = 0; i < n; ++i) {
				s ^= b[i];
			}
			if(s == x) {
				break;
			}
		}
		for(int i = 0; i < n; ++i) {
			ans[i] += b[i] << j;
		}
	}

	for(int i : ans) {
		cout << i << ' ';
	}

	cout << '\n';

	return 0;
}


Measured memory_bytes: 5648
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}

int main() {
	string s;cin>>s;bool ok=0;
	rep(l,0,SZ(s)-1)rep(r,l-1,SZ(s)-1){//empty
		string t;rep(i,0,SZ(s)-1)if(!(i>=l&&i<=r))t+=s[i];
		ok|=t=="keyence";
	}
	if(ok)puts("YES");else puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long long square(long long n)
{
    return n*n;
}
long long bigmod(long long b,long long p,long long m)
{
    //long long m=1000000007;
    if(p==0)
        return 1;
    else if(p%2==0)
        return square(bigmod(b,p/2,m))%m;
    else
        return ((b % m)*bigmod(b,p-1,m))%m;
}
int main()
{
    long long b,p,m,a,i;
    while(scanf("%lld%lld",&b,&p)==2)
    {
        a=bigmod(b,p,1000000007);
        printf("%lld\n",a);
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;
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 N;

// DP テーブル
double dp[310][310][310];
double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;
    
    double res = 0.0;
    if (i > 0) res += rec(i-1, j, k) * i;
    if (j > 0) res += rec(i+1, j-1, k) * j;
    if (k > 0) res += rec(i, j+1, k-1) * k;
    res += N;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;
}

int main() {
    cin >> N;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a == 1) ++one;
        else if (a == 2) ++two;
        else ++three;
    }
    
    // 初期化
    memset(dp, -1, sizeof(dp));

    // 答え
    cout << fixed << setprecision(10) << rec(one, two, three) << endl;
}

Measured memory_bytes: 233088
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, N, a, b, c;
  cin >> K >> N;
  a = 0;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int j = 0; j < N - 1; j++) {
    b = vec.at(j + 1) - vec.at(j);
    if (a < b) {
      a = b;
    }
  }
  c = K + vec.at(0) - vec.at(N - 1);
  if (a < c) {
    a = c;
  }
  cout << K - a << endl;
}

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

int main() {
    
    int N, A, B, plan_1, plan_2;
    cin >> N >> A >> B;
  
    plan_1 = N * A;
    plan_2 = B;
    
    if (plan_1 < plan_2){
        cout << plan_1 << endl;
    } else {
        cout << plan_2 << endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	string str;
	string base = "aiueo";
	cin >> str;
	if (base.find(str) <= 4) {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
            var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var a = firstLine[0];
			var b = firstLine[1];
			var c = firstLine[2];

			if(a + b == c || a + c == b || b + c == a)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}


Measured memory_bytes: 11220
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;


ll MOD = 1000000007;


int main()
{
	int A, B, C;
	cin >> A >> B >> C;

	A -= B;
	C -= A;

	cout << max(0, C) << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
str_n = str(n)
keta = len(str_n)
res = 0
for num in range(1, keta, 2):
  res += 9 * (10 ** (num - 1))
if(keta % 2 == 1):
  last = 0
  if(keta == 1):
    last = n
  else:
    last = (n - 10 ** len(str_n[1:])) + 1
  res += last
print(res)

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

#define Int register int
#define mod 1000000007
#define MAXN 100005

template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}
template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}
template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}

int n,m,X[MAXN];
int mul (int a,int b){return 1ll * a * b % mod;}
int dec (int a,int b){return a >= b ? a - b : a + mod - b;}
int add (int a,int b){return a + b >= mod ? a + b - mod : a + b;}
int qkpow (int a,int b){int res = 1;for (;b;b >>= 1,a = mul (a,a)) if (b & 1) res = mul (res,a);return res;}

struct Matrix{
	int res[3][3];
	Matrix(){memset (res,0,sizeof (res));}
	int* operator [](int key){return res[key];}
	Matrix operator * (const Matrix &b)const{Matrix New;for (Int i = 0;i < 3;++ i) for (Int j = 0;j < 3;++ j) for (Int k = 0;k < 3;++ k) New[i][j] = add (New[i][j],mul (res[i][k],b.res[k][j]));return New;}
}MA,MB,Ans;

Matrix qkpow (Matrix a,int b){
	Matrix New;for (Int i = 0;i < 3;++ i) New[i][i] = 1;
	for (;b;b >>= 1,a = a * a) if (b & 1) New = New * a;
	return New;
}

signed main(){
	read (n,m);
	MA[0][0] = MA[0][2] = MA[1][1] = MA[1][2] = MA[2][2] = 1,MA[0][1] = 2;
	MB = MA;MB[0][0] ++,MB[1][0] ++,MB[2][0] ++,Ans[0][0] = Ans[1][1] = Ans[2][2] = 1;
	for (Int i = 1;i <= m;++ i) read (X[i]);X[++ m] = n;
	for (Int i = 1;i <= m;++ i) Ans = Ans * qkpow (MB,X[i] - X[i - 1] - 1) * MA;
	write (Ans[0][2]),putchar ('\n');
	return 0;
}

Measured memory_bytes: 3928