akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 0x3f3f3f
#define PB push_back
#define F first
#define S second
#define FOR(i,k) for(int i=0; i<k; i++)
#define RFOR(i,k) for(int i=k; i>=0; i--)
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
#define DEBUGV(x) cout<<#x<<": "; for(auto &d:x) cout<<d<<" "; cout<<endl
#define DEBUGM(x) for(auto &p:x) cout<<p.F<<":"<<p.S<<" "; cout<<endl;
#define OUT(x) cout<<(x)<<endl

using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef map<char,int> MC;
typedef map<int,int> MI;
typedef map<string,int> MS;

template<typename T, typename U> void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if(x < y) x = y; }
VPII neighbors = {{0,1}, {1,0}, {0,-1}, {-1,0}};
PII operator+(PII &l, PII &r) { return {l.F+r.F, l.S+r.S}; }
bool IsValid(PII p, int Y, int X) { 
  return p.F >=0 && p.F < Y && p.S >=0 && p.S < X; }
bool IsPrime(int n) {
  if (n <= 1)  return false;
  if (n <= 3)  return true;
  if (n%2 == 0 || n%3 == 0) return false;
  for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
      return false;
  return true;
}

int main() {
  int n;
  VI v;
  cin>>n;
  FOR(i,n) {
    int e;
    cin>>e;
    v.PB(e);
  }
  int maxE = *max_element(ALL(v));
  int minE=maxE;
  for(auto d : v) {
    if(d==maxE)
      continue;
    if(abs(d-(maxE+1)/2) <= abs(minE-(maxE+1)/2))
      minE = d;
  }
  cout<<maxE<<" "<<minE<<endl;
}


Measured memory_bytes: 892
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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

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

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long double a, b, x;
  cin >> a >> b >> x;
  if (2 * x >= a * a * b) {
    double y = 2 * b - 2 * x / a / a;
    double ans = atan(y / a) / M_PI * 180;
    printf("%.10f", ans);
  } else {
    double y = 2 * x / a / b;
    double ans = atan(b / y) / M_PI * 180;
    printf("%.10f", ans);
  }
  return 0;
}

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

#define pb push_back
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define mk make_pair
using namespace std;
const long long INF = 1e16;

typedef long long ll;
#define P pair<ll,int>

#define MAX_V 200000

struct edge {
    ll to;
    ll cost;
};

ll V;
vector<edge> G[MAX_V];
ll d[MAX_V];


void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

vector<edge> G2[MAX_V];
void dijkstra2(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G2[v].size(); ++i) {
            edge e = G2[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}


int main(){
  int E,s,t;
  cin >> V >> E >> s >> t;
  V++;
  REP(i,E){
    int f,t,c1,c2;
    cin >> f >> t >> c1 >> c2;
    edge e = {t,c1};
    edge e2 = {t,c2};
    G[f].pb(e);
    e.to = f;
    G[t].pb(e);
    G2[f].pb(e2);
    e2.to = f;
    G2[t].pb(e2);
  }
  dijkstra(s);
  ll dis[MAX_V];
  REP(i,MAX_V){
      dis[i] = d[i];
  }

  dijkstra2(t);
  ll sum = 0;
  ll ft = 1e15;
  vector <P> p;
  rep(i,1,V){
      ll y = ft - dis[i] - d[i];
      p.pb(mk(y,i));
      //cout << dis[i] << " " << d[i] << endl;
  }
  sort(p.begin(),p.end(), greater <P>() );
  int u = 0;
  REP(i,V-1){
      
      while(p[u].second <= i){
          u++;
      }
      cout << p[u].first << endl;
  }
  //cout << sum << endl;
  return 0;
}


Measured memory_bytes: 26172
N = int(input())
A = list(map(int, input().split()))
B = [0] * N

for i in range(N - 1, -1, -1):
    B[i] = (sum(B[2 * (i + 1) - 1::i + 1]) % 2) ^ A[i]

print(sum(B))
print(*[i+1 for i in range(N) if B[i] == 1])

Measured memory_bytes: 18456
<?php
fscanf(STDIN, "%d", $n);

$start = [2, 3, 25];
$pairs = [
	[30, 60],
	[32, 28],
	[33, 27],
	[4, 26],
	[5, 55],
	[6, 24],
	[8, 22],
	[9, 21],
	[10, 20],
	[12, 18],
	[14, 16],
];

if ($n == 3) {
	echoes($start);
	return;
}

if (($n % 2) === 0) {
	$start[] = 30;
}

if ($n == 4) {
	echoes($start);
	return;
}

$times = ($n - count($start)) / 2;
$alpha = 0;
while (true) {
	foreach ($pairs as $pair) {
		if (($alpha % 2 == 0) && $pair[0] === 30) {
			continue;
		}
		$start[] = $pair[0] + 30 * $alpha;
		$start[] = $pair[1] + 30 * $alpha;
		$times--;
		if ($times === 0) {
			break 2;
		}
	}
	$alpha++;
}
echoes($start);
return;

function echoes(array $a) {
	foreach ($a as $value) {
		echo $value, " ";
	}
	echo "\n";
}

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)998244353
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
}


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



