akhauriyash/Code-Regression huggingface dataset:
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <queue>
#include <stack>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

ll W, W2;
const int maxn = 101;
const int maxw = 400;
const int maxv = 1e7 + 100;
ll w[maxn];
int v[maxn];
int n;
int dp[maxn][maxw][maxn];

int dfs(int i, int j, int k) {
  //インデックスi番目以降の品物から
  //重さj以内で
  //残りk個選べる
  //場合の価値の最大値 == ret
  //printf("i,j,k = %3d %3d %3d\n", i, j, k);
  if (dp[i][j][k] != -1) {
    return dp[i][j][k];
  }
  int ret = 0;
  if (k == 0) {
    ret = 0;
  } else if (i == n) {
    ret = 0;
  } else if (j < w[i]) {  //少なくとも1個選べるが、i番目の品物は入らない
    ret = dfs(i + 1, j, k);
  } else {  //i番目の品物が入れられる
    ret = max(dfs(i + 1, j - w[i], k - 1) + v[i], dfs(i + 1, j, k));
  }
  dp[i][j][k] = ret;
  return dp[i][j][k];
}

void solve() {
  cin >> n >> W;
  cin >> w[0] >> v[0];
  ll wm = 0;
  for (int i = 1; i < n; ++i) {
    cin >> w[i] >> v[i];
    wm = max(w[i], wm);
    w[i] -= w[0];
  }
  ll w0 = w[0];
  w[0] = 0;
  //使う個数がt個のとき, 重さ制限はW - t*w0
  //重さW'以内になるようにt個までの品物を選択して得られる最大の価値を求めよ
  //個数制限つきナップサック問題をW/w0回解く（最大でn回）
  //O(N*NW')
  //W'は3*n以内
  //O(N*N*3*N) = O(N^3)
  ll ans = 0, ret;
  for (ll t = 1; t <= n; ++t) {
    W2 = min(W - t * w0, (wm - w0) * t);
    if (W2 < 0)
      continue;
    for (int i = 0; i < maxn; ++i) {
      for (int j = 0; j < maxw; ++j) {
        for (int k = 0; k < maxn; ++k) {
          dp[i][j][k] = -1;
        }
      }
    }
    //debug(W2);
    ret = dfs(0, W2, t);
    ans = max(ans, ret);
    //cout << "t=" << t << ":" << ret << endl;
  }
  cout << ans << endl;
}

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


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  vector<int> v(3);
  rep(i, 3) cin >> v[i];
  sort(all(v));
  out(v[0] * v[1] / 2);
}


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll X,Y,A,B,C;
	cin>>X>>Y>>A>>B>>C;
    vector<ll> P(A),Q(B),R(C);

    rep(i,A){
        cin>>P[i];
    }

    rep(i,B){
        cin>>Q[i];
    }

    rep(i,C){
        cin>>R[i];
    }

    sort(P.begin(),P.end());
	sort(Q.begin(),Q.end());
	sort(R.begin(),R.end());
    auto pb = P.begin();
    pb += A-X;
    auto qb = Q.begin();
    qb += B-Y;
    ll min_r = 0,max_r = (ll)1e9+1,tmp_r;
    ll need_n,supply_n;
    while(min_r+1 !=max_r){
        tmp_r = (min_r+max_r)/2;
        need_n = 0;
        supply_n = 0;
        need_n+= lower_bound(pb,P.end(),tmp_r)-pb;
        need_n+= lower_bound(qb,Q.end(),tmp_r)-qb;
        supply_n = R.end()-lower_bound(R.begin(),R.end(),tmp_r);
        if(supply_n>=need_n){
            min_r = tmp_r;
        }else{
            max_r = tmp_r;
        }
    }
    ll ans = 0;
    pb = lower_bound(pb,P.end(),min_r);
    qb = lower_bound(qb,Q.end(),min_r);
    for(auto itr = P.end()-1;X!=0&&itr!=pb-1;--itr){
        ans += *itr;
        --X;
    }
    for(auto itr = Q.end()-1;Y!=0&&itr!=qb-1;--itr){
        ans += *itr;
        --Y;
    }
    ll N = X+Y;
    // cout<<N<<"\n";
    for(auto itr = R.end()-1;N!=0;--itr){
        ans += *itr;
        --N;
    }
    cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    if(a <= 9 && b <= 9){
        PUTS(a * b)
    }
    else
    {
        PUTS(-1);
    }
}

