akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost {ios_base::sync_with_stdio(false);}
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PII, PII> PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
typedef vector <int> vi;
const int mod = 1e9+7;
const int inf = 1e9+10;
const ll MOD = 1e9+696969;
const ll INF = 1e18;
const int W = 1e9;
#define maxn 201009
bool ok[maxn];
int tab[maxn], small[maxn], n;
ll ans[maxn];
priority_queue <int> q;
ll lastans;
int main()
{
	boost;
	lastans = 0;
	cin >> n;
	int MAKS = 0;
	ll sumall = 0;
	FOR(i, 1, n)
	{
		cin >> tab[i];
		sumall += tab[i];
		if (tab[i] > MAKS) ok[i] = 1, small[i] = MAKS, MAKS = tab[i];
	}

	ll suma = 0, ile = 0;
	for (int i=n; i>0; --i)
	{
		q.push(tab[i]);
		if (!ok[i]) continue;
		while (!q.empty() && q.top() > small[i])
		{
			ll val = q.top();
			q.pop();
			suma += val;
			ile++;
		}
		ans[i] = suma - ile * small[i] - lastans;
		lastans += ans[i];
	}
	
	//ans[1] = sumall - lastans;
	FOR(i, 1, n) cout << ans[i] << "\n";
}


Measured memory_bytes: 2816
#encoding=utf-8
import sys
data1, data2 = [], []


while True:
    x = map(int, raw_input().split(","))
    if sum(x) == 0:
        break
    data1.append([x[1], x[0]])

i = 1
data1 = sorted(data1)[::-1]
data1[0].insert(2,1)
ma = data1[0][0]

while True:
    if ma == data1[i][0]:
        data1[i].insert(2, (data1[i - 1][2]))
    elif ma > data1[i][0]:
        data1[i].insert(2,((data1[i - 1][2]) + 1))
        ma = data1[i][0]
    i += 1
    if i >= len(data1):
        break


for i in sys.stdin:
    for j in xrange(len(data1)):
        if int(i) == data1[j][1]:
            print data1[j][2]
            break

Measured memory_bytes: 6408
#include <stdio.h>

int main(void) {
	int i, j, len;
	int f = 1;
	char c;
	char s[200001] = {}, t[200001] = {};
	scanf("%s%s", s, t);
	for (i = 0; i < strlen(s); i++) {
		if (s[i] != t[i]) {
			c = t[i];
			for (j = 0; j < strlen(s); j++) {
				if (t[j] == s[i] || t[j] == c) {
					if (t[j] == c) t[j] = s[i];
					else if (t[j] == s[i]) t[j] = c;
					if (i > j) f = 0;
					if (f == 0) break;
				}
			}
		}
		if (f == 0) break;
	}
	printf(f ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 512
A, B = map(int, input().split())

sum = 0

for n in range(A, B+1):
    rev = 0
    m = n
    while n != 0:
        dig = n % 10
        rev = rev*10+dig
        n = n//10
    if(m == rev):
        sum += 1
print(sum)



Measured memory_bytes: 9124
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt")
#endif

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int M = 10;

vector<pair<int, int>> solve_knapsack(vector<int> cost, vector<int> w) {
	vector<pair<int, int>> ans;
	int n = (int)cost.size();
	for (int mask = 0; mask < (1 << n); mask++) {
		int sum_cost = 0;
		int sum_w = 0;
		for (int i = 0; i < n; i++) {
			if ((mask >> i) & 1) {
				sum_cost += cost[i];
				sum_w += w[i];
			}
		}
		ans.push_back({sum_w, sum_cost});
	}
	sort(ans.begin(), ans.end());
	vector<pair<int, int>> nans;
	int mx = -1;
	for (auto [wt, cst] : ans) {
		if (mx < cst) {
			nans.push_back({wt, cst});
			mx = cst;
		}
	}
	return nans;
}

int solve(vector<int> cost, vector<int> w, vector<pair<int, int>> &lp, int L) {
	auto rp = solve_knapsack(cost, w);
	int pnt = (int)rp.size() - 1;
	int ans = 0;
	for (auto [sw, sc] : lp) {
		while (pnt >= 0 && sw + rp[pnt].first > L) {
			pnt--;
		}
		if (pnt >= 0) {
			ans = max(ans, sc + rp[pnt].second);
		}
	}
	return ans;
}

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

	int n;
	cin >> n;
	vector<int> h(n + 1);
	vector<int> cost(n + 1);
	vector<int> w(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> cost[i] >> w[i];
		if (i > 1) {
			h[i] = h[i / 2] + 1;
		}
	}
	vector<vector<pair<int, int>>> knacks(n + 1);
	for (int i = 1; i <= n; i++) {
		if (h[i] <= M) {
			vector<int> cc;
			vector<int> cw;
			int v = i;
			while (v > 0) {
				cc.push_back(cost[v]);
				cw.push_back(w[v]);
				v /= 2;
			}
			// cerr << "+ " << i << endl;
			knacks[i] = (solve_knapsack(cc, cw));
		}
	}
	int q;
	cin >> q;
	while (q--) {
		int v, L;
		cin >> v >> L;
		vector<int> cc;
		vector<int> cw;
		while (h[v] > M) {
			cc.push_back(cost[v]);
			cw.push_back(w[v]);
			v /= 2;
		}
		// assert(h[v] <= M);
		// cerr << v << endl;
		cout << solve(cc, cw, knacks[v], L) << '\n';
	}
}


Measured memory_bytes: 34128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double x, sum = 0;
	string s;
	cin >> n;
	while (n--){
		cin >> x >> s;
		if(s == "BTC") x *= 380000.0;
		sum += x;
	}
	cout << fixed << setprecision(6) <<  sum << endl;
	return 0;
} 

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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    vector<int> D(N,0);
    map<int, int> d;
    map<int, int> t;
    for(int i = 0; i < N; i++) {
        cin >> D.at(i);
        if(!d.count(D.at(i))) {
            d[D.at(i)] = 0;
        }
        d.at(D.at(i))++;
    }
    int M = 0;
    cin >> M;
    vector<int> T(M,0);
    for(int i = 0; i < M; i++) {
        cin >> T.at(i);
        /*
        if(!t.count(T.at(i))) {
            d[T.at(i)] = 0;
        }
        t.at(T.at(i))++;
        */
    }

    for(int i = 0; i < M; i++) {
        if(!d.count(T.at(i))) {
            cout << "NO" << endl;
            return 0;
        }
        if(d.at(T.at(i)) == 0) {
            cout << "NO" << endl;
            return 0;
        }
        d.at(T.at(i))--;
    }
    cout << "YES" << endl;



    return 0;
}