int main(void){
    string s;
    int K;
    cin >>s >> K;
    
    vector<string> ans;
    for(int i = 0; i < s.size();i++){
        for(int j =1; j <= K;j++){
            ans.push_back(s.substr(i,j));
        }
    }
    
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    cout << ans[K-1]<<endl;
}



Measured memory_bytes: 1660
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

int main() {
    int n, m; cin >> n >> m;
    string s; cin >> s;
    vector<int> res;
    auto dfs = [&](auto dfs, int cur) -> void {
        for (int i = m; i >= 1; i--) if (cur - i >= 0 && s[cur - i] == '0') {
            res.emplace_back(i);
            dfs(dfs, cur - i);
            break;
        }
    };
    dfs(dfs, n);
    reverse(res.begin(), res.end());
    if (accumulate(res.begin(), res.end(), 0) != n) cout << -1 << endl;
    else cout << res << endl;
    return 0;
}

Measured memory_bytes: 4984
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	string s;
	long long int a,ct=0;
	cin>>a;
	forr(i,0,a)
	{
		int x=i+1;
		if(x%3!=0 and x%5!=0)
			ct+=x;
	}
	cout<<ct;
	
	
	return 0;	
}

Measured memory_bytes: 3652
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=2e5+5;




int main()
{ 

IOS;


ll n;cin>>n;

vl a(n+1);

FOR(i,n+1)cin>>a[i];

vl b(n+1);

b[0]=1;

if(!n&&a[0]==1){
cout<<1;
return 0;
}

if(a[0]!=0){
  cout<<-1;
return 0;
}

ll flag=0;

vl f(n+2);

for(int i=n;i>=0;i--){
  f[i]=f[i+1]+a[i];
}

for(int i=1;i<=n;i++){
  b[i]=min(2*b[i-1]-a[i],f[i+1]);
  if(b[i]<0){
    flag=1;
    break;
  }
}

if(flag){
  cout<<-1;
  return 0;
}

ll tot=0;

for(int i=0;i<=n;i++){
  tot+=a[i]+b[i];
}

cout<<tot;



//end_routine();

return 0;
 
 }

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

int n, kk;
int sea[110][110][110];
int xx1[55], yy1[55], dd1[55], xx2[55], yy2[55], dd2[55];
int x[110], y[110], d[110];
long long int ans = 0;

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

  for(int i = 0; i < n; i++)
    cin >> xx1[i] >> yy1[i] >> dd1[i] >> xx2[i] >> yy2[i] >> dd2[i];

  for(int i = 0; i < n; i++){
    x[2 * i] = xx1[i];
    x[2 * i + 1] = xx2[i];
  }
  for(int i = 0; i < n; i++){
    y[2 * i] = yy1[i];
    y[2 * i + 1] = yy2[i];
  }
  for(int i = 0; i < n; i++){
    d[2 * i] = dd1[i];
    d[2 * i + 1] = dd2[i];
  }

  sort(x, x + 2 * n);
  sort(y, y + 2 * n);
  sort(d, d + 2 * n);

  for(int i = 0; i < 2 * n - 1; i++)
    for(int j = 0; j < 2 * n - 1; j++)
      for(int k = 0; k < 2 * n - 1; k++){
	int many = 0;
	for(int l = 0; l < n; l++)
	  if(xx1[l] <= x[i] && x[i + 1] <= xx2[l] && yy1[l] <= y[j] && y[j + 1] <= yy2[l] && dd1[l] <= d[k] && d[k + 1] <= dd2[l])
	    many++;
	
	if(many >= kk)
	  ans += (long long int)(x[i + 1] - x[i]) * (long long int)(y[j + 1] - y[j]) * (long long int)(d[k + 1] - d[k]);
	
      }

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

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
using namespace std;

