akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
 
// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    while (cin >> n) {
        llvec a(n);
        i64 s = 0;
        forn(i, n) {
            cin >> a[i];
            s += a[i];
        }
        
        i64 ss = 0;
        int pos = -1;
        forn(i, n) {
            if (ss <= s / 2 && ss + a[i] > s / 2) {
                pos = i;
                break;
            }
            ss += a[i];
        }

        i64 c1 = (s - ss) - ss;
        i64 c2 = ss + a[pos] - (s - ss - a[pos]);
        cout << min(c1, c2) << endl;
    }
}

Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);

        String[] number = scan.nextLine().split(" ");
        double x1 = Double.parseDouble(number[0]);
        double x2 = Double.parseDouble(number[2]);
        double y1 = Double.parseDouble(number[1]);
        double y2 = Double.parseDouble(number[3]);
        double distance = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
        System.out.println(distance);
    }
}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll a,b,c;
  	ci(a>>b>>c)
  FOR(i,0,10){
      co(a*c-b)
        c=(a*c-b);
    }
}
  

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n;
    double x;
    double ans;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%lf", &x);
        ans += (1 / x);
    }
    printf("%f\n", (1 / ans));
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

const double pi=3.1415;
ll absc(ll a,ll b){return (a-b>0?a-b:b-a);
}
ll mini(ll a,ll b){return (a>b?b:a);}
ll gcd(ll a,ll b){
	if(a<b)swap(a,b);
	return (a%b?gcd(a%b,b):b);
}
ll mainasu(ll a,ll b,ll c){
	if(a>=b)return mainasu(a-b,b+1,c+1);
	else return c;
}
ll gojou(ll n){return pow(n,5);}
int main()
{
	ll k=-1,num,ans=0,j;
	bool f=false,g=false,h=false;
	cin>>num;
	vector<int>jou;
	for(ll i = 2; i*i <= ll(num);i++)
	{
		if(num%i==0){f=true;break;}
	}
	if(f)
	{
	for (int i = 2; i <= num; i++){ // 他の素数で割っていく
		if(num % i == 0){ j=0;k++;g=true;h=false;}
		else g=false;
        while (num % i == 0){
        	if(!j)jou.push_back(1);
        	else jou[k]++;
            num /= i;
            j++;
        }
        if(g&&num!=1){
        	for(ll l = 2; l*l <= ll(num);l++)if(num%l==0){h=true;break;}
		if(!h)
        {
        	jou.push_back(1);
        	break;
        }
        }
        
        
    }
    for(ll i=0;i<jou.size();i++)
    {
    	ans+=mainasu(jou[i],1,0);
    }
    cout<<ans;
    }
    else cout<<(num==1?0:1);
}


Measured memory_bytes: 3724
/** 
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>
 
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 8; i++) {
		cout << s[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

ll n;
vector<ll> a, b, diff_big, diff_small;


void solve() {
    sort(diff_big.begin(), diff_big.end(), greater<>());
    sort(diff_small.begin(), diff_small.end(), greater<>());
    ll small_count = 0;
    ll ans = 0;
    rep(i, diff_small.size()) {
        small_count += diff_small[i];
        ans++;
    }
    if (small_count == 0) {
        cout << "0" << endl;
        return;
    }
    rep(i, diff_big.size()) {
        small_count -= diff_big[i];
        ans++;
        if (small_count <= 0) break;
    }
    if (small_count >= 0) cout << "-1" << endl;
    else cout << ans << endl;
}

int main() {
    cin >> n;
    a.resize(n), b.resize(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
        if (a[i] > b[i]) diff_big.emplace_back(a[i] - b[i]);
        if (a[i] < b[i]) diff_small.emplace_back(b[i] - a[i]);
    }
    solve();
    return 0;
}

Measured memory_bytes: 2812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main(void) {
  ll n , k; cin >> n >> k;
  vector<ll> h(n);
  rep(i, 0, n) {
    cin >> h[i];
  }
  sort(all(h));
  ll ans = 0;
  rep(i, 0, n-k) {
    ans += h[i];
  }
  cout << ans << endl;
/*
  rep(i, 0, n) {
    cout << "h = " << h[i] << endl;
  }
*/

}