Measured memory_bytes: 13996
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>a>>b>>c;
    if(a>b&&a>c){
        if(b<c)swap(b,c);
    }else if(b>a&&b>c){
        swap(a,b);
        if(b<c) swap(b,c);
    }else{
        swap(a,c);
        if(b<c) swap(b,c);
    }
    cout<<abs(c-b+b-a)<<endl;
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>

using namespace std;

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

    string S;
    cin >> S;

    vector<char> S_(S.begin(), S.end());

    int result { 0 };

    vector<char> resultChars {};

    char prev = S_[0];
    resultChars .push_back(prev);
    for (int i { 1 }; i < N; ++i) {
        char current = S_[i];
        if (prev != current) {
            resultChars .push_back(current);
            prev = current;
        }
    }

    string resultStr(resultChars.begin(), resultChars.end());

    cout << resultStr.size() << endl;

    return 0;
}


Measured memory_bytes: 1144
import string

if __name__ == '__main__':
    A = input()

    p = {}
    for x in string.ascii_lowercase:
        p[x] = len(A)
    # print(p)
    '''
    tb
    1つ目：
    2つ目：アルファベット
    3つ目：
    '''
    tb = [(0, 0, 0)] * len(A)
    tb.append((1, 0, 0))
    tb.append((0, 0, 0))
    # print(tb)
    for i, x in reversed(list(enumerate(A))):
        p[x] = i
        tb[i] = min([(tb[p[c] + 1][0] + 1, c, p[c] + 1) for c in string.ascii_lowercase])
        # print(tb)
    i = 0
    ans = []
    while i < len(A):
        ans.append(tb[i][1])
        i = tb[i][2]

    print("".join(ans))


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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define CONTAINS(a, x) (a.find(x) != a.end())
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define nl cout << endl
#define F first
#define S second

#define what_is(x) cout << #x << " = " << x << endl
#define boost ios::sync_with_stdio(false);cin.tie(NULL)
#define CASET int ___T, case_n = 1; cin >> ___T; while (___T-- > 0) 


#define rep(it, st, en) for(ll it = st; it < en; it++)
#define rep1(it, st, en) for(ll it = st; it <= en; it++)
#define per(it, st, en) for(ll it = en - 1; it >= st; it--)

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef vector<vi> vvi;

ll INF = 1E9;
ll M = 1E9 + 7;

inline ll max_(ll a, ll b) { return (a>b)?a:b; }
inline ll min_(ll a, ll b) { return (a<b)?a:b; }

inline ll power (ll a,ll p){
    ll res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x );
        x = ( x * x ); p >>= 1;
    }
    return res;
}

template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

