akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
using namespace std;

int main(){
  long long sum = 0;
  int n,d;
  cin >> n >> d;
  vector<vector<int>> mp(n, vector<int>(d));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> mp[i][j];
    }
  }

//  for(int i = 0; i < n; i++){
//    for(int j = 0; j < d; j++){
//     cout << mp[i][j] << " ";
//    }
//    cout << endl;
//  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      int subsum = 0;
//      cout << i << "," << j << endl;
      for(int k = 0; k < d; k++){
        subsum += pow(mp[i][k] - mp[j][k], 2);
      }
      ans += ( subsum - (int)sqrt(subsum) * (int)sqrt(subsum) == 0);
    }
  }
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int cmp(const void* a,const void* b){
	return *(const int*)a-*(const int*)b;
}
int main(){
	int n=0;
	cin>>n;
	int *a=new int[n];
    int count=0;
    int i=0;
	while(i<n){
	cin>>a[i++];
	}
	qsort(a,n,sizeof(int),cmp); 
	for(int i=0;i<n;i++){
		int temp=1;
		while(i<(n-1)&&a[i]==a[i+1]){
		   temp++;
		   i++;
	    }
		if(temp&0x01)count+=1 ;
	}
	cout<<count;
}


Measured memory_bytes: 1020
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b;
  cin >> a >> b;
  cout << (a+b) % 24 << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

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

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

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

using namespace std;