Measured memory_bytes: 1792
#include<cstdio>
	#include<iostream>
	#include<map>
	#include<set>
	#include<vector>
	#include<cstring>
	#include<cassert>
	#include<sstream>
	#include<cmath>
	#include<algorithm>
	#include<queue>
	#include<limits>
	#include<ctime>
	#include<stack>
	#include<bits/stdc++.h>
	#include<string>
	#include<stdlib.h>
	#include<stdio.h>
	
	typedef long long ll;
	using namespace std;
	const ll x=1000000007;
	int mod(ll a){
		return a%x;
	}
	int main(){
		ll n,maks=0;
		cin>>n;
		if(n<4){
			cout<<1;
		}
		else{
			int i=2;
			while(i<=n){
				int j=2;
				while(pow(i,j)<=n){
					ll z=pow(i,j);
					maks=max(maks,z);
					j++;
				}
				i++;
			}
			cout<<maks;
		}
	}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, w;
    scanf("%d%d%d", &w, &n, &m);
    if(min(m, n)+w >= max(m, n))printf("0");
    else printf("%d", max(n, m) - min(n, m) - w);
    return 0;
}


Measured memory_bytes: 256
/** author: __nishad__ **/

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


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    ll n, k, x, count;
    cin>>n>>k;
    vll v;
    int arr[n]={0};

    while(k--){
        ll d;
        count=0;
        cin>>d;
        while(d--){
            cin>>x;
            arr[x-1] = 1;

        }

    }
    for(int i=0; i<n; i++)
    {
        if(arr[i] == 0)
            count++;
    }


    cout<<count;

}




Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int count = 0;

		int p[] = new int[n];

		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt();
		}

		for (int i = 1; i < n - 1; i++) {
			if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
				count++;
			} else if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
				count++;
			}
		}
		System.out.print(count);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int k=1;
    set<int> s;
    for(int i=1;i<n;i++){
        k*=i;
        s.insert(i);
    }
    s.insert(n);
    int pnum=0,qnum=0;
    int a;

    
    for(int i=n-1;i>0;i--){
        cin>>a;
        pnum+=(distance(s.begin(),s.find(a)))*k;
        s.erase(a);
        k/=i;
    }
    cin>>a;
    s.clear();
    for(int i=1;i<n;i++){
        k*=i;
        s.insert(i);
    }
    s.insert(n);
    for(int i=n-1;i>0;i--){
        cin>>a;
        qnum+=(distance(s.begin(),s.find(a)))*k;
        s.erase(a);
        k/=i;
    }
    cin>>a;
    cout << (abs(pnum-qnum))<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stack>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? (-(a)) : (a))

typedef long long ll;

using namespace std;

bool is_palindrome(string& str, int st, int ed)
{
	for (int i = 0; i <= ed - st; ++i)
	{
		if (str[st + i] != str[ed - i]) return false;
	}
	return true;
}

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

	string input;
	
	cin >> input;

	if (is_palindrome(input, 0, (int)input.size() - 1) && is_palindrome(input, 0, (int)input.size() / 2 - 1) && is_palindrome(input, (int)input.size() / 2 + 1, (int)input.size() - 1)) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    if (N%2 == 0) {
        int i = N/2;
        string a = S.substr(0, i);
        string b = S.substr(i, i);
        if (a == b) {
            print("Yes");
        } else {
            print("No");
        }
    } else {
        print("No");
    }
}

int main()
{
    solve();

    return 0;
}


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

typedef long long ll;
const int mod = 1e9 + 7;

ll N;
vector<ll> C;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    cin >> N;
    C.resize(N);

    rep(i, N) {
        cin >> C[i];
    }
    sort(C.begin(), C.end());

    vector<mint> two(N + 1);
    two[0] = 1;
    for (int i = 1; i <= N; i++) {
        two[i] = two[i - 1] * 2;
    }

    mint ans = 0;
    for (int i = 0; i < N; i++) {
        ll l = i;
        ll r = N - i - 1;
        mint now = two[r];
        if (r != 0) now += two[r - 1] * r;
        now *= two[l];
        now *= C[i];

        ans += now;
    }
    ans *= two[N];

    cout << ans.x << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\mis\\b2.in","r",stdin)
