akhauriyash/Code-Regression huggingface dataset:
void main() {
	auto N = ri;
	auto a = readAs!(ulong[]).sort!"a > b"().array;
	a[0..2*N+1].enumerate.map!(i => i.index % 2 == 1 ? i.value : 0).sum.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

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

  int ans = 0;
  for (int i = 1; i <= N / 2; i++) {
    int j = N - i;
    if (j > N / 2) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	int N,M;
	cin >> N >> M;

	vector<string> A(N),B(M);
	rep(i,N){
		cin >> A[i];
	}
	rep(i,M){
		cin >> B[i];
	}

	bool flg = false;
	rep(i,N-M+1){
		rep(j,N-M+1){
			if(A[i].substr(j,M) == B[0].substr(0,M)){
				// cout << i << " " << j << endl; 
				rep(k,M){
					if(A[i+k].substr(j,M) != B[k].substr(0,M)){
						break;
					}
					if(k == M-1){
						flg = true;
					}
				}
			}
		}
	}

	if(flg){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;

	}

	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
std::vector<int>A['   '];int N,M,S['   '],B,L,R,I;int U(int z,int u){while(z<=N)S[z]+=u,z+=z&-z;}main(){scanf("%d%d",&M,&N);for(;~scanf("%d%d",&L,&R);)A[R-L+1].push_back(L);for(L=1;L<=N;L++){for(B=M,I=L;I<=N;I+=L){R=I;while(R)B+=S[R],R-=R&-R;}for(int u:A[L])U(u,1),U(u+L,-1),M--;printf("%d\n",B);}}

Measured memory_bytes: 53760
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll n, l;
    vector<ll> taste;
    cin >> n >> l;

    for (ll i=0; i<n; ++i)
    {
        taste.push_back(l+i);
    }

    ll smallest (999999999);
    ll index;
    for (ll i=0; i<n; ++i)
    {
            if (abs(taste[i]) < smallest)
            {
                smallest = abs(taste[i]);
                index = i;
            }
    }

    ll sum (0);
    for (ll i=0; i<n; ++i)
    {
            if (i != index)
                sum += taste[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
bool chmax(ll& a, ll b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

int counter[4];

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

    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        if (s == "AC") {
            counter[0]++;
        } else if (s == "WA") {
            counter[1]++;
        } else if (s == "TLE") {
            counter[2]++;
        } else if (s == "RE") {
            counter[3]++;
        }
    }

    printf("AC x %d\n", counter[0]);
    printf("WA x %d\n", counter[1]);
    printf("TLE x %d\n", counter[2]);
    printf("RE x %d\n", counter[3]);
    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi;
typedef vector<double> vd;
 
double mypow(double b ,int e){
      if(e == 0) return 1;
      if(e%2==0)
            return mypow( b*b, e/2 );
      else
            return mypow( b*b, e/2 ) * b;
}
 
int main(){
 
 
      int N,M,L; cin >> N >> M >> L ;
      if(N==1){
            cout << 1.0 << endl;
            return 0;
      }
      vector<vd> prob(N,vd(M+1,0.0));
      vector<vd> dist(N,vd(M+1,0.0));
 
      vd p(N),t(N),v(N);
      for(int i=0; i<N; i++) cin >> p[i] >> t[i] >> v[i];
 
      // PRE PROCESS
      for(int i=0; i<N; i++){
            dist[i][0] = (double)L / v[i];
            for(int j=1; j<=M; j++){
                  dist[i][j] = dist[i][j-1] + t[i];
            }
      }
      for(int i=0; i<N; i++)
            prob[i][0] = mypow((100-p[i])/100,M);
      for(int i=0; i<N; i++){
            for(int j=1; j<=M; j++){
                  if(p[i] != 100)
                        prob[i][j] = (prob[i][j-1] * (p[i]/100)) / ((100-p[i])/100);
                  else
                        prob[i][j] = 1.0;
            }
      }
      double comb = 1;
      for(int j=1; j<=M; j++){
            comb = comb * (M - j + 1) / j; 
            for(int i=0; i<N; i++){
                  prob[i][j] *= comb;
            }
      }
       
      vector<vd> sum = prob;
      for(int i=0; i<N; i++){
            for(int j=M-1; j>=0; j--){
                  sum[i][j] += sum[i][j+1];
                  if(sum[i][j] > 1) sum[i][j] = 1;
            }
      }
 
      vector<vd> ans = prob;
      for(int i=0; i<N; i++){
            for(int j=0; j<=M; j++){
                  for(int k=0; k<N; k++){
                        if(i==k) continue;
                        int id = upper_bound(dist[k].begin(),dist[k].end(), dist[i][j]) - dist[k].begin();
                        if(id > M) ans[i][j] = 0.0;
                        else       ans[i][j] *= sum[k][id];
 
                  }
            }
      }
 
      for(int i=0; i<N; i++){
            double tmp = 0.0;
            if(p[i] == 100) tmp = ans[i][M];
            else
                  for(int j=0; j<=M; j++)
                        tmp += ans[i][j];
            if(tmp > 1) tmp = 0;
            printf("%.10f\n",tmp);
      }
                         
}

Measured memory_bytes: 3384
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int N;
	int ans = 0;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++)
	{
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	p[N-1] = p[N-1] / 2;
	for (int i = 0; i < N; i++)
	{
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String[] str1 = sc.next().split("");
            String[] str2 = sc.next().split("");
            int count = 0;
            for(int i = 0; i < 3; i++){
              if(str1[i].equals(str2[i])){
                count++;
              }
            }
            System.out.println(count);
          }
}

Measured memory_bytes: 23636
import sys
input = sys.stdin.readline
yo = input()
if(yo[-1]=='\n'):
	yo=yo[:-1]
n=int(yo)
s=input()
if(s[-1]=='\n'):
	s=s[:-1]
preb=[0 for i in range(n)]
preg=[0 for i in range(n)]
prer=[0 for i in range(n)]
b=0; g=0; r=0
for i in range(n-1,-1,-1):
	if(s[i]=='R'):
		r+=1
	elif(s[i]=='G'):
		g+=1
	else:
		b+=1
	preb[i]=b; prer[i]=r; preg[i]=g
# print(preb)
# print(preg)
# print(prer)
l=[prer,preg,preb]
s=s.replace('R','0')
s=s.replace('G','1')
s=s.replace('B','2')
ans=0
# print(s)
for i in range(n):
	for j in range(i+1,n):
		if(s[i]!=s[j]):
			if(j+1>=n):
				continue
			ct = l[(3-int(s[i])-int(s[j]))][j+1]
			diff = j-i
			if((j+diff)<n and s[j+diff]==str(3-int(s[i])-int(s[j]))):
				ct-=1
			ans+=ct
print(ans)



Measured memory_bytes: 68660
N = int(input())
ans = [[j for j in range(i+1,N)]for i in range(N)]
for i in range(N):
    if len(ans[i]) >= N%2+i+1:
        ans[i][-(N%2+i+1)] = -1
out = []
for i in range(N):
    for j in ans[i]:
        if j >= 0:
            out.append([i+1,j+1])
print(len(out))
for i,j in out:
    print(i,j)

Measured memory_bytes: 4124
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long n = lread();
    writeln((n < 1000) ? "ABC" : "ABD");
}


Measured memory_bytes: 256
#include<stdio.h>
int a[10];
int bstack[10];
int btop;
int cstack[10];
int ctop;
bool dfs(int i)
{
    bool b1=false,b2=false;
    if(i==10)
        return true;
    if(btop==-1 || bstack[btop]<a[i])
    {
        btop++;
        bstack[btop]=a[i];
        i++;
        b1=dfs(i);
        btop--;
    }
    if(ctop==-1 || cstack[ctop]<a[i])
    {
        ctop++;
        cstack[ctop]=a[i];
        i++;
        b2=dfs(i);
        ctop++;
    }
    return b1|b2;
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        for(int i=0;i<10;i++)
        {
            scanf("%d",&a[i]);
        }
        btop=-1;
        ctop=-1;
        if(dfs(0))
            printf("YES\n");
        else
            printf("NO\n");
    }
}

Measured memory_bytes: 1008
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

typedef struct node node;
typedef struct edge{
    node* target;
    struct edge* next;
}edge;
typedef struct node{
    int id;
    edge* fst;
    edge* lst;
}node;
void initNodeArray(node* p, int n){
    for(int i=0; i<n; i++){
        (p+i)->id = 0;
        (p+i)->fst = NULL;
        (p+i)->lst = NULL;
    }
}
void addEdge(node* p, node* target){
    if(p->fst == NULL){
        p->fst = (edge*)malloc(sizeof(edge));
        p->lst = p->fst;
    }else{
        p->lst->next = (edge*)malloc(sizeof(edge));
        p->lst = p->lst->next;
    }
    p->lst->target = target;
    p->lst->next = NULL;
}
void rmEdge(node* p, node* q){
    edge* e = p->fst;
    edge* pre = NULL;
    while(e != NULL){
        if(e->target == q){
            if(pre != NULL){
                pre->next = e->next;
            }
            if(e == p->fst){
                p->fst = e->next;
            }
            if(e == p->lst){
                p->lst = pre;
            }
            free(e);
            return;
        }
        pre = e;
        e = e->next;
    }
    return;
}

void func(int* group, node* a, int g){
    if(*(group + (a->id)) != 0){
        return;
    }
    *(group + (a->id)) = g;
    edge* e = a->fst;
    while(e != NULL){
        func(group, e->target, g);
        e = e->next;
    }
}

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int p[n], q[n];
    node a[n];
    initNodeArray(a, n);
    int group[n];
    rep(i, 0, n){
        scanf("%d", &p[i]);
        a[i].id = i;
        group[i] = 0;
    }
    rep(i, 0, m){
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        addEdge(&a[x], &a[y]);
        addEdge(&a[y], &a[x]);
    }
    int num = 1;
    rep(i, 0, n){
        func(group, &a[i], num++);
    }
    rep(i, 0, n){
        q[p[i]-1] = group[i];
    }
    int ans = 0;
    rep(i, 0, n){
        if(group[i] == q[i]){
            ans++;
        }
    }
    printf("%d", ans);

    return 0;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll mod = 998244353;
ll dp[200005][3][3][2]; 
set <string> vis;
ll ss3(string s){
    vis.insert(s);
    for (ll i = 1; i < s.size(); i++){
        if (s[i] != s[i - 1]){
            string s1 = s;
            s1[i] = s1[i - 1] = (3 - (s1[i] - 'a') - (s1[i - 1] - 'a')) + 'a';
            if (vis.count(s1)) continue; ss3(s1);
        }
    }
    return vis.size();
}
int main(){
	string s; cin >> s;
	ll n = s.length(), edge = 0;
	for (ll i = 0; i < n - 1; i++) edge |= (s[i] != s[i + 1]);
	if (!edge) cout << 1 << endl;
	else if (n <= 3) cout << ss3(s) << endl;
	else{
		dp[1][0][0][0] = dp[1][1][1][0] = dp[1][2][2][0] = 1; 
		ll ans = 0; edge = 0;
		for (ll i = 1; i < n; i++){
			for (ll j = 0; j < 3; j++){
				for (ll k = 0; k < 3; k++){
					for (ll t = 0; t < 3; t++){
						for (ll l = 0; l < 2; l++) (dp[i + 1][t][(k + t) % 3][l | (t == j)] += dp[i][j][k][l]) %= mod;
					}
				}
			}
		}
		ll ss = 0; for (ll i = 0; i < n; i++) ss += (s[i] - 'a'); ss %= 3;
		for (ll j = 0; j < 3; j++) (ans += dp[n][j][ss][1]) %= mod;
		for (ll i = 0; i < n - 1; i++) edge |= (s[i] == s[i + 1]);
		cout << (ans + 1 - edge) % mod << endl; 
	}
}

Measured memory_bytes: 28676
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    vector<vector<int>> WH(H, vector<int>(W, 0));

    rep(i, N) {
        int x, y, a;
        cin >> x >> y >> a;
        if (a == 1) {
            rep(j, H) {
                rep(k, x) {
                    WH[j][k] = 1;
                }
            } 
        }
        else if (a == 2) {
            rep(j, H) {
                repd(k, x, W) {
                    WH[j][k] = 1;
                }
            }
        }
        else if (a == 3) {
            rep(k, W) {
                rep(j, y) {
                    WH[j][k] = 1;
                }
            }
        }
        else {
            rep(k, W) {
                repd(j, y, H) {
                    WH[j][k] = 1;
                }
            }
        }
    }

    int ans = W * H;
    rep(i, H) {
        rep(j, W) ans -= WH[i][j];
    }

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

Measured memory_bytes: 256
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> X;
  
  ll r = (X / 5 * 5);
  for (ll i = 500; i <= X;i += 500) {
    ll ua = X / i;
    ll tma = X-i;
    r = max(r, i / 500 * 1000 + (tma / 5 * 5));
  }

  return r;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int N;
  while (N = in()) {
    auto A = in(N);
    sort(ALL(A));
    int mini = inf;
    rep(i, N - 1) { chmin(mini, A[i + 1] - A[i]); }
    pr(mini);
  }
  return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
/*
#pragma comment(linker, "/STACK: 20000000005")
*/


using namespace std;


const int N = 200005, MOD = 1e9 + 7;

int n, x, y;
int ans[N];

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> x >> y;
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++){
            int d = min (j - i, 1 + min (abs (x - i) + abs (y - j), abs (x - j) + abs (y - i)));
            ans[d]++;
        }
    for (int i = 1; i < n; i++)
        cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 256
