akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;

#define MOD 1e9+7

ll mod_pow(ll x, ll n, ll m){
    if(n == 0)
        return 1LL;
    if(n % 2 == 0){
        return mod_pow(x * x % m, n / 2, m);
    }else{
        return (x * mod_pow(x, n - 1, m)) % m;
    }
}



int main(){

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

    ll power = mod_pow(m,n,MOD);
    cout << power << endl;


    return 0;
}


Measured memory_bytes: 3132
//============================================================================
// Name        : ITP_1_7_B.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	int i,j,k,n,x,c=0;
	do {
		cin >> n >> x;
		if (n==0 && x==0 ) break;
		c=0;
		for(i=1;i<=n;++i) {
			for(j=i+1;j<=n;++j) {
				for(k=j+1;k<=n;++k) {
					if(i+j+k==x) {
						c++;
					}
				}
			}
		}
		printf("%d\n",c);
	} while(1);
	return 0;
}

Measured memory_bytes: 3144
#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(){
    int k;
    cin >> k;
    ll m;
    queue <ll>q1,q2,q3;
    m=9;
    ll qq;
    rep(i,9){
        q1.push(i+1);
    }
    ll ans;
    ll l;
    if(k<=9){
        ans=k;
    }
    else{
        while(m<k){
            q2=q3;
            while(q1.size()!=0){
                qq=q1.front();
                q1.pop();
                if(qq%10!=0){
                    q2.push(qq*10+qq%10-1);
                }
                q2.push(qq*10+qq%10);
                if(qq%10!=9){
                    q2.push(qq*10+qq%10+1);
                }

            }
            q1=q2;
            m+=q2.size();
        }
        l=m-q2.size();

        rep(i,k-l-1){
            q2.pop();
        }
        ans=q2.front();


    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n)-1; i>=0; --i)
#define For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int n;cin >> n;
    vi d(n);
    cin >> d;

    int ans = 0;
    rep(i,n){
        for(int j=i+1;j<n;++j){
            ans += d[i] * d[j];
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;

int main(){
    lint n;
    cin >> n;
    lint arr[n];
    lint ans = 0;
    lint x = 1;
    
    for(int i=0; i<n; i++) cin >> arr[i];

    for(int i=0; i<60; i++){
        lint cntr = 0;
        for(int j=0; j<n; j++){
            if((arr[j])&(1ll << i))
                cntr++;
        }
       
        ans+=(cntr*(n-cntr)%lint(1e9+7))*x;
        ans%=lint(1e9+7);
        x = (x*2)%lint(1e9+7);
        
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		h: usize,
		w: usize,
		n: usize,
		a: [usize; n],
	}

	let mut v: Vec<Vec<usize>> = vec![vec![0; h]; w];
	let mut x = 1;
	let mut y = 0;
	for i in 0..n {
		for _j in 0..a[i] {
			if y % 2 == 0 {
				v[x-1][y] = i;
				x += 1;
				if x == w+1 {
					x = w;
					y += 1;
				}
			}
			else {
				v[x-1][y] = i;
				x -= 1;
				if x == 0 {
					x = 1;
					y += 1;
				}
			}
		}
	}
	for i in 0..h {
		for j in 0..w {
			print!("{} ", v[j][i]+1);
		}
		println!("");
	}
}



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

int main() {
    int N,count;
    count=0;
    cin >>N;
    vector<int> vec(N);
     for (int i = 0; i < N; i++) {
       cin >> vec.at(i);
         if(vec.at(i)%2==1 && (i+1)%2==1){
             ++count;
         }
     }
    cout<<count<<endl;
    
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,num;

    scanf("%d",&n);

    int *a = calloc(n,sizeof(int));
        
    for(int x = 1;x < n;x++)
    {
        for(int y = 1;y < n;y++)
            for(int z = 1;(num = x * x + y * y + z * z + x * y + x * z + y * z) <= n;z++)
            {
                a[num - 1]++;
            }
    }

    for(int i = 0;i < n;i++)
        printf("%d\n",a[i]);

    return 0;
}

Measured memory_bytes: 1688
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int n,m,a;
    cin>>n>>m>>a;
    if(!n&&!m&&!a)break;
    vector<pair<int,int> > v[1001];
    for(int i=0;i<m;i++){
      int h,p,q;
      cin>>h>>p>>q;
      h--;
      v[h].push_back(make_pair(p,q));
    }

    for(int i=1000;i>=0;i--){
      for(int j=0;j<v[i].size();j++){
        if(v[i][j].first==a){
          a=v[i][j].second;
          break;
        }else if(v[i][j].second==a){
          a=v[i][j].first;
          break;
        }
      }
    }
    cout<<a<<endl;
  }
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


#define BOOST        ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define AZ(x)        x.begin(),x.end()
#define fi           first
#define se           second
#define pb           push_back
#define emp          emplace_back
#define mp           make_pair
#define mt           make_tuple 
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); degub(_it, args); }
#define For(i,a,n)   for(auto i = a; i < n; i++)
#define int          long long