#define write freopen("debug\\misout\\b2.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
template<class T,class V> ostream& operator<<(ostream &s,pair<T,V> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
ll st[4*asz];
ll lz[4*asz];
ll f(ll l,ll r)
{
    return l+r;
}
void propagate(ll node,ll ss,ll sf)
{
    if(lz[node]==0)return;
    st[node]+=(sf-ss+1)*lz[node];
    if(ss!=sf)
    {
        lz[2*node]+=lz[node];
        lz[2*node+1]+=lz[node];
    }
    lz[node]=0;
}
void update(ll node,ll ss,ll sf,ll qs,ll qe,ll val)
{
    propagate(node,ss,sf);
    if(qs>sf||qe<ss||sf<ss)return;
    if(qs<=ss&&qe>=sf)
    {
        lz[node]+=val;
        propagate(node,ss,sf);
        return;
    }
    ll mid=(ss+sf)/2;
    update(2*node,ss,mid,qs,qe,val);
    update(2*node+1,mid+1,sf,qs,qe,val);
    st[node]=f(st[2*node],st[2*node+1]);
}

ll query(ll node,ll ss,ll sf,ll qs,ll qe)
{
    propagate(node,ss,sf);
    if(qs>sf||qe<ss||sf<ss)return 0;
    if(qs<=ss&&qe>=sf)return st[node];
    ll mid=(ss+sf)/2;
    return f(query(2*node,ss,mid,qs,qe),query(2*node+1,mid+1,sf,qs,qe));
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T;qq++)
    {
        ll n;
        cin>>n;
        vector<vi> adj(n);
        for(int i=0;i<n-1;i++){
            ll x,y;
            cin>>x>>y;
            x--,y--;
            if(x>y)swap(x,y);
            adj[y].push_back(x);
        }
        for(int i=0;i<n;i++)sort(adj[i].begin(),adj[i].end());
        ll ans=0;
        for(int i=0;i<n;i++){
            if(adj[i].empty())update(1,0,n-1,0,i,1);
            if(adj[i].size()==1)update(1,0,n-1,adj[i][0]+1,i,1);
            if(adj[i].size()>1){
                update(1,0,n-1,adj[i].back()+1,i,1);
                for(int j=adj[i].size()-2;j>=0;j--)update(1,0,n-1,0,adj[i][j],-1);
            }
            ans+=query(1,0,n-1,0,n-1);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 22344
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
using namespace std;

int INFTY=2000000000,t;
vector<int> s;

void merge(int left,int mid,int right){
    int n1=mid-left,n2=right-mid;
    vector<int> l(n1+1),r(n2+1);
    for(int i=0;i<n1;i++){
        l[i]=s[left+i];
    }
    for(int i=0;i<n2;i++){
        r[i]=s[mid+i];
    }
    l[n1]=INFTY;
    r[n2]=INFTY;
    int i=0,j=0;
    for(int k=left;k<right;k++){
        if(l[i]<=r[j]){
            s[k]=l[i];
            i++;
            t++;
        }
        else{
            s[k]=r[j];
            j++;
            t++;
        }
    }
}

void mergeSort(int left,int right){
    if(left+1<right){
        int mid=(left+right)/2;
        mergeSort(left,mid);
        mergeSort(mid,right);
        merge(left,mid,right);
    }
}

int main(void){
    int n;
    t=0;
    cin>>n;
    s.resize(n,0);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    mergeSort(0,n);
    for(int i=0;i<n-1;i++){
        cout<<s[i]<<" ";
    }
    cout<<s[n-1]<<endl<<t<<endl;
    return 0;
}

Measured memory_bytes: 6772
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

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

int a, b;

signed main() {
	cin >> a >> b;
	int c = gcd(a, b);
	
	int ans = 0;
	for (int i = 2; i * i <= c; i++) {
		if (c % i == 0) {
			while (c % i == 0) {
				c /= i;
			}
			ans++;
		}
	}
	if (c > 1) ans++;
	
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define MAX 100
typedef long long ll;

int main(){
	int n;
	cin >> n;
	int a[2][n],dp[2][n];
	rep(i,2){
	rep(j,n){
	cin >> a[i][j];
	dp[i][j] = 0;
	}}

	rep(i,2){
	rep(j,n){
	if (i==0&&j==0) {
	dp[0][0] = a[0][0];
	}
	else if (i==0) {
	dp[0][j] = dp[0][j-1] + a[i][j];
	}
	else if (j==0) {
	dp[1][0] = dp[0][0] + a[1][0];
	}
	else{
	dp[1][j] = max(dp[0][j],dp[1][j-1]) + a[i][j];
	}
	}
	}
/*
	rep(i,2){
        rep(j,n){
	cout << dp[i][j] << " ";
	}
	cout << endl;
	}
*/

	cout << dp[1][n-1] << endl;
	return 0;
}
	


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


int main(){
  int n,d,ans=0;cin >> n >> d;
  vector<vector<int>> x(n,vector<int>(d));
  double dst;
  rep(i,n)rep(j,d)cin >> x.at(i).at(j);

  rep(i,n-1){
    int j = i+1;
    while(j<n){
      
      int sum =0;
      rep(k,d){
        int a = abs(x.at(i).at(k)-x.at(j).at(k));
        sum += a*a;
      }
      dst = sqrt(sum);
      if(dst == ceil(dst)) ans ++;
      j++;
    }
  }

  cout << ans;
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
using namespace std;
int i, j;
const int num = 100002;
const int numm = 1 + num / 2;
const int INF = 1000000001;
struct Card {
    int numc;
    char pic;
};
Card A[num], B[num];
inline int partition(int p, int r) {
    int base = A[r].numc;
    int q = p - 1;
    for (i = p; i < r; i++) {
        if (A[i].numc <= base)
            swap(A[++q], A[i]);
    }
    swap(A[++q], A[r]);
    return q;
}
inline void quickSort(int p, int r) {
    if (r > p) {
        int a = partition(p, r);
        quickSort(p, a - 1);
        quickSort(a + 1, r);
    }
}
inline void merge(int left, int mid, int right) {
    int n1 = mid - left, n2 = right - mid;
    Card I[numm], J[numm];
    for (i = 0; i < n1; i++)
        I[i] = B[left + i];
    for (i = 0; i < n2; i++)
        J[i] = B[mid + i];
    int a = 0, b = 0;
    I[n1].numc = J[n2].numc = INF;
    for (i = left; i < right; i++) {
        if (I[a].numc <= J[b].numc)
            B[i] = I[a++];
        else B[i] = J[b++];
    }
}
inline void mergeSort(int left, int right) {
    if (right > left + 1) {
        int mid = (left + right) / 2;
        mergeSort(left, mid);
        mergeSort(mid, right);
        merge(left, mid, right);
    }
}
int main() {
    int n, v, sta = 1;
    char c[2];
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s%d", c, &v);
        A[i].numc = B[i].numc = v;
        A[i].pic = B[i].pic = c[0];
    }
    quickSort(0, n - 1);
    mergeSort(0, n);
    for (i = 0; i < n - 1; i++) {
        if (A[i].pic != B[i].pic)
            sta = 0;
    }
    if (sta) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
    for (i = 0; i < n; i++) {
        printf("%c %d\n", A[i].pic, A[i].numc);
 
    }
    return 0;
}

Measured memory_bytes: 5572
n = int(input())
for i in range(n):
    out = 0
    cnt = 0
    ro = [0for i in range(3)]
    while True:
        o = str(input())
        if (o == 'HIT'):
            cnt += ro[2]
            ro = [1] + ro[:2]
        elif (o == 'OUT'):
            out += 1
        elif (o == 'HOMERUN'):
            cnt += (sum(ro)+1)
            ro = [0for i in range(3)]
        if (out == 3):
            print(cnt)
            break
            
        


Measured memory_bytes: 5604
//50000 for aizu0056
//1000000 for aizu0185
#define M 32768
p[M+1];


main(i,j,n){
  p[1]=1;
  for(;i<=M;i++)
    if(!p[i])
      for(j=i*2;j<=M;j+=i)
        p[j]=1;
  for(;scanf("%d",&n),n;printf("%d\n",j))
    for(i=2,j=0;i<=n/2;i++)
      if(!p[i]&&!p[n-i])j++;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    char b;
    cin >> b;
    cout << (b == 'A' ? 'T' : b == 'T' ? 'A' : b == 'G' ? 'C' : 'G') << endl;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int s = 0;
  for (int i = 0; i < k; i++) {
    s += v.at(i);
  }
  cout << s << endl;
}

Measured memory_bytes: 256
//14:07:00 

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b; cin>>a>>b;
	if(a==2 || b==2) cout<<"No\n";
	else if((a==4 || a==6 || a==9 || a==11) && (b==4 || b==6 || b==9 || b==11)) cout<<"Yes\n";
	else if(a==4 || a==6 || a==9 || a==11) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}











Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
#dp[i]:=iにつくまでの最小コスト
dp=[1145141919810 for i in range(n)]
dp[0]=0
dp[1]=abs(A[0]-A[1])
for i in range(2,n):
  dp[i]=min(dp[i-2]+abs(A[i-2]-A[i]),dp[i-1]+abs(A[i-1]-A[i]))
print(dp[n-1])

Measured memory_bytes: 13924
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define endl '\n';
typedef long long ll;
typedef long double ld;
using namespace std;


int main() {
  const int mod = 1e9 + 7;
  int n, m;
  scanf("%d%d", &n, &m);
  vector<ll> ways(n + 1, 0);
  vector<int> bad(n + 1, 0);
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    bad[x] = 1;
  }
  ways[0] = 1;
  if (!bad[1]) ways[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (!bad[i - 2]) ways[i] = (ways[i] + ways[i - 2]) % mod;
    if (!bad[i - 1]) ways[i] = (ways[i] + ways[i - 1]) % mod;
  }
  cout << ways[n] << endl;
  return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main()
{
    ll N, K;
    cin >> N >> K;
    ll sum = 0;
    REP(i, N)
    {
        cin >> A[i];
        sum += A[i];
    }

    vector<pll> v;
    //! 各bitを反転させるとどれだけ増える？
    REP(i, 40)
    {
        ll s = 0;
        ll bit = ((ll)1 << i);
        REP(j, N)
        {
            if ((A[j] & bit) > 0)
                s -= bit;
            else
                s += bit;
        }
        if (s > 0)
        {
            v.push_back(pll(bit, s));
        }
    }
    sort(v.begin(), v.end(), [](pll a, pll b) { return a.second == b.second ? a.first > b.first : a.second > b.second; });

    ll n = 0;
    REP(i, v.size())
    {
        if ((n | v[i].first) <= K)
        {
            n |= v[i].first;
            sum += v[i].second;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    int i;
    long ans=0;
    long count[100001];
    for(i=0;i<100001;i++){
        count[i]=0;
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        ans += a[i];
        count[a[i]]++;
    }
    int q;
    scanf("%d",&q);
    int b[q], c[q];
    
    for(i=0;i<q;i++){
        scanf("%d %d",&b[i],&c[i]);
    }
    for(i=0;i<q;i++){
        ans += count[b[i]]*(c[i]-b[i]);
        count[c[i]] += count[b[i]];
        count[b[i]]=0;
        printf("%ld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 4084
#include <cstdio>
#include <string.h>
#include <stdio.h>

using namespace std;
int main(){
    int a;
    int b;
    int c;
    char n1;
    char e;
    
    scanf("%d", &a);
    scanf("%c", &n1);
    scanf("%c", &e);
    scanf("%d", &b);
    if('+' == e){
        c = (a + b);
    };
    if('-' == e){
        c = (a - b);
    };
    printf("%d\n", c);




}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;++i)
int r[18][100000],x[100000];
int main(){
    int i,j,n,L,Q,a,b;
    cin>>n;
    rep(i,n)cin>>x[i];
    cin>>L;
    rep(i,n)r[0][i]=upper_bound(x,x+n,x[i]+L)-x-1;
    rep(i,17)rep(j,n)r[i+1][j]=r[i][r[i][j]];
    cin>>Q;
    rep(j,Q){
        cin>>a>>b;--a;--b;
        if(a>b)swap(a,b);
        int ans=0,now=a;
        for(i=17;i>=0;--i)if(r[i][now]<b){now=r[i][now];ans+=1<<i;}
        if(now<b){now=r[0][now];++ans;}
        cout<<ans<<'\n';
    }
}


Measured memory_bytes: 8192
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	var s string
	if sc.Scan() {
		s = sc.Text()
	}

	i, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		panic(err)
	}

	fmt.Println(i * i * i)
}


Measured memory_bytes: 1056
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	int y1, m1, d1, y2, m2, d2;
	in >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;

	if (y1 > y2)
	{
		std::swap(y1, y2);
		std::swap(m1, m2);
		std::swap(d1, d2);
	}
	else if (y1 == y2)
	{
		if (m1 > m2)
		{
			std::swap(y1, y2);
			std::swap(m1, m2);
			std::swap(d1, d2);
		}
		else if (m1 == m2 && d1 > d2)
		{
			std::swap(y1, y2);
			std::swap(m1, m2);
			std::swap(d1, d2);
		}
	}

	if (y1 == y2 && m1 == m2 && d1 == d2) out << 0 << std::endl;
	else if (m1 < m2 || (m1 == m2 && d1 < d2)) out << y2 - y1 + 1 << std::endl;
	else out << y2 - y1 << std::endl;
	return 0;
}


Measured memory_bytes: 3120
N,Ma,Mb=map(int,input().split())
medic=[tuple(map(int,input().split())) for i in range(N)]
from collections import defaultdict
dp=defaultdict(lambda : float('inf'))
dp[(0,0)]=0
for a,b,c in medic:
    dpc=dp.copy()
    for k,v in dpc.items():
        x,y=k
        dp[(x+a,y+b)]=min(dp[(x+a,y+b)],v+c)
ans=10**10
for i in range(1,1+N):
    ans=min(ans,dp[(Ma*i,Mb*i)])
if ans>10**9:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 10836
import math
import fractions
from functools import reduce


def main():
    n, x = input_list()
    a = input_list()
    a.append(x)
    sa = list(sorted(a))
    kukan = []
    for i, v in enumerate(sa):
        if i+1 > len(sa)-1:
            break
        d = sa[i+1] - v
        kukan.append(d)
    print(gcd_list(kukan))


def input_list():
    return list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == "__main__":
    main()


Measured memory_bytes: 89620
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;

int main(){

	int n, a[100000], max_a=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]>max_a){
			max_a=a[i];
		}
	}
	if(n==2){
		sort(a, a+n);
		cout << a[1] <<" "<< a[0] << endl;
		return 0;
	}
	int half=max_a/2;
	int sa=1000000001;
	int ans;
	for(int i=0; i<n; i++){
		if(sa>abs(half-a[i])){
			sa=abs(half-a[i]);
			ans=a[i];
		}
	}
	cout << max_a <<" "<< ans << endl;

	return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    int ans = -Inf;
    cin >> n >> m;
    double base = m / n;
    FOR (i, 1, sqrt(m + 1) + 1) {
        if (m % i == 0) {
            if (base >= i) ans = max(ans, i);
            if (base >= m / i) ans = max(ans, m / i);
        }
    }
    cout << ans << endl;
    
    return 0;
}



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

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int n;
long long x[50], y[50];

int check(long long xma, long long xmi, long long yma, long long ymi) {
  int ret = 0;
  rep(k, n) {
    if (xmi <= x[k] and x[k] <= xma and ymi <= y[k] and y[k] <= yma) ++ret;
  }
  return ret;
}

int main() {
  int K; cin>>n>>K;
  rep(i, n) cin>>x[i]>>y[i];
  long long ans = LLINF;
  rep(i, n) rep(j, n) rep(k, n) rep(l, n) {
    long long xma, xmi, yma, ymi;
    xma = max(x[i], x[j]); xmi = min(x[i], x[j]);
    yma = max(y[k], y[l]); ymi = min(y[k], y[l]);
    if (check(xma, xmi, yma, ymi) >= K) ans = min(ans, (xma-xmi) * (yma-ymi));
  }
  print(ans);

  return 0;
}


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

int c[33], s[444][33];
int sc(int i, int t, const vector<int> &v) {
    int j = i - 1, k = i + 1;
    while(j >= 0 && v[j] != t)
        j--;
    while(k < v.size() && v[k] != t)
        k++;
    return s[i][t] + c[t] * (i - j) * (k - i);
}
int main() {
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    vector<int> ss, tt;
    int M = -1e9;
    for(int a = 10; a < 16; a++) {
        for(int b = 0; b < 4; b++) {
            for(int z = 5; z < 16; z++) {
                int r = 0, l[33] = {};
                ss.clear();
                for(int i = 0; i < d; i++) {
                    auto m = 0.;
                    int t = 0;
                    for(int j = 0; j < 26; j++) {
                        double p = s[i][j];
                        p += c[j] * (i + 1 - l[j]) * .4 * a;
                        for(int k = 1; k < z; k++)
                            if(i + k < d)
                                p -= s[i + k][j] * (z - k) * .05 / z * b;
                        if(p > m)
                            m = p, t = j;
                    }
                    ss.push_back(t);
                    r -= c[t] * (i + 1 - l[t]) * (i - l[t]) / 2;
                    l[t] = i + 1;
                    r += s[i][t];
                }
                for(int j = 0; j < 26; j++)
                    r -= c[j] * (d + 1 - l[j]) * (d - l[j]) / 2;
                if(r > M)
                    M = r, tt.swap(ss);
            }
        }
    }
    random_device rd;
    mt19937 mt(rd());
    uniform_int_distribution<> rc(0, 25), r0(0, d - 1), r2(1, 16);
    uniform_real_distribution<> ru(0, 1);
    auto ti = clock();
    for(;;) {
        auto T = (clock() - ti) / 1.9 / CLOCKS_PER_SEC;
        if(T > 1)
            break;
        auto U = pow(2e3, 1 - T) * pow(6e2, T);
        for(int cn = 0; cn < 100; cn++) {
            if(rc(mt) < 13) {
                int x0 = r0(mt), xc = rc(mt);
                int di = sc(x0, xc, tt) - sc(x0, tt[x0], tt);
                if(ru(mt) <= exp(di / U))
                    tt[x0] = xc;
                continue;
            }
            int x2 = r2(mt);
            uniform_int_distribution<> r1(0, d - 1 - x2);
            int x1 = r1(mt);
            x2 += x1;
            int di = -sc(x1, tt[x1], tt) - sc(x2, tt[x2], tt);
            swap(tt[x1], tt[x2]);
            di += sc(x1, tt[x1], tt) + sc(x2, tt[x2], tt);
            if(ru(mt) > exp(di / U))
                swap(tt[x1], tt[x2]);
        }
    }
    for(int i : tt)
        cout << i + 1 << '\n';
    return 0;
}


Measured memory_bytes: 4372
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int K;
int A[100001];

ll next_f(ll a,ll b){
      return a - a%b;
}
int main (){
      cin>>K;
      rep0(i,K) cin>>A[i];
      ll left=1;
      ll right=longinf;
      int cnt=0;
      while(right-left>1){
            ll mid=(left+right)/2;
            ll a=mid;
            rep0(i,K){
                  a=next_f(a,A[i]);
            }
            //cout<<a<<" "<<left<<" "<<right<<endl;
            if(a<=2){
                  left = mid;
            }
            else{
                  right = mid;
            }
      }
      ll lef=1;
      ll rig=longinf;
      while(rig-lef>1){
            ll mid=(lef+rig)/2;
            ll a=mid;
            rep0(i,K){
                  a=next_f(a,A[i]);
            }
            if(a>=2){
                  rig = mid;
            }
            else{
                  lef = mid;
            }
      }
      if(rig<left) cout<<rig<<" "<<left<<endl;
      else cout<<-1<<endl;
      
      return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];
    sort(all(H));
    ll ans = 0;
    rep(i, max(0, N - K)) ans += H[i];
    write(ans);
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    int n,x,i,j,count=0,t;
    while(1){
        scanf("%d%d", &n, &x);
        if((n|x)==0)break;
        for(i=1;i<(double)x/3;i++)for(j=i+1;j<=n;j++){
            t=x-(i+j);
            if(t<=n&&t>j){
                count++;
            }else if(x-(i+j)<j)break;
        }
        printf("%d\n", count);
        count=0;
    }
    return 0;
}