import java.nio.charset.Charset;
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        try (Scanner sc = new Scanner(System.in, Charset.defaultCharset().name())) {
            int diff = Integer.parseInt(sc.next());
            String text = sc.next();

            StringBuilder sb = new StringBuilder();
            for (char c : text.toCharArray()) {
                int codePoint = (c - 'A' + diff) % ('Z' - 'A' + 1) + 'A';
                sb.append((char) codePoint);
            }
            System.out.println(sb.toString());
        }
    }

}

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

using namespace std;

int main()
{
    long long int n,m,sum=0;
    cin>>n>>m;
    long long int a[m+1];
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(n>=sum)
    {
        cout << n-sum << endl;
    }
    else
    {
        cout << "-1\n";
    }
}


Measured memory_bytes: 3640
from collections import Counter

N = int(input())
As = [int(input()) for i in range(N)]

c = Counter(As)
c = sorted(c.items(), key=lambda x:x[0])
A_unique, A_counts = zip(*c)

ans = 0
for a in A_counts:
    if a%2!=0:
        ans += 1
print(ans)

Measured memory_bytes: 78996
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 100010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

char s[N];

int main()
{
	ll n,x=0,y=0,ans=0;
	scanf("%s",s);
	n=strlen(s);
	REP(i,n)
	{
		if (s[i]=='g')
		{
			if (x+1<=y)
			{
				x++;
				ans++;
			}
			else y++;
		}
		else
		{
			if (x+1<=y)
				x++;
			else
			{
				ans--;
				y++;
			}
		}
	}
	printf("%lld\n",ans);
return 0;
}


