akhauriyash/Code-Regression huggingface dataset:
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
#include<queue>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}

inline void solve(void){
  int K,T;
  in(K,T);
  priority_queue<int>q;
  int a;
  rep(i,T){
    in(a);
    q.push(a);
  }
  while(q.size()>2){
    int b=q.top();q.pop();
    int c=q.top();q.pop();
    if(b!=c)q.push(b-c);
  }
  if(q.size()==2){
    int d=q.top();q.pop();
    int e=q.top();
    if(d==e)out(0);
    else out(d-e-1);
  }else{
    int d=q.top();
    out(d-1);
  }
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
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; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

    ll N, X, Y;
    cin >> N >> X >>Y;

    vector<vector<ll>> G(N + 1, vector <ll>(N + 1, mod));

    repl(i, 1, N) {
        repl(j, i + 1, N + 1) {
            G[i][j] = min(j - i, abs(X - i) + abs(Y - j) + 1);
        }
    }

    vector<ll> cnt(N + 1, 0);


    repl(i, 1, N) {
        repl(j, i + 1, N + 1) {
            cnt[G[i][j]]++;
        }
    }

    repl(i, 1, N) {
        cout << cnt[i] << endl;
    }

    return 0;
}



ll gcd(ll a, ll b) {
    if (a % b == 0)return(b);
    else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

Measured memory_bytes: 34816
//   __      __       .__           .____________                   __________        __ ________   __                 
//  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
//  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define PI 3.14159265358979323846

using namespace std;

void solve()
{
    ll n;
    cin >> n;
    ll a[n], b[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    ll am, aM;
    if(n % 2 == 0)
    {
        am = (a[n / 2] + a[n / 2 - 1]);
        aM = (b[n / 2] + b[n / 2 - 1]);
        cout << aM - am + 1 << endl;
    }
    else
    {
        am = a[n / 2];
        aM = b[n / 2];
        cout << aM - am + 1 << endl;
    }
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 6748
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define int long long

int dp[2][100005];

vector< vector<int> >adj(100005);
vector<int>visited(100005,0);

void dfs(int x)
{
	visited[x]=1;
	dp[0][x]=1;
	dp[1][x]=1;
	for(auto &r: adj[x])
	{
		if(!visited[r])
		{
			dfs(r);
			dp[0][x]=(dp[0][x]*dp[1][r])%MOD;
			dp[1][x]=(dp[1][x]*((dp[0][r]+dp[1][r])%MOD) )%MOD;
		}
	}
}

signed main()
{
  	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	int n;
	cin>>n;
	for(int u=0;u<n-1;u++)
	{
		int x,y;
		cin>>x>>y;
		adj[x].emplace_back(y);
		adj[y].emplace_back(x);
	}
	dfs(1);
	cout<<(dp[0][1]+dp[1][1])%MOD;
return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

int main(){
	ll N; cin>>N;
    vector<ll> a(N);
    rep(i,N) cin>>a[i];
  sort(a.begin(),a.end());
  printf("%lld",a[N-1]-a[0]);
  
  
}

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

#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 LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<LL> v(n);
  REP (i, n) {
    cin >> v[i];
  }

  int num = -1;
  FOR (i, 1, n) {
    if (k <= v[i] + v[i - 1]) {
      num = i;
      break;
    }
  }

  if (num == -1) {
    cout << "Impossible" << endl;
    exit(0);
  }

  cout << "Possible" << endl;
  FOR (i, 1, num) {
    cout << i << endl;
  }
  RFOR (i, num + 1, n) {
    cout << i << endl;
  }
  cout << num << endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

void solve(int p, int q) {
  p *= 10;
  int pos = 0;
  map<int, int>vis;
  vis[p] = pos++;
  while(p != 0) {
    int k;
    for(k = 1; k <= 9 && q*k <= p; ++k);
    --k;
    cout << k;

    p -= q*k;
    p *= 10;
    if(vis.find(p) != vis.end()) {
      cout << endl;
      for(int i = 1; i <= pos; ++i) {
	if(i <= vis[p]) cout << ' ';
	else           cout << '^';
      }
      break;
    }
    vis[p] = pos++;
  }
  cout << endl;
}

main() {
  int p, q;
  while(cin >> p >> q) solve(p, q);
}

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



#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int>v(3);
  cin >> v.at(0) >> v.at(1) >> v.at(2);
  
  sort(v.begin(),v.end());
  int k = v.at(2) - v.at(0);
  int l = v.at(2) - v.at(1);
  
  if ((k+l) % 2 == 0) {
    cout << (k+l) / 2 << endl;
  }
  else {
    cout << (k+l+3) / 2 << endl;
  }
}

Measured memory_bytes: 256
n=gets.to_i

ans=1
max_count=0
current=0
1.upto(n) do |i|
    current=i
    count=0
    while i%2 == 0
        i/=2
        count+=1
    end
    if count>max_count
        max_count=count
        ans=current
    end
end
puts ans


Measured memory_bytes: 14196
N, K = map(int, input().split(' '))
h = [None] + list(map(int, input().split(' ')))

dp = [None for _ in range(N+1)]
# dp[0], dp[1], ..., dp[N] が用意される

dp[1] = 0
for k in range(2, N+1): # k = 2, ..., N
  candidate = []
  for i in range(1, K+1): # i = 1, 2, ..., K
    if k - i <= 0:
      break
    candidate.append(dp[k-i] + abs(h[k] - h[k-i]))
  dp[k] = min(candidate)

print(dp[N])



Measured memory_bytes: 93524
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=2e5+5;
int t[N];
int n;
int get(int i){
    int res=0;
    for(i+=n;i>=0;i=(i&(i+1))-1)res+=t[i];
    return res;
}
void add(int i,int x){for(i+=n;i<N;i|=i+1)t[i]+=x;}
int a[N];
int ch(int x){
    memset(t,0,sizeof t);
    int res=0,p=0;
    add(p,1);
    forn(i,n){
        int c=-1;
        if(a[i]>=x)c=1;
        p+=c;
        res+=get(p);
        add(p,1);
    }
    int all=n*(n+1)/2;
    return res+res>=all;
}
int32_t main(){
    cin>>n;
    vector<int> al={0};
    forn(i,n){
        cin>>a[i];
        al.pb(a[i]);
    }
    sort(al.begin(), al.end());
    al.resize(unique(al.begin(), al.end())-al.begin());
    int l=0,r=sz(al);
    while(r-l>1){
        int m=(l+r)/2;
        if(ch(al[m]))l=m;
        else r=m;
    }
    cout<<al[l]<<'\n';
    return 0;
}



Measured memory_bytes: 6396
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;
const int MAXN = 100005;
const int MAXE = 200005;
const int NIL = -1;
typedef long long ll;
const ll INF = 0x3f3f3f3f3f3f3f3f;

bool vis[MAXN];
struct Edge {
	int to, next, w;
	Edge() { next = -1; }
} edge[MAXE];

int N;
int prenum[MAXN], parent[MAXN], lowest[MAXN], head[MAXE], timer, cnt;

void dfs(int cur, int pre)
{
	prenum[cur] = lowest[cur] = timer++;
	vis[cur] = true;

	int next;

	for (int i = head[cur]; i != NIL; i = edge[i].next)
	{
		next = edge[i].to;
		if (!vis[next])
		{
			parent[next] = cur;
			dfs(next, cur);
			lowest[cur] = min(lowest[cur], lowest[next]);
		}
		else if (next != pre)
		{
			lowest[cur] = min(lowest[cur], prenum[next]);
		}
	}
}

void art_points()
{
	for (int i = 0; i < N; ++i)
		vis[i] = false;
	timer = 1;
	dfs(0, NIL);

	set<int> ans;
	int flag = 0;	//?????????

	for (int i = 1; i < N; ++i)
	{
		int p = parent[i];
		if (p == 0)
			++flag;
		else if (prenum[p] <= lowest[i])
			ans.insert(p);
	}

	if (flag > 1)
		ans.insert(0);

	for (set<int>::iterator it = ans.begin(); it != ans.end(); ++it)
		cout << *it << endl;

}

void add(int u, int v, int w)
{
	edge[cnt].to = v;
	edge[cnt].w = w;
	edge[cnt].next = head[u];
	head[u] = cnt++;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int m, s, t;
	cin >> N >> m;
	memset(head, NIL, sizeof(int) * 2 * (m + 1));
	cnt = 0;
	for (int i = 0; i < m; ++i)
	{
		cin >> s >> t;
		add(s, t, 0);
		add(t, s, 0);
	}
	art_points();
	return 0;
}

Measured memory_bytes: 6424
//https://atcoder.jp/contests/dp/tasks/dp_o
#include <bits/stdc++.h>
#define ALL(e) e.begin(), e.end()
#define RALL(e) e.rbegin(), e.rend()
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define dbg(x) (cerr << #x << ":" << x)
#define mid (l + r) / 2
#define fi first
#define sc second
#define N 1000000009

using namespace std;

typedef long long int lli;

void mod(lli &a){
	if(a > 1e9 + 7)
		a -= (1e9 + 7);
}

int main(){
	ios::sync_with_stdio(0);
	int n; cin >> n;

	vector <vector <int>> ar(n+1, vector <int>(n+1, 0));

	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin >> ar[i][j];

	lli mask = 1 << n;
	vector <lli> dp(mask+5, 0);

	dp[0] = 1;

	for(int i=0; i<mask; i++){
		int a = __builtin_popcount(i);
		//cerr << a << endl;
		for(int j=0; j<n; j++){
			if(ar[a][j] and !(i & (1 << j))){
				mod(dp[i]);
				dp[i | (1 << j)] += dp[i];
				mod(dp[i | (1 << j)]);
			}
		}
	}

	cout << dp[mask-1] << endl;

	return 0;
}

Measured memory_bytes: 16768
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

ll func( long xx[40][2], long* a, long num )
{
    ll sum=0;
    long i;
    for(i=0; i<40; i++) {
        long curr= (i<num? a[i]: 0);
        sum += ((ll)xx[i][1-curr]<<i);
    }
    return sum;
}

ll value( long* a, long num )
{
    ll sum=0;
    long i;
    for(i=0; i<num; i++) {
        sum += ((ll)a[i]<<i);
    }
    return sum;
}

int main(int argc, char* argv[])
{
    long n;
    ll   k;
    scanf("%ld%lld", &n, &k);

    vector<ll> a(n);
    long i, j;
    for(i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }

    vector<long> kk;
    ll tmp = k;
    while( tmp>0 ) {
        kk.push_back(tmp%2);
        tmp /= 2;
    }

    long xx[40][2]={0};
    long c[40]={0};
    for(j=0; j<40; j++) {
        for(i=0; i<n; i++) {    
            xx[j][(a[i]>>j)&1]++;
        }
        c[j]=(xx[j][0]<=xx[j][1]? 0: 1);
    }

    ll max=-1;
    long len=(long)kk.size();
    for(i=0; i<len; i++) {
        vector<long> kk2=kk;
        long m;
        for(m=0; m<=i; m++) {
            kk2[m]=c[m];
        }
        if ( value( &(kk2[0]), len ) <= k ) {
            ll tmp = func( xx, &(kk2[0]), len );
            max = MAX(max, tmp);
        }
        if( i<len-1 && kk2[i+1]==1 ) {
            kk2[i+1]=0;
            ll tmp = func( xx, &(kk2[0]), len );
            max = MAX(max, tmp);
        }
    }
    if(len==0) {
        long a = 0;
        ll tmp = func( xx, &a, 0 );
        max = MAX(max, tmp);
    }
    else {
        ll tmp = func( xx, &(kk[0]), len );
        max = MAX(max, tmp);
    }

    printf("%lld\n", max);

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)

void solve() {
	double n, x, t;
	cin >> n >> x >> t;
	cout << (int)(n <= x ? t : t * ceil(n / x));
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int tc = 1;
	// cin >> tc;
	while(tc--) {
	    solve();
	}
	return 0;
}


Measured memory_bytes: 3728
#include <cstdio>
#include <iostream>
#define MAXN 100500
using namespace std;
int n;
int a[MAXN];
int b[MAXN];
int c[MAXN];
int ansa[MAXN];
int ansb[MAXN];
int ansc[MAXN];
int main(){
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    ansa[0] = a[0];
    ansb[0] = b[0];
    ansc[0] = c[0];
    for (int i = 1; i < n; i++){
        ansa[i] = max(ansb[i - 1], ansc[i - 1]) + a[i];
        ansb[i] = max(ansa[i - 1], ansc[i - 1]) + b[i];
        ansc[i] = max(ansb[i - 1], ansa[i - 1]) + c[i];
    }
    cout << max(max(ansa[n - 1], ansb[n - 1]), ansc[n - 1]) << endl;
}

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

using ll = long long int;
const ll maxs = 1e5+5;

ll n;
ll arr[maxs],dp[maxs];

ll rec(ll i)
{
    if(i >= n-2)
        return dp[i];
    
    if(dp[i] != -1)
        return dp[i];
    else
        return dp[i] = min(rec(i+1) + abs(arr[i+1] - arr[i]) , rec(i+2) + abs(arr[i+2] - arr[i]));
}

int main()
{
    cin >> n;

    for(ll i=0;i<n;i++) {
        cin >> arr[i];
        dp[i] = -1;
    }
    dp[n-1] = 0;
    dp[n-2] = abs(arr[n-2] - arr[n-1]);

    cout << rec(0);
    
    return 0;
}

Measured memory_bytes: 3328
# Aizu Problem 0259: All Numbers Lead to 6174

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def solve(digits):
    steps = 0
    while digits != ['6', '1', '7', '4']:
        L = int(''.join(sorted(digits)))
        S = int(''.join(sorted(digits, reverse=True)))
        digits = [_ for _ in str(S - L)]
        while len(digits) < 4:
            digits = ['0'] + digits
        steps += 1    
    return steps

    
while True:
    digits = [_ for _ in input().strip()]
    if digits == ['0'] * 4:
        break
    print("NA" if len(set(digits)) == 1 else solve(digits))

Measured memory_bytes: 7836
n, m = [int(i) for i in input().split()]
a = []
b = []
flag_yes = 0
for i in range(n):
  a.append(input())
for i in range(m):
  b.append(input())
for ri in range(n-m+1):
  for ci in range(n-m+1):
    c = []
    for mi in range(m):
      c.append(a[ri+mi][ci:ci+m])
    if c == b:
      flag_yes = 1
if flag_yes == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {
    let (n, m): (usize, usize) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        (a, b)
    };

    let mut vec = {
        let mut x: Vec<(isize, isize, isize)> = Vec::new();
        for _ in 0..n {
            let (a, b, c): (isize, isize, isize) = {
                let mut s = String::new();
                std::io::stdin().read_line(&mut s).unwrap();
                let s = s.trim_right().to_owned();
                let mut ws = s.split_whitespace();
                let a = ws.next().unwrap().parse().unwrap();
                let b = ws.next().unwrap().parse().unwrap();
                let c = ws.next().unwrap().parse().unwrap();
                (a, b, c)
            };
            x.push((a, b, c));
        }
        x
    };

    let mut max = std::isize::MIN;
    for i in 0..8 {
        let sign1 = sign(i, 0);
        let sign2 = sign(i, 1);
        let sign3 = sign(i, 2);
        // dbg!(sign1);
        // dbg!(sign2);
        // dbg!(sign3);

        // let mut vec = vec.clone();
        vec.sort_by(|&(a1, b1, c1), &(a2, b2, c2)| (sign1 * a1 + sign2 * b1 + sign3 * c1).cmp(&(sign1 * a2 + sign2 * b2 + sign3 * c2)));
        vec.reverse();
        // debugln!("{:?}", vec);
        let sum: isize = vec[0..m].iter().map(|&(a, b, c)| sign1 * a + sign2 * b + sign3 * c).sum();
        // let mut sum = 0;
        // sum += vec[0..m].iter().map(|&(a, b, c)| a).sum::<isize>().abs();
        // sum += vec[0..m].iter().map(|&(a, b, c)| b).sum::<isize>().abs();
        // sum += vec[0..m].iter().map(|&(a, b, c)| c).sum::<isize>().abs();
        // debugln!("{}", sum);
        if max < sum {
            max = sum;
        }
    }
    println!("{}", max);
}

fn sign(bits: usize, i: usize) -> isize {
    if bits & (1 << i) > 0 {
        1
    } else {
        -1
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int H,W;
vector<vector<int>> field;
vector<int> di = {0, 1, 0, -1, 1, 1, -1, -1};
vector<int> dj = {1, 0, -1, 0, 1, -1, 1, -1};

void dfs(int nowi, int nowj){
  field[nowi][nowj] = 0;
  for (int i=0; i<di.size(); i++){
    int ni = nowi + di[i];
    int nj = nowj + dj[i];
    if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;
    if (field[ni][nj]) dfs(ni,nj);
  }
}

int main() {
  cin >>W >>H;
  while (W * H){
    field.assign(H, vector<int>(W, 0));
    rep(i, H) rep(j, W) cin >>field[i][j];
    int res = 0;

    for (int i=0; i<H; i++){
      for (int j=0; j<W; j++){
        if (field[i][j]) dfs(i,j), res++;
      }
    }

    cout <<res <<endl;

    cin >>W >>H;
  }

}


Measured memory_bytes: 3164
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll x[20000005];
ll a[10000005];
ll dp[10005][10005];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;


double q[200005];

int main(void) {
	int n, k,p;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> p;
		q[i] = (double)(0.5 * p* (1 + p)) / p;
		
	}
	
	double sum = 0;
	for (int i = 0; i < k; i++) {
		sum += q[i];
	}
	double max = sum;
	double ans = 0;
	for (int i = k; i < n; i++) {
		ans = sum - q[i - k]+q[i];
		
		if (ans > max) {
			max = ans;
		}
		sum = ans;
	}
	printf("%.12f", max);
	return 0;
}


Measured memory_bytes: 1792
import           Control.Monad
import           Data.IORef
import           Data.List.Split
import           Data.Maybe
import           Data.List

main :: IO ()
main = do
  [a, op, b] <- words <$> getLine
  print $ case op of
    "+" -> toInt a + toInt b
    "-" -> toInt a - toInt b
    _ -> error "error"
  where
    toInt s = read s :: Int

Measured memory_bytes: 508
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 998244353;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

int main(){

  int n = in();
  int ans = n * 800 - n / 15 * 200;
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
using namespace std;
int main() {
	string a;
	cin>>a;
	int frist=0;  
	for(int i=0; i<a.size(); i++) {
		if(a[i]=='C') {
			frist=1;
		}
		if(a[i]=='F'&&frist==1) {
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

using namespace std;
typedef long long ll;

inline int at(ll x, int k){ return (x >> k) & 1; }
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)



int main() {
  int k;
	string s;
	cin >> k>>s;
  if(s.size()<=k){
    cout << s << endl;
  }
  else{
    cout << s.substr(0, k)+"..." << endl;
  }

}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

int main()
{
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < N; i++)
    {
        cout << S[i] << T[i];
    }
    cout << 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);
        // 整数の入力
        int n = sc.nextInt();
        Set<Integer> hSet = new HashSet<>();
        for (int i = 0; i < n; i++) {
            hSet.add(sc.nextInt());
        }
        // 出力
        System.out.println(hSet.size());
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main() {
	long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> F(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&F[i]);
    }

	sort(A.begin(), A.end());
	sort(F.begin(), F.end());

	ll sum = 0;
	for(int i=0; i<N; i++) sum += A[i];
	if(sum <= K){
		cout << 0 << endl;
		return 0;
	}

	ll lb=0, ub=1e13;
	while(ub-lb>1){
		ll x = (lb+ub)/2;

		ll l = 0;
		for(int i=0; i<N; i++){
			l += max(0ll, A[i]-x/F[N-i-1]);
		}
		if(l <= K){
			ub = x;
		} else {
			lb = x;
		}
	}

	cout << ub << endl;

	return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int main() {
	int n;
  	cin >>n;
  int cnt = 0;
    for (int i=0 ; i<n ; i++) {
      int x;
      cin >>x;
      if (i%2==0 and x%2==1) cnt++;
    }
   cout <<cnt<<endl; 
	return 0;
}

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

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

int main() {

  string S, T;
  cin >> S >> T;

  string ans = T+S;
  
  cout << ans << endl;

  return 0;
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	int32 A, B, C;
	cin >> A >> B >> C;
	cout << max({A*10+B+C, A+B*10+C, C*10+A+B}) << endl;
}


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

int main() {
  
  int N,l1,l2;
  string S,R,S1,R1,S2,R2;


  cin >> S;
  
  N = S.length();
  l1 = (N-1)/2;
  l2 = (N+3)/2;
  
  char A[S.size() + 1];
  char B[l1 + 1];
  char C[N - l2 + 1];
  
  R = S;
  S1 = S.substr(0,l1);
  R1 = S1;
  S2 = S.substr(l2-1,l1);
  R2 = S2;
  reverse(R.begin(), R.end()); 
  reverse(S1.begin(), S1.end()); 
  reverse(S2.begin(), S2.end());
  
  if (R != S) {
    cout << "No" << endl;
    return 0;
  }
  
  if (R1 != S1) {
    cout << "No" << endl;
    return 0;
  }
  
  if (R2 != S2) {
    cout << "No" << endl;
    return 0;
  }
    

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

vector<int> factorize(int x) {
    vector<int> res;
    for (int i = 1; i * i <= x; ++i) {
        if (x % i == 0) {
            res.push_back(i);
            if (i * i != x) {
                res.push_back(x / i);
            }
        }
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    vector<int> cnt(1000001, 0);
    for (auto& a : A) {
        ++cnt[a];
    }
    int ans = 0;
    for (auto& a : A) {
        --cnt[a];
        vector<int> factors = factorize(a);
        bool is_ok = true;
        for (auto& f : factors) {
            if (cnt[f]) {
                is_ok = false;
                break;
            }
        }
        if (is_ok) {
            ++ans;
        }
        ++cnt[a];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7952
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n;

int main(){
	cin>>n;
	bool B=0;
	for(int i=0;i<n;i++){
		char c;
		cin>>c;
		if(c=='Y') B=1;
	}
	cout<<(B?"Four":"Three")<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n; cin >> n;
    vector<int> a(n-1);
    rep(i,n-1) {
        cin >> a[i];
        --a[i];
    }
    map<int,int> mp;
    rep(i,n) {
        mp[i] = 0;
    }
    rep(i,n-1) {
        ++mp[a[i]];
    }
    for(auto x: mp) {
        cout << x.se << endl;
    }

    return 0;
}





























Measured memory_bytes: 13492
#include<cstdio>

const int maxn=55,p[8][2]={{0,1},{1,0},{0,-1},{-1,0},{-1,1},{1,-1},{-1,-1},{1,1}};
int n,m;
char a[maxn][maxn];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",a[i]+1);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++)
		 if (a[i][j]=='#') putchar('#');else{
		 	int res=0;for (int t=0;t<8;t++) res+=(a[i+p[t][0]][j+p[t][1]]=='#');
		 	putchar(res+48);
		 }
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    print(sum(len(str(i)) % 2 for i in range(1, n + 1)))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


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

int abl_l[4] = {0, 0, 0, 0};
int abl_r[4] = {0, 0, 0, 0};

int ability(double f) {
	if (f >= 1.1) return 0;
	if (f >= 0.6) return 1;
	if (f >= 0.2) return 2;
	return 3;
}

int main() {
	double l, r;
	while (cin >> l >> r) {
		abl_l[ability(l)]++;
		abl_r[ability(r)]++;
	}
	for (int i = 0; i < 4; i++)
		cout << abl_l[i] << " " << abl_r[i] << endl;
	return 0;
}

Measured memory_bytes: 0
n = int(input())
list_s = list((map(int, input().split())))
q = int(input())
list_t = list((map(int, input().split())))
ans = 0
for numbert in list_t:
    for numbers in list_s:
        if numbers == numbert:
            ans += 1
            break
        else:
            pass
print(ans)



Measured memory_bytes: 6320
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N=100005,P=1e9+7;
int n,f[N],nxt[N][2];char s[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool flg=0;
	rep(i,1,n-1)if(s[i]==s[i+1])flg=1;
	if(!flg)puts("1"),exit(0); 
	f[n+1]=1;
	nxt[n+1][0]=nxt[n+1][1]=nxt[n+2][0]=nxt[n+2][1]=n+2;
	int sum=0;
	per(i,n,1){
		(sum+=s[i]-'a'+1)%=3;
		nxt[i][0]=(s[i]=='a'?i+1:s[i+1]=='b'?i+2:nxt[i+2][0]);
		nxt[i][1]=(s[i]=='b'?i+1:s[i+1]=='a'?i+2:nxt[i+2][1]);
		f[i]=(f[nxt[i][0]]+f[nxt[i][1]]+(sum==0))%P;
	}
	printf("%d\n",(f[1]-(sum==0)+P)%P);
	return 0;
}

Measured memory_bytes: 5104
n,q=map(int,input().split())
s=input()
a=[0 for _ in range(n)]
for i in range(n-1):
  a[i+1]=a[i]+(1 if s[i:i+2]=="AC" else 0)
for i in range(q):
  l,r=map(int,input().split())
  print(a[r-1]-a[l-1])

Measured memory_bytes: 7772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using gp = priority_queue<int, vector<int>, greater<int>>;
int N, K;
vector<int> D;

void solve() {
    cin >> N >> K;
    for (int i = 0; i < N; ++i) {
        int v; cin >> v;
        D.push_back(v);
    }
    int limit = min(N, K);
    ll ans = 0;
    for (int i = 0; i <= limit; ++i) {
        for (int j = 0; j + i <= limit; ++j) {
            ll now = 0;
            gp copy;
            for (int k = 0; k < i; ++k) {
                now += D[k];
                copy.push(D[k]);
            }
            for (int k = 1; k <= j; ++k) {
                int x = D[N - k];
                now += x;
                copy.push(x);
            }
            int d = K - i - j;
            for (int k = 0; k < d; ++k) {
                if (copy.empty()) break;
                int v = copy.top();
                if (v >= 0) break;
                copy.pop();
                now -= v;
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		HashMap<String,Integer> h = new HashMap<String,Integer>();
		String a[] = new String[1000];
		int I = 0;
		int maxlength = 0;
		String maxleng = "";
		while(sc.hasNext()){
			String str = sc.next();
			if(h.containsKey(str)){
				int c = h.get(str).intValue();
				h.put(str,Integer.valueOf(c+1));
			}
			else{
				h.put(str,Integer.valueOf(1));
				a[I++] = str;
			}
		}
		int maxval = 0;
		String maxVal = "";
		for(int i=0;i<I;i++){
			if(h.get(a[i]).intValue() > maxval){
				maxval = h.get(a[i]).intValue();
				maxVal = a[i];
			}
			if(maxlength < a[i].length()){
				maxlength = a[i].length();
				maxleng = a[i];
			}
		}
		System.out.println(maxVal+" "+maxleng);
	}
}



Measured memory_bytes: 26244
# -*- coding: utf-8 -*-

def merge(A, left, mid, right):
    global cnt
    n1 = mid - left
    n2 = right - mid
    L = [None]*(n1+1)
    R = [None]*(n2+1)
    L[:n1] = A[left:left+n1]
    R[:n2] = A[mid:mid+n2]

    L[n1] = float('inf')
    R[n2] = float('inf')
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
    
if __name__ == '__main__':

    n = int(input())
    S = [int(s) for s in input().split(" ")]
    cnt = 0

    mergeSort(S, 0, n)

    print(" ".join(map(str, S)))
    print(cnt)


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

int n, w;
int a[111], b[111];
int memo[111][11111];

int solve(int i, int p){

  if(p < 0) return -(1<<28);
  if(i == n) return 0;
  if(memo[i][p]) return memo[i][p];
  
  int ans = 0;
  return memo[i][p] = ans += max(solve(i+1, p), max(solve(i+1, p-b[i])+a[i], solve(i, p-b[i])+a[i]));

}

int main(){

  cin >> n >> w;
  for(int i=0;i<n;i++) cin >> a[i] >> b[i];

  cout << solve(0, w) << endl;

}

Measured memory_bytes: 5952
INF = 10**9
N, K = map(int, input().split())
s = [int(c) for c in input().split()]

ans = INF
for i in range(N-K+1):
  l = i
  r = l+K-1
  ans = min(ans, abs(s[l])+abs(s[r]-s[l]), abs(s[r])+abs(s[r]-s[l]))

print(ans)

Measured memory_bytes: 14380
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n;
  cin >> n;
  int a[n];
  int b[n];
  int c[n-1];
  int d = 0;
  for (int i = 0 ; i < n ; i++) {
    cin >> a[i]; }
  for (int i = 0; i < n; i++) {
    cin >> b[i]; }
  for ( int i = 0 ; i < n-1 ; i++) {
    cin >> c[i];}
  for (int i = 0; i < n; i++) {
    d += b[a[i]-1]; 
    if (a[i] + 1 == a[i+1] && i != n-1) {
      d += c[a[i]-1]; }
      
  } 
cout << d;}
  

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define ren(i,n) for(int i=n-1;i>=0;i--)
#define iter(it,v) for(auto it:v)
#define iterp(it,v) for(auto it=v.begin(),it!=v.end();it++)
#define itern(it,v) for(auto it=v.rbegin();it!=v.rend();it++)
#define w(n) while(n--)
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define sc(a) scanf("%d",&a)
#define pf(a) printf("%d",a)
#define init(a,r) for(auto&i:a) i=r;
#define inpt(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define inp(a) for(int&i:a) cin>>i;
#define diss(a) for(int i:a) cout<<i<<' ';
#define disn(a) for(int i:a) cout<<i<<'\n';
#define debug(a) cout<<#a<<": ";for(auto i:a)cout<<i<<" ";cout<<'\n';
#define mpii map<int,int>
#define sii set<int>
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define all(v) v.begin(),v.end()
#define bitc __builtin_popcount
#define fst ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
#define pq priority_queue
#define pii pair<int,int>
#define cs(a) cout<<a<<' '
#define cn(a) cout<<a<<'\n'
#define deb(a,b) cout<<a<<' '<<b<<endl;
#define yy "YES"
#define nn "NO"
#define ff first
#define ss second
typedef long long ll;
const int mod=1e9+7,mod1=998244353;
const int N=2e5+7;
int ar[N];
void a_b_l(){
    int n,k;
    cin>>n>>k;
    int ar[n];
    inp(ar);
    int dp[n];
    init(dp,INT_MAX);
    dp[0]=0;
    rep(i,n){
        forp(j,1,k){
            if(i-j<0)
                break;
            dp[i]=min(dp[i],dp[i-j]+abs(ar[i]-ar[i-j]));
        }
    }
    cn(dp[n-1]);
}
signed main(){
    fst;
    int t=1;
    //cin>>t;
    w(t)
    	a_b_l();
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
    int n = 0, m = 0, k[35] = {0}, a[35] = {0}, i = 0, j = 0, t = 0, num[35] = {0};
    cin >> n >> m;
    for(i = 1; i <= n; i++)
    {
        cin >> k[i];
        for(j = 1; j <= k[i]; j++)
        {
            cin >> a[i];
            num[a[i]]++;
        }
    }
    for(i = 1; i <= m; i++)
    {
        if(num[i] == n)
        {
            t++;
        }
    }
    cout << t;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> V;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;

int main() {
    double ans=0,a;
    string b;
    int n;
    cin >> n;
    rep(i,n){
        cin >> a >> b;
        if(b=="JPY") ans += a;
        else ans += a*380000;
    }
    cout << setprecision(10) <<ans << endl;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h> 
 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define pie pair<int,int>
using namespace std;

int32_t main(){

	int a,b;
	cin>>a>>b;
	float p,q;
	for(int i=1;i<=100000;i++){


		if(((i*8)/100)==a&&((i*10)/100)==b){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> use(n+1,0),e(m);
  
  rep(i,m) cin >> e[i];
  
  rep(i,m){
    int v = e[m-1-i];
    if(!use[v]){
      cout << v << endl;
      use[v] = 1;
    }
  }

  rep(i,n){
    if(!use[i+1]) cout << i + 1 << endl;
  }
}
  

Measured memory_bytes: 3868
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n, p;
string s;
vector<int> a(10000, 0);
int main(void){
    cin >> n >> p >> s;
    reverse(s.begin(), s.end());
    int t = 0, u = 1;
    long long ans = 0;
    for(int i=0;i<n;i++){
        int v = s[i]-'0';
        t += v*u;
        t %= p;
        u = (u*10)%p;
        ans += a[t]++;
        if(t == 0) ans++;
    }

    if(p == 2 || p == 5){
        ans = 0;
        for(int i=0;i<n;i++){
            int v = s[i]-'0';
            if(v%p == 0) ans += n-i;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 644
#include <stdio.h>
#include <string.h>
#include <math.h>


int main(void)
{	
	int x,y;
	scanf("%d %d",&x,&y);
	
	if(x==2){
		x='c';
	} else if(x==4 || x==6 || x==9 || x==11){
		x='b';
	} else{
		x='a';
	}
	
	if(y==2){
		y='c';
	} else if(y==4 || y==6 || y==9 || y==11){
		y='b';
	} else{
		y='a';
	}
	
	if(x==y){
		puts("Yes");
	} else{
		puts("No");
	}
	
	return 0;
}


Measured memory_bytes: 128