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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs 
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

vector<ll>z_algorithm(string s){
  ll n = s.size();
  vector<ll>ret(n,0);
  ret[0] = n;
  ll p = 1,len = 0;
  while(p < n){
    while(p+len < n && s[len] == s[p+len])len++;
    ret[p] = len;
    if(len == 0){p++; continue;}
    ll k = 1;
    while(p+k < n && k+ret[k] < len)ret[p+k] = ret[k], k++;
    p += k, len -= k;
  }
  return ret;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  rep(i,0,n){
    auto v=z_algorithm(s.substr(i));
    rep(j,0,v.size()){
      chmax(res,min(j,v[j]));
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
  int n,a=0,b=0,aa,bb;
  cin>>n;
  while(n!=0){
    for(int i=0;i<n;i++){
    cin>>aa>>bb;
    if(aa<bb){
      b+=aa+bb;
    }else if(aa>bb){
      a+=aa+bb;
    }else if(aa==bb){
      a+=aa;
      b+=bb;
    }
  }
    cout<<a<<" "<<b<<endl;
    cin>>n;
    a=0;
    b=0;
  }
  return 0;
}

Measured memory_bytes: 2996
import sys

def gcd(a,b):
    if a<b:
        a,b = b,a
    if a%b==0:
        return b
    else:
        return gcd(a%b,b)
        
N,M=map(int,input().split())
length=N*M//gcd(N,M)

S=input()
T=input()

a=length//N
b=length//M
l=a*b//gcd(a,b)
s=l//a
t=l//b

for i in range(gcd(N,M)):
    if S[i*s]!=T[i*t]:
        print(-1)
        sys.exit()
print(length)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector< std::pair<long long, long long> > drinks;
  for (int i = 0; i < n; i++) {
    long long a, b;
    std::cin >> a >> b;
    drinks.push_back(std::make_pair(a, b));
  }
  std::sort(drinks.begin(),
            drinks.end(),
            [](const std::pair<long long, long long>& lhs, const std::pair<long long, long long>& rhs) {
              return lhs.first < rhs.first;
            }
  );
  int sum = 0;
  long long ans = 0;
  for (const std::pair<long long, long long> d : drinks) {
    if (m - sum >= d.second) {
      sum += d.second;
      ans += d.first * d.second;
    } else {
      ans += d.first * (m - sum);
      break;
    }
  }
  std::cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	int ar[n];
  	int ans = 0;
  	for(int i=0;i<n;i++){
    	cin>>ar[i]; if(ar[i]&1) ans++;
    }
  	if(ans&1) cout<<"NO";
  	else cout<<"YES";
}

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

struct Heap {
    int *heapTable;
    int length;
    int curr;

    Heap () {
        this->heapTable = new int[20000001];
        this->length = 0;
        this->curr = 1;
    }

    void add (int valor) {
        this->heapTable[this->curr] = valor;
        this->curr++;
        this->length++;
    }

    void bottomUp() {
        if (this->length > 1) {
            int k = this->length;
            int v = this->heapTable[k];
            bool heapConfirm = false;
            while (!heapConfirm && k > 1) {
                int j = k / 2;
                if (v <= this->heapTable[j]) {
                    heapConfirm = true;
                } else {
                   this->heapTable[k] = this->heapTable[j];
                   this->heapTable[j] = v;
                   k = j;
                }
            }
        }
    }
    void upDown() {
            int k = 1;
            int v = this->heapTable[k];
            bool heapConfirm = false;
            while (!heapConfirm) {
                int j = 2 * k;
                if (j < this->curr) {
                    if (this->heapTable[j] < this->heapTable[j+1]) {
                        j = j + 1;
                    }
                } if (v >= this->heapTable[j]) {
                    heapConfirm = true;
                } else {
                    this->heapTable[k] = this->heapTable[j];
                    k = j;
                }
            }
            this->heapTable[k] = v;
        }


    void extract () {
        int aux = this->heapTable[1];
        this-> heapTable[1] = this->heapTable[length];
        this->heapTable[length] = 0;
        this->curr--;
        this->length--;
        cout << aux << endl;
    }
};

int main () {
    Heap *heap = new Heap();
    bool stop = false;
    while (!stop) {
        string action = "";
        int valor = 0;
        cin >> action;
        if (action == "end") {
            stop = true;
        }
        else if (action == "insert") {
            cin >> valor;
            heap->add(valor);
            heap->bottomUp();
        } else {
            heap->extract();
            heap->upDown();
        }
    }
}


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

// ABC124A - Buttons
// https://atcoder.jp/contests/abc124/tasks/abc124_a

void ABC124A() {
	int A, B;
	cin >> A >> B;

	//ボタンの大きさが同じときは各1回ずつ押す
	if (A == B) {
		cout << A + B << endl;
		return;
	}


	int value_a = A + (A - 1);
	int value_b = B + (B - 1);

	if (value_a > value_b) {
		cout << value_a << endl;
	}
	else {
		cout << value_b << endl;
	}

}


int main() {
	ABC124A();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
using p = pair<long long, int>;


#define INF 100000000
vector<bool> bitTointeger(int bit,int n){
	vector<bool> s(n,false);
	for(int i = 0; i < n; i++){
		if(bit & (1 << i)){
			s[i] = true;
		}
	}
	
	return s;
}
int main(){
	int n,m;
	cin >> n >> m;
	
	vector<vector<int> > s(m);
	
	for(int i = 0; i < m; i++){
		int k; cin >> k;
		
		for(int j = 0; j < k; j++){
			int a; cin >> a;
			a--;
			s[i].push_back(a);
		}
	}
    int p[m];	
	for(int i = 0; i < m; i++) cin >> p[i];
	int ans = 0;
	for(int bit = 0; bit < (1<<n); ++bit){
		vector<bool> on = bitTointeger(bit,n);
		bool can = true;
		for(int i = 0; i < m; i++){
		int count = 0;
			for(int j = 0; j < s[i].size(); j++){
				if(on[s[i][j]]) count++;
			}
			if(count % 2 != p[i])	can = false;
		}
		
		if(can) ans++;
    }
	cout << ans << endl;
}
	
	


Measured memory_bytes: 256
# coding: utf-8

N, K, Q = map(int, input().split())
A = [None for _ in range(Q)]
for i in range(Q):
    A[i] = int(input())

n_win_list = [0 for _ in range(N)]

for a in A:
    n_win_list[a-1] += 1

for n_win in n_win_list:
    if n_win >= Q-K+1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 8644
/*
[abc110] D - Factorization
*/

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

ll gcd(ll a, ll b) {
    while (b > 0) {
        swap(b, a %= b);
    }
    return a;
}

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

ll mod_inv(ll a, ll m) {
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x) % m;
}

const int MAX_N = 100000;
const int MAX_SQRT_M = 100000;
const int MAX_FACT_N = MAX_N + 100;
const ll MOD = 1e9 + 7;

int N, M;
ll fact[MAX_FACT_N], fact_inv[MAX_FACT_N];

ll solve() {
    fact[0] = 1;
    fact_inv[0] = 1;
    for (int i = 1; i < MAX_FACT_N; i++) {
        fact[i] = (fact[i - 1] * i) % MOD;
        fact_inv[i] = mod_inv(fact[i], MOD);
    }

    map<int, int> pf;
    bool is_prime[MAX_SQRT_M];
    fill(is_prime, is_prime + MAX_SQRT_M, true);

    int remain = M;
    for (int i = 2; 1LL * i * i <= M; i++) {
        if (!is_prime[i]) {
            continue;
        }
        for (int j = 2 * i; 1LL * j * j <= M; j += i) {
            is_prime[j] = false;
        }
        for (; remain > 1 && remain % i == 0; remain /= i) {
            pf[i]++;
        }
    }
    if (remain > 1) {
        pf[remain] = 1;
    }

    ll ans = 1;
    for (auto& kv : pf) {
        int a = kv.second;
        ll c = ((fact[N - 1 + a] * fact_inv[a]) % MOD) * fact_inv[N - 1] % MOD;
        (ans *= c) %= MOD;
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 1920
def insertionSort(a,n,g)
  cnt = 0
  for i in g..n-1
    v = a[i]
    j = i-g
    while j>=0 && a[j]>v do
      a[j+g] = a[j]
      j = j-g
      cnt += 1
    end
    a[j+g] = v
  end
  return cnt
end
 
def makeShellNum(n)
  num = 0
  arr = []
  tmp = 1
  while n >= tmp do
    arr << tmp
    num += 1
    tmp = 3*tmp + 1
  end
  return num,arr.reverse
end

def shellSort(a,n)
  cnt = 0
  m,g = makeShellNum(n)
  for i in 0..m-1
    cnt += insertionSort(a,n,g[i])
  end
  printf("%d\n%s\n%d\n%s\n",m,g.join(" "),cnt,a.join("\n"))
end

n = gets.chomp.to_i
a = []
for i in 1..n do
  a[i-1] = gets.chomp.to_i
end
shellSort(a,n)


Measured memory_bytes: 36056
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
struct Point{
    double x,y;
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);  
    double a,b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();
		int c = 0;
		int d = 0;       
        if(b>0){int [] in = new int [b];
        String [] str = new String [b];
                int [] in2 = new int [a];
        for(int i=0;i<b;i++){in[i] = sc.nextInt();str[i] = sc.next();                             
                            }		        
        for(int i=0;i<b;i++){if("AC".equals(str[i]) && in2[in[i]-1]>=0)
                                                           {
                                          c++;d+=in2[in[i]-1];in2[in[i]-1]=-1000000;                                                                                     
                            }
                 else {in2[in[i]-1]++;}           
                            }      
               }
		System.out.println(c + " " + d);
	}
}

Measured memory_bytes: 70700
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
    int N,Y;
    scanf("%d %d",&N,&Y);
    for(int i=0;i<=N && 10000*i<=Y;i++){
            for(int j=0;i+j<=N && 10000*i+5000*j<=Y;j++){
                if(i*10000+j*5000+(N-i-j)*1000 == Y){
                    printf("%d %d %d",i,j,N-i-j);
                    goto OUT;
                }
          }
    }
printf("-1 -1 -1");
OUT:
return 0;        
}