int main() {
	IOS;

	int r1, r2, r3, r4;
	cin >> r1 >> r2 >> r3 >> r4;
	if(r2 > r4) cout << 1;
	else cout << 0;
    return 0;
}

Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]

matrix = []
for ni in range(n):
    matrix.append([int(a) for a in input().split()])

vector = []
for mi in range(m):
    vector.append(int(input()))


b = []
for ni in range(n):
    sum = 0
    for mi in range(m):
        sum += matrix[ni][mi] * vector[mi]

    print(sum)

Measured memory_bytes: 8072
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main (){
    ll k,n;cin>>n>>k;
    vector<ll> V(n);
    for(int i=0;i<n;i++){
            cin>>V[i];
    }
    sort(V.rbegin(),V.rend());
    if(k==0){
        cout<<accumulate(V.begin(),V.end(),0LL);
        return 0;
    }
    if(k>n)k=n;
    ll res = accumulate(V.begin(),V.end(),0LL)-accumulate(V.begin(),V.begin()+k,0LL);
    cout<<res;
    return 0;
}


Measured memory_bytes: 1792
// ------------------------------------
// Date:2018/ 3/25
// Problem:C - Snuke c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

int N;

int main()
{
  scanf("%d", &N);
  vector< int > A(N);
  REP(i, N) scanf("%d", &A[i]);
  vector< int > B(N);
  REP(i, N) scanf("%d", &B[i]);
  vector< int > C(N);
  REP(i, N) scanf("%d", &C[i]);

  sort(ALL(A));
  sort(ALL(B));
  sort(ALL(C));

  ll ans = 0ll;
  REP(i, N) {
    ll sum = 0ll;
    debug(B[i]);
    sum = lower_bound(ALL(A), B[i]) - A.begin();
    debug(ans);
    sum *= N - (upper_bound(ALL(C), B[i]) - C.begin());
    debug(ans);
    ans += sum;
  }

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



Measured memory_bytes: 1408
#include <iostream>
#include <string.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
struct ppppp
{
    int num;
    int year;
    long long ans;
    long long xian;
}d[100005];
bool cmp(ppppp a,ppppp b)
{
    if(a.xian<b.xian)return true;
    else if(a.xian==b.xian)
    {
        if(a.year<b.year)return true;
    }
    return false;
}
bool cmp2(ppppp a,ppppp b)
{
    if(a.num<b.num)return true;
    return false;
}
int weishu(int a)
{
    int d=0;
    while(a!=0)
    {
        a/=10;
        d++;
    }
    return d;
}
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    for(int i=1;i<=b;i++)
    {
        d[i].num=i;
        cin>>d[i].xian;
        cin>>d[i].year;
    }
    sort(d+1,d+b+1,cmp);
    int cnt=0;
    for(int i=1;i<=b;i++)
    {
        if(i==1||d[i].xian!=d[i-1].xian)
        {
            cnt=1;
        }
        d[i].ans=d[i].xian*1000000+cnt;
        cnt++;
    }
    sort(d+1,d+b+1,cmp2);
    for(int i=1;i<=b;i++)
    {
        printf("%012lld\n",d[i].ans);
    }
    return 0;
}


