akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

bool is_prime(long long n)
{
    if (n == 1) {
        return false;
    }

    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main()
{
    long long n, m;
    std::cin >> n >> m;

    if (n > 1 && m > 1) {
        std::cout << (n - 2) * (m - 2) << std::endl;
    } else if (n > 1) {
        std::cout << n - 2 << std::endl;
    } else if (m > 1) {
        std::cout << m - 2 << std::endl;
    } else {
        std::cout << 1 << std::endl;
    }
}


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

const int mod=1000000007;
int N,M;
long long DP[301][302][302];

int main(){
	cin>>N>>M;
	DP[0][1][1]=1;
	for(int i=0;i<M;++i){
		for(int j=1;j<=N;++j){
			for(int k=1;k<j;++k){
				DP[i+1][j][j]+=DP[i][j][k]*k;
				DP[i+1][j][k]+=DP[i][j][k]*(j-k);
				DP[i+1][j+1][k]+=DP[i][j][k]*(N-j);
				DP[i+1][j][j]%=mod;
				DP[i+1][j][k]%=mod;
				DP[i+1][j+1][k]%=mod;
			}
			//j==kのときの処理
			DP[i+1][j+1][j]+=DP[i][j][j]*(N-j);
			DP[i+1][j][j]+=DP[i][j][j]*j;
			DP[i+1][j+1][j]%=mod;
			DP[i+1][j][j]%=mod;
		}
	}
	cout<<DP[M][N][N]<<endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

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

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

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

vector<int> common(char* s, char* t, int n) {
    vector<int> ans(n);
    int r = 0;
    forn(i, 0, n) {
        if (r < i) r = i;
        while (r < n && s[r] == t[r]) ++r;
        ans[i] = r - i;
    }
    return ans;
}

const int N = 2017;
char s[N][N], t[N][N];
int len[N][N];

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    forn(i, 0, h) scanf("%s", s[i]);
    forn(i, 0, h) forn(j, 0, w) t[i][j] = char('.' + '#' - s[i][j]);
    forn(i, 0, h - 1) {
        vector<int> tmp = common(s[i], s[i + 1], w);
        forn(j, 0, w) len[i][j] = tmp[j];
        tmp = common(s[i], t[i + 1], w);
        forn(j, 0, w) setmax(len[i][j], tmp[j]);
    }
    ll ans = w;
    forn(j, 0, w) {
        vector<int> lft(h - 1), rgt(h - 1);
        vector<pair<int, int>> q;
        q.eb(-1, -1);
        forn(i, 0, h - 1) {
            while (q.back().fs >= len[i][j]) q.pop_back();
            lft[i] = q.back().sn;
            q.eb(len[i][j], i);
        }
        q.clear();
        q.eb(-1, h - 1);
        ford(i, 0, h - 1) {
            while (q.back().fs >= len[i][j]) q.pop_back();
            rgt[i] = q.back().sn;
            q.eb(len[i][j], i);
        }
        forn(i, 0, h - 1) {
            int cnt = rgt[i] - lft[i];
            setmax(ans, 1ll * cnt * len[i][j]);
        }
    }
    cout << ans << '\n';
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef pair<double, double> P;

void print_line(vector<int> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

void warshall_floyd(int n, vector<vector<ll>> &d) {
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

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

    vector<vector<ll>> distances(n, vector<ll>(n, INF));
    rep(i, n) distances[i][i] = 0;
    rep(i, n) {
        int j, k;
        cin >> j >> k;

        rep(l, k) {
            int u, c;
            cin >> u >> c;
            distances[j][u] = c;
        }
    }

    warshall_floyd(n, distances);

    rep(i, n) cout << i << ' ' << distances[0][i] << endl;

}




Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;

int X, Y;

LL frac(int n) {
    LL res = 1;
    for (LL i = 2; i <= n; i++) res = (res*i)%MOD;
    return res;
}

LL ksm(LL x, LL p, LL m) {
    if (p == 0) return 1;
    LL ans = ksm(x, p/2, m);
    ans = (ans*ans)%m;
    if (p%2 == 1) ans = (ans*x)%m;
    return ans;
}

LL inv(LL x, LL p) {
    return ksm(x, p-2, p);
}

LL cal(int m, int n) {
    return frac(n)*(inv(frac(n-m), MOD)%MOD)%MOD*(inv(frac(m), MOD)%MOD)%MOD;
}

int main() {
    scanf("%d %d", &X, &Y);

    if (2*X-Y >= 0 && 2*Y-X >= 0 && ((2*X-Y)%3 == 0) && ((2*Y-X)%3 == 0)) {
        int a = (2*X-Y)/3, b = (2*Y-X)/3;
        printf("%lld\n", cal(min(a, b), a+b));
    }
    else {
        printf("0\n");
    }
    return 0;
}


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

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

    auto children = vector<vector<int>>(N);
    for (auto v = 1; v < N; v++)
    {
        int parent; cin >> parent;
        parent--;
        children[parent].push_back(v);
    }

    const function<int(int)> depth = [&](const int v)
    {
        if (children[v].empty()) return 0;

        auto child_depths = vector<int>();
        for (const auto child : children[v])
            child_depths.push_back(depth(child));
        sort(begin(child_depths), end(child_depths), greater<int>());

        auto distance = 1;
        for (auto& x : child_depths)
        {
            x += distance;
            distance++;
        }

        return *max_element(begin(child_depths), end(child_depths));
    };
    cout << depth(0) << endl;
}


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

int main(){
    int a,b,c;
    cin >>a>>b>>c;
    if (a+b <= b+c and a+b <= a+c ){
        cout << a+b << endl;
    }
    else if (b+c <= a+b and b+c <= a+c){
        cout << b+c << endl;
    }
    else if (a+c <= a+b and a+c <= b+c){
        cout << a +c <<endl;
    }
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const int siz = 5 * 1e5 + 7;
int bit[27][siz];
void update(int idx, int val, int which) {
	while (idx < siz) {
		bit[which][idx] += val;
		idx += (idx & -idx);
	}
}
int query(int idx, int which) {
	int sum = 0;
	while (idx) {
		sum += bit[which][idx];
		idx -= (idx & -idx);
	}
	return sum;
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	string s;
	cin >> s;
	s = '*' + s;
	for (int i = 1; i <= n; i++) {
		int have = s[i] - 'a';
		update(i, 1, have);
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int type;
		cin >> type;
		if (type == 1) {
			int l;
			char ch;
			cin >> l >> ch;
			update(l, -1, s[l] - 'a');
			update(l, +1, ch - 'a');
			s[l] = ch;
		}
		else {
			int l, r;
			cin >> l >> r;
			int ans = 0;
			for (int k = 0; k < 26; k++) {
				int have = query(r, k) - query(l - 1, k);
				if (have > 0)ans++;
			}
			cout << ans << endl;
		}
	}
}


Measured memory_bytes: 54580
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P);
P dequeue(void);
int min(int,int);


int main(){
  int elaps = 0, c;
  int i, q,n,s;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head!=tail)
    {
      u = dequeue();
      s = min(q,u.t);
      u.t -=  s;
      elaps += s;
      if(u.t <= 0){
	printf("%s %d\n",u.name ,elaps);
      }
      else {
	enqueue(u);
      }
    }
  
  
  return 0;
}

void enqueue(P x){
  Q[tail] = x;
  
  tail =(tail+1)%LEN;
}



P dequeue(){
  P x;
  x = Q[head];
  head = (head+1)%LEN;
  
    return x;
}

int min(int a,int b)
{
  if(a < b)return a; 
  else return b;
}

Measured memory_bytes: 10756
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

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

int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n, 0);
    for(int i = 0; i < q; i++){
        int b;
        cin >> b;
        b--;
        a[b]++;
    }
    for(int i = 0; i < n; i++){
        if(k > q){
            cout << "Yes" << endl;
            continue; 
        }else if(a[i] > q-k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
   return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N;
  cin >> N;

  int num = (N + 111 - 1) / 111;
  cout << num * 111 << endl;
}


Measured memory_bytes: 3632
import math
import collections
import itertools

def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return

def resolve():

    S=input()
    if(S[len(S)-1]=="s"):
        S=S+"es"
    else:
        S=S+"s"
    print(S)

resolve()


Measured memory_bytes: 9404
import math
n, k = map(int, input().split())

m = math.ceil(math.log2(k) - math.log2(1))

ans = 0
ans_ = 0
for i in range(1, n+1):
    if i >= k:
        ans_ += 1
    else:
        x = math.ceil(math.log2(k) - math.log2(i))
        ans += 2 ** (m - x)

a = (ans/(2**m)+ans_)/n
print(a)

Measured memory_bytes: 3188
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int a[1000007];
int main()
{
	int m;
	scanf("%d",&m);
	long long int ans=1;
	long long int anss=1;
	int i;
	for(i=0;i<m;i++)
		scanf("%d",a+i);
	for(i=0;i<m;i++)
		if(!(a[i]%2))
			anss=anss*2;
	for(i=0;i<m;i++)
		ans=ans*3;
	printf("%lld\n",ans-anss);
	return 0;
}

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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a)
{
	return mod_pow(a , mod-2 , mod);
}

