akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct data{
  ll a,b,c;
};
ll dp[41][405][405];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,ma,mb;
cin>>n>>ma>>mb;
vector<data> d(n);
for(int i=0;i<n;i++){
  cin>>d[i].a>>d[i].b>>d[i].c;
}
for(int i=0;i<=n;i++){
  for(int j=0;j<401;j++){
    for(int k=0;k<401;k++){
      dp[i][j][k]=inf;
    }
  }
}
ll ans=inf;
dp[0][0][0]=0;
for(int i=0;i<n;i++){
  for(int j=0;j<401;j++){
    for(int k=0;k<401;k++){
      if(j+d[i].a<=400&&k+d[i].b<=400)chmin(dp[i+1][j+d[i].a][k+d[i].b],dp[i][j][k]+d[i].c);
       chmin(dp[i+1][j][k],dp[i][j][k]);
    }
  }
}
  for(int j=1;j<401;j++){
    for(int k=1;k<401;k++){
     if(j*mb==k*ma)chmin(ans,dp[n][j][k]);
    }
  }
if(ans==inf)cout<<-1<<endl;
else cout<<ans<<endl;
}



Measured memory_bytes: 52736
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
const int MAXN=60;
int n,V,d;
vector<int> ver[MAXN];
struct node {
	int v,id; ll c;
}a[MAXN];
bool operator < (const node &aa,const node &bb) {
	return aa.v*bb.c>bb.v*aa.c;
}
void dfs(int u) {
	a[u].v=1;
	for(int v:ver[u]) {
		dfs(v);
		a[u].v+=a[v].v;
		a[u].c+=a[v].c;
	}
}
ll f[MAXN*MAXN*MAXN],ans;
int main() {
	scanf("%d%d%d",&n,&V,&d);
	for(int i=1;i<=n;i++) a[i].id=i;
	scanf("%lld",&a[1].c);
	for(int i=2,fa;i<=n;i++) {
		scanf("%lld%d",&a[i].c,&fa);
		ver[fa].push_back(i);
	}
	dfs(1);
	int N=n*n*n,lim=min(n,d);
	memset(f,0x3f,sizeof(f)); f[0]=0;
	for(int i=1;i<=n;i++) {
		int x=lim;
		for(int j=0;(1<<j)<=x;j++) {
			ll c=a[i].c*(1<<j),v=a[i].v*(1<<j);
			for(int k=N;k>=v;k--)
				f[k]=min(f[k],f[k-v]+c);
			x-=1<<j;
		}
		if(x) {
			ll c=a[i].c*x,v=a[i].v*x;
			for(int k=N;k>=v;k--)
				f[k]=min(f[k],f[k-v]+c);
		}
	}
	sort(a+1,a+n+1);
	for(int i=0;i<=N;i++) if(f[i]<=V) {
		ll v=i,c=f[i];
		int j;
		for(j=1;a[j].id!=1;j++) {
			ll x=min((ll)d-lim,(V-c)/a[j].c);
			v+=x*a[j].v,c+=x*a[j].c;
		}
		ll x=(V-c)/a[j].c;
		ans=max(ans,v+x*a[j].v);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5560
n, m, q = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
pq = [list(map(int, input().split())) for i in range(q)]
li = [[0] * (n + 1) for i in range(n + 1)]
for i in lr:
    l, r = i[0], i[1]
    li[l][r] += 1
for i in range(1, n + 1):
    for j in range(1, n + 1):
        li[i][j] += li[i - 1][j] + li[i][j - 1] - li[i - 1][j - 1]
for i in pq:
    p, q = i[0], i[1]
    print(li[q][q] - li[p - 1][q] - li[q][p - 1] + li[p - 1][p - 1])

Measured memory_bytes: 63536
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(){
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> a(N);
    for(auto& t : a) cin >> t;
    long long res = accumulate(a.begin(), a.end(), 0LL);
    for(int i=0;i<N;i++){
        auto c = a;
        for(int j=0;j<N;j++){
            c[j] = min(c[j], a[(j+N-1)%N]);
        }
        a = c;
        res = min(res, accumulate(a.begin(), a.end(), 0LL) + (i+1) * K);
    }
    cout << res << endl;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();
			var x = new double[4];
			var y = new double[4];
			x[0] = array[0];
			y[0] = array[1];
			x[1] = array[2];
			y[1] = array[3];
			double[] vx1 = { x[1] - x[0], y[1] - y[0] };

			double[] vx2 = new double[2];
			double theta = 45.0 / 180.0 * Math.PI;
			vx2[0] = Math.Round((vx1[0] * Math.Cos(theta) - vx1[1] * Math.Sin(theta)) * Math.Sqrt(2));
			vx2[1] = Math.Round((vx1[0] * Math.Sin(theta) + vx1[1] * Math.Cos(theta)) * Math.Sqrt(2));
			x[2] = vx2[0] + x[0];
			y[2] = vx2[1] + y[0];

			theta = 90.0 / 180.0 * Math.PI;
			vx2[0] = Math.Round(vx1[0] * Math.Cos(theta) - vx1[1] * Math.Sin(theta));
			vx2[1] = Math.Round(vx1[0] * Math.Sin(theta) + vx1[1] * Math.Cos(theta));
			x[3] = vx2[0] + x[0];
			y[3] = vx2[1] + y[0];

			//string answer = "No";
			Console.WriteLine($"{x[2]:f0} {y[2]:f0} {x[3]:f0} {y[3]:f0}");
			Console.ReadLine();
		}
	}
}