int main(void)
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a == b || b == c || c == a){
		if(a == b && b == c) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define Scan(a) scanf("%I64d", &a);
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int n, m;
char a[110][110], b[210][110];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    cin >> n >> m;
    FOR(i,1,n)
        FOR(j,1,m) cin >> a[i][j];
    FOR(i,1,n) {
        FOR(j,1,m) {
            b[2*i-1][j] = a[i][j];
            b[2*i][j] = a[i][j];
        }
    }
    FOR(i,1,2*n) {
        FOR(j,1,m) cout << b[i][j];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using lli = long long;

lli calc_prime_factor(lli N) {
    lli res = 1LL;

    for (lli p = 2LL; p * p <= N; ++p) {
        if (N % p) continue;  // 素因数判定

        res++;

        // 割り切る
        while (N % p == 0LL) {
            N /= p;
        }
    }

    if (N > 1LL) res++;

    return res;
}

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

    cout << calc_prime_factor(__gcd(a, b)) << '\n';

    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
/*
 Aを貪欲に取るのは明らかに嘘。Aを取らずにBの最大値を取り、Bが得る点数を減らすことで最終的に自分の幸福度を上げることがでできる。
 Aの貪欲を取らずに、Bの最大値をとった方が最終的に自分の幸福度を上げることができるかどうかを判定するのは難しい→足して考えてしまえ
 */

signed main(){
    int n; cin >> n;
    using pii = pair<int,int>;
    vector<pii>v,u;
    for(int i = 0; i < n;i++){
        pii t; cin >> t.first >> t.second;
        u.push_back(t);
        v.push_back(pii(t.first + t.second,i));
    }
    sort(v.begin(),v.end(),greater<>());
    int ans = 0;
    for(int i = 0;i < n;i++){
        if(i % 2 == 0) ans += u[v[i].second].first;
        else ans -= u[v[i].second].second;
    }
    cout << ans << endl;
}


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

vector<ll> a, p; // a は層の厚さ。p はパティの数

ll f(int n, ll x){
    if(n == 0){
        return 1;
    }
    else if(x == 1){
        return 0;
    }
    else if(x <= a[n-1] + 1){
        return f(n-1, x-1);
    }
    else if(x == a[n-1] + 2){
        return p[n-1] + 1;
    }
    else if(x <= 2 * a[n-1] + 2){
        return p[n-1] + 1 + f(n-1, x-(a[n-1] + 2));
    }
    else{
        return p[n-1] * 2 + 1;
    }
}

int main() {

    int n;
    ll x;
    cin >> n >> x;

    a.push_back(1); //レベル0
    p.push_back(1); //レベル0
    for(int i=1; i<=n; ++i){
        a.push_back(a.back() * 2 + 3);
        p.push_back(p.back() * 2 + 1);
    }

    ll ans = f(n, x);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int prime[] = {
        2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97
    };
    int n;
    cin>>n; 
    if(n<10) {cout<<0<<endl; return 0;}
    vector <int> insu(sizeof(prime));
    for(int i=1;i<=n;i++){
        int x=i;
        while(x>1){
           for(int j=0;j<25;j++){
            if(x%prime[j]==0){
                insu[j]++; x/=prime[j];
                }
            }
        }
    }
    /*for(int i=0;i<25;i++){
        cout<<insu[i]<<endl;
    }*/
    int ans = 0;
    //74を探す
    for(int i=0;i<25;i++){
        if(insu[i]>=74) ans++;
    }
    vector <bool>  ok2(25) ;
    vector <bool>  ok24(25) ;
    vector <bool>  ok14(25) ;
    vector <bool>  ok4(25) ;
    for(int i=0;i<25;i++){
        if(insu[i]>=2) ok2[i]=true;
        if(insu[i]>=24) ok24[i] = true;
        if(insu[i]>=14) ok14[i] = true;
        if(insu[i]>=4) ok4[i] = true;
    }
    //2と24を探す
    for(int i=0;i<25;i++){
        for(int j=0;j<25;j++){
            if(i!=j&&ok2[i]&&ok24[j]) ans++;
        }
    }
    //14と4
    for(int i=0;i<25;i++){
        for(int j=0;j<25;j++){
            if(i!=j&&ok14[i]&&ok4[j]) ans++;
        }
    }
    //4と4と2
    vector <pair<int,int>>  done ;
    for(int i=0;i<25;i++){
        for(int j=0;j<25;j++){
            if(i==j||!ok4[i]||!ok4[j]) continue;
            bool ok = true;
            for(int l=0;l<done.size();l++){
                    if(done[l]== make_pair(i,j)||done[l]== make_pair(j,i)) { ok = false; break;}
        }
            if(ok) done.push_back((i>j) ? make_pair(j,i) : make_pair(i,j) );
            else continue;
            for(int k=0;k<25;k++){
                if(k==j||k==i) continue;
                if(ok2[k]) ans++;
            }
            
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s;
    cin>>n;
    vector<int> h, ans;
    ans.eb(0);
    int ma = 0, cnt = 0;
    rep(i, n){
        cin>>s;
        if(s<=ma){
            ma = s;
            cnt += 1;
        }
        else{
            ans.eb(cnt);
            cnt = 0;
            ma =  s;
        }
    }
    ans.eb(cnt);
    cout<<max(ans)<<endl;
    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n;
  cin >> n;

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

  ll sum = abs(a[0]);
  ll prev = a[0];
  for (ll i = 1; i < n; ++i) {
    sum += abs(a[i]-prev);
    prev = a[i];
  }
  sum += abs(0-a[n-1]);

  for (ll i = 0; i < n; ++i) {
    ll prev = 0;
    ll next = 0;
    if (i > 0) {
      prev = a[i-1];
    }
    if (i < n-1) {
      next = a[i+1];
    }
    ll d = abs(next-prev) - (abs(a[i]-prev) + abs(next-a[i]));
    cout << abs(sum+d) << endl;
  }

  return 0;
}


Measured memory_bytes: 2048
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T>
void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C>
void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion

bool func(vector<long double> x, vector<long double> y) {
    if ((y[1] - y[0]) * (x[3] - x[2]) == (y[3] - y[2]) * (x[1] - x[0])) return true;
    return false;
}

int main()
{
    int n;
    cin >> n;
    vector<long double> x(4);
    vector<long double> y(4);

    while(n--) {
        rep(i,4) cin >> x[i] >> y[i];
        P(func(x,y) ? "YES" : "NO");
    }
    return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;
using namespace chrono;
 
typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

//#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define loop(x,n) for(int x = 0; x < n; ++x)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 100001;

string get_str() {
    string temp;
    cin >> temp;
    return temp;
}
int get_int() {
    int temp;
    cin >> temp;
    return temp;
}




int main() {
    
    ll n; 
    cin >> n;

    char a[50];
    a[1] = 'a';
    int b[50];

    loop(i, 25) {
        a[i+2] = a[i+1] + 1;
        b[i] = 0;
    }

    for(int i=0; n>0; i++) {
        b[i] = n % 26;
        if(b[i] == 0) b[i] = 26;
        n = (n-1) / 26;
    }

    for(int i=20; i>= 0; --i) {
        if(b[i] != 0) cout << a[b[i]];
    } 

    cout << endl;

}

Measured memory_bytes: 3612
#include<stdio.h>

typedef long long ll;

ll gcd(ll a, ll b);
long long lcm(long long a, long long b);
long long gD(long long a, long long b, long long c);


int main()
{	
	long long a, b, c, d, diff, ans;
	
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	
	diff = b-a+1;
	ans = diff - (gD(a, b, c) + gD(a, b, d) - gD(a, b, lcm(c, d)));
	//printf("%lld, %lld, %lld, %lld\n", diff, gD(a, b, c), gD(a, b, d), gD(a, b, lcm(c, d)));
	printf("%lld\n", ans);
	return 0;
}



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


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


long long gD(long long a, long long b, long long c)
{
	if (a%c) a = ( ( a / c ) + 1 ) * c;
	if (b%c) b = ( b / c ) * c;
	
	//printf("[*] inside gD: %lld %lld for %lld\n", a, b, c);
	return (b-a)/c + 1;
}


Measured memory_bytes: 128
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  vi a(6);
  cin>>a;

  if(a[4]-a[0]<= a[5]) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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 namespace std;
using namespace atcoder;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

void Main() {
	int N, K; cin >> N >> K;
	vi A(N);
	int _max = -1;
	REP(i,N) {
		cin >> A[i];
		chmax(_max, A[i]);
	}
	segtree<int, op, e> seg(_max + 1);
	REP(i,N) {
		int tmp = seg.prod(max(A[i] - K, 0), min(A[i] + K + 1, _max + 1));
		seg.set(A[i], tmp + 1);
	}
	cout << seg.prod(0, _max + 1) << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 9820
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long ll;


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

    ll total_gcd = 0;
    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                total_gcd += gcd(gcd(a, b), c);
            }
        }
    }

    cout << total_gcd << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(ll i = a; i <= (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (long long) (x).size()
#define mem(a) memset(a, 0, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define MAXN 5000000
const long double PI = 3.141592653589793238462643383;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<double> vd;
typedef vector<pii> vii;
ll mod = 1000000007;
int Ceil(int a, int b){
	if(a%b==0) return a/b;
	else return (a/b)+1;
}
 
int main() {
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);   
	freopen("output.txt", "w", stdout);
	#endif*/
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n,x;
	cin >> n >> x;
	int arr[n];
    ll ans=0;
	rep(i,n)cin >> arr[i];
	if(n==1){
		if(arr[0]<=x)
			cout <<"0\n";
		else
			cout << arr[0]-x << "\n"; 
		return 0;
	}
	repA(i,0,n-2){
		if(arr[i]+arr[i+1]>x){
			int temp=arr[i]+arr[i+1]-x;
			ans+=temp;
			if(arr[i+1]>temp)
				arr[i+1]-=temp;
			else{
				temp-=arr[i+1];
				arr[i+1]=0;
				arr[i]-=temp;
			}
		}
	}cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
#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<0 || x + r>W || y - r<0 || y + r>H) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	return 0;
}



Measured memory_bytes: 2100
N = int(input())
A = [ int(x)-1 for x in input().split() ]
B = [ int(x) for x in input().split() ]
C = [ int(x) for x in input().split() ]

ans = B[A[0]]
for i in range(1,N):
  ans += B[A[i]]
  if A[i] == A[i-1]+1:
    ans += C[A[i-1]]

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF=1e18;
#define PI 3.14159265358979323846

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

    int N;
    cin >> N;

    cout << 2 * N * PI << '\n';

    return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int n,k;
  cin>>n>>k;
  int ans=0;
  while(n!=0){
    n/=k;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3520
let N = Int(readLine()!)!
if (readLine()!.characters.split(" ").map{Int(String($0))!}.sort()) == ((0..<N).map{$0+($0+N+1)%2}) {
    print((0..<N/2).reduce(1){i,_ in i*2%1000000007})
} else {
    print(0)
}

Measured memory_bytes: 6592
import sys
readline = sys.stdin.readline

def solve():
    X, K, D = map(int, readline().split())

    X = abs(X)

    if K * D <= X:
        print(X - K * D)
    else:
        a = (X + D - 1) // D
        K -= a
        X = abs(X - a * D)
        if K % 2 == 0:
            print(X)
        else:
            print(D - X)

solve()

Measured memory_bytes: 61700
S = str(input())
keyence = 'keyence'

if len(S) == 7: # 空文字列を削除するとき
    if S==keyence:
        print('YES')
    else:
        print('NO')
else :
    for i in range(0,7):
      if keyence[:i] in S and keyence[i:] in S[S.index(keyence[:i])+i:] : # keyenceがある
        if i==0 and S.index(keyence)==0 : # keyenceXXX のとき
            print('YES')
            break
        elif i==0 and S.index(keyence)!=0 and len(S)-7 == S.index(keyence) : # XXXkeyence のとき
            print('YES')
            break
        elif i!=0 and S.index(keyence[:i])==0 and S[len(keyence[:i])+(len(S)-7):] == keyence[i:] :  # keyXXXenceのとき
            print('YES')
            break
    else:
        print('NO')

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

#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back;

using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string c="IMPOSSIBLE";
    if((b+a)&1)
        cout<<c;
    else
        cout<<(b+a)/2;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm> 
#include<climits>
#include<stack>
#include<queue>
#include<set>
#include<cctype>
#include<bitset> 
#include<deque>
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int mod = 1000000007;
const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
}


int main(){
	int n,k;cin >> n >> k;

    deque<ll> dq;
    deque<ll> dq2;

    REP(i,n){
        ll tmp;cin >> tmp;
        dq.push_front(tmp);
        dq2.push_front(tmp);
    }

    ll ans=0;
    REP(b,k){
    for(int i=0;i<k-b;i++){
            vector<ll> mi_vec;
            ll tmp_ans=0;
            REP(j,i) {
                if(dq.size()==0) continue;
                tmp_ans += dq.front();
                if(dq.front()<0) mi_vec.push_back(dq.front());
                dq.pop_front();
            }
            REP(j,k-b-i) {
                if(dq.size()==0) continue;
                tmp_ans += dq.back();
                if(dq.back()<0) mi_vec.push_back(dq.back());
                dq.pop_back();
            }

            sort(all(mi_vec));
            int mi = min(b,(int)mi_vec.size());
            if(mi != 0) {
                REP(b1,mi) tmp_ans -= mi_vec[b1];
            }
            dq = dq2;

            chmax(ans,tmp_ans);
        }
    }

    pl(ans)
	return 0;
}

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

int main() {
  ll Q, H, S, D;
  ll N;
  cin >> Q >> H >> S >> D >> N;
  ll a = min(2*Q,H);
  ll b = min(S,2*a);
  ll c = min(D,2*b);
  ll x = N/2;
  ll y = N%2;

  cout << c*x+b*y << endl;
  return 0;
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

int n, mx;
vector<vector<int>> adj;
vector<pair<int, int>> edges;
map<pair<int, int>, int> ans;

void bfs()
{
	queue<pair<int, int>> Q;
	Q.emplace(0, -1);
	vector<bool> visited(n);
	visited[0] = 1;
	while (!Q.empty()) {
		int u, last;
		tie(u, last) = Q.front();
		int next = (last + 1) % mx;
		Q.pop();
		for (auto v : adj[u]) {
			if (visited[v])
				continue;
			visited[v] = 1;
			ans[{u, v}] = ans[{v, u}] = next;
			Q.emplace(v, next);
			next = (next + 1) % mx;
		}
	}
}

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

	cin >> n;
	adj.resize(n);
	edges.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		cin >> edges[i].fi >> edges[i].se;
		edges[i].fi--;
		edges[i].se--;
		adj[edges[i].fi].pb(edges[i].se);
		adj[edges[i].se].pb(edges[i].fi);
		mx = max(mx, (int)adj[edges[i].fi].size());
		mx = max(mx, (int)adj[edges[i].se].size());
	}
	
	bfs();
	cout << mx << '\n';
	for (int i = 0; i < n - 1; ++i)
		cout << ans[edges[i]] + 1 << '\n';
}


Measured memory_bytes: 19456
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
string order;
vector<int> num;
vector<char> word;
int n;
char button[9][5] = {{'.',',','!','?',' '},{'a','b','c'},{'d','e','f'},{'g','h','i'},{'j','k','l'},{'m','n','o'},{'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};

int main()
{
  int but = 0,push = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> order;
    for(int j=0;j<order.size();j++){
      num.push_back((int)(order[j]-'0'));
    }
    for(int j=0;j<num.size();j++){
      if(1<=num[j] && num[j]<=9 && but==0){
	but = num[j];
      }else if(1<=num[j] && num[j]<=9 && but!=0){
	push++; //cout << "pushed" << endl;
      }else if(num[j]==0 && but && but!=1 && but!=7 && but!=9){
	word.push_back(button[but-1][push%3]); //cout << button[but-1][push%3] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && but && (but==7 || but==9)){
	word.push_back(button[but-1][push%4]); //cout << button[but-1][push%4] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && but && but==1){
	word.push_back(button[but-1][push%5]); //cout << button[but-1][push%4] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && !but){
	continue;
      }
    }
    for(int k=0;k<word.size();k++){
      cout << word[k];
    }
    cout << endl;
    word.clear();
    num.clear();
  }
  
  return 0;
  
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iomanip>

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<string> vec(N);
	for (int i = 0; i < N; ++i)
		cin >> vec[i];
	double res = 0;
	for (auto&& v : vec)
		res += 1.0 / stol(v);
	cout << setprecision(10) << (1.0 / res);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll N, P;
	cin >> N >> P;
	map<ll, int> mp;
	set<ll> st;
	ll tmp = P;
	for (ll i = 2; i * i <= P; i++) {
		while (tmp % i == 0) {
			mp[i]++;
			st.insert(i);
			tmp /= i;
		}
	}
	mp[tmp]++;
	st.insert(tmp);
	ll ans = 1;
	for (auto itr = st.begin(); itr != st.end(); itr++) {
		ll A = *itr;
		int n = mp[A] / N;
		for (int i = 0; i < n; i++) ans *= A;
	}
	cout << ans << endl;
}

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

string a = "apple";
string p = "peach";

int main() {
	string s;
	getline(cin, s);
	int i = 0;

	while (i < s.size()) {
		if (s.substr(i, 5) == "apple") {
			for (int j = 0; j < 5; j++) {
				s[i + j] = p[j];
			}
		} else if(s.substr(i, 5) == "peach") {
			for (int j = 0; j < 5; j++) {
				s[i + j] = a[j];
			}
		}
		i++;
	}
	cout << s << endl;
	return 0;
}

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

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

	vector<vector<int>> data(2, vector<int>(N));

	rep(i, N) {
		cin >> data.at(0).at(i) >> data.at(1).at(i);
	}

	int max_val = 0;
	int max_pos = 0;
	rep(i, N) {
		if(data.at(0).at(i) >= max_pos) {
			max_pos = data.at(0).at(i);
			max_val = data.at(1).at(i);
		}
	}

	cout << max_val + max_pos << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;



int main(void) {
    int n,c;
    cin >> n >> c;
    int imos[100005]={};
    vector<vector<pair<int, int>>> record(c,vector<pair<int,int>>());
    vector<vector<pair<int, int>>> record_2(c,vector<pair<int,int>>());
    rep(i,n){
        int ts,tt,tc;
        cin >> ts >> tt >> tc;
        record[tc-1].push_back(make_pair(ts,tt));
    }
    rep(i,c){
        sort(record[i].begin(),record[i].end());
        int cur=0;
        while(cur<record[i].size()){
            int from=record[i][cur].first;
            while(cur+1<record[i].size()&&record[i][cur].second==record[i][cur+1].first)cur++;
            record_2[i].push_back(make_pair(from,record[i][cur].second));
            cur++;
        }
    }
    rep(i,c)rep(j,record_2[i].size()){
        int from = record_2[i][j].first;
        int to = record_2[i][j].second;
        imos[from-1]++;
        imos[to]--;
    }
    int res=0,tmp=0;
    rep(i,100005){
        tmp+=imos[i];
        res=max(res,tmp);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std ; 
const double PI=  acos(-1.0);

int main(){
   double A , B , H , M ; 
  
   double rad ; 
  
  cin >> A >> B >> H >> M ; 
  
  rad = 2*PI*( (  60*H + M )/720 - M/60.0);

  
   double rsq = (A * A + B * B) - (2.0 * A * B) * cos(rad);
  
  cout << setprecision(14) << sqrt(rsq) << endl ;
}

Measured memory_bytes: 4212
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Friend Suggestions
 */

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

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef vector<int> vi;

struct UFT {
  int links[MAX_N], ranks[MAX_N], sizes[MAX_N];
  UFT() {}

  void init(int n) {
    for (int i = 0; i < n; i++) links[i] = i, ranks[i] = sizes[i] = 1;
  }

  int root(int i) {
    int i0 = i;
    while (links[i0] != i0) i0 = links[i0];
    return (links[i] = i0);
  }

  int rank(int i) { return ranks[root(i)]; }
  int size(int i) { return sizes[root(i)]; }
  bool same(int i, int j) { return root(i) == root(j); }

  int merge(int i0, int i1) {
    int r0 = root(i0), r1 = root(i1), mr;
    if (r0 == r1) return r0;
    if (ranks[r0] == ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      ranks[r0]++;
      mr = r0;
    }
    else if (ranks[r0] > ranks[r1]) {
      links[r1] = r0;
      sizes[r0] += sizes[r1];
      mr = r0;
    }
    else {
      links[r0] = r1;
      sizes[r1] += sizes[r0];
      mr = r1;
    }
    return mr;
  }
};

/* global variables */

UFT uft;
vi nbrs[MAX_N], blks[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);

  uft.init(n);
  
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    nbrs[a].push_back(b);
    nbrs[b].push_back(a);
    uft.merge(a, b);
  }

  for (int i = 0; i < k; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    blks[a].push_back(b);
    blks[b].push_back(a);
  }

  for (int i = 0; i < n; i++) {
    int r = uft.root(i), sz = uft.size(i);
    vi &nbri = nbrs[i], &blki = blks[i];

    for (vi::iterator vit = blki.begin(); vit != blki.end(); vit++)
      if (uft.same(r, *vit)) sz--;
    sz -= nbri.size() + 1;

    if (i) putchar(' ');
    printf("%d", sz);
  }
  putchar('\n');
  return 0;
}


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

int main(void)
{
    char W[11], T[1001];

    scanf("%s", W);

    int i, count = 0;

    for(i = 0; i < strlen(W); ++i)
    {
        W[i] = tolower(W[i]);
    }

    while(scanf("%s", T))
    {
        if(!strcmp(T, "END_OF_TEXT"))
        {
            break;
        }

        for(i = 0; i < strlen(T); ++i)
        {
            T[i] = tolower(T[i]);
        }

        count += (strcmp(T, W) == 0);
    }

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

Measured memory_bytes: 548
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    int ans=0;
    for(int i=1;i<b-a;i++) ans += i;
    cout << ans - a << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  string a,b,c,d;
  cin >> a;
  cin >>b;
  cin >>c;
  int offset;
  offset='A'-'a';
  cout << char (a[0]+offset) <<char ( b[0]+offset)<<char( c[0]+offset)<<endl;
    return 0;
}


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

int A[100];

int selectionSort(int A[], int n) {
	int c = 0, minj;

	for (int i = 0; i < n - 1; ++i) {
		minj = i;
		for (int j = i; j < n; ++j) {
			if (A[j] < A[minj]) {
				minj = j;
			}
		}
			if (i != minj) {
				int t = A[minj];
				A[minj] = A[i];
				A[i] = t;
				++c;
			}
		
	}
	return c;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> A[i];
	}
	int c = selectionSort(A, n);
	for (int i = 0; i < n; ++i) {
		if (i) {
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
	cout << c << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,P,O=0,E=0,x,A;cin>>N>>P;
  for(long long int i=0;i<N;i++){
    cin>>A;
    if(A%2==0)E++;
    else O++;
  }
  if(O==0){
    if(P==0)x=pow(2,N);
    else x=0;
  }
  else x=pow(2,N-1);
  printf("%lld\n",x);
}

Measured memory_bytes: 384
N = int(input())
a = list(map(int, input().split()))

a.insert(0,0)
a.append(0)

all_sum = 0
for i in range(0,N+1):
    all_sum += abs(a[i+1] - a[i])


for i in range(1, N+1):
    print(all_sum - (abs(a[i-1] - a[i]) + abs(a[i+1] - a[i])) + abs(a[i+1] - a[i-1]))

Measured memory_bytes: 13920
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
 
#define FOR(i,to) for( int i=0;i<(to);i++)
#define FORR(i,from) for( int i=from;i>-1;i--)

using namespace std;

int N,K;
int s[4002][4002];
int w[4002][4002];

int calc(int x,int y){
	return w[x][y]-w[x-K][y]-w[x][y+K]+w[x-K][y+K];
}

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

	FOR(i,N){
		int x,y;
		char c;
		cin >> x >> y >> c;
		
		if(c=='W') s[(x+K)%(2*K)+K][y%(2*K)+K]+=1;
		else s[x%(2*K)+K][y%(2*K)+K]+=1; 
	}


	FOR(y,4*K) FOR(x,4*K){
		if(x==0) w[x][y]=s[x][y];
		else	  w[x][y]=w[x-1][y]+s[x][y];
	}

	FOR(x,4*K) FORR(y,4*K-1){
		if(y==4*K-1) w[x][y]=w[x][y];
		else	     w[x][y]=w[x][y+1]+w[x][y];
	}


	int ans=0;
	int tmp=0;

	for(int y=K; y<2*K; y++){
		for(int x=2*K; x<3*K; x++){
			tmp=calc(x,y)+calc(x-K,y-K)+calc(x+K,y-K)+calc(x+K,y+K)+calc(x-K,y+K);
			ans=max( ans, max(N-tmp,tmp) );
		}
	}

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


Measured memory_bytes: 96512
# 半分全列挙バージョン
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def allptn(abc,ma,mb):
    inf=10**9
    # a,b,cの全組合せを作る
    allabc=[(0,0,0)]
    for a,b,c in abc:
        n=len(allabc)
        for i in range(n):
            aa,bb,cc=allabc[i]
            allabc.append((aa+a,bb+b,cc+c))
    # 指標とコストの組合せにする
    # 指標が重複するときはコストが小さいほうだけ残す
    # 指標が0のときは前後半で組み合わせる必要がないので単独で答えを出しておく
    vc={}
    ans=inf
    for a,b,c in allabc[1:]:
        val=a*mb-b*ma
        if val:
            pc=vc.setdefault(val,inf)
            if c<pc:vc[val]=c
        else:
            if c<ans:ans=c
    res=[(val,c) for val,c in sorted(vc.items())]
    return ans,res

def main():
    n,ma,mb=MI()
    abc=[LI() for _ in range(n)]
    inf=10**9
    # 前半の要素をa1,b1、後半の要素をa2,b2とする
    # (a1+a2):(b1+b2)=ma:mbとなればよい。式変形すると
    # (mb*a1-ma*b1)+(mb*a2-ma*b2)=0となる
    # つまり各要素についてmb*a-ma*bという指標を計算し、前半と後半で和が0になる組合せを探せばよい
    # 前半全列挙
    ans,pre=allptn(abc[:n//2],ma,mb)
    # 後半全列挙
    ret,pos=allptn(abc[n//2:],ma,mb)
    ans=min(ans,ret)
    # 指標が昇順になるよう並び替えて、前半は前から後半は後からしゃくとり法で
    # 指標の和が0になるところのコストを求める
    j=len(pos)-1
    for val,c in pre:
        while val+pos[j][0]>0 and j:j-=1
        if val+pos[j][0]==0:ans=min(ans,c+pos[j][1])
    if ans==inf:print(-1)
    else:print(ans)

main()

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll gcd(ll x, ll y){
  if(y==0) return x;
  return gcd(y, x-(x/y)*y);
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)
  ll X;
  IN(X);

  ll h = gcd((ll)360, X);
  ll ans = (360*(X/h))/X;

  OUT(ans);

  return 0;
}

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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    ll price[4];
    FOR(i,0,3) cin >> price[i];
    
    ll n;
    cin >> n; n *= 4;
    
    FOR(i,0,3) FOR(j,i+1,3) {
        ll p = price[i];
        FOR(_,1,j-i) p *= 2;
        
        price[j] = min(price[j], p);
    }
    
    ll ans = price[3] * (n / 8);
    ll rest = n % 8;
    
    FOR(i,0,2) if (rest & (1 << i)) {
        ans += price[i];
    }
    
    cout << ans;

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 256
#素因数分解
def prf(m):
    pf = {}
    for i in range(2, int(m**0.5)+1):
        while m % i == 0:
            pf[i] = pf.get(i, 0)+1
            #get:辞書のkeyを指定し、そのkeyがあればvalueを返し、なければ指定した値を返す
            m //= i
    if m > 1:
        pf[m] = 1
        #mの平方根よりも大きい数が残る場合はその数自体が素因数(m=10=2*5)
    return pf

#組合せ（nCk）
def comb(n, k):
    k = min(k, n - k)
    result = 1
    for i in range(n, n - k, -1):
        result *= i
    for i in range(1, k + 1):
        result //= i 
    return result
 
n, m = map(int, input().split())
mod = 10 ** 9 + 7

ans = 1
for i in prf(m).values():
    ans = ans * comb(n - 1 + i, i) % mod
    #重複組合せ：N-1枚の仕切り（aとaの間の個数に相当）を使って、i（指数）を振り分ける場合の数
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;
LL Euclid(LL a,LL b){
    while(1){
        if(a<b){LL c=a;a=b;b=c;}
        if(a%b==0){return b;}
        else{a=a%b;}
    }
}
int main()
{ 
    LL n;
    cin>>n;
    LL a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    LL b[n];
    LL c[n];
    b[0]=a[0];c[n-1]=a[n-1];
    for(int i=1;i<n;i++){
        b[i]=Euclid(b[i-1],a[i]);
        c[n-1-i]=Euclid(c[n-i],a[n-1-i]);
    }
    /*for(int i=0;i<n;i++){
        cout<<b[i]<<' ';
    }
    cout<<endl;
    for(int i=0;i<n;i++){
        cout<<c[i]<<' ';
    }
    cout<<endl;*/



    LL ans=max(b[n-2],c[1]);
    for(int i=0;i<n-2;i++){
        if(ans<Euclid(b[i],c[i+2])){ans=Euclid(b[i],c[i+2]);}
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s, sr, f, fr, e, er;
	cin >> s;
	sr = s;
	reverse(sr.begin(), sr.end());
	f = s.substr(0, (s.size() - 1) / 2);
	fr = f;
	reverse(fr.begin(), fr.end());
	e = s.substr((s.size()+3)/2 - 1, s.size());
	er = e;
	reverse(er.begin(), er.end());

	if ( s == sr && f == fr && e == er )
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";

	return 0;
}


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

int main(){
    while(1){

    int n;

    cin>>n;

    if(n == 0) break;

    vector <int> data(n);

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

        cin>>data.at(i);
    }

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

    reverse(data.begin(),data.end());

    

    vector <int> gap(n);

    for(int i=0; i<n-1; i++){

        gap.at(i) = data.at(i) - data.at(i+1);

        
    }

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

    if(gap.at(0) == 0) cout<<gap.at(1)<<endl;

    else cout<<gap.at(0)<<endl;


    }

    return 0;
    
}


Measured memory_bytes: 3156
n = int(input())
ais = list(map(int, input().split()))
evens = []
for a in ais:
  if a % 2 == 0:
    evens.append(a)
if len(evens) == 0:
  print("APPROVED")
  quit()
m = 0
for e in evens:
  if e % 3 == 0 or e % 5 == 0:
    pass
  else:
    m += 1
if m == 0:
  print("APPROVED")
else:
  print("DENIED")
  


Measured memory_bytes: 3064