akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void test_case() {
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i ++) {
		cin >> arr[i];
	}
	sort(arr, arr+n);
	int l = arr[0], r = arr[n - 1];
	long long answer = INT_MAX;
	for(int i = l; i <= r; i ++) {
		long long dollars = 0;
		for(int j = 0; j < n; j ++) {
			dollars += (arr[j] - i) * (arr[j] - i);
		}
		answer = min(dollars, answer);
	}
	cout << answer;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1; 
	//scanf("%d", &t);
	while(t --) {
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

using namespace std;

int main()
{
    int a, b, ans;
    cin >> a >> b;
    if (a % b == 0)
    {
        ans = 0;
    }
    else
    {
        ans = 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,C,D,H,K,L,M,N,T,W,X;
  string S;
  //cin >> N;
  vector<long long> vec(N);
  //for (i=0;i<N;i++) {
   //cin >> vec.at(i);
  //
  
  cin >> S;
   if (S[2]==S[3] && S[4]==S[5]) {cout << "Yes" << endl;}
   else {cout << "No" << endl;}
  
  
   
}

Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    int x;
    cin >> x;

    if (30 <= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    GVI(a,N);
    sort(ALL(a),greater<int>());
    int ans=0;
    for(int i=0;i<N;++i){
        if(i%2==0){
            ans+=a[i];
        }else{
            ans-=a[i];
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
MOD = int(1e9+7)


def div(a, b):
    return a * pow(b, MOD-2, MOD) % MOD


def fact(x):
    prev = 1
    ret = 1
    for i in range(1, x+1):
        ret = (i * prev) % MOD
        prev = ret
    return ret


def main():
    X, Y = map(int, input().split())
    N = (X+Y)//3
    if (X+Y) % 3 != 0 or X < N or Y < N:
        print(0)
        return
    ans = div(div(fact(N), fact(X-N)), fact(N*2-X))
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    int n, m;
    cin >> n >> m;
    vector <vector <int>> miti(n+1);
    int a,b;
    rep(i,m){
        cin >> a >> b;
        miti[a].push_back(b);
        miti[b].push_back(a);
    }

    queue <int> q;
    q.push(1);
    vector <int> ans(n+1,-1);
    int l;
    int qq;
    ans[1]=0;
    while(q.size()!=0){
        qq=q.front();
        //cout << qq << endl;
        q.pop();
        l=miti[qq].size();
        //cout << ans[miti[qq][0]] << endl;
        rep(i,l){
            if(ans[miti[qq][i]]==-1){
                //cout << miti[qq][i] << endl;
                q.push(miti[qq][i]);
                ans[miti[qq][i]]=qq;
            }
        }
    }
    cout << "Yes" << endl;
    rep(i,n-1){
        cout << ans[i+2] << endl;
    }

    return 0;
}

Measured memory_bytes: 10156
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, A[1 << 18], S;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) S ^= A[i];
	for (int i = 1; i <= N; i++) {
		if (i >= 2) cout << " "; cout << (S ^ A[i]);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n;
    cin >> n;
    vector<ll> x(n, 0), y(n, 0);
    rep1(i, n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y.begin(), y.end());
    ll ans = 0; 
    rep1(i, n){
        if (n%2 == 0){
            if (x[i] <= y[n/2-1]){
                cout << y[n/2] << endl;
            }
            else{
                cout << y[n/2-1] << endl;
            }
        }
    }
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

ll dp[3005][3005][4], E[3005][3005];

int main() {
    init();
    ll R, C, K;
    cin >> R >> C >> K;

    rep(i, K){
        ll r, c, k;
        cin >> r >> c >> k;
        E[r][c] = k;
    }

    repe(i, 1, R + 1) {
        repe(j, 1, C + 1) {
            rep(k, 4) dp[i][j][k] = dp[i][j - 1][k];
            rep(k, 4) chmax(dp[i][j][0], dp[i - 1][j][k]);
            if (E[i][j] == 0) continue;

            rep(k, 3) chmax(dp[i][j][k + 1], dp[i][j - 1][k] + E[i][j]);
            rep(k, 4) chmax(dp[i][j][1], dp[i - 1][j][k] + E[i][j]);
        }
    }

    // repe(i, 1, R + 1) repe(j, 1, C + 1) {
    //     err(i, j);
    //     verr(dp[i][j], 4);
    // }

    cout << *max_element(dp[R][C], dp[R][C] + 4) << endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*


fun main(args: Array<String>) {
    val inputReader = InputReadera168(System.`in`)

    val a = inputReader.nextLine().toInt()
    when (a%10) {
        2,4,5,7,9 -> {
            print("hon")
        }
        0,1,6,8 -> {
            print("pon")
        }
        3 -> {
            print("bon")
        }
    }
}

class InputReadera168(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream))
    private var tokenizer: StringTokenizer? = null

    init {
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = reader.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}


Measured memory_bytes: 34188
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        for(int i=0; i<n; i++){
            sum += sc.nextInt();
        }
        System.out.println(sum-n); 
    }
}


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

void check(int number) {
    int root_num = sqrt(number);
    int total = 0;

    for (int i = 1; i <= root_num; i++) {
        if (number % i == 0) {
            total += i;
            if (i != number / i) {
                total += (number / i);
            }
        }
    }
    total -= number;
    if (total == number) {
        std::cout << "perfect number" << std::endl;
    } else if (total < number) {
        std::cout << "deficient number" << std::endl;
    } else {
        std::cout << "abundant number" << std::endl;
    }

    return;
}

int main(void) {
    int number;
    while (1) {
        std::cin >> number;
        if (number == 0) {
            break;
        }
        check(number);
    }
    return 0;
}

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

using namespace std;

int gcd(int a, int b) {
	for (; b; swap(a, b))
		a %= b;
	return a;
}
int a[11111], q[11111];
int main() {
	int n;
	cin >> n;
	for (int i = n; i >= 0; i--)
		cin >> a[i];
	vector<int> o;
	int b = 0;
	for (int i = 0; i <= n; i++)
		b = gcd(b, abs(a[i]));
	for (int i = 2; i <= b / i; i++) {
		if (b%i) continue;
		o.push_back(i);
		while (b%i == 0) b /= i;
	}
	if (b > 1) o.push_back(b);
	for (int p = 2; p <= n; p++) {
		if (q[p]) continue;
		for (int j = p * p; j <= n; j += p)
			q[j] = 1;
		long f[11111] = {};
		if (a[0] % p) goto pn;
		for (int i = 0; i <= n; i++)
			(f[i % (p - 1)] += a[i] % p + p) %= p;
		for (int i = 0; i < p - 1; i++)
			if (f[i]) goto pn;
		o.push_back(p);
	pn:;
	}
	sort(o.begin(), o.end());
	unique(o.begin(), o.end());
	for (int m : o) cout << m << '\n';
	cout << flush;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a - 2 * b <= 0) {
            System.out.println(0);
        } else {
            System.out.println(a - 2 * b);
        }
        sc.close();
    }
}

