akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  int N;
  int sum = 0;
  int highest = 0;
  cin >> N;
  rep(i, N) {
    int p;
    cin >> p;
    highest = max(highest, p);
    sum += p;
  } 

  cout << sum - highest/2 << endl;
   
  return 0;
}


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

A = [[0 for i in range(m)] for j in range(n)]
B = [[0 for i in range(l)] for j in range(m)]
C = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
	A[i] = input().split()
for i in range (m):
	B[i] = input().split()

for i in range(n):
	for j in range(l):
		for k in range(m):
			C[i][j] += int(A[i][k]) * int(B[k][j])
			
[print(*row) for row in C]

Measured memory_bytes: 9564
#include <stdio.h>
#include <algorithm>
using namespace std;
int arr[21][21];
int brr[21];
int main(){
	int N,M,C;
	scanf("%d %d %d",&N,&M,&C);
	for(int i=0;i<M;i++) scanf("%d",brr+i);
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++) scanf("%d",&arr[i][j]);
	}
	int cnt=0;
	for(int i=0;i<N;i++){
		int sum=C;
		for(int j=0;j<M;j++) sum+=arr[i][j]*brr[j];
		if(sum>0) cnt++;
	}
	printf("%d",cnt);
}

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

int main() {
  int N, j;
  cin >> N;
  j = N % 10;
  if(j == 2 || j == 4 || j == 5 || j == 7|| j == 9){
      cout << "hon" << endl;
  }
  else if(j == 3) {
      cout << "bon" << endl;
  } else {
      cout << "pon" << endl;
  }
  
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;

    int ans=0;
    for(int i=1;i<n;i++){
        int count=0;
        for(char c='a';c<='z';c++){//a~zまでの全探索
            bool left=false, right=false;//a~zが存在するか否か
            for(int j=0;j<i;j++){
                if(s[j]==c) left=true;//左の部類について
            }
            for(int j=i;j<n;j++){
                if(s[j]==c) right=true;//右について
            }
            if(left && right) count++;//両方にあったら++count
        }
        ans=max(ans, count);
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
N=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
cmax=0
for i in range(N):
    if cmax<sum(a1[:i+1])+sum(a2[i:]):
        cmax=sum(a1[:i+1])+sum(a2[i:])
print(cmax)

Measured memory_bytes: 3060
#include <iostream>

int main()
{
    int first, last, divided;
    std::cin >> first >> last >> divided;

    int divisor;
    int cnt = 0;
    for (divisor = first; divisor <= last; divisor++){
        if (divided % divisor == 0){
            cnt++;
        }
    }
    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 1164
S = input()
up_y_flg = False
dw_y_flg = False
up_m_flg = False
dw_m_flg = False

if 1 <= int(S[0:2]) <= 12:
    up_m_flg = True
if 0 <= int(S[0:2]) <= 99:
    up_y_flg = True
if 1 <= int(S[2:4]) <= 12:
    dw_m_flg = True
if 0 <= int(S[2:4]) <= 99:
    dw_y_flg = True


if up_y_flg and dw_m_flg:
    if up_m_flg and dw_y_flg:
        print("AMBIGUOUS")
    else:
        print("YYMM")
elif up_m_flg and dw_y_flg:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(x)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> T& chmin(T &a, const U &b){return a = (a<=b?a:b);}
template <typename T, typename U> T& chmax(T &a, const U &b){return a = (a>=b?a:b);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int N;
  string s;
  while(cin >> N >> s){
    if(count(ALL(s),'R') > count(ALL(s),'B'))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

  }
  
  return 0;
}


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

int main() {
  int n;ll k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i=0;i<n;i++){
      cin >> a.at(i);
  }
  vector<int> s;
  vector<int> ord(n+1,-1);
  int c = 1;
  int l=0;
  {
    int v = 1;
    while(ord[v]== -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() -ord[v];
    l = ord[v];
  }

  if(k < l) 
    cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}


Measured memory_bytes: 5724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int N, Q, cnts, p[900009][27], answ[900009], dp[900009]; string S[900009]; vector<pair<int, string>>X[900009];
int res[900009][27], ret[27][27];

void add(string V) {
	int cx = 0;
	for (int i = 0; i < V.size(); i++) {
		int id = V[i] - ('a' - 1);
		if (p[cx][id] == -1) { cnts++; p[cx][id] = cnts; cx = cnts; }
		else { cx = p[cx][id]; }
	}
}
int dfs(int pos) {
	int ret = 0;
	for (int i = 0; i < 27; i++) { if (p[pos][i] != -1) ret += dfs(p[pos][i]); }
	dp[pos] = max(1, ret);
	return dp[pos];
}

int main() {
	cin >> N;
	for (int i = 0; i < 900009; i++) { for (int j = 0; j < 27; j++)p[i][j] = -1; }
	for (int i = 1; i <= N; i++) {
		cin >> S[i]; S[i] += ('a' - 1); add(S[i]);
	}
	dfs(0);
	cin >> Q;
	for (int i = 1; i <= Q; i++) {
		int v; string w; cin >> v >> w; string ww = ""; ww += ('a' - 1); ww += w; w = ww;
		X[v].push_back(make_pair(i, w));
	}
	for (int i = 1; i <= N; i++) {
		if (X[i].size() == 0) continue;
		int cx = 0;
		for (int j = 0; j < S[i].size(); j++) {
			for (int k = 0; k < 27; k++) { if (p[cx][k] != -1) res[j][k] = dp[p[cx][k]];  else res[j][k] = 0; }
			cx = p[cx][(int)(S[i][j] - ('a' - 1))];
		}
		for (int j = 0; j < 27; j++) { for (int k = 0; k < 27; k++) ret[j][k] = 0; }
		for (int j = 0; j < S[i].size(); j++) {
			for (int k = 0; k < 27; k++) { ret[(int)(S[i][j] - ('a' - 1))][k] += res[j][k]; }
		}
		for (int j = 0; j < X[i].size(); j++) {
			string W = X[i][j].second;
			int ans = 0;
			for (int k = 0; k < W.size(); k++) {
				for (int l = k + 1; l < W.size(); l++) ans += ret[W[l] - ('a' - 1)][W[k] - ('a' - 1)];
			}
			answ[X[i][j].first] = ans + 1;
		}
	}
	for (int i = 1; i <= Q; i++) cout << answ[i] << endl;
	return 0;
}

Measured memory_bytes: 197236
# 入力の受取
n = int(input())
a = [0] * (n+1)
x = [[0] * (n+1) for _ in range(n+1)]
y = [[0] * (n+1) for _ in range(n+1)]

for i in range(1,n+1):
    a[i] = int(input())
    for j in range(1,a[i]+1):
        x[i][j], y[i][j] = map(int, input().split())

# ビット全探索用のシーケンスを生成
import itertools
seq = [0, 1]
arr = itertools.product(seq, repeat=(n))

# ビット全探索
# 証言と整合する場合は，その際の人数をリストに格納
ans = [0]
for v in arr:
    v = [0] + list(v)
    
    flag = True
    # 証言と整合しない場合，フラグをfalseにする
    for i in range(1, n+1):
        if v[i] == 1:
            for k in range(1,a[i]+1):
                if y[i][k] == 1 and v[x[i][k]] == 0:
                    flag = False
                if y[i][k] == 0 and v[x[i][k]] == 1:
                    flag = False
                          
    # 証言と整合した場合
    if flag:
        ans.append(sum(v))


# 証言と整合したケースの人数の最大値を出力
print(max(ans))


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
long long int dp[100010];
int main (){
  int N,M;
  cin>>N>>M;
  rep(i,M){
    int x;
    cin>>x;
    dp[x]=-1;
  }
  if(dp[1]==0) dp[1]=1;
  else dp[1]=0;
  if(dp[2]==0){
    if(dp[1]==0) dp[2]=1;
    else dp[2]=2;
  }
  else dp[2]=0;
  for(int i=3;i<=N;i++){
    if(dp[i]==-1){
      dp[i]=0;
    }
    else{
      dp[i]=dp[i-1]+dp[i-2];
      dp[i]=dp[i]%MOD;
    }
  }
  cout<<dp[N];
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	n=II()
	A=[II() for _ in range(5)]
	ans=0

	for i in A:
		ans=max(ans,(n-1)//i)

	ans+=5

	print(ans)









if __name__ == "__main__":
	main()


Measured memory_bytes: 27132
#include<iostream>
#include<cstdio>
char s[200];
int main() {
    scanf("%s",s+1);
    bool ok=true;
    for(int i=1;s[i];i++) {
        if(i&1) {
            if(s[i]=='L') ok=false;
        }
        else if(s[i]=='R') ok=false;
    }
    printf("%s",ok?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4000)
a = input()
b = input()
def print_lcs (a, b, lcs, i, j):
    global ans
    if (i == 0 or j == 0):
        return
    if (a[i-1] == b[j-1]):
        print_lcs(a, b, lcs, i - 1, j - 1)
        ans.append(a[i - 1])
    else:
        if lcs[i-1][j] >= lcs[i][j-1]:
            print_lcs(a, b, lcs, i - 1, j)
        else:
            print_lcs(a, b, lcs, i, j - 1)

lcs = [ [0 for j in range(len(b) + 1)] for i in range(len(a)+1) ]

for i in range(1, len(a) + 1):
    for j in range(1, len(b) + 1):
        if a[i - 1] == b[j - 1]:
            x = 1
        else:
            x = 0
        lcs[i][j] = max(lcs[i-1][j-1] + x, lcs[i-1][j], lcs[i][j-1])

ans = []
print_lcs(a, b, lcs, len(a), len(b))
print("".join(ans))

Measured memory_bytes: 121436
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

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

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int ans = 1;
	rep(i,5){
		int a;
		cin>>a;
		if(a == 0){
			ans = i+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3636
/**
    @Author:Monk78
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second;
#define F first;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end));i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mod 1000000009
#define MAX 100005
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define rf(i,a,b) for(int i=(a);i>=b;i--)
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
#define vpshVar() int main()

vpshVar(){
    ll N;
    sl(N);
    ll h[N];
    for(ll i=0;i<N;i++){
        sl(h[i]);
    }
    ll dp[N];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(ll i=2;i<N;i++){
            ll v1=dp[i-1]+abs(h[i]-h[i-1]);
            ll v2=dp[i-2]+abs(h[i]-h[i-2]);
            dp[i]=min(v1,v2);
    }
    pl(dp[N-1]);
return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000



int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N);
	set<int> S1,S2;
	for(int i=0;i<N;i++){
		cin>>A[i];
		if(i%2==0)S1.insert(A[i]);
		else S2.insert(A[i]);
	}
	int ans = 0;
	sort(A.begin(),A.end());
	for(int i=0;i<N;i+=2){
		if(S1.find(A[i])==S1.end())ans++;
	}
	
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 5376
//monk
#include<bits/stdc++.h>
using namespace std;
#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>pii;
typedef vector<pii>Vll;
typedef vector<pair<int,pii> >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>M;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) cin>>n
#define pl(n) cout<<n
const int mod=1e9+7;
const int sze=1e5+2;
const int inf= (int)(1e19+10LL);
void solve()
{
	double l;
	sl(l);
	double val=(1.0*(l))/3.0;
	double rem=l-2*val;
	cout<<fixed<<setprecision(6)<<(val*val*rem)<<endl;
}
 
signed main(){
	int test=1;
   //sl(test);
   while(test--){
	 solve();
   }
  return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	string str;cin >> str;
	REP(i, str.size())cout << "x";cout << endl;

	return 0;
}


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

using namespace std;

const int MAX_K = 123456;
int n, k, a[MAX_K];
bool dp[MAX_K];

int main() {
    cin >> n >> k;

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

    for (int i = 1; i <= k; i++)
        for (int j = 0; j < n; j++) {

            if (i - a[j] < 0)
                break;

            else {
                if (!dp[i - a[j]]) {

                    dp[i] = true;

                    break;
                }
            }
        }

    if (dp[k])
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h> 
#define ll long long
#define ld long double
#define vi vector<int>
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define vp vector<pair<ll, ll>>
#define all(a) a.begin(), a.end()
#define pb push_back
#define pi pair<int, int>
#define pl pair<ll, ll>
#define mp make_pair
#define fi first
#define sc second
#define for0(i, n) for(ll i=0; i<n; i++) 
#define for1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ll mod = 1e9+7;

void solve(){
	ll n, k; cin>>n>>k;
	ll a[n];
	for0(i, n)
		cin>>a[i];
	ll prev=0;
	for(int i=k; i<n; i++){
		if(a[i]>a[prev])
			cout<<"Yes\n";
		else
			cout<<"No\n";
		prev++;
	}
}

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll test = 1;
	//cin>>test;
	while(test--)
		solve();

	return 0;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
vector<ll> b(51), p(51);

ll f(ll n, ll x) {
	if (n == 0)
		return (x <= 0) ? 0 : 1;
	else if (x <= 1 + b[n-1])
		return f(n - 1, x - 1);
	else
		return p[n-1] + 1 + f(n - 1, x - 2 - b[n-1]);
}

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

	b[0] = p[0] = 1;
	REP(i, 50) {
		p[i+1] = p[i] * 2 + 1;
		b[i+1] = b[i] * 2 + 3;
	}
	cout << f(n, x) << '\n';
    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
    int N, a;
    char c;
    int i;
    int MOD = 0;
        
    
    scanf("%d", &N);
    
    for(i=0; i<N; i++)
    {
        scanf("%d%c", &a, &c);
        
        MOD += a;
    }
    
    printf("%d\n", MOD-N);

    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N, A, B, C;
    cin >> N >> A >> B >> C;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    vector<int> check(N);
    int tmp;
    int a, b, c;
    int ans = inINF;
    int tans;

    for (int i = 0; i < 1<<(2*N); i++) {
        tmp = i;
        a = 0; b = 0; c = 0;
        tans = 0;
        for (int j = 0; j < N; j++) {
            if(tmp % 4 == 0){
                a += L[j];
                tans += 10;
            }
            else if(tmp % 4 == 1){
                tans += 10;
                b += L[j];
            }
            else if(tmp % 4 == 2){
                tans += 10;
                c += L[j];
            }
            tmp = tmp / 4;
        }
        if(a == 0 || b == 0 || c == 0){
            continue;
        }

        if(a < b){
            tmp = a;
            a = b;
            b = tmp;
        }
        if(b < c){
            tmp = b;
            b = c;
            c = tmp;
        }
        if(a < b){
            tmp = a;
            a = b;
            b = tmp;
        }

        tans += abs(A-a) + abs(B-b) + abs(C-c);
        tans -= 30;
        ans = min(ans, tans);

    }

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

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s == u){
        a--;
    }else{
        b--;
    }
    cout << a << ' ' << b << endl;
}

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

int H, W;
int C[26];
vector<char> V1, V2, V4;

void input_data(void) {
	cin >> H >> W;
	fill(C, C + 26, 0);
	for (int j = 0; j < H; ++j) {
		string str;
		cin >> str;
		for (int i = 0; i < W; ++i) {
			char c = str[i];
			int id = (int)(c - 'a');
			++C[id];
		}
	}
}

void pre_calcu(void) {
	V1.clear();	V2.clear(); V4.clear();
	int g4 = (H / 2) * (W / 2);
	for (int i = 0; i < 26; ++i) {
		if (C[i] == 0)
			continue;
		int cnt = C[i];
		while (cnt > 0) {
			if (cnt >= 4) {
				cnt -= 4;
				if ((int)V4.size() >= g4) {
					V2.push_back((char)(i + 'a'));
					V2.push_back((char)(i + 'a'));
				}
				else
					V4.push_back((char)(i + 'a'));
			}
			else if (cnt >= 2) {
				cnt -= 2;
				V2.push_back((char)(i + 'a'));
			}
			else if (cnt == 1) {
				--cnt;
				V1.push_back((char)(i + 'a'));
			}
		}
	}
}

bool solve(void) {
	bool ret = false;
	int g4 = (H / 2) * (W / 2);
	if (H % 2 == 0 && W % 2 == 0) {
		if (g4 == V4.size())
			ret = true;
	}
	else if (H % 2 == 1 && W % 2 == 1) {
		if (V1.size() != 1)
			return ret;
		int g2 = (H / 2) + (W / 2);
		if (g2 == V2.size() && g4 == V4.size())
			ret = true;
	}
	else {
		int g2 = (H % 2 == 0) ? H / 2 : W / 2;
		if (g2 == V2.size() && g4 == V4.size())
			ret = true;
	}
	return ret;
}

int main(void) {
	input_data();
	pre_calcu();
	bool ans = solve();
	if (ans)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<bitset>
#include<deque>
using namespace std;
#define ll long long
// #define inf 0x3f3f3f3f
#define ri register int
#define il inline
#define fi first
#define se second
#define mp make_pair
#define pi pair<int,int>
#define mem0(x) memset((x),0,sizeof (x))
#define mem1(x) memset((x),0x3f,sizeof (x))
il char gc()
{
    static const int BS = 1 << 22;
    static unsigned char buf[BS], *st, *ed;
    if (st == ed) ed = buf + fread(st = buf, 1, BS, stdin);
    return st == ed ? EOF : *st++;
}
#define gc getchar
template<class T>void in(T &x)
{
    x = 0;
    bool f = 0;
    char c = gc();
    while (c < '0' || c > '9')
    {
        if (c == '-') f = 1;
        c = gc();
    }
    while ('0' <= c && c <= '9')
    {
        x = (x << 3) + (x << 1) + (c ^ 48);
        c = gc();
    }
    if (f) x = -x;
}
#undef gc
#define pb push_back
#define N 100010
#define M N<<1
int n, m;
int v[M], nx[M];
int cnt, head[N];
il void add(int uu, int vv)
{
    v[++cnt] = vv, nx[cnt] = head[uu];
    head[uu] = cnt;
}
int col[N];
bool ok = 1;
int sz;
void dfs(int x)
{
    if (col[x] == 2) ++sz;
    for (ri i = head[x]; i; i = nx[i])
    {
        if (col[v[i]])
        {
            if (col[v[i]] == col[x])
            {
                ok = 0;
                return;
            }
        }
        else
        {
            col[v[i]] = col[x] ^ 1;
            dfs(v[i]);
        }
    }
}
signed main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
#endif
    in(n), in(m);
    for (ri i = 1, a, b; i <= m; ++i)
    {
        in(a), in(b);
        add(a, b);
        add(b, a);
    }
    col[1] = 2;
    dfs(1);
    if (ok == 0)
    {
        printf("%lld", (ll)n * (n - 1) / 2 - m);
    }
    else
    {
        printf("%lld", (ll)sz * (n - sz) - m);
    }
    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto& i : a) cin >> i;
    sort(a.begin(), a.end());
    cout << (unique(a.begin(), a.end()) == a.end() ? "YES" : "NO") << endl;
    // https://cpprefjp.github.io/reference/algorithm/unique.html
}

Measured memory_bytes: 1792
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    char c1[] = new char[3];
    char c2[] = new char[3];
    for(int i=0 ; i<3 ; i++){
      c1[i] = s1.charAt(i);
      c2[i] = s2.charAt(i);
    }
    if(c1[1]==c2[1] && c1[0]==c2[2] && c1[2]==c2[0]){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans=n/(a+b);
	ans*=a;
	ans+=min(a,n%(a+b));
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,k,a[3],b=0,c=1000,d=0;
    for(i=0;i<3;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]>b) b=a[i];
        if(a[i]<c) c=a[i];
    }
    for(i=0;i<3;i++)
    {
        if(a[i]!=b && a[i]!=c)
        {
            d=a[i];
        }
    }
    j=(d-c)+(b-d);
    printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A(MAX_N), B;
void input() {
    cin >> n;
    rep(i, n) {
        cin >> x;
        A[x]++;
        ans += x;
    }
    cin >> q;
}
void solve() {
    rep(i, q) {
        cin >> b >> c;
        ans += (c - b) * (A[b]);
        A[c] += A[b];
        A[b] = 0;

        cout << ans << endl;
    }
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 7004
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
long long int mod = 1e9 + 7;
long long int  n,m;
long long int a[200005];
bool cmp(int x, int y)
{
	return abs(x) < abs(y);
}
int main()
{
	int pn=0 ,nn = 0;
	//pn正数，nn负数；
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] >= 0)
			pn++;
		else
			nn++;
	}
	int l=1, r=n;//左右逼近
	long long ans = 1;
	if (!pn && m % 2 == 1)//结果必定为负数
	{
		sort(a + 1, a + 1 + n, cmp);
		for (int i = 1; i <= m; i++) 
			ans = a[i] * ans % mod;
	}
	else
	{
		sort(a + 1, a + 1 + n, greater< int >());
			////内置类型的由大到小排序
		while (m)
		{
			if (m % 2 == 1)//为奇数就乘大的正数
			{
				ans = ans * a[l] % mod;
				l++, m--;
			}
			else
			{
				if (a[l] * a[l + 1] >= a[r] * a[r - 1])
					//两正数乘起来比负数大
				{
					ans = ans * a[l] % mod * a[l + 1] % mod;
					l += 2,m -= 2;
				}
				else
				{
					ans = ans * a[r - 1] % mod * a[r] % mod;
					r -= 2,m -= 2;
				}
			}

		}
	}
	//防止出现负数，故再加mod再取余数
	cout << (ans % mod + mod) % mod << endl;
}

Measured memory_bytes: 5124
#include <bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

//                                          mdsaqib
signed main(){
    fast;
    int n,k;
    cin >> n >> k;
    vector <int> A(n,0);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    sort(all(A));
    int sum=0;
    for(int i=0;i<k;i++){
        sum+=A[i];
    }
    cout << sum;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  int n;
  cin >> n;
  set<ll> st;
  REP(i,n){
    int x;cin >> x;
    if(st.find(x) == st.end()){
      st.insert(x);
    }else{
      st.erase(x);
    }
  }
  cout << st.size() << endl;

  


  

  return 0;
}

Measured memory_bytes: 4864
using System;

namespace ABC055B
{
    class Program
    {
        static void Main(string[] args)
        {
            long m = 1000000000 + 7;
            long N = long.Parse(Console.ReadLine());
            long pow = 1;
            for(int i=1;i<=N;i++){
                pow = (pow * i) % m;
            }
            Console.WriteLine(pow);
        }
    }
}


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

int main() {
    ll n,m;
    cin >> n >> m;
    if(2*n>=m){
        cout << m/2 << endl;
        return 0;
    }
    m -= 2*n;
    cout << m/4+n << endl;

    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int r,d,x; cin>>r>>d>>x;
	for(int i=0;i<10;++i){
		x=r*x-d;
		cout<<x<<"\n"s;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int a[2][110],b[110],c[110];
int main()
{
	int i,j,k,n,m,x,y;
	scanf("%d",&n);
	for(i=0;i<2;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	b[0]=a[0][0];
	for(i=1;i<n;i++)
	{
		b[i]=a[0][i]+b[i-1];
	}
	c[n-1]=a[1][n-1];
	for(i=n-2;i>=0;i--)
	{
		c[i]=a[1][i]+c[i+1];
	}
	int ans=0;
	for(i=0;i<n;i++)
	{
		ans=max(ans,b[i]+c[i]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int H, W;
char a[10][10];
int res, sum;
int ok;

void srch(int x, int y)
{
	if(ok)
		return ;
	if(x==H-1 && y==W-1){
		if(res == sum)
			ok = 1;
		return; 
	}
	int xx = x;
	int yy = y+1;
	if(xx>=0 && xx<H && yy>=0 && yy<W && a[xx][yy]=='#'){
		res ++;
		srch(xx, yy);
		res --;
	}
	xx = x+1;
	yy = y;
	if(xx>=0 && xx<H && yy>=0 && yy<W && a[xx][yy]=='#'){
		res ++;
		srch(xx, yy);
		res --;
	}
}

void solve()
{
	int i, j;
	if(a[0][0] == '.'){
		printf("Impossible\n");
		return ;
	}
	sum = 0;
	for(i=0; i<H; i++){
		for(j=0; j<W; j++){
			if(a[i][j] == '#')
				sum ++;
		}
	}
	ok = 0;
	res = 1;
	srch(0, 0);
	if(ok == 1)
		printf("Possible\n");
	else
		printf("Impossible\n");
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d%d", &H, &W);
	for(i=0; i<H; i++)
		scanf("%s", &a[i]);
	solve();
	return 0;
}

Measured memory_bytes: 128
mod = 10**9+7
h, w, k = [ int(v) for v in input().split() ]

non_contiuous_list = [1,2]

end_0, end_1 = 1, 1
for i in range(8):
    end_1_new = end_0
    end_0_new = end_0 + end_1
    end_0, end_1 = end_0_new, end_1_new
    non_contiuous_list.append(end_0 + end_1)


def non_contiuous(x):
    global non_contiuous_list
    if x >= 0:
        return non_contiuous_list[x]
    else:
        return 1

reach = [ [ 0 for i in range(w) ] for j in range(h+1) ]
reach[0][0] = 1

for i in range(1,h+1):
    if w > 1:
        for j in range(w):
            a = max(0,w-2)
            b = max(0,w-3)
            if j == 0:
                reach[i][j] = reach[i-1][j] * non_contiuous(a) + reach[i-1][j+1] * non_contiuous(b)
            elif j == w - 1:
                reach[i][j] = reach[i-1][j] * non_contiuous(a) + reach[i-1][j-1] * non_contiuous(b)
            else:
                reach[i][j] = reach[i-1][j-1] * non_contiuous(j-2) * non_contiuous(w-j-2) + reach[i-1][j] * non_contiuous(j-1) * non_contiuous(w-j-2) + reach[i-1][j+1] * non_contiuous(j-1) * non_contiuous(w-j-3) 
    else:
        reach[i][0] = 1

    reach[i] = [ j % mod for j in reach[i] ] 

print(reach[h][k-1])

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

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  if (s == "Cloudy") cout << "Rainy" << endl;
  if (s == "Rainy") cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = INT32_MIN;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

template<int index>
bool comp(tuple<ll, ll, ll, ll> a, tuple<ll, ll, ll, ll> b) {
	return get<index>(a) < get<index>(b);
}

int vector_finder(std::vector<ll> vec, ll number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return index;
	}
	else { // 発見できなかったとき
		return 0;
	}
}


int len(int x) {
	return (int)log10(x) + 1;
}

int same_vec(vector<int> a, vector<int> b) {
	int res = 1, num = a.size();
	for (int i = 0; i < num; i++) {
		if (a[i] != b[i]) {
			res = 0;
			break;
		}
 	}
	return res;
}


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

	int N;
	cin >> N;

	vector<ll> B(N + 1);
	B[0] = INF;
    B[N] = INF;
	
	rep(i, N - 1) {
		cin >> B[i + 1];
	}

	ll ans = 0;
	rep(i, N) {
		ans += std::min(B[i], B[i + 1]);
	}

	cout << ans << endl;




ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}




Measured memory_bytes: 504
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

    ll n, m;
    cin >> n >> m;

    ll ans = 1;
    ll diff = abs(n - m);
    if (diff > 1) ans = 0;
    else {
        if (diff == 0) {
            REP(i, n) {
                ans *= (i + 1);
                ans %= mod;
            }
            REP(i, m) {
                ans *= (i + 1);
                ans %= mod;
            }
            ans *= 2;
            ans %= mod;
        }
        if (diff == 1) {
            REP(i, n) {
                ans *= (i + 1);
                ans %= mod;
            }
            REP(i, m) {
                ans *= (i + 1);
                ans %= mod;
            }
        }
    }

    cout << ans << '\n';
    return 0;
}


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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<vector<long long>> mll;
typedef vector<vector<pair<long long, long long>>> mpl;
typedef vector<pair<long long, long long>> vpl;
typedef pair<long long, long long> pll;
#define minimize(var, val) (var = min((val), var))

const long long MOD = 1e9 + 7;

int main() {
    ll n;
    cin >> n;
    vll a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    mpl dp(n, vpl(n, {0, (((ll)INT32_MAX) << 16)}));
    for (int i = 0; i < n; i++) {
        dp[i][i] = {a[i], 0};
    }
    for (int len = 1; len <= n; len++) {
        for (int i = 0; i < n && i + len - 1 < n; i++) {
            int j = i + len - 1;
            for (int k = i; k < j; k++) {
                dp[i][j].first = dp[i][k].first + dp[k + 1][j].first;
                ll cost = dp[i][k].first + dp[i][k].second +
                          dp[k + 1][j].first + dp[k + 1][j].second;
                minimize(dp[i][j].second, cost);
            }
        }
    }
    cout << dp[0][n - 1].second << endl;
}

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

int main(){
	long long n,m,x;
	cin >> n >> m >> x;
	vector<long long > c(n);
	vector<vector<long long >> a(n,vector<long long>(m));
	long long i,j;
	for(i=0;i<n;i++){
		cin >> c.at(i);
		for(j=0;j<m;j++){
			cin >> a.at(i).at(j);
		}
	}
	
	long long money = 0;
	
	for(long long l = 0;l < ( 1 << 12); l++){
		bitset<12> bit(l);
		
		long long sum=0;
		vector<long long> skill(m);
		bool b=1;
		for(j=0;j<n;j++){
			if(bit.test(j)){
				sum+=c.at(j);
				for(long long k=0;k<m;k++){
					skill.at(k)+=a.at(j).at(k);
				}
			}
		}
		for(i=0;i<m;i++){
			if(skill.at(i) < x){
					b=0;
			}
		}
		if(b){
          if(money==0){
            money = sum;
          }else{
			money = min(money,sum);
          }
		}
	}
	
	if(money==0){
		cout << (-1) << endl;
	}else{
		cout << money << endl;
	}
			
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
//freopen("in.txt","r",stdin);
	int n;
	cin>>n;
	int ans = 0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans ^= a[i];
	}
	for(int i=0;i<n;i++){
		cout<<(ans^a[i])<<" ";
	}cout<<endl;
	return 0;
}


Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,M;cin>>N>>M;
    long long  ans =0;
    typedef pair<int,int>value_type;
    vector<value_type> X(N);
    for (int i=0;i<N;i++){
        cin>>X[i].first>>X[i].second;
    }
    //sort(X.begin(), X.end(), bind(&value_type::first, _1) < bind(&value_type::first, _2));
    sort(X.begin(), X.end());
    //for(int i =0;i<N;i++){
    //    cout << X[i].first <<':'<< X[i].second<<endl;
    //}
    while(M > 0){
        for(int i=0;i<N;i++){
            if(X[i].second > M){
                ans += (long long)X[i].first * M;
                M = 0;
            } else{
                ans +=(long long)X[i].first * X[i].second;
                M -= X[i].second;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



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

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

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

#define BIT_ON(x,b) ((x)|=(b))
#define BIT_OFF(x,b) ((x)&=~(b))
#define BIT_IS_ON(x,b) (((x)&(b))==(b))


using namespace std;

int main(void){
  int A,B,C,t;
  vector<int> v(3);
  cin >> A >> B >> C;
  v[0] = A; v[1]=B; v[2] =C;
  sort(v.begin(), v.end());
  int res = (v[2]*2 - (v[0]+v[1]))/2;
  bool odd = (v[2]*2 - (v[0]+v[1]))%2;
  if(odd) res+=2;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

map<ll, ll> prime_factorization(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while(n >= a*a){
    if(n % a == 0){
      ans[a]++;
      n /= a;
    }else{
      a++;
    }
  }
  ans[n]++;

  return ans;
}

int main(){
  ll n;
  cin >> n;
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  auto pr = prime_factorization(n);
  int ans = 0;
  for(auto p : pr){
    int num = 0;
    for(int i = 1;;i++){
      num += i;
      if(num <= p.second) ans++;
      else break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;
struct segtree{
  int val[1100000];
  int n;
  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
  }
  void set(int k,int a){
    k+=n-1;
    val[k]=a;
    while(k>0){
      k=(k-1)/2;
      val[k]=min(val[k*2+1],val[k*2+2]);
    }
  }
  int query(int a,int b,int i,int l,int r,int K){
    if(b<=l || r<+a || val[i]>=K) return INF;
    if(r-l==1) return l;
    int md=(l+r)>>1;
    int L=query(a,b,i*2+1,l,md,K);
    if(L==INF) return query(a,b,i*2+2,md,r,K);
    return L;
  }
  bool alive(int v){
    return val[v+n-1]<INF;
  }
};
segtree seg;

int n,K;
int ar[500005],br[500005];

int res[500005],cnt,ans[500005];
set<int> alive;
void rec(int v){
  seg.set(v,INF);
  while(1){
    int v2=seg.query(v+1,n,0,0,seg.n,ar[v]);
    if(v2>=v+K) break;
    rec(v2);
  }
  res[cnt++]=v;
}
int main(){
  cin>>n>>K;
  REP(i,n){
    scanf("%d",&ar[i]),--ar[i];
    br[ar[i]]=i;
  }
  seg.init(n);
  REP(i,n) seg.set(i,ar[i]);

  REP(i,n) if(seg.alive(i)){
    rec(i);
  }

  REP(i,n) ans[res[i]]=i;

  REP(i,n) printf("%d\n",ans[i]+1);

  return 0;
}




Measured memory_bytes: 54400
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <stack>
#define int long long
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;
    cin >> n;
    int j = 1;
    int ans = 1;
    while(n!=1){
        n /= 2;
        j*=2;
        ans += j;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3 = y1 - y2 + x2, y3 = x2 - x1 + y2;
  int x4 = y2 - y3 + x3, y4 = x3 - x2 + y3;
  printf("%d %d %d %d", x3, y3, x4, y4);
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    int n;
    std::cin >> n;

    int count = 0;
    for (int i = 0; i < n; i++) {
        int l, r;
        std::cin >> l >> r;

        count += r - l + 1;
    }

    std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include<bitset>


using namespace std;

#define ll long long
#define ld long double
#define MOD 1000000007
#define rep(i, n) for(int i = 0;i < n;i++)
#define PI 3.14159265358979323846
int main()
{
    int n;
    cin >> n;
    string alice;
    string bob;
    cin >> alice >> bob;
    vector<char> ans;
    int flag = 0;
    for (int i = 0; i < 2*n; i++)
    {
        if (flag % 2== 0)
        {
            ans.push_back(alice[i/2]);
            flag++;
        }else
        {
            ans.push_back(bob[i/2]);
            flag++;
        }
    }
    for (int i = 0; i < 2*n; i++)
    {
        cout << ans[i];
    }
    cout  << endl;
    
}

Measured memory_bytes: 256