akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = ~(1 << 31);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;

    int c = a * b;
    if(c % 2 == 0) {
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }


    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void)
{
  int tate[30];
  int num;
  int yoko;
  int i;

  for(i=0;i<30;i++)
    tate[i]=i+1;

  scanf("%d %d",&num,&yoko);

  for(i=0;i<yoko;i++){
    int a,b;
    int tmp;
    scanf("%d,%d",&a,&b);
    tmp=tate[a-1];
    tate[a-1]=tate[b-1];
    tate[b-1]=tmp;
  }
  for(i=0;i<num;i++)
    printf("%d\n",tate[i]);


  return 0;
}

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

typedef long long ll;

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

    int N;
    cin >> N;

    vector<pair<int, pair<int,int> > > a(N);

    for(int i = 0; i < N; i++) {
        int x, y, h;
        cin >> x >> y >> h;
        a[i] = make_pair(h, make_pair(x, y));
    }

    sort(a.begin(), a.end(), greater<pair<int, pair<int, int> > >());

    int ax, ay, ah;

    for(int i = 0; i <= 100; i++) {
        for(int j = 0; j <= 100; j++) {
            int h = a[0].first;
            int x = a[0].second.first;
            int y = a[0].second.second;

            int ch = h + abs(x - j) + abs(y - i);

            bool checker = false;
            for(int k = 1; k < N; k++) {
                h = a[k].first;
                x = a[k].second.first;
                y = a[k].second.second;
                if(h != max(ch - abs(x - j) - abs(y - i), 0)) {
                    //if(i == 2 && j == 2) cerr << i << " " << j << " " << ch << endl;
                    checker = true;
                    break;
                }
            }
            if(checker) continue;

            ax = j;
            ay = i;
            ah = ch;
        }
    }

    cout << ax << " " << ay << " " << ah << endl;
}

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

void cycle(vector<int> &v) {
    vector<int> ret;
    for (int i=1; i<(int)v.size(); ++i) {
        ret.push_back(v[i]);
    }
    ret.push_back(v[0]);
    v = ret;
}

