akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll x = 0;
    rep(i, N)
    {
        if (i % 2)
        {
            x -= A[i];
        }
        else
        {
            x += A[i];
        }
    }

    vector<ll> ans(N);
    ans[0] = x / 2;
    rep(i,N-1)
    {
        ans[i +1] = A[i] - ans[i];
    }
    rep(i, N) { ans[i] *= 2; }
    rep(i, N) printf("%d%c", ans[i], i == N - 1 ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/


const int MAX = 100005;
int mod;

void chmod(int &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
 
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int modpow(int x, int n){
    if(n == 0) return 1;
    if(x == 0) return 0;
    
    int res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}


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

    cin >> mod;
    int p = mod;
    vector<int> a(p);
    for(int i=0; i<p; ++i) cin >> a[i];
    vector<int> ans(p, 0);
    COMinit();

    for(int j=0; j<p; ++j) if(a[j] == 1){
        for(int k=0; k<p; ++k){
            if(k == 0){
                if((p-1)%2 == 0) ans[0] += 1-modpow(j, p-1-k);
                else ans[0] += 1+modpow(j, p-1-k);
            }
            else{
                if((p-1-k)%2 == 0)  ans[k] += -(COM(p-1, k)*modpow(j, p-1-k));
                else ans[k] += COM(p-1, k)*modpow(j, p-1-k);
            }
            chmod(ans[k]);
        }
    }

    for(int i=0; i<p; ++i){
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;

	return 0;
}


Measured memory_bytes: 2816
<?php


[$N, $G[1], $G[2], $G[3]] = fscanf(STDIN, "%d%d%d%d");
$map = [];
for($i=0;$i<$N;$i++){
    [$map[$i]] = fscanf(STDIN, "%d");
}
$ans = PHP_INT_MAX;
for($i=0;$i<4**$N;$i++){
    $four = (string)base_convert($i, 10, 4);
    $arr = array_reverse(str_split($four));
    $list = array_fill(1,3,[]);
    foreach($arr as $key => $value){
        $list[$value][] = $key;
    }
    $mp = 0;
    for($j=1;$j<=3;$j++){
        if(count($list[$j]) === 0){
            continue 2;
        }elseif(count($list[$j]) === 1){
            $mp += abs($G[$j] - $map[$list[$j][0]]);
        }else{
            $count = -1;
            $sum = 0;
            foreach($list[$j] as $ckey => $cvalue){
                $sum += $map[$cvalue];
                $count++;
            }
            $mp += $count * 10;
            $mp += abs($G[$j] - $sum);
        }

    }

    $ans = min($mp, $ans);




}
echo $ans;

Measured memory_bytes: 16252
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define pii pair<int,int>
#define pll pair<ll, ll>
#define forn(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

int n;
int a[5000];
ll ds[4000][4000][2];

ll dp(int s, int e, int p){
	if(s > e) return 0;
	if(ds[s][e][p] != -1) return ds[s][e][p];
	ll &ans = ds[s][e][p];
	if(p == 0) ans = max(a[s] + dp(s + 1, e, 1), a[e] + dp(s, e - 1, 1));
	else ans = min( - a[s] + dp(s + 1, e, 0),  - a[e] + dp(s, e - 1, 0));
	return ans;
}
 
int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	forn(i, 0, n - 1){
		cin >> a[i];
	}
	memset(ds, -1, sizeof(ds));
	cout << dp(0, n - 1, 0) << "\n";
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int x;
  cin >> x;
  if (x >= 2000) {
    cout << 1 << endl;
    return;
  }
  repc(a, 20) repc(b, 20) repc(c, 20) repc(d, 20) repc(e, 20) repc(f, 20) {
    int sum = a * 100 + b * 101 + c * 102 + d * 103 + e * 104 + f * 105;
    if (x == sum) {
      cout << 1 << endl;
      return;
    }
  }
  cout << 0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int white = 0;
    rep(i,h) rep(j,w) if (s[i][j] == '.') white++;

    queue<P> q;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    q.push(make_pair(0,0));
    dist[0][0] = 0;
    while(!q.empty()){
        P v = q.front(); q.pop();

        for(int i = 0; i < 4; i++){
            int x = v.first + dx[i], y = v.second + dy[i];
            if (x >= w || y >= h || x < 0 || y < 0) continue;
            if (s[y][x] == '#') continue;
            if (dist[y][x] != -1) continue;
            q.push(make_pair(x, y));
            dist[y][x] = dist[v.second][v.first] + 1;
        }
    }

    if (dist[h-1][w-1] == -1) cout << -1 << endl;
    else cout << white - dist[h-1][w-1] - 1 << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
ll k,a,b;
cin>>k>>a>>b;
bool z=false;
for(ll i=a;i<=b;i++)if(i%k==0)z=true;
if(z)cout<<"OK"<<endl;
else cout<<"NG"<<endl;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A * B, C * D) << endl;
}



Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long


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

  if( a <= 0 && b >= 0 ){
    cout << "Zero\r\n";
  }else if(b<0){
    if((b-a)%2){
      cout << "Positive\r\n";
    }else{
      cout << "Negative\r\n";
    }
  }else{
    cout << "Positive\r\n";
  }

}