Measured memory_bytes: 1804
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;

using VI = vector <int> ;
using VVI = vector <VI> ;

int main() {
    long long N;
    long long A;
    long long B;
    long long tot;

    cin >> N >> A >> B;
    tot = (A+B);

    long long now = N/tot;

    N -= now*tot;
    cout << now*A + min(N, A) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int n,k,c=0;
    cin >> n >> k;
    vector<int>x(n);
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        if(abs(x[i]-0)>abs(x[i]-k)){
            c+=2*abs(x[i]-k);
        }else{
            c+=2*abs(x[i]);
        }
    }
    cout << c;
}

Measured memory_bytes: 256
str_len = gets.to_i
st_array = gets.strip.split(" ").map{|i| i.to_s}
i = 0
j = 0

new_len = str_len * 2

ans =  Array.new(new_len)

while i < str_len
   ans[j] = st_array[0][i]
   ans[j + 1] = st_array[1][i]
   
   i += 1
   j += 2
end

ans.each do |i|
   print i
end


Measured memory_bytes: 1788
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    else:
        for i in range(0,H):
            if i == 0 or i == H-1:
                print("#"*W)
            else:
                for j in range(0,W):
                    print ("#",end="") if j == 0 or j == W-1 else print(".",end="")
                print()
        print()