void solve() 
{
	string s;
	
	cin >> s;
	
	int sm = 0;
	
	for(auto u : s) {
		sm += (u-'0');
		sm %= 9;
	}
	
	if(sm == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

signed main() {
    fast;

    int t = 1;

	//cin >> t;

    while(t--) {
        solve();
    }

    return 0;
}


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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 2e5 + 5;
const ll INF = 1e17;
const double eps = 1e-12 , PI = acos(-1);

int n , m;

ii a[N];

void solve(int cs){
    scanf("%d" , &n);

    for(int i = 0 ; i < n ; i ++){
            scanf("%d" , &a[i].second);
            a[i].first = i + 1;
    }

    sort(a , a + n , [&](ii x , ii y){return x.second < y.second;});

    for(int i = 0 ; i < n ; i ++){
            printf("%d%c" , a[i].first , i == n ? '\n' : ' ');
    }
}

main(){
    int t = 1;
    //scanf("%d" , &t);

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}



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

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

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

const int MOD = 1000000007;

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

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

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

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

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

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

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

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

bool exist(int a, VI& p){
	int n = p.size();
	rep(i,n){
		if(a == p[i]){
			return true;
		}
	}
	return false;
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int x, n;
	cin>>x>>n;
	VI p(n);
	rep(i,n){
		cin>>p[i];
	}
	int ans;
	int a = 0;
	while(true){
		if(!exist(x - a, p)){
			ans = x - a;
			break;
		}
		if(!exist(x + a, p)){
			ans = x + a;
			break;
		}
		a++;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3632
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT

//#define MORE_THAN_ONE_TESTCASE // COMMENT IT








#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vvi vector<vector<int>>
#define viil vector<vector<long long>>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define mci map<char , int >
#define mcl map<char , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(i,x) for(auto i=0 ; i<x; ++i)
#define repa(i,a,b) for(auto i=a; i<b; ++i)
#define repe(i,x) for(auto i=0; i<=x; ++i)
#define repea(i,a,b) for(auto i=a;i<=b;++i)
#define ef else if
#define wh while
#define el else
#define ivar(x) int x; cin>>x
#define lvar(x) bint x; cin>>x
#define svar(x) string x; cin>>x
#define cvar(x) char x; cin>>x
#define fvar(x) float x; cin>>x
#define dvar(x) double x; cin>>x
#define endl '\n'
using namespace std;


auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 
    ivar(a);ivar(b);
    a--;
    b--;
    cout<<a*b<<endl;
    return ;
}

int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

typedef long long ll;

#define        optimize           ios::sync_with_stdio(0); cin.tie(0);
#define PI    acos(-1.0)
#define pb push_back
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define RESET(a, b) memset(a, b, sizeof(a))
#define pii pair <int, int>
#define gcd(a, b) __gcd(a, b)
#define min3(a, b, c) min(c, min(a, b))
#define max3(a, b, c) max(c, max(a, b))

#define        MX        200005

int ara[MX];
int dp[MX];

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

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

    for(int i = 1; i <= k; i++){
        for(int j = 0; j < n; j++){
            if(i-ara[j] >= 0 && !dp[i-ara[j]]){
                dp[i] = 1;
            }
        }
    }
    puts(dp[k] ? "First" : "Second");
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
unordered_map<string,int> mp;
string str;
long long n, ans;
int main() {
	cin>>n;
	for (int i = 0; i < n; i++) {
		cin>>str;
		sort(str.begin(),str.end());
		mp[str]++;
	}
	for (auto i = mp.begin(); i != mp.end(); i++) {
        long long x = i->second;
        ans += ( x*(x-1) )/2;
    }
	cout<<ans;
	return 0;
}

Measured memory_bytes: 10660
n,k = gets.strip.split.map(&:to_i)
rec = Array.new(10**5,0)
n.times do
  a,b = gets.strip.split.map(&:to_i)
  rec[a-1] += b
end

s = Array.new(rec.length+1)
s[0] = 0
0.upto(rec.length-1) do |i|
  s[i+1] = s[i] + rec[i]
end

i = 0
while s[i] < k do
  i += 1
end
puts i

Measured memory_bytes: 15812
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;


int main(){
    int N;cin>>N;
    string s;cin>>s;
    set<string> st;
    string tmp="...";
    int f1,f2,f3,ite;
    for(char AA='0';AA<='9';AA++){
        for(char AB='0';AB<='9';AB++){
            for(char AC='0';AC<='9';AC++){
                ite=0;f1=1;f2=0,f3=0;
                while(ite<N){
                    if(f1==1&&s.at(ite)==AA){
                        f1=0;f2=1;
                    }
                    else if(f2==1&&s.at(ite)==AB){
                        f2=0;f3=1;
                    }
                    else if(f3==1&&s.at(ite)==AC){
                        f3=0;f1=1;
                        tmp.at(0)=AA;
                        tmp.at(1)=AB;
                        tmp.at(2)=AC;
                        st.insert(tmp);
                    }
                    ite++;
                }
            }
        }
    }
    cout<<st.size()<<endl;
}







Measured memory_bytes: 384
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: x,n,i,j
    integer(int64), allocatable:: f(:)

    read*, x
    n=0
    do while( n**5 <= 100000000000000000_8)
        n=n+1
    end do
    allocate(f(-n:n))

    do i=-n,n
        f(i) = i**5
    end do

    do i=-n,n
        do j=-n,n
            if (f(i)-f(j) == x) then
                print*, i,j 
                stop
            end if
        end do
    end do
end program name

Measured memory_bytes: 2836
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    vector<int> towns;
    for(int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        towns.push_back(i);
    }
    vector<vector<double> > dist(n, vector<double>(n));
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            dist[i][j] = sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2));
        }
    }
    vector<double> ans;
    do {
        double length = 0;
        for(int i = 0; i < towns.size() - 1; i++) {
            length += dist[towns[i]][towns[i + 1]];
        }
        ans.push_back(length);
    } while(next_permutation(towns.begin(), towns.end()));
    cout << fixed;
    cout << setprecision(8) << accumulate(ans.begin(), ans.end(), 0.0) / (double)ans.size() << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

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; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

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

  int n; cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  rep(i, 2) rep(j, n) cin >> a[i][j];

  vector<int> b(n+1, 0), c(n+2, 0);
  for (int i = 1; i <= n; i++) {
    b[i] = b[i-1] + a[0][i-1];
  }
  for (int i = n; i > 0; i--) {
    c[i] = c[i+1] + a[1][i-1];
  }

  int ans = 0;
  rep(i, n+1) chmax(ans, b[i] + c[i]);

  cout << ans << endl;

  return 0;
}


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