Measured memory_bytes: 128
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int n, m;
  cin >> n >> m;
  //  vector<int> a(n);
  int a;
  priority_queue<int> q;
  ll ans = 0;
  REP(i, n)
  {
    cin >> a;
    ans += a;
    q.push(a);
  }
  REP(i, m)
  {
    //    sort(ALL(a));
    //    reverse(ALL(a));
    int a_max = q.top();
    q.pop();
    ans -= a_max - a_max / 2;
    q.push(a_max / 2);
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    int64_t a, b, c, d;
    std::cin >> a >> b >> c >> d;

    int64_t max = std::max(a*c, std::max(a*d, std::max(b*c,b*d)));

    std::cout << max << std::endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i, n)cin >> a[i];
    rep(i, n)cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>());
    ll l = -1;
    ll r = (ll)1e12 + 1;
    while(l + 1 < r){
        ll x = (l + r) / 2;
        ll cnt = 0;
        rep(i, n){
            if(a[i] > x / f[i]){
                cnt += a[i] - x / f[i];
            }
        }
        if(cnt <= k)r = x;
        else l = x;
    }
    cout << r << endl;
}

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

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

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

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

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

void IN(void){
  return;
}

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

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

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

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

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

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

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

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

  ll N;
  IN(N);
  string S;
  IN(S);

  vvll L(N, vll(10, 0));
  FOR(i,1,N){
    REP(j,10) L[i][j] = L[i-1][j];
    L[i][(S[i-1]-'0')]++;
  }
  
  vvll R(N, vll(10, 0));
  RREP(i,N-2){
    REP(j,10) R[i][j] = R[i+1][j];
    R[i][(S[i+1]-'0')]++;
  }

  vvvb flag(10, vvb(10, vb(10, false)));
  FOR(M,1,N-1){
    ll mid = (S[M]-'0');
    REP(i,10){
      if(L[M][i]==0) continue;
      REP(j,10){
        if(R[M][j]==0) continue;
        flag[i][mid][j] = true;
      }
    }
  }

  ll ans = 0;
  REP(i,10){
    REP(j,10){
      REP(k,10){
        if(flag[i][j][k]) ans++;
      }
    }
  }

  OUT(ans);

  return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,y=0,c;cin>>n>>x;
  vector<int>a(n);for(int i=0;i<n;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    y+=a.at(i);
    if(y>x){c=i;break;}
    else if(i==n-1){
      if(y<x)c=n-1;
      else c=n;
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int N, M, i, j;
    cin >> N >> M;
    int A[N];

    int total = 0;
    rep (i, N) {
        cin >> A[i];
        total += A[i];
    };

    int count = 0;
    rep (i, N) {
        int a = A[i];
        if (a * 4 * M >= total) {
            count++;
        }
    }

    if (count >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include<cstdio>
#include<cmath>
int a,b;
int main() {
	scanf("%d%d",&a,&b);
	for (int i=1;i<=1250;++i) {
		int a1=floor(i*0.08);
		int b1=floor(i*0.1);
		if (a1==a&&b1==b) {
			printf("%d",i);
			return 0;
		}
	} 
	printf("-1");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	string S;
	cin >> S;
	int N = S.size();
	int sum = 0;
	for (int i = 0; i < N; ++i)
	{
		sum += (S[i] - '0');
	}
	if (sum % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3688
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	D, _ := strconv.Atoi(sc.Text())

	X := make([][]int, N)
	for i := 0; i < N; i++ {
		X[i] = make([]int, D)
	}

	for i := 0; i < N; i++ {
		for j := 0; j < D; j++ {
			sc.Scan()
			X[i][j], _ = strconv.Atoi(sc.Text())
		}
	}

	count := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			var tmp float64
			for d := 0; d < D; d++ {
				tmp += math.Pow(float64(X[i][d]-X[j][d]), 2)
			}

			t := math.Sqrt(float64(tmp))
			if t == math.Floor(t) {
				count++
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, d[60];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
}


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

using ll = long long;

#define vl vector<long long>
using pll = pair<long long, long long>;
#define __ <<'\n'
#define _ << ' '
#define all(x) (x).begin(), (x).end()

void error()
{
    cout << "-1";
    exit(0);
}

struct delta
{
    ll d;
    bool operator<(const delta& b) const
    {
        return d < b.d;
    }
};

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

    ll n;
    cin >> n;
    vl a(n);
    for (auto i = 0; i < n; i++)
        cin >> a[i];
    vl b(n);
    for (auto i = 0; i < n; i++)
        cin >> b[i];

    multiset<delta> d;
    for (auto i = 0; i < n; i++)
    {
        d.insert({a[i] - b[i]});
    }

    ll changed = 0;

    multiset<delta> used;
    bool flag = true;
    while (d.begin()->d < 0)
    {
        ll tmp = d.begin()->d;

        if (tmp >= 0)
            break;

        changed++;

        if (used.empty())
        {
            ll use = d.rbegin()->d;
            if (use < 0)
                error();

            auto itr = d.find({tmp});
            if(itr!=d.end()){
                d.erase(itr);
            }
            //d.erase({tmp});
            //d.erase({use});

            itr = d.find({use});
            if(itr!=d.end()){
                d.erase(itr);
            }

            if (use + tmp > 0)
            {
                used.insert({use + tmp});
                changed++;
            } else if (use + tmp == 0)
            {

            } else
            {
                d.insert({use + tmp});
                changed--;
            }
        } else
        {
            ll use = used.rbegin()->d;
            
            auto itr = d.find({tmp});
            if(itr!=d.end()){
                d.erase(itr);
            }
            //d.erase({tmp});
            //d.erase({use});

            itr = used.find({use});
            if(itr!=d.end()){
                used.erase(itr);
            }

            if (use + tmp > 0)
            {
                used.insert({use + tmp});
            } else if (use + tmp == 0)
            {

            } else
            {
                d.insert({use + tmp});
                changed--;
            }
        }
    }

    cout << changed;

    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s;

int main() {
	cin >> s;
	
	int ans = 1000;
	inc(i, s.size() - 2) {
		setmin(ans, abs(753 - stoi(s.substr(i, 3))));
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <map>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int main(){
  int N, M;
  cin >> N;
  int tmp;
  list<int> D;
  rep(i, N){
    cin >> tmp;
    D.push_back(tmp);
  }
  cin >> M;
  list<int> T;
  rep(i, M){
    cin >> tmp;
    T.push_back(tmp);
  }
  //入力終了

  //問題案が足りていない
  if(N < M){
    cout << "NO" << endl;
    return 0;
  }

  //両方ソートしておく
  D.sort();
  T.sort();

  //小さい難易度から順に一致しているか見ていく
  
  while(1){
    //問題セットを処理できた
    if(T.empty() ){
      cout << "YES" << endl;
      return 0;
    }
    //問題セットが処理できていない，かつ，問題案が先になくなった
    if(D.empty() ){
      cout << "NO" << endl;
      return 0;
    }
    
    //難易度が一致していれば両方pop
    if(D.front() == T.front()){
      D.pop_front();
      T.pop_front();
    }
    //難易度が一致していなければ問題案のみpop
    else
      D.pop_front();
  }

  
  return 0;
}


Measured memory_bytes: 16048
#include <iostream>
#include <cstdio>

using namespace std;

int n, k, niz[1000000];
bool b[1000000];

int main () {
	scanf ("%d %d", &n, &k);
	if (n == 1 && k == 1) {
		cout << "Yes\n1";
		return 0;
	}
	if (k < 2 || k > 2 * n - 2) {
		printf ("No");
		return 0;
	}
	printf ("Yes\n");
	if (k == 2) {
		niz[n-1] = 2;
		niz[n-2] = 3;
		niz[n] = 1;
		niz[n+1] = 4;
		b[1] = 1;
		b[2] = 1;
		b[3] = 1;
		b[4] = 1;
	} else {
		niz[n-1] = k;
		niz[n-2] = k-1;
		niz[n] = k+1;
		niz[n+1] = k-2;
		b[k] = 1;
		b[k-1] = 1;
		b[k+1] = 1;
		b[k-2] = 1;
	}
	
	int j = 1;
	for (int i = 0; i < 2 * n - 1; i++) {
		while (b[j] == 1) {
			j++;
		}
		if (niz[i] == 0) {
			niz[i] = j;
			b[j] = 1;
		}
	}
	for (int i = 0; i < 2 * n - 1; i++) printf ("%d\n", niz[i]);
	return 0;
}

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

int N;
const int MAX_N = 1.0e5 + 100;
vector<int> A, B, C;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int A_in;
        cin >> A_in;
        A.push_back(A_in);
    }
    for (int i = 0; i < N; i++) {
        int B_in;
        cin >> B_in;
        B.push_back(B_in);
    }
    for (int i = 0; i < N; i++) {
        int C_in;
        cin >> C_in;
        C.push_back(C_in);
    }

    sort(begin(A), end(A));
    sort(begin(C), end(C));


    ll ans = 0;
    for (int i = 0; i < N; i++) {
        auto itr_A = lower_bound(begin(A), end(A), B[i]);
        auto itr_C = upper_bound(begin(C), end(C), B[i]);

        size_t lower_Bi = distance(begin(A), itr_A);
        size_t upper_Bi = distance(itr_C, end(C));

        ans += lower_Bi * upper_Bi;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1784
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int stack[101];
int top;

int pop()
{
	top--;
	return stack[top+1];
}

int main(){

  top=0;
  int a,b,x;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
    	a=pop();
    	b=pop(); 
    	stack[++top]=a+b;
 

    } else if ( s[0] == '-' ){
    	a=pop();
    	b=pop();
    	stack[++top]=b-a;

    } else if ( s[0] == '*' ){
    	a=pop();
    	b=pop();
    	stack[++top]=a*b;

    } else {
      stack[++top] = atoi(s);
    }
  }
  printf("%d\n",stack[1]);

  return 0;
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD = 1000000007;

     signed main(){
   int n;
   cin>>n;
   if(n>=30)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
using namespace std;
int main(){
  int K;
  string S;
  cin >> K;
  cin >> S;
  int size=S.size();
  if(size<=K){
    cout << S << endl;
  }else{
    cout << S.substr(0,K) << "..." << endl;
  }
}

Measured memory_bytes: 3604
import queue
n,q=map(int,input().split())
p=queue.PriorityQueue()
s=[0]*-~n
for _ in[0]*q:
 a,v=map(int,input().split())
 s[a]+=v;p.put((-s[a],a))
 while 1:
  t=p.get()
  if -t[0]==s[t[1]]:print(t[1],-t[0]);p.put(t);break


Measured memory_bytes: 28864
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,j,n) for(int i=j;i<n;i++)

int main(){
    int N;
    cin >> N ;
    int h[N],ans[N];
    REP(i,N){
        cin >>h[i];
    }
    ans[0] = 0;
    ans[1] = abs(h[1]-h[0]);
    REP2(i,2,N){
        ans[i] =((ans[i-1]+abs(h[i]-h[i-1]))<(ans[i-2]+abs(h[i]-h[i-2]))) ?(ans[i-1]+abs(h[i]-h[i-1])) : (ans[i-2]+abs(h[i]-h[i-2]));
            
    }
    cout << ans[N-1];

}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, S):
    if N % 2 != 0:
        return 'No'
    if S[:N//2] == S[N//2:]:
        return 'Yes'
    return 'No'


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6220
#include<stdio.h>
#include<stdlib.h>

int parent(int);
int left(int);
int right(int);
void maxheapify(int);

int A[500000];
int H;

int main(){
  
  int i;

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=H/2;i>=1;i--){
    maxheapify(i);
  }
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  
  return 0;
}
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return (2*i+1);
}
void maxheapify(int i){
  int l,r;
  int swap,largest;
  l=left(i);
  r=right(i);
  if(l<=H && A[l]>A[i]) largest=l;
  else largest=i;
  if(r<=H && A[r]>A[largest]) largest=r;
  if(largest!=i){
    swap=A[i];
    A[i]=A[largest];
    A[largest]=swap;
    maxheapify(largest);
  }
}



Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <map>
#include <climits>
#include <iomanip>
#include <cmath>
#include <algorithm>

using namespace std;

#define eb emplace_back
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define ll long long

const int N = 2e6 + 123;
const int NN = 2e3 + 500;
const int INF = INT_MAX;

void solve() {
	string s, t;
	cin >> s >> t;
	cout << t << s;
}

int main () {
	cerr << "Ready";
	
	solve();
	
	cerr << '\n';
	return 0;
}

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

int n, x[128], y[128], h[128];

int main () {
    cin >> n;
    for ( int i = 0 ; i < n ; i ++ ) {
        cin >> x[i] >> y[i] >> h[i];
    }

    for ( int cy = 0 ; cy <= 100 ; cy ++ ) {
        for ( int cx = 0 ; cx <= 100 ; cx ++ ) {

            int cH = 1;

            for ( int i = 0 ; i < n ; i ++ ) {
                int expH = abs( cx - x[i] ) + abs( cy - y[i]  ) + h[i];
                if ( h[i] )  {
                    cH = max( cH, expH );
                }
            }

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


                if ( cH - abs( cx - x[i] ) - abs( cy - y[i]  ) < 0 ) {
                    if ( h[i] == 0 ) { }
                    else { ok = 0; }
                }else {
                    if ( cH - abs( cx - x[i] ) - abs( cy - y[i]  ) != h[i] ) { ok = 0; }
                }
            }

            if ( ok ) {
                cout << cx << " " << cy << " " << cH << "\n";
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

const double PI=(acos(-1));

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> s(m);
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int a;
            cin>>a;
            --a;
            ++s[a];
        }
    }
    int ans=0;
    rep(i,m){
        if(s[i]==n)++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<pair<string, int>> v;

	int a;
	cin >> a;
	for(int i=0; i < a; i++){
		string b; int c;
		cin >> b >> c;
		if(b == "D") v.push_back(make_pair(b, c));
	}
	cin >> a;
	for(int i=0; i < a; i++){
		string b; int c;
		cin >> b >> c;
		if(b == "DD") v.push_back(make_pair(b, c));
	}
	int ret = 0;
	for(long long S = 0; S < (1 << v.size()); S++){
		int p = 0;
		int count = n;
		for(int i=0; i < v.size(); i++) if(S >> i & 1){count -= v[i].first.size(); p += v[i].second;}
		if(0 <= count) ret = max(ret, p);
	}
	cout << ret << endl;
}

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

int digit (long long int v) {
    int cnt = 1;
    while((v/=10) != 0) {
	cnt++;
    }
    return cnt;
}
int main() {
	
	long long int n,k,l;
	cin>>n;
	k=digit(n);
	l=pow(10,k-1);
	
	cout<<9*(k-1)+(n+1)/l-1<<endl;
}

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

//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;
const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
          double n,d;
          cin>>n>>d;
          int ans=0;
          for(int i=0;i<n;i++){
            double x,y;
            cin>>x>>y;
            double z=x*x + y*y;
            z=sqrt(z);
            if(z<=d)ans++;
          }
          cout<<ans<<endl;

   }
   }
















Measured memory_bytes: 3768
// #includes {{{
#include <bits/stdc++.h>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

int N;
vector<Int> a;

int main(){
	cin>>N;
	const int M = N*3;
	a.assign(M,0);
	REP(i,M){
		cin>>a[i];
	}
	sort(ALL(a));
	Int ans = 0;
	REP(i,N){
		int j = N*3-2-i*2;
		ans+=a[j];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;

int n,dp[404][404];
bool done[404][404];
vector<int> a(n+1,0);

int cal(int l,int r){
    if(done[l][r])return dp[l][r];
    done[l][r]=true;
    if(r==l)return 0;
    int now=inf;
    for(int i=l;i<r;i++){
        now=min(now,cal(l,i)+cal(i+1,r));
    }
    dp[l][r]=now+a[r]-a[l-1];
    return dp[l][r];   
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    a.resize(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)a[i]+=a[i-1];
    for(int i=0;i<404;i++){
        for(int j=0;j<404;j++)dp[i][j]=0;
    }
    cal(1,n);
    cout<<dp[1][n]<<endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const int MAX = 1e5;

int main(){
    int n; cin >> n;
    map<int,int> m;
    int t;
    ll ans = 0;
    REP(i,n){
        cin >> t;
        if(t > MAX) ++ans; // 絶対取り除く必要がある。
        else ++m[t];
    }
    REP(i,MAX){
        ans += (i <= m[i] ? m[i] - i : m[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <time.h>

#define loop(i, num)  for (int i = 0; i < num; i++)

using namespace std;

int main() {
    
    string data;
    
    cin >> data;
    
    cout << 2018 << data.substr(4, 6) << endl;
    
}


Measured memory_bytes: 256
n = input()
node = 0
tmp = n
while tmp:
	node += 1
	tmp >>= 1
edges = []
for i in range(node - 1):
	edges.append([i+1, i+2, 0])
	edges.append([i+1, i+2, 1<<i])
for i in range(node-2, -1, -1):
	if (1<<i)&n:
		edges.append([i+1, node, (n>>(i+1))<<(i+1)])
print node, len(edges)
for i in edges:
	print i[0], i[1], i[2]	

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

using namespace std;
#define endl "\n"

const int MOD = 1000000007;
int main()
{
	char a;
    scanf("%c",&a);
    if(a =='a' || a =='e' || a =='i' || a =='o' || a =='u' ){
        printf("vowel\n");
    }
    else{
        printf("consonant\n");
    }
	return 0;
}

Measured memory_bytes: 3660
input()
A=list(map(int,input().strip().split(" ")))
pos=[]
neg=[]
for x in A:
    if x>=0:
        pos+=[x]
    else:
        neg+=[x]

pos=sorted(pos)
neg=sorted(neg)

if len(neg)%2==0:
    print(sum(pos)-sum(neg))
else:
    ans1=sum(pos)-sum(neg)+2*neg[-1]
    ans2=sum(pos)-sum(neg)+2*neg[-1]
    if len(pos)>0:
        ans2=sum(pos)-sum(neg)-2*pos[0]
    print(max(ans1,ans2))
    

Measured memory_bytes: 69852
#include<bits/stdc++.h>
using namespace std;
class slove
{
private:
        int node[10];
        int route[205][205];
        int dp[1<<10][10];
        int n,m,k;
public:
    void in();
    void doing()
    {

        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                for(int s = 1; s <= n; s++)
                {
                    route[j][s] = min(route[j][s],route[j][i] + route[i][s]);
                }
            }
        }
        memset(dp,0x3f,sizeof(dp));
        int maxx = dp[0][0];
        for(int i = 0; i < k; i++)
        {
            dp[(1<<i)][i] = 0;
        }
        for(int i = 1; i < 1<<k; i++)
        {
            for(int j = 0; j < k; j++)
            {
                for(int s = 0; s < k; s++)
                {
                    if(j!=s&&!(i&(1<<s)))
                    {
                        dp[i|(1<<s)][s] = min(dp[i|(1<<s)][s],dp[i][j] + route[node[j]][node[s]]);
                    }
                }
            }
        }
        for(int i = 0; i < k; i++)
        {
            maxx = min(dp[(1<<k)-1][i],maxx);
        }
        printf("%d\n",maxx);
    }
};
void slove::in()
    {
        memset(route,0x3f,sizeof(route));
        scanf("%d %d %d",&n,&m,&k);
        for(int i = 0; i < k; i++)
            scanf("%d",&node[i]);
        while(m--)
        {
            int x,y,cost;
            scanf("%d %d %d",&x,&y,&cost);
            route[y][x] = route[x][y] = cost;
        }
    }
class dd:public slove
{

};
int main(void)
{
    dd M;
    M.in();
    M.doing();
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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 SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class D {
	ll k;
	const ll n{ 50 };
public:
	D()
	{
		cin >> k;
	}
	void solve()
	{

		if (k == 0)
		{
			cout << 2 << endl;
			cout << "1 1" << endl;
			return;
		}

		vll ans(n);
		REP(i, n)
			ans[i] = i + 1;

		ll r{ k % 50 };

		REP(i, n)
			ans[i] += k / 50;

		if (!r)
		{
			REP(i, n)
				--ans[i];
		}

		if (r)
		{
			REP(i, n - r)
			{
				--ans[i];

			}
		}
	

		cout << n << endl;
		REP(i, n - 1)
			cout << ans[i] << " ";
		cout << ans[n - 1] << endl;

	}
};


int main()
{
	D solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int ho[100010];
long long int str[100010];
int main(void){
    int n,m,i,temp;
    for(i=0;i<100010;i++){
        ho[i]=0;
        str[i]=0;
    }
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&temp);
        ho[temp]=1;
        if(i!=0 && ho[temp-1]==1){
            printf("0\n");
            return 0;
        }
    }
    str[0]=1;
    str[1]=1;
    if(ho[1]==1){
        str[1]=0;
    }
    for(i=2;i<100010;i++){
        str[i]=str[i-1]+str[i-2];
        str[i]=str[i]%1000000007;
        if(ho[i]==1){
            str[i]=0;
        }
    }
    printf("%lld\n",str[n]%1000000007);
    return 0;
}

Measured memory_bytes: 1280
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============

void reduce(vector<ll>& v) {
    const int N = v.size();
    rep(i, N - 1)v[i] = abs(v[i] - v[i + 1]);
    v.pop_back();
}

void zero_reduce(vector<ll>& v) {
    const int N = v.size();
    vector<ll> res;
    res.push_back(v[0]);
    REP(i, 1, N)if (v[i - 1] != 0 || v[i] != 0) {
        res.push_back(v[i]);
    }
    v = res;
}

int cnt2(int n) {
    int res = 0;
    while (n > 0) {
        res += n / 2;
        n >>= 1;
    }
    return res;
}

bool isodd(int n, int k) {
    int up = cnt2(n) - cnt2(n - k);
    int down = cnt2(k);
    assert(up >= down);
    return up == down;
}

int main()
{
    ll N;
    string s;
    cin >> N >> s;
    vector<ll> a(N);
    auto base = a;
    rep(i, N)a[i] = s[i] - '0';
    if (a.size() > 1)reduce(a);

    const int M = a.size();
    ll res = 0;

    rep(i, M) {
        res += isodd(M - 1, i)*a[i];
    }
    if (res % 2 == 1) {
        cout << 1 << endl;
    }
    else {
        if (find(a.begin(), a.end(), 1) != a.end()) {
            cout << 0 << endl;
        }
        else {
            for (auto& num : a)num /= 2;
            rep(i, M) {
                res += isodd(M - 1, i)*a[i];
            }
            cout << (res % 2) * 2 << endl;
        }
    }
    return 0;
}


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

int main() {
	int N, M;
	bool s = false;
	string U[256], T[256];

	cin >> N;
	for (int i = 0; i < N; ++i) cin >> U[i];
	cin >> M;
	for (int i = 0; i < M; ++i) {
		cin >> T[i];
		int f = 0;
		for (int j = 0; j < N; ++j) {
			if (T[i] == U[j]) {
				s = !s;
				if (s) cout << "Opened by ";
				else cout << "Closed by ";
				f = 1;
				break;
			}
		}
		if (!f) cout << "Unknown ";
		cout << T[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	unsigned long long a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] * a[1] * (a[2] % 2 == 1) << endl;
	return 0;
}

Measured memory_bytes: 256