Measured memory_bytes: 256
import sys

# import numpy as np


def main():
    f = sys.stdin.buffer
    N, K = map(int, f.readline().split())
    H = list(map(int, f.readline().split()))
    dp = [0] * N
    for i in range(1, N):
        dp[i] = min(
            dp[i - k - 1] + abs(H[i] - H[i - k - 1]) for k in range(K) if i - k - 1 >= 0
        )
    print(dp[-1])


if __name__ == "__main__":
    main()

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


// dp[i][j]: j chars after i times of typing
li dp[5050][5050];

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

	rep(i, 5050)dp[0][i] = 0;
	dp[0][0] = 1;
	repp(i, 1, n + 1) {
		dp[i][0] = (dp[i - 1][1] + dp[i - 1][0]) % MOD;
		repp(j, 1, 5050 - 1) {
			dp[i][j] = (dp[i - 1][j + 1] + dp[i - 1][j - 1] * 2) % MOD;
		}
		dp[i][5049] = dp[i - 1][5048] % MOD;
	}
	li res = dp[n][sz(s)];
	li inv2 = (MOD + 1) / 2;
	rep(i, sz(s))res = (res * inv2) % MOD;
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 197632
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
int T = 1;
int cntb, cnta, cntab;
int fac[maxn];

void solve() {
    fac[0] = 1;
    rep(i, 1, 2e5 + 5)fac[i] = fac[i - 1] * 2 % mod;
    map<pii, int> mp;
    int n;
    cin >> n;
    rep(i, 1, n) {
        int a, b;
        cin >> a >> b;
        if (a * b == 0) {
            if (a == 0 && b == 0)
                ++cntab;
            else if (a == 0)
                ++cnta;
            else if (b == 0)
                ++cntb;
            continue;
        }

//        if (a * b > 0) {
//            a = abs(a), b = abs(b);
//            int gcd = __gcd(a, b);
//            ++mp[pair<int,int>(a / gcd, b / gcd)];
//        } else {
//            a = abs(a), b = abs(b);
//            int gcd = __gcd(a, b);
//            ++mp[pair<int,int>(-a / gcd, b / gcd)];
//        }

        int gcd = __gcd(a, b);
        a /= gcd, b /= gcd;
        if (a * b > 0) {
            a = abs(a), b = abs(b);
            ++mp[pair<int,int>(a, b)];
        } else {
            a = abs(a), b = abs(b);
            ++mp[pair<int,int>(-a, b)];
        }

    }
    int ans = (fac[cnta] + fac[cntb] - 1 + mod) % mod;
    for (auto &to:mp) {
        if (to.second == 0)
            continue;
        int a = to.first.first, b = to.first.second;
        int num = to.second;
        pii j = a > 0 ? pii(-b, a) : pii(b, -a);
        if (mp[j] == 0)
            ans = ans * fac[num] % mod;
        else
            ans = ans * (fac[num] + fac[mp[j]] - 1 + mod) % mod;
        //cout << a << ' ' << b << ' ' << ans << ' ' << mp[j] << endl;
        mp[j] = to.second = 0;
    }
    cout << (ans - 1 + cntab + mod) % mod;
}

signed main() {
    start;
    //cout<<__gcd(4,6)<<' '<<__gcd(-4,6)<<' '<<__gcd(4,-6)<<' '<<__gcd(-4,-6)<<endl;
    while (T--)
        solve();
    return 0;
}


Measured memory_bytes: 30000
H,W,D=map(int,input().split())