Measured memory_bytes: 13396
#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)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,K;
int main(){
    cin >> N >> K;
    cout << N - K + 1 << '\n';
}

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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0; i<N; ++i) cin >> S.at(i);

    set<string> chr;
    for(int i=0; i<N; ++i) chr.insert(S.at(i));
    cout << chr.size() << endl;
}

Measured memory_bytes: 25040
var
f:array[0..100000] of longint;
n,i,k:longint;  s,z:ansistring;
a:array[1..100000] of longint;
function min(a,b:longint):longint;
begin
    if a<b then exit(a);
    exit(b);
end;
begin
readln(n);
readln(s);
s:=s+' ';
i:=1;
k:=0;
while pos(' ',s)>0 do
begin
   z:=copy(s,1,pos(' ',s)-1);
   val(z,k);
   a[i]:=k;
   inc(i);
   delete(s,1,pos(' ',s));
end;
f[0]:=0;
f[1]:=0;
f[2]:=abs(a[2]-a[1]);
   for i:=3 to n do
   f[i]:=min(f[i-2]+abs(a[i]-a[i-2]),f[i-1]+abs(a[i]-a[i-1]));
   writeln(f[n]);
readln
end.

Measured memory_bytes: 1804
# ALDS1_7_D: Reconstruction of the Tree

class Walker
  attr_reader :post
  def initialize(preorder, inorder)
    @pre  = preorder
    @in   = inorder
    @post = []
    @pre_pos = 0
  end

  def reconstruct(left, right)
    return if right <= left
    root = @pre[ @pre_pos ]
    @pre_pos += 1
    in_pos = @in.index root
    reconstruct(left, in_pos)
    reconstruct(in_pos + 1, right)
    @post << root
  end
end

n_nodes  = gets.to_i
preorder = gets.split.map &:to_i
inorder  = gets.split.map &:to_i

walker = Walker.new(preorder, inorder)
walker.reconstruct 0, n_nodes

puts walker.post.join(' ')

Measured memory_bytes: 8684
#include<bits/stdc++.h>
#define ll long long
#define all(v) v.begin(),v.end()
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define what(x) cout<<#x<<" is "<<x<<endl;
using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll powmod(ll a,ll b,ll mod) {
    ll res=1;a%=mod;
    //assert(b>=0);
    for(;b;b>>=1){
        if(b&1)res=res*a%mod;a=a*a%mod;
    }
    return res;
}
const int mxn=2e3+1;
const ll M=1e9+7;
ll fac[mxn],inv[mxn],invfac[mxn];
void pre(){
	fac[0]=fac[1]=inv[0]=inv[1]=invfac[0]=invfac[1]=1;
	for(ll i=2;i<mxn;i++){
		fac[i]=(fac[i-1]*i)%M;
		inv[i]=(inv[M%i]*(M-M/i))%M;
		invfac[i]=(invfac[i-1]*inv[i])%M;
	}
}

void solve(){
	ll n,ans=0;
	cin>>n;
	debug(n);
	for(ll i=1;i<=n;i++){
		ll up=n-2*i-1;
		ll down=n-3*i;
		debug(up,down);
		if(down<0||up<0)break;

		debug(fac[up],invfac[up-down],invfac[down]);
		ans+=(fac[up]*invfac[up-down]%M*invfac[down])%M;
		ans%=M;
		debug(ans);
	}
	cout<<ans<<'\n';
}


int main(){
	pre();
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    #endif
    int tc=1;
    // cin>>tc;
    while(tc--)solve();
}


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

