akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main() {
	
	int N,M;
cin>>N>>M;
pairsl(C)

fx(N){
	pairspl(C)
}

sorts(C)
ll ans=0;
ll m=0;
int i=0;
while(true){
	
	if(m+C.at(i).second<M){
		m+=C.at(i).second;
		ans+=C.at(i).first*C.at(i).second;
	}
	else{
		ans+=C.at(i).first*(M-m);
		ce(ans)
		break;
	}
	i++;
}

}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    int count = 0;
    for(int i = 0; i <= n-3; i++){
        if(p[i] < p[i+1] && p[i+1] < p[i+2]){
            count += 1;
        }
        if(p[i] > p[i+1] && p[i+1] > p[i+2]){
            count += 1;
        }
    }
    cout << count;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

vector<vector<int>> v;


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

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "{" << p.first << ", " << p.second << "}";
}


using state = string::const_iterator;
struct Parser {
    int n;
    Parser(int n) : n(n){};

    vector<int> num(state &cur){
        ll x = 0;
        while(isdigit(*cur)) x = (x*10)+*(cur++)-'0';
        if(!x) x = 1;
        vector<int> p;
        if(isalpha(*cur)){
            p = v[(*(cur++)-'A')];
        }else if(*cur == '('){
            cur++;
            p = expr(cur);
            cur++;
        }else return {};
        vector<int> ret(n), a;
        vector<int> visited(n);
        for (int i = 0; i < n; ++i) {
            if(!visited[i]){
                a.clear();
                int c = i;
                while(!visited[c]){
                    visited[c] = 1;
                    a.emplace_back(c);
                    c = p[c];
                }
                int cc = x%a.size();
                for (int j = 0; j < a.size(); ++j) {
                    ret[a[j]] = a[cc];
                    if(++cc == a.size()) cc -= a.size();
                }
            }
        }
        return ret;
    }
    vector<int> expr(state &cur){
        auto ret = num(cur);
        while(*cur == '+'){
            cur++;
            auto a = num(cur), b = ret;
            for (int i = 0; i < a.size(); ++i) {
                ret[i] = b[a[i]];
            }
        }
        return ret;
    }
};


int main() {
    int n, k;
    cin >> n >> k;
    v = move(decltype(v)(26, vector<int>(n, 0)));
    for (auto &&j : v) iota(j.begin(),j.end(), 0);
    for (int _ = 0; _ < k; ++_) {
        char p; int h;
        cin >> p >> h;
        int x = p-'A';
        for (int j = 0; j < h-1; ++j) {
            for (int i = 0; i < n-1; ++i) {
                int f;
                cin >> f;
                if(f) swap(v[x][i], v[x][i+1]);
            }
        }
    }
    Parser parser(n);
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        string s;
        cin >> s;
        state cur = s.begin();
        auto ans = parser.expr(cur);
        for (int j = 0; j < ans.size(); ++j) {
            printf("%d", ans[j]+1);
            putchar(j+1 == ans.size() ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 3372
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates

int main()
{
    ll x, y;
    cin >> x >> y;
    if (y % 2 == 0 && y / 2 >= x && 2 * x >= y / 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <stdio.h>
 int x[28][28];
 char y[28][28],i,j;
 int main(){
while(scanf("%s%s%s%s%s%s%s%s",&y[10],&y[11],&y[12],&y[13],&y[14],&y[15],&y[16],&y[17]) != EOF){
 for(i=10;i<18;i++){
	 for(j=0;j<8;j++){
		 x[i][j]=y[i][j]-'0';
		 x[i][j+10]=x[i][j];
	 }
 }
 for(i=10;i<18;i++){
 for(j=10;j<18;j++){
 if(x[i][j]==1 && x[i][j+1]==1 && x[i+1][j]==1 &&x[i+1][j+1]==1){ printf("A\n");}
 if(x[i][j]==1 && x[1+i][j]==1 && x[i+2][j]==1 &&x[i+3][j]==1){ printf("B\n");}
 if(x[i][j]==1 && x[i][j+1]==1 && x[i][2+j]==1 &&x[i][j+3]==1){ printf("C\n");}
 if(x[i][j]==1 && x[i][j+1]==1 && x[i-1][1+j]==1 &&x[i+1][j]==1){ printf("D\n");}
if(x[i][j]==1 && x[i][j+1]==1 && x[i+1][1+j]==1 &&x[i+1][j+2]==1){ printf("E\n");}
if(x[i][j]==1 && x[i][j+1]==1 && x[i-1][j]==1 &&x[i+1][j+1]==1){ printf("F\n");}
if(x[i][j]==1 && x[i][j+1]==1 && x[i+1][j]==1 &&x[i+1][j-1]==1){ printf("G\n");}
}}
}
return 0;
}

Measured memory_bytes: 528
#!/usr/bin/env python3

if __name__ == "__main__":
    n,m = map(int, input().split())
    l = list(map(int, input().split()))

    if n >= m:
        print("0")
    else:
        d = (m-1) * [0]

        l = sorted(l)
        for i in range(1,m):
            d[i-1] = l[i] - l[i-1]
        d = sorted(d, key=lambda x: -x)

        ans = 0
        for i in range(n-1):
            ans += d[i]

        print(l[-1] - l[0] - ans)




Measured memory_bytes: 13968
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define MAXN (20 + 5)
#define LL long long
using namespace std;
int ws(LL x)
{
	int re = 0;
	while (x /= 10)
		++re;
	return re;
}
int main()
{
	LL n;
	scanf("%lld", &n);
	int xn = ws(n);
	LL dq = 0, wz = 1, ans = 0;
	for (; dq + wz * 9 <= n; )
	{
		dq += wz * 9;
		wz *= 10;
		ans += 9;
	}
	for (int i = 9; i; i--)
	{
		if (dq + wz * i <= n)
		{
			ans += i;
			break;
		}
	}
	printf("%lld", ans);
	return 0;
}

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

int n;

int main(){
	cin>>n;
	if(n < 10){
		cout<<n<<endl;
	}else if(n < 100){
		cout<<9<<endl;
	}else if(n < 1000){
		cout<<9 + n - 100 + 1<<endl;
	}else if(n < 10000){
		cout<<909<<endl;
	}else if(n < 100000){
		cout<<909 + n - 10000 + 1<<endl;
	}else{
		cout<<90909<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000;
#define MOD 1000000007LL;
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
typedef int64_t i64;

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

long long int A, B, K; cin >> A >> B >> K;

if (A > K)
    cout << A - K << " " << B  << endl;
else 
    cout << 0 << " " << max(0LL, B - (K - A)) << endl;;






}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
       mut a:[i64;n],
    }
    a.sort();
    println!("{}", a[n - 1] - a[0]);
}


Measured memory_bytes: 2164
#include <cstdio>
#define MOD 1000000007
typedef long long ll;
ll fact[100005], inv[100005], dp[25][100005]; 
int arr[25]; 
inline ll quick_pow(ll a, int n)
{
	ll res = 1; 
	while (n)
	{
		if (n & 1)
			res = res * a % MOD; 
		a = a * a % MOD; 
		n >>= 1; 
	}
	return res; 
}
inline ll C(int n, int m)
{
	return fact[n] * inv[m] % MOD * inv[n - m] % MOD; 
}
int main()
{
	// freopen("ARC093-F.in", "r", stdin); 
	int n, m; 
	scanf("%d%d", &n, &m); 
	for (int i = 0; i < m; i++)
		scanf("%d", arr + i); 
	fact[0] = inv[0] = 1; 
	for (int i = 1; i <= 1 << n; i++)
	{
		fact[i] = fact[i - 1] * i % MOD; 
		inv[i] = quick_pow(fact[i], MOD - 2); 
	}
	dp[m][0] = 1;
	for (int i = m; i; i--)
	{
		for (int x = 0; x < 1 << n; x++)
		{
			int rem = (1 << n) - arr[i - 1] - x; 
			(dp[i - 1][x] += dp[i][x]) %= MOD; 
			for (int j = n - 1; j >= 0; j--)
			{
				if (!(x & (1 << j)) && (1 << j) - 1 <= rem)
					(dp[i - 1][x | (1 << j)] += (MOD - C(rem, (1 << j) - 1)) * dp[i][x]) %= MOD; 
			}
		}
	}
	ll ans = 0; 
	for (int i = 0; i < 1 << n; i++)
	{
		ll x = dp[0][i]; 
		for (int j = 0; j < n; j++)
		{
			if (!(i & (1 << j)))
				x = x * inv[1 << j] % MOD; 
		}
		int rem = (1 << n) - i - 1; 
		x = x * fact[rem] % MOD; 
		(ans += x) %= MOD; 
	}
	for (int i = 0; i < n; i++)
		ans = ans * fact[1 << i] % MOD; 
	printf("%lld\n", ans * (1 << n) % MOD);
	return 0; 
}


Measured memory_bytes: 16384
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a == b && b != c) {cout << "Yes" << endl;;return 0;}
    if(a == c && c != b) {cout << "Yes" << endl;;return 0;}
    if(c == b && b != a) {cout << "Yes" << endl;;return 0;}
    cout << "No" << endl; return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
//ll MOD = 1000000007;
ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 20){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};



//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}


ll Rank(ll N, ll M, vector<vector<ll>> A){
  ll next = 0;
  rep(i, M){
    for(ll j = next; j < N; j++){
      if(A[j][i]){
        swap(A[next], A[j]);
      }
    }
    if(!A[next][i]) continue;
    rep(j, N)if(j != next){
      if(A[j][i]){
        rep(k, M) A[j][k] ^= A[next][k];
      }
    }
    next++;
    if(next == N) break;
  }
  return next;
}

ll N, M;
vector<vector<ll>> A;


void solve(){
  COMinit();
  cin >> N >> M;
  A.resize(N);
  rep(i, N) A[i].resize(M);
  rep(i, N)rep(j, M) cin >> A[i][j];
  ll r = Rank(N, M, A);
  ll ans = 0;
  rep(i, r+1){
    ll add = comb(r, i) * pow_mod(2, r-i) % MOD;
    for(ll j = 1; j <= i; j += 2){
      ans += add * comb(i, j) % MOD;
      ans %= MOD;
    }
  }
  ans *= pow_mod(2, N + M - 2 * r);
  ans %= MOD;
  cout << ans << endl;
}


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


Measured memory_bytes: 6400
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N;

void solve() {

	cin >> N;

	ll ans, pans = 16;
	ll nA, nG, AG, AC, AT, GA, AnG, AGn;
	ll pnA = 4, pnG = 4, pAG = 1, pAC = 1, pAT = 1, pGA = 1, pAnG = 0, pAGn = 0;

	for (int i = 3; i <= N; i++) {
		nA = pans; nA %= MOD;
		nG = pans - pAC; nG %= MOD;
		AG = pnA; AG %= MOD;
		AC = pnA - pGA; AC %= MOD;
		AT = pnA; AT %= MOD;
		GA = pnG; GA %= MOD;
		AnG = pAT + pAG; AnG %= MOD;
		AGn = pAG; AGn %= MOD;

		ans = pans * 4 - pAG - pAC - pGA - pAnG - pAGn; ans %= MOD; ans += MOD; ans %= MOD;

		pnA = nA;
		pnG = nG;
		pAG = AG;
		pAC = AC;
		pAT = AT;
		pGA = GA;
		pAnG = AnG;
		pAGn = AGn;

		pans = ans;

	}

	cout << ans << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}

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

ll dfs(ll node, vector<ll>& fg, const unordered_multimap<ll, ll>& ABm, ll group_no)
{
    if (fg[node] != 0) {
        return 0;
    }
    fg[node] = group_no;

    ll num = 1;
    auto r = ABm.equal_range(node);
    for (auto r = ABm.equal_range(node); r.first != r.second; r.first++) {
        num += dfs(r.first->second, fg, ABm, group_no);
    }
    return num;
}

void main_()
{
    ll N, M, K;
    cin >> N >> M >> K;
    unordered_multimap<ll, ll> ABm;
    for (ll i = 0; i < M; i++) {
        ll A, B;
        cin >> A >> B;
        ABm.emplace(A, B);
        ABm.emplace(B, A);
    }
    unordered_multimap<ll, ll> CDm;
    for (ll i = 0; i < K; i++) {
        ll C, D;
        cin >> C >> D;
        CDm.emplace(C, D);
        CDm.emplace(D, C);
    }

    vector<ll> fg(N + 1); // 1-origin

    unordered_map<ll, ll> group_num_m;
    for (ll i = 1; i <= N; i++) {
        if (fg[i] == 0) {
            auto num = dfs(i, fg, ABm, i);
            group_num_m[i] = num;
        }
    }

    for (ll i = 1; i <= N; i++) {
        ll ans = group_num_m[fg[i]] - 1; // 自分を含む友達グループから自分を引いた数
        auto it = ABm.equal_range(i);
        ans -= distance(it.first, it.second); // 自分と直接友達関係を除く

        for (auto it = CDm.equal_range(i); it.first != it.second; it.first++) {
            auto block_i = it.first->second;
            if (fg[i] == fg[block_i]) {
                // ブロック関係の相手が友達グループに含まれていたらその分を除く
                ans--;
            }
        }
        cout << ans << " ";
    }
    cout << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 21832
fn main(){
    let line : Vec<_> = getline().trim().split(' ').map(|e| e.parse::<i64>().unwrap()).collect();
    
    println!("{}", line[0] - (line[1] - 1));
}

fn getline() -> String{
    let mut __ret=String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

vector<pair<int,int>>arr;
int dp[2005][2005];
int n;
int solve(int pos,int left, int right){
    if(pos>=n)return 0;
    if(left>right)return -1e10;
    int &ans=dp[left][right];

    if(ans!=-1)return ans;
    int maxi1=solve(pos+1,left+1,right)+abs(arr[pos].second-left)*arr[pos].first;
    int maxi2=solve(pos+1,left,right-1)+abs(arr[pos].second-right)*arr[pos].first;
    
    return ans=max(maxi1,maxi2);

}

int32_t main(){

    simplify
    cin>>n;
    arr.resize(n);
    for(int i=0;i<n;i++){
        cin>>arr[i].first;
        arr[i].second=i;
    }
    sort(arr.rbegin(),arr.rend());
    memset(dp,-1,sizeof dp);
    int ans=solve(0,0,n-1);
    cout<<ans;


    
    return 0;
}


Measured memory_bytes: 35180
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
               
    // }
    ll n;
    cin>>n;
    
    for(int i=-500;i<=500;i++)
    {
        for(int j=-500;j<=500;j++)
        {
            if(pow(i,5)-pow(j,5)==n)
            {
                cout<<i<<" "<<j;
                return 0;
            }
        }
    }
    //cout<<ans;
    
}

Measured memory_bytes: 4132
N,K=map(int,input().split())
A=list(map(int,input().split()))
data=[0 for i in range(0,41)]
for i in range(0,N):
    for j in range(0,41):
        data[j]+=(A[i]>>j)&1
X=0
subdata=[K>>i &1 for i in range(0,41)]
subdataK=[i for i in range(0,41) if subdata[i]==1]
ans=sum(K^A[i] for i in range(0,N))
for i in range(0,len(subdataK)):
    k=subdataK[i]#2^kの位で変化　2^0~2^k-1の位がフリー
    X=0
    for j in range(0,k):
        if N-data[j]>=data[j]:
            X+=2**j
    for j in range(k+1,41):
        X+=subdata[j]*2**j
    test=sum(X^A[i] for i in range(0,N))
    if test>ans:
        ans=test
print(ans)


Measured memory_bytes: 69080
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n;
  cin >> n;
  vs s(n);
  rep(i,n) cin >> s[i];
  vi a(26,inf);
  rep(i,n){
    //cout << i << endl;
    rep(j,26){
      char t = 'a'+j;
      int aa = count(s[i].cbegin(),s[i].cend(),t);
      //cout << aa << endl;
      a[j] = min(aa,a[j]);
    }
  }
  string ans = "";
  rep(i,26){
    rep(j,a[i]){
      char an = 'a'+i;
      ans.push_back(an);
    }
  }
  //rep(i,26) cout << a[i] << endl;
  cout << ans << endl;
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=a;i<b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define pb push_back
#define off 250555

int a,b;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    cin>>a>>b;
    if(a<=0&&b>=0) cout<<"Zero";
    else if(a<0&&b<0&&(b-a)%2==0) cout<<"Negative";
    else cout<<"Positive";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define all(x) (x).begin(), (x).end()

ll N;
ll M;

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

    cin >> N >> M;
    vector<ll> a(M);
    vector<ll> b(M);
    rep(i, M) {
        cin >> a[i];
        a[i]--;
        cin >> b[i];
        b[i]--;
    }

    vector<ll> p(N);
    rep(i, N) {
        p[i] = i;
    }

    bool d[N][N];
    memset(d, false, sizeof(d));
    rep(i, M) {
        d[a[i]][b[i]] = true;
        d[b[i]][a[i]] = true;
    }

    ll cnt = 0;
    do {
        if(p[0] != 0) {
            continue;
        }

        bool flag = true;

        rep(i, N-1) {
            if (!d[p[i]][p[i+1]]) {
                flag = false;
                break;
            }
        }

        if (flag) {
            cnt++;
        }
    } while(next_permutation(all(p)));

    cout << cnt << endl;
    return 0;
}


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

int main() {
	int a[10];
	for (int i = 0; i < 10; i++) {
		cin >> a[i];
	}
	sort(a, a + 10);
	reverse(a, a + 10);
	for (int i = 0; i < 3; i++) {
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
		
	fast;
  int a,b,c; cin >> a >> b >> c;
  if(a+b+c>=22) cout << "bust\n";
  else cout << "win\n";

	

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
#all_even = True
cnt = 0
while True:
    amari = 0
    for i in range(N):
        amari += A[i] % 2
        A[i] /= 2
        if amari != 0:
            print(cnt)
            exit()
    cnt += 1

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int INFTY = (1 << 20);

int cost[MAX][MAX];
int d[MAX][MAX];
int wall_num_count[MAX];

// 数字numにおける1の変換コストを見つけるダイクストラ
void dijkstra(int num) {
    priority_queue<pair<int, int> > PQ;
    int color[MAX];
    for (int i = 0; i < 10; i++) {
        d[num][i] = INFTY;
        color[i] = WHITE;
    }

    d[num][num] = 0;
    PQ.push(make_pair(0, num));
    color[num] = GRAY;

    while (! PQ.empty()) {
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;
        color[u] = BLACK;

        if (d[num][u] < f.first * (-1)) continue;

        for (int j = 0; j < MAX; j++) {
            int v = j;
            if (color[v] == BLACK) continue;
            if (d[num][v] > d[num][u] + cost[u][v]) {
                d[num][v] = d[num][u] + cost[u][v];
                PQ.push(make_pair(d[num][v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }
}

int main() {
    int H, W, A, magic_count = 0;
    cin >> H >> W;
    for (int i = 0; i < MAX; i++) {
        for (int j = 0; j < MAX; j++) cin >> cost[i][j];
    }

    for (int i = 0; i < MAX; i++) {
        wall_num_count[i] = 0;
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A;
            if (A != -1) wall_num_count[A]++;
        }
    }

    for (int i = 0; i < MAX; i++) {
        dijkstra(i);
    }

    for (int i = 0; i < MAX; i++) magic_count += d[i][1] * wall_num_count[i];

    cout << magic_count << endl;

    return 0;
}

Measured memory_bytes: 256
arr = []
for i in range(3):
	arr += [list(map(int,input().split()))]

flg = 0

for j in range(100):
	b1 = arr[0][0] - j
	a2 = arr[0][1] - b1
	a3 = arr[0][2] - b1
	b2 = arr[1][0] - j
	b3 = arr[2][0] - j
	if (arr[1][1] == b2 + a2) and \
	(arr[2][1] == b3 + a2) and \
	(arr[1][2] == b2 + a3) and \
	(arr[2][2] == b3 + a3):
		flg = 1

if flg == 1:
	print('Yes')
else:
	print('No')

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

void solve(int ans[10001]){
    for(int i=2; i<10001; i++){
        ans[i]=ans[i-1]+i;
    }
}

int main()
{
    int n,ans[10001];
    ans[1]=2;
    solve(ans);
    while(cin>>n,!cin.eof()){
        cout<<ans[n]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,a,b;cin>>n>>m;
  lvector v(n,0);
  rep(i,m) {
    cin>>a>>b;a--,b--;
    v[a]++,v[b]++;
  }
  bool isok=true;
  for(ll i:v) if(i%2==1) isok=false;
  print(isok?"YES":"NO");
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    long double a;
    long double b;
    cin>>a>>b;
    ll c = floor(a*b);
    cout<<c<<endl;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define int long long
#define sync ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 35001;
const int inf = 1e9 + 7;
const int MOD = 1e9 + 7;
const int P = 1e5 + 3;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
signed main() {
    sync;
#ifdef varex
    freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
#endif
    int n, k;
    cin >> n >> k;
    int ans = 0;
    while (n > 0) {
        n /= k;
        ans++;
    }
    cout << ans << '\n';
    return 0;
}

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

int main(void){
    int r, D, x;
    cin >> r >> D >> x;
    
    int ans, temp;
    temp = r*x-D;
    for(int i=0; i < 10; i++){
        ans= r*temp-D;
        cout << temp << endl;
        temp = ans;
    }
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> AC(N, 0);
  vector<int> WA(N, 0);
  for(int i = 0; i < M; i++){
    int tmp1;
    string tmp2;
    cin >> tmp1 >> tmp2;
    if(tmp2 == "AC"){
      if(AC[tmp1-1] == 0) AC[tmp1-1]++;
    }else{
      if(AC[tmp1-1] == 0) WA[tmp1-1]++;
    }
  }
  int ac = 0;
  int wa = 0;
  for(int i = 0; i < N; i++) ac += AC[i];
  for(int i = 0; i < N; i++){
    if(AC[i] != 0) wa += WA[i];
  }
  cout << ac << " " << wa << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include <set> 
#include <iterator> 
using namespace std;

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

  int a[n][3];
  for(int i=0;i<n;i++)
  cin>>a[i][0]>>a[i][1]>>a[i][2] ;

  int dp[n][3];

  dp[0][0]=a[0][0] ;
  dp[0][1]=a[0][1] ;
  dp[0][2]=a[0][2] ;

  for(int i=1;i<n;i++)
  {
    dp[i][0]=max( dp[i-1][1]+a[i][0] , dp[i-1][2]+a[i][0] );
    dp[i][1]=max( dp[i-1][0]+a[i][1] , dp[i-1][2]+a[i][1] );
    dp[i][2]=max( dp[i-1][1]+a[i][2] , dp[i-1][0]+a[i][2] );
  }
  cout<<max( max(dp[n-1][0] ,dp[n-1][1]) ,dp[n-1][2] )<<endl;
	return 0;
}

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

int main() {
  int n, d;
  cin >> n >> d;
  cout << (n + d * 2) / (d * 2 + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;
typedef pair<int,int> pr;

const int maxn=1e5+5;

int n,a[maxn];
LL s[maxn];

int main()
{
	scanf("%d",&n);
	fo(i,0,n) scanf("%d",&a[i]);
	fd(i,n,0) s[i]=s[i+1]+a[i];
	
	LL now=1, ans=0;
	fo(i,0,n)
	{
		if (i) now<<=1;
		now=min(now,s[i]);
		ans+=now;
		now-=a[i];
		if (now<0) {puts("-1"); return 0;}
	}
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 4928
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>

//また何回か同じの投げてみるか

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

char cn[300100], * ci = cn, ct;
int N, A, B, C;

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

	fread(cn, 1, 300100, stdin);
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	while ((ct = *ci++) >= '0') B = B * 10 + ct - '0';
	while ((ct = *ci++) >= '0') C = C * 10 + ct - '0';

	int kei = A + B + C;
	

	int OK = 1;
	char *di = cn;

	char* S = ci;

	for (int i = 0; i < 3 * N; i += 3) {
		if (S[i] == 'B') {
			if (C == 0 && B == 0) OK = 0;
			if (C == 1 && B == 1) {
				if (i == 3 * N - 3 || S[i + 4] == 'C') {
					*di++ = 'C';
					*di++ = '\n';
					C++;
					B--;
				}
				else {
					*di++ = 'B';
					*di++ = '\n';
					B++;
					C--;
				}
			}
			else if (C <= B) {
				*di++ = 'C';
				*di++ = '\n';
				C++;
				B--;
			}
			else {
				*di++ = 'B';
				*di++ = '\n';
				B++;
				C--;
			}
		}
		else if (S[i + 1] == 'B') {
			if (A == 0 && B == 0) OK = 0;
			if (A == 1 && B == 1) {
				if (i == 3 * N - 3 || S[i + 3] == 'A') {
					*di++ = 'A';
					*di++ = '\n';
					A++;
					B--;
				}
				else {
					*di++ = 'B';
					*di++ = '\n';
					B++;
					A--;
				}
			}
			else if (A <= B) {
				*di++ = 'A';
				*di++ = '\n';
				A++;
				B--;
			}
			else {
				*di++ = 'B';
				*di++ = '\n';
				B++;
				A--;
			}
		}
		else {
			if (A == 0 && C == 0) OK = 0;
			if (A == 1 && C == 1) {
				if (i == 3 * N - 3 || S[i + 4] == 'C') {
					*di++ = 'C';
					*di++ = '\n';
					C++;
					A--;
				}
				else {
					*di++ = 'A';
					*di++ = '\n';
					A++;
					C--;
				}
			}
			else if (A <= C) {
				*di++ = 'A';
				*di++ = '\n';
				A++;
				C--;
			}
			else {
				*di++ = 'C';
				*di++ = '\n';
				C++;
				A--;
			}
		}
	}
	if (OK) {
		printf("Yes\n");
		fwrite(cn, 1, di - cn, stdout);
	}
	else printf("No\n");

	Would you please return 0;
}

Measured memory_bytes: 1824
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;

signed main(){
    long long H,W;cin>>H>>W;
    long long ans=LLONG_MAX;
    long long Sx,Sy,Sz;
    REP(i,W-1){
        Sx=(i+1)*H;
        Sy=(H/2)*(W-i-1);
        Sz=((H+1)/2)*(W-i-1);
        ans=min(ans,max({Sx,Sy,Sz})-min({Sx,Sy,Sz}));
    }
    REP(i,H-1){
        Sx=(i+1)*W;
        Sy=(W/2)*(H-i-1);
        Sz=((W+1)/2)*(H-i-1);
        ans=min(ans,max({Sx,Sy,Sz})-min({Sx,Sy,Sz}));
    }
    ans=min(ans,min(((W+2)/3)*H-(W/3)*H,((H+2)/3)*W-(H/3)*W));
    cout<<ans<<endl;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

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

    vector<int> p;
    int temp = 0;
    for(int i=0; i<N; i++){
        cin >> temp;
        p.emplace_back(temp);
    }

    vector<double> SIGMA(N,0);
    REP(i,N){
        SIGMA[i] = (double)(1 + p[i])*p[i]/2.0;
    }

    double ans = 0;

    REP(i,K){
        ans += (SIGMA[i]/p[i]);
    }

    double out = ans;
    // cout << "[" << ans << ",";

    REP(i,N - (K - 1) - 1){
        ans -= (SIGMA[i]/p[i]);
        ans += (SIGMA[i+K]/p[i+K]);
        if(ans > out){
            out = ans;
        }
        // cout << ans << ",";
    }
    // cout << "]" << "\n";

    cout << setprecision(10);
    cout << out << "\n";

return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

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

	ll g = GCD(a, b);
	
	auto res = factorize(g);
	cout << res.size() + 1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100


int main()
{
  int i,j,a[N],n,v,c = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<=n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(a[j]<a[j-1]){
	v = a[j];
	a[j] = a[j-1];
	a[j-1] = v;
	c++;
      }/* 隣あう値が後ろ側に小さい値がある場合交換する */
    }/* n個目から交換の終っているi番目迄実行する */
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1)printf(" ");
  }
  printf("\n");
  printf("%d\n",c);
  return 0;
}




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

def seconds(a,b,c,d):
  if b<=c or d<=a:
    print(0)
    return
  else:
    st=max(a,c)
    go=min(b,d)
    print(go-st)
    return

seconds(a,b,c,d)

Measured memory_bytes: 9180
N=int(input())
A=list(map(int,input().split()))
B=[0]*N

def nanji(a,b):
    t = a
    count = 0
    while t % b == 0:
        t = t / b
        count = count +1
    return(count)

for i in range(N):
    B[i] = nanji(A[i],2)

print(sum(B))

Measured memory_bytes: 4148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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;
}

const ll mod = 1e9+7;

ll modpow(ll a,ll b){
    if(b == 0)return 1;
    if(b % 2 == 0){
        ll k = modpow(a,b/2);
        return k*k%mod;
    }else{
        return modpow(a,b-1)*a%mod;
    }
}
int main(void){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>add(n),sub(n);
    rep(i,n){
        int x,y;
        cin >> x >> y;
        add[i] = x+y;
        sub[i] = x-y;
    }
    sort(add.begin(),add.end());
    sort(sub.begin(),sub.end());

    ll ans = max(add[n-1]-add[0],sub[n-1]-sub[0]);
    cout << ans << endl;
    
    

    return 0;
}

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

using namespace std;

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int N, a[100];
int cnt[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	REP(i, N) cnt[a[i]]++;
	
	int mi = *min_element(a, a + N), ma = *max_element(a, a + N);
	
	bool ans = true;
	if (ma & 1 && cnt[mi] != 2) ans = false;
	if (!(ma & 1) && cnt[mi] != 1) ans = false;
	
	FOR(i, mi + 1, ma + 1) {
		if (cnt[i] < 2) ans = false;
	}
	
	puts(ans ? "Possible" : "Impossible");
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m,val;
cin>>n>>m>>val;
if(m>n)
    swap(n,m);
int x=val/n;
if(val%n!=0)
    x++;
cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
H, W = gets.split.map(&:to_i)
M = H.times.map { gets.chomp.chars }

mm = M.reject { |l| l.all? { |d| d == '.' } }.transpose.reject { |l| l.all? {|d| d == '.' } }.transpose

mm.each do |m|
  puts m.join
end

Measured memory_bytes: 2684
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    long long x, a, b;
    
    cin >> x >> a >> b;
    if(abs(x - a) > abs(x - b))
        cout << 'B' << endl;
    else
        cout << 'A' << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,q;
    cin >> n >> q;
    vector<vector<int>> edge;
    int a,b;
    rep(i,n+1){
        edge.push_back({});
    }
    rep(i,n-1){
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    long long val[n+1]={0};
    long long ans[n+1]={0};
    long long p,x;
    rep(i,q){
        cin >> p >> x;
        val[p]+=x;
    }
    ans[1]=val[1];
    queue<int> que;
    que.push(1);
    bool check[n+1];
    rep(i,n+1){
        check[i] = false;
    }
    check[1] = true;
    while(!que.empty()){
        int tmp = que.front();
        que.pop();
        for(int i = 0;i<edge[tmp].size();i++){
            int tem = edge[tmp][i];
            //cout << check[tem] << endl;
            if(!check[tem]){
                ans[tem]+=ans[tmp]+val[tem];
                que.push(tem);    
                check[tem] = true;            
            }
        }
    }
    rep(i,n){
        cout << ans[i+1] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 18668
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void)
{
  int N;
  scanf("%d", &N);
  if (N == 1) {
    printf("No");
  }
  else if (N == 2) {
    printf("No");
  }
  else if (N == 3) {
    printf("No");
  }
  else if (N == 5) {
    printf("No");
  }
  else if (N == 6) {
    printf("No");
  }
  else if (N == 9) {
    printf("No");
  }
  else if (N == 10) {
    printf("No");
  }
  else if (N == 13) {
    printf("No");
  }
  else if (N == 17) {
    printf("No");
  }
  else {
    printf("Yes");
  }
 return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  ll x; scanf("%lld", &x);
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &A[i]);
  }
  ll ans = 0;
  for (int i = 1; i < N; ++i) {
    ll sum = A[i - 1] + A[i];
    if (sum <= x) { continue; }
    ans += (sum - x);
    A[i] = max(0LL, A[i] - (sum - x));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000003
typedef long long ll;
using namespace std;

#define MAX_N 1000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r-1);
}

ll mod_pow(ll x,ll n){
  ll res=1;
  x%=MOD;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n/=2;
  }
  return res;
}

int main(){
  int Q;
  cin>>Q;
  
  setComb();
  for(int i=0;i<Q;i++){
    ll x,d,n;
    cin>>x>>d>>n;

    if(d==0){
      cout<<mod_pow(x,n)<<endl;
      continue;
    }

    x=x*inv[d]%MOD;
    x=(x+MOD)%MOD;

    
    if(x==0){
      cout<<0<<endl;
      continue;
    }

    if(n>=MOD||(x+n-1)>=MOD) cout<<0<<endl;
    else{
      ll ans=fac[(x+n-1)%MOD]%MOD;
      ans=ans*ifac[(x-1+MOD)%MOD]%MOD;
      ans=ans*mod_pow(d,n)%MOD;
      cout<<(ans+MOD)%MOD<<endl;
    }
    
  }

  return 0;
}


Measured memory_bytes: 24320
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)


























int main(){
    ll x, y;
    cin >> x >> y;
    for(ll i = 0; i <= x; i++){
        if(i * 2 + (x - i) * 4 == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3608
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

X = I()
num = 100
i=0
while True:
    i+=1
    num = int(num*1.01)
    if X<=num:
        break
print(i)


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  int ans = INT_MAX;
  for (int i=1; i<101; i++) {
    int res = 0;
    rep(j, n) {
      res += pow(i - x[j], 2);
    }
    ans = min(ans, res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256