Measured memory_bytes: 384
<?php

$stdin = trim(fgets(STDIN));  

$number = explode(" ", $stdin);

$W = $number[0];
$H = $number[1];
$x = $number[2];
$y = $number[3];
$r = $number[4];

if( ($x+$r) > $W || ($x-$r) < 0 || ($y+$r > $H) || ($y-$r) < 0)
    echo "No\n";
else
    echo "Yes\n";

Measured memory_bytes: 6552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    rep(i, N) if (A[i] == 0) { cout << 0 << endl; return 0; }
    ll pro = 1;
    rep(i, N) {
        if (1000000000000000000 / pro < A[i]) { cout << -1 << endl; return 0; }
        else { pro *= A[i]; }
    }
    cout << pro << endl; return 0;
}

Measured memory_bytes: 3940
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  char S[3];
  int res=0;
  cin >> S;

  sort(S, S+3);

  if(strcmp(S,"abc")==0) cout << "Yes" << endl;
  else cout << "No"  << endl;
}


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

int main() {
	string S;
	cin >> S;
	bool AC=true;
	if (S.at(0)!='A') AC=false;
	int count=0;
	for (int i=2; i<S.length()-1; i++){
	    if (S.at(i)=='C') count++;
	}
	if (count!=1) AC=false;
	int COUNT=0;
	for (int i=0; i<S.length(); i++){
	    if (S[i]>='A' && S[i]<='Z') COUNT++;
	}
	if (COUNT!=2) AC=false;
	if (AC) cout << "AC" << endl;
	else cout << "WA" << endl;
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int X = 0, Y = 0, ansx = 200000, ansy = 200000;
	int ans = 0;
	scanf("%d %d", &X, &Y);

	if (X == 1) {
		ansx += 100000;
	} else if (X == 3) {
		ansx -= 100000;
	} else if (X != 2) {
		ansx = 0;
	}
	if (Y == 1) {
		ansy += 100000;
	} else if (Y == 3) {
		ansy -= 100000;
	} else if (Y != 2) {
		ansy = 0;
	}
	if ((X==1) && (Y == 1)) {
		ans = 400000;
	}
	printf("%d\n", ans+ansx+ansy);
    return 0;
}