Measured memory_bytes: 21716
n, m = *gets.chomp.split.map(&:to_i)

items = gets.chomp.split.map(&:to_i).sort_by {|i| -i }
all = items.inject(0) {|result, item| result + item}
limit = all.to_f / (4 * m)

vo = items[m - 1]

puts(vo >= limit ? "Yes" : "No")

Measured memory_bytes: 1788
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi; ///VECTOR<VECTOR<INT>NAME>NAME 2
typedef vector<vl> vvl;///LONG LONG
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;///VECTOR WITH PAIR
typedef vector<pll> vll;
typedef double dl;

#define endl "\n"
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define over return 0;

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }


///--------> YOUR JOURNEY STARTS HERE <-------



int main(){

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

if(n==1){

    cout<<0<<endl;
}
else{





for(int i=0;i<n-1;i++){
    if(a[i]>a[i+1]){ans+=a[i]-a[i+1];
        a[i+1]=a[i];

        //cout<<a[i]<<" "<<a[i+1]<<endl;
    }
}

cout<<ans<<endl;
}
over
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

string ss[4] = {"dream","dreamer","erase","eraser"};
ll dp[101010];

bool dfs(const string& s,ll p){
	if(dp[p]!=-1) return dp[p];
	if(p==s.size()) return dp[p]=true;
	bool ret=false;
	REP(i,4){
		if(p+ss[i].size() > s.size()) continue;
		string s2=s.substr(p,ss[i].size());
		if(s2==ss[i]) if(dfs(s,p+ss[i].size())) ret=true; 
	}
	//cout<<p<<" "<<ret<<en;
	return dp[p]=ret;
}



void solve(){
	ll l;
	cin>>l;

	ll n=0;
	while((1<<n)<=l) n++;

	vec<tuple<ll,ll,ll>> es;
	REP(i,n-1){
		es.push_back(make_tuple(i+1,i+2,0));
		es.push_back(make_tuple(i+1,i+2,(1LL<<i)));
	}

	REP2(i,n-1){
		if(l>(1LL<<(i+1))){
			ll d=l-(1LL<<i);
			if(d<(1LL<<(n-1))) continue;
			es.push_back(make_tuple(i+1,n,d));
			l=d;
		}
	}
	cout<<n<<" "<<es.size()<<en;
	for(auto i:es){
		ll a,b,c;
		tie(a,b,c) = i;
		cout<<a<<" "<<b<<" "<<c<<en;
	}
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

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

using namespace std;

int n, ans = 0, turn = 0;
string s;

int main() {
    cin >> s;
    for(int i = 0; i < s.length(); i++) {
        if(s[i] == 'g') {
            if(turn != 0) {
                ans++;
                turn --;
            }
            else turn++;
        }
        else {
            if(turn == 0) {
                ans--;
                turn++;
            }
            else turn--;
        }
    }
    cout << ans;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_`{|}~"); // ok
//string HOGE(".!\"#&%&'()*+,-/:"); // bad
//string HOGE(";<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'"); // bad
//string HOGE("()*+,-/:;<=>?@[\\"); // bad
//string HOGE("]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\"); // bad
//string HOGE("()*+,-/:;<=>?@[\\]^_`{|}~"); // bad

//string HOGE(".!\"#&%&'()*,-/:;<=>?@[\\]^_`{|}~"); // ok (no +)

//string HOGE(".!\"#&%&'()*+,-/:;<=>?@[\\]^_"); // ok -5


// included '_'

//string HOGE("_.!\"#&%&'()*+,-/:;<=>?"); // ok more -5
//string HOGE("_.!\"#&%&'()*+,-/:"); // ok more -5 
//string HOGE("_.!\"#&%"); // ok more -5 
//string HOGE("_.!"); // bad 
//string HOGE("_.!\"#&%"); // bad 
string HOGE("_.!\"#&%&'()"); // ?


int main(void) {
	string s;

	int total = 0;

	while (cin >> s) {
		replace_if(s.begin(), s.end(), [](char c){ return isalpha(c) || c == '.' || HOGE.find(c) != string::npos; }, ' ');
		
		istringstream iss(s);
		int num;
		while (iss >> num) {
			total += num;
		}
	}

	cout << total << endl;

	return 0;}

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

string str;
bool yymm, mmyy;

int main(){
	cin >> str;
	// Check if MMYY
	int tmp = 10*(str[0]-'0') + (str[1]-'0');
	if(tmp >= 1 && tmp <= 12)
		mmyy = true;

	// Check if ddmm
	tmp = 10*(str[2]-'0') + (str[3]-'0');
	if(tmp >= 1 && tmp <= 12)
		yymm = true;

	if(yymm && mmyy){
		printf("AMBIGUOUS\n");
	}else if(yymm){
		printf("YYMM\n");
	}else if(mmyy){
		printf("MMYY");
	}else{
		printf("NA\n");
	}
}

Measured memory_bytes: 256
max = 50021

primes = (2..Math.sqrt(max).ceil).inject([*2..max]) do |nums, sieve|
  nums.reject { |num| num % sieve == 0 && num != sieve }
end

while line = gets
  n = line.chomp.to_i
  max = primes.take_while { |x| x < n }.max
  min = primes.sort { |a, b| b <=> a }.take_while { |x| x > n }.min
  puts "#{max} #{min}" 
end

Measured memory_bytes: 21368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H-h) * (W-w) << endl;

    return 0;
}

Measured memory_bytes: 256
/* author : akshatjai258 */
#include<bits/stdc++.h>
using namespace std;   
typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
#define int ll
#define mod int(1e9+7)
#define inf int(1e9)
#define endl "\n"  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define fi first
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end() 
#define se second 
#define mp make_pair 
#define pb push_back 
#define w(x)   int x; cin>>x; while(x--)
#define ps(x,y)     fixed<<setprecision(y)<<x
void prep()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif*/
		
}
int32_t main()
{
	prep();
	int n;
	cin>>n;
	vi dp(n+1,inf),arr(n);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=2;j++)
		{
			if(i-j>=0)
			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	cout<<dp[n-1];
			
	
	return 0;
}

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

