akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    vector<vector<int>>pas(n);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        pas[a[i]-1].push_back(b[i]-1);
    }
    int s,t;
    cin>>s>>t;
    s--;
    t--;
    queue<pair<int,int>>q;
    q.push({s,0});
    int check[n][3]={};
    check[s][0]=1;
    while(q.size()){
        int f=q.front().first,d=q.front().second;
        q.pop();
        if(f==t && d%3==0){
            cout<<d/3<<endl;
            return 0;
        }
        for(int i=0;i<pas[f].size();i++){
            if(check[pas[f][i]][(d+1)%3]==0){
                check[pas[f][i]][(d+1)%3]=1;
                q.push({pas[f][i],d+1});
            }
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

Measured memory_bytes: 7680
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  ll N;
  while (cin >> N) {
    if (N == 1) {
      cout << "Yes" << endl;
      cout << 2 << endl;
      cout << 1 << " " << 1 << endl;
      cout << 1 << " " << 1 << endl;
      continue;
    }
    ll k = -1;
    for (ll i = 1; i <= N; i++) {
      if (i * (i - 1) / 2 == N) {
        k = i;
        break;
      }
    }
    if (k < 0) {
      cout << "No" << endl;
      continue;
    }
    vec<ll, 2> res(k);
    ll x = 1;
    for (int i = 0; i < k; i++) {
      for (int j = i + 1; j < k; j++) {
        res[i].push_back(x);
        res[j].push_back(x);
        ++x;
      }
    }
    cout << "Yes" << endl;
    cout << k << endl;
    for (int i = 0; i < k; i++) {
      cout << res[i].size();
      for (ll x : res[i]) cout << " " << x;
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
x, n = map(int, input().split())
p = list(map(int, input().split()))

p_all = set(range(0, 102)) - set(p)
# print(p_all)

mi = float('inf')
ans = 0
for i in p_all:
    if abs(x - i) < mi:
        mi = abs(x - i)
        ans = i

print(ans)


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll a,b;
    cin >> a >> b;
    if(a > 0){
        cout << "Positive" <<endl;
    }
    else if(a == 0){
        cout << "Zero" <<endl;
    }
    else{
        if(b >= 0){
            cout << "Zero" <<endl;
        }
        else{
            if((b-a) % 2 == 0){
                cout << "Negative" <<endl;
            }
            else{
                cout << "Positive" <<endl;
            }
        }
    }


}   

Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            long iA = long.Parse(sS[0]);
            long iB = long.Parse(sS[1]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            long iOut = 0;
            if (iA % 2 == 0)                                // 偶数
            {
                if (iB % 2 == 0)                            // 偶数
                {
                    long iDef = ((iB - 1 - iA) + 1) / 2;
                    if (iDef % 2 == 0) { iDef = 0; }        // 偶数
                    else { iDef = 1; }                      // 奇数
                    iOut = iB ^ iDef;
                }
                else                // 奇数
                {
                    long iDef = ((iB - iA) + 1) / 2;
                    if (iDef % 2 == 0) { iOut = 0; }        // 偶数
                    else { iOut = 1; }                      // 奇数
                }
            }
            else                                            // 奇数
            {
                if (iB % 2 == 0)                            // 偶数
                {
                    long iDef = (((iB - 1) - (iA + 1)) + 1) / 2;
                    if (iDef % 2 == 0) { iDef = 0; }        // 偶数
                    else { iDef = 1; }                      // 奇数
                    iOut = iA ^ iB ^ iDef;
                }
                else                                        // 奇数
                {
                    long iDef = ((iB - (iA + 1)) + 1) / 2;
                    if (iDef % 2 == 0) { iOut = iA ^ 0; }   // 偶数
                    else { iOut = iA ^ 1; }                 // 奇数
                }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, d;
int x[10][10];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> d;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            double sum = 0;
            for (int k = 0; k < d; k++)
            {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            sum = sqrt(sum);
            if (ceil(sum) == floor(sum))
            {
                ans++;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         1e9+7
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";}
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;

// map<ll,vector<ll> > M;
// map<ll,vector<ll> >:: iterator it;
// it = M.begin();
// it.F will be ll
// it.S will be vector<ll>

using namespace std;

bool SbS(const pair<int,int> &a,const pair<int,int> &b)
{return (a.second < b.second);}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;
}

ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll rd(dl x)
{

        if((ll)x==x)
            return (ll)x;
        else
            return ((ll)x);
}


int main()
{
ll t=1;
//cin >> t;
while(t--)
{
    ll n,m,k,i,j,l,u,v,x,y,a,b,c,d;
    cin >> n;
    vector<ll> V(n);
    CIN(V,0,n);
    sort(all(V));
    ll choice = V[n/2] - V[n/2-1];

    cout << choice;
}
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){

	int S, h, m, s;

	scanf ("%d", &S);

	h = S/3600;

	m = ( S%3600 ) / 60;

	s = ( S%3600 ) % 60;


	printf ("%d:%d:%d\n", h, m, s);

	return 0;

}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

ll binary_search(
    ll lo, ll hi, function<bool(ll)> is_ok,
    bool maximize
){
    while(lo < hi){
        if(maximize){
            const ll mid = (lo + hi + 1) / 2;
            if(is_ok(mid)){
                lo = mid;
            }else{
                hi = mid - 1;
            }
        }else{
            ll mid = (lo + hi) / 2;
            if(mid == hi){ mid--; }
            if(is_ok(mid)){
                hi = mid;
            }else{
                lo = mid + 1;
            }
        }
    }
    return lo;
}

ll ceildiv(ll x, ll y){
    if(x >= 0 && y > 0){
        return (x + y - 1) / y;
    }else if(x >= 0 && y < 0){
        return - x / abs(y);
    }else if(x < 0 && y > 0){
        return - abs(x) / y;
    }else{
        assert(x < 0 && y < 0);
        return (abs(x) + abs(y) - 1) / abs(y);
    }
}

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    const ll maxval = ll(1e18) + 1;
    const ll minval = - maxval;

    ll ans = ::binary_search(
        minval, maxval,
        [&](ll x){
            ll count = 0;
            REP(i, n){
                ll tmp = 0;
                if(a.at(i) == 0){
                    if(x > 0){
                        tmp = n - 1 - i;
                    }
                }else if(a.at(i) > 0){
                    const ll y = ceildiv(x, a.at(i));
                    // ll y;
                    // if(x >= 0){
                    //     y = (x + a.at(i) - 1) / a.at(i);
                    // }else{
                    //     y = - abs(x) / a.at(i);
                    // }
                    const auto it_start = a.begin() + i + 1;
                    tmp = lower_bound(it_start, a.end(), y) - it_start;
                }else{
                    assert(a.at(i) < 0);
                    ll y;
                    if(x >= 0){
                        y = - (x + abs(a.at(i)) - 1) / abs(a.at(i));
                    }else{
                        y = abs(x) / abs(a.at(i));
                    }
                    const auto it_start = a.begin() + i + 1;
                    tmp = a.end() - upper_bound(it_start, a.end(), y);
                }
                count += tmp;
            }
            return count < k;
        },
        true
    );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
using ll = long long;
ll solve(vector<ll> a){
	sort(all(a));
	int N = a.size();
	if(N%2==1){
		ll ans = 0;
		for(int i=N/2+1;i<N;i++) ans += a[i]*2;
		rep(i,N/2+1){
			if(i>=N/2-1) ans -= a[i];
			else ans -= 2*a[i];
		}
		return ans;
	}else{
		ll ans = 0;
		for(int i=N/2;i<N;i++){
			if(i==N/2) ans += a[i];
			else ans += 2*a[i];
		}
		rep(i,N/2){
			if(i==N/2-1) ans -= a[i];
			else ans -= 2*a[i];
		}
		return ans;
	}
}
int main(){
	int N;
	cin>>N;
	vector<ll> a(N);
	rep(i,N) cin>>a[i];
	ll ans = solve(a);
	rep(i,N) a[i] = -a[i];
	chmax(ans,solve(a));
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
fun main(args:Array<String>):Unit {
    val (a, b, c, x, y) = readLine()!!.split(' ').map(String::toInt)
    var aNum = 0
    var bNum = 0
    var cNum = 0
    if (a + b > c * 2){
        cNum += min(x, y) * 2
        if (a >= c * 2 && cNum < x * 2){
            cNum += (x - cNum / 2) * 2
        }
        if (b >= c * 2 && cNum < y * 2){
            cNum += (y - cNum / 2) * 2
        }
        aNum = if (x - cNum / 2 > 0) x - cNum / 2 else 0
        bNum = if (y - cNum / 2 > 0) y - cNum / 2 else 0
    }else{
        aNum = x
        bNum = y
    }
    println(a * aNum + b * bNum + c * cNum)
}
fun min(a:Int, b:Int):Int = if (a < b) a else b

Measured memory_bytes: 38140
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int len = min(s.size(), t.size()); ; --len) {
        if (s.substr((int)s.size() - len, len) == t.substr(0, len)) {
            cout << s.size() + t.size() - len << endl;
            exit(0);
        }   
    }   
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, M, a[1123], b[1123], c[1123][123];
int memo[1123][1 << 13];

int dp(int i, int j) {
	if (memo[i][j] != -1) return memo[i][j];
	if (!i) {
		if (j) {
			return 1000000000;
		}
		else {
			return 0;
		}
	}

	int ret = dp(i - 1, j);

	int mask = 0;//(1 << N) - 1;
	rep(t, b[i - 1]) {
		mask ^= 1 << (c[i - 1][t] - 1);
	}

	for (int t = 0+ (1 << N)-1; t < (1 << N); ++t) {
		ret = min(ret, dp(i - 1, j & (~(t & mask))) + a[i - 1]);
	}

	return memo[i][j] = ret;
}

int main() {

	memset(memo, 0xff, sizeof(memo));

	set<int> s;
	scanf("%d%d", &N, &M);
	rep(i, M) {
		scanf("%d%d", &a[i], &b[i]);
		rep(j, b[i]) {
			scanf("%d", &c[i][j]);
			s.insert(c[i][j]);
		}
	}
	if (s.size() != N) {
		printf("-1\n");
		return 0;
	}

	printf("%d\n", dp(M, (1 << N) - 1));

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

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

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

void solve() {
  vi32 ns(4); cin >> ns;
  sort(all(ns));
  if (ns[0] == 1 && ns[1] == 4 && ns[2] == 7 && ns[3] == 9) yes(); no();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<vector<char>>date(3,vector<char>(3));
  for(int i=0;i<3;i++){
  for(int j=0;j<3;j++){
  
  cin>>date.at(i).at(j);
  }
  }
cout<<date.at(0).at(0)<<date.at(1).at(1)<<date.at(2).at(2)<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	a++;

	int s = 0;
	for (int i = 0; i < b; i++)
	{
		int x;
		cin >> x;

		s += x;
	}

	cout << (a + s - 1) / a << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

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

	for(int k=28;k>=0;k--)
	{
		ll tmp=0;
		for(int i=0;i<n;i++)
			a[i]%=(1LL<<(k+1));
		for(int i=0;i<n;i++)
			b[i]%=(1LL<<(k+1));
		//aを固定する
		sort(b,b+n);
		for(int i=0;i<n;i++)
		{
			tmp+=lower_bound(b,b+n,(1<<k)*2-a[i])-lower_bound(b,b+n,(1<<k)-a[i]);
			tmp+=lower_bound(b,b+n,(1<<k)*4-a[i])-lower_bound(b,b+n,(1<<k)*3-a[i]);
		}
		if(tmp&1)
			ans+=(1<<k);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

stdin.ReadLine()
|> readIntArray
|> Array.groupBy (fun x ->
    if x >= 3200 then "A"
    elif x >= 2800 then "B"
    elif x >= 2400 then "C"
    elif x >= 2000 then "D"
    elif x >= 1600 then "E"
    elif x >= 1200 then "F"
    elif x >= 800 then "G"
    elif x >= 400 then "H"
    else "I")
|> Array.fold (fun (min, max) (x, arr) -> if x = "A" then (min, max + (arr |> Array.length)) else (min + 1, max + 1))
       (0, 0)
|> fun (a, b) -> if a = 0 then printfn "1 %d" b else printfn "%d %d" a b


Measured memory_bytes: 30128
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stdbool.h>
#include<math.h>
#include<sstream>
typedef long long ll;
#define N (1000000000+7)
#define INF (-1000000)
using namespace std;
typedef pair<int, int> P;

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

int d[55][55];

char board[55][55];
int h, w;

int bfs() {
	queue<P>q;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			d[i][j] = INF;
		}
	}
	q.push(P(1, 1));
	d[1][1] = 0;
	while (!q.empty()) {
		P p = q.front();q.pop();
		if ((p.first == h) && (p.second == w))break;
		for (int i = 0;i < 4;i++) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if ((1 <= nx) && (nx <= h) && (1 <= ny) && (ny <= w) && (board[nx][ny] != '#') && (d[nx][ny] == INF)) {
				q.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return d[h][w];
}

int main(void) {
	cin >> h >> w;
	int x = 0;
	for (int i = 1;i <= h;i++) {
		for (int j = 1;j <= w;j++) {
			cin >> board[i][j];
			if (board[i][j] == '.')x++;
		}
	}
	int a = bfs();
	if (a == INF) {
		cout << -1 << endl;
	}
	else {
		cout << x - (a + 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int ll

int ans[101010];
int dam[101010];
int n;
int32_t main()
{
    usecppio
    cin >> n;
    int total = 0;
    for (int i = 0; i<n; i++)
    {
        cin >> dam[i];
        total += dam[i];
    }
    int oddsum = 0; 
    for (int i = 1; i<n; i+=2)
    {
        oddsum += dam[i];
    }
    ans[0] = total - (2*oddsum);
    cout << ans[0] << ' ';
    for (int i = 1; i<n; i++)
    {
        ans[i] = dam[i-1]*2 - ans[i-1];
        cout << ans[i] << ' ';
    }
    cout << '\n';
    
}

Measured memory_bytes: 2944
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3+5;
map<int,int> m1;
int sz;
int ans;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        if(x==i){
            sz++;
        }else{
            if(sz){
                
                ans+=((sz/2)+(sz%2));
                sz = 0;
            }
        }
        
    }
    if(sz){
               
                ans+=((sz/2)+(sz%2));
                 sz = 0;
            }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
let n, a, b, c, d, s = Scanf.scanf " %d %d %d %d %d %s" @@ fun a b c d e f -> a, b - 1, c - 1, d - 1, e - 1, f
let s2 = String.sub s a @@ max c d - a + 1
let s3 = String.sub s (b - 1) @@ min (n - b + 1) @@ d - b + 3
let _ =
  try Str.search_forward (Str.regexp "##") s2 0 |> ignore; print_endline "No"; exit 0 with _ -> ();
  print_endline @@ if d < c then
    try Str.search_forward (Str.regexp "\\.\\.\\.") s3 0 |> ignore; "Yes" with _ -> "No"
  else "Yes"

Measured memory_bytes: 3200
#include <iostream>

using namespace std;

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

    int x_top=x+r,x_btm=x-r;
    int y_top=y+r,y_btm=y-r;

    if (x_top <= W && x_btm >=0 && y_top <= H && y_btm >=0)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No"  << endl;
    }
    
    
}


Measured memory_bytes: 3116
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from itertools import permutations, combinations,combinations_with_replacement,product
from fractions import Fraction as frac
import bisect
import heapq

import logging
logging.basicConfig(level=logging.DEBUG)

import sys
#input = sys.stdin.readline().rstrip

setrecursionlimit(1000000)

MOD = 10**9+7
INF = float('inf')

def main():
    S=input()
    A=['SUN','MON','TUE','WED','THU','FRI','SAT','SUN' ]

    print(7-A.index(S))
main()


Measured memory_bytes: 69228
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
int main(){
    string strInput, strTemp;
    vector<string> vecNotation;
    vector<int> vecAns;
    getline(cin, strInput);
    stringstream ss;
    ss << strInput;
    while(ss >> strTemp) vecNotation.push_back(strTemp);
    ss.clear();
    for(string k:vecNotation){
        int n, m;
        switch(k[0]){
            case '+':
                m = vecAns.back();
                vecAns.pop_back();
                n = vecAns.back();
                vecAns.pop_back();
                vecAns.push_back(n+m);
                break;
            case '-':
                m = vecAns.back();
                vecAns.pop_back();
                n = vecAns.back();
                vecAns.pop_back();
                vecAns.push_back(n-m);
                break;
            case '*':
                m = vecAns.back();
                vecAns.pop_back();
                n = vecAns.back();
                vecAns.pop_back();
                vecAns.push_back(n*m);
                break;
            default:
                int num;
                stringstream SS;
                SS << k;
                SS >> num;
                vecAns.push_back(num);
        }
    }
    cout << vecAns[0];
    cout<<endl;
}


Measured memory_bytes: 3156
import numpy as np

H, W = map(int, input().split())
As = [list(map(int, input().split())) for _ in range(H)]
Bs = [list(map(int, input().split())) for _ in range(H)]

ds = [[abs(A-B) for A, B in zip(row_A, row_B)] for row_A, row_B in zip(As, Bs)]

size = 10005

dp = np.full((H, W, size), False)
dp[0][0][ds[0][0]] = True
for i in range(H):
    for j in range(W):
        if i+1 < H:
            d = ds[i+1][j]
            dp[i+1][j][d:] = np.logical_or(dp[i][j][:size-d], dp[i+1][j][d:])
            dp[i+1][j][:size-d] = np.logical_or(dp[i][j][d:], dp[i+1][j][:size-d])
            dp[i+1][j][:d+1] = np.logical_or(dp[i][j][d::-1], dp[i+1][j][:d+1])
        if j+1 < W:
            d = ds[i][j+1]
            dp[i][j+1][d:] = np.logical_or(dp[i][j][:size-d], dp[i][j+1][d:])
            dp[i][j+1][:size-d] = np.logical_or(dp[i][j][d:], dp[i][j+1][:size-d])
            dp[i][j+1][:d+1] = np.logical_or(dp[i][j][d::-1], dp[i][j+1][:d+1])

print(np.min(np.where(dp[-1][-1])))


Measured memory_bytes: 89376
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    a = LI()
    c = defaultdict(lambda :0)
    for i in a:
        c[i] += 1
    a = [[i,2-(j&1)] for (i,j) in c.items()]
    a.sort()
    s = 0
    c = 0
    for i in range(len(a)):
        if a[i][1] == 2:
            c += 1
        s += a[i][1]
    s -= c
    if c&1:
        s -= 1
    print(s)
    return

#Solve
if __name__ == "__main__":
    solve()


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int dp[3005][3005] = {};
//i番目まで見た時の1がj個あるような状態
int main() {
    int N, M;
    int cnt[3005] = {};
    int A[3005];
    
    string S;
    
    cin >> N >> M >> S;
    for (int i = 0; i < N; i++) {
        cnt[i + 1] = S[i] == '1';
        cnt[i + 1] += cnt[i];
    }

    for (int i = 0; i <= N; i++) A[i] = i; 
    for (int i = 0; i < M; i++) {
        int l, r;
        cin >> l >> r;
        A[l] = max(A[l], r);
    }
    
    for (int i = 1; i <= N; i++) A[i] = max(A[i], A[i - 1]);

    dp[0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            if (dp[i][j] == 0) continue;
            if (cnt[A[i + 1]] >= j + 1) (dp[i + 1][j + 1] += dp[i][j]) %= mod;
            if (A[i + 1] - cnt[A[i + 1]] >= i - j + 1) (dp[i + 1][j] += dp[i][j]) %= mod;
        }
    }
    cout << dp[N][cnt[N]] << endl;
    return (0);
}

Measured memory_bytes: 34048
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int x=sc.nextInt();
        int[] nums=new int[n];
        int ans=Math.abs(sc.nextInt()-x);
        for(int i=1;i<n;i++){
            ans=Euclid(ans,Math.abs(sc.nextInt()-x));
        }
        System.out.println(ans);

    }
        private static int Euclid(int n, int m) {
        int tmp;
        while (true) {
            if (n == 0) {
                return m;
            } else if (m == 0) {
                return n;
            }
            tmp = n;
            n = m;
            m = tmp;
            n = n % m;

        }

    }
}


Measured memory_bytes: 51420
#include <bits/stdc++.h>
using namespace std;
int a[2010];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);

    int ans=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            int num1=a[i];
            int num2=a[j];
            int temp=j+1;
            while(num1+num2>a[temp] && temp<=n-1)
            {
                temp++;
            }
            if(temp==n) temp==n-1;
            if(temp==j) continue;
            temp--;
            int num=temp-j;
            ans+=num;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
using namespace std;
priority_queue<int> q;
int main()
{
    int n,m;cin>>n>>m;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        q.push(a);
    }
    for(int i=0;i<m;i++)
    {
        a=q.top()/2;
        q.pop();
        q.push(a);
    }
    ll sum=0;
    while(!q.empty())
    {
        sum+=q.top();
        q.pop();
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3884
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int dp[60005];
const int INF = 1001001001;
int main() {
  int n,m;
  cin >> n >> m;
  vi c(m,0);
  rep(i,m) cin >> c.at(i);
  orep(i,60004) dp[i] = INF;

  rep(j,n) rep(i,m) dp[j+c.at(i)] = min(dp[j+c.at(i)],dp[j]+1);
  cout << dp[n] << endl;

  return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int k, x;
	cin >> k >> x;
	for (int i=(x-k+1); i<(k+x); i++) cout << i << " ";
};

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>

#define all(v) (v).begin() + 1, (v).end()
#define LEFT(n) (2*n)
#define RIGHT(n) (2*n + 1)
using namespace std;

struct query_info
{
    int left, right, query_no;

    query_info(int L, int R, int N)
    {
        left = L, right = R, query_no = N;
    }

    int operator<(const query_info &A)
    {
        return (right < A.right);
    }
};

struct train_info
{
    int left, right;

    train_info(int L, int R)
    {
        left = L, right = R;
    }

    int operator<(const train_info &A)
    {
        return (right < A.right);
    }
};

const int MAX_N = 515;
int sum_tree[4*MAX_N];

void update(int n, int left, int right, int position, int value)
{
    if(position < left || right < position)
        return;

    if(left == right)
    {
        sum_tree[n] += value;
        return;
    }

    int mid = (left + right) >> 1;

    update(LEFT(n), left, mid, position, value);
    update(RIGHT(n), mid + 1, right, position, value);

    sum_tree[n] = sum_tree[LEFT(n)] + sum_tree[RIGHT(n)];
}

int get_sum(int n, int left, int right, int query_left, int query_right)
{
    if(right < query_left || query_right < left)
        return 0;

    if(query_left <= left && right <= query_right)
    {
        return sum_tree[n];
    }

    int mid = (left + right) >> 1;
    int left_sum = get_sum(LEFT(n), left, mid, query_left, query_right);
    int right_sum = get_sum(RIGHT(n), mid + 1, right, query_left, query_right);

    return (left_sum + right_sum);
}

int main()
{
    int no_of_cities, no_of_trains, no_of_queries;
    scanf("%d %d %d", &no_of_cities, &no_of_trains, &no_of_queries);

    vector <train_info> train(no_of_trains + 1, train_info(0, 0));
    for(int i = 1; i <= no_of_trains; i++)
        scanf("%d %d", &train[i].left, &train[i].right);

    sort(all(train));

    vector <query_info> query(no_of_queries + 1, query_info(0, 0, 0));
    for(int i = 1; i <= no_of_queries; i++)
    {
        scanf("%d %d", &query[i].left, &query[i].right);

        query[i].query_no = i;
    }

    sort(all(query));

    memset(sum_tree, 0, sizeof(sum_tree));
    vector <int> answer(no_of_queries + 1);

    int last_train = 1;
    for(int i = 1; i <= no_of_queries; i++)
    {
        while(last_train <= no_of_trains && train[last_train].right <= query[i].right)
        {
            update(1, 1, no_of_cities, train[last_train].left, 1);

            last_train++;
        }

        answer[query[i].query_no] = get_sum(1, 1, no_of_cities, query[i].left, query[i].right);
    }

    for(int i = 1; i <= no_of_queries; i++)
        printf("%d\n", answer[i]);

    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;

void solve() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    ll ans = 0, x = 0, mul = 1;
    map<ll, ll> m;
    m[0] = 1;
    for(ll i = 0; i < s.size(); i++) {
        x = (x + ((ll)(s[i] - '0') * mul)) % 2019;
        ans += m[x]; m[x]++;
        mul = (mul * 10) % 2019;
    }
    cout << ans;
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e6+5,P=1e9+7;
int n,a,b,A[4][4]={0,1,0,0,P-1,0,1,0,P-1,0,2,0,0,0,P-1,1},R[4][4]={1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1},B[4]={1,1,2,P-1},C[4],t[4][4];
inline void mult(int a[4][4],int b[4][4],int c[4][4]){
	for(int i=0;i<4;i++)for(int j=0;j<4;j++){unsigned long long w=0;for(int k=0;k<4;k++)w+=(ll)a[i][k]*b[k][j];t[i][j]=w%P;}
	memcpy(c,t,sizeof(t));
}
int main(){
	scanf("%d",&n);
	if(n<=2)printf("%d\n",n*n),exit(0);
	a=((ll)n*n+1)%P;b=n;n-=3;
	while(n){if(n&1)mult(R,A,R);mult(A,A,A);n>>=1;}
	for(int i=0;i<4;i++)for(int j=0;j<4;j++)C[i]=(C[i]+(ll)B[j]*R[i][j])%P;
	printf("%d\n",((C[3]+(ll)a*C[2]-C[1]-(ll)C[0]*b)%P+P)%P);
	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

class Combination{
public:
    int N;
    ll mod;
    vector<ll> fact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1){
        fact[0] = 1;
        for(ll i=1; i<=N; i++){
            fact[i] = i * fact[i-1] % mod;
        }
    }

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

    ll combin(int n, int k){
        if(n < 0 || k < 0 || n < k){
            return 0;
        }
        return fact[n] * POW(fact[k] * fact[n-k] % mod, mod - 2) % mod;
    }
};

signed main(){
    int x, y;
    cin >> x >> y;

    if((x + y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }

    int n = (x + y) / 3;

    // k + 2(z - k) = x
    // 2k + (n - k) = y
    // k = 2n - x = y - n

    Combination C(n, MOD);
    int k = 2*n - x;

    cout << C.combin(n, k) << endl;




    return 0;
}


Measured memory_bytes: 5504
#include<iostream>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(a>0){
    c -= b;
    a -= d;
  }
  if(c>0)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var d = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        long sum = 0;

        for (var i = 0; i < N; i++)
        {
            for (var j = i + 1; j < N; j++)
            {
                sum = sum + d[i] * d[j];
            }
        }

        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
long long c[200010],ar[200010];
int main()
{
  long long n,i;
  scanf("%lld",&n);
  for(i=0;i<n;i++)
  {
    scanf("%lld",ar+i);
    c[ar[i]]++;
  }
  long long sum=0;
  for(i=1;i<=n;i++)
  {
    if(c[i]>0)
      sum+=((c[i]*(c[i]-1))/2);
  }
  long long temp,x;
  for(i=0;i<n;i++)
  {
    temp=sum;
    x=c[ar[i]]-1;
    temp-=((c[ar[i]]*(c[ar[i]]-1))/2);
    temp+=((x*(x-1))/2);
    printf("%lld\n",temp);
  }
}

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

using namespace std;

typedef long long int ll;
ll pts[1000005][6]={0};

ll mnht(ll pt[100005][6], ll kth, ll idx, ll d)
{
    ll dist=0;

    for(ll i=0;i<d;i++)
    {
        dist+=abs(pt[kth][i]-pt[idx][i]);
    }

    return dist;
}
   /*
   10
   -70 -64 -6 -56 64 61 -57 16 48 -98
   */
ll max_cmb(ll cmbn[6], ll pt[100005][6], ll n, ll d)
{
    ll pk=0;ll idx=0;

   for(ll i=0;i<n;i++)
   {
       ll val=0;

       for(ll j=0;j<d;j++)
       {
           val+=(1-2*cmbn[j])*pt[i][j];
       }

       if(val>pk)
       {
           pk=val;
           idx=i;
       }
   }

   return idx;
}

int main()
{
   ll n, d;
   cin>>n;
   d = 2;
   for(ll i=0;i<n;i++)
   {
       for(ll j=0;j<d;j++)
        cin>>pts[i][j];
   }

   ll pk[2<<d];

   for(ll j=0;j< 1<<(d);j++)
   {
       ll cmbn[6]={0};
       for(ll dig=0;dig< d; dig++)
       {
           if(j & 1<<dig)
             cmbn[dig]=1;
          // cout<<cmbn[dig]<<" ";
       }
//cout<<endl;
       pk[j]=max_cmb(cmbn, pts, n, d);
   }

   ll maxd=0;
   for(ll i=0;i<n;i++)
   {
       for(ll j=0;j< 1<<(d);j++)
       maxd=max(maxd, mnht(pts, i, pk[j], d));
   }

   cout<<maxd<<endl;
   return 0;
}


Measured memory_bytes: 12944
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	fmt.Println(maxpow2(n))

}

// nを超えない最大の2^m
// ex. 100->64, 32->32, 1->1
func maxpow2(n int) int {
	return pow(2, int(math.Log2(float64(n))))
}

func pow(a, b int) int {
	var ret int = 1
	for b > 0 {
		if (b & 1) == 1 {
			ret *= a
		}
		a *= a
		b >>= 1
	}
	return ret
}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
#define N 200050
using namespace std;
typedef long long ll;
ll n,a[N],l,ans=0ll;
int main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]),a[i]-=i;
	sort(a+1,a+n+1),l=a[(n+1)>>1];
	for (int i=1;i<=n;i++) ans+=abs(a[i]-l);
	printf("%lld\n",ans);
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    vector<int64_t> t(n),a(n);
    rep(i,0,n) cin >> t[i] >> a[i];
    int64_t x=t[0],y=a[0];
    rep(i,1,n){
        x=t[i]*max((x+t[i]-1)/t[i],(y+a[i]-1)/a[i]);
        y=a[i]*max((x+t[i]-1)/t[i],(y+a[i]-1)/a[i]);
    }
    cout << x+y << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


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

int main(){
    int n,m;cin>>n>>m;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    sort(v.begin(),v.end());
    int sum=0;
    for(int i=0;i<n;i++)sum+=v[i];
    for(int i=0;i<m;i++){
        if(v[n-1-i]*4*m<sum){cout<<"No";return 0;}
    }
    cout<<"Yes";return 0;
}


Measured memory_bytes: 256
N, M, Q = map(int, input().split())
a = [0 for _ in range(Q)]
b = [0 for _ in range(Q)]
c = [0 for _ in range(Q)]
d = [0 for _ in range(Q)]
for k in range(Q):
  a[k], b[k], c[k], d[k] = map(int, input().split())
A = [1 for _ in range(N)]

def point(A):
  p = 0
  for ai, bi, ci, di in zip(a, b, c, d):
    if A[bi-1] - A[ai-1] == ci:
      p += di
  return p

def next(A):
  k = 1
  while k < N+1:
    if A[-k] < M:
      A[-k] += 1
      return A
      break
    else:
      for j in range(1, k+1):
        A[-j] = A[-k-1] + 1
      k += 1

ans = point([M for _ in range(N)])
while A[0] < M:
  ans = max(ans, point(A))
  A = next(A)
print(ans)

Measured memory_bytes: 9244
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = Console.ReadLine().Trim();
        var pre = new string[] { "SS", "SW", "WW", "WS" };
        var ok = false;
        foreach (var x in pre)
        {
            var ret = checkA(a, x);
            if (ret != "no") { Console.WriteLine(ret); ok = true; break; }
        }
        if (!ok) Console.WriteLine(-1);
    }
    public static string checkA(string a, string st)
    {
        var aL = a.Length;
        var na = new char[aL + 1];
        na[0] = st[0]; na[1] = st[1];
        for (int i = 1; i < aL; i++)
        {
            if (a[i] == 'o' && na[i] == 'S') na[i + 1] = na[i - 1];
            else if (a[i] == 'o' && na[i] == 'W') na[i + 1] = notWS(na[i - 1]);
            else if (a[i] == 'x' && na[i] == 'S') na[i + 1] = notWS(na[i - 1]);
            else na[i + 1] = na[i - 1];
        }
        if (na[0] == na[aL])
        {
            var w = new string(na);
            var w1 = w.Substring(0, w.Length - 1);
            if (a[0] == 'o' && w1[0] == 'S')
                if (w1[1] == w1[w1.Length - 1]) return w1;
                else return "no";
            else if (a[0] == 'o' && w1[0] == 'W')
                if (w1[1] == w1[w1.Length - 1]) return "no";
                else return w1;
            else if (a[0] == 'x' && w1[0] == 'S')
                if (w1[1] == w1[w1.Length - 1]) return "no";
                else return w1;
            else if (w1[1] == w1[w1.Length - 1]) return w1;
            else return "no";
        }
        else return "no";
    }
    public static char notWS(char a)
    {
        if (a == 'W') return 'S';
        else return 'W';
    }
}

Measured memory_bytes: 13272
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctype.h>
using namespace std;

int main ()
{
   int r, D, x[11];
   scanf("%d%d%d", &r, &D, &x[0]);
      for(int i = 1; i <= 10;i++)
        {x[i] = r * x[i-1] -D;
      cout << x[i] <<endl;}

        return 0;
}


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

int main()
{
    int N;
    std::cin >> N;

    double sol = N / 1.08;
    int u = std::ceil(sol);
    int l = std::floor(sol);
    if (((int)std::floor(u*1.08)) == N) {
        std::cout << u << std::endl;
    }
    else if (((int)std::floor(l*1.08)) == N) {
        std::cout << l << std::endl;
    }
    else {
        std::cout << ":(" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}

int main(){
	int n;
	cin>>n;
	vector<int> c(n-1),s(n-1),f(n-1);
	rep(i,n-1){
		cin>>c[i]>>s[i]>>f[i];
	}

	rep(i,n-1){
		int ans=0;
		ans+=s[i]+c[i];
		FOR(j,i+1,n-1){
			if(ans>=s[j]){
				if(ans%f[j]!=0){
					ans+=c[j]+f[j]-ans%f[j];
				}else{
					ans+=c[j];
				}
			}else{
				ans=c[j]+s[j];
			}
		}
		cout<<ans<<endl;
	}
	cout<<0<<endl;
}


Measured memory_bytes: 256