template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;

typedef long long ll;
typedef long double ld;


template<typename T>
// for super_map add a parameter Y above and replace "null_type" with "Y"

// set with two additional super powers
	// find_by_order(int k) - returns k'th smallest element (0-indexed)
	// order_of_key(int k) - returns number of elements strictly smaller than k.
using super_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


void degub(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>
void degub(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " : " << a << "] ";
	degub(++it, args...);
}


ll power(ll a,ll b)
{
	// a = a;
	ll result = 1;

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

ll super_rand(ll n) // Random number from set [0,n-1]
{
	uniform_int_distribution<ll> uid(0, n - 1);
	return uid(rng);
}



/*


1. Make sure you're taking all the inputs.
2. In case of nested loops, remember to use different variables.
3. If in doubt, do int -> ll
4. Don't fight the question, try solving the next one.
5. ffs (positon of first set bit), clz (leading 0s, max->32), ctz (trailing 0s), popcount (set bits). Don't use any of these on 0;


*/



// Don't code anything above this //






const int mod = 1e9+7, N = 1e5 + 5;
const ll INF = 1000000000000000107;

int dp[100][N] = {};

int32_t main()
{
	BOOST
	
	// #ifndef ONLINE_JUDGE
	// // for getting input from input.txt
	// freopen("input.txt", "r", stdin);
	// // for writing output to output.txt
	// freopen("output.txt", "w", stdout);
	// cout << "OUTPUT \n";
	// #endif

	int n, k;
	cin >> n >> k;
	int a[n];
	for(auto &i : a)
		cin >> i;
	int prev[k + 1] = {};
	prev[0] = 1;
	for(int j = 0; j <= a[0]; j++)
		dp[0][j] = 1;
	for(int j = 1; j <= k; j++)
		prev[j] = (prev[j - 1] + dp[0][j]) % mod;
	for(int i = 0; i < n; i++)
		dp[i][0] = 1;
	for(int i = 1; i < n; i++)
	{
		for(int j = 1; j <= k; j++)
		{
			dp[i][j] = (j > a[i] ? prev[j] - prev[j - a[i] - 1] : prev[j]);
			if(dp[i][j] < 0)
				dp[i][j] += mod;
		}
		for(int j = 1; j <= k; j++)
			prev[j] = (prev[j - 1] + dp[i][j]) % mod;
	}
	if(dp[n - 1][k] < 0)
		dp[n - 1][k] += mod;
	cout << dp[n - 1][k] << "\n";
	return 0;
}


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

void solve(){
    string s;
    cin>>s;
    if(s.back()=='s'){
        s+="es";
    }
    else{
        s+="s";
    }
    cout<<s<<'\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

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

  int cnt = 0;
  int ans = 0;
  REP(i, S.size()) {
    if(S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') cnt++;
    else cnt = 0;

    if(ans < cnt) ans = cnt;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Volumen0
{
    static void Main()
    {
        int ans = 100000;
        double sem = double.Parse(Console.ReadLine());
        for (int i = 0; i < sem; ++i)
        {
            double tmp = ans * 0.05;
            int tmp2 = (int)tmp / 1000;
            if (tmp2 != tmp / 1000)
            {
                ans += (tmp2 + 1) * 1000;
            }
            else
            {
                ans += tmp2 * 1000;
            }
        }
        Console.Out.WriteLine(ans);
    }
}


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

int main(){
  set<int> y;
  y.insert(1);
  fr(i,9) y.insert(pow(2,i+2));
  fr(i,5) y.insert(pow(3,i+2));
  for(int i=5;i<32;i++) fr(j,3) if(pow(i,j+2)<1001) y.insert(pow(i,j+2)); 
  int x,k=0;
  cin>>x;
  for(auto i=y.begin();i!=y.end();i++){
    if(x<*i){
      cout<<*--i<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      ll x;
      cin >> x;
      ll ans=1;
      for(int i=2;i*i<=x;i++){
        ll subans=i;
        while(i*subans<=x)subans*=i;
        ans=max(ans,subans);
      }
      cout << ans << endl;
      return 0;}

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

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

#define fr first
#define sc second
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)

int cnt(int n){
	int ret=0;
	while((n&1)==0){
		ret++;
		n>>=1;
	}
	return ret;
}

int main(){
	static int n;
	static string s;
	cin>>n>>s;
	bool a=false;
	for(int i=0;i<n;i++){
		if(s[i]=='2')a=true;
	}
	if(a){
		int sum=0;
		int t=0;
		for(int i=0;i<n;i++){
			if(t==0)sum+=s[i]-'0';
			if(i+1==n)break;
			t+=cnt(n-i-1);
			t-=cnt(i+1);
		}
		if(sum&1)cout<<1<<endl;
		else cout<<0<<endl;
	}
	else {
		int sum=0;
		int t=0;
		for(int i=0;i<n;i++){
			if(t==0)sum+=(s[i]-'1')/2;
			if(i+1==n)break;
			t+=cnt(n-i-1);
			t-=cnt(i+1);
		}
		if(sum&1)cout<<2<<endl;
		else cout<<0<<endl;
	}
}

Measured memory_bytes: 1412
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long x,ans;

int main(){
	cin>>x;
	ans+=(x/11)*2;
	x%=11;
 	if(x!=0){
		if(x>6){
			cout<<ans+2<<endl;
		}else{
			cout<<ans+1<<endl;
        }
	}else{
		cout<<ans<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n)cin >> b[i];
  vector<int> ans;
  vector<int> curr = b;
  for(int i = 0; i < n; i++){
    for(int j = sz(curr) - 1; j >= 0; j--){
      if(curr[j] == j + 1){
        ans.pb(j + 1);
        if(i + 1 == n)break;
        vector<int> tmp(sz(curr) - 1);
        for(int k = 0; k < j; k++){
          tmp[k] = curr[k];
        }
        for(int k = j + 1; k < sz(curr); k++){
          tmp[k-1] = curr[k];
        }
        swap(curr, tmp);
        break;
      }
      if(j == 0){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  reverse(all(ans));
  for(int i = 0; i < sz(ans); i++)cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = n;
    int cnt = 0;
    rep(i,n)if(s[i]=='R')cnt++;
    ans = cnt;
    int r = 0;
    rep(i,n){
        if(s[i]=='R'){
            r++;
            cnt--;
        }
        int t = 0;
        t += min(i + 1 - r, cnt);
        t += (i + 1 - r) - t + cnt - t;
        ans = min(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
const int INF = 1e9 + 10;

struct edge{
	int to, weigth;
};

struct State{
	int id;
	int dist;
	bool operator < (const State &other) const {
		if (dist != other.dist) return dist > other.dist;
			return id < other.id;
		}
};

int N, R;
const int SZ = 100010;
vector<edge> adj[SZ];

VI ditra(int src, VI& ans){
	const int INF = 1e9;
	VI D(N, INF);
	D[src] = 0;
	priority_queue <State> Q;
	Q.push({src, 0});
	while(!Q.empty()){
		State u = Q.top();
		int i_d = u.id, dis = u.dist;
		Q.pop();
		if (dis > D[i_d]) continue;
		for(edge v : adj[i_d]) {
			int distancia = dis + v.weigth;
			if(distancia<D[v.to]){
			   ans[v.to] = i_d + 1; 
				D[v.to] = distancia;
				Q.push({v.to, D[v.to]});
			}
		}
	}
	return D;
}

int main() {
	cin>>N>>R;
	for(int i=0; i<R; i++){
		int u, v;
		cin >> u >> v;
		u--,v--; // para pasar de 1 base a 0 base
		adj[u].push_back({v, 1});
		adj[v].push_back({u, 1});
	}
	VI ans = VI(N, 1);
	VI d = ditra(0, ans); // porque pase de 1 a 0 base
	for(int i=0; i<d.size(); i++){
		if(d[i] >= INF) {
		   cout << "No" << endl;
		   return 0;
		}
	}
	cout << "Yes" << endl;
	for(int i = 1; i < N; i++){
	   cout << ans[i] << endl;
	}
  return 0;
}


Measured memory_bytes: 13708
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
  int N;
  int s = 0;
  scanf("%d", &N);
  while(N--)
  {
    int l, r;
    scanf("%d %d", &l, &r);
    s += (r - l + 1);
  }
  printf("%d\n", s);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int thp,tatk,ahp,aatk;
  scanf("%d%d%d%d",&thp,&tatk,&ahp,&aatk);
    do{
     ahp-=tatk;
     thp-=aatk;
    }while(thp>0&&ahp>0);
  if(ahp<=0&&thp>0)
    printf("Yes");
  else if(ahp<=0&&thp<=0)
    printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 1732
D=int(input())
c=list(map(int,input().split()))
last = [0] * 26
S=0
for d in range(1,D+1):
  s=list(map(int,input().split()))
  decline=0
  for j in range(26):
    decline += c[j]*(d-last[j])
  exp=S - decline + c[0]*(d-last[0]) + s[0]
  t=0
  for j in range(1,26):
    tmp = S - decline + c[j]*(d-last[j])+s[j]
    if tmp > exp:
      t=j
      exp=tmp
  S = exp
  last[t]=d
  print(t+1)

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

using namespace std;

int dp[500010];
int a[500010];

int main() {
    
    int n,k;
    cin >> n >> k;
    
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        dp[a[i]] = 1;
    }
    
    for (int i = 1; i <= k; ++i) {
        for (int j = 0; j < n; ++j) {
            if(i - a[j] >= 0) 
                dp[i] |= !dp[i - a[j]];
        }
    }
    
    puts(dp[k] ? "First" : "Second");
    return 0;
}


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

 int main(){
  	 ios::sync_with_stdio(false);
   	 cin.tie(0);  
	 vector<int> v(3); 
	 for(int i=0;i<3;i++){ 
		 cin>>v[i]; 
	 } 
	 sort(v.begin(),v.end()); 
	 int ct=v[2]-v[1]; 
	 v[0]+=ct; 
	 if(v[0]%2!=v[2]%2){ 
		 ct++; 
	         v[2]++; 	 
	 }   
	 ct+=(v[2]-v[0])/2; 
	 cout<<ct<<endl;
    
    return 0; 
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())


def solve(a, b, c, k):
    while b <= a:
        b *= 2
        k -= 1
    while c <= b:
        c *= 2
        k -= 1
    return k >= 0



print("Yes" if solve(a, b, c, k) else "No")


Measured memory_bytes: 61708
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;
using ll = long long;

#define EPS (1e-7) 

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

	string str = "No";

	sort(begin(L), end(L));

	const int mostlong = L.back();
	L.pop_back();
	const int sum = accumulate(cbegin(L), cend(L), 0);

	if (sum > mostlong) {
		str = "Yes";
	}

	cout << str << endl;


	return 0;
}

Measured memory_bytes: 256
N=int(input())
l = [list(map(int, input().split())) for i in range(N-1)]
for i in range(N):
    t=0
    for j in range(i,N-1):
        if t>l[j][1]:
            while 1:
                if t%l[j][2]==0:
                    break
                else:
                    t+=1
            t+=l[j][0]
        else:
            t=l[j][1]+l[j][0]
    print(t)   

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    sc.close();

    if (b >= a)
      System.out.println("unsafe");
    else
		System.out.println("safe");
  }
}

Measured memory_bytes: 35776
N, M=map(int, input().split())
if abs(N-M)>=2:
  print(0)
else:
  from math import factorial
  if abs(M-N)==1:
    r=0
  else:
    r=1
  ans=factorial(N)*factorial(M)*(2**r)
  ans=ans%(10**9+7)
  print(ans)

Measured memory_bytes: 10772
#include<stdio.h>
#include<string.h>
int main()
{
    int N,c=1;
    char s[105],i,j;
    scanf("%d",&N);
    scanf("%s",s);
    j=strlen(s);

       if(N%2==0)
       {
           for(i=0;i<j/2;i++)
           {


               if(s[i]!=s[i+N/2])

               c=2;


           }

       }
        else
        printf("No");

       if(c==1 && N%2==0)
       {
           printf("Yes");
       }
       else if (c == 2 &&  N%2==0) printf("No");


    return 0;
}


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

int main()
{
  int k, n, ans;
  cin >> n >> k;
  for (int i = 0; true; i++)
  {
    if (n / pow(k, i) < 1){
      ans = i;
      break;
    }
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
import Data.List

opposite :: Char -> Char
opposite d
    | d == 'U' = 'D'
    | d == 'D' = 'U'
    | d == 'N' = 'S'
    | d == 'S' = 'N'
    | d == 'E' = 'W'
    | d == 'W' = 'E'

turn :: Char -> Char -> Char
turn 'U' d = d
turn 'D' d = opposite d
turn f d
    | f == d          = 'D'
    | f == opposite d = 'U'
    | otherwise       = f

roll :: [(Int, Char)] -> Char -> [(Int, Char)]
roll fs d = map (\t -> (fst t, turn (snd t) d)) fs

solve :: String -> String -> String
solve f d = show $ fst $ (filter (\t -> snd t == 'U') $ foldl (\a c -> roll a c) fs d) !! 0
    where
        fs = zip (map read $ words f) "USEWND"

main :: IO ()
main = do
    f <- getLine
    d <- getLine
    putStrLn $ solve f d

Measured memory_bytes: 3656
from math import atan, pi

a, b, x = map(int, input().split())
if a * a * b > 2 * x:
    ans = atan(a * b * b / 2 / x)
else:
    ans = atan((2 * a * a * b - 2 * x) / a / a / a)

ans *= 180 / pi
print(ans)


Measured memory_bytes: 62384
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

struct SegmentTree {
	using P = std::pair<i64, int>;
	std::vector<P> seg;
	int sz = 1;
	
	const P e = {1LL << 60, -1};
	
	SegmentTree(int n) {
		while(sz < n) sz <<= 1;
		seg.assign(sz * 2, e);
	}
	void set(int k, P x) {
		k += sz;
		seg[k] = x;
		
		while(k >>= 1) seg[k] = std::min(seg[2 * k + 0], seg[2 * k + 1]);
	}
	P get(int a, int b) {
		P L = e, R = e;
		for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if(a & 1) L = std::min(L, seg[a++]);
			if(b & 1) R = std::min(seg[--b], R);
		}
		return std::min(L, R);
	}
	P operator[](int k) {
		return seg[k + sz];
	}
};

struct UnionFind {
	std::vector<int> data;
	
	UnionFind(int n) {
		data.assign(n, -1);
	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if(x == y) return false;
		if(data[x] > data[y]) std::swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	int find(int k) {
		if(data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
};

int main() {
	int n; i64 d; scanf("%d%lld", &n, &d); std::vector<i64> a(n);
	std::vector<std::pair<i64, int>> vec;
	for(int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		
		vec.push_back({a[i], i});
	}
	sort(begin(vec), end(vec));
	
	
	SegmentTree seg(n), tsugu(n);
	std::vector<std::pair<i64, std::pair<int, int>>> edges;
	for(auto v: vec) {
		int p = v.second;
		auto A = seg.get(p + 1, n);
		auto B = tsugu.get(0, p);
		i64 X = A.first, Y = B.first, x = A.second, y = B.second;
		i64 tmp = d * p, pmt = d * (n - p - 1);
		
		if(x != -1) edges.push_back({X + a[p] - tmp, {p, x}});
		if(y != -1) edges.push_back({Y + a[p] - pmt, {p, y}});
		seg.set(p, {a[p] + tmp, p});
		tsugu.set(p, {a[p] + pmt, p});
	}
	sort(begin(edges), end(edges));
	
	i64 ans = 0;
	UnionFind uf(n);
	for(int i = 0; i < edges.size(); i++) {
		int to = edges[i].second.first, from = edges[i].second.second;
		i64 cost = edges[i].first;
		
		if(uf.unite(to, from)) ans += cost;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 32364
# include <iostream>
# include <iomanip>

int main() {
	double r;
	std::cin >> r;
	double const PI = 3.14159265358979;
	double surface = 2 * r * PI;
	double area = PI * r * r;
	std::cout << std::setprecision(10);
	std::cout << std::fixed;
	std::cout << area << " " << surface << std::endl;
	
	std::cin >> r;
	return 0;
}

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

#define ll long long
#define endl "\n"

using namespace std;

int main() {string s;
cin >> s;
int sum = 0;
for (int i = 0; i < s.size(); ++ i) sum += s[i] - '0';
if (sum % 9 == 0) cout << "Yes";
else cout << "No";
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long int li;
typedef long long ll;

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

    int n; cin >> n;
    int h[n]; for (int i=0; i<n; i++) cin >> h[i];
    
    // dp table
    vector<int> dp(n+10, 0); 
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    
    int ans = 0;

    for (int i=2; i<n; i++)
    {
        dp[i] = min(dp[i-2] + abs(h[i-2]-h[i]), dp[i-1] + abs(h[i-1]-h[i]));
    }
    
    cout << dp[n-1] << "\n";

    return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
int main(){
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
  for(int i = 0; i <= N; ++i) {
    for(int j = 0; j <= N; ++j) {
      int b = N - (i * R + j * G);
      if(b >= 0 && b % B == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,x,count=0,i=0,j=0,k=0;

	while(1){
		scanf("%d %d",&n,&x);
		if(n==0 && x==0)
			break;
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				k=x-i-j;
				if(j<k && k<=n)
					count++;
			}
		}
	printf("%d\n",count);
	count=0;
	}
}

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



int main(){
	
	map<string,int> mp;
	int N;
	cin>>N;
	
	for(int i=0;i<N;i++){
		string s;
		cin>>s;
		mp[s]++;
	}
	
	int M;
	cin>>M;
	
	for(int i=0;i<M;i++){
		string t;
		cin>>t;
		mp[t]--;
	}
	
	int ans = 0;
	for(auto a:mp){
		ans = max(ans,a.second);
	}
	
	cout<<ans<<endl;
		
    return 0;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	int n;
  string s;
  cin >> n >> s;
  ll cnt = 0, pre = 0;
  rep(i, n) {
    if (s[i] == '(') cnt++;
    else {
      cnt--;
      if (cnt < 0) pre = max(pre, -cnt);
    }
  }
  rep(i, pre) s = "(" + s;
  n += pre;
  cnt = 0;
  rep(i, n) {
    if (s[i] == '(') cnt++;
    else cnt--;
  }
  rep(i, cnt) s += ")";
  cout << s << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    Vec v(n);
    Vec m;
    ll mcount = 0;
    ll ans = 0;
    rep(i,n){
        cin>>v[i];
        if(v[i]<=0){
            m.pb(-v[i]);
            mcount++;
            ans += -v[i];
        }else{
            m.pb(v[i]);
            ans += v[i];
        }
    }
    sort(ALL(m));
    if(mcount%2==1){
        ans -= m[0]*2;
    }
    cout<<ans<<endl;
    return  0;
}


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

int main()
{
    vector<vector<int>> A(3, vector<int>(3));
    vector<vector<int>> ans(3, vector<int>(3));
    int N;
    int temp;
    rep(i, 3)
    {
        rep(j, 3) cin >> A[i][j];
    }
    cin >> N;
    rep(i, N)
    {
        cin >> temp;
        rep(i, 3)
        {
            rep(j, 3)
            {
                if (temp == A[i][j])
                    ans[i][j] = 1;
            }
        }
    }
    rep(i, 3)
    {
        rep(j, 3)
        {
            if (ans[i][j] != 1)
                break;
            if (j == 2)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    rep(j, 3)
    {
        rep(i, 3)
        {
            if (ans[i][j] != 1)
                break;
            if (i == 2)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    rep(i, 3)
    {
        if (ans[i][i] != 1)
            break;
        if (i == 2)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    rep(i, 3)
    {
        if (ans[2 - i][i] != 1)
            break;
        if (i == 2)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

int n,ans=0;
int a[200005];

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)
	{
		if (a[a[i]]==i)  ans++;
	}
	cout<<ans/2<<endl;
	
	return 0;
}

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

#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<int,pi>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int I_LIMIT = 999999999;
ll L_LIMIT = 999999999999999999;
ll mod = 1e9+7;

void solve()
{
    ll n,i,ans=0;
    cin>>n;
    ll A[n];
    for(i=0;i<n;i++)
        cin>>A[i];
    
    ll pre[n+1];
    pre[n]=0;
    for(i=n-1;i>=0;i--)
        pre[i]=(pre[i+1]+A[i])%mod;
    
    for(i=0;i<n-1;i++)
        ans = (ans+A[i]*pre[i+1])%mod;
    
    cout<<ans<<endl;
}
int main()
{
    IOS;
    solve();
}


Measured memory_bytes: 6772
M,D=map(int,input().split())
s=0
if M>=4 and D>=22:
    for i in range(4,M+1):
        for j in range(22,D+1):
            t=j//10
            r=j%10
            if t>=2 and r>=2:
                if t*r==i:
                    s+=1
print(s)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


int main(){
	int n; cin >> n;
	string s1,s2; cin >> s1 >> s2;
	int i = 0;
	bool isrow;
	mint ans(1);
	if(s1[0] == s2[0]){
		ans *= mint(3);
		i = 1;
		isrow = false;
	}else{
		ans *= mint(6);
		i = 2;
		isrow = true;
	}

	while(i < n){
		if(s1[i] == s2[i]){
			if(isrow){
				
			}else{
				ans *= mint(2);
			}
			isrow = false;
			i++;
		}else{
			if(isrow){
				ans *= mint(3);
			}else{
				ans *= mint(2);
			}
			isrow = true;
			i += 2;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
import math
x,n=map(int,input().split())
l=[]
for i in range(x):
    a,b=map(int,input().split())
    s=math.sqrt((a**2)+(b**2))
    l.append(s)
count=0
for i in l:
    if i<=n:
        count=count+1
print(count)


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

int main() {


    int h, n;
    cin >> h >> n;
    int a = 0;
    for(int i=0; i<n; i++){
    	cin >> a;
    	h -= a;
    }
    if(h > 0){
    	cout << "No" << endl;
    }else{
    	cout << "Yes" << endl;
    }
} 

Measured memory_bytes: 256
#include <cstdio>
int n, a, c[5];
int main() {
	scanf("%d", &n);
	while(n--) scanf("%d", &a), c[a%4]++;
	c[1] += c[3];
	puts(c[0]>=c[1] || c[0]+1==c[1] && c[2]==0 ? "Yes":"No");
	return 0;
}

Measured memory_bytes: 128
# encoding: "utf-8"

from collections import defaultdict

# class Stdin:
#     @staticmethod
#     def read_line(converter=str):
#         return [converter(x) for x in input().split()]
    
#     @staticmethod
#     def read_lines(n, converter=str):
#         result = list()
#         for _ in range(n):
#             result.append(Stdin.read_line(converter))
#         return result
    
#     @staticmethod
#     def convert(data, converter):
#         assert(len(data) == len(converter))
#         return tuple(map(lambda x, f: f(x), data, converter))

#     @staticmethod
#     def convert_lines(datas, n, converter):
#         return [converter(data, n, converter) for data in datas]


def first_count_and_pop(xs):
    cnt = 0
    fst = xs[0]
    # cnt = xs.count(fst)
    for x in xs:
        if x != fst:
            break
        cnt += 1
    return (cnt, xs[cnt:])    
    

def main():
    _ = input()
    # xs = Stdin.read_line(converter=int)
    xs = [int(x) for x in input().split()]
    xs.sort()
    ys = defaultdict(int)
    # for key in xs:
    #     ys[key] += 1
    #     ys[key-1] += 1
    #     ys[key+1] += 1
    for x in xs:
        key = x
        ys[key] += 1
        ys[key-1] += 1
        ys[key+1] += 1

    print(max(ys.values()))

# def main_():
#     input()
#     xs = Stdin.read_line(converter=int)
#     xs.sort()
#     counts = list()
#     for i in range(100000):
#         if not xs:
#             counts.extend([0] * (100000 - len(counts)))
#             break     
#         elif i == xs[0]:
#             cnt, xs = first_count_and_pop(xs)
#             counts.append(cnt)
#         else:
#             counts.append(0)
#     m = 0
#     for i in range(0, 100000):
#         if i == 0:
#             temp = counts[i] + counts[i+1]
#         elif i == 100000 - 1:
#             temp = counts[i-1] + counts[i]
#         else:
#             temp = counts[i-1] + counts[i] + counts[i+1]
#         if m < temp:
#             m = temp
#     print(m)

if __name__ == "__main__":
    main()

Measured memory_bytes: 20284
// #ifdef DEBUG
// #define _GLIBCXX_DEBUG
// #endif
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

// these require C++11
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define int long long

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

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

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

typedef complex<double> point;

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

int calc_power(const vector<int>& ss,const int p,const int n,const int L){
    if(n < p) return calc_power(ss,n,p,L);
    return (ss[n] - ss[p-1]) / L;
}

int solve(int ii,int ui,int di,vector<int>& ss,vector<int>& k,const int L,vector<vector<int>>& memo){
    if(ui > di) return solve(ii,di,ui,ss,k,L,memo);
    if(memo[ui][di] >= 0) return memo[ui][di];
    int u = k[ui];
    int d = k[di];
    int i = k[ii];
    if(ii == k.size()-1){
        return memo[ui][di] = calc_power(ss,u,i,L) + calc_power(ss,d,i,L);
    }else{
        return memo[ui][di] = min(calc_power(ss,u,i,L) + solve(ii+1,ii,di,ss,k,L,memo),
                                  calc_power(ss,d,i,L) + solve(ii+1,ui,ii,ss,k,L,memo));
    }
}

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

    int N,M,L;
    cin >> N >> M >> L;

    vector<int> K(N);
    vector<int> S(M);
    vector<vector<int> > memo(N,vector<int>(N,-1));
    for(int& i : K) cin >> i;
    sort(all(K));
    for(int& i : S) cin >> i;

    vector<int> SS(M+1);
    for(int i=1;i<SS.size();i++){
        SS[i] = SS[i-1] + S[i-1];
    }
    cout << solve(1,0,0,SS,K,L,memo) << endl;
    return 0;
}

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


def main():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    plus = [a[-1]]
    minus = [a[0]]

    # KeyInsight
    # 具体的な数字ではなく，変数として扱う
    # 数列のうち，1つは正，もう一つは負として扱う
    # 残りは，正の値となるように符号を調整
    # See:
    # https://www.youtube.com/watch?v=TbobvdA6AlE
    for ai in a[1:-1]:
        if ai >= 0:
            plus.append(ai)
        else:
            minus.append(ai)

    print(sum(plus) - sum(minus))

    # 正として扱う要素を1つ以外，操作(x - y)を行う
    for p in plus[1:]:
        print(minus[-1], p)
        minus[-1] -= p

    for m in minus:
        print(plus[0], m)
        plus[0] -= m


if __name__ == '__main__':
    main()


Measured memory_bytes: 14016
n,m,l=map(int,input().split())
a=[]

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

c=[]
L=[]
o=0
for i in range(l):
    for j in range(n):
        for k in range(m):
            o+=a[j][k]*b[k][i]
        c.append(o)
        o=0
    L.append(c[i*n:i*n+n])
    
for i in range(n) :
    for j in range(l) :
        if j == l - 1 :
            print(L[j][i])
        else :
            print(L[j][i], end = " ")
    
   



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

int main ()
{
 
  int a1, a2, a3;
  std::cin >> a1 >> a2 >> a3;
  if (a1+a2+a3 >= 22)
  {
    std::cout << "bust";
  }
  else
  {
    std::cout << "win";
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
#define ll long long
using namespace std;
int n,k;
int a[200005];
bool check(int x)
{
    int ans = 0;
    for(int i=1; i<=n; ++i){
        ans += (a[i]-1)/x; //偶数4/2 = 2但实际只切了1次，所以减一
    }
    return ans<=k;
}
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    cin>>n>>k;
    int right = 0;
    for(int i=1; i<=n; ++i){
        cin>>a[i];
        right = max(right,a[i]);
    }
    int left = 1;
    while(left <= right){
        int mid = left + (right-left)/2;
        if(check(mid)){ //如果ans<=k,则说明次数小，要求最小的最长长度，切割次数要实现最多，需要向k次继续靠近
            right = mid-1;  //那么切割长度应小一些，次数会大一些
        }
        else
            left = mid+1;
    }
    cout<<left<<endl;
    return 0;
}


Measured memory_bytes: 4424
/**
 *  author: MahfuzAhmed
 *  created: 26.08.2019
**/

#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;


int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
       
    #ifdef _DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    ll a, b; cin >> a >> b;
    
    if(a > b){
        swap(a, b);
    }
    
    ll cnt = a;
    
    b -= a;
    a = 0;
    
    
    
    while(b >= a){
        if(a == b){
            cout << cnt << "\n";
            return 0;
        }else{
            a++;
            b--;
            cnt++;
        }
    }
    
    cout << "IMPOSSIBLE\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 60;
int grid[N][N], cpy[N][N];

bool solve(int n, int k) {
  if (k != 44)
    return false;

  vector<VI> pages;
  pages.emplace_back();
  for (int i = 1; i <= k; i++) {
    pages[0].push_back(i);
  }

  int s = k - 1;
  for (int i = 1, v = k + 1; i <= s; i++) {
    for (int j = 1; j <= s; j++) {
      grid[i][j] = v++;
    }
  }

  for (int r = 1; r <= k; r++) {
    for (int i = 1; i <= s; i++) {
      pages.push_back({r});
      for (int j = 1; j <= s; j++) {
        pages.back().push_back(grid[i][j]);
      }
    }

    for (int i = 1; i <= s; i++) {
      for (int j = 1; j <= s; j++) {
        int ii = j;
        int jj = i + j - 1;
        if (jj > s) jj -= s;
        cpy[i][j] = grid[ii][jj];
      }
    }

    memcpy(grid, cpy, sizeof grid);
  }

  cout << n << ' ' << k << '\n';
  assert((int) pages.size() == n);
  for (auto& page: pages) {
    assert((int) page.size() == k);
    sort(page.begin(), page.end());
    auto it = unique(page.begin(), page.end());
    assert(it == page.end());
    for (int p: page) {
      cout << p << ' ';
    }
    cout << '\n';
  }

  return true;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  for (int n = 1000; n <= 2000; n++) {
    int d2 = 4 * n - 3;
    int d_approx = round(sqrt(d2));
    for (int dd = -2; dd <= +2; dd++) {
      int d = d_approx + dd;
      if (d * d == d2 && d % 2 == 1) {
        int k = (d + 1) / 2;
//        cerr << n << ' ' << k << endl;
        if (solve(n, k)) {
          return 0;
        }
        break;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3780