#define ll long long 
#define ii pair<ll,ll> 
const ll RANGE = 1e9, INF = 1e18;
const int MAXN = 1e5 + 5;

int n, m;
ll pos[MAXN];
bool valid = true;
vector<ii> adj[MAXN];

int main(){
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; ++i){
		ll u, v, w;
		scanf("%lld %lld %lld", &u, &v, &w);
		adj[u].push_back(ii(v, w));
		adj[v].push_back(ii(u, -w));
	}
	for(int i = 1; i <= n; ++i){
		pos[i] = 1e18;
	}
	for(int i = 1; i <= n; ++i){
		if(pos[i] != INF)
			continue;
		queue<int> q;
		q.push(i);
		pos[i] = 0;
		ll maxVal = 0, minVal = 0;
		while(!q.empty()){
			int top = q.front(); q.pop();

			for(ii j : adj[top]){
				if(pos[j.first] != INF && pos[top]+j.second != pos[j.first]){
					valid = false;
				}else if(pos[j.first] == INF){
					pos[j.first] = pos[top]+j.second;
					maxVal = max(maxVal, pos[j.first]);
					minVal = min(minVal, pos[j.first]);
					q.push(j.first);
				}
			}
		}

		if(maxVal-minVal > RANGE){
			valid = false;
		}
	}

	if(valid)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 13824