def main():
  A=list()
  for h in range(H):
    for w,a in enumerate(map(int,input().split())):
      A.append([a,h,w])

  A=sorted(A, key=lambda x:x[0])

  B=[0]*(H*W)
  for i in range(D):
    while i+D<W*H:
      B[i+D]=B[i]+abs(A[i][1]-A[i+D][1])+abs(A[i][2]-A[i+D][2])
      i+=D

  for q in range(int(input())):
    l,r=map(int,input().split())
    print(B[~-r]-B[~-l])

main()


Measured memory_bytes: 25036
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	long long k;
	cin >> k;

	cout << 50 << endl;
	if(k <= 50){
		vector<long long> ans(50, 50);
		k = 50 - k;
		rep(i,k){
			ans[i] -= 50;
			rep(j,50){
				if(i == j) continue;
				ans[j]++;
			}
		}

		cout << ans << endl;
	}else{
		long long t = k / 50;
		k = k % 50;

		vector<long long> ans(50, t + 50 - 1);
		rep(i,k){
			ans[i] += 50;
			rep(j,50){
				if(i == j) continue;
				ans[j]--;
			}
		}

		cout << ans << endl;
	}
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int h[n];
    rep(i,n)cin>>h[i];
    map<int,bool>mp;
    rep(i,n)mp[i]=true;
    
    rep(i,m){
        int j,k;
        cin>>j>>k;
        if(h[j-1]>h[k-1])mp[k-1]=false;
        else if(h[j-1]==h[k-1]){
            mp[j-1]=false;
            mp[k-1]=false;
        }
        else mp[j-1]=false;
    }

    int sum=0;
    rep(i,n)if(mp[i])sum++;
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 8684
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vi A;
  rep(i,N) {
    int x;
    cin >> x;
    if(x<K) {
      A.push_back(x);
    }
  }
  N = sz(A);
  
  vvi dpr(N+1,vi(K,0));
  
  dpr[N][0]=1;
  drep(i,N) {
    rep(j,K) {
      if(j-A[i]<0) {
        dpr[i][j]=dpr[i+1][j];
      } else {
        dpr[i][j]=dpr[i+1][j]|dpr[i+1][j-A[i]];
      }
    }
  }
  vvi accr(N+1,vi(K+1,0));
  rep(i,N+1) {
    rep(j,K) {
      accr[i][j+1] = accr[i][j]+dpr[i][j];
    }
  }
  dpr.clear();
  dpr.shrink_to_fit();
  // [l,r)
  auto exists = [&](int i,int l,int r) -> bool {
    if(l>=r) return false;
    return (accr[i][r]-accr[i][l])>0;
  };
  vvi dpl(N+1,vi(K,0));
  dpl[0][0]=1;
  rep(i,N) {
    rep(j,K) {
      if(j-A[i]<0) {
        dpl[i+1][j]=dpl[i][j];
      } else {
        dpl[i+1][j]=dpl[i][j]|dpl[i][j-A[i]];
      }
    }
  }
  int ans = 0;
  rep(i,N) {
    int l = i;
    int r = i+1;
    bool need=false;
    rep(k,K) {
      // [K-A[i],K)
      // l := [k,k+1)
      // r := [K-A[i]-k,K-k)
      if(!dpl[l][k]) continue;
      if(exists(r,K-A[i]-k,K-k)) {
        need=true;
        break;
      }
    }
    if(!need) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 199068
#include <bits/stdc++.h>
    using namespace std;
    
    int main() {

        string S;
        bool flag = false;
        string hitati="hi";

        cin >> S;

        for(int i = 0; i<5;i++){

            if (S==hitati) flag=true;

            hitati = hitati + "hi";
            //cout << hitati << endl;
        }

        if(flag){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }

    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 


//3111111111111111111111111111111






	void solve(){

		ini(n);
		vi morty;
		vi mortysort;
		FOR(i,0,n){
			ini(x);
			morty.push_back(x);
			mortysort.push_back(x);
		}
		sort(all(mortysort));
		int tmp  = 0;
		FOR(i,0,n){
			int x1 = lower_bound(all(mortysort),morty[i])-mortysort.begin();
			if((x1+i)%2)tmp++;
		}
		out(tmp/2);



	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 2036
#include<bits/stdc++.h>
//#define int long long
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define mi(N) int N; cin >> N;
#define ms(s) string s; cin >> s;
#define md(d) double d; cin >> d;
#define mv(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 998244353

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, char r) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << r << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

void Yay(bool b) {
	if (b)say("Yay!");
	else say(":(");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<typename T>
vector<vector<T>> fill_vector(int h, int w, T val) {
	vector<vector<T>> ret;
	vector<T> v(w, val);
	rep(h)ret.push_back(v);
	return ret;
}

template<typename T>
T maxi(vector<T> v) {
	T ret = v[0];
	Rep(1, v.size())maxi(ret, v[i]);
	return ret;
}

template<typename T>
T mini(vector<T> v) {
	T ret = v[0];
	Rep(1, v.size())mini(ret, v[i]);
	return ret;
}

signed main() {
	mi(n);
	ms(s);
	vi black(n + 1), white(n + 1);
	black[0] = 0;
	rep(n) {
		black[i + 1] = black[i] + (s[i] == '#');
	}
	white[n] = 0;
	for (int i = n - 1; i >= 0; --i) {
		white[i] = white[i + 1] + (s[i] == '.');
	}
	int ans = INT_MAX;
	rep(n + 1)mini(ans, white[i] + black[i]);
	say(ans);
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin >> n;
  if(n%2==1 || n<10){
    puts("0");
    return 0;
  }
    
  ll sum = 0;
  ll p = 10;
  while(p<=n){
    sum += n/p;
    p *= 5;
  }
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;
 
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;
 
int n,m,s[2001],t[2001],sumarray[2001]={0};

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    int out = 1;
 
    for (int i = 0; i < m; i++) {
        int temp = 0;
        for (int j = 0; j < n; j++) {
            if(j){
                if (t[i] == s[j]) {
                    int prev = temp + sumarray[j];
                    sumarray[j] += (temp + 1);
                  	sumarray[j]%=MOD;
                    temp = prev;
                } else {
                    temp += sumarray[j];
                }
            } else {
                temp += sumarray[j];
                if (t[i] == s[j]) {
                    sumarray[j] += 1;
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        out += sumarray[i];
        out %= MOD;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t A, B, K;
  cin >> A >> B >> K;
  if(K >= A + B) cout << 0 << ' ' << 0 << endl;
  else if(K <= A){
    cout << A - K << ' ' << B << endl;
  }
  else{
    cout << 0 << ' ' << A + B - K << endl;
  }
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, M;
  scanf("%d %d", &N, &M);
  vector<int> v(N + 5, 0);
  for (int i = 0; i < M; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == 1) { ++v[b]; }
    else if (b == N) { ++v[a]; }
  }
  string ans = "IMPOSSIBLE";
  for (int i = 1; i <= N; ++i) {
    if (v[i] == 2) {
      ans = "POSSIBLE";
      break;
    }
  }
  printf("%s\n", ans.c_str());
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;cin >> n;
  vector<vector<ll>> c(10,vector<ll>(10));
  for(int i=1;i<=n;i++){
    int h=i,t=i%10;
    while(h>9){
      h/=10;
    }
    c[h][t]++;
  }
  ll ans=0;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      ans+=c[i][j]*c[j][i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
    int n;
    int a[105];
    cin >> n;
    int aa = 0, b = 0;
    rep(i, n)cin >> a[i];
    sort(a, a + n, greater<int>());
    rep(i, n){
        if(i % 2 == 0)aa += a[i];
        else b += a[i];
    }
    cout << abs(aa - b) << endl;
    return 0;
}


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

int main() {
  int N, A, B, C, D, a, b, c, d;
  cin >> N;
  A = N / 1000;
  a = N % 1000;
  B = a / 100;
  b = a % 100;
  C = b / 10;
  c = b % 10;
  D = c / 1;
  d = c % 1;
  
  if (A == B && B == C) {
    cout << "Yes" << endl;
  }
  else if (B == C && C == D) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>


#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end());
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000

using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if (b < a*n)cout << b << endl;
	else cout << a*n << endl;

	return 0;
}



Measured memory_bytes: 256
import std;

// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}
T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}
void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;}
void scan(TList...)(ref TList Args){auto line = readln.split;
foreach (i,T;TList){T val=line[i].to!(T);Args[i]=val;}}
void dprint(TList...)(TList Args){debug{auto s=new string[](TList.length);
static foreach(i,a;Args) s[i]=text(a);s.map!(text).join(' ').writeln;}}
alias sread=()=>readln.chomp();enum MOD =10^^9+7;
alias PQueue(T,alias less="a<b") = BinaryHeap!(Array!T,less);
// dfmt on

void main()
{
    long X = lread();
    long r = 5000;
    foreach (a; -r .. r + 1)
        foreach (b; -r .. r + 1)
            if ((a ^^ 5) - (b ^^ 5) == X)
            {
                arywrite([a, b]);
                return;
            }
}


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

using namespace std;

int main()
{
  int n;
  long long i1,i2;

  scanf("%d",&n);
  scanf("%lld",&i1);
  for(int c=1;c<n;c++)
  {
    scanf("%lld",&i2);
    i1=(i1/__gcd(i1,i2))*i2;
  }
  printf("%lld\n",i1);
}


Measured memory_bytes: 256
#include <stdio.h>
int min(int n,int m){
    if(n<m) return n;
    else return m;
}
int main(void){
    int a,b,k,i,cnt=0;
    scanf("%d%d%d",&a,&b,&k);
    int ans = min(a,b);
    for(i=min(a,b);i>0;i--){
        if(k==cnt) break;
        if(a%i==0 && b%i==0){
            cnt++;
            ans = i;
        }
    }
    printf("%d",ans);

}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
#define NUMBER 10000

int isPrime(int x)
{
	int i;
    if (x == 2)
    return 1;
    else if ((x < 2) || (x % 2 == 0))
    return 0;

    for (i = 3; i <= sqrt(x); i+=2){
    if (x % i == 0)
    return 0;
    }
    return 1;

}


int main(void)
{
    int n, i;
    int count = 0;
    int num[NUMBER];
    
	scanf("%d", &n);

    for (i = 0; i < n; i++){
    scanf("%d", &num[i]);
    count = count + isPrime(num[i]);
    }

    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 2064
import scipy.sparse.csgraph as s
def b(u,x):c[u]=x;return all(d[u][v]^1or(c[u]!=c[v])&(c[v]or b(v,-x))for v in X)
N,*S=open(0)
N=int(N)
X=range(N)
d=[[i^j and(S[i][j]=='1'or N)for j in X]for i in X]
c=[0]*N
print(int(b(0,1)and s.floyd_warshall(d).max()+2)-1)


Measured memory_bytes: 16956
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define MAX_T 202
#define MAX_N 100

int main() {
#ifdef DEBUG

#endif
	int N;
	int A[200];
	int i;
	int flag = 0;
	int cnt = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	while (1) {
		for (i = 0; i < N; i++) {
			if (A[i] % 2 != 0) {
				flag = 1;
				break;
			}
			A[i] /= 2;
		}
		if (flag)break;
		cnt++;
	}

	printf("%d\n", cnt);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MEM 1000
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
long long t,n,m;
string s;
int main()
{
    sanic;
    cin >> n >> m;
    for(int i=1; i<=50000; i++){
        int a=i*0.08;
        int b=i*0.1;
        if(n==a && m==b){
            cout << i;
            return 0;
        }
    }
    cout << -1;
}


Measured memory_bytes: 256
A = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())

N = int(input())
B = []

for i in range(N):
    B.append(int(input()))
     
for b in B:
    for i in range(3):
        for j in range(3):
            if b == A[i][j]:
                A[i][j] = "x"
                
flag = False
            
for i in range(3):
    if A[i][0] == A[i][1] == A[i][2]:
        flag = True
        break
    if A[0][i] == A[1][i] == A[2][i]:
        flag = True
        break
    
if A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
    flag = True
    
if flag == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();
    let c: usize = iterator.next().unwrap().parse().unwrap();

    if a == b + c || b == c + a || c == a + b {
        return "Yes".to_string();
    }

    return "No".to_string();
}


Measured memory_bytes: 2172
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());

        var ans = N % N.ToString().Select(c => c - '0').Sum() == 0 ? "Yes" : "No";

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 28120
import java.util.Scanner;

public class Main {

public static void main(String args[]) {
	Scanner s = new Scanner(System.in);
	int W =s.nextInt();
	int H= s.nextInt();
	int x = s.nextInt();
	int y = s.nextInt();
	int r = s.nextInt();
	if(x + r <= W && y + r <= H && x>=r && y>=r) System.out.println("Yes");
	else System.out.println("No");
	s.close();
}
}



Measured memory_bytes: 26316
#include <iostream>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;

  int count = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < n; ++j) {
      if (i * j > n - 1) {
        break;
      }
      ++count;
    }
  }

  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] V = new int[N];
        for (int  i = 0; i < N; i++) {
            V[i] = sc.nextInt();
        }
        int[] C = new int[N];
        for (int  i = 0; i < N; i++) {
            C[i] = sc.nextInt();
        }
        int max = 0;
        for (int  i = 0; i < N; i++) {
            int diff = V[i] - C[i];
            if (diff > 0) {
                max += diff;
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 23380
/**
 * CardGame.cpp
 * Create:20180430
 * Description:
 * 【ゲーム内容】
 * nターン数、お互いに動物の名前が書かれたカードを出す。
 * 辞書順で大きいものがそのターンの勝者となり
 * 勝者には3ポイント、引き分けの場合はお互いに１ポイントが与えられる。
 */
#include <iostream>

/**
 * 勝敗判定関数
 * @param  strA プレーヤーAの入力
 * @param  strB プレーヤーBの入力
 * @return      -1:引き分け 0:Aの勝利 1:Bの勝利
 */
int judge(const std::string &strA, const std::string &strB){
  // 文字列の短いほうの長さを調べる
  int minSize;
  if (strA.size() <= strB.size()){
    minSize = strA.size();
  } else {
    minSize = strB.size();
  }

  for (int i = 0; i < minSize; i++){
    if (strA[i] > strB[i]){
      return 0;
    } else if (strA[i] < strB[i]){
      return 1;
    }
  }

  // ここまで一緒だった場合、文字列が長いほうが勝利する。
  if (strB.size() < strA.size()){
    return 0;
  }
  if (strA.size() < strB.size()){
    return 1;
  }

  // ここまで一緒だった場合、引き分け
  return -1;
}

int main(int argc, char* argv[]){
  int point[] = {0, 0};
  int n;

  std::cin >> n;
  for (int i = 0; i < n; i++){
    std::string playerA, playerB;
    std::cin >> playerA >> playerB;

    switch (judge(playerA, playerB)){
      case -1:
        point[0] += 1;
        point[1] += 1;
        break;
      case 0:
        point[0] += 3;
        break;
      case 1:
        point[1] += 3;
        break;
    }

  }

  std::cout << point[0] << " " << point[1] << std::endl;

  return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

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

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

	ll N, K, highest;
	ll A[114514], B[114514];
	cin >> N >> K;

	REP(i, 31){
		if((K >> i) & 1){
			highest = i;
		}
	}
	REP(i, N){
		cin >> A[i] >> B[i];
	}
	ll res = 0;
	REP(i, 31){
		ll nk = K;
		if(i != 0){
			if((K >> (i-1)) & 1){
				nk ^= (1 << (i-1));
				nk |= (1 << (i-1))-1;
			}
		}
		ll ret = 0;
		REP(j, N){
			if((A[j] | nk) == nk){
				ret += B[j];
			}
		}
		res = max(res, ret);
	}
	cout << res << endl;
}


Measured memory_bytes: 1792
N,K = map(int, input().split())
d = list(map(int, input().split()))
ans = 0
for le in range(min([K+1,N+1])):
    for ri in range(min([K-le+1,N+1])):
        if (le+ri)>K: break
        if (le+ri)>=N:
            cur = d
        else:
            cur = (d[0:le] + d[(N-ri):] if le!=0 else d[(N-ri):])
        t = K - le - ri
        for ti in range(t):
            if not cur: break
            mi = min(cur)
            if mi>0: break
            cur.remove(mi)
        ans = max(ans, sum(cur))
print(ans)

Measured memory_bytes: 3064
#pragma region
#ifndef LOCAL_DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <assert.h>
#include <math.h>

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define pb push_back
#define f(i, a, b) for (int i = a; i < b; i++)
#define revf(i, b, a) for (int i = b; i >= a; i--)
#define all(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define revsrt(v) sort(v.rbegin(), v.rend())
#define sp << ' ' <<
#define en << '\n'
#define precision(x) cout << fixed << setprecision(x);
#define fio                \
  ios::sync_with_stdio(0); \
  cin.tie(0);              \
  cout.tie(0);

using namespace std;

template <typename T, typename U>
ostream &operator<<(ostream &os, vector<pair<T, U>> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++)
    os << "{" << v[i].first << ", " << v[i].second << "}" en;
  return os;
}

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

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; i++) is >> v[i];
  return is;
}

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#pragma endregion