Measured memory_bytes: 3840
while True:
	x=input().split()
	if x[1]=='?':
		break
	elif x[1]=='+':
		print(int(x[0])+int(x[2]))
	elif x[1]=='-':
		print(int(x[0])-int(x[2]))
	elif x[1]=='*':
		print(int(x[0])*int(x[2]))
	elif x[1]=='/':
		print(int(x[0])//int(x[2]))


Measured memory_bytes: 5600
N = int(input())
a = list(map(int,input().split()))
ans1 = 0
ans2 = 0
S1 = 0
S2 = 0
for n in range(N):
    S1 += a[n]
    S2 += a[n]
    if n%2 == 0:
        if S1 >= -1:
            ans1 += S1 + 1
            S1 = -1
        if S2 <= 1:
            ans2 += 1 - S2
            S2 = 1
    if n%2 == 1:
        if S1 <= 1:
            ans1 += 1 - S1
            S1 = 1
        if S2 >= -1:
            ans2 += S2 + 1
            S2 = -1
print(min(ans1,ans2))


Measured memory_bytes: 14464
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Ford(i,a,b) for(int i=(a);i>=(b);--i)
#define fio(s) freopen(s".inp","r",stdin)
#define foo(s) freopen(s".out","w",stdout)
#define task "test"
using namespace std;
typedef long long LL;
const LL N=100009,OO=1e9+7;
LL n,f[N],h[N],k;
int main(){
    //fio(task); foo(task);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>k; For(i,1,n) cin>>h[i];h[0]=h[1];
    For(i,2,n){
        f[i]=OO;
        Ford(j,i-1,max((LL)1,i-k)) f[i]=min(f[i],f[j]+abs(h[i]-h[j]));
    }
    cout<<f[n];
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<vector<ll>>F(N,vector<ll>(10));
    vector<vector<ll>>P(N,vector<ll>(11));
    rep(i,N){
        rep(j,10){
            cin>>F[i][j];
        }
    }

    rep(i,N){
        rep(j,11){
            cin>>P[i][j];
        }
    }
    ll ans=-INF;
    rep2(i,(1<<10)-1){
        vector<bool> S(10);
        rep(j,10){
            if(i&(1<<j)){
                S[j]=1;
            }
        }
        ll now=0;
        rep(j,N){
            ll cnt = 0;
            rep(k,10){
                cnt += (F[j][k]&S[k]);
            }
            //cout<<cnt<<endl;
            now+=P[j][cnt];
        }
        
        chmax(ans,now);
            
    }
    cout << ans << endl;


    return 0;
    

}

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

using namespace std;

int main() {
    int m, f, r;
    char res;
    while (true) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) return 0;

        if (m == -1 || f == -1) {
            res = 'F';
        } else if (m + f >= 80) {
            res = 'A';
        } else if (65 <= m + f) {
            res = 'B';
        } else if (50 <= m + f) {
            res = 'C';
        } else if (30 <= m + f) {
            if (50 <= r) {
                res = 'C';
            } else {
                res = 'D';
            }
        } else {
            res = 'F';
        }

        cout << res << endl;
    }
}


Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <utility>
#include <cmath>

#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef long long ll;

int main()
{

    double a, b, x;
    cin >> a;
    cin >> b;
    cin >> x;

    double s = x / a;
    double rad;
    if (s >= a * b / 2)
    {
        double h = (a * b - s) * 2 / a;
        rad = atan2(h, a);
    }
    else
    {
        double w = s * 2 / b;
        rad = atan2(b, w);
    }

    double PI = acos(-1);
    double deg = rad / (2 * PI) * 360;
    printf("%.10f\n", deg);

    return 0;
}

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

int main(){
    int n,m,ans = 0;
    cin >> n >> m;
    char a[n][n],b[m][m];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++)cin >> a[i][j];
    }
    for(int i = 0;i < m;i++){
        for(int j = 0;j < m;j++)cin >> b[i][j];
    }
    int check = 1;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++,ans = 0){
            if(i+m-1 >= n && j+m-1 >= n)continue;
            for(int p = 0;p < m;p++){
                for(int q = 0;q < m;q++){
                    if(b[p][q] != a[i+p][j+q])++ans;
                }
            }
            if(ans == 0)check = 0;
        }
    }
    if(check == 0)cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  int x;
  cin>>x;
  if(x==0)
    cout<<1<<endl;
  else
    cout<<0<<endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

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

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int N;
    cin >> N;
    cout << N / 3 << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  while (true) {
    if (n >= 1000) {
      n -= 1000;
    } else {
      break;
    }
  }
  if (n == 0) {
    cout << n << endl;
  } else {
    cout << 1000 - n << endl;
  }
}


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

double rad = 3.1415926535897932;

int main(){
	int a, b, h, m;
  	cin >> a >> b >> h >> m;
	double hd = (double)(h*60 + m)/2.0;
    double md = 6*m;
  	double dg = min(abs(hd-md),abs(360-abs(hd-md)));
  	double y = pow(pow(a,2)+pow(b,2)-2*a*b*cos(dg*rad/180),0.5);
//  	cout << hd << " " << md << endl;
 	cout << fixed << setprecision(15) << y << endl;
}


Measured memory_bytes: 4280
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define inf 1000000000
#define mod 1000000007
using namespace std;
template <class T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <class T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;

int k;
int a[]={0 ,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
	cin>>k;
	cout<<a[k]<<endl;
	return 0;
}

Measured memory_bytes: 3632
# coding:utf-8


def main():
    N = int(input())
    ans = 0
    divisors = make_divisors(N)
    for d in divisors:
        m = d - 1
        if m > 0 and N % m == N//m:
            ans += m
    print(ans)
    return


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


if __name__ == "__main__":
    main()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