Measured memory_bytes: 128
while True:
    n,k = map(int, input().split())
    if n == k == 0:
        break
    s = list(map(int, input().split()))
    for _ in range(n):
        b = list(map(int, input().split()))
        for i in range(k):
            s[i] -= b[i]
    print("Yes" if min(s) >= 0 else "No")

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

int check(char s[], int n){//n文字めが半分にあたる偶文字列なら0を返し、それ以外は1
	for(int i = 0; i < n; i++){
		if(s[i] != s[i+n]){
			return 1;
		}
	}
	return 0;
}

int main(void){
	char s[210];
	scanf("%s", s);
	int len = strlen(s);
	for(int n = len/2 - 1; n > 0; n--){
		if(check(s, n) == 0){
			printf("%d\n", 2*n);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);
	
	int N,X; scanf("%d%d", &N, &X);
	int pos = 0, cnt = 0;;
	for (int i = 0; i < N; i++){
		int L; scanf("%d", &L);
		if (pos <= X){
			cnt++;
		}
		pos += L;
	}
	if (pos <= X) cnt++;

	printf("%d", cnt);


	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	vector<llong> p, pp;

	cin >> N;
	p.resize(N+2), pp.resize(N+1);
	for(int i = 1; i <= N; i++){
		cin >> p[i];
		pp[i] = p[i];
	}

	pp = p;
	llong ans1 = 0, ans2 = 0;
	for(int i = 1; i <= N; i++){
		// for(auto x : p)
		// 	cerr << x << " ";
		// cerr << endl;
		if(i == p[i])
			ans1++, swap(p[i], p[i+1]);
	}
	cerr << endl;

	for(int i = N; i >= 1; i--){
		// for(auto x : pp)
		// 	cerr << x << " ";
		// cerr << endl;
		if(i == pp[i])
			ans2++, swap(pp[i], pp[i-1]);
	}


	cerr << ans1 << " " << ans2 << endl;
	cout << min(ans1,ans2) << endl;

	return 0;
}

Measured memory_bytes: 2560
import java.io.*;

class Main{
    public static void main(String[] args){
        try{
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String line = reader.readLine();
            double r = Double.parseDouble(line);
            System.out.printf("%f %f\n",r*r*Math.PI,r*2.0*Math.PI);
        }
        catch(IOException e){
            System.out.println(e);
        }
    }
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    double t, x;
    cin >> t >> x;
    cout << t / x << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = gets.split.map(&:to_i)
sum1 = a * x + b * y
sum2 = (x > y) ? (c * y * 2 + a * (x - y)) : (c * x * 2 + b * (y - x))
sum3 = (x > y) ? (c * x * 2) : (c * y * 2)
puts [sum1, sum2, sum3].min


Measured memory_bytes: 14264
str = gets.chomp
n = gets.to_i

n.times do
  line = gets.chomp.split
  case line[0]
  when "replace"
    str[line[1].to_i..line[2].to_i] = line[3]
  when "reverse"
    temp = str[line[1].to_i..line[2].to_i].reverse
    str[line[1].to_i..line[2].to_i] = temp
  when "print"
    puts str[line[1].to_i..line[2].to_i]
  end
end

Measured memory_bytes: 8780
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>

struct bizyutuhin_t {
	int64_t A, B;
};

int cmp(const void* x, const void* y) {
	int64_t a = ((const struct bizyutuhin_t*)x)->A;
	int64_t b = ((const struct bizyutuhin_t*)y)->A;
	return a < b ? -1 : a > b;
}

int32_t N;
struct bizyutuhin_t AB[555555];

/* sore wo hazusu to doredake score ga fueru ka */
int64_t katen_left[555555], katen_right[555555];

int64_t katen_left_max[555555], katen_right_max[555555];

int main(void) {
	int32_t i;
	int64_t kihon = 0;
	int64_t acc;
	int64_t kotae = 0;
	if (scanf("%" SCNd32, &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64 "%" SCNd64, &AB[i].A, &AB[i].B) != 2) return 1;
		kihon += AB[i].B;
	}
	qsort(AB, N, sizeof(*AB), cmp);
	kihon -= AB[N - 1].A - AB[0].A;
	for (i = 0; i < N - 1; i++) {
		katen_left[i] = AB[i + 1].A - AB[i].A - AB[i].B;
	}
	for (i = 1; i < N; i++) {
		katen_right[i] = AB[i].A - AB[i - 1].A - AB[i].B;
	}
	acc = katen_left[0];
	katen_left_max[0] = 0;
	for (i = 1; i < N; i++) {
		katen_left_max[i] = katen_left_max[i - 1] < acc ? acc : katen_left_max[i - 1];
		acc += katen_left[i];
	}
	acc = katen_right[N - 1];
	katen_right_max[N - 1] = 0;
	for (i = N - 1 - 1; i >= 0; i--) {
		katen_right_max[i] = katen_right_max[i + 1] < acc ? acc : katen_right_max[i + 1];
		acc += katen_right[i];
	}
	for (i = 0; i < N; i++) {
		int64_t candidate = kihon + katen_left_max[i] + katen_right_max[i];
		if (i == 0 || candidate > kotae) kotae = candidate;
	}
	printf("%" PRId64 "\n", kotae);
	return 0;
}



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

int main() {
  int a, b, h, m;
  double theta, pi, d;
  cin >> a >> b >> h >> m;
  pi = 3.14159265358979;
  theta = (2 * pi * (60*h+m) / 720) - (2 * pi * m / 60);
  if (theta < 0) {
    theta *= -1;
  }
  d = pow(a,2) + pow(b,2) - 2*a*b*cos(theta);
  cout << fixed << setprecision(15) << sqrt(d) << endl;
}


Measured memory_bytes: 4192
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n,d;
	int x;
	int sum;
	cin>>n>>d;
	x=2*d+1;
	sum=n/x;
	if(n%x!=0)	sum++;
	cout<<sum<<endl;
	return 0;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
	string s;
	cin>>s;

	ll n=s.size();
	ll ans=0;
	REP(i,n){
		rep(j,1,n){
			if(i+j*2>n) break;
			if(j*2!=n && s.substr(i,j)==s.substr(i+j,j)) chmax(ans,(ll)2*j);
		}
	}
	cout<<ans<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int p[10];
    for(int i=0;i<n;i++)cin>>p[i];
    sort(p,p+n);
    p[n-1]/=2;
    int ans=0;
    for(int i=0;i<n;i++)ans+=p[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll odd,even;
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(x%2==0){
			even++;
		}
	}
	ll ans1=1,ans2=1;
	for(int i=0;i<n;i++){
		ans1*=3;
	}
	for(int i=0;i<even;i++){
		ans2*=2;
	}
	cout << ans1-ans2;
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++) {
            int a;
            cin >> a;
            a--;
            c[a]++;
        }
    }
    for(int i = 0; i < m; i++) {
        if(c[i] == n) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    k = int(input())
    d = len(s)
    m = set()
    if k >= d:
        for i in range(d):
            for j in range(1, d - i + 1):
                m.add(s[i:i + j])
    else:
        for i in range(d):
            for j in range(1, k + 1):
                m.add(s[i:i + j])

    m = list(m)
    m.sort()
    print(m[k - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 4464
#include <stdio.h>

int main(void) {
	int n,x,i;
	scanf("%d%d",&n,&x);
	int l[n];
	int t=0,c=1;
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
		t=t+l[i];
		if(t<=x){c++;}
	}
	printf("%d",c);
	// your code goes here
	
	return 0;
}


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

struct Dinic{
    struct edge {
        int64_t to, cap, rev;
        edge(int64_t to, int64_t cap, int64_t rev):to(to), cap(cap), rev(rev){}
    };

    int N, S, T;
    int64_t flow = 0;
    const int64_t INF = 1e18;
    vector<int> level, iter;
    vector<vector<edge>> G;

    Dinic(int N, int S, int T):N(N), S(S), T(T){
        flow = 0;
        level.resize(N);
        iter.resize(N);
        G.resize(N);
    }

    void add_edge(int from, int to, int64_t cap){
        G[from].emplace_back(to, cap, G[to].size());
        G[to].emplace_back(from, 0, G[from].size()-1);
    }

    void bfs(int s){
        fill(level.begin(), level.end(), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while(que.size()){
            int v = que.front(); que.pop();
            for(auto& e : G[v]){
                if(e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int64_t dfs(int v, int t, int64_t f){
        if(v == t) return f;
        for(int& i=iter[v]; i<G[v].size(); i++){
            auto& e = G[v][i];
            if(e.cap > 0 && level[v] < level[e.to]){
                int64_t d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int64_t max_flow(){
        while(true){
            bfs(S);
            if(level[T] < 0) return flow;
            fill(iter.begin(), iter.end(), 0);
            while(true){
                int64_t f = dfs(S, T, INF);
                if(f == 0) break;
                flow += f;
            }
        }
    }
};

int code(int i, int j){
    return i*50+j;
}

int main(){
    int H, W, C;
    int64_t B[50][50];
    cin >> H >> W >> C;
    for(int i=0; i<H; i++) for(int j=0; j<W; j++) cin >> B[i][j];

    int S = 2500, T = 2501;
    Dinic solver(T+1, S, T);

    int64_t ans = 0;
    for(int i=0; i<H-1; i++) for(int j=i%2; j<W-1; j+=2){
        int c = code(i, j);
        int64_t gain = B[i][j] + B[i][j+1] + B[i+1][j] + B[i+1][j+1] - C;
        if(gain <= 0) continue;
        ans += gain;
        if(i%2){
            solver.add_edge(c, T, gain);
        }else{
            solver.add_edge(S, c, gain);
        }
        if(i>0 && j>0){
            int c2 = code(i-1, j-1);
            if(i%2){
                solver.add_edge(c2, c, B[i][j]);
            }else{
                solver.add_edge(c, c2, B[i][j]);
            }
        }
        if(i>0 && j+1<W-1){
            int c2 = code(i-1, j+1);
            if(i%2){
                solver.add_edge(c2, c, B[i][j+1]);
            }else{
                solver.add_edge(c, c2, B[i][j+1]);
            }
        }
    }
    ans -= solver.max_flow();
    cout << ans << endl;
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  ll ans = LINF;
  for(int i=-100;i<=100;++i) {
    ll su = 0;
    for(int j=0;j<n;++j) {
      su += (i - a[j]) * (i - a[j]);
    }
    ans = min(ans, su);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int r,g,b;
    cin >> r >> g >> b;
    bool ans = (10*g+b)%4 == 0;

    cout << (ans? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

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


def dfs(s, graph, bridge, visit):
    visit[s] = True
    for next in graph[s]:
        if not bridge[s][next]: continue
        if visit[next]: continue
        dfs(next, graph, bridge, visit)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    graph = {n: [] for n in range(N)}

    for _ in range(M):
        a, b = il()
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)

    ret = 0
    bridge = {n: [True] * N for n in range(N)}
    searched = {n: [False] * N for n in range(N)}
    for i in range(N):
        for j in graph[i]:
            if searched[i][j]: continue
            searched[i][j],searched[j][i] = True, True
            visit = [False] * N
            bridge[i][j],bridge[j][i] = False, False
            dfs(0, graph, bridge, visit)
            if not all(visit): ret += 1
            bridge[i][j], bridge[j][i] = True, True
    print(ret)


if __name__ == '__main__':
    main()


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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i += 2) {
    if (s.at(i) == 'L') {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 1; i < s.size(); i += 2) {
    if (s.at(i) == 'R') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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


  

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
  int T; cin >> T;  
  while (T--) {
    vector<int> A;
    {
      int a; 
      while (cin >> a and a) A.push_back(a);
    }
    int n = count_if(A.begin(), A.end(), [](int a) { return a > 0; });
    vector<vector<int>> g(n);
    vector<int> deg;
    vector<int> stk;
    int cur = 0;
    for (int a : A) {
      if (a > 0) {
        if (stk.size()) {
          --deg.back();
          --a;
          g[stk.back()].push_back(cur);
          g[cur].push_back(stk.back());
        } 
        stk.push_back(cur++);
        deg.push_back(a);
      } else {
        int u = stk[stk.size() - 1 + a];
        g[stk.back()].push_back(u);
        g[u].push_back(stk.back());
        --deg.back();
        --deg[stk.size() - 1 + a];
      }
      while (deg.size() and deg.back() == 0) deg.pop_back(), stk.pop_back();
    }
    for (int i = 0; i < n; ++i) {
      cout << i + 1;
      sort(g[i].begin(), g[i].end());
      for (int u : g[i]) cout << ' ' << u + 1;
      cout << '\n';
    }
  }
}



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

const int N = 1 << 20;
const int mo = 1e9 + 7;

int d, ans;
int p[N + 5], sum[N + 5];

#define mp make_pair

typedef pair<int, int> pii;

void modify(int u, int v, int t) {
    while (u > 0) {
        v = 1ll * v * u % mo;
        sum[u] = (sum[u] + v * t) % mo;
        u = u >> 1;
    }
}

int query(int u, int v) {
    int res = 0;
    for (int u0 = 0; u > 0; u >>= 1) {
        if (u0) {
            res = (res + 1ll * v * (sum[u] - 1ll * sum[u0] * u % mo)) % mo;
        }
        u0 = u;
        v = 1ll * v * u % mo;
    }
    return res;
}

vector<pii> dfs(int u, int dep) {
    if (dep == d) {
        return vector<pii> (1, mp(u, p[u]));
    }
    
    vector<pii> res;
    vector<pii> L = dfs(u << 1, dep + 1), R = dfs(u << 1 | 1, dep + 1);
    for (auto x : L) {
        modify(x.second, 1ll * x.first * u % mo, +1);
        res.push_back(mp(1ll * x.first * u % mo, x.second));
    }

    for (auto x : R) {
        ans = (ans + query(x.second, x.first)) % mo;
        res.push_back(mp(1ll * x.first * u % mo, x.second));
    }

    for (auto x : L) {
        modify(x.second, 1ll * x.first * u % mo, -1);
    }
    return res;
}

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
#endif

    scanf("%d", &d);
    for (int i = 1 << (d-1); i < (1 << d); ++i) {
        scanf("%d", p + i);
        p[i] += (1 << (d-1)) - 1;
    }

    dfs(1, 1);
    printf("%d\n", (ans + mo) % mo);

    return 0;
}


Measured memory_bytes: 7032
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
a = na()

ans = 0
has = []
for i in range(45):
    s = 0
    for v in a:
        s += v>>i&1
    has.append(s)

und = []
for i in range(45):
    und.append(max(n-has[i], has[i])<<i)

for i in range(44):
    und[i+1] += und[i]

k += 1
top = 0
ans = 0
for i in range(44,-1,-1):
    if k>>i&1:
        # print(i, top, has[i]<<i, und[i-1])
        ans = max(ans, top + (has[i]<<i) + (und[i-1] if i-1 >= 0 else 0))
    top += n-has[i]<<i if k>>i&1 else has[i]<<i

print(ans)



Measured memory_bytes: 14692
/*
 * C言語のサンプルプログラム - Webkaru
 * - フィボナッチ数の計算 -
 */
#include <stdio.h>
 
int main(void)
{
  /* 変数の宣言 */
  int n;
  int f0, f1, f2;
  int count=0;
  f0 = 0;
  f1 = 1;
  scanf("%d",&n);
 
  /* フィボナッチ数の計算 */
  while(n<=44) {
    count++;
    // フィボナッチ数の計算
    f2 = f1 + f0;
    if(n==count){
      printf("%d\n",f2);
      break;
    }
    
    //printf("f2=%d f1=%d f0=%d\n",f2,f1,f0);
    // 変数の代入
    f0 = f1;
    f1 = f2;
  }
 
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int main()
{
  //flash;
  string cal;
  cin>>cal;
  ll ans=0;
  for (ll i = 0; i < cal.size(); ++i)
  {
  	if(cal[i]==cal[i+1] && (i+1)<=cal.size()-1)
  		{
  			if((i+1)<(cal.size()-1))
  			ans+=2;
  		    else ans++;
  			i+=2;
  		}
  	else ans++;
  	//debugs(ans,i);
  }
  cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map

Measured memory_bytes: 640
#include"bits/stdc++.h"
using namespace std;
int func(int d,int value)
{
	int sum=0;
	for(;;sum++)
	{
		if(sum*value+1>d)
			break;
	}
	return sum;
}
int main()
{
	int n,d,x;
	int a;
	int sum=0;
	int i,j;
	scanf("%d",&n);
	scanf("%d %d",&d,&x);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		sum+=func(d,a);
	}
	printf("%d",sum+x);
}

Measured memory_bytes: 256