int main() {
    boost;
    if(fopen("inp.txt", "r")){
      freopen("inp.txt", "r", stdin);
      freopen("outp.txt", "w", stdout);
    }

    ll n;

    cin>>n;

    ll a[n],i;
    ll H[100006];
    memset(H,0,sizeof(H));

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

    ll ans=H[0];

    for (i=1;i<=100001;i++) {
        // cout<<ans<<" ";
        ans=max_(ans,H[i-1]+H[i]+H[i+1]);
    }


    cout<<ans;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define F first
#define S second
#define mset(x,v) memset(x, v, sizeof(x))
#define left(x) 2*x
#define right(x) (2*x) + 1
#define ALL(t) (t).begin(),(t).end() 
#define ret return 0
#define all(x) x.begin(),x.end()
int main()
{
    boost;
            ll n,ans=0;
            cin>>n;
            ll arr[n];
            forn(i,n)
            cin>>arr[i];
            
            forn(i,n)
            {
                  for(int j=i+1;j<n;j++)
                  {
                        ans=max(ans,abs(arr[i]-arr[j]));
                  }
            }
            cout<<ans<<endl;
}
    

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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int>v,dummy;
    for(int i=0; i<n; i++)
    {
        int in;
        cin>>in;
        v.push_back(in);
    }
    dummy=v;
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++)
    {
        if(dummy[i]>v[n/2-1])
        {
            cout<<v[n/2-1]<<endl;
        }
        else
        {
            cout<<v[n/2]<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3956
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    aa=LI()
    if sum(aa)>=22:
        print("bust")
    else:
        print("win")
main()

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	set<int> s = { 1,2,3 };
	int x; cin >> x;
	int y; cin >> y;
	s.erase(y);
	s.erase(x);
	cout << *s.begin() << endl;
	return 0;
}

/*

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

const int INF = 4e18;

int n, m, k, s, p, q;
int c[100010], a[200010], b[200010];

int price[100010];
VI node[100010];

queue<int> qu;
bool zombi[100010];
bool visited[100010];

int cheap[100010];
priority_queue<PII, VP, greater<PII> > pq;

void bfs()
{
  for(int i = 0; i < k; i++){
    qu.push(c[i]);
    zombi[c[i]] = true;
  }

  for(int i = 0; i <= s; i++){
    int sz = qu.size();

    for(int j = 0; j < sz; j++){
      int now = qu.front();
      qu.pop();

      if(!visited[now]){
	visited[now] = true;

	for(auto pt:node[now]){
	  qu.push(pt);
	}
      }
    }
  }
}

void dijk()
{
  memset(cheap, -1, sizeof cheap);
  pq.push(MP(0, 1));
  while(!pq.empty()){
    PII now = pq.top();
    pq.pop();
    if(cheap[now.S] == -1){
      cheap[now.S] = now.F;

      for(auto pt:node[now.S]){
	if(!zombi[pt]){
	  pq.push(MP(now.F + price[pt], pt));
	}
      }
    }
  }
}
     
signed main()
{
  scanf("%lld%lld%lld%lld%lld%lld", &n, &m, &k, &s, &p, &q);
  for(int i = 0; i < k; i++){
    scanf("%lld", &c[i]);
  }
  for(int i = 0; i < m; i++){
    scanf("%lld%lld", &a[i], &b[i]);
  }
  
  for(int i = 0; i < m; i++){
    node[a[i]].PB(b[i]);
    node[b[i]].PB(a[i]);
  }

  bfs();

  for(int i = 2; i <= n - 1; i++){
    price[i] = visited[i] ? q : p;
  }

  dijk();

  printf("%lld\n", cheap[n]);
  
  return 0;
}

Measured memory_bytes: 17124
#ifdef __APPLE__
#include <cassert>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <cctype>
#include <list>
#include <cmath>
#include <limits>
#include <bitset>
#include <numeric>
#include <climits>
#include <complex>
#else
#include<bits/stdc++.h>
#endif // __APPLE__
using namespace std;
typedef pair<int,int>   II;
typedef vector<II>     VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int LL;
typedef  unsigned long long int ULL;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define SET(a,b) memset(a,b,sizeof(a))
#define LET(x,a) __typeof(a) x(a)
#define ALL(c) (c).begin(),(c).end()
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i,a,b) for(int i = (int)a; i < (int)b; i++)
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)	{
cerr << name << " : " << arg1 << std::endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
     const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif
//A






int main()
{
	//fr;fw;
	fast_io;
    int a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<"Draw"<<endl;
        return 0;
    }
    
    if(a==1)
    {
        cout<<"Alice"<<endl;
    }
    else if(b==1)
    {
        cout<<"Bob"<<endl;
    }
    else
    {
        if(a>b)
        {
            cout<<"Alice"<<endl;
        }
        else
        {
            cout<<"Bob"<<endl;
        }
    }



	return 0;
}





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

int main() {
  int n,m,r;
  cin>>n>>m>>r;
  vector<int> order;
  for(int i=0;i<r;++i) {
    int val;
    cin>>val;
    order.push_back(val);
  }
  sort(order.begin(),order.end());

  int d[201][201];
  for(int i=0;i<201;++i){
    for(int j=0;j<201;++j){
      d[i][j] = 1e9;
    }
  }
  for(int i=0;i<m;++i) {
    int a,b,c;
    cin>>a>>b>>c;
    d[a][b] = c;
    d[b][a] = c;
  }

  for(int k=1;k<n+1;++k){
    for(int i=1;i<n+1;++i){
      for(int j=1;j<n+1;++j){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }

  int ret = 1e9;
  do{
    int tmp = 0;
    for(int i=0;i<r-1;++i){
      tmp += d[order[i]][order[i+1]];
    }
    ret = min(ret, tmp);
  }while(next_permutation(order.begin(), order.end()));
  cout<<ret<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<string, string> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;


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

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

int main(){
    int n,l;
    cin >> n >> l;
    string s[100];
    string ans[100];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    
    for (int i = 0; i < n; i++) {
        int now = 0;
        string minu = "{";
        for (int j = 0; j < n; j++) {
            if (minu > s[j]) {
                minu= s[j];
                now = j;
            }
        }
        ans[i] = minu;
        s[now] = "}";
    }
    rep(i, n) cout << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
while (1){
long n,dset[5000],temp=0,max;
cin>>n;
if (n==0)break;
for (int i=0;i<n;i++){
        cin>>dset[i];
}
max=-1000000;
for (int i=0;i<n;i++){
        for (int j=i;j<n;j++){
                temp=temp+dset[j];
                if (max<temp){
                        max=temp;
                }
        }
temp=0;
}
cout<<max<<endl;
}
return 0;
}

Measured memory_bytes: 3124
import java.util.*;

public class Main {

	public static void main(String[] args) {
			
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String S0 = S.substring(0, S.length()/2);
		String S1 = S.substring((S.length()+3)/2-1);
		//System.out.println(S0+"  "+S1);
		boolean ans = true;
		for (int i = 0; i < S.length()/2; i++) {
			if (S.charAt(i) != S.charAt(S.length()-1-i)) {
				ans = false;
				break;
			}
		}

		for (int i = 0; i < (S0.length()-1)/2; i++) {
			if (S.charAt(i) != S.charAt(S0.length()-1-i))
				ans = false;
		}

		for (int i = 0; i < S1.length(); i++) {
			if (S.charAt(i) != S.charAt(S1.length()-1-i))
				ans = false;
		}
		if (ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21844
import qualified Data.Vector         as V
import qualified Data.Vector.Mutable as VM
import Control.Applicative
import Control.Monad
import Data.IORef

-- 1 selectionSort(A, N) // N個の要素を含む0-オリジンの配列A
-- 2   for i が 0 から N-1 まで
-- 3     minj = i
-- 4     for j が i から N-1 まで
-- 5       if A[j] < A[minj]
-- 6         minj = j
-- 7     A[i] と A[minj] を交換

selectionSort :: [Int] -> IO ([Int], Int)
selectionSort xs = do
  aVec <- V.thaw $ V.fromList xs
  let len = length xs - 1
  c <- newIORef 0
  forM_[0 .. len] $ \i -> do
    mini <- newIORef i
    forM_ [i .. len] $ \j -> do
      v1 <- VM.read aVec j
      k  <- readIORef mini
      v2 <- VM.read aVec k
      when (v1 < v2) $ writeIORef mini j
    k <- readIORef mini
    -- print (i, k)
    when (i /= k) $ do
      VM.swap aVec i k
      modifyIORef c (+ 1)
  list  <- V.toList <$> V.freeze aVec
  count <- readIORef c
  return (list, count)

main :: IO ()
main = do
  _  <- getLine
  xs <- map read . words <$> getLine
  (ys, c) <- selectionSort xs
  putStrLn $ unwords $ map show ys
  print c



Measured memory_bytes: 4444
# include <algorithm>
# include <cassert>
# include <cctype>
# include <cstdio>
# include <cstdlib>
# include <cstring>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <set>
# include <sstream>
# include <stack>
# include <string>
# include <vector>
# include <iomanip>

# define rep(i, n) for (int i = 0; i < (int)(n); i++)
# define irep(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define FOR(i, m, n) for (int i = int(m); i < (int)(n); i++)

using namespace std;
typedef long long ll;


// %% NOTE : begin matrix %%

typedef vector<int> vec;
typedef vector<vec> mat;

void pretty_print(mat g) {
  rep (i, g.size()) {
    rep (j, g[0].size()-1) {
      cout << g[i][j] << ' ';
    }
    cout << g[i][g[0].size()-1] << endl;
  }
}


mat mul(mat A, mat B) {
  mat C(A.size(), vec(B.size()));
  rep (i, A.size()) {
    rep (k, B.size()) {
      rep (j, B[0].size()) {
        C[i][j] += A[i][k] * B[k][j];
      }
    }
  }
  return C;
}

// %% NOTE : end matrix %%


int main() {

  float a, b, h;

  cin >> a >> b >> h;

  int ans = ((a+b) * h) / 2;

  cout << ans << endl;
}


Measured memory_bytes: 256
//Using FeatherPad
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#define problem_solving ios::sync_with_stdio(0);cin.tie(0);
#define oo (int)1e9 + 10
#define all(x) x.begin(), x.end()
using namespace std;

void solve(int case_number) {
	int n;
	cin >> n;
	vector<int> freq(n + 1);
	for(int i = 0, x; i < n - 1; i++)
		cin >> x, freq[x]++;
	for(int i = 1; i <= n; i++)
		cout << freq[i] << endl;
}


int main() {
	problem_solving
	int cases = 1;
	//cin >> cases;
	for(int i=0;i<cases;i++)
		solve(i + 1);
	return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
struct UnionFind{
    vi data;
    UnionFind(int size):data(size,-1){}
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    vi a(n);
    REP(i,n){
        cin>>a[i];
        a[i]--;
    }
    UnionFind uf(n);
    REP(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
    }
    int ans=0;
    REP(i,n){
        if(uf.find(i,a[i])){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#define NODE_SIZE 101

using namespace std;

struct tStamp
{
    int dsc;    //discovery
    int fin;    //finish
};

void dfs(int node, int adj[][NODE_SIZE], tStamp s[], int *cnt, int n){
    s[node].dsc = *cnt;   *cnt += 1;
    for(int i = 1; i <= n; i++){
        if(adj[node][i] && s[i].dsc == 0){
            dfs(i, adj, s, cnt, n);
        }
    }
    s[node].fin = *cnt;   *cnt += 1;
}

int main(){
    int n, u, k, v, cnt = 1;
    int adj[NODE_SIZE][NODE_SIZE] = {};
    tStamp stamp[NODE_SIZE];

    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> u >> k;
        while(k--){
            cin >> v;
            adj[u][v] = 1;
        }
    }

    for(int i = 1; i <= n; i++){
        if(stamp[i].dsc == 0){
            dfs(i, adj, stamp, &cnt, n);
        }
        cout << i << " " << stamp[i].dsc << " " << stamp[i].fin << endl;
    }

    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

vector< pair<int,int> > ans;

bool solve(int N) {
  if (__builtin_popcount(N) == 1) return false;


  for (int p = 2; p + 1 <= N; p += 2) {
    ans.push_back({ N+p, N+p+1 });
    ans.push_back({ N+p+1, 1 });
    ans.push_back({ 1, p });
    ans.push_back({ p, p+1 });
  }
  ans.push_back({N+1, 3});


  if (N % 2 == 0) {
    int x = 1 << (31 - __builtin_clz(N ^ 1));
    int y = (N ^ 1) ^ x;

    if (x % 2) x += N;
    if (y % 2) y += N;
    ans.push_back({N,   x});
    ans.push_back({N+N, y});
  }

  return true;
}

int main2() {
  int N = nextLong();
  ans.clear();

  bool res = solve(N);
  if (res) {
    cout << "Yes" << endl;
    REP(i, ans.size()) {
      cout << ans[i].first << " " << ans[i].second << '\n';
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 5280
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,k;
  cin>>n>>k;
  Int x[n],y[n];
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];
  vector<Int> vx(n),vy(n);
  
  for(Int i=0;i<n;i++) {
    vx[i]=x[i];
    vy[i]=y[i];
  }
  sort(vx.begin(),vx.end());
  //vx.erase(unique(vx.begin(),vx.end()),vx.end());
  sort(vy.begin(),vy.end());
  //vy.erase(unique(vy.begin(),vy.end()),vy.end());
  Int ans=(vx.back()-vx.front())*(vy.back()-vy.front());
  
  for(Int i=0;i<(Int)vx.size();i++){
    for(Int j=0;j<(Int)vy.size();j++){
      for(Int a=i+1;a<(Int)vx.size();a++){	
	for(Int b=j+1;b<(Int)vy.size();b++){
	  Int c=0;
	  for(Int l=0;l<n;l++){
	    if(vx[i]<=x[l]&&x[l]<=vx[a]&&vy[j]<=y[l]&&y[l]<=vy[b]) c++;
	  }
	  if(c>=k) ans=min(ans,(vx[a]-vx[i])*(vy[b]-vy[j]));
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace _515_SchoolRoad
{
	class Program
	{
		static void Main ( string[] args )
		{
			while (true)
			{
				//input
				int[] roadCount = Console.ReadLine ().Split (' ').Select (str => int.Parse (str)).ToArray ();

				bool isEnd = roadCount.All (item => item == 0);
				if (isEnd)
				{
					break;
				}

				int constructionCount = int.Parse (Console.ReadLine ());

				Point[] constructionPoint = new Point[constructionCount];

				for (int lp = 0; lp < constructionPoint.Length; lp++)
				{
					int[] array = Console.ReadLine ().Split (' ').Select (str => int.Parse (str)).ToArray ();
					constructionPoint[lp] = new Point (array[0] - 1, array[1] - 1);
				}

				//process
				int[,] rootCount = new int[roadCount[0], roadCount[1]];

				//??????????????????-1????¨??????????
				foreach (var item in constructionPoint)
				{
					rootCount[item.X, item.Y] = -1;
				}

				//???????????¨??????????????¨???1?????????
				//?????????
				for (int col = 0; col < rootCount.GetLength (0); col++)
				{
					if (rootCount[col, 0] != -1)
					{
						rootCount[col, 0] = 1;
					}
					else
					{
						for (; col < rootCount.GetLength (0); col++)
						{
							rootCount[col, 0] = -1;
						}
					}
				}
				//?????????
				for (int row = 0; row < rootCount.GetLength (1); row++)
				{
					if (rootCount[0, row] != -1)
					{
						rootCount[0, row] = 1;
					}
					else
					{
						for (; row < rootCount.GetLength (1); row++)
						{
							rootCount[0, row] = -1;
						}
					}
				}

				//???????????°?????????
				for (int col = 1; col < rootCount.GetLength (0); col++)
				{
					for (int row = 1; row < rootCount.GetLength (1); row++)
					{
						if (rootCount[col, row] != -1)
						{
							//????????\???
							if (rootCount[col - 1, row] == -1)
							{
								rootCount[col, row] = rootCount[col, row - 1];
							}
							//????????\???
							else if (rootCount[col, row - 1] == -1)
							{
								rootCount[col, row] = rootCount[col - 1, row];
							}
							//??\?????????????????????
							else
							{
								rootCount[col, row] = rootCount[col - 1, row] + rootCount[col, row - 1];
							}
						}
					}
				}

				//output
				int result = rootCount[rootCount.GetLength (0) - 1, rootCount.GetLength (1) - 1];
				Console.WriteLine (result);
			}
		}
	}

	class Point
	{
		public Point ( int x, int y )
		{
			this.X = x;
			this.Y = y;
		}

		public int X { private set; get; }
		public int Y { private set; get; }
	}
}

Measured memory_bytes: 9524
D = int(input())
C = [int(x) for x in input().split()]
S = [[int(i) for i in input().split()] for D in range(D)]
T = [0]*D
for i in range(D):
    T[i] = int(input())
M = int(input())
dp = [[int(i) for i in input().split()] for M in range(M)]

score = [0]*26
last = [-1]*26

for i in range(D):
    score[T[i]-1] += S[i][T[i]-1]
    last[T[i]-1] = i

    for j in range(26):
        score[j] -= C[j]*(i-last[j])

for k in range(M):
    x = T[dp[k][0]-1]
    y = dp[k][1]
    T[dp[k][0]-1] = y
    score[x-1] = 0
    score[y-1] = 0
    last[x-1] = -1
    last[y-1] = -1
    for i in range(D):
        if T[i] == x or T[i] == y:
            score[T[i]-1] += S[i][T[i]-1]
            last[T[i]-1] = i

        score[x-1] -= C[x-1]*(i-last[x-1])
        score[y-1] -= C[y-1]*(i-last[y-1])

    print(sum(score))


Measured memory_bytes: 91652
N, M = [int(x) for x in input().split()]

AB = []
for i in range(N):
    a, b = [int(x) for x in input().split()]
    AB.append((a, b))

AB.sort()

cost = 0
total_n = 0
i = 0

# print(AB)

while True:
    if total_n + AB[i][1] >= M:
        break
    cost += (AB[i][0] * AB[i][1])
    total_n += AB[i][1]
    # print("i:{}, cost:{}, total_n:{}".format(i, cost, total_n))
    i += 1

cost += (M - total_n) * AB[i][0]

print(cost)


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

int main(){
	int N,Y;
	cin>>N>>Y;
	int na=Y/10000,nb=Y/5000;
	for(int a=0;a<=na;a++){
		for(int b=0;b<=nb;b++){
			if(10000*a+b*5000+(N-a-b)*1000==Y&&N-a-b>=0){
				cout<<a<<" "<<b<<" "<<N-a-b<<endl;
				return 0; 
			}
		}
	}
	cout<<"-1 -1 -1";
    return 0;
}


Measured memory_bytes: 256
import numpy as np

def main():
    N, L = map(int, input().split())
    apple = np.zeros(N)
    R = L + N - 1
    eat = 0
    if R <= 0:
        eat = R
    elif L >= 0:
        eat = L
    print(int((R + L) * (R - L + 1)/2 - eat))



       

if __name__ == '__main__':
    main()


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

int main(){
  int A,B,C,ans;
  cin >> A >> B >> C;
  if(B>=C){
    ans=B+C;
  }
  else if(B<C) {
    if(A+B>=C-1){
      ans=B+C;
    }
    else if(A+B<C-1){
      ans=A+2*B+1;
    } 
  }
  cout << ans << endl;
  return 0;
}

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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6;
int A[N];

int mat[1005][1005];

int solve(int A[], int n, int k)
{
    sort(A, A + n);

    int product = 1;

    if (A[n - 1] == 0 && (k & 1))
        return 0;

    if (A[n - 1] <= 0 && (k & 1)) {
        for (int i = n - 1; i >= n - k; i--)
            product = ((product % mod) * (A[i] % mod))%mod;
        return product;
    }

    int i = 0;

    int j = n - 1;

    if (k & 1) {
        product = ((product % mod) * (A[j] % mod))%mod;
        j--;
        k--;
    }

    k = k / 2;

    for (int itr = 0; itr < k; itr++) {

        int left_product = ((A[i]%mod) * (A[i + 1]%mod));

        int right_product = ((A[j]%mod) * (A[j - 1]%mod));

        if (left_product > right_product) {
            product = ((product%mod) * (left_product%mod));
            i += 2;
        }
        else {
            product = ((product%mod) * (right_product%mod));
            j -= 2;
        }
    }

    return (product%mod + mod) % mod;
}

int32_t main()
{
    //code
	IOS;

    int t,n,m,k,i,j,x,y,a,b;

    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n>>k;
        for(i=0;i<n;i++)
            cin>>A[i];

        cout<<(solve(A, n, k) + mod) % mod<<endl;
    }

	return 0;
}

Measured memory_bytes: 5224
/**
 * author: said_v15
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
typedef long long  ll;

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define pb push_back 
#define sc second 
#define f first 
#define kek cout<<"\n"; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 


const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int MAXN = 1000100;
const int INF = 1e8;
const ll LL_INF=1e18;
const double pi=3.1415926535;
using namespace std;
int divide(int a, int b)
{
          return (a+b-1)/b;
}

int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 fast;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 
 int questions=1;
 // cin>>questions;
 while(questions--)
 {
    string s;
    cin>>s;
    int n=s.size();
    if(s[n-1]=='s') cout<<s<<"es";
    else cout<<s<<"s";
    
           
       
 }
 
 
 // !!! LOOK AT NUMBER OF QUESTIONS IN A PROBLEM !!! (cin>>questions)
 

  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
  int k, a,b ;
  cin  >> k>> a>>b ;
  int ans=0 ;
  for(int i=a ;i<=b; i++){
    if(i%k==0) ans=1 ;
  }
  
  if(ans==0 )
  cout <<"NG" <<endl ;
  else
  cout <<"OK"<<endl ; 
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n,cev[li];
char s[li];
vector<int> l,r;
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='R') r.pb(i);
		else l.pb(i);
	}
	int ll=(int)l.size();
	int rr=(int)r.size();
	for(int i=1;i<=n;i++){
		if(s[i]=='R'){
			int bas=0,son=ll-1;
			while(bas<=son){
				int mid=(bas+son)/2;
				if(l[mid]<i) bas=mid+1;
				else son=mid-1;
			}
			int enyakin=l[bas];
			int mes=enyakin-i;
			if(mes%2==0){
				cev[enyakin]++;
			}
			else cev[enyakin-1]++;
		}
		else{
			int bas=0,son=rr-1;
			while(bas<=son){
				int mid=(bas+son)/2;
				if(r[mid]>i) son=mid-1;
				else bas=mid+1;
			}
			int enyakin=r[son];
			int mes=i-enyakin;
			if(mes%2==0){
				cev[enyakin]++;
			}
			else cev[enyakin+1]++;
		}
	}
	for(int i=1;i<=n;i++) printf("%d ",cev[i]);
	
	return 0;
}




Measured memory_bytes: 1532
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int r,c,e=0;
	r=scan.nextInt();
	c=scan.nextInt();
	int a[][]=new int[r+1][c+1];
	int i,j;
	for(i=0;i<r;i++)
	    {
		int b=0;
		for(j=0;j<c;j++)
		    {
			a[i][j]=scan.nextInt();
			b+=a[i][j];
			
			System.out.print(a[i][j]+" ");
		    }
		a[i][j]=b;
		e+=b;
		System.out.println(a[i][j]);
	
		
	    }
	for(i=0;i<c;i++)
	    {
		int d=0;
		for(j=0;j<r;j++)
		    {
			d+=a[j][i];
				
		    }
		a[j][i]=d;
		System.out.print(a[j][i]+" ");	
	    }
	System.out.println(e);
    }
}

Measured memory_bytes: 32200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

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

	int judge = 0;
	for(int i = 1; i < 10; i++){
		for(int j = 1; j < 10; j++){
			if(n == i * j){
				judge = 1;
			}
		}
	}

	if(judge == 1){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		char a=s.charAt(0);
		char b= s.charAt(1);
		char c= s.charAt(2);
		if(a=='7'||b=='7'||c=='7'){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35804
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int N;
string S;

int cnt[26];

map<pair<string, string>, int> m, m2;

void dfs(int idx, string prefix, string suffix) {
    if (idx == N) {
        m[mp(prefix, suffix)]++;
        return;
    }
    dfs(idx + 1, prefix + S[idx], suffix);
    dfs(idx + 1, prefix, S[idx] + suffix);
}

void dfs2(int idx, string prefix, string suffix) {
    if (idx == N) {
        m2[mp(prefix, suffix)]++;
        return;
    }
    dfs2(idx + 1, prefix + S[2 * N - idx - 1], suffix);
    dfs2(idx + 1, prefix, S[2 * N - idx - 1] + suffix);
}

signed main() {
    cin >> N >> S;

    rep(i, 2 * N) cnt[S[i] - 'a']++;
    rep(i, 26) {
        if (cnt[i] % 2) {
            cout << 0 << endl;
            return 0;
        }
        cnt[i] /= 2;
    }

    dfs(0, "", "");
    dfs2(0, "", "");

    int ret = 0;
    itrep(it, m) {
        ret += it->second * m2[it->first];
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 101248
n,a,b =map(int,input().split())
mod =pow(10,9) +7

def comb(n,x):
    numerator = 1
    for i in range(n-x+1,n+1):
        numerator=  numerator * i  % mod
    
    denominator = 1
    for j in range(1,x+1):
        denominator = denominator * j % mod
    
    d = pow(denominator,mod-2,mod)

    return numerator * d

a = comb(n,a)
b =  comb(n,b)

print( (pow(2,n,mod) - 1  - a - b) %mod)

Measured memory_bytes: 3188
N = int(input())

def main():
    p_sum = 0
    p_max = -1
    for i in range(N):
        p = int(input())
        p_sum += p
        if p > p_max:
            p_max = p
    p_sum -= int(p_max/2)
    return p_sum

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 2940
import sys,math
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7
dy = [0,1,0,-1]
dx = [1,0,-1,0]
ddy = [0,1,1,1,0,-1,-1,-1]
ddx = [1,1,0,-1,-1,-1,0,1]

a,b = map(int,input().split())
print(max(2*a-1,a+b,2*b-1))

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	const max = 1000
	mpp := make(map[int]int)
	for i := 0; i <= max; i++ {
		k := i * i * i * i * i
		mpp[k] = i
		if v, ok := mpp[x+k]; ok {
			fmt.Println(i, v)
			return
		}
	}
	for i := 1; i >= -max; i-- {
		k := i * i * i * i * i
		mpp[k] = i
		if v, ok := mpp[x+k]; ok {
			fmt.Println(v, i)
			return
		}
	}
}


Measured memory_bytes: 1928
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr first
#define se second
using namespace std;

const ll N = 2e3 + 7;
ll mod = 1e9 + 7;
map<int , int> mp , mp1 , pm , pm1;
ll n , m , ans , x , y , a , b ,  mx , mn  ;
long long cnt;
int sum;
string s , s1 , s2;
vector<int>v;
set<char>st;
char z , u;
  ll arr[N][N];
int main(){
    cin >> s;
    for( int i = 0 ;i < s.size();i ++ )
        st.insert(s[i]);
    if( st.size() != 1 )
        cout << "Yes";
    else
        cout << "No";
    }



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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  string res;

  REP(i,ty - sy) res += "U";
  REP(i,tx - sx) res += "R";

  REP(i,ty - sy) res += "D";
  REP(i,tx - sx) res += "L";

  res += "L";
  REP(i,ty - sy + 1) res += "U";
  REP(i,tx - sx + 1) res += "R";
  res += "D";

  res += "R";
  REP(i,ty - sy + 1) res += "D";
  REP(i,tx - sx + 1) res += "L";
  res += "U";

  cout << res << endl;
  return 0;
}



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

    int cnt=0;
    for(int i=0; i<1000; ++i){
        vector<int> v={i/100, i/10%10, i%10};
        int k=0;
        for(int j=0; j<n; ++j){
            if(s[j]-'0'==v[k]){
                if(k==2){
                    ++cnt;
                    break;
                }
                ++k;
            }
        }
    }
    cout << cnt << endl;
}

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

int main() {
	double a, b, C, c, h, PI = acos(-1);
	cin >> a >> b >> C;
	C *= PI / 180;
	h = b * sin(C);
	c = sqrt(a * a + b * b - 2 * a * b * cos(C));
	printf("%.8f\n", a * h / 2);
	printf("%.8f\n", a + b + c);
	printf("%.8f\n", h);
}


Measured memory_bytes: 3536
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

struct UnionFind {
  vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n) { par.assign(n, -1); }

  int root(int x) {
    if (par[x] < 0)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (par[x] > par[y])
      swap(x, y);
    par[x] += par[y];
    par[y] = x;
  }

  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { return -par[root(x)]; }
};


signed main() {
  ios::sync_with_stdio(false);
  ll h, w, k;
  cin >> h >> w >> k;
  k--;
  vector<vector<ll>> dp(h+1, vector<ll>(w));
  vector<int> arr;
  REP(i, power(2, w-1)) {
    bool ok = true;
    REP(j, w) {
      if((i&1<<j) && (i&1<<(j+1))) {
        ok = false;
        break;
      }
    }
    if(ok) arr.push_back(i);
  }
  dp[0][0] = 1;
  REP(i, h) {
    for(const auto a : arr) {
      int nexts[w];
      REP(j, w) {
          nexts[j] = j;
      }
      REP(j, w-1) {
          if ((a >> j) & 1) swap(nexts[j], nexts[j + 1]);
      }

      for (int j = 0; j < w;j++) {
          dp[i + 1][nexts[j]] += dp[i][j];
          dp[i + 1][nexts[j]] %= mod;
      }
    }
  }
  cout << dp[h][k] << endl;
  return 0;
}


Measured memory_bytes: 256