typedef long l;
l h,w,n,i;
l k(l a,l b){for(i=0;i<a;i++)n=min(n,max(i*b,(b/2+(b%2?1:0))*(a-i))-min(i*b,(b/2)*(a-i)));}
int main(){cin>>h>>w,n=h%3&&w%3?min(h,w):0,k(h,w),k(w,h),cout<<n;}


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

int main()
{
	int n,m,total,c;
	int p[10000];
	
	while(scanf("%d%d",&n,&m) && n != 0 && m != 0){
		for(int i = 0; i < n; i++){
			scanf("%d",&p[i]);
		}
		sort(&p[0],&p[n-1]+1);
		
		c = total = 0;
		for(int i = n-1; i >= 0; i--){
			c++;
			if(c % m != 0){
				total += p[i];
			}
		}
		
		printf("%d\n",total);
	}

	return 0;
}

Measured memory_bytes: 1216
#include <cstdio>
#include <cstring>
using namespace std;

const int N=100013;
char cc[N];

signed main(void)
{
	scanf("%s", cc);
	int len=strlen(cc);
	for(int i=0, j=len-1; i<=j; ++i, --j)
	{
		if(cc[i] == 'b')
			if(cc[j] != 'd')
				goto Ne;
		if(cc[i] == 'd')
			if(cc[j] != 'b')
				goto Ne;	
		if(cc[i] == 'p')
			if(cc[j] != 'q')
				goto Ne;
		if(cc[i] == 'q')
			if(cc[j] != 'p')
				goto Ne;					
	}
	puts("Yes");
	return 0;
	
	Ne:
		puts("No");
		return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ci cin
#define co cout
#define ed endl
#define vc vector
#define sr string
#define pb push_back
#define st(a,n) sort(a,a+n)
#define ms(a) memset(a,0,sizeof(a))
#define fr(i,k,n) for(int i=k;i<=n;++i)
#define FR(i,n,k) for(int i=n;i>=k;--i)
#define inf 0x3f3f3f3f
#define mod 10000019
#define maxn 1000
#define exp 1e-6
typedef long long ll;
using namespace std;
int main()
{
    string s;
    ci>>s;
    char a[20]={0};
    int pos=0;
    fr(i,0,s.size()-1)
    {
        if(s[i]=='B')
            pos=max(0,pos-1);
        else a[pos++]=s[i];
    }
    fr(i,0,pos-1)
    co<<a[i];
    co<<ed;
    return 0;
}


Measured memory_bytes: 256
count=gets.to_i
let=gets.chomp.split.map(&:to_i)
let2=gets.chomp.split.map(&:to_i)
answer=0
count.times do |timesCount|
  test=let[timesCount]-let2[timesCount]
  if test >0 then
      answer += test
  end      
end
puts(answer)

Measured memory_bytes: 1788
import sys
input = sys.stdin.readline

S = input().rstrip()
T = input().rstrip()
n = len(S)
s = []
t = []

for i in range(n):
	if S[i] in s:
		if t[s.index(S[i])] != T[i]:
			print("No")
			exit()
	else:
		s.append(S[i])
		t.append(T[i])

for i in range(n):
	if T[i] in t:
		if s[t.index(T[i])] != S[i]:
			print("No")
			exit()
	else:
		s.append(S[i])
		t.append(T[i])


print("Yes")

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main(){
    int H, W, K; cin >> H >> W >> K;
    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    --x1; --x2; --y1; --y2;
    vector<string> c(H);
    for(auto& s : c) cin >> s;
    vector dist = vector(H, vector(W, -1));
    queue<pair<int, int>> qu; qu.emplace(x1, y1);
    dist[x1][y1] = 0;
    while(!qu.empty()){
        auto p = qu.front(); qu.pop();
        int dx[] = {-1, 0, 1, 0};
        int dy[] = {0, -1, 0, 1};
        for(int d=0;d<4;d++){
            for(int i=1;i<=K;i++){
                int nx = p.first + i * dx[d];
                int ny = p.second + i * dy[d];
                if(nx < 0 || H <= nx || ny < 0 || W <= ny || c[nx][ny] == '@') break;
                if(dist[nx][ny] != -1 && dist[nx][ny] < dist[p.first][p.second] + 1) break;
                if(dist[nx][ny] == -1){
                    dist[nx][ny] = dist[p.first][p.second] + 1;
                    qu.emplace(nx, ny);
                }
            }
        }
    }
    cout << dist[x2][y2] << endl;
}


Measured memory_bytes: 12096
from collections import Counter
n=int(input())
a=list(map(int,input().split()))

f=Counter(a[0::2]).most_common(2)
b=Counter(a[1::2]).most_common(2)

if f[0][0]!=b[0][0]:print(n-f[0][1]-b[0][1]);exit()

if f[0][1]==n//2:print(n//2)
else:print(n-b[0][1]-f[1][1] if f[1][1]>b[1][1] else n-f[0][1]-b[1][1])

Measured memory_bytes: 21384
#include<stdio.h>
#include<utility>

int main(){
    int n,c=0;
    scanf("%d",&n);
    int a[n];
    for(int i = 0;i < n;i++){
        scanf("%d",&a[i]);
    }
    bool flag = 1;
    while(flag){
        flag = 0;
        for(int i = n-1; i >= 1;i--){
            if(a[i] < a[i-1]){
                std::swap(a[i],a[i-1]);
                c++;
                flag =1;
            }
        }
    }
    
    for(int i = 0;i < n;i++){
        if(i != n-1){
            printf("%d ",a[i]);
        } else {
            printf("%d\n",a[i]);
        }
    }
    printf("%d\n",c);
    
}



Measured memory_bytes: 2736
import std;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "base", long, "cnt");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto N = lread();
    auto p = N.make_primeF_pairs();
    long bseach(long t)
    {
        long ok = -1, ng = t + 1;
        while (abs(ok - ng) > 1)
        {
            auto mid = (ok + ng) / 2;
            if (mid * (mid + 1) / 2 <= t)
                ok = mid;
            else
                ng = mid;
        }
        // ok.writeln();
        return ok;
    }

    long ans;
    p.each!(x => ans += bseach(x.cnt));
    ans.writeln();
}