Measured memory_bytes: 256
/*
edit : Le Duy Dat
team : THree Wolves
Task:
Link:
*/
#include <bits/stdc++.h>

#define f0(i,a,b) for(int i= a; i<= b; ++i)
#define f1(i,a,b) for(int i= a; i>= b; --i)
#define DEBUG(x) cerr << #x << " = " << x << endl
#define X first
#define Y second
using namespace std;
const int base=1e9+7;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
const long long MAX_N = 1000001;
/*

 End of Template

*/

/* Action  */
ll dd[MAX_N];
void Solves(){
    ll n;
    cin >> n;
    ll a[n + 5];
    ll xorr = 0;
    for(int i = 1; i <= n;i ++){
        cin >> a[i];
        xorr = (xorr ^ a[i]);
    }
    if(xorr == 0) cout << "Yes";
    else cout << "No";

}

//
int main(){

	Solves();
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(void)
{
	int N=1,i,t,n=0,M;
	
	for(;N!=0;){
		
		n=0;
		scanf("%d",&N);
		
		for(i=1;i<(N/2)+1;i++){
			M=N;
			for(t=i;t<(N/2)+2;t++){
				
				M=M-t;
				//printf("%d %d %d\n",i,t,M);
				if(M<=0){
					
					if(M==0){
						
						n=n+1;
						break;
					}
					if(M<0){
						break;
					}
				}
				//printf("%d\n\n",n);
			}
			//printf("%d\n\n",n);
		}
		
		if(N!=0){
			printf("%d\n",n);
		}
	}
	return 0;
}

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

int dig(ll x){
  int ans=0;
  while(x>0){
    ans ++;
    x /= 10;
  }
  return ans;
}

int main(){
  ll N;cin >> N;
  int ans=100000;
  for(ll i=1;i*i<=N;i++){
    if(N%i==0){
      ll j=N/i;
      ans = min(ans,max(dig(i),dig(j)));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)

bool isok(ll now, ll k, vector<ll> &a)
{
   // cerr << "*" << now << " ";
    ll sum = 0;
    ll mx = -1;
    ll op = 0;
    vector<ll> b(a.size(), 0);
    rep(i, a.size())
    {
        sum += (a[i] % now);
        b[i] = a[i] % now;
    }
    if ((sum % now) != 0)
    {
        return false;
    }
    sort(ALL(b), greater<ll>());
    ll bsum = 0;
    rep(i, a.size())
    {
        sum -= b[i];
        bsum += (now - b[i]) % now;
        if (sum == bsum)
            break;
    }
    //cerr << bsum << endl;
    //return true;
    return bsum <= k;
}
int main()
{

    ll n, k;
    cin >> n >> k;
    vector<ll> a(n, 0);
    sort(ALL(a), greater<int>());
    ll cmax = 0;
    rep(i, n)
    {
        cin >> a[i];
        cmax += a[i];
    }

    vector<ll> d;
    ll i = 1;
    while (i * i <= cmax)
    {
        if (cmax % i == 0)
        {
            d.push_back(i);
            d.push_back(cmax / i);
        }
        i++;
    }
    sort(ALL(d), greater<ll>());
    for (auto now : d)
    {
        //   cerr << now << endl;
        //  ;
        if (isok(now, k, a))
        {
            cout << now << endl;
            return 0;
        }
    }

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define pi 2.0*acos(0.0)
#define INTM INT_MAX
#define FOR(i,n)	for(int i=0;i<n;i++)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

bool cmp(int &a,int &b){
        return a<b;                //ascending order
        return a>b;                //descending order
}

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

ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a*b/gcd(a,b);
}
struct IO{
    ll pow,coin,id;
}srr[100001];

bool cmpsr(IO aa,IO bb){
    if(aa.pow==bb.pow) return aa.coin>bb.coin;
    return (aa.pow<bb.pow);
}

int main()
{
    ll n,l;
    cin>>n>>l;
    string arr[n];
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    for(ll pass=0;pass<n;pass++){
    for(ll i=0;i<n-1-pass;i++){
        ll j = 0;
        while(j<l){
            if(arr[i][j]==arr[i+1][j]){

            }
            else if(arr[i][j]<arr[i+1][j]){
                break;
            }
            else{
                swap(arr[i],arr[i+1]);
                break;
            }
            j++;
        }
    }
    }
    for(ll i=0;i<n;i++){
        cout<<arr[i];
    }
    cout<<endl;
}



Measured memory_bytes: 256
from collections import Counter

def ABC137C_GreenBin():
    N = int(input().strip())
    S = [input().strip() for i in range(N)]

    ans = 0
    di = Counter()
    for s in S:
        s = ''.join(sorted(list(s)))
        
        if s in di:
            ans += di[s]

        di[s] += 1
    
    print(ans)


def main():
    ABC137C_GreenBin()

if __name__ == "__main__":
    main()


Measured memory_bytes: 73688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

struct UF{ //O(loga(n))
    int n;
    int m;
    vi d, r;
    UF(int n) : n(n), m(n), d(n, -1), r(n, 0){};
    int root(int i){
        if(d[i] < 0) return i;
        return d[i] = root(d[i]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(r[x] < r[y]) swap(x, y);
        else if(r[x] == r[y]) r[x]++;
        d[x] += d[y];
        d[y] = x;
        --m;
        return true;
    }
    int size(int i){
        return -d[root(i)];
    }
    int size() {
        return m;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    UF uf(n);
    using E = tuple<int, int, int>;
    vector<E> es(m);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        es[i] = tie(c, a, b);
    }
    sort(all(es));
    ll ans = 0;
    rep(i, m) {
        int a, b, c;
        tie(c, a, b) = es[i];
        if(uf.same(a, b)) continue;
        uf.unite(a, b);
        ans += c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4172
/* Print a Rectangle */
#include <stdio.h>

int main()
{
    int H, W, i, j, n;
    for(n=0;; n++){
        scanf("%d %d", &H, &W);
        if(H ==0 && W == 0){
            break;
        }
        for(i=0; i < H; i++){
            for(j=0; j < W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2044
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n,m;
int main()
{
	scanf("%lld%lld",&n,&m);
    if(n==1)
	{
		if(m==1)	printf("1");
		else if(m==2)	printf("0");
		else printf("%lld",m-2);
	}
	else if(m==1)
	{
		if(n==1)	printf("1");
		else if(n==2)	printf("0");
		else printf("%lld",n-2);
	}
	else printf("%lld",n*m-2*((m-1)+(n-1)));
	return 0;
}


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


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,y;
    cin >> n >> y;
    
    ll i,j,k;
    
    bool flag = false;
    for(i = 0; i * 10000 <= y; i++){
        for(j = 0; i * 10000 + j * 5000 <= y; j++){
            k = (y - i * 10000 - j * 5000) / 1000;
            if(i + j + k == n){
                cout << i << " " << j << " " << k << endl;
                flag = true;
                return 0;
            }
        }
    }
    
    
    if(flag == false) cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n;
    string s;
    while(cin>>n>>s){
        ll ans=0;
        for(int i=0; i<s.size(); ++i){
            cout<<char('A'+((s[i]-'A'+n)%26));
        }
        cout<<endl;
    }
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cout << x << endl;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;
int MAX_A = 303030;

int op(int l, int r) { return max(l, r); }
int e() { return 0; }


int main()
{
    int N, K;
    cin >> N >> K;
    segtree<int, op, e> seg(MAX_A);
    rep(i,N)
    {
        int a;
        cin >> a;
        int l = max(0, a - K);
        int r = min(MAX_A, a + K + 1);
        int x = seg.prod(l, r);
        x++;
        seg.set(a, x);
    }
    int ans = seg.all_prod();
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 8512
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	float a,b,c;
    	cin>>a>>b;
    	if(b==1)
    	{
    	    cout<<'0';
    	    return 0;
    	}
    	if(b>a)
    	{b=b-a;
    	    a=a-1;
    	c=ceil(b/a);
    	cout<<c+1;
    	return 0;}
    	if(b<=a)
    	{cout<<'1';return 0;}
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,y,sum,pos,k,x[ohara],dp[ohara];
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>k;
    rep(i,n)cin>>x[i];
    rrep(i,1,n){
        tmp=LINF;
        rrrep(j,i-1,max(i-k,0LL)){
            tmp=min(dp[j]+abs(x[i]-x[j]),tmp);
        }
        dp[i]=tmp;
    }
    Cout(dp[n-1]);
    return 0;
}


Measured memory_bytes: 5120
#include<cstdio>

using namespace std;

int main(void) {
  long n, m;
  scanf("%ld %ld", &n, &m);

  if (m / 2 < n + 1) {
    printf("%ld\n", m / 2);
  } else {
    printf("%ld\n", (n + (m - 2 * n) / 4));
  }
  return 0;
}

Measured memory_bytes: 128
N = int(input())
s = []
for i in range(N):
    s.append(int(input()))
SUM = sum(s)
s.sort()
flag = 0
if SUM % 10 != 0:
    flag = 1
ans = SUM
i = 0
while(SUM % 10 == 0):
    if i >= len(s):
        break
    if s[i] % 10 != 0:
        ans = SUM - s[i]
        break
    i = i+1
if ans == SUM and flag ==0:
    print(0)
else:
    print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int H, W, x, popcount[1024];
int main() {
	for (int i = 0; i < 1024; i++) {
		for (int j = 0; j < 10; j++) {
			if (i & (1 << j)) popcount[i]++;
		}
	}
	while (scanf("%d%d", &H, &W), H) {
		vector<int> bit(W);
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				scanf("%d", &x);
				bit[j] |= x << i;
			}
		}
		vector<int> cnt(1 << H);
		for (int i = 0; i < W; i++) cnt[bit[i]]++;
		int ret = 0;
		for (int i = 0; i < 1 << (H - 1); i++) {
			vector<int> f(1 << H);
			for (int j = 0; j < 1 << H; j++) {
				f[j] = popcount[i ^ j];
				f[j] = max(f[j], H - f[j]);
			}
			int res = 0;
			for (int j = 0; j < 1 << H; j++) res += cnt[j] * f[j];
			ret = max(ret, res);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  string S;
  cin >> S;
  if (S[0] == 'A' && S[1] == 'A' && S[2] == 'A') {
    cout << "No" << endl;
    return 0;
  }
  if (S[0] == 'B' && S[1] == 'B' && S[2] == 'B') {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
int main()
{
    long long int s=0,c,t,result=0,q,p,r;
  double n,m;
    int arra[100000];
   cin>>n>>m;
  r= ceil(n/m*1.00);
  cout<<r<<endl;
        return 0;
}

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

using namespace std;

int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.length();
  if (N < K) {
    cout << 0 << endl;
    return 0;
  }
  vector<vector<long long>> dp0(N + 1, vector<long long>(5));
  vector<vector<long long>> dp1(N + 1, vector<long long>(5));
  dp1[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 4; j++) {
      dp0[i + 1][j] += dp0[i][j];
      dp0[i + 1][j + 1] += dp0[i][j] * 9;
      int d = S[i] - '0';
      if (d == 0) {
        dp1[i + 1][j] += dp1[i][j];
      } else {
        dp1[i + 1][j + 1] += dp1[i][j];
        dp0[i + 1][j] += dp1[i][j];
        dp0[i + 1][j + 1] += dp1[i][j] * (d - 1);
      }
    }
  }
  long long ans = dp0[N][K] + dp1[N][K];
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
#define F first 
#define S second 

using namespace std;

//ll count(ll a,ll b,ll c){
//	if(a==b and a==c)return 1;
//	
//	if(a==b)return 3;
//	if(a==c)return 3;
//	if(b==c)return 3;
//	
//	return 6;
//	
//}

void test(){
	ll n;
	cin>>n;
	ll sum = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum = sum+__gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<sum<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		test();
	}
}

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

int main() {
  int N;
  int M;
  int count=0;
  cin >> N >> M;
  if( N%2==1){
    for(int i=1;i<(M+1);i++){
     cout << i << " "<< N-i<<endl;
    }
  }
  else{
    int aa=(M+1)/2;
  for(int i=0;i<aa;i++){
   cout << 1+i << " " << 1+M-i<<endl;      
  }
    int bb=M/2;
  for(int i=0;i<bb; i++){
   cout << M+2+i << " " << M+M+1-i<<endl;  
  }
    
  }
  return 0;
  
}

Measured memory_bytes: 3640
# coding: utf-8


def main():

    own_money = int(input())
    cake_price = int(input())
    donut_price = int(input())

    own_money -= cake_price * 1
    own_money %= donut_price

    print(own_money)

    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
n = int(input())
s = input()
west = [0 for _ in range(n)]
if s[0] == 'W':
    west[0] = 1
for _ in range(1, n):
    if s[_] == 'W':
        west[_] = west[_-1] + 1
    else:
        west[_] = west[_-1]
east = [0 for _ in range(n)]
if s[n-1] == 'E':
    east[n-1] = 1
for _ in range(n-2, -1, -1):
    if s[_] == 'E':
        east[_] = east[_+1] + 1
    else:
        east[_] = east[_+1]
ans = [0 for _ in range(n)]
ans[0] = east[1]
for _ in range(1, n-1):
    ans[_] = west[_-1] + east[_+1]
ans[n-1] = west[n-2]

print(min(ans))


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

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
bool adjacent[8][8];

int DFS (int v, int N, bool visited[8]) {

  // すべてのノードに訪れているか判定
  bool all = true;
  for (int i = 0; i < N; i++) {
    if (visited[i] == false) all = false;
  }
  if (all) return 1;

  int ret = 0;
  for (int i = 0; i < N; i++) {
    // vとiが隣接していない
    if (adjacent[v][i] == false) continue;
    // 次の頂点が訪問済み
    if (visited[i]) continue;
    visited[i] = true;
    ret += DFS(i, N, visited);
    visited[i] = false;
  }
  return ret;
}

int main() {
  int N, M;

  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    adjacent[a - 1][b - 1] = adjacent[b - 1][a - 1] = true;
  }
  bool visited[8];
  for (int i = 0; i < N; i++)
    visited[i] = false;

  visited[0] = true;
  cout << DFS(0, N, visited) << endl;

}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n >= 2)
    {
        ans += n * (n - 1) / 2;
    }
    if (m >= 2)
    {
        ans += m * (m - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	
	Scanner sc = new Scanner(System.in);
	int a;
	int b;
	int c;
	int su=0;
	void rp4(){
	
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		
		for(int i=a; i<=b; i++){
			if(c%i==0) su++;
		}
		System.out.println(su);
	}
	
	public static void main(String[]agrs){
		new Main().rp4();
	}
}

Measured memory_bytes: 17356
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	long long x, y;
	int ans = 0;
	scanf("%lld %lld", &x,&y);


	while(x<=y){
		x = x * 2;
		ans++;
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    int A,B;
    long long ans=0;

    cin >> A >> B;

    for(int i=0; i<10 ; i++){
        for(int j=0; j<10 ; j++){
            for(int k=0; k<10 ; k++){
                int num=10001*i+1010*j+100*k;
                if(num>=A && num<=B) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, K = MAP()
A = MAP()

while True:
	for s in str(N):
		if A.count(int(s)): break
	else:
		break
	N += 1
print(N)

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

int main() {
  string n;
  cin >> n;
  int flag = 0;
  if (n[0] == n[1] && n[1] == n[2]) {
    flag = 1;
  }
  else if (n[1] == n[2] && n[2] == n[3]) {
    flag = 1;
  }
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#define int long long
//#define _DEBUG
//#include <vector>
#include <string>
//#include <map>
//#include <stack>
#include <cassert>
using namespace std;

//input
int N;
string input;

int cur;
int expression();

char readchar(){
    assert(cur < input.size());
    return input[cur++];
}
char peek(){
    assert(cur < input.size());
    return input[cur];
}
bool isDisit(char c){
    return int(c)>=48 && int(c)<58;
}
int disit(){
    assert(isDisit(peek()));
    return readchar() - '0';
}
int number(){
    int n = disit();
    while(cur < input.size() && isDisit(peek())){
        n = 10*n + disit();
    }
    return n;
}
char additiveOpr(){
    assert(peek()=='+' || peek()=='-');
    return readchar();
}
char multiveOpr(){
    assert(peek()=='*' || peek()=='/');
    return readchar();
}
int opr(char opr, int x, int y){
    if(opr=='+'){
        return x+y;
    }else if(opr=='-'){
        return x-y;
    }else if(opr=='*'){
        return x*y;
    }else if(opr=='/'){
        assert(y!=0);
        return x/y;
    }else{
        return -1;//error
    }
}
int factor(){
    if(peek()!='(') return number();
    cur++;
    int n = expression();
    assert(peek()==')');
    cur++;
    return n;
}
int term(){
    int r = factor();
    while(cur<input.size()
            &&(peek()=='*' || peek()=='/')){
        char o = multiveOpr();
        int b = factor();
        r = opr(o,r,b);
    }
    return r;
}
int expression(){
    int r = term();
    while(cur<input.size() 
            &&(peek()=='+' || peek()=='-')){
        char o = additiveOpr();
        int b = term();
        r = opr(o,r,b);
    }
    return r;
}
int solve(){
    int n = expression();
    assert(peek()=='=');
    return n;
}
signed main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> input;
        cur = 0;
        cout << solve() << endl;
    }
}


Measured memory_bytes: 3136
n = gets.to_i

def search(n, count)
    # 6のべき乗でいくらまで行けるか？
    c6 = 0
    while 6 ** (c6 + 1) <= n
        c6 += 1
    end
    # 9のべき乗でいくらまで行けるか？
    c9 = 0
    while 9 ** (c9 + 1) <= n
        c9 += 1
    end
    # puts "n, c6, c9 = #{n}, #{c6}, #{c9}"
    if c6 == 0 && c9 == 0
        return count + n
    end
    c1 = search(n - 9 ** c9, count + 1)
    c2 =  search(n - 6 ** c6, count + 1)
    return [c1, c2].min
end

puts search(n, 0)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) f2or (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B;
    cin >> A >> B;
    if(A==B) cout << A+B << endl;
    else cout << 2*max(A,B)-1 << endl; 
    return 0;
}


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

class Program
{
    private static readonly Scanner sc = new Scanner();
    static void Main(string[] args)
    {
        int n = sc.Int;
        int m = sc.Int;

        int[] cnt = new int[n];

        for (int i = 0; i < m; i++)
        {
            int a = sc.Int;
            int b = sc.Int;

            cnt[a-1]++;
            cnt[b-1]++;
        }

        foreach (var e in cnt)
            Console.WriteLine(e);
    }
}

class Scanner
{
    private string[] _str = new string[0];
    private int _i;

    public string Str
    {
        get
        {
            if (_i >= _str.Length)
            {
                _str = Console.ReadLine().Split(' ');
                _i = 0;
            }
            return _str[_i++];
        }
    }

    public int Int { get { return int.Parse(Str); } }
    public long Long { get { return long.Parse(Str); } }
    public double Double { get { return double.Parse(Str); } }
}

Measured memory_bytes: 13268
package main

import (
	"fmt"
)

func main() {
	var M, N int
	fmt.Scan(&N)
	var sum int
	t := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&t[i])
		sum += t[i]
	}
	fmt.Scan(&M)
	for i := 0; i < M; i++ {
		var p, x int
		fmt.Scan(&p, &x)
		fmt.Println(sum + x - t[p-1])
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

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

  cout << max(-1ll, K-sum) << "\n";

  

  return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  long long sum=0;
  for(i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0){
        if(sum<0){
            printf("ははは");
        }
      sum=sum+i;
    }
  }
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 1736
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    map<int, int> C;
    for(int a : A) C[a] ++;
    int max_c = 0;
    for(int i = 1; i < 99999; i++) max_c = max(max_c, C[i - 1] + C[i] + C[i + 1]);
    cout << max_c << endl;
}

Measured memory_bytes: 5376
// {{{ by shik
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REP1(i, a, b) for (int i = (a); i <= int(b); i++)
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int, int> PII;
typedef vector<int> VI;

namespace { namespace shik {

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

#ifdef SHIK
#include "dump.hpp"
#else
#define dump(...)
#endif

template<class T, class F = less<T>> void sort_uniq(vector<T> &v, F f = F()) { sort(begin(v), end(v), f); v.resize(unique(begin(v), end(v)) - begin(v)); }
template<class T> inline T bit(T x, int i) { return (x >> i) & 1; }
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

// }}}

void main() {
    LL a,b,c;
    R(a,b,c);
    LL ans=min(b+c,b+min(c,a+b+1));
    W(ans);
}

// {{{ main
}}
int main() { shik::main(); return 0; }
// }}}


Measured memory_bytes: 256
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=110;
int a[N],n;
int main()
{
    IO;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    int res=0;
    for(int i=1;i<=n;i++)
        if((i&1)&&(a[i]&1)) res++;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
using namespace std;
int a[100010];
int main()
{
	int n,k;
	int sum;
	while(scanf("%d %d",&n,&k)!=EOF)
	{
		
		memset(a,0,sizeof(a));
		sum=0;
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
		}
		do
		{
			sum++;
			n=n-k;
			if(n>0)n++;
		}while(n>0);
		
		printf("%d\n",sum);	
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	string s;
	cin >> s;
	bool a = false, b = false, c = false;
	rep(i, 3) {
		if (s[i] == 'a') a = true;
		else if (s[i] == 'b') b = true;
		else if (s[i] == 'c') c = true;
	}
	if (a) {
		if (b) {
			if (c) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
#define Tubtet(i, k) for (k = (i - 1) & i; k; k = (k - 1) & i)
#define Subset(i, k) for (k = i; k; k = (k - 1) & i)
using namespace std;
inline int read() {
    int res = 0; bool bo = 0; char c;
    while (((c = getchar()) < '0' || c > '9') && c != '-');
    if (c == '-') bo = 1; else res = c - 48;
    while ((c = getchar()) >= '0' && c <= '9')
        res = (res << 3) + (res << 1) + (c - 48);
    return bo ? ~res + 1 : res;
}
const int N = 17, M = 405, C = (1 << 15) + 5, PYZ = 1e9 + 7;
int n, m, g[N][N], f[3][C], c[C], d[C], Cm, p[M], ans;
int main() {
    int i, j, k, x, y; n = read(); m = read(); p[0] = 1;
    For (i, 1, m) x = read(), y = read(), g[x][y]++, p[i] = 2ll * p[i - 1] % PYZ;
    Cm = (1 << n) - 1; For (i, 0, Cm) For (j, 1, n) For (k, 1, n) if (g[j][k]) {
        if (((i >> j - 1) & 1) && ((i >> k - 1) & 1)) c[i] += g[j][k];
        if (((i >> j - 1) & 1) || ((i >> k - 1) & 1)) d[i] += g[j][k];
    }
    For (k, 1, 2) For (i, 0, Cm) {
            if (!((i >> k - 1) & 1)) continue; f[k][i] = p[c[i]]; Tubtet(i, j) {
                if (!((j >> k - 1) & 1)) continue;
                f[k][i] = (f[k][i] - 1ll * f[k][j] * p[c[i - j]] % PYZ + PYZ) % PYZ;
            }
        }
    ans = p[m]; For (i, 0, Cm) {
        if (!(i & 1) || ((i >> 1) & 1)) continue; Subset(Cm - i, j) {
            if (!((j >> 1) & 1) || c[i] + c[j] < c[i + j]) continue;
            ans = (ans - 1ll * f[1][i] * f[2][j] % PYZ *
                p[m - d[i + j]] % PYZ + PYZ) % PYZ;
        }
    }
    cout << ans << endl; return 0;
}

Measured memory_bytes: 768
import std.stdio, std.string, std.math, std.conv, std.algorithm;
void main() {
	readln;
	int[][] d;
	foreach (string l; lines(stdin))
		d ~= l.split.to!(int[]);
	int n = d[0].count.to!int;
	foreach (p; 1..4) {
		auto s = 0.0;
		foreach (i; 0..n)
			s += pow(abs(d[0][i] - d[1][i]), p);
		s = pow(s, 1.0/p.to!real);
		"%.6f".writefln(s);
	}
	real[] m;
	foreach (i; 0..n)
		m ~= abs(d[0][i] - d[1][i]).to!real;
	"%.6f".writefln(m.sort!("a>b")[0]);
}


Measured memory_bytes: 2612
from functools import reduce
import math

MIN = -10 ** 9
MAX = 10 ** 9


def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    sign = 1

    xx = 0
    for ai in A:
        xx += sign * ai
        sign *= -1

    res = [xx]
    for ai in A:
        xx = 2*(ai - xx//2)
        res.append(xx)
    res.pop()
    print(*res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14648
import java.util.Scanner;

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

		int w = scan.nextInt();		
		int a = scan.nextInt();		
		int b = scan.nextInt();		

		if(b > a+w){
			System.out.println(b-(a+w));
		}
		else if(a > b+w){
			System.out.println(a-(b+w));
		}
		else {
			System.out.println("0");
		}
	}
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=9223372036854775807ll;

struct line{
    ll k,b;
    line(ll k=0,ll b=0):k(k),b(b){}
    ll get(ll x){return k*x+b;}
}st[300010],u;

int tp;

double its(line a,line b){
    return (b.b-a.b)/double(a.k-b.k);
}

int t[300010],n;
ll s[300010],f[300010],g[300010];
void dp(ll*f){
    int i;
    for(int i=1;i<=n;i++) s[i]=s[i-1]+t[i];
    tp=1;
    st[1]=line(0,0);
    for(int i=1;i<=n;i++){
        while(tp>1&&st[tp].get(i)<=st[tp-1].get(i)) tp--;
        f[i]=max(st[tp].get(i)+((ll)i*i+i)/2-s[i],f[i-1]);
        u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
        while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1])) tp--;
        st[++tp]=u;
    }
}
ll h[300010];
void solve(int l,int r){
    if(l==r){
        h[l]=1ll-t[l];
        return;
    }
    int mid,i,now;
    ll mx;
    mid=(l+r)>>1;
    solve(l,mid);
    solve(mid+1,r);
    tp=0;
    for(int i=l-1;i<mid;i++){
        u=line(-i,f[i]+((ll)i*i-i)/2+s[i]);
        while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1])) tp--;
        st[++tp]=u;
    }
    now=1;
    mx=-inf;
    for(i=r;i>mid;i--){
        while(now<tp&&its(st[now],st[now+1])>=i)now++;
        mx=max(mx,st[now].get(i)+((ll)i*i+i)/2-s[i]+g[i+1]);
        h[i]=max(h[i],mx);
    }
    tp=0;
    for(i=mid+1;i<=r;i++){
        u=line(-i,g[i+1]+((ll)i*i+i)/2-s[i]);
        while(tp>1&&its(u,st[tp-1])>=its(st[tp],st[tp-1]))tp--;
        st[++tp]=u;
    }
    now=tp;
    mx=-inf;
    for(i=l-1;i<mid;i++){
        while(now>1&&its(st[now],st[now-1])<=i)now--;
        mx=max(mx,st[now].get(i)+((ll)i*i-i)/2+s[i]+f[i]);
        h[i+1]=max(h[i+1],mx);
    }
}
int main(){

    int i,m,x,y;
    cin>>n;
    for(i=1;i<=n;i++) scanf("%d",t+i);
    dp(f);
    reverse(t+1,t+n+1);
    dp(g);
    reverse(t+1,t+n+1);
    reverse(g+1,g+n+1);
    for(i=1;i<=n;i++)s[i]=s[i-1]+t[i];
    solve(1,n);
    scanf("%d",&m);
    while(m--){
        scanf("%d%d",&x,&y);
        printf("%lld\n",max(f[x-1]+g[x+1],h[x]+t[x]-y));
    }
}

Measured memory_bytes: 17792
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    cin >> N >> K;
    vector<ll> x(N), y(N);
    vector<ll> xary(N), yary(N);
    rep(i, 0, N)
    {
        cin >> x[i] >> y[i];
        xary[i] = x[i];
        yary[i] = y[i];
    }
    sort(xary.begin(), xary.end());
    sort(yary.begin(), yary.end());

    vector<vector<int>> acm(N + 1);
    rep(i, 0, N + 1) acm[i].assign(N + 1, 0);
    rep(xi, 0, N) rep(yi, 0, N)
    {
        const int point = distance(x.begin(), find(x.begin(), x.end(), xary[xi])) == distance(y.begin(), find(y.begin(), y.end(), yary[yi])) ? 1 : 0;
        acm[xi + 1][yi + 1] = acm[xi][yi + 1] + acm[xi + 1][yi] - acm[xi][yi] + point;
    }

    ll ans = (xary[N - 1] - xary[0]) * (yary[N - 1] - yary[0]);

    rep(xi, 0, N) rep(xj, xi + 1, N) rep(yi, 0, N) rep(yj, yi + 1, N)
    {
        int num = acm[xj + 1][yj + 1] - acm[xi][yj + 1] - acm[xj + 1][yi] + acm[xi][yi];
        ll lx = xary[xi], rx = xary[xj];
        ll by = yary[yi], uy = yary[yj];

        if (num >= K) chmin(ans, (rx - lx) * (uy - by));
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    reprev (i, s.size() / 2) {
        bool allof = true;
        rep (j, i) allof &= s[j] == s[j + i];
        if (allof) {
            cout << i * 2 << "\n";
            return 0;
        }
    }
    cout << 0 << "\n";
    return 0;
}

Measured memory_bytes: 256