ll mod = 1e9 + 7;  // 998244353;
const int MAX = 1e5 + 5;

void preprocessing() {}

void solvetestcase() {
  string v;
  cin >> v;
  int n=v.size();
  ll ans = 0;
  f(i,0,n){
    ans += v[i] - '0';
  }
  cout << (ans % 9 ? "No" : "Yes") en;
}

int main() {
  fio;
  preprocessing();

  int t = 1;
  // UNCOMMENT FOR TESTCASES	\
	cin >> t;

  f(T, 1, t + 1) {
    // UNCOMMENT FOR CODEJAM,HACKERCUP	\
		cout << "Case #" << T << ": ";
    solvetestcase();
    cout.flush();
  }
};

/*
    AUTHOR:     KUNAL TAWATIA
    EDUCATION:  INDIAN INSTITUTE OF TECHNOLOGY, JODHPUR
*/

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

int main() {
  int hill[10];
  for(int i=0;i < 10;i++) {
    cin >> hill[i];
  }
  sort(hill,hill + 10);
  cout << hill[9] << endl
       << hill[8] << endl
       << hill[7] << endl;
}

Measured memory_bytes: 0
n=int(raw_input())
x=map(float,raw_input().split())
y=map(float,raw_input().split())
for p in [1,2,3]:
    d=sum([abs(x[i]-y[i])**p for i in xrange(len(x))])**(1.0/p)
    print '%6f' %(d)