auto factors(long N)
{
    long iter = 1;
    long[] ret;
    while (true)
    {
        if (iter ^^ 2 > N)
            break;
        if (!(N % iter))
            ret ~= only(iter, N / iter).array();

        iter++;
    }
    return ret;
}

auto primeFactors(long N)
{
    auto fs = N.factors();
    auto ret = fs.filter!(x => x != 1 && x.factors.length == 2).array();
    return ret;
}

auto make_primeF_pairs(long N)
{
    auto pfps = N.primeFactors();
    Pair[] ret;
    foreach (e; pfps)
    {
        long cnt;
        while (!(N % e))
        {
            cnt++;
            N /= e;
        }
        ret ~= Pair(e, cnt);
    }
    return ret;
}

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


Measured memory_bytes: 5264
import sys

sys.setrecursionlimit(10**9)
INF=float('inf')

n,m=map(int,input().split())
adj=[[] for _ in range(n+1)]
for _ in range(m):
  x,y=map(int,input().split())
  adj[x].append(y)
  
dp=[-1 for _ in range(n+1)]

def f(k):
  if dp[k]!=-1:
    return dp[k]
  
  dp[k]=0
  if adj[k]:
    for v in adj[k]:
      dp[k]=max(dp[k],f(v)+1)
  return dp[k]

ans=-INF  
for i in range(1,n+1):
  ans=max(ans,f(i))

print(ans)

Measured memory_bytes: 196460
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

//char arr[107][107];
int main(){
	Lancer();
	ll n, tm, a, t, res = 100000000;
	cin >> n >> tm;
	for (int i = 0; i < n; i++){
		cin >> a >> t;
		if (t <= tm)
			res = min(res, a);
	}
	if (res != 100000000)cout << res;
	else cout << "TLE";
	cout << endl;
	return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 100000
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0
using namespace std;
signed main() {
	int n;
	cin>>n;
	if(n%2){
		cout<<n*(n-1)/2-(n-1)/2<<endl;
		for(int i=1;i<n;i++){
			cout<<i<<" "<<n<<endl;
		}
		for(int i=1;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(i+j!=n&&i!=j)cout<<i<<" "<<j<<endl;
			}
		}
	}
	else{
		cout<<n*(n-1)/2-n/2<<endl;
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if(i+j!=1+n)cout<<i<<" "<<j<<endl;
			}
		}
	}
	ggr;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

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

int main() {
  int N, M;
  cin >> N >> M;
  int X, Y;
  cin >> X >> Y;

  vector<int> x(N);
  rep(i, N) cin >> x[i];
  vector<int> y(M);
  rep(i, M) cin >> y[i];

  sort(all(x));
  sort(all(y));

  if (x[N - 1] < y[0] && X < y[0] && x[N - 1] < Y) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}

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

int main(){
    int h, m, s, S;
    cin >> S;
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 3600 % 60;
    cout << h<<":"<< m <<":"<< s << endl;
    return 0;
    
}