int main(void){
   int i,a[10];
   for(i=0; i<10; i++)
    cin>>a[i];
    sort(a,a+10);
    for(int i=0;i<3; i++)
    cout<<a[9-i]<<endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m; cin >> n >> m;
	vector<int> at(m, -1), cnt(m + 1, 0), stk;
	cnt[0] = n;
	int q; cin >> q;
	vector<int> op(q);
	for(int & v : op) cin >> v;
	reverse(op.begin(), op.end());
	for(int & v : op){
		v--;
		if(at[v] == -1){
			stk.push_back(v);
			at[v] = stk.size();
			cnt[at[v]] = 1;
		} else {
			if(cnt[at[v] - 1] > cnt[at[v]]){
				cnt[at[v]]++;
			}
		}
	}
	int len = stk.size() + 1;
	vector<int> res;
	for(int i = 0, j = 0; i < len; i = j){
		while(j < len && cnt[j] == cnt[i]) j++;
		if(!res.empty() && j != len) continue;
		vector<int> holm;
		for(int k = 1; k < j; k++) holm.push_back(stk[k - 1]);
		for(int k = 0; k < m; k++) if(at[k] == -1 || at[k] >= j) holm.push_back(k);
		if(res.empty()) res = holm;
		else if(res != holm){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3068
MI = lambda :(map(int,input().split()))
x = int(input())
if x>1799:
	print(1)
elif x>1599:
	print(2)
elif x>1399:
	print(3)
elif x>1199:
	print(4)
elif x>999:
	print(5)
elif x>799:
	print(6)
elif x>599:
	print(7)
else:
	print(8)

Measured memory_bytes: 61988
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

template<class T> void swap(T &a, T &b ){
    T temp;
    temp = a;
    a = b;
    b = temp;   
}

int main(){
    ULL X;
    ULL count;
    ULL max;
    cin >> X;
    count = X / 100;
    max = count * 5;
    if( X % 100 <= max){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2**20)

class Node:
    def __init__(self):
        self.id = None
        self.p = None
        self.left = None
        self.right = None
        self.deg = None
        self.att = None
        self.depth = None
        self.height = None
        self.sibling = None

def SetDepth(u, p):
    T[u].depth = p
    pr, pl = 0, 0
    if T[u].right != -1:
        pr = SetDepth(T[u].right, p+1)
    if T[u].left != -1:
        pl = SetDepth(T[u].left, p+1)
    p = max(p, pr, pl)
    T[u].height = p - T[u].depth
    return p

n = int(input())
T = [None] * n
for i in range(n):
    temp = Node()
    T[i] = temp

for i in range(n):
    d = 0
    L = [int(x) for x in input().split()]
    v, l, r = L[0], L[1], L[2]
    T[v].id = v
    T[v].left = l
    T[v].right = r
    if l != -1:
        T[l].p = v
        d += 1
    if r != -1:
        T[r].p = v
        d += 1
    T[v].deg = d 

for i, t in enumerate(T):
    if t.p == None:
        t.att = 'root'
        t.p = -1
        maxd = SetDepth(i, 0)
    elif t.deg == 0:
        t.att = 'leaf'
    else:
        t.att = 'internal node'
    if t.p == -1:
        t.sibling = -1
    else:
        if T[t.p].left == t.id:
            if T[t.p].right == None:
                t.sibling = -1
            else:
                t.sibling = T[t.p].right
        else:
            if T[t.p].left == None:
                t.sibling = -1
            else:
                t.sibling = T[t.p].left

for i in range(n):
    print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'.format(T[i].id, T[i].p, T[i].sibling, T[i].deg, T[i].depth, T[i].height, T[i].att))


Measured memory_bytes: 5628
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <cmath>
#include <algorithm>

int main(int argc, char *argv[]){
    long int A,B;
    std::cin >> A >> B;
    long int K = A+B;
    if((K&1) != 0){
        std::cout << "IMPOSSIBLE" << std::endl;
        return 0;
    }
    std::cout << K/2 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define ll long long
    #define f   first
    #define s   second
    #define pb          push_back
    #define mod         1000000007
    #define hell        998244353
    #define inf         1000000000000000000LL
    using namespace std;
    ll n,k,m,sum,q;
    ll s,l,r,x,y,h,w;
    //ll a[1005][1005];
    
    void solve()
    {   
        ll n1,n2,n3;
        string s1,s2;
        cin>>s1>>s2;
        n=s1.size();
        m=s2.size();
        if(m!=(n+1)) {cout<<"No";return;}
        else
        {
            for(int i=0;i<n;i++){
                if(s1[i]!=s2[i]) {cout<<"No";return;}
            }
            cout<<"Yes";
        }
        
    }   
    int main()
    {   
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
        //cout<<primes.size();
        ll t=1;
      //cin>>t;
        while(t--)
            solve();
    }


    


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
long long dp[101][25];
int main(){
      int n,tmp;
      cin >> n >> tmp;
      dp[0][tmp] = 1;
      for(int i = 1;i<=n-2;i++)
      {
            cin >> tmp;
            for(int j = 0;j <= 20;j++)
            {
                  if(j+tmp<=20)dp[i][j]+=dp[i-1][j+tmp];
                  if(j>=tmp)dp[i][j]+=dp[i-1][j-tmp];
            }

      }
      cin >> tmp;
      cout << dp[n-2][tmp]<<endl;

}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b==c+d) cout << "Balanced" << endl;
  else if(a+b>c+d) cout << "Left" << endl;
  else cout << "Right" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll n, a[3005], dp[3005][3005];

ll rec(bool turn, int i, int j){
    if(i>j) return 0;
    if(dp[i][j]<LLINF) return dp[i][j];
    ll res = (turn?LLINF:-LLINF);
    if(turn){
        res = max(rec(!turn,i+1,j)+a[i],rec(!turn,i,j-1)+a[j]);
    }
    else{
        res = min(rec(!turn,i+1,j)-a[i],rec(!turn,i,j-1)-a[j]);
    }
    dp[i][j] = res;
    return res;
}

int main() {
    cin >> n;
    REP(i,n) cin >> a[i];
    REP(i,n)fill(dp[i],dp[i]+n,LLINF);
    cout << rec(true,0,n-1) << endl;
    return 0;
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;

#define ERR 0.000001
int main(){
    int n, d;
    scanf("%d %d", &n, &d);
    int point[n][d];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            scanf("%d", &point[i][j]);
        }
    }

    
    int count = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            
            double sqaresum = 0;
            for(int k = 0; k < d; k++){
                sqaresum += (point[i][k] - point[j][k]) * (point[i][k] - point[j][k]);
            }
            double rt = sqrt(sqaresum);
            int rt_int = rt;
            double err = abs(rt - (double)rt_int);
            if(err < ERR){
                count++;
            }
        }
    }
    printf("%d\n", count);

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
ll f(ll x, int c, int d) {
  ll res = x;
  res -= x/c;
  res -= x/d;
  res += x/lcm(c,d);
  return res;
}
 
int main() {
  ll a, b;
  int c, d;
  cin >> a >> b >> c >> d;
  ll ans = f(b,c,d) - f(a-1,c,d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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

int main(){
    int a, b;
    cin >> a;
    cin >> b;
    cout << gcd(a, b) << '\n';
    return 0;
}

Measured memory_bytes: 1160
#define _USE_NATH_DEFINES
#include <iostream>
using namespace std;

int main() {
	int N;
	bool exit = false;
	cin >> N;
	for (int i = 0; i < 25; ++i) {
		for (int j = 0; j < 15; ++j) {
			int total = 4 * i + 7 * j;
			if (N == total) {
				exit = true;
				break;
			}
		}
	}
	if(exit) cout << "Yes" << endl;
	else cout << "No" << endl;
	
}

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

const int N = 1000+5;
const int M = 20000+5;

LL dp[M];

struct data {
    int w, s, v;
    bool operator< (data b) {return w+s < b.w + b.s;}
};

data a[N];

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

    for (int i=1; i<=n; i++)
        cin>>a[i].w>>a[i].s>>a[i].v;

    sort(a+1, a+n+1);
    for (int i=1; i<=n; i++) {
        for (int j=a[i].s; j>=0; j--)
            dp[j+a[i].w] = max(dp[j+a[i].w], dp[j] + a[i].v);
    }

    long long ans = 0;
    for (int i=0; i<M; i++)
        ans = max(ans, dp[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 384
def binary_search(A,x,flag):
  start = 0
  end = len(A)-1
  
  while start < end:
    middle = (start + end) // 2
    if flag:# Aの時
      if A[middle] < x <= A[middle+1]:
        return middle + 1
      elif x <= A[middle]:
        end = middle
      else:
        start = middle + 1
    else:# Bの時
      if A[middle] <= x < A[middle+1]:
        return middle + 1
      elif x < A[middle]:
        end = middle
      else:
        start = middle + 1
  if end == 0: # 小さい
    return 0
  elif start == len(A)-1:
    return len(A)
        
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

# N=1はコーナーケース
if N == 1:
  print(1) if A[0] < B[0] < C[0] else print(0)
else:
  ans = 0
  for i in range(N):
    ans += binary_search(A,B[i],True)*(N-binary_search(C,B[i],False))#B[i]より小さいAの数とB[i]より大きいCの数の積
  print(ans)

Measured memory_bytes: 24264
h,i = map(int,input().split(" "))
k,j = map(int,input().split(" "))
a,b,c,d = map(int,input().split(" "))

s=h*a+i*b+(h//10)*c+(i//20)*d
r=k*a+j*b+(k//10)*c+(j//20)*d

if s > r:
  print("hiroshi")
elif s == r:
  print("even")
else:
  print("kenjiro")


Measured memory_bytes: 5596
import qualified Data.ByteString.Lazy.Char8 as B
import Data.List
import Data.Maybe
import Debug.Trace

traceQ :: (Show a) => String -> a -> a
-- traceQ label a = trace (label ++ ": " ++ show a) a
traceQ _ a = a

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

solve :: Int -> Int -> [Int] -> [Int] -> Int
solve valN valH as bs =
  case [(i, sum) | (i, sum) <- sc, sum >= valH] of
    (ans, _) : _ -> ans
    [] -> (fst lastres) + (((valH - (snd lastres)) + (amax - 1)) `div` amax)
  where
    amax = maximum (traceQ "as" as)
    effBs = reverse $ sort $ filter (> amax) bs
    sc = scanl op (0, 0) (traceQ "effBs" effBs)
      where op (i, sum) h = (i + 1, sum + h)
    lastres = last sc

eoSplit :: [Int] -> ([Int], [Int])
eoSplit [] = ([], [])
eoSplit (o:e:xs) = (o:os, e:es)
  where (os, es) = eoSplit xs

main :: IO ()
main = do
  conts <- B.getContents
  let valN : valH : rest = bsReadInts conts
      (as, bs) = eoSplit rest
      x = solve valN valH as bs
  putStrLn $ show x
  


Measured memory_bytes: 24828
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
using namespace std;

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    int y0, x0;
    cin >> y0 >> x0;
    string S,  T;
    cin >> S >> T;

    int y = y0;
    for(int i=0; i<N; i++){
        if(S[i] == 'U') y--;
        if(y == 0){
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'D' && y < H) y++;
    }
    y = y0;
    for(int i=0; i<N; i++){
        if(S[i] == 'D') y++;
        if(y == H+1){
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'U' && y > 1) y--;
    }

    int x = x0;
    for(int i=0; i<N; i++){
        if(S[i] == 'L') x--;
        if(x == 0){
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'R' && x < W) x++;
    }
    x = x0;
    for(int i=0; i<N; i++){
        if(S[i] == 'R') x++;
        if(x == W+1){
            cout << "NO" << endl;
            return 0;
        }
        if(T[i] == 'L' && x > 1) x--;
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 776
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		line = br.readLine();
		int n = parseInt(line.substring(0, line.indexOf(' ')));
		int t = parseInt(line.substring(line.indexOf(' ') + 1));

		List<String> stations = new ArrayList<String>();
		int[] opens = new int[n - 1];

		for (int i = 0; i < n; i++) {
			String[] tokens = br.readLine().split(" ");
			stations.add(tokens[3]);
			int arrive = minutes(tokens[2]);
			int leave = minutes(tokens[0]);
			if (i < n - 1) {
				opens[i] = arrive;
			}
			if (i > 0) {
				opens[i - 1] = leave - opens[i - 1];
			}
		}

		int c = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n - 1; i++) {
			if (opens[i] >= t) {
				c++;
				sb.append(stations.get(i) + " " + opens[i] + "\n");
			}
		}
		System.out.println(c);
		System.out.print(sb.toString());
	} //end main

	static int minutes(String time) {
		int h = parseInt(time.substring(0, 2));
		int m = parseInt(time.substring(3, 5));
		return h * 60 + m;
	}
}

Measured memory_bytes: 17064
$n=<>;
$d[1]=1;
for$i(@n=2..$n){
	$p[$i]&&next;
	@p[map$i*$_,@n]=@n;
	$k=-$_,map$d[$k*++$_]+=$d[$k],1..map{grep$'%$i**$_<1,//..9}@n for-75..-1
}
print$d[75]+0

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

using namespace std;

int arr[50], memo[50][50][101], n, big = 2e9 + 10;

int solve(int l, int r, int k) {

    int sum = 0;
    multiset<int> s;
    for (int i = 0; i < l; i++)
        s.insert(arr[i]), sum += arr[i];
    for (int i = r + 1; i < n; i++)
        s.insert(arr[i]), sum += arr[i];

    if (l >= n || r < 0)
        return sum;

    int &re = memo[l][r][k];

    if (re == big) {

        if (!k || r < l)
            re = sum;
        else {
            re = max(solve(l + 1, r, k - 1), solve(l, r - 1, k - 1));
            for (int x : s) {
                if (x < 0)
                    sum -= x, k--;
                if (!k)
                    break;
            }

            re = max(re, sum);
        }
    }

    return re;
}

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

    for (int i = 0; i < 50; i++)
        for (int j = 0; j < 50; j++)
            for (int l = 0; l <= 100; l++)
                memo[i][j][l] = big;

    int k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    cout << solve(0, n - 1, k) << "\n";

    return 0;
}

Measured memory_bytes: 1280
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

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

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

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	for (int i = k; i < n; ++i)
	{
		if (a[i] > a[i- k])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 4792
h, w = map(int, input().split())
ml = [input() for i in range(h)]
ll = [[0]*w for i in range(h)]

for i in range(h):
    for j in range(w):
        if ml[i][j] == ".":
            for k in range(-1, 2):
                for l in range(-1, 2):
                    if 0 <= i+k < h and 0 <= j+l < w:
                        if ml[i+k][j+l] == "#":
                            ll[i][j] += 1
        else:
            ll[i][j] = "#"

for i in range(h):
    print("".join(map(str, ll[i])))

                        
                

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;

int N, Q;
int c[500005];
int l[500005], r[500005];

int ans[500005];
vector<int> Vl[500005], Vi[500005];

int Data[1<<21], Datb[1<<21];

int M = 1 << 19;



void ADD(int a, int b, int l, int r, int k, int x) { // call l=0, r=M-1, k=1
	
	if (b< l || r < a) { return; }

	if (a <= l && r <= b) { Data[k] += x; }
	else {
		Datb[k] += (min(b, r) - max(a, l)+1)*x;

		ADD(a, b, l, (l + r) / 2, 2 * k, x);
		ADD(a, b, (l + r) / 2 + 1, r, 2 * k + 1, x);
	}
}

int SUM(int a, int b, int l, int r, int k) { // call l=0, r=M-1, k=0
	int ret = 0;

	if (b < l || r < a) { return 0; }

	if (a <= l && r <= b) {  return Data[k] * (r - l + 1)+Datb[k]; }
	else {
		ret += Data[k]*(min(b,r)-max(l,a)+1);
		ret += SUM(a, b, l, (l + r) / 2, k * 2);
		ret += SUM(a, b, (l + r) / 2 + 1, r, 2 * k + 1);
	}
	return ret;
}

int pre_pos[500005];

int last[500005];

int main(void) {

	cin >> N >> Q;
	for (int i = 1; i <= N; i++) { cin >> c[i]; }
	for (int i = 1; i <= Q; i++) {
		cin >> l[i] >> r[i];
	}

	
	for (int i = 1; i <= N; i++) {
		pre_pos[i] = last[c[i]];  last[c[i]] = i;
	}
	
	/*for (int i = 1; i <= N; i++) {
		cout << "pre_pos[" << i << "]= " << pre_pos[i] << endl;
	}*/

	for (int i = 1; i <= Q; i++) {
		Vl[r[i]].push_back(l[i]);
		Vi[r[i]].push_back(i);
	}

	for (int i = 1; i <= N; i++) {
		int p = pre_pos[i];
		//cout << "pre_pos[" << i << "]= " << pre_pos[i] << endl;
		ADD(p + 1, i, 0, M - 1, 1,1);
		for (int u = 0; u < (int)Vl[i].size(); u++) {
			int num = SUM(Vl[i][u], Vl[i][u], 0, M - 1, 1);
			ans[Vi[i][u]] = num;
		}
	}

	for (int i = 1; i <= Q; i++) {
		cout << ans[i] << endl;
	}
	
	/*ADD(0, 3, 0, M - 1, 1, 7);
	ADD(3, 5, 0, M - 1, 1, 9);
	ADD(6, 7, 0, M - 1, 1, 20);

	for (int k = 1; k <= 16; k++) {

		cout << "Data[" << k << "]= " << Data[k] <<"  Datb["<<k<<"]= "<< Datb[k] << endl;
	}

	cout << "SUM= " << SUM(6, 7, 0, M - 1, 1) << endl;
	*/


	return 0;
}

Measured memory_bytes: 62776
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n, mx[303000], ans[303000];
inline void U(int &x,int y){if (y>x) x=y;} 
int main(){
	cin>>n;
	#define rint register int
	int x;for (int i=0;i<1<<n;++i){scanf("%d",&x);for (rint j=i;j<1<<n;j=(j+1)|i){U(ans[j],x+mx[j]);U(mx[j],x);}}
	for (int i=1;i<1<<n;++i){printf("%d\n",ans[i]);U(ans[i+1],ans[i]);}
}

Measured memory_bytes: 5120
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	var result string

	for _, r := range scanner.Text() {
		if strings.ToLower(string([]rune{r})) == string([]rune{r}) {
			// lower
			result += strings.ToUpper(string([]rune{r}))
			continue
		}
		result += strings.ToLower(string([]rune{r}))
	}
	fmt.Println(result)
}



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

const int N=200010;
int n,m,v[20],x[N],f[N][20],g[N][20],F[1<<20],G[1<<20],ans[1<<20];

void work()
{
	scanf("%d %d",&n,&v[0]);
	for (int i=1; i<=n; i++)  scanf("%d",&x[i]);
	for (int t=v[0]; (v[++m]=t/=2); );
	x[0]=-int(2e9),x[n+1]=-x[0];
	for (int i=n; i; i--)
		for (int j=1; j<=m; j++)
			if (x[i+1]-x[i]<=v[j])  f[i][j]=f[i+1][j];
			else  f[i][j]=i;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
			if (x[i]-x[i-1]<=v[j])  g[i][j]=g[i-1][j];
			else  g[i][j]=i;
	for (int i=0; i<(1<<m); i++)  G[i]=n+1;
	for (int i=1; i<(1<<m); i++)
		for (int j=1,k; j<=m; j++)
			if (i&(1<<(j-1)))
				k=i-(1<<(j-1)),F[i]=max(F[i],f[F[k]+1][j]),G[i]=min(G[i],g[G[k]-1][j]);
	for (int i=0; i<=n; i++)  ans[i]=n+2;
	for (int i=0; i<(1<<m); i++)  ans[F[i]]=min(ans[F[i]],G[(1<<m)-1-i]);
	for (int i=n-1; i>=0; i--)  ans[i]=min(ans[i],ans[i+1]);
	for (int l,r=1; r<=n; r++)
		{
			l=r;
			while ((r<n)&&(x[r+1]-x[r]<=v[0]))  r++;
			for (int i=l; i<=r; i++)
				puts(ans[l-1]<=r+1?"Possible":"Impossible");
		}
}

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


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

int main() {
    int n, ans = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        if(floor(i*1.08) == n) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << ":(" << '\n';
}


Measured memory_bytes: 256