akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define int long long

using namespace std;

const int MAXN = 1e4 + 100;

int A[MAXN];

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N;
    cin >> N;

    for(int i = 1 ; i <= 100 ; i++)
    {
    	for(int j = 1 ; j <= 100 ; j++)
    	{
    		for(int k = 1 ; k <= 100 ; k++)
    		{
    			if(i*i + j*j + k*k + i*j + i*k + j*k >= MAXN)continue;
    			A[i*i + j*j + k*k + i*j + i*k + j*k]++;
    		}
    	}
    }

    for(int i = 1 ; i <= N ; i++)
    {
    	cout << A[i] << '\n';
    }

    return 0;
}

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

int main(){

  string s;
  cin >>s;
  
  if(s=="SUN"){
    cout<<"7"<<endl;
  }
  else if(s=="MON"){
    cout<<"6"<<endl;
  }
    else if(s=="TUE"){
    cout<<"5"<<endl;
  }
    else if(s=="WED"){
    cout<<"4"<<endl;
  }
    else if(s=="THU"){
    cout<<"3"<<endl;
  }
    else if(s=="FRI"){
    cout<<"2"<<endl;
  }
    else if(s=="SAT"){
    cout<<"1"<<endl;
  }
  
  
  
return(0);
}

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

#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long

#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>

#define infi INT_MAX
#define infl LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second

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

//(x^y)%p
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 
 
 
ll lcm(ll a,ll b)
{
  ll ans=(a*b)/(gcd(a,b));
  return ans;
} 


/*
ll parent[(ll)1e6+7];
ll rank1[(ll)1e6+7]; 


ll find(ll i)
{
  if(parent[i]!=i)  parent[i]=find(parent[i]);
  return parent[i];
}

void union1(ll i,ll j)
{
    ll i_id=find(i);
    ll j_id=find(j);
    if(i_id==j_id)  return;

    if(rank1[i_id]>rank1[j_id]) parent[j_id]=i_id;
    else parent[i_id]=j_id;

    if(rank1[i_id]==rank1[j_id]) rank1[j_id]++;
}

*/

//list<ll>adj[1000007];
//ll p=1e9+7;
/*bool dfs(ll s,bool *visited,ll parent)
{
   visited[s]=1;
   for(auto i:adj[s])
   {
      if(!visited[i])  
      {
        if(dfs(i,visited,s))  return 1;
      }

      else if(i!=parent)  return 1;
   } 
   return 0;

}*/

/*void dfs(ll s,bool *visited,ll *count)
{
  visited[s]=1;
  (*count)++;
  for(auto i:adj[s])  if(!visited[i])  dfs(i,visited,count);
}*/


void func()
{
  ll a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>=22)  cout<<"bust\n";
  else cout<<"win\n";
}
 