Measured memory_bytes: 3092
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

if m % 2 == 1:
    print(-1)
    exit()

ans = []

depth = [-1] * n
deg = [0] * n
def dfs(v, pr):
    for nv in g[v]:
        if nv == pr:
            continue
        if depth[nv] != -1:
            if depth[nv] < depth[v]:
                ans.append((v, nv))
                deg[v] += 1
        else:
            depth[nv] = depth[v] + 1
            dfs(nv, v)
            if deg[nv] % 2 == 0:
                ans.append((v, nv))
                deg[v] += 1
            else:
                ans.append((nv, v))
                deg[nv] += 1

depth[0] = 0
dfs(0, -1)

for i, j in ans:
    print(i + 1, j + 1)






Measured memory_bytes: 116368
#include <stdio.h>
    int main()
    {
    	int num[4] = { 0,-1,-1,-1 };
    	int N, M, s, c;
    	scanf("%d %d", &N, &M);
    	for (int i = 1;i <= M;i++)
    	{
    		scanf("%d %d", &s, &c);
    		if (num[s] == -1 || num[s] == c)
    			num[s] = c;
    		else
    		{
    			printf("-1");
    			return 0;
    		}
    	}
    	if (num[1] == 0)
    	{	
    		if (N > 1)
    		{
    			printf("-1");
    			return 0;
    		}
    	}
    	if (num[1] == -1)
    	{
    		if (N > 1)
    			num[1] = 1;
    	}
    	for (int i = 1;i <= N;i++)
    	{
    		if (num[i] == -1)
    			num[i] = 0;
    		printf("%d", num[i]);
    	}
    	return 0;
    }

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

int main()
{
    string S, T;
    cin >> S >> T;
    int max_same = 0;
    int countsame;
    for (int i = 0; i < S.size(); i++)
    {
        if (i + T.size() <= S.size())
        {
            countsame = 0;
            for (int j = 0; j < T.size(); j++)
            {
                if (S.at(i + j) == T.at(j))
                {
                    countsame++;
                }
            }
            if (countsame > max_same)
            {
                max_same = countsame;
            }
        }
    }
    int ans = T.size() - max_same;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
void mmin(int &a, int b) {
	a = min(a, b);
}
void mmax(int &a, int b) {
	a = max(a, b);
}
int nibl(vel &v, int tan) {
	int up = v.size() - 1;
	int lo = 0;
	if (v[up] <= tan) return up;
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (v[mi] <= tan) lo = mi;
		if (tan < v[mi]) up = mi;
	}
	return lo;
}
signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	int p0 = 0;
	int p1 = 0;
	int p2 = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x <= a) {
			p0++;
		}
		else if (x <= b) {
			p1++;
		}
		else {
			p2++;
		}
	}
	cout << min(min(p0, p1), p2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main(){	
	long long a,b;
	cin>>a>>b;
	for(int i=0;i<=1000000000;i++){
		if(abs(a-i)==abs(b-i)){
			cout<<i;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
    return 0;
} 

Measured memory_bytes: 256
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
 
(defconstant inf 1000000)
(defvar *n* (read))
(defvar *hi* (make-array *n*))
 
;dp[i]→i番目にたどり着くための最小コスト
(defvar *dp* (make-array *n* :initial-element nil))
 
(dotimes (i *n*)
         (setf (aref *hi* i) (read)))
 
(defun cost (now delta)
   (abs (- (aref *hi* now) (aref *hi* (- now delta)))))
 
;dpテーブル初期化
(setf (aref *dp* 0) 0)
(setf (aref *dp* 1) (cost 1 1))
 
(defun ans (i)
  (cond
    ((aref *dp* i) (aref *dp* i))
    (t (setf (aref *dp* i) (min
                            (+ (ans (- i 1)) (cost i 1))
                            (+ (ans (- i 2)) (cost i 2))
                            )))))
                                         
 
(print (ans (1- *n*)))

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

const int MAX_N	= 100000;
char S[ MAX_N + 5 ];

int main()
{
int iLen;
int iA;
int iB;
char C;

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

	cin >> S;

	iLen = strlen( S );
	iA = iLen / 2;
	iB = iLen - iA;
	if( iA == iB )
	{
		C = S[ iB ];
		iA--;
		if( C != S[ iA ] )
		{
			cout << iB << endl;

			return 0;
		}
	}
	else
	{
		C = S[ iA ];
		iA--;
	}

	while( iA >= 0 && iB < iLen )
	{
		if( C != S[ iA ] || C != S[ iB ] )
		{
			cout << iB << endl;

			return 0;
		}

		iA--;
		iB++;
	}

	cout << iLen << endl;

	return 0;
}




Measured memory_bytes: 384
a,b,c,x,y = map(int,input().split())
c *= 2
ans = 0
z = min(x,y)
if x >= y:
    w = x-z
    v = a
else:
    w = y-z
    v = b

ans += min(a+b,c)*z

ans += min(v,c)*w

print(ans)

Measured memory_bytes: 38256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

// 二部グラフ判定
func isBipartite(s []string) bool {
	n := len(s)
	// -1:白, 0:無色, 1:黒
	colors := make([]int, n)
	var dfs func(i, color int) bool
	dfs = func(i, color int) bool {
		colors[i] = color
		for j := range s[i] {
			if s[i][j] == '0' {
				continue
			}
			if colors[j] == color {
				return false
			}
			if colors[j] == 0 && !dfs(j, -color) {
				return false
			}
		}
		return true
	}
	for i := range s {
		if colors[i] == 0 && !dfs(i, 1) {
			return false
		}
	}
	return true
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	const inf = 1 << 50

	n := nextInt()
	s := make([]string, n)
	for i := range s {
		s[i] = next()
	}

	if !isBipartite(s) {
		puts(-1)
		return
	}

	// ワーシャルフロイド
	dist := make([][]int, n)
	for i := range dist {
		dist[i] = make([]int, n)
		for j := range dist[i] {
			dist[i][j] = inf
		}
	}
	for i := 0; i < n; i++ {
		dist[i][i] = 0
		for j := 0; j < n; j++ {
			if s[i][j] == '1' {
				dist[i][j] = 1
			}
		}
	}
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
			}
		}
	}

	// 直径
	d := 0
	for i := range dist {
		d = max(d, max(dist[i]...))
	}
	puts(d + 1)
}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int64_t soujo(int64_t x, int64_t y) //x ~ yの積
{
    if (y < x)
        swap(x, y);
    if (x == y)
        return y;
    else
        return x * soujo(x + 1, y) % mod;
}