Measured memory_bytes: 7004
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	static int[] S ;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		int N = Integer.parseInt(W.split(" ")[0]);
		int M = Integer.parseInt(W.split(" ")[1]);
		int ans = N*(N-1)/2 + M*(M-1)/2;

		System.out.println(ans);
	}


}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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


    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

    ll sumA = 0;
    for(int i = 0; i < N; i++) sumA += A[i];

    vector<ll> ret;
    ret = divisor(sumA);

    ll alt = 1;
    ll ans = 1;
    vector<ll> subvec(N);

    for(int i = 1; i < ret.size(); i++){
        alt = ret[i];

        ll sumpos = 0;
        for(int j = 0; j < N; j++){

            subvec[j] = A[j] % alt;
            sumpos += (alt - subvec[j]);
        }

        sort(subvec.begin(), subvec.end());

        ll sumneg = 0;
        for(int j = 0; j < N; j++){
            sumneg += subvec[j];
            sumpos -= (alt - subvec[j]);
            if(sumneg == sumpos){
                if(sumneg <= K){
                    chmax(ans, alt);
                }else{
                    break;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define re register
using namespace std;
const int maxn=1e4+10;
const int maxw=2e4+10;
template<typename T> void read(T &x){
	T f=1;x=0;
	char c=getchar();
	while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	x*=f;
}
int n;
struct node {
	ll w,s,v,tw;
}t[maxn];
bool cmp(node a,node b){
	return a.tw<b.tw;
}
ll f[maxw],ans;
int main(){
	cin>>n;
	for(re int i=1;i<=n;i++){
		cin>>t[i].w>>t[i].s>>t[i].v;                                                                                                                                
		t[i].tw=t[i].w+t[i].s;
	}
	sort(t+1,t+n+1,cmp);
	for(re int i=1;i<=n;i++){
		for(re int j=maxw-5;j>=t[i].w;j--){
			if(t[i].tw>=j){
				f[j]=max(f[j],f[j-t[i].w]+t[i].v);
			}
			ans=max(ans,f[j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; 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 rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  cin>>a;
  sort(rng(a));
  vi s(n);
  rep(i,n) s[i] = a[i]<0;
  s[0] = 1; s.back() = 0;
  int ans = 0;
  rep(i,n) ans += s[i]?-a[i]:a[i];
  cout<<ans<<endl;
  for (int i = 1; s[i]; ++i) {
    cout<<a.back()<<" "<<a[i]<<endl;
    a.back() -= a[i];
  }
  for (int i = n-2; !s[i]; --i) {
    cout<<a[0]<<" "<<a[i]<<endl;
    a[0] -= a[i];
  }
  cout<<a.back()<<" "<<a[0]<<endl;
  return 0;
}






















Measured memory_bytes: 2688
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

string s;
long long p_sum_M[1024 * 1024], p_sum_MC[1024 * 1024], p_sum_C[1024 * 1024];
int lst[1024 * 1024], lst_len = 0;

inline long long get_C_on_segm(int x, int y) {
	long long res = p_sum_C[y];
	if (x > 0)
		res -= p_sum_C[x - 1];
	return res;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	int n, q;
	cin >> n >> s >> q;

	for (int i = 0; i < n; i++) {
		if (i > 0) {
			p_sum_M[i] = p_sum_M[i - 1];
			p_sum_C[i] = p_sum_C[i - 1];
		}
		p_sum_M[i] += s[i] == 'M';
		p_sum_C[i] += s[i] == 'C';
	}

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

		if (s[i] == 'C')
			p_sum_MC[i] += p_sum_M[i - 1];
	}

	for (int i = 0; i < n; i++)
		if (s[i] == 'D') lst[lst_len++] = i;

	for (int i = 0; i < q; i++) {
		int k;
		cin >> k;   
		k--;   // 'C' - 'D' <= k    DMC  subst

		long long ans = 0;
		for (int j = 0; j < lst_len; j++) {
			int x = lst[j];
			ans += p_sum_MC[min(n-1, x + k)];
			if (x >= 1) {
				ans -= p_sum_MC[x - 1];
				ans -= get_C_on_segm(x + 1, min(n - 1, x + k)) * p_sum_M[x - 1];
			}
		}

		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 29956