int main() 
{
    fast
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

    int q=1;
    //cin>>q;
    while(q)
    {
      func();
      q--;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

//nCrの偶奇
inline int C_parity(int n, int r)
{
  return n == (r | (n - r));
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  string s;
  cin >> n >> s;
  int sum = 0;
  rep(i, n)
  {
    sum ^= (s[i] - '0') * C_parity(n - 1, i) % 2;
  }
  if (sum)
  {
    cout << 1 << endl;
    return 0;
  }
  int b[1000010];
  rep(i, n - 1)
  {
    b[i] = abs(s[i] - s[i + 1]);
    if (b[i] == 1)
    {
      cout << 0 << endl;
      return 0;
    }
    b[i] /= 2;
  }
  sum = 0;
  rep(i, n - 1)
  {
    sum ^= (b[i] - '0') * C_parity(n - 2, i) % 2;
  }
  cout << (sum ? 2 : 0) << endl;

  return 0;
}

Measured memory_bytes: 5276
#include <cstdio>
#include <algorithm>

int p;

int sum(int a, int b)
{
	a += b;
	if (a >= p) a -= p;
	return a;
}
int mult(int a, int b)
{
	return (a * b) % p;
}

bool check(int g)
{
	int pw = g;
	for (int r = 2; r < p; ++r, pw = mult(pw, g))
		if (pw == 1) return false;
	return true;
}


const int N = 3000;

int pw[N];
int a[N], b[N];

int main()
{
	scanf("%d", &p);
	int g = 1;
	while(!check(g))
		++g;
		
	pw[0] = 1;
	for (int i = 1; i < p - 1; ++i)
		pw[i] = mult(pw[i - 1], g);
	
	scanf("%d", &a[0]);
	b[0] = a[0];
	for (int i = 1; i < p; ++i)
	{
		scanf("%d", a + i);
		a[i] = (a[i] - a[0] + p) % p;
	}
	
	for (int i = 0; i < p - 1; ++i)
	{
		b[i + 1] = 0;
		for (int j = 0; j < p - 1; ++j)
			b[i + 1] = sum(b[i + 1], mult(pw[(i * j) % (p - 1)], a[pw[j]]));
		b[i + 1] = (p - b[i + 1]) % p;
	}
	std::reverse(b + 1, b + p);
	for (int i = 0; i < p; ++i)
		printf("%d ", b[i]);
}

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

typedef pair<int, int> pi; 

int main(){

ios_base::sync_with_stdio(false);

long long t,y,i,k,ans;
string s1,s2;

t=1;

while(t--){
	
	ans=0;
	
	cin>>s1>>s2;
	
	k=s1.length();
	
	for(i=0;i<k;i++)
	if(s1[i]==s2[i])
		ans++;
	
cout<<ans<<endl;}

return 0;}
	
	
	
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    REP(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    REP(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

int main()
{
	int A = inputValue();
	int B = inputValue();
	int ans = max(A+B,A-B);
	ans = max(ans, A*B);
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main()
{
    ll k,a,b;
    cin >> k >> a >> b;
    for(ll i = a;i <= b;i++)
    {
        if(i % k == 0)
        {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    
    return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <utility>
#include <memory>
#include <sstream>
#include <complex>
#include <cassert>
#include <bitset>
#define rep(i, n) for(int i = 0; i < n; i++)
#define fi first
#define se second
//#include <Windows.h>
//#include "Library.h"
//#include "Math.h"
//#include "Othello.h"
using namespace std;
typedef long long int ll; typedef pair <int, int> P; typedef vector <int> vecint; typedef pair<int, P> P1; typedef pair<ll, P1> P2;
const int inf = 1000000000;
const ll INF = 9000000000000000000;
const double EPS = 10e-9;
int x[100001], y[100001], t[100001];
int main()
{
	int n;
	cin >> n;
	rep(i, n)
	{
		cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
	}
	bool ok = true;
	rep(i, n)
	{
		int td = t[i + 1] - t[i];
		int xs = abs(x[i + 1] - x[i]);
		int ys = abs(y[i + 1] - y[i]);
		int d = xs + ys;
		//cout << td << " " << xs << " " << ys << endl;
		if (td < d || (td - d) % 2 == 1) { ok = false; break; }
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1408
var ch:array[0..200007] of char;
    n,lx,rx:longint;
begin
  n:=0;
  while not(eoln) do
  begin
    inc(n);
    read(ch[n]);
  end;
  readln;
  lx:=1;rx:=n;
  while (ch[lx]<>'A') do inc(lx);
  while (ch[rx]<>'Z') do dec(rx);
  writeln(rx-lx+1);
end.
  

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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(long n, long m) {
    if (n > m) return calc(m, n);

    if (n == 1) {
        if (m == 1) return 1;
        return m - 2;
    }

    if (n == 2) return 0;

    return (n - 2) * (m - 2);
}

void main() {
    auto nm = readints;
    int n = nm[0], m = nm[1];

    auto ans = calc(n, m);
    writeln(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll n, m;
vector<pair<int, int> > ab(100000);
vector<ll> ans(100000);
ll par[100001];
ll ran[100001];
ll siz[100001];

void init(int n){
	for (int i = 0; i <= n; i++){
		par[i] = i;
		ran[i] = 0;
		siz[i] = 1;
	}
}
int find(int x){
	if (par[x] == x){
		return x;
	}else{
		par[x] = find(par[x]);
		return par[x];
	}
}
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if (x == y) return;

	if (ran[x] < ran[y]){
		par[x] = y;
		siz[y] += siz[x];
		siz[x] = siz[y];
	}else{
		par[y] = x;
		siz[x] += siz[y];
		siz[y] = siz[x];
		if (ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x, int y){
	return find(x) == find(y);
}
int size(int x){
	return siz[find(x)];
}

int main(){
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		cin >> ab[i].first >> ab[i].second;
	}
	init(n);
	ans[m] = n*(n-1)/2;
	for (int i = m-1; i > 0; i--){
		ll tmp1_size = size(ab[i].first), tmp2_size = size(ab[i].second);
		if (!same(ab[i].first, ab[i].second)){
			ans[i] = ans[i+1] - tmp1_size*tmp2_size;
		}else{
			ans[i] = ans[i+1];
		}
		unite(ab[i].first, ab[i].second);
	}
	for (int i = 1; i <= m; i++){
		cout << ans[i] << endl;
	}
 	return 0;
 }

Measured memory_bytes: 5248
import math
n, d = map(int , input().split())
points = []
for x in range(n):
    points.append(list(map(int, input().split())))
#print(points)
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        a = 0
        for k in range(d):
            a = a + abs(pow(points[i][k] - points[j][k], 2))
        a = math.sqrt(a)
        floatX, intX = math.modf(a)
        #print(floatX)
        if floatX == 0.0:
            ans = ans + 1
        #print("(i, j, a) = ({}, {}, {})".format(i, j, a))
print(ans)

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

using namespace std;

int main() {
  vector<int> card(9);
  for (int i=0; i<9; i++) {
    cin >> card.at(i);
  }
  vector<bool> check(9, false);
  
  int n;
  cin >> n;
  for (int i=0; i<n; i++) {
    int a;
    cin >> a;
    for (int i=0; i<9; i++) {
      if (card.at(i) == a) check.at(i) = true;
    }
  }
  
  if ((check.at(0) && check.at(1) && check.at(2)) ||
      (check.at(3) && check.at(4) && check.at(5)) ||
      (check.at(6) && check.at(7) && check.at(8)) ||
      (check.at(0) && check.at(3) && check.at(6)) ||
      (check.at(1) && check.at(4) && check.at(7)) ||
      (check.at(2) && check.at(5) && check.at(8)) ||
      (check.at(0) && check.at(4) && check.at(8)) ||
      (check.at(2) && check.at(4) && check.at(6))) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	cin >> s;
	cout << s.substr(0, 3) << "\n";


	return 0;
}


Measured memory_bytes: 3004
class PriorityQueue
  attr :s
  
  def initialize
    @q = [nil]
    @s = 0
  end

  def bubble_up(i)
    p = i / 2
    return if i <= 1 || @q[p] <= @q[i]
    @q[i], @q[p] = @q[p], @q[i]
    bubble_up(p)
  end

  def add(e)
    @q << e
    @s += e
    bubble_up(@q.size - 1)
  end

  def bubble_down(i)
    c = i * 2
    return if c >= @q.size
    c += 1 if c != @q.size - 1 && @q[c] > @q[c + 1]
    return if @q[i] <= @q[c]
    @q[i], @q[c] = @q[c], @q[i]
    bubble_down(c)
  end

  def pop
    @q[1], @q[-1] = @q[-1], @q[1]
    ret = @q.pop
    @s -= ret
    bubble_down(1)
    ret
  end

  def push_pop(e)
    self.add(e)
    self.pop
  end
end

N = gets.to_i
As = gets.split.map(&:to_i)

def f(xs, ys)
  pq = PriorityQueue.new
  xs.each{|x| pq.add(x)}
  ys.each_with_object([pq.s]){|y, o| pq.push_pop(y); o << pq.s}
end

as1, as2, as3 = As.each_slice(N).to_a
s1 = f(as1, as2)
s2 = f(as3.map{|a| -a}, as2.map{|a| -a}.reverse).reverse
puts s1.zip(s2).map{|x, y| x + y}.max

Measured memory_bytes: 36932
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
using namespace std;
 
int main(){
	long long a,b;
	cin >> a >> b;
	long long cnt=0;
	for(long long i=a;i<=b;i++){
		if(i==0){
			cout << "Zero" << endl;
			return 0;
		}
		if(i<0)cnt++;
	}
	if(cnt%2==0)cout << "Positive" << endl;
	else cout << "Negative" << endl;
	return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    const ll INF = 1e15;

    int A, B, Q;
    cin >> A >> B >> Q;

    vll s(A + 2);
    s.front() = -INF;
    for (int i = 1; i <= A; i++) {
        cin >> s[i];
    }
    s.back() = INF;

    vll t(B + 2);
    t.front() = -INF;
    for (int i = 1; i <= B; i++) {
        cin >> t[i];
    }
    t.back() = INF;

    ll x;
    for (int q = 0; q < Q; q++) {
        cin >> x;

        auto its = lower_bound(all(s), x);
        ll sL = *prev(its), sR = *its;

        auto itt = lower_bound(all(t), x);
        ll tL = *prev(itt), tR = *itt;

        ll ans = LLONG_MAX;
        for (ll s : { sL , sR }) {
            for (ll t : { tL , tR} ) {
                ans = min(ans, abs(x - s) + abs(s - t));
                ans = min(ans, abs(x - t) + abs(t - s));
            }
        }
        cout << ans << endl;
    }

    return 0;
}



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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    string s; cin >> s;
    cout << (s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  VI e(n+1);
  VI w(n+1);
  REP(i,0,n) {
    e[i+1] = e[i] + (s[i] == 'W');
  }
  for(int i=n-1; i>=0; i--) {
    w[i] = w[i+1] + (s[i] == 'E');
  }
  int ans = 1e8;
  REP(i,0,n) {
    ans = min(ans, e[i] + w[i+1]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2964
n,m = map(int, input().split())
A=[]
B=[]
s=0
for i in range(n):
   a = list(map(int, input().split()))
   A.append(a)
for j in range(m):
   b = int(input())
   B.append(b)
for p in range(n):
   s=0
   for q in range(m):
      y = A[p][q] * B[q]
      s += y
   print(s)


Measured memory_bytes: 6012
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int gcd(int x, int y){
	if (x < y){
		int temp = y;
		y = x;
		x = temp;
	}
	if (x % y) return gcd (y, x%y);
	return y;
}


int main(){
	int n, xx;
	cin >> n >> xx;
	vector<int> x(n+1);
	for (int i = 0; i < n; i++){
		cin >> x[i];
	}
	x[n] = xx;
	sort(x.begin(), x.end());

	vector<int> vec(n);
	for (int i = 0; i < n; i++){
		vec[i] = x[i+1] - x[i];
	}
	int ans = vec[0];
	for (int i = 1; i < n; i++){
		ans = gcd(ans, vec[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
n,m = map(int,input().split())
place_list = list(map(int,input().split()))

sorted_place_list = sorted(place_list)

dis_list = []

if n >= m :
    ans = 0 
else:
    for i,place in enumerate(sorted_place_list[:m-1]):
        dis = abs(sorted_place_list[i+1]-place)
        dis_list.append(dis)

    sorted_dis_list = sorted(dis_list)
    ans = sum(sorted_dis_list[:m-n])

print(ans)

Measured memory_bytes: 13968
<?php
$n = trim(fgets(STDIN));
$week = [
    'SUN' => 7,
    'MON' => 6,
    'TUE' => 5,
    'WED' => 4,
    'THU' => 3,
    'FRI' => 2,
    'SAT' => 1
    ];
echo $week[$n] . "\n";

Measured memory_bytes: 4604
N=int(input())
money_list=[1,6,36,216,1296,7776,46656,9,81,729,6561,59049]
dp=[0]
for i in range(1,N+1):
    dp.append(100000)

for i in range(1,N+1):
    for money in money_list:
        if i-money >= 0:
            dp[i]=min(dp[i-money]+1,dp[i])
print(dp[N])

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  int n;
  string s;
  cin>>n>>s;
  vector<bool> ss(n);
  rep(i,n) ss[i] = s[i]=='o';
  vector<bool> vec(n, false);
  // true S, false W

  rep(mask,4){
    vec[0] = mask%2;
    vec[1] = (mask>>1)%2;
    repl(i,1,n-1){
      if(vec[i]){ // s
        vec[i+1] = !(ss[i]^vec[i-1]);
      } else { // w
        vec[i+1] = ss[i]^vec[i-1];
      }
    }
    if(vec[0]){
      if(vec[1] != !(ss[0]^vec[n-1])) continue;
    } else {
      if(vec[1] != (ss[0]^vec[n-1])) continue;
    }
    if(vec[n-1]){
      if(vec[0] != !(ss[n-1]^vec[n-2])) continue;
    } else {
      if(vec[0] != (ss[n-1]^vec[n-2])) continue;
    }
    rep(i,n) cout<<"WS"[vec[i]];
    cout<<endl;
    return 0;
  }
  cout<<-1<<endl;

  return 0;
}


Measured memory_bytes: 512
using System;

namespace cs
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] blocks = Console.ReadLine().Split(' ');
            int x = int.Parse(blocks[0]);
            int a = int.Parse(blocks[1]);
            int b = int.Parse(blocks[2]);
            if (Math.Abs(a - x) < Math.Abs(b - x))
                Console.Write("A");
            else
                Console.Write("B");
        }
    }
}

Measured memory_bytes: 13140
/*
 * Problem Description: String Search
 * Category: String Search
 * Author: Khan
 * Date: 23th October, 2017
 */
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define MAXN 1000000
 
int next[MAXN];
 
void get_next(char *pattern)
{
    int lp = strlen(pattern);   //????????¨?????????????
    int k = -1, j = 0;
    next[0] = k;
    while (j < lp)
    {
        if ((k == -1) || (pattern[j] == pattern[k]))
        {
            ++k;
            ++j;
            next[j] = k;
        }
        else
            k = next[k];
    }
}
 
int index_BM(char *S, char *T, int pos)  
{  
    int i;  
    int j;  
   
    i = pos;  
    j = 0;   
   
    while ( (i < strlen(S)) && (j < strlen(T)) )  
    {  
        if (S[i] == T[j])  
        {  
            i++;  
            j++;  
        }  
        else 
        {  
            i = i - j + 1;   
            j = 0;  
        }  
    }  
   
    /* ???¨???strlen(T)?????????j???????????????´???0 ~ (strlen(T) - 1) */ 
    if (strlen(T) == j)  
    {  
        return i - strlen(T);  
    }  
    else 
    {  
        return -1;  
    }  
}  
 
void BM(char *content, char *pattern)
{
    int lp = strlen(pattern);
    get_next(pattern);
    int pos = index_BM(content, pattern, 0);;
    while(pos != -1)
    {
        printf("%d\n", pos);
        pos = index_BM(content, pattern, pos + 1);
    }
}
 
int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
 
    char content[MAXN + 1], pattern[10001];
    scanf("%s", content);
    scanf("%s", pattern);
    BM(content, pattern);
 
    return 0;
}

Measured memory_bytes: 1832
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double D = sc.nextDouble();
        double[] list = new double[N*2];
      
        for(int i = 0; i < N*2; i++){
          list[i] = sc.nextDouble();
        }
       
        int count = 0;
        for(int i = 1; i < N*2; i+=2){
          double x = list[i-1];
          double y = list[i];
          double ans = x*x + y*y;
          double answer = Math.sqrt(ans);
         
           if(answer <= D){
             count++;
           }
        }
  
          System.out.println(count);
        
	}

}

Measured memory_bytes: 66360
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n,t;
  cin >> n >> t;
  int x,h;
  double a=0;
  rep(i,n){
    cin >> x >> h;
    a = max((double)h/x,a);
  }
  double ans = a*t;
  cout << fixed << setprecision(8)<< ans << endl;
  return 0;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long double ld;

int main(){
    // read in integer 
    ld n;
    cin >> n;
    cout << fixed << n/(float)3 * n/(float)3 * n/(float)3<< endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

a =[[0 for i in range(m)]for j in range(n)]
for i in range(n):
    a[i] = list(map(int, input().split()))

b = [0 for j in range(m)]
for j in range(m):
    b[j] = int(input())

c = [0 for i in range(n)]

for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
    print(c[i])

Measured memory_bytes: 7968
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

const int INF = 1e9;
const ll LLINF = 1e16;
 
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //auto dp=make_v<int>(4,h,w);
    //fill_v(dp,0);
    string s;
    cin >> s;
    bool sflag = false;
    bool nflag = false;
    bool eflag = false;
    bool wflag = false;
    rep(i,sz(s)){
        if(s[i] == 'S') sflag = true;
        if(s[i] == 'N') nflag = true;
        if(s[i] == 'E') eflag = true;
        if(s[i] == 'W') wflag = true;
    }
    if(sflag && !nflag) {
        print("No");
    }
    else if(!sflag && nflag){
        print("No");
    }
    else if(eflag && !wflag) {
        print("No");
    }
    else if(!eflag && wflag){
        print("No");
    }
    else {
        print("Yes");
    }

}


Measured memory_bytes: 256
using System;
using CompLib.Util;

public class Program
{
    private int N;
    private int[] A;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();

        int all = 0;
        foreach (int i in A)
        {
            all ^= i;
        }

        int[] ans = new int[N];
        for (int i = 0; i < N; i++)
        {
            ans[i] = all ^ A[i];
        }

        Console.WriteLine(string.Join(" ", ans));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

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

typedef long long ll;
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

set < string > S;
set < string > :: iterator it;
string s,ss,ans;
int k,i,j;

int main(){
    cin >> s >> k;
    for(i=0;i<s.size();i++){
        for(ss="",j=i; j<min((int)s.size(),i+5); j++){
            ss += s[j];
            S.insert(ss);
        }
    }

    for(it=S.begin();it!=S.end();it++){
        ans = *it;
        k--;
        if(!k) break;
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  lll n,m,k;

  cin >> n >> m >> k;
  vector<int> a,b;
  a.resize(n);
  b.resize(m);

  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }
  for(ii=0;ii<m;ii++){
    cin >> b[ii];
  }

  //1.Aのみ読む数
  lll sum = 0;
  lll cnt = 0;
  lll aPos = 0;
  lll bPos = 0;

  for(ii=0;ii<n;ii++){
    if(sum + a[ii] <= k){
      sum += a[ii];
      cnt++;
    }
    else{
      break;
    }
    //cout << "sum:" << sum << endl;
  }

  //cout << "cnt:" << cnt << endl;
  aPos = ii -1;
  //cout << "aPos:" << aPos << endl;
  
  //2.Bを読む
  for(ii=0;ii<m;ii++){
    if(sum + b[ii] <= k){
      sum += b[ii];
      cnt++;
    }
    else{
      break;
    }
    //cout << "sum:" << sum << endl;    
  }

  bPos = ii - 1;

  //cout << "cnt:" << cnt << endl;
  //aPos = ii -1;
  //cout << "bPos:" << bPos << endl;
  
  lll max = cnt;

  for(ii=aPos;ii>=0;ii--){

    sum -= a[ii];
    cnt--;

    for(jj=bPos+1;jj<m;jj++){

      if(sum + b[jj] <= k){
        sum += b[jj];
        cnt++;
      }
      else{
        break;
      }

    }
    
    bPos = jj -1;
    
    if(cnt > max){
      max = cnt;
    }
    
  }

  cout << max << endl;
  
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

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

	ll ans=x/11*2;
	x%=11;

	if(x>0){
		if(x>6)
			ans+=2;
		else
			ans++;
	}

	cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int  main()
{
	int n; cin >> n;
	vector<int> p(n);
	rep(i, n)
		cin >> p[i];
	int cnt = 0;
	rep(i , n)
	{
		if (p[i] != i+1)
			cnt++;
	}
	if (cnt <= 2 ) cout << "YES\n";
	else cout << "NO\n";
	return (0);
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()
    a_desc = a[::-1]

    ok = 0
    ng = 2 * max(a) + 1

    while abs(ng - ok) > 1:
        mid = (ok + ng) // 2
        count = 0
        i = 0
        for elem in a:
            while i < n:
                if elem + a_desc[i] >= mid:
                    i += 1
                else:
                    break
            count += i
        if count >= m:
            ok = mid
        else:
            ng = mid

    from itertools import accumulate

    a_cum = list(accumulate(a_desc))
    a_cum = a_cum[::-1] + [0]
    ans = 0
    j = n
    cnt_over = 0

    for elem in a:
        while j > 0:
            if elem + a[j - 1] > ok:
                j -= 1
            else:
                break
        cnt_over += (n - j)
        ans += a_cum[j]
        ans += elem * (n - j)

    ans += ok * (m-cnt_over)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 60688
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    
    int x[m];

    for (int i = 0; i < m; i++) {
        cin >> x[i];
    }

    sort(x, x+m);

    if (m > n) {
        int distance[m-1];
        for (int i = 0; i < m-1; i++) {
            distance[i] = x[i+1] - x[i];
        }
        sort(distance, distance + m - 1);
        int ans = 0;
        for (int i = 0; i < m - n; i++) {
            ans += distance[i];
        }
        cout << ans << endl;
    }
    else {
        cout << 0 << endl;
    }
}

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

using namespace std;

constexpr int MAX_N = 100'000;
constexpr int MAX_VAL = 100'000;

int partition(int* A, const int& p, const int& r) {
    int x = A[r];
    int i = p;
    for (int j = p; j < r; j++) {
        if (A[j] <= x) {
            swap(A[i], A[j]);
            i++;
        }
    }
    swap(A[i], A[r]);
    return i;
}

int main() {
    ios::sync_with_stdio(false);

    int A[MAX_N];

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    int pivot = partition(A, 0, n-1);
    for (int i = 0; i < n; i++) {
        if (i > 0) { cout << ' '; }
        if (i == pivot) { cout << '['; }
        cout << A[i];
        if (i == pivot) { cout << ']'; }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 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 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int t=0;while(x){t+=BIT[x];x-=x&-x;}return t;}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)

LL z[N];
map<LL,int>mp;
void add(int x){
	while(x<=N){
		z[x]++;
		x+=x&-x;
	}
}
LL get(int x){
	int s=0;
	while(x)s+=z[x],x-=x&-x;
	return s;
		
}


LL n,k,a[N],s[N],d[N],p[N],b[N];
int get_num(LL x){
	return mp[x]?mp[x]:mp[x]=SZ(mp);
}
int main(){Accel
	cin>>n>>k;
	
	FOR(i,1,n){ 
		cin>>a[i];
		s[i]=s[i-1]+a[i];
		p[i]=d[i]=s[i]-k*i;
	}
	
	sort(p+1,p+n+1);
	FOR(i,1,n){
		mp[p[i]]=get_num(p[i]);
	}
	FOR(i,1,n)
		b[i]=mp[d[i]];

	//FOR(i,1,n)cout<<b[i]<<" ";cout<<endl;


	LL ans=0;
	FOR(i,1,n){
		ans+=get(b[i]);
		add(b[i]);
		ans+=p[i]>=0;
	}
	cout<<ans<<endl;
	

}

/*
4 6
1
1
2
3
*/




Measured memory_bytes: 36864
n = gets.to_i
as = gets.chomp.split.map(&:to_i)
array = Array.new(60,0)
MOD = (1e9 + 7).to_i
ans = 0
as.each do |a|
  (0..59).each do|i|
    array[i] += a[i]
  end
end
array.each_with_index do |k,i|
  ans += k * (n - k) * 2 ** i
end
puts ans % MOD

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

#define MAX 100000

int parent(int i) { return i / 2; }
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }

int main()
{
	int A[MAX];
	int H;

	cin >> H;
	for (int i = 1; i <= H; i++)
	{
		cin >> A[i];
	}

	for (int i = 1; i <= H; i++)
	{
		cout << "node " << i << ": ";
		cout << "key = " << A[i] << ", ";
		if (parent(i) >= 1)
			cout << "parent key = " << A[parent(i)] << ", ";
		if(left(i) <= H)
			cout << "left key = " << A[left(i)] << ", ";
		if(right(i) <= H)
		cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
}


Measured memory_bytes: 3128
/*
    e
*/
#include <bits/stdc++.h>

namespace Lsk {
#define _auto_ template <typename T>

// fast io
#define writesp(x) (write(x), putchar(' '))
#define writeln(x) (write(x), putchar('\n'))
_auto_ inline void read(T &x) {
	x = 0; bool sgn = false; char ch = getchar();
	while(!isdigit(ch)) (ch == '-') && (sgn = true), ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	if(sgn) x = -x;
}
_auto_ inline void write(T x) {
	if(x < 0) putchar('-'), x = -x;
	static char buf[40]; int o = 0;
	for(x; x > 9; x /= 10, ++o) buf[o] = x % 10 + '0'; buf[o] = x + '0';
	for(o; ~o; --o) putchar(buf[o]);
	return;
}

// cmin / cmax / swap
_auto_ inline void cmin(T &u, const T v) { if(u > v) u = v; }
_auto_ inline void cmax(T &u, const T v) { if(u < v) u = v; }
_auto_ inline T min(const T u, const T v) { return u < v ? u : v; }
_auto_ inline T max(const T u, const T v) { return u > v ? u : v; }
_auto_ inline void swap(T &u, T &v) { T tmp(u); u = v, v = tmp; }

// math
const int mod = 998244353, mod_2 = 1996488706;
//const int mod = 1000000007, mod_2 = 2000000014;
//const int mod = 1000000009, mod_2 = 2000000018;
_auto_ inline T abs(T x) { return x > 0 ? x : -x; }
_auto_ inline T gcd(T u, T v) {	return v ? gcd(v, u % v) : u; }
_auto_ inline T Mod(T u) { return u >= mod_2 ? u % mod : (u > mod ? u - mod : u); }
_auto_ inline T inmod(T u) { return u >= mod ? u - mod : (u < 0 ? u + mod : u); }
inline long long fpm(long long base, long long mi) {
	long long res = 1;
	while(mi) {
		if(mi & 1) res = Mod(res * base);
		base = Mod(base * base), mi >>= 1;
	}
	return res;
}

} using namespace Lsk;
#define N 200005
using std :: sort;

int n;
int a[N], f[N];
long long K;

inline bool check(long long mid) {
	long long res = 0;
	for(int i = 1; i <= n; ++i) {
		long long to = mid / f[i];
		if(to < a[i]) res += a[i] - to;	
	}
	return res <= K;
}

int main() {
	read(n), read(K);
	for(int i = 1; i <= n; ++i) read(a[i]);
	for(int i = 1; i <= n; ++i) read(f[i]);
	
	sort(a + 1, a + 1 + n);
	sort(f + 1, f + 1 + n, std :: greater<long long>());
	
	long long l = 0, r = 1e12, mid, minp = 1e18;
	while(l <= r) {
		mid = l + r >> 1;
		//writesp(l), writeln(r);
		if(check(mid)) {
			cmin(minp, mid);
			r = mid - 1;
		} else {
			l = mid + 1;
		}
	}
	
	writeln(minp);
	return 0;
}

Measured memory_bytes: 1920
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b=LI()
  return a*b

# main()
print(main())


Measured memory_bytes: 10784
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AAirConditioner solver = new AAirConditioner();
        solver.solve(1, in, out);
        out.close();
    }

    static class AAirConditioner {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.readInt();
            System.out.println(x >= 30 ? "Yes" : "No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32344
import java.util.Scanner;

public class Main {
 static int[][]daoyu;
 static int count;
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true) {
            int x = input.nextInt();
            int y = input.nextInt();
            if (x == 0 && y == 0) {
            	break;
            	}
            daoyu = new int [y+2][x+2];
            for(int i = 1;i<=y;i++) {
            	for(int j = 1;j<=x;j++) {
            		daoyu[i][j]=input.nextInt();
            		}
            }
            for (int i=0; i<y+2; i++){
            	daoyu[i][0] = daoyu[i][x+1] = 0;
         
            for (int j=0; j<x+2; j++){
            	daoyu[0][j] = daoyu[y+1][j] = 0;
 
            count = 0;
            }
        }
        for (int i = 1; i <= y; i++) {
            for (int j = 1; j <=x; j++) {
                if (daoyu[i][j] == 1) {
                    count++;
                    lj(i, j);
                }
            }
        } 
        System.out.println(count);
    /*    for(int i=0;i<=y;i++) {
        	for(int j=0;j<=x;j++) {
        		System.out.print(daoyu[i][j]);
        	}
        	System.out.println();
        }*/
        daoyu=null;
    }
    }
    private static void lj(int i, int j) {
    	 daoyu[i][j] = 2;
         if (i - 1 >= 0 && daoyu[i - 1][j] == 1)
             lj(i - 1, j);//上
         if (i + 1 < daoyu.length && daoyu[i + 1][j] == 1)
             lj(i + 1, j);//下
         if (j - 1 >= 0 && daoyu[i][j - 1] == 1)
             lj(i, j - 1);//左
         if (j + 1 < daoyu[i].length && daoyu[i][j + 1] == 1)
             lj(i, j + 1);//右
         if (i - 1 >= 0 && j-1>=0 && daoyu[i - 1][j-1] == 1)
             lj(i - 1, j-1);//左上
         if (i - 1 >= 0 && j+1<daoyu[i-1].length && daoyu[i - 1][j+1] == 1)
             lj(i - 1, j+1);//右上错误
         if (i + 1 < daoyu.length && j-1>=0 && daoyu[i + 1][j-1] == 1)
             lj(i + 1, j-1);//左下
         if (i + 1 < daoyu.length && j+1<daoyu[i+1].length &&daoyu[i + 1][j+1] == 1)
             lj(i+1, j+1);//右下
     }
 
}


Measured memory_bytes: 46208
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[10000],mi = INF,ma = 0;
	cin >> n;
	for(int i = 0;i < n;i++) {
		cin >> a[i];
		mi = min(mi,a[i]);
		ma = max(ma,a[i]);
	}
	int ans = INF;
	for(int i = 0;i < n;i++){
		ans= min(ans,min(ma - a[i],a[i] - mi) + ma - mi);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256