int main() {
    vector<int> gowland = {1,4,1,4,1,2,1,2};
    vector<int> p(8);
    while (cin >> p[0]) {
        for (int i=1; i<8; ++i) {
            cin >> p[i];
        }
        vector<int> ans;
        int mn = INT_MAX;
        for (int k=0; k<8; ++k) {
            int cnt = 0;
            for (int i=0; i<8; ++i) {
                cnt += max(0, p[i] - gowland[i]);
            }
            if (cnt < mn || (cnt == mn && gowland < ans)) {
                ans = gowland;
                mn = cnt;
            }
            cycle(gowland);
        }
        for (int i=0; i<(int)ans.size(); ++i) {
            cout << (i == 0 ? "" : " ") << ans[i];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int main(void){
    int s, cnt;
    cnt = 0;
    scanf("%d", &s);
    cnt = cnt + (s % 10);
    s = s / 10;
    cnt = cnt + (s % 10);
    s = s / 10;
    cnt = cnt + (s % 10); 
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

// DEBUG TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
  *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}

int val ( int x ){
  int ret = 0;
  while ( x != 0) {
    ret++;
    x%=__builtin_popcount(x);
  }
  return ret;
} 

void solve()
{ 
 int n;
 string inp;
 cin>>n>>inp;
 int bits_set = 0;
 for (auto x:inp) {
   if (x == '1') bits_set++;
 }
 int lb = bits_set - 1;
 lb = max(lb,1ll);
 int rb = bits_set + 1;
 int lsum = 0;
 int rsum = 0;
 int lcur = 1;
 int rcur = 1;
 for (int i=n-1;i>-1;i--){
   if (inp[i] == '1'){
     lsum+=lcur;
     rsum+=rcur;
   }
   lcur = (lcur*2)%lb;
   rcur = (rcur*2)%rb;
   lsum%=lb;
   rsum%=rb;
 }
 debug() << imie(lsum) imie(rsum);
 vector<int> out(n);
 lcur = 1;
 rcur = 1;
 for (int i=n-1;i>-1;i--){
   int cur = 0;
   if (inp[i] == '1') {
     cur = ((lsum - lcur)%lb + lb) % lb; 
   } else {
     cur = ((rsum + rcur)%rb + rb) % rb;
   }
   debug() << imie(cur);
   out[i] = val(cur) + !(inp[i] == '1' && bits_set == 1);
   lcur = (lcur*2)%lb;
   rcur = (rcur*2)%rb;
 }
 for (auto x:out) cout<<x<<endl;
}


/*

*/
signed main(){
  int t = 1;
  // cin>>t;
  while (t--)
  solve();
}
// Check MOD values plox :(


Measured memory_bytes: 5216
//Go to Jail 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;cin>>n;
    int c=0;
    bool flag=false;
    rep(i,0,n){
        int a,b;cin>>a>>b;
        if(a==b)c++;
        else c=0;
        if(c==3)flag=true;
    }
    if(flag)cout<<"Yes"<<nnn;
    else cout<<"No"<<nnn;
    return 0;
}

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

int main() {
  int n;
  scanf("%d",&n);
  int c[510],s[510],f[510];
  for (int i=0; i<n; i++) {
    scanf("%d %d %d",&c[i],&s[i],&f[i]);
  }

  int t;
  for (int i=0; i<n; i++) {
    t=0;
    for (int j=i; j<n-1; j++) {
      t = max(t,s[j]);
      t = ((t+f[j]-1)/f[j])*f[j];
      t += c[j];
    }
    printf("%d\n",t);
  }

  return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N,M;
    cin >> N >> M;

    vector<i64> s(N+1);
    rep(i,0,M){
        i64 L,R;
        cin >> L >> R;
        --L;
        --R;
        ++s[L];
        --s[R+1];
    }

    i64 ans=0;
    rep(i,1,N+1){
        s[i]+=s[i-1];
    }

    rep(i,0,N){
        if(s[i]==M) ++ans;
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

#define INF 1000000000000000000

typedef long long LL;

struct v{
  int ax;
  int bx;
  int d;
};

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> c(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cin >> c[h-i-1][j];
  }
  vector<char> a(h),b(h);
  vector<vector<int>> samea(h+1,vector<int>(h,0));
  vector<vector<int>> sameb(h+1,vector<int>(h,0));
  auto com=[](struct v l,struct v r){return l.d>r.d;};
  priority_queue<struct v,vector<struct v>,decltype(com)> dijk(com);
  struct v now;
  vector<vector<LL>> dist(h+1,vector<LL>(h+1));
  LL ans=0;
  for(int i=1;i<w;i++){
    for(int j=0;j<h;j++){
      a[j]=c[j][i-1];
      b[j]=c[j][i];
    }
    samea[0][h-1]=(a[h-1]==b[h-1]?1:0);
    for(int k=h-2;k>=0;k--){
      samea[0][k]=samea[0][k+1]+(a[k]==b[k]?1:0);
    }
    for(int j=1;j<=h;j++){
      for(int k=h-j-1;k>=0;k--){
        samea[j][k]=samea[j][k+1]+(a[k]==b[k+j]?1:0);
      }
      for(int k=h-j-1;k>=0;k--){
        sameb[j][k]=sameb[j][k+1]+(a[k+j]==b[k]?1:0);
      }
    }
    for(int j=0;j<=h;j++){
      for(int k=0;k<=h;k++){
        dist[j][k]=INF;
      }
    }
    dijk.push({h,h,0});
    while(!dijk.empty()){
      now=dijk.top();
      dijk.pop();
      // cout << now.ax << " " << now.bx << " " << now.d << endl;
      if(dist[now.ax][now.bx]==INF){
        if(now.ax==0&&now.bx==0){
          ans+=now.d;
          // cout << now.d << endl;
          while(!dijk.empty()) dijk.pop();
          break;
        }
        dist[now.ax][now.bx]=now.d;
        if(now.ax>0){
          dijk.push({now.ax-1,now.bx,now.d+(now.ax>=now.bx?samea[now.ax-now.bx][h-now.ax]:sameb[now.bx-now.ax][h-now.bx])});
        }
        if(now.bx>0){
          dijk.push({now.ax,now.bx-1,now.d+(now.ax>=now.bx?samea[now.ax-now.bx][h-now.ax]:sameb[now.bx-now.ax][h-now.bx])});
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

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

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n + 1);
	bool flag = true;
	ll ans = 0;
	ll res = 1;
	ll total = 0;
	rep(i, n + 1) {
		cin >> a[i];
		total += a[i];
	}
	rep(i, n + 1) {
		if (res < a[i]) {
			cout << -1 << endl;
			return 0;
		}
		ans += res;
		res -= a[i];
		total -= a[i];
		res = min(res * 2, total);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4048
#include<cstdio>
#include<vector>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,m,s;
    vector<int> V;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d",&m);
        V.push_back(m);
        sort(V.begin(),V.end());
        if(V.size()>4)V.pop_back();
    }
    vector<int> S;
    int x = V.size();
    for(int i = 0;i < x;i++){
        for(int j = 0;j < x;j++){
            if(i == j)continue;
            S.push_back(V[i]*pow(10,(int)log10(V[j])+1) + V[j]);
            //cout<<S[S.size()-1]<<endl;
        }
    }
    sort(S.begin(),S.end());
    printf("%d\n",S[2]);
    return 0;
}

Measured memory_bytes: 1272
#include <stdio.h>
int main (){
 int a,b;
 scanf("%d %d",&a,&b);
 if(a < b){
  printf("a < b\n");
 } else if(a == b){
  printf("a == b\n");
 } else {
  printf("a > b\n");
 }
return 0;
}


Measured memory_bytes: 2044
n, m = gets.chomp.split(' ').map(&:to_i)
as = m.times.map { gets.chomp.to_i }

@ngs = {}
as.each { |pos| @ngs[pos] = 'x' }

@cnts = {}
@cnts[0] = 1

(1..n).each do |pos|
    unless @ngs[pos].nil?
        @cnts[pos] = 0
        next
    end

    if pos == 1
        @cnts[pos] = 1
        next
    end

    @cnts[pos] = @cnts[pos - 1] + @cnts[pos - 2]
end

puts @cnts[n] % (10**9 + 7)


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
  string s;
  cin >> s;

  int n = s.size();
  char last = s.at(0);
  int ans=0;
  rep(i,n){
    if(s.at(i)!=last){ans++; last=s.at(i);}
  }

  cout << ans;
}

Measured memory_bytes: 3720
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <algorithm>  // std::unique
#include <cmath>
#include <limits.h>
#include <queue>
#include <unordered_map>

#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

using ll = long long;
constexpr auto PrimeBigNum10_9_7 = 1000000007;


// 素数判定
template <typename T>
bool IsPrimeNumber(T value) {

	for (int i = 2; i * i <= value; ++i) {
		if ((value % i) == 0) {
			return true;
		}
	}
	return false;
}

// 桁数判定
template <typename T>
T GetFigureLength(T value) {
	T figure = 1;
	while (value >= 10) {
		value /= 10;
		++figure;
	}
	return figure;
}

// 素因数分解結果
template <typename T>
map<T, T> GetPrimeFactorize(T value) {

	map<T, T> res;

	for (T i = 2; i * i <= value; ++i) {
		if ((value%i) != 0)	continue;

		T count = 0;
		while ((value % i) == 0) {
			value /= i;
			++count;
		}

		res[i] = count;
	}

	if (value != 1) {
		res[value] = 1;
	}
	return res;
}

void DebugPrint(const vector<ll>& vec) {
	cout << "{";
	for (auto itr = vec.begin(); itr != vec.end(); ++itr) {
		cout << *itr << ",";
	}
	cout << "}" << endl;
}

// valueが2のx乗以下である計算
ll calc2x(ll value) {
	ll n = 0;
	while (value > 0) {
		value /= 2;
		++n;
	}
	return n;
}

struct Vec2 {
	double x;
	double y;

	void rotate(double rad) {
		double s = sin(rad);
		double c = cos(rad);
		double tmpX = this->x*c - this->y*s;
		double tmpY = this->x*s + this->y*c;
		this->x = tmpX;
		this->y = tmpY;
	}
};

ll funcAns(ll a) {


	auto overValue = 1000000000000000000;
	std::vector<ll> vec;
	for (ll i = 0; i < a; ++i) {
		ll n;
		cin >> n;
		vec.push_back(n);
		if (n == 0)	return 0;
	}
	ll ans = 1;

	for( auto n : vec){
		if (n > overValue)	return -1;
		if ((overValue / ans) < n)	return -1;
		ans *= n;
	}
	return ans;
}


int main(void) {

	ll a;

	cin >> a;


	cout << funcAns(a) << endl;



	return 0;
}


Measured memory_bytes: 4256
#include<iostream>
using namespace std;
int main(){
long N,K;
cin>>N>>K;
long sum=0;
long summ=0;
if(K%2==0){
    for(int i=1;i<=N;i++){
        if(i%K==0){
            sum++;
        }else if(i%K==K/2){
            summ++;
        }

    }

}else{
    for(int i=1;i<=N;i++){
        if(i%K==0){
            sum++;
        }

    }
    
}
cout<<sum*sum*sum+summ*summ*summ<<endl;
}

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

const int64_t inf = 1000000000000000037;

int64_t a, b, c, d;
map < int64_t, int64_t > dp;

int64_t f (int64_t n) {
    if (dp.find(n) != dp.end()) 
        return dp[n];
    else {
        int64_t res = inf;
        if (n <= inf / d)
            res = n * d;
        res = min(res, a + min((n % 2) * d + f(n / 2), (((n + 1) / 2) * 2 - n) * d + f((n + 1) / 2)));
        res = min(res, b + min((n % 3) * d + f(n / 3), (((n + 2) / 3) * 3 - n) * d + f((n + 2) / 3)));
        res = min(res, c + min((n % 5) * d + f(n / 5), (((n + 4) / 5) * 5 - n) * d + f((n + 4) / 5)));
        return dp[n] = res;
    }
}

signed main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    while (t--) {
        int64_t n;
        cin >> n >> a >> b >> c >> d;
        dp.clear();
        dp[0] = 0;
        dp[1] = d;
        cout << f(n) << '\n';
    }
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int x;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>x;
    cout<<!x;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

int N;
vector<ll> a(10001, 0);
 
int main(void){
    
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> a[i];
    
    int ans = 0;
    for(int i = 0; i < N; ++i){
        while(a[i] % 2 == 0){
            a[i] /= 2;
            ++ans;
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	n, a, b := nextInt(), nextInt(), nextInt()

	res := n/(a+b)*a + min(n%(a+b), a)

	fmt.Println(res)
}


Measured memory_bytes: 640
class Q
	def initialize
		@h = [] # max-heap
	end

	def enq(v)
		@h.push(v)
		up_heap
	end

	def deq
		max, last = @h[0], @h.pop
		unless @h.empty?
			@h[0] = last
			dn_heap
		end
		return max
	end

	def all(&block)
		return @h.each(&block)
	end

private
	def up_heap
		i, up = @h.size-1, @h[-1]
		while 0 <= (iP = (i-1)/2)
			break unless @h[iP] < up
			@h[i], i = @h[iP], iP
		end
		@h[i] = up
	end

	def dn_heap
		i, dn, size = 0, @h[0], @h.size
		while (iC = 2*i+1) < size
			iC += 1 if iC+1 < size and @h[iC] < @h[iC+1]
			break unless dn < @h[iC]
			@h[i], i = @h[iC], iC
		end
		@h[i] = dn
	end
end

N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

q = Q.new
A.each{|a|
	q.enq a
}
M.times{
	q.enq(q.deq/2)
}
p q.all.inject(:+)


Measured memory_bytes: 10252
#include <stdio.h>

#define N 201
#define TIMES 4

void init(int table[][TIMES], int height, int width);

void display(int table[][TIMES], int height, int width);

int check(int table[][TIMES], int player, int col, int row);

int main(void)
{
	
	int n;
	int i, k;
	int table[N][TIMES];
	int score[N] = {0};
	
	scanf("%d", &n);
	
	init(table, n, TIMES);
	
	for(i=1; i<=n; i++){
		
		for(k=1; k<TIMES; k++){
			
			scanf("%d", &table[i][k]);
			
		}
		
	}
	
	for(i=1; i<TIMES; i++){
		
		for(k=1; k<=n; k++){
			
			if(check(table, k, i, n) == 1){
				
				score[k] += table[k][i];
				//printf("%d番目のプレイヤーに+%d点\n", k, table[k][i]);
				
			}
			
		}
		
	}
	
	//display(table, n, TIMES);
	
	for(i=1; i<=n; i++){
		
		printf("%d\n", score[i]);
		
	}
	
	return 0;
}



void init(int table[][TIMES], int height, int width){
	
	int i, k;
	
	for(i=1; i<=height; i++){
		
		for(k=1; k<width; k++){
			
			table[i][k] = 0;
			
		}
		
	}
	
	return;
	
}



void display(int table[][TIMES], int height, int width){
	
	int i, k;
	
	for(i=1; i<=height; i++){
		
		for(k=1; k<width; k++){
			
			printf("%d ", table[i][k]);
			
		}
		
		printf("\n");
		
	}
	
}



int check(int table[][TIMES], int player, int col, int row){
	
	int i;
	int ret = 1;
	
	for(i=1; i<=row; i++){
		
		if(i == player){
			
			continue;
			
		}
		
		if(table[i][col] == table[player][col]){
			
			ret = 0;
			break;
			
		}
		
	}
	
	return ret;
	
}

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

using namespace std;
typedef long long ll;

bool isPerfectSquare(long double x){    
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 

int main(){
    long double  n;
    cin>>n;
    for(int  i = n; i >= 1; i--){
        long double ans = i;
        if(isPerfectSquare(ans)== true){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long int
#define push_back pb

using namespace std; 
 
int main() 
{
    int n;

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

    ll sum[n+5];
    sum[0] = a[0];
    for(int i=1;i<n;i++) {
        sum[i] = sum[i-1]+a[i];
    }
    // for(int i=0;i<n;i++) cout<<sum[i]<<" ";cout<<endl;

    ll ans = 8020202020200000;
    for(int i=0;i<n-1;i++) {
        ll selisih = sum[n-1] - sum[i];
        selisih = abs(sum[i]-selisih);
        // cout<<selisih<<" ";
        if(selisih < ans) ans = selisih;
    }

    cout<<ans<<endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)


#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(arg),key)-begin(arg)

using namespace std;

template<class T>void reg(vector<T> &ary,const T &elem){ary.emplace_back(elem);}

using R=long double; // __float128
const R EPS = 1E-11; // [-1000:1000]->EPS=1e-8 [-10000:10000]->EPS=1e-7
const R INF = 1E40;
constexpr R PI = acos(R(-1));
inline int sgn(const R& r){ return (r > EPS) - (r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

using P=complex<R>;
using VP=vector<P>;
using L=struct{P s,t;};
using VL=vector<L>;

constexpr P O = P(0,0);
istream& operator >> (istream& is,P& p){ R x,y;is >> x >> y; p=P(x,y); return is;}


//?????? dot ?????? det
inline R dot(P o,P a,P b){a-=o,b-=o; return real(conj(a)*b);}
inline R det(P o,P a,P b){a-=o,b-=o; return imag(conj(a)*b);}

// CCW verify AOJ CGL_1_C
enum CCW{ LEFT = 1,RIGHT = 2,BACK = 4,FRONT = 8,ON = 16};
inline int ccw(P o,P a, P b) {//???a??¨???b???????????????????????????
	if (sgn(det(o,a,b)) > 0) return LEFT;    // counter clockwise
	if (sgn(det(o,a,b)) < 0) return RIGHT;   // clockwise
	if (sgn(dot(o,a,b)) < 0) return BACK;    // b--base--a on line
	if (sgn(norm(a-o)-norm(b-o)) < 0) return FRONT;   // base--a--b on line
	return ON;// base--b--a on line  a??¨b????????????????????????
}


// ?????? verify AOJ CGL_2_C
P cross(L a,L b){
	R s1=det(a.s,b.s,b.t);
	R s2=s1+det(a.t,b.t,b.s);
	return a.s+s1/s2*(a.t-a.s);
}
	

// ????§???¢
// ??¢??? Verify AOJ 1100 CGL_3_A
R area(const VP& pol){
	int n=pol.size();
	R sum=0;
	rep(i,n) sum+=det(O,pol[i],pol[(i+1)%n]);
	return abs(sum/2.0);
}

VP convex_cut(const VP& pol,const L& l) {
	VP res;
	int n=pol.size();
	rep(i,n){
		P a = pol[i],b=pol[(i+1)%n];
		if(ccw(l.s,l.t,a)!=RIGHT) reg(res,a);
		if((ccw(l.s,l.t,a)|ccw(l.s,l.t,b))==(LEFT|RIGHT)) reg(res,cross({a,b},l));
	}
	return res;
}

L bisector(P a, P b){P mid=(a+b)/P(2,0);return L{mid, mid+(b-a)*P(0,1)};}
VP voronoi_cell(VP pol,VP v,int s){rep(i,v.size())if(i!=s)pol=convex_cut(pol,bisector(v[s],v[i]));return pol;}

int main(void){
	P x,y,z;
	int T=1;
	while(cin >> x >> y >> z){
		if(x==O&&y==O&&z==O) break;
		const R all=1E8;
		VP point={x,y,z},pol={P(0,0),P(10000,0),P(10000,10000),P(0,10000)};
		cout.precision(20);
		cout << T++ << " " << fixed << area(voronoi_cell(pol,point,0))/all << endl;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string color;
  string result = "Three";
  for(int i = 0; i < N; i++){
    cin >> color;
    if(color == "Y"){
      result = "Four";
      break;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	//assets vs liabilities
	//keeping cash = risk of losing money to inflation
	//financial freedom
	int n; cin>>n;
	int answer = 0;
	int tmp = -1;
	for(int mask = 1; mask <= n; mask++){
		if(__builtin_ctz(mask) >  tmp){
			answer = mask;
			tmp = __builtin_ctz(mask);
		}
	}	
	cout<<answer<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char a[27];
int main()
{
	ll n,yu,i=0,j;
	scanf("%lld",&n);
	do{
		yu=n%26;
		if(yu==0){
			yu=26;
		}
		n/=26;
		a[i]='a'+yu-1;
		i++;
		if(yu==26){
			n--;
		}
	}while(n>=1);
	for(j=i-1;j>=0;j--){
		printf("%c",a[j]);
	}
	printf("\n");
	return 0;
}


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

typedef pair<int,int> P;

int main(){
  int k;
  cin >> k;
  queue<long long int> q;
  if(k<=12){
    cout << k << endl;
    return 0;
  }
  for(int i=1; i<10; i++){
    q.push(i);
  }
  for(int i=1; i<k; i++){
    long long int a = q.front();
    q.pop();
    if(a%10!=0) q.push(a*10+a%10-1);
    q.push(a*10+a%10);
    if(a%10!=9) q.push(a*10+a%10+1);
  }
  cout << q.front() << endl;
  return 0;
}


Measured memory_bytes: 1792
import itertools

N, M, Q = map(int, input().split())
ABCD = []
ans = 0

for _ in range(Q):
    ai, bi, ci, di = map(int, input().split())
    ABCD.append((ai, bi, ci, di))

A = itertools.combinations_with_replacement(range(1, M+1), N)

for a in A:
    tmp = 0
    for abcd in ABCD:
        if a[abcd[1]-1] - a[abcd[0]-1] == abcd[2]:
            tmp += abcd[3]
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 9212
#include "bits/stdc++.h"
 
typedef long long ll;
// #define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
// #define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int n,k,l;

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

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

signed main(){

    cin >> n >> k >> l;
    int p[200010];
    int q[200010];
    int r[200010];
    int s[200010];
    rep(i,k) cin >> p[i] >> q[i];
    rep(i,l) cin >> r[i] >> s[i];

    int oya[200010][2];
    init(n+1);
    rep(i,k) unite(p[i],q[i]);
    for(int i = 1; i<=n;i++) oya[i][0] = find(i);

    init(n+1);
    rep(i,l) unite(r[i],s[i]);
    for(int i = 1; i<=n;i++) oya[i][1] = find(i);

    map<pair<int,int>,int> mp;

    for(int i = 1; i<=n;i++){
        mp[MP(oya[i][0],oya[i][1])]++;
    }

    for(int i = 1; i<=n;i++) cout << mp[MP(oya[i][0],oya[i][1])] << " " ;
    cout << endl;
    // rep(i,n) cerr << oya[i+1][0] << " " << oya[i+1][1] << endl;

    

    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 17792
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls signed
#define give main()
const int mod = 1000000007;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

#pragma endregion

const int N = 55;
int n, ans;

pls give {
    AC;
    cin >> n;
    for (int i=1; i<=n; i++) {
        if (i%3 and i%5) ans += i;
    }
    cout << ans << nl;
}


Measured memory_bytes: 3608
N = int(input())
S = {}

for i in range(N):
    arg = input()
    if (arg in S):
        S[arg] = S[arg] + 1
    else:
        S[arg] = 1
valSorted = sorted(S.items(), key=lambda x:(-x[1], x[0]))
breakKey = -1
for key, value in valSorted:
    if breakKey == -1:
        breakKey = value
    if breakKey != value:
        break
    print(str(key))

Measured memory_bytes: 59228
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    a = collections.Counter(a).most_common()[:k]
    cnt = 0
    for k, v in a:
        cnt += v
    print(n - cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 96716
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	int n;
	int a[3111];
	cin>>n;
	REP(i,n)
		cin>>a[i];
	sort(a,a+n);
	ll ans=0; 
	REP(i,n)
		for(int j=i+1;j<n;j++)
		{
			int l=j+1;
			int r=n-1;
			while(l<=r)
			{
				int mid=(l+r)/2;
				if(a[i]+a[j]>a[mid])l=mid+1;
				else r=mid-1;
			}
			ans+=l-j-1;
		 } 
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>


using namespace std;

//int tri_sum(double x1, double y1, double x2, double y2, double x3, double y3 ){
//    double tri1 = fabs(y1-y2)*fabs(x1-x3)/2;
//    double tri2 = fabs(y1-y2)*fabs(x2-x3)/2;
//    
//    double tri3 = fabs(x1-x2)*fabs(y1-y3)/2;
//    double tri4 = fabs(x1-x2)*fabs(y2-y3)/2;
//    
//    double squ = fabs(x1-x2)*fabs(y1-y2);
//    
//    if(squ == tri1+tri2+tri3+tri4)return 0;
//    else return 1;
//}

int main(){
    
    double xA, yA, xB, yB, xC, yC, xD, yD;
    while(cin>>xA>>yA>>xB>>yB>>xC>>yC>>xD>>yD){
        if(xA>xD)cout<<"NO"<<endl;
        else if(yA>yD)cout<<"NO"<<endl;
        else if(xB<xC)cout<<"NO"<<endl;
        else if(yB<yC)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

template <class T>
vector<pair<T, T>> prime_factorize(T n) {
    vector<pair<T, T>> res;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0)
            continue;
        ll num = 0;
        while (n % i == 0) {
            num++;
            n /= i;
        }
        res.push_back(make_pair(i, num));
    }
    if (n != 1)
        res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll s = GCD(a, b);
    auto m = prime_factorize(s);
    cout << m.size() + 1 << endl;
}

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

string change(string s,int num){

	for(int i=0;i<s.size();i++){
		if(s[i]+num>'z')s[i]=(s[i]+num-'z'+'a'-1);
		else s[i]=(s[i]+num);
	}
	return s;
}
char change(char c,int num){
	char re;
	if(c+num>'z')re=c+num-'z'+'a'-1;
	else re=c+num;
	return re;
}

int solve(string s){
	string now;
	
	for(int i=0;i<s.size();i++){
		if(s[i]>='a' && s[i]<='z')now+=s[i];
		else {
			for(int j=0;j<=26;j++){
				string tmp=change(now,j);
				if(tmp=="the" || tmp=="this" || tmp=="that"){
					return j;
				}
			}
			now.clear();
		}
	}
}

string ans(string s){
	int n=solve(s);
	string ans;
	for(int i=0;i<s.size();i++){
		if(s[i]>='a' && s[i]<='z')ans+=change(s[i],n);
		else ans+=s[i];
	}
	return ans;
}

int main(){
	string str;
	
	while(getline(cin,str)){
		cout<<ans(str)<<endl;
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b) cout<<"YES"<<endl;
    else  cout<<"NO"<<endl;
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <algorithm>

//typedef pair<int,int> P;

using namespace std;

int main(){
	int N;
	long long a[10000];
	long long b[10000];

	scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%lld", &a[i]);
	for(int i=0;i<N;i++) scanf("%lld", &b[i]);

	long long A = 0;
	long long B = 0;

	for(int i=0;i<N;i++) A += a[i];
	for(int i=0;i<N;i++) B += b[i];

	if(A>B){
		printf("No\n");
	}else{
		long long diff = B - A;
		if(diff==0){
			for(int i=0;i<N;i++){
				if(a[i]!=b[i]){
					printf("No\n");
					return 0;
				}
			}
			printf("Yes\n");
			return 0;
		}
		long long ta = 0;
		long long tb = 0;
		for(int i=0;i<N;i++){
			if(a[i]>b[i]){
				tb += a[i] - b[i];
			}else{
				if((b[i]-a[i])%2==0){
					ta += (b[i]-a[i])/2;
				}else{
					ta += (b[i]-a[i]+1)/2;
					tb++;
				}
			}
		}
		if(tb*2-ta<=diff){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ff first
#define ss second
 
#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif
 
const int inf = 2e18;
const int ninf = -2e18-5;
const int mod = 1e9 + 7;
 
int dp1[5010][5010];
int dp2[5010][5010];
vector<int> arr;
vector<int> pre;
 
int solve(int i, int j, int p){
	// cout<<i<<" "<<j<<" "<<p<<endl;
	if(p){
		if(i==j) {
			dp2[i][j] = arr[i];
			// cout<<"yo "<<dp2[i][j]<<endl;
			return dp2[i][j];
		}
		if(dp1[i+1][j]==ninf) solve(i+1, j, 0);
		if(dp1[i][j-1]==ninf) solve(i, j-1, 0);
		dp2[i][j] = max(arr[i]+pre[j+1]-pre[i+1]-dp1[i+1][j], pre[j]-pre[i]-dp1[i][j-1]+arr[j]);
		
		return dp2[i][j];		
	}
	else{
		if(i==j) {
			dp1[i][j] = arr[i];
			// cout<<"yo "<<dp1[i][j]<<endl;
			return dp1[i][j];
		}
		if(dp2[i+1][j]==ninf) solve(i+1, j, 1);
		if(dp2[i][j-1]==ninf) solve(i, j-1, 1);
		dp1[i][j] = max(arr[i]+pre[j+1]-pre[i+1]-dp2[i+1][j], pre[j]-pre[i]-dp2[i][j-1]+arr[j]);
		
		return dp1[i][j];		
	}
}
signed main(){
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
 
	int n; cin>>n;
	int cur = 0;
	pre.pb(cur);
	for(int i=0; i<n; i++){
		int x; cin>>x;
		cur+=x;
		pre.pb(cur);
		arr.pb(x);
	}
 
	for(int i=0; i<5010; i++){
		for(int j=0; j<5010; j++){
			dp1[i][j] = ninf;
			dp2[i][j] = ninf;
		}
	}
 
	cout<<2*solve(0, n-1, 0)-cur<<endl;

	return 0;
}

Measured memory_bytes: 396108
import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe


type Dice = [([String], [String])]

makeDice :: [String] -> Dice
makeDice ls = map f di
  where
    f (xs, ys) = (map (ls' !!) xs, map (ls' !!) ys)
    ls' = "_" : ls
    di = [([1, 6], [5, 3, 2, 4]),
          ([2, 5], [1, 3, 6, 4]),
          ([3, 4], [1, 5, 6, 2]),
          ([4, 3], [1, 2, 6, 5]),
          ([5, 2], [1, 4, 6, 3]),
          ([6, 1], [2, 3, 5, 4])]

makeRotation :: [a] -> [[a]]
makeRotation xs = take 4 $ map (take 4) $ tails (cycle xs)

check :: Dice -> Dice -> Bool
check ds1 ds2
  | null ys       = True
  | otherwise = all (check' ds1) $ take 2 ys
  where
    ys = [x | x@([a, b], _) <- ds2, a /= b]
    check' ds1 (tb, ds)
      | zs == Nothing = False
      | otherwise = elem ds $ makeRotation $ fromJust zs
      where zs = lookup tb ds1


main :: IO ()
main = do
  ds1 <- makeDice . words <$> getLine
  ds2 <- makeDice . words <$> getLine
  putStrLn $ if check ds1 ds2 then "Yes" else "No"



Measured memory_bytes: 3564
#Cut and Count

#ライブラリ
import copy

#入力
N = int(input())
S = list(input())
ans = []
#計算
for j in range(1,N-1,1):
	counter = 0
	S_hidari = []
	S_migi = []
	S_hidari = set(copy.copy(S[0:j]))
	S_migi = set(copy.copy(S[j:N]))
	for s_hidari in S_hidari:
		for s_migi in S_migi:
			if s_hidari == s_migi:
				counter += 1
	ans.append(counter)

#出力
if N == 2:
	if S[0] == S[1]:
		print("1")
	else:
		print("0")
	exit()
print(max(ans))

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int, string> x,
         pair<int, string> y)
{
    if (x.first < y.first) {
        return true;
    }
    else if (x.first > y.first) {
        return false;
    }
    else {
        if (x.second < y.second) {
            return false;
        }
        else {
            return true;
        }
    }
}
void printArraystring(string str[], int n)
{
    unordered_map<string, int> m;
    for (int i = 0; i < n; i++) {
        m[str[i]]++;
    }
    vector<pair<int, string> > vec;
    for (auto it = m.begin(); it != m.end();
         it++) {
        vec.push_back(
            make_pair(it->second, it->first));
    }
    sort(vec.begin(), vec.end(), cmp);
    cout<<vec.size();
}
int main()
{
    int n,i;
    cin>>n;
    string arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    printArraystring(arr, n);

    return 0;
}


Measured memory_bytes: 35560
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define prique priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  int N, K, Q, A; cin >> N >> K >> Q;
  vector<int> pts(N, 0);
  REP(i, Q){
    cin >> A; A--;
    pts[A]++;
  }
  REP(i, N){
    int minus = Q - pts[i];
    if(minus >= K){
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

char ans_c(int c){
	if (c < 10)
		return '0'+c;
	return 'A' + c - 10;
}

int main() {
	int N, M, Q;
	while (cin >> N >> M >> Q, N){
		string switch_s;
		string bswitch_s;
		string light_s;
		string blight_s;
		vector<vector<bool>> vvb(M,vector<bool>(N,true));
		REP(i, N)
			bswitch_s.append(i,'0');
		REP(i, M)
			blight_s.append(i,'0');

		REP(i, Q){
			cin >> switch_s;
			cin >> light_s;
			//-----------//
			REP(j, N){
				REP(k, M){
					if ((switch_s[j]=='0') != (light_s[k] == blight_s[k])){
						vvb[k][j]=false;
					}
				}
			}
			//-----------//
			bswitch_s= switch_s;
			blight_s = light_s;
		}


		REP(i,M){
			int count = 0;
			int ans = 0;
			REP(j, N){
				if (vvb[i][j]){
					count++;
					ans = j;
				}
			}
			if (count == 1)cout << ans_c(ans);
			else cout << '?';
		}
		cout << endl;
	}
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a).size()
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define endl "\n"

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
//K-th smallest
//cout << k << "rd smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;


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

ll mod=1000000007;

ll power(ll x, ll y) 
{
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2);
	if (y%2 == 0)
		return (temp*temp)%mod;
	else
		return (((x*temp)%mod)*temp)%mod; 
}

double dp[305][305][305];
ll n;

void rec(ll a1,ll b1,ll c1)
{
	if(dp[a1][b1][c1]!=-1)
		return;
	double x1,x2,x3;
	if(a1>0)
	{
		rec(a1-1,b1,c1);
		x1=dp[a1-1][b1][c1]+1;
	}
	else
		x1=0;
	if(b1>0)
	{
		rec(a1+1,b1-1,c1);
		x2=dp[a1+1][b1-1][c1]+1;
	}
	else
		x2=0;
	if(c1>0)
	{
		rec(a1,b1+1,c1-1);
		x3=dp[a1][b1+1][c1-1]+1;
	}
	else
		x3=0;
	double x=a1*x1+b1*x2+c1*x3;
	double xx=a1+b1+c1;
	x+=n;
	x/=xx;
	// if(a1==1)
	// {
	// 	cout<<x<<" "<<xx<<endl;
	// }
	x--;
	dp[a1][b1][c1]=x;
	return;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	vector<ll> a;
	ll i,j,k;
	for(i=0;i<=300;i++)
		for(j=0;j<=300;j++)
			for(k=0;k<=300;k++)
				dp[i][j][k]=-1;
	ll a1=0,b1=0,c1=0;
	for(i=0;i<n;i++)
	{
		ll val;
		cin>>val;
		a.pb(val);
		if(val==1)
			a1++;
		else if(val==2)
			b1++;
		else
			c1++;
	}
	dp[0][0][0]=0;
	rec(a1,b1,c1);
	// cout<<dp[1][0][0]<<endl;
	printf("%.13lf\n", dp[a1][b1][c1]);
	return 0;
}

Measured memory_bytes: 219392
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m,c;
  cin>>n>>m>>c;
  vector<Int> b(m);
  for(Int i=0;i<m;i++) cin>>b[i];

  Int cnt=0;
  for(Int i=0;i<n;i++){
    Int res=c;
    for(Int j=0;j<m;j++){
      Int a;
      cin>>a;
      res+=a*b[j];
    }
    if(res>0) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    for(int i=1; i<=5; i++){
        int x; cin>>x;
        if(x==0){
            cout<<i<<endl;
        }
    }
	return 0;
}


Measured memory_bytes: 3588