int main()
{
    int64_t N, M;
    cin >> N >> M;
    int64_t ans = 0;
    if (N == M)
        ans = 2 * soujo(1, N) * soujo(1, N) % mod;
    if (abs(N - M) == 1)
        ans = soujo(1, M) * soujo(1, N) % mod;
    cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long

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

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

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; 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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
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 modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	string s;
	cin>>s;
	int q;
	cin>>q;
	bool p=true;
	vector<char> front,back;
	rep(i,q){
		int f;
		cin>>f;
		if(f==1)p=(!p);
		else{
			int ff;
			cin>>ff;
			char c;
			cin>>c;
			if(p){
				if(ff==1)front.push_back(c);
				else back.push_back(c);
			}else{
				if(ff==2)front.push_back(c);
				else back.push_back(c);
			}
		}
	}
	reverse(front.begin(),front.end());
	rep(i,s.size())front.push_back(s[i]);
	rep(i,back.size())front.push_back(back[i]);
	if(p==false)reverse(front.begin(),front.end());
	rep(i,front.size())cout<<front[i];
	cout<<endl;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n, n){
        long long a[1120];
        range(i,1,1120) a[i] = i * i * i;
        long long res = 0;
        range(i,1,n){
            range(j,1,n){
                if(a[i] + a[j] > a[n]) continue;
                res = max(res, a[i] + a[j]);
            }
        }
        cout << a[n] - res << endl;
    }
}

Measured memory_bytes: 1164
N = gets.to_i
a = gets.split(' ').map(&:to_i)
b = a.map(&:abs).sort

minus = (a.select{|i| i < 0}.size)&1
if minus == 0
	sum = b.inject(:+)
else
	sum = b.inject(:+) - b[0]*2
end

puts sum


Measured memory_bytes: 11000
import collections
N = int(input())
a = ['']*N
for i in range(N):
    a[i] = list(input())[0]
c_list = [0]*5
MARCH = ['M','A','R','C','H']
c_list = [a.count(i) for i in MARCH]
summation = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            summation += c_list[i]*c_list[j]*c_list[k]
print(summation)

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    int N; cin >> N;
    N = N % 10;
    if (N == 3){
        puts("bon");
    }else if ((N == 0) or (N == 1) or (N == 6) or (N == 8)){
        puts("pon");
    }else{
        puts("hon");
    }
}

Measured memory_bytes: 3636