int main(){
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  int n, k;
  scan(n, k);
  vi cnt(n, 0);
  rep (i, k) {
    int d;
    scan(d);
    rep (i, d) {
      int a;
      scan(a);
      cnt[a-1] += 1;
    }
  }
  int ans = 0;
  rep (i, n) {
    if (cnt[i] == 0) {
      ans += 1;
    }
  }
  print(ans);
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 3252
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N,K;
    cin >> N >> K;

    if(((N-1)*(N-2))/2<K){
        cout << -1 << endl;
        return 0;
    }
    int cnt=0;
    bool flag=false;
    cout << ((N-1)*(N-2))/2-K+N-1 << endl;

    REP2(i,2,N+1) cout << 1 << " " << i << endl;
    REP2(i,2,N+1){
        REP2(j,i+1,N+1){
            if(cnt==((N-1)*(N-2))/2-K) flag=true;
            if(flag) break;
            cout << i << " " << j << endl;
            cnt++;
            
        }
        if(flag) break;
    }


    
}

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

int main(){
  
  int A,B,C,D,ans;
  cin >> A >> B >> C >> D;
  
  if(B<C || D < A) ans =0;
  else if((A<C && D<B)||(C<A && B<D)){
    ans = min((B-A),(D-C));
  }
  else if(C<B || A<D) ans = min(B-C,D-A);
  
  cout << ans;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll gcdl[101010], gcdr[101010];

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

    ll ans = A[0];
    {
        rep(i, N) ans = __gcd(ans, A[i]);
    }

    {
        ll tmp = A[0];
        for (int i=1; i<N; ++i) {
            tmp = __gcd(tmp, A[i-1]);
            gcdl[i] = tmp;
        }
    }
    {
        ll tmp = A[N-1];
        for (int i=N-2; i>=0; --i) {
            tmp = __gcd(tmp, A[i+1]);
            gcdr[i] = tmp;
        }
    }

    rep(i, N) {
        ans = max(ans, __gcd(gcdr[i], gcdl[i]));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;


int N, K;


signed main(){
    cin >> N >> K;

    if(K%2) cout << POW(N/K, 3) << endl;
    else cout << POW(N/K, 3)+POW((N+K/2)/K, 3) << endl;

    return 0;
}

Measured memory_bytes: 384
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	ll n,k;
	cin>>n>>k;
	vi a(n+1);
	for(ll i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	vvi dp(n+1,vi(k+1));
	for(ll i=0;i<=n;++i)
	{
		dp[i][0]=1;
	}
	for(ll j=0;j<=k;++j)
	{
		dp[0][j]=1;
	}
	for(ll i=1;i<=n;++i)
	{
		for(ll j=1;j<=k;++j)
		{
			dp[i][j]=dp[i-1][j]%mod;
			if((j-a[i]-1)>=0)
			{
				dp[i][j]=(dp[i][j]-dp[i-1][j-a[i]-1]+mod)%mod;
			}
		}
		if(i!=n)
		{
			for(ll j=1;j<=k;++j)
			{
				dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[n][k]<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 80256
import math
N=int(input())
def hantei(u):
  if u==1:
    return 1
  for i in range(1,u+1):
    if (1/2)*i**2+(1/2)*i>u:
      return int(i-1)
    else:
      continue
   
a=[0]*int(math.sqrt(N))
for i in range(2,int(math.sqrt(N))+1):
  while N%i==0:
    N=N//i
    a[i-1]=a[i-1]+1
c=0
if N!=1:
  c+=1
for t in range(len(a)):
  if a[t]!=0:
    c+=hantei(a[t])
print(c)    

    

Measured memory_bytes: 16636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>

using namespace std;

int main()
{
    long long a=0,N;
    cin>>N;
    for(int i=1;i<=N;i++){
        if(i%3!=0&& i%5!=0){
            a+=i;
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		string ans = "No";
		if(N*M%2==1){
			ans = "Yes";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder
{
    public static class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var targets = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(i => i).ToArray();
            Console.WriteLine(targets[N / 2] - targets[N / 2 - 1]);
        }
    }
}


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

int main() {

double A,B,H,M;
cin>>A>>B>>H>>M;

double degm=360*M/60;
double degh=360*(H/12)+30*(M/60);

double deg = min(degh-degm,degm-degh);

double ans= sqrt(A*A+B*B-2*A*B*cos(deg*M_PI/180));

cout<<setprecision(15)<<ans<<endl;
}


Measured memory_bytes: 4196
#include <bits/stdc++.h> 
using namespace std;
bool order1(long long int a, long long int b){
    return a < b;
}

bool order2(pair<long long int, long long int> a, pair<long long int, long long int> b){
    return a.second > b.second;
}

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

    long long int sum = 0;
    vector<long long int> A(N);
    for(int i = 0; i < N; i++){
        cin>>A[i];
        sum += A[i];
    }

    vector< pair<long long int, long long int> > V;
    for(int i = 0; i < M; i++){
        long long int B, C;
        cin>>B>>C;
        V.push_back(make_pair(B, C));
    }

    sort(A.begin(), A.end(), order1);
    sort(V.begin(), V.end(), order2);

    int a = 0;
    int v = 0;
    bool f = 1;

    while(f){
        if(v >= V.size() || a >= A.size()) break; 
        if(A[a] > V[v].second) break;

        sum -= A[a];
        A[a] = V[v].second;
        sum += A[a];

        a++;
        V[v].first--;

        if(V[v].first == 0) v++;
    }

    cout<<sum<<endl;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <numeric>
#include <queue>
#define mod 1000000007
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define srep(i,s,t) for (ll i = s; i < t; i++)
#define drep(i,n) for(ll i = (n)-1; i >= 1; i--)
using namespace std;
typedef long long ll;
typedef vector<vector<char>> field_t;
typedef unsigned long long ull;
typedef pair<ll, ll> point_t;


int main()
{
    ll n;
    cin >> n;
    ll s;
    ll ans=0;
    vector<ll> x(n,0),h(n,0),y(n,0);
    rep(i,n){
        cin >> x[i] >> y[i] >>h[i];
        if(h[i]!=0){
            s=i;
        }
    }
    ll ansx,ansy,ansh;
    rep(dx,101){
        rep(dy,101){
            ansh=h[s]+abs(dx-x[s])+abs(dy-y[s]);
            bool T=true;
            rep(i,n){
                if(h[i]!=max((ll)0,ansh-(abs(dx-x[i])+abs(dy-y[i])))){
                    T=false;
                }
            }
            if(T){
                ansx=dx;
                ansy=dy;
                cout <<ansx <<" "<<ansy<<" "<<ansh<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

const ll INF = 1LL << 50;
int N, M, R;
int r[8];
ll dis[210][210];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M >> R;
  for (int i = 0; i < R; i++) {
    cin >> r[i];
    r[i]--;
  }
  sort(r, r + R);
  fill_n((ll*)dis, 210 * 210, INF);
  for (int i = 0; i < N; i++) {
    dis[i][i] = 0;
  }
  for (int i = 0; i < M; i++) {
    int A, B, C;
    cin >> A >> B >> C;
    A--; B--;
    dis[A][B] = dis[B][A] = C;
  }  
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }
  ll ans = INF;
  do {
    ll sum = 0;
    for (int i = 0; i + 1 < R; i++) {
      sum += dis[r[i]][r[i + 1]];
    }
    ans = min(ans, sum);
  } while (next_permutation(r, r + R));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<float.h>
#include<cfloat>
#include<string>
#include<ctype.h>
#include<algorithm>
#include<errno.h>
#include<cerrno>
#include<assert.h>
#include<cassert> 
#include<map>
#include<memory.h>
#include<cctype>
#include<ctype.h>
#include<math.h>
#include<vector> 
#include<cstdio> 
#include<set>
#include<string.h>
#include<stdio.h>
#include<new>
#include<memory>
#include<cmath>
#include<queue>
#include<cstring>
#define ll long long
#define fo(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define br break
#define ct continue
#define pb push_back
#define pi 3.141592653589793238462643383279502884197169
#define F first
#define S second
#define em empty()
#define vei vector<int>
#define ves vector<string>
#define qui queue<int> 
#define qu queue
using namespace std;
int main()
{int a,b,c,d;
 cin>>a>>b>>c>>d; 
 if(a*b>=c*d)
 cout<<a*b;
 else 
 cout<<c*d;
 return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.typecons;

void main()
{
    long X, Y;
    readf("%d %d", &X, &Y);

    if (X % Y == 0) {
        writeln("-1");
    } else {
        writeln(X * (Y+1));
    }
}

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

using i64 = std::int64_t;

constexpr i64 Mod = 998244353;

i64 pow(i64 x, i64 n) {
	i64 ret = 1;

	while (n > 0) {
		if (n % 2 == 1)
			ret = (ret * x) % Mod;

		x = (x * x) % Mod;
		n /= 2;
	}

	return ret;
}

int main() {
	i64 n;
	std::cin >> n;

	std::vector<i64> count(n);
	for (int i = 0; i < n; ++i) {
		int d;
		std::cin >> d;

		if (i == 0 && d != 0) {
			std::cout << 0 << std::endl;
			return 0;
		}

		++count[d];
	}

	if (count[0] != 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	i64 ans = 1;
	for (i64 i = 1; i < n; ++i) {
		ans *= pow(count[i - 1], count[i]);
		ans %= Mod;
	}

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

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

#define M 1000

static int
openyan (
  const char * s,
  int n
  )
{
  const char * it;

  if ( !( n % 15 ) )  return ( !strcmp ( s, "FizzBuzz" ) );
  if ( !( n % 5 ) )   return ( !strcmp ( s, "Buzz" ) );
  if ( !( n % 3 ) )   return ( !strcmp ( s, "Fizz" ) );

  for ( it = s + strlen ( s ); ( it-- ) != s; )
  {
    if ( *it - '0' != ( n % 10 ) )  return ( 0 );
    n /= 10;
  }

  return ( !( n ) );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int d[ M ], p, pp, t;
    int m, n;

    scanf ( " %d %d", &m, &n );
    if ( !( m | n ) ) break ;

    for ( i = 0; i < m; ++i )
    {
      d[ i ] = i + 1;
    }
    d[ pp = m - 1 ] = 0;

    p = 0; t = 1;
    while ( n-- )
    {
      char s[ 1024 ];

      scanf ( " %s", s );
      if ( d[ p ] == p ) continue ;

      if ( !openyan ( s, t++ ) )
      {
        const int tp = p;
        d[ pp ] = d[ p ];
        p       = d[ p ];
        d[ tp ] = -1;
      }
      else
      {
        pp  = p;
        p   = d[ p ];
      }
    }

    p = 1;
    for ( i = 0; i < m; ++i )
    {
      if ( d[ i ] != -1 )
      {
        if ( p )  p = 0;
        else      putchar ( ' ' );
        printf ( "%d", i + 1 );
      }
    }
    puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, C;
	cin >> N >> C;

	int A[400], B[400];
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];

	ll dp[401][401] = {};
	dp[0][0] = 1;
	ll mod = 1e9 + 7;

	rep(i, N) {
		ll AB[401] = {};
		for (int j = A[i]; j <= B[i]; j++) {
			ll k = 1;
			rep(p, C + 1) {
				AB[p] += k;
				AB[p] %= mod;
				k = k * j % mod;
			}
		}

		rep(j, C + 1) {
			for (int k = 0; k <= C - j; k++) {
				dp[i + 1][j + k] += dp[i][j] * AB[k] % mod;
				dp[i + 1][j + k] %= mod;
			}
		}
	}

	co(dp[N][C]);
	Would you please return 0;
}

Measured memory_bytes: 1536
from collections import deque
import sys
input = sys.stdin.readline
INF = float('inf')

def main():
    def bfs(x, y):
        L = [[INF]*W for _ in range(H)]
        L[0][0] = 1
        Q = deque([[0,0]])
        while len(Q)!=0:
            x, y = Q.popleft()
            if x==W-1 and y==H-1:
                break
            for i in range(4):
                nx, ny = x + [1,0,-1,0][i], y + [0,1,0,-1][i]
                if 0<=nx and nx<W and 0<=ny and ny<H:
                    if M[ny][nx]=='.' and L[ny][nx]==INF:
                        Q.append([nx, ny])
                        L[ny][nx] = L[y][x] + 1
        return L[H-1][W-1]
    
    H, W = map(int, input().split())
    M = []
    cnt = 0
    for _ in range(H):
        m = list(input()[:-1])
        cnt += m.count('#')
        M.append(m)

    b = bfs(0, 0)
    if b==INF:
        print(-1)
    else:
        print(H*W - cnt - b)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007
map<string, int>f, b;

signed main() {
	int n, m, ans = 0;
	string s[150], t[150];
	cin >> n;
	rep(i, n) cin >> s[i];
	cin >> m;
	rep(i, m) cin >> t[i];
	rep(i, n) {
		f[s[i]]++;
	}
	rep(i, m) {
		b[t[i]]++;
	}
	for (auto i = f.begin(); i != f.end(); i++) {
		string x = i->first;
		int y = b[x], z = i->second;
		if (z >= y) {
			ans = max(ans, z - y);
		}
	}
	cout << ans << endl;

	END;
}


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 W = sc.nextInt();

        int[] w = new int[n];
        int[] v = new int[n];

        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        
        long[][] dp = new long[n+1][W+1];
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= W; j++) {

                if(i == 0 || j == 0) {
                    dp[i][j] = 0;
                } else if(w[i-1] <= j) {
                    dp[i][j] = Math.max(v[i-1] + dp[i-1][j - w[i-1]], dp[i-1][j]);
                } else {
                    dp[i][j] = dp[i-1][j];
                }

            }
        }

        System.out.println(dp[n][W]);
    }
}

Measured memory_bytes: 127440
N=int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
ans = 2 ** (N//2)
for i in range(N-1):
    if (i%2 != 0):
        continue
    else:
        if(A[i] != N-(i+1) or A[i+1] != N-(i+1)):
            ans = 0

if (N%2 != 0 and A[-1] != 0):
    ans = 0

print(ans%(10**9+7))


Measured memory_bytes: 14008
// 問題名: The Number of Inversions
// URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_D&lang=jp
// 所要時間: 20分
// --感想--
// 転倒数の計算は平衡二分木やセグメント木を使った実装しかしたことがなかったため、マージソートを用いた実装が
// 経験できて勉強になった。

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

int main()
{
    while(1){
        int n;
        cin >> n;
        if(n == 0)
            break;
        char c;
        set<pair<pair<int, int>, int>> secs; // <<始点, 長さ>, 識別子>
        secs.insert(make_pair(make_pair(0, 2e9), -1));
        for (int i = 0; i < n; i++){
            cin >> c;
            if(c=='W'){
                int l, s;
                cin >> l >> s;
                for (auto itr = secs.begin(); itr!=secs.end(); itr++){
                    auto sec = *itr;
                    int st = sec.first.first, le = sec.first.second, nu = sec.second;
                    if(nu==-1){
                        if (s < le){ // 現在見ている区間に収まる
                            secs.erase(sec);
                            secs.insert(make_pair(make_pair(st, s), l));
                            itr = secs.insert(make_pair(make_pair(st + s, le - s), nu)).first;
                            s = 0;
                        }
                        else{ // 収まらない
                            secs.erase(sec);
                            itr = secs.insert(make_pair(make_pair(st, le), l)).first;
                            s -= le;
                        }
                    }
                    if(s==0)
                        break;
                }
            }
            else if(c=='D'){
                int l;
                cin >> l;
                for (auto itr = secs.begin(); itr != secs.end(); itr++){
                    auto sec = *itr;
                    int st = sec.first.first, le = sec.first.second, nu = sec.second;
                    if(nu==l){
                        secs.erase(sec);
                        itr = secs.insert(make_pair(make_pair(st, le), -1)).first;
                    }
                }
            }
            else{
                int p;
                cin >> p;
                int ans;
                for (auto itr = secs.begin(); itr != secs.end(); itr++){
                    auto sec = *itr;
                    if (sec.first.first <= p)
                        ans = sec.second;
                    else
                        break;
                }
                cout << ans << endl;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
int a, b, c, d;
 
int main(void){
	
	scanf("%d %d %d %d", &a, &b, &c, &d);
    
	int x = c - a, y = d - b;
	
	printf("%d %d %d %d\n", c - y, d + x, a - y, b + x);
	
    return 0;
}

Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a < b:
  if a + t * v >= b + t * w:
    print('YES')
  else:
    print('NO')
else:
  if a - t * v <= b - t * w:
    print('YES')
  else:
    print('NO')


Measured memory_bytes: 9180
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
vector<int> v[maxn];
vector<bool> vis;
void dfs(int node)
{
	vis[node] = true;
	for (auto i : v[node])
		if (!vis[i])
			dfs(i);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, m = 0, x = 0, y = 0;
	cin >> n >> m;
	vector<int> deg(n, 0);
	for (int i = 0; i < m; ++i)
	{
		cin >> x >> y; --x; --y;
		v[x].pb(y); v[y].pb(x);
	}
	int ct = 0; vis.assign(n, false);
	for (int i = 0; i < n; ++i)
		if (!vis[i])
		{
			dfs(i); ++ct;
		}
	cout << ct - 1 << endl;
}

Measured memory_bytes: 9608
#include<iostream>
#include<string>
#include<iomanip>
#include<stdio.h>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<cstdlib>

using namespace std;

int main(void){
	long n;

	cin >> n;
	if(n % 2 == 0){
		cout << n << endl;
	}else{
		cout << n*2 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >>W  >>H  >>x  >>y  >>r;
    if(x-r>=0 && x+r<=W){
        if(y-r>=0 && y+r<=H){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
   }else{
        cout<<"No"<<endl;
    
    }
    return 0;
}


Measured memory_bytes: 3116
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
a = b = cnt = 0
R = []

for i in range(1,N+1):
  R.append(i)

for permutation in itertools.permutations(R):
  cnt += 1
  if permutation == P:
    a = cnt
  if permutation == Q:
    b = cnt

ans = abs(a-b)
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>

/* 选择排序法（0起点）*/
int selectionSort(int A[], int N) {
    int i, j, t, sw = 0, minj;
    for ( i = 0; i < N; i++ ) {
        minj = i;
        for ( j = i; j < N; j++ ) {           // 我认为j可以从i+1开始
            if ( A[j] < A[minj] ) minj = j;
        }
        t = A[i]; A[i] = A[minj]; A[minj] = t;
        if ( i != minj ) sw++;
    }
    return sw;
}

int main() {
    int A[100], N, i, sw;
    
    scanf("%d", &N);
    for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
    
    sw = selectionSort(A, N);
    
    for ( i = 0; i < N; i++ ) {
        if ( i > 0 ) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);
    
    return 0;
}


Measured memory_bytes: 2724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int comb[2][2];

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  comb[0][0] = comb[1][0] = comb[1][1] = 1;
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    char c;
    cin >> c;
    a[i] = c-'0';
  }
  vector<int> a2(n-1);
  rep(i, n-1) a2[i] = abs(a[i]-a[i+1]);
  a = a2;
  --n;
  int p = 0;
  rep(i, n) {
    if (a[i]%2 == 0)
      continue;
    int pro = 1;
    rep(j, 30)
      pro *= comb[n-1>>j&1][i>>j&1];
    if (pro) 
      p ^= 1;
  }
  if (p) {
    cout << 1 << endl;
    return 0;
  }
  rep(i, n) {
    if (a[i] == 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i, n) a[i] /= 2;
  p = 0;
  rep(i, n) {
    if (a[i]%2 == 0)
      continue;
    int pro = 1;
    rep(j, 30)
      pro *= comb[n-1>>j&1][i>>j&1];
    if (pro)
      p ^= 1;
  }
  if (p)
    cout << 2 << endl;
  else
    cout << 0 << endl;
  return 0;
}

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

int main() {
	long long a, b;
	while (cin>>a>>b) {
		long long G=a,L=b;
		if (G < L)swap(G, L);
		while (G%L != 0) {
			G = G - L*(G/L);
			if(G < L)swap(G, L);
			//cout<<G<<" "<<L<<endl;
		}
		G=min(G,L);
		L=a*b/G;
		cout << G << " " << L << endl;
	}
	return 0;
}

Measured memory_bytes: 2984
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto N = readln.chomp.to!int;
    auto a = readln.split.to!(int[]);
    int cnt = 0;
    while (a.all!"a%2==0") {
        a[] /= 2;
        cnt++;
    }
    writeln(cnt);
}



Measured memory_bytes: 256
def div(n):
   return n//2
def myAnswer(N:int,A:list) -> int:
   counter = 0
   while all([i%2==0 for i in A]):
      counter+=1
      A = list(map(div,A))

   return counter

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
 int W,H,x,y,r;

 scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

 if(x+r<=W && x-r>=0 && y+r<=H && y-r>=0){printf("Yes\n");}
 else{printf("No\n");}
 return 0;
}

Measured memory_bytes: 584
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  vector<int64> d(n + 1);
  for (int i = n - 1; i >= 0; --i) {
    d[i] = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
    d[i] = n - d[i];
    d[i] += d[i + 1];
  }
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    int k = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
    ret += d[k];
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int countDigitNumber(int num);

int main(void)
{
    int a,b;
    
    while (cin >> a >> b) {
        cout << countDigitNumber(a + b) << endl;
    }
    
    return 0;
}

int countDigitNumber(int num)
{
    int digits = 0;
    
    while (num) {
        num /= 10;
        digits++;
    }
    
    return digits;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll divup(ll a, ll b){
	return (a + b - 1) / b;
}
int main(){
	int q; cin >> q;
	while(q--){
		ll a, b, c, d; cin >> a >> b >> c >> d;
		/**
		a + 1
		b / (a + 1)
		k

		a, b -> g(a, k) | b | g(a,k) | 
		x are a
		y are b

		x <= y * k

		^ y / k ^
		x >= (^ y / k ^) * k
		  **/
		ll k = (a + b)/(min(a,b) + 1);
		auto canDo = [&](ll cura, ll curb){
			if(cura < 0 || curb < 0) return -1;
			if(divup(curb, k) - 1 <= cura && cura <= curb * k) return 1;
			return 0;
		};
		ll tot = a + b;
		ll blk = -1, pre_k = -1, aafter = -1, bafter = -1;
		{
			ll lo = 1, hi = 1<<30, ans = 0;
			while(lo <= hi){
				ll mid = (hi + lo) / 2;
				ll cura = a - mid * k;
				ll curb = b - mid + 1;
				if(canDo(cura, curb) == 1) lo = mid + 1, ans = mid;
				else hi = mid - 1;
			}
			blk = ans;
			a -= blk * k;
			b -= blk;
			if(blk) b++;
		}
		bool check_a = blk == 0;
		if(blk && canDo(b - 1, a) == 1){
			b--;
			pre_k = 1;
			check_a = true;
		} else {
			pre_k = 0;
		}
		if(check_a){
			if(b == 0){
				assert(a <= k);
				aafter = a;
				a = 0;
			} else {
				ll lo = 1, hi = k, ans = 0;
				while(lo <= hi){
					ll mid = (lo + hi) / 2;
					ll cura = a - mid;
					ll curb = b;
					if(canDo(cura, curb) == 1) lo = mid + 1, ans = mid;
					else hi = mid - 1;
				}
				aafter = ans;
				a -= aafter;
			}
		} else {
			aafter = 0;
		}
		if(b > 0){
			ll lo = 1, hi = k, ans = k;
			while(lo <= hi){
				ll mid = (lo + hi)/2;
				ll cura = a;
				ll curb = b - mid;
				if(cura < 0 || curb < 0) hi = mid - 1;
				else {
					if(divup(cura, k) - 1 <= curb && curb <= cura * k) ans = mid, hi = mid - 1;
					else lo = mid + 1;
				}
			}
			bafter = ans;
			b -= bafter;
		} else {
			bafter = 0;
		}
		
		ll abad = 0, bbad = b % k;
		if(bbad) abad = 1;
		
		auto getVal = [&](ll ind){
			ll sz0 = (k + 1) * blk - min(blk, 1ll);
			if(ind <= sz0){
				if(ind % (k + 1) == 0) return 'B';
				return 'A';
			}
			ind -= sz0;
			if(ind <= pre_k) return 'B';
			ind -= pre_k;
			if(ind <= aafter) return 'A';
			ind -= aafter;
			if(ind <= bafter) return 'B';
			ind -= bafter;
			if(ind <= abad) return 'A';
			ind -= abad;
			if(ind <= bbad) return 'B';
			ind -= bbad;
			if(ind % (k + 1) == 1) return 'A';
			return 'B';
		};
		for(int i = c; i <= d; i++){
			cout << getVal(i);
		}
		cout << endl;
	}
	return 0;
}


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

int cal(long long x, long long mid, vector<long long> &a) {
    int s = upper_bound(a.begin(), a.end(), x+mid) - lower_bound(a.begin(), a.end(), x-mid);
    int t = a.end() - upper_bound(a.begin(), a.end(), x + mid);
    return t - s;
}

int lowerindex(long long x, vector<long long> &a) {
    int ret = lower_bound(a.begin(), a.end(), x) - a.begin();
    return ret;
}

int upperindex(long long x, vector<long long> &a) {
    int ret = upper_bound(a.begin(), a.end(), x) - a.begin();
    return ret;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q; cin >> n >> q;
    vector<long long> a(n), sum(n+1, 0), sum2(n+1, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        sum[i+1] = sum[i] + a[i];
        sum2[i+1] = sum2[max(0, i-1)] + a[i];
    }
    for (int qi = 0; qi < q; qi++) {
        long long x; cin >> x;
        if (a[n-2] <= x) {
            cout << sum2[n] << "\n";
            continue;
        }
        long long left = 0; long long right = 1e9;
        long long mid; int s;
        while (right - left > 1) {
            mid = (left + right) / 2;
            s = cal(x, mid, a);
            if (s < 0) right = mid;
            else if (s > 1) left = mid;
            else {
                left = mid;
                break;
            }
        }
        s = cal(x, left, a);
        int u = lowerindex(x-left, a);
        int v = upperindex(x+left, a);
        if (s == 2) {
            u--; s--;
        }
        long long ans = sum[n] - sum[v];
        if (s == 1) ans += sum2[max(0, u-1)];
        else if (s == 0) ans += sum2[max(0, u)];
        cout << ans << "\n";
    }
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> P(N), Q(N);
    REP(i, N) cin >> P[i];
    REP(i, N) cin >> Q[i];

    vector<ll> perm(N);
    ll a, b;
    ll count = 0;
    REP(i, N) perm[i] = i + 1;
    do{
        count++;
        bool flagP = true, flagQ = true;
        REP(i, N)
        {
            if (perm[i] != P[i]) flagP = false;
            if (perm[i] != Q[i]) flagQ = false;
        }
        if (flagP) a = count;
        if (flagQ) b = count;
    } while(next_permutation(ALL(perm)));

    ll ans = abs(a - b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> count(4);
    for(int i=0; i<N; i++){
        string str;
        cin >> str;
        if (str=="AC")
            count.at(0)++;
        else if(str=="WA")
            count.at(1)++;
        else if(str=="TLE")
            count.at(2)++;
        else if (str=="RE")
            count.at(3)++;
    }
    
    cout << "AC x " << count.at(0) << endl;
    cout << "WA x " << count.at(1) << endl;
    cout << "TLE x " << count.at(2) << endl;
    cout << "RE x " << count.at(3) << endl;
}

Measured memory_bytes: 3640