import sys
N,D,A=[int(i) for i in input().split(" ")]
enemies=[]
for i in range(N):
    X,H=[int(j) for j in input().split(" ")]
    enemies.append([X,H])

enemies=sorted(enemies,key=lambda w:w[0])

if enemies[-1][0]-enemies[0][0]<=2*D:
    hpmax=sorted(enemies,key=lambda  w:w[1])[-1][1]
    if hpmax%A==0:
        print(hpmax//A)
    else:
        print(hpmax//A+1)
    sys.exit()


retval=0
for i in range(N):
    hp=enemies[i][1]
    place=enemies[i][0]
    if hp<=0:
        continue
    if hp%A==0:
        bomb=hp//A
    else:
        bomb=hp//A+1
    retval+=bomb

    for j in range(i,N):
        if enemies[j][0]-place>2*D:
            break
        enemies[j][1]-=bomb*A



print(retval)


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

int main() {
    string S, T;
    cin >> S >> T;
    int N = S.size();
    map<char, vector<int>> mp;
    for(int i = 0; i < 2 * N; ++i) mp[S[i % N]].push_back(i);
    int64_t now = -1;
    for(auto &c : T) {
        int i = now % N;
        auto it = upper_bound(mp[c].begin(), mp[c].end(), i);
        if(it == mp[c].end()) {
            cout << -1 << '\n';
            return 0;
        }
        now += *it - i;
    }
    cout << now + 1 << '\n';
    return 0;
}


Measured memory_bytes: 4628
s=input()
ans = (-1,-1)
for i,c in enumerate(s[:-1]):
    if c==s[i+1]:
        ans = (i+1,i+2)
        break
else:
    for i,c in enumerate(s[:-2]):
        if c==s[i+2]:
            ans = (i+1,i+3)
            break
print(*ans)

Measured memory_bytes: 3188
given = ["dreamer", "dream", "eraser", "erase"]
S = input()
while len(S) > 0:
    tmp = S
    for i in given:
        if S.endswith(i):
            S = S[::-1].replace(i[::-1], "", 1)[::-1]
            if len(S) == 0:
                print("YES")
                break
    if tmp == S:
        print("NO")
        break

Measured memory_bytes: 3484
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int a[3][3][3][3];

vi sm(string &s, char c) {
    vi t(sz(s)+1);
    rep(i, sz(s)) {
        t[i + 1] = s[i] == c;
    }
    partial_sum(all(t),t.begin());
    return t;
}

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

    rep(i, 3)rep(j, 3) {
        a[i][j][(i + 2) % 3][(j + 2) % 3] = 1;
    }

    rep(k, 3)rep(kk, 3)rep(i, 3)rep(ii, 3)rep(j, 3)rep(jj, 3) {
        a[i][ii][j][jj] |= a[i][ii][k][kk] & a[k][kk][j][jj];
    }

    string S, T;

    cin >> S >> T;
    vi as = sm(S, 'A'), bs = sm(S, 'B'), at = sm(T, 'A'), bt = sm(T, 'B');

    int Q; cin >> Q;
    rep(ii, Q) {
        int l, r, L, R;
        cin >> l >> r >> L >> R;
        l--; L--;
        int x = as[r] - as[l], y = bs[r] - bs[l], z = at[R] - at[L], w = bt[R] - bt[L];
        x %= 3; y %= 3; z %= 3; w %= 3;
        cout << (a[x][y][z][w] ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 2512
n, m = gets.chomp.split(" ").map(&:to_i)
num = Array.new(n, nil)
m.times do
    s, c = gets.chomp.split(" ").map(&:to_i)
    if n != 1 && s == 1 && c == 0
        puts -1
        exit
    end
    if num[s-1] == nil
        num[s-1] = c
    elsif num[s-1] != c
        puts -1
        exit
    end
end
 
n.times do |i|
    num[i] = 0 if num[i] == nil
end

num[0] = 1 if num[0] == 0 && n != 1
 
puts num.join("").to_i

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(){
    int min=1000001,max=-1000001,n,m;
    long sum=0;
    cin >> n;
    for (int i=1;i<=n;i++){
    	cin >> m;
    	if (m>max)
    		max=m;
    	if (m<min)
    		min=m;
    	sum+=m;
	}
	cout << min << ' ' << max << ' ' << sum << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <cmath>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
const int dx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
const int dy[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
char c[8][9];
int place(int x, int y, char t, bool m) {
	int ret = 0;
	for (int i = 0; i < 8; i++) {
		int px = x + dx[i], py = y + dy[i];
		bool flag = false;
		while (0 <= px && px < 8 && 0 <= py && py < 8) {
			if (c[py][px] == '.') break;
			if (c[py][px] == t) {
				flag = true; break;
			}
			px += dx[i];
			py += dy[i];
		}
		if (flag) {
			ret += max(abs(x - px) - 1, abs(y - py) - 1);
			if (m) {
				int qx = x, qy = y;
				while (qx != px || qy != py) {
					c[qy][qx] = t;
					qx += dx[i];
					qy += dy[i];
				}
			}
		}
	}
	return ret;
}
int main() {
	for (int i = 0; i < 8; i++) scanf("%s", &c[i]);
	int t = 0, v = 0;
	while (true) {
		int x = -1, y = -1, r = 0;
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (c[i][j] == '.') {
					int p = place(j, i, t % 2 == 0 ? 'o' : 'x', false);
					if (p >= r && p >= 1 && t % 2 == 1) { x = j; y = i; r = p; }
					else if (p > r && p >= 1) { x = j; y = i; r = p; }
				}
			}
		}
		if (r == 0) {
			if (v == 0) { v = 1; t++; continue; }
			break;
		}
		else { place(x, y, t++ % 2 == 0 ? 'o' : 'x', true); v = 0; }
	}
	for (int i = 0; i < 8; i++) printf("%s\n", c[i]);
	return 0;
}

Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vstr=vector<string>;
#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 _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vin a(n);
    vin b(n);
    vin c(n-1);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    rep(i,n)cin>>b[i];
    rep(i,n-1)cin>>c[i];
    int sum=0;
    rep(i,n){
        sum+=b[a[i]];
        if(i>=1&&a[i]==a[i-1]+1)sum+=c[a[i-1]];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#!/bin/env python3

N = int(input())

t_prev = x_prev = y_prev = 0
for i in range(N):
    t_i, x_i, y_i = map(int, input().split())

    if (x_i+y_i)> t_i:
        print("No")
        exit()
    elif (x_i+y_i) %2 != t_i%2 :
        print("No")
        exit()
    elif (abs(x_i - x_prev) + abs(y_i - y_prev)) > (t_i - t_prev):
        print("No")
        exit()
    t_prev, x_prev, y_prev = t_i, x_i, y_i

print("Yes")


Measured memory_bytes: 3064
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

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

# strlist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
K = int(input())
arrA = list(map(int,input().split()))

anslis = []
for i in arrA:
    num = min(i,K-i)
    anslis.append(num)

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


Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
  int sum=0;
  char s[4]={'\0'};
  scanf("%s",s);
  for(int i=0;i<3;i++){
    if(s[i]=='1'){
      sum++;
    }
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 128
import math
N = int(input())
A = list(map(int, input().strip().split()))
minus = 0
abs_min = abs(A[0])
sum = 0
for i in range(0, N):
    sum += abs(A[i])
    if A[i] < 0:
        minus += 1
    if abs(A[i]) < abs_min:
        abs_min = abs(A[i])
if minus % 2 != 0:
    sum -= abs_min*2
print("{}".format(sum))


Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(Int i = 0; i < (Int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

Int GCD(Int a, Int b)
{
    if (a < 0)
        a = -a;
    if (b < 0)
        b = -b;
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

vector<Int> eratosthenes(const Int &N)
{
    vector<Int> is_prime(N + 1);
    for(int i = 0; i < is_prime.size(); i++) is_prime[i] = i;
    is_prime[1] = 0;

    for(Int i = 2; i * i <= N; i++)
    {
        if(is_prime[i] != i) continue;
        for(Int j = 2 * i; j <= N; j += i)
        {
            is_prime[j] = min(is_prime[j], i);
        }
    }
    return is_prime;
}

map<Int, Int> prime_factor(Int N, const vector<Int> &is_prime)
{
    map<Int, Int> result;
    while(N > 1)
    {
        // N = x * p(=is_prime[N]) 
        result[is_prime[N]]++;
        N = N / is_prime[N];
    }
    return result;
}



void solve()
{
    Int N; cin >> N;
    vector<Int> A(N);
    for(Int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    vector<Int> is_prime = eratosthenes(*max_element(A.begin(), A.end()) + 1);

    vector<map<Int, Int>> buff;
    map<Int, Int> mp;
    for(Int i = 0; i < N; i++)
    {
        map<Int, Int> tmp = prime_factor(A[i], is_prime);
        for(const auto &x : tmp)
        {
            mp[x.first] += x.second;
        }
        buff.push_back(tmp);
    }

    bool ok = true;

    for(Int i = 0; i < N; i++)
    {
        if(ok == false) break;
        for(const auto &x : buff[i])
        {
            mp[x.first] -= x.second;
        }

        for(const auto &x : buff[i])
        {
            if(mp[x.first] > 0)
            {
                ok = false;
                break;
            }
        }
    }

    if(ok)
    {
        cout << "pairwise coprime" << endl;
        return;
    }

    Int v = A.front();
    for(Int i = 0; i < N; i++)
    {
        v = GCD(v, A[i]);
    }
    if(v == 1)
    {
        cout << "setwise coprime" << endl;
        return;
    }
    cout << "not coprime" << endl;
}

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


Measured memory_bytes: 381364
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    int ans;
    if(n == 1) ans = 1;
    else if(n < 4) ans = 2;
    else if(n < 8) ans = 4;
    else if(n < 16) ans = 8;
    else if(n < 32) ans = 16;
    else if(n < 64) ans = 32;
    else ans = 64;
    cout << ans << "\n";
    return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

string s,ans="";
cin>>s;
for(auto& x: s) {
  if(x=='0') {
    ans+='0';
  }
  if(x=='1') {
    ans+='1';
  }
  if(x=='B') {
    if(ans.size()>0) ans.pop_back();
  }
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n,d,w;
	cin>>n>>d;
	w=(n+(d*2+1-1))/(d*2+1);

	cout<<w<<endl;
	return 0;
}



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

int com(const void *a, const void *b){
  return *(int *)b - *(int *)a;
}


int main(){
  int n;
  cin >> n;
  int a[1000];
  rep(i,n){
    cin >> a[i];
  }
  qsort(a,n,sizeof(int),com);
  int score1 = 0;
  int score2 = 0;
  rep(i,n){
    if(i % 2 == 0) score1 += a[i];
    else score2 += a[i];
  }
  cout << score1 - score2 << endl;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int h, w, x, y;
	cin >> h >> w >> x >> y;
		int a = h * w;
		int b = x + y;
		cout << (a % 2 && b % 2 ? "No" : "Yes") << endl;
	
	return 0;	
}



Measured memory_bytes: 3220
package main

import "fmt"

func main() {
	var N, Q int
	var S string
	fmt.Scan(&N, &Q)
	fmt.Scan(&S)

	c := make([]int, N)
	for i := 1; i < N; i++ {
		c[i] = c[i-1]
		if S[i-1] == 'A' && S[i] == 'C' {
			c[i]++
		}
	}

	var l, r int
	for i := 0; i < Q; i++ {
		fmt.Scan(&l, &r)
		fmt.Println(c[r-1] - c[l-1])
	}
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    map<int, int> m;
    Rep(i, 1, N+1){
        int t = i;
        while(t != 1){
            Rep(j, 2, N+1){
                while(t%j==0){
                    m[j]++;
                    t /= j;
                }
            }
        }
    }

    int p_74=0, p_24=0, p_14=0, p_4=0, p_2=0;

    for(auto&& i : m){
        if(i.second >= 74) p_74++;
        if(i.second >= 24) p_24++;
        if(i.second >= 14) p_14++;
        if(i.second >= 4) p_4++;
        if(i.second >= 2) p_2++;
    }

    int ans = p_74;
    ans += p_24 * (p_2-1);
    ans += p_14 * (p_4-1);
    ans += (((p_4*(p_4-1))/2) * (p_2-2));
    pr(ans);
}

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,0,n) cin >> a[i];
	int cnt=0;
	rep(i,0,n){
		while(a[i]%2 == 0){
			cnt++;
			a[i]/=2;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int[] l = arrayInt(sc, n);
		sc.close();
		int ans = 1;
		int d = 0;
		for (int i = 0; i < n; i++) {
			d += l[i];
			if (d <= x)
				ans++;
		}
		System.out.println(ans);
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 22864
def projecter(x, y, xp, yp)
  return (xp * x + yp * y) / (x ** 2 + y ** 2), (yp * x - xp * y) / (x ** 2 + y ** 2)
end
def main(input = STDIN)
  x1, y1, x2, y2 = input.gets.split(" ").map(&:to_r)
  q = input.gets.to_i
  x, y = (x2 - x1), (y2 - y1)
  q.times do
    xp, yp = input.gets.split(" ").map(&:to_r)
    a, b = projecter(x, y, xp - x1, yp - y1)
    if b > 0
      puts "COUNTER_CLOCKWISE"
    elsif b < 0
      puts "CLOCKWISE"
    elsif a < 0
      puts "ONLINE_BACK"
    elsif a > 1
      puts "ONLINE_FRONT"
    else
      puts "ON_SEGMENT"
    end
  end
end
main

Measured memory_bytes: 6148
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,D;
    cin >> N >> D;
    int ans = 0;
    while(N > 0){
        N -= D*2+1;
        ans++;
    }
    pr(ans);
}

Measured memory_bytes: 256
#include <array>
#include <cstddef>
#include <functional>
#include <type_traits>
#include <utility>

template <class Key, class T, Key Empty, std::size_t N,
	class Hash = std::hash<Key>>
	struct mu_hashmap {

	std::array<std::pair<Key, T>, N> table;
	Hash hash;

	explicit mu_hashmap(Hash hash = Hash()) : table(), hash(hash) {
		for (auto itr = table.begin(), end = table.end(); itr != end; ++itr) {
			itr->first = Empty;
		}
	}

	T& operator[](const Key key) {
		std::size_t i = hash(key);
		while (table[i % N].first != key) {
			if (table[i % N].first == Empty) {
				table[i % N].first = key;
				break;
			}
			++i;
		}
		return table[i % N].second;
	}
};

#include<cstddef>
#include<cstdint>
#include<iostream>

int main() {
	using usize = std::size_t;
	using u32 = std::uint_fast32_t;
	using i64 = std::int_fast64_t;

	usize n;
	std::cin >> n;

	u32 ans = 0;
	i64 acc = 0;
	mu_hashmap<i64, u32, 200000ULL * 1000000000 + 1, 1ULL<<20> count;
	++count[acc];

	for (usize i = 0; i != n; ++i) {
		i64 a;
		std::cin >> a;

		acc += a;
		ans += count[acc];
		++count[acc];
	}

	std::cout << ans << std::endl;

	return 0;
}



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

using namespace std ;

const int MAX = 10 ;

int arr[MAX] ;
int n , m ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	memset(arr , -1 , sizeof(arr)) ;
	cin>>n>>m ;
	for(int i = 0 ; i < m ; ++i)
	{
		int x , y ; 
		cin>>x>>y ;
		if(arr[x] != -1 && arr[x] != y)
			return cout<<-1<<"\n" , 0 ;
		arr[x] = y ;
	}
	if(arr[1] == 0 && n != 1)
		return cout<<-1<<"\n" , 0 ;
	for(int i = 1 ; i <= n ; ++i)
	{
		if(arr[i] == -1)
			arr[i] = 0 ;
		if(arr[i] == 0 && i == 1 && n != 1)
			arr[i] = 1 ;
		cout<<arr[i] ;
	}
	cout<<"\n" ;
	return 0 ;
}		

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

using namespace std;

using ll = long long;

constexpr int MOD = 1e9 + 7;

inline int pot(ll n, unsigned int k, int mod = MOD){
	ll ret = 1;
	while(k){
		if (k & 1u){
			ret *= n;
			ret %= mod;
		}
		n *= n;
		n %= mod;
		k >>= 1u;
	}
	return ret;
}

ll sub(ll a, ll const& b) {
	a -= b;
	if (a < 0) a += MOD;
	return a % MOD;
}

ll add(ll a, ll const& b) {
	a += b;
	return a % MOD;
}

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

	ll n;
	cin >> n;
	if (n < 2) {
		cout << 0 << '\n';
		return 0;
	}
	ll ans = add(sub(pot(10, n), (2ll * pot(9, n)) % MOD), pot(8, n));
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hd", &A[i+1]);
    C[A[i+1]]++;
  }

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i-1];

  /*
  for(i=0; i<n-1; i++){
    printf("%d ", C[i]);
  } printf("%d\n", C[i]);
  */

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  return 0;
}



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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

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

constexpr long long mod = 1000000007;

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

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

    ll n, k, s;
    cin >> n >> k >> s;

    vll a(n);

    if (s == 1000000000) {
        for (int i = 0; i < k; i++){
            a[i] = s;
        }
        for (int i = k; i < n; i++){
            a[i] = s - 1;
        }
    } else {
        for (int i = 0; i < k; i++) {
            a[i] = s;
        }
        for (int i = k; i < n; i++) {
            a[i] = s + 1;
        }
    }

    rep(i, n) cout << a[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2176
N = int(input())
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
C = list(map(int, input().split(' ')))
ans = B[A[0] - 1]
for i, a in enumerate(A[1:]):
    bef_a = A[i]
    ans += B[a - 1]
    if a - bef_a == 1:
        ans += C[bef_a - 1]
print(ans)

Measured memory_bytes: 9044