print '%6f' %max([abs(x[i]-y[i]) for i in xrange(len(x))])

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

void print_ans(int n)
{
    if (n == 0)
        cout << "EQUAL" << endl;
    else if (n > 0)
        cout << "GREATER" << endl;
    else
        cout << "LESS" << endl;
}
int main()
{
    string a, b;
    cin >> a >> b;

    if (a.size() != b.size())
    {
        print_ans(a.size() - b.size());
        return 0;
    }
    
    int ans = 0;
    rep(i, 0, a.size())
    {
        ans = int(a[i]) - int(b[i]);

        if (ans != 0)
        {
            print_ans(ans);
            return 0;
        }
    }
    print_ans(0);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    map<ll, ll> mp;
    ll key;
    rep(i, n) {
        cin >> key;
        if(mp.find(key) != mp.end()) {
            mp.erase(key);
        } else {
            mp[key] = 1;
        }
    }
    cout << mp.size();
}

Measured memory_bytes: 7296
let () = Scanf.scanf "%d\n" @@ fun n ->
  let as_ = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun a -> a
  in
  let (prev, (incr, decr), (stock, yen)) =
    Array.fold_left (fun (prev, (incr, decr), (stock, yen)) a ->
      a, (if a = prev then (incr, decr) else (prev < a, a < prev)),
      if not decr && a < prev
      then (0, prev * stock + yen)
      else if not incr && prev < a
      then (stock + yen / prev, yen mod prev)
      else (stock, yen)) (as_.(0), (false, false), (0, 1000)) as_ in
  Printf.printf "%d\n" @@ prev * stock + yen

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

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int i;
    if(s.size()%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    for(i = 0;i < s.size()-1;i+= 2){
       if(!(s.at(i) == 'h' && s.at(i+1) == 'i')){
           cout << "No" << endl;
           return 0;
       }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int size, A, B, i, sumA, sumB;
	
	do {
		scanf ("%d", &size);
		if (size == 0) break;
		sumA = 0;
		sumB = 0;
		for (i = 0;i < size;i++) {
			scanf ("%d %d", &A, &B);
			
			if (A > B) {
				sumA += A + B;
			} else if (A < B) {
				sumB += A + B;
			} else {
				sumA += A;
				sumB += B;
			}
		}
		printf ("%d %d\n", sumA, sumB);
		
	} while (size != 0);
	
	return 0;
}

Measured memory_bytes: 596
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
# 盤面の受け取り
H,W = map(int,input().split())
board = []
for i in range(H):
    word = input()
    if "#" in word:
        board.append(list(word))

board = np.array(board).T
ans = []
for b in board:
    if "#" in b:
        ans.append(b)

ans = np.array(ans).T

for a in ans:
    print(*a,sep="")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 13852
a,b=map(int, input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

c = gcd(a,b)

if c == 1:
	print(1)
else:
	print(len(factorization(c))+1)

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(){
    ll X;
    cin >> X;
    for(ll a = -200; a <= 200; a++){
        for(ll b = -200; b <= 200; b++){
            if(pow(a, 5) - pow(b, 5) == X){
                cout << a << ' ' << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3540