akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    string s = gs;
    vec<string> words = {"dream", "dreamer", "erase", "eraser"};
    map<string, int> wordsizes;
    for (string word: words) {
        wordsizes[word] = word.size();
    }
    bool cont = true;
    while (cont) {
        cont = false;
        for (string word: words) {
            int wordsize = wordsizes[word];
            if (s.size() >= wordsize) {
                if (s.substr(s.size()-wordsize, wordsize) == word) {
                    s = s.substr(0, s.size() - word.size());
                    cont = true;
                }
            }
        }
    }
    YESNO2(s == "");
    //debug(s);
}

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main () {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int sx=x1,sy=y1,tx=x2,ty=y2;
	while (y1 != ty) {
		if (y1 > ty) {
			cout <<"D";y1--;
		}
		if (y1 < ty) {
			cout <<"U";y1++;
		}
	}
	while (x1 != tx) {
		if (x1 > tx) {
			cout <<"L";x1--;
		}
		if (x1 < tx) {
			cout <<"R";x1++;
		}
	}
	while (y2 != sy) {
		if (y2 > sy) {
			cout <<"D";y2--;
		}
		if (y2 < sy) {
			cout <<"U";y2++;
		}
	}
	while (x2 != sx) {
		if (x2 > sx) {
			cout <<"L";x2--;
		}
		if (x2 < sx) {
			cout <<"R";x2++;
		}
	}
	cout <<"L";
	x1=sx-1,y1=sy,x2=tx,y2=ty+1;
	while (y1 != y2) {
		if (y1 > y2) {
			cout <<"D";y1--;
		}
		if (y1 < y2) {
			cout <<"U";y1++;
		}
	}
	while (x1 != x2) {
		if (x1 > x2) {
			cout <<"L";x1--;
		}
		if (x1 < x2) {
			cout <<"R";x1++;
		}
	}
	cout << "D";
	cout << "R";
	x1=sx,y1=sy-1,x2=tx+1,y2=ty;
	while (y2 != y1) {
		if (y2 > y1) {
			cout <<"D";y2--;
		}
		if (y2 < y1) {
			cout <<"U";y2++;
		}
	}
	while (x2 != x1) {
		if (x2 > x1) {
			cout <<"L";x2--;
		}
		if (x2 < x1) {
			cout <<"R";x2++;
		}
	}
	cout << "U";
	return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(12);
  std::cerr << std::fixed << std::setprecision(12);

  int N;

  std::cin >> N;
  
  double p, dp[2][3333], *curr = dp[0], *next = dp[1];

  memset(dp, 0, sizeof(dp));

  curr[0] = 1.0;

  for (int i = 0; i < N; i ++) {
    std::cin >> p;

    memset(next, 0, sizeof(dp[0]));

    for (int j = 0; j <= N; j ++) {
      next[j + 1] += curr[j] *      p;
      next[j    ] += curr[j] * (1 - p);
    }

    std::swap(curr, next);
  }

  double x = 0.0;
  
  for (int i = (N + 1) / 2; i <= N; i ++)
    x += curr[i];

  std::cout << x << std::endl;

  return 0;
}


Measured memory_bytes: 256
comb_memo = {}
def comb(n, r):
  global comb_memo
  if (n, r) in comb_memo:
    return comb_memo[(n, r)]
  else:
    r = min(r, n-r)
    res = 1
    for _ in range(r):
      res *= n
      n -= 1
    for i in range(1, r+1):
      res //= i
    comb_memo[(n, r)] = res
    comb_memo[(n, n-r)] = res
    return res

N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)

mu = sum(v[:A]) / A
ans = 0
if v[0] == mu:
  R = v.count(v[0])
  for i in range(A, B+1):
    if i > R:
      break
    ans += comb(R, i)
else:
  min_v = v[A-1]
  n = v.count(min_v)
  need = v[:A].count(min_v)
  ans += comb(n, need)

print(mu)
print(ans)

Measured memory_bytes: 3064
import collections


def solve():
    N, X, Y = map(int, input().split())

    inf = 10 ** 9
    ans = [0]*N

    def push(v, d, dist, q):
        if dist[v] == inf:
            dist[v] = d
            q.append(v)

    for i in range(N):
        q = collections.deque()
        dist = [inf]*N
        push(i, 0, dist, q)

        while(len(q)):
            v = q.popleft()
            d = dist[v]
            if v < N-1:
                push(v+1, d+1, dist, q)
            if 0 < v:
                push(v-1, d+1, dist, q)
            if v == X-1:
                push(Y-1, d+1, dist, q)
            if v == Y-1:
                push(X-1, d+1, dist, q)

        for i in range(N):
            ans[dist[i]] += 1

    for i in range(1, N):
        print(ans[i]//2)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 51164
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=410;
const int inf=0x3f3f3f3f;
const int mod=1000000007;

int n;
ll f[Maxn][Maxn],a[Maxn];

signed main() {
//	freopen("test.in","r",stdin);
	read(n);
	for(int i=1;i<=n;i++) read(a[i]),a[i]+=a[i-1];
	memset(f,0x3f,sizeof(f));
	for(int i=1;i<=n;i++) f[i][i]=0;
	for(int i=2;i<=n;i++)
		for(int j=i;j<=n;j++) {
			int l=j-i+1,r=j;
			for(int k=l;k<r;k++)
				qmin(f[l][r],f[l][k]+f[k+1][r]+a[r]-a[l-1]);
		}
	printf("%lld",f[1][n]);
	return 0;
}



Measured memory_bytes: 1536
from collections import deque
H, W = map(int,input().split())
grid = [list(input()) for _ in range(H)]


d = [[-1]*W for _ in range(H)]
dx = [0,1,0,-1]
dy = [1,0,-1,0]


que = deque()
for x in range(W):
    for y in range(H):
        if grid[y][x] == '#':
            d[y][x] = 0
            que.append([x,y])

while len(que) != 0:
    p = que.popleft()
    for i in range(4):
        nx = p[0] + dx[i]
        ny = p[1] + dy[i]
        #print(nx,ny)
        if 0 <= nx <= W-1 and 0 <= ny <= H-1 and grid[ny][nx] == '.' and d[ny][nx] == -1:
            que.append([nx,ny])
            d[ny][nx] = d[p[1]][p[0]] + 1

# print(d)
# print(d[H-1][W-1])
res = 0
for x in range(W):
    for y in range(H):
        res = max(res,d[y][x])
print(res)


Measured memory_bytes: 176476
import numpy as np

def list_element_add(l1, l2):
    result = np.array(l1) + np.array(l2)
    return result.tolist()

def solve(l, ave):
    for k in l:
        if k < ave:
            return False
    else:
        return True

n,m,x = map(int,input().split())
c = [list(map(int,input().split())) for _ in range(n)]
ans = 10**12

for i in range(2**n):
    understanding = [0]*m
    money = 0
    for j in range(n):
        if ((i >> j) & 1):
            money += c[j][0]
            understanding = list_element_add(understanding, c[j][1::])
    if solve(understanding, x):
        ans = min(ans,money)

print(ans if ans != 10**12 else '-1')

Measured memory_bytes: 27180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N;
    cin>>N;
    vector<ll> a(N*3);
    for(int i=0;i<N*3;i++) cin>>a[i];
    
    vector<ll> S(N*2+1,0);
    priority_queue<ll, vector<ll>,greater<ll>> que1;
    for(int i=0;i<N;i++){
        S[i+1]=S[i]+a[i];
        que1.push(a[i]);
    }
    for(int i=N;i<N*2;i++){
        ll mi=que1.top();
        if(a[i]>mi){
            S[i+1]=S[i]-mi+a[i];
            que1.pop();
            que1.push(a[i]);
        }
        else S[i+1]=S[i];
    }
    
    vector<ll> T(N*2+1,0);
    priority_queue<ll> que2;
    for(int i=0;i<N;i++){
        T[i+1]=T[i]+a[N*3-1-i];
        que2.push(a[N*3-1-i]);
    }
    for(int i=N;i<N*2;i++){
        ll ma=que2.top();
        if(a[N*3-1-i]<ma){
            T[i+1]=T[i]-ma+a[N*3-1-i];
            que2.pop();
            que2.push(a[N*3-1-i]);
        }
        else T[i+1]=T[i];
    }
    
    ll res=-(1LL<<60);
    for( int i=N;i<=N*2;i++){
        res=max(res,S[i]-T[N*3-i]);
    }
    cout<<res<<endl;
}

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

A = list(map(int,input().split()))
reverseA = sorted(A,reverse = True)
money = 1000
stock = 0

if A == reverseA:
    print(money)
else:
    for i in range(N-1):
        if A[i] < A[i+1]:
            if stock == 0:
                stock = money // A[i]
                money = money % A[i]
        elif A[i] > A[i+1]:
            money += stock * A[i]
            stock = 0
        else:
            None
        
    
    if stock > 0:
        money += stock * A[N-1]
        stock = 0
    
    print(money)

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

vector<pair<long long, long long> > prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  long long N;
  cin >> N;
  auto pf = prime_factorize(N);
  long long res = 0;
  for (auto p : pf) {
    long long e = p.second;
    long long tmp = 0, cur = 1;
    while (e >= cur) e -= cur++, ++tmp;
    res += tmp;
  }
  cout << res << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    ll n;
    std::cin >> n;
    ll ans = 0;

    auto judge = [&](ll k) {
        if (k == 1) return false;
        ll nc = n;
        while (nc % k == 0) nc /= k;
        return nc % k == 1;
    };

    for (ll k = 1; k * k <= n; k++) {
        if (n % k) continue;
        ans += judge(k);
        if (k * k < n) ans += judge(n / k);
    }

    for (ll k = 1; k * k <= (n - 1); k++) {
        if ((n - 1) % k) continue;
        if (k != 1) ans++;
        if (k * k < n - 1) ans++;
    }

    std::cout << ans << '\n';
    return 0;
}


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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vll = V<ll>;
using vvll = V<vll>;
using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll n, k, h;
    ll count = 0;
    cin >> n >> k;
    REP(i,n){
        cin >> h;
        if(h>=k){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

struct Point{
    ll num,c1,c2;
};

static const ll MAX = 200001;
ll c1[MAX] = {};
ll c2[MAX] = {};
ll ans[MAX] = {};
vector <ll> nbr1[MAX], nbr2[MAX];

bool asc( const Point& left, const Point& right ) {
    return left.c1 == right.c1 ? left.c2 < right.c2 : left.c1 < right.c1;
}

void bfs1(ll s, ll color){
    queue <ll> q;
    q.push(s);
    ll tmp = color;
    c1[s] = tmp;
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(ll i=0;i<nbr1[u].size();i++){
            if(c1[nbr1[u][i]] == 0) {
                c1[nbr1[u][i]] = tmp;
                q.push(nbr1[u][i]);
            }
        }
    }
}
void bfs2(ll s, ll color){
    queue <ll> q;
    q.push(s);
    ll tmp = color;
    c2[s] = tmp;
    while(!q.empty()){
        ll u = q.front();
        q.pop();
        for(ll i=0;i<nbr2[u].size();i++){
            if(c2[nbr2[u][i]] == 0) {
                c2[nbr2[u][i]] = tmp;
                q.push(nbr2[u][i]);
            }
        }
    }
}


int main() {
    

    ll n,k,l;
    cin >> n >> k >> l;
    for (ll i=1;i<=k;i++){
        ll p,q;
        cin >> p >> q;
        nbr1[p].push_back(q);
        nbr1[q].push_back(p);
    }
    for (ll i=1;i<=l;i++){
        ll r,s;
        cin >> r >> s;
        nbr2[r].push_back(s);
        nbr2[s].push_back(r);
    }
    ll color = 1;
    for (ll i=1;i<=n;i++){
        if(c1[i] == 0){
            bfs1(i, color);
            color++;
        }
    }
    color = 1;
    for (ll i=1;i<=n;i++){
        if(c2[i] == 0){
            bfs2(i, color);
            color++;
//            cout << i << endl;
        }
    }
    vector <Point> lis;
    for (ll i=1;i<=n;i++){
        Point p;
        p.num = i;
        p.c1 = c1[i];
        p.c2 = c2[i];
        lis.push_back(p);
    }
    sort(lis.begin(), lis.end(), asc);
//    for (ll i=0;i<n;i++){
//        cout << lis[i].num << " " << lis[i].c1 << " " << lis[i].c2 << endl;
//    }
    ll tmp;
    tmp = 1;
    for (ll i=0;i<n;i++){
        if(i == n-1 or lis[i].c1 != lis[i+1].c1 or lis[i].c2 != lis[i+1].c2){
            ll memo = tmp;
//            cout << memo << endl;
            while(memo > 0){
                ans[lis[i-memo+1].num] = tmp;
                memo--;
            }
            tmp = 1;
        }else{
            tmp++;
        }
    }
    for(ll i=1;i<=n;i++){
        cout << ans[i] << " ";
    }
    cout << endl;

}

Measured memory_bytes: 29276
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>


using namespace std;


using ll = long long;


class ball {
    public:
        ll num;
        ll cnt;
        ball(ll num, ll cnt);
        ball();
};


ball::ball(ll num, ll cnt)
    : num(num), cnt(cnt)
{
}


int main()
{
    map<ll, ll> ball_cnt;
    ll N, K;
    cin >> N >> K;
    for (ll i = 0; i <= N; i++)
        ball_cnt[i] = 0;

    for (ll i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        ball_cnt[tmp]++;
    }

    vector<ball*> balls;
    for (auto c : ball_cnt) {
        balls.push_back(new ball(c.first, c.second));
    }

    sort(balls.begin(), balls.end(),
            [](ball* l, ball* r) { return l->cnt < r->cnt; });

    ll i = 0;
    ll ans = 0;
    while ((balls.size() - i) > K) {
        ans += balls[i++]->cnt;
    }
    cout << ans << endl;
}


Measured memory_bytes: 20592
MOD = 998244353
MAX = 2_002_000
FACT = Array.new(MAX, 1)
FINV = Array.new(MAX, 1)
INV = Array.new(MAX, 1)

def powmod(n, r, mod)
  if r.zero?
    1
  elsif r.odd?
    (n * powmod(n, r - 1, mod)) % mod
  else
    (powmod(n, r / 2, mod) ** 2) % mod
  end
end


FACT[0] = FACT[1] = 1
FINV[0] = FINV[1] = 1
INV[1] = 1
(2 ... MAX).each do |i|
  FACT[i] = FACT[i - 1] * i % MOD;
  INV[i] = MOD - INV[MOD%i] * (MOD / i) % MOD;
  FINV[i] = FINV[i - 1] * INV[i] % MOD;
end

def combination(n, k)
  return 0 if n < k
  return 0 if n < 0 || k < 0
  return FACT[n] * (FINV[k] * FINV[n - k] % MOD) % MOD;
end


N, M, K = gets.split.map(&:to_i)

all = powmod(M, N, MOD)
upK = (K + 1 .. N - 1).inject(0){|s, k| (s + combination(N - 1, k) * M * powmod(M - 1, N - 1 - k, MOD)) % MOD }

puts  (all - upK) % MOD



Measured memory_bytes: 61364
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder {
	class Program {
		#region Reserve
		static int cin() { return cin(-1); }
		static int cin(int D) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return int.Parse(s);
		}
		static long cln(long D = -1) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return D;
			return long.Parse(s);
		}
		static int[] cins(char spliter) {
			string s = Console.ReadLine();
			if (string.IsNullOrEmpty(s))
				return new int[] { };
			string[] ss = s.Split(spliter);
			var Res = new int[ss.Length];
			for (int i = 0; i < ss.Length; i++)
				Res[i] = int.Parse(ss[i]);
			return Res;
		}
		static int[] cins() { return cins(' '); }
		static void print(object j) { Console.WriteLine(j.ToString()); }
		static void print(string j) { Console.WriteLine(j); }
		static string read() { return Console.ReadLine(); }
		#endregion

		static void Main(string[] args) {
			var A = read();
			var G = new long[26];
			foreach (char f in A) G[f - 97]++;
			long Res = ((long)A.Length) * (A.Length - 1) / 2 - G.Sum(j => j * (j - 1) / 2) + 1;
			print(Res);
			read();
		}
	}
}


Measured memory_bytes: 13368
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

static const int kRem = 998244353;

int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	vector<int64_t> ds(n);
	for (auto& d : ds) {
		cin >> d;
	}

	vector<int64_t> vs(n);
	FOR_LT(i, 0, n) {
		vs[ds[i]]++;
	}

	if (vs[0] != 1 || ds[0] != 0) {
		cout << 0 << endl;
		return 0;
	}

	int64_t ans = 1;
	FOR_LT(i, 0, n - 1) {
		ans *= pow_rem(vs[i], vs[i + 1], kRem);
		ans %= kRem;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext()) {
			int count=0;
			int T=in.nextInt();
			int[] a=new int[T];
			for(int i=0;i<T;i++) {
				a[i]=in.nextInt();
			}
			for(int i=0;i<T;i=i+2) {
				if(a[i]%2==1) {
					count++;
				}
			}
			System.out.println(count);
		}
	}
}


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

using namespace std;

using i64 = long long;

const i64 MOD = 998244353;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


signed main(){
    int n;
    cin >> n;
    vector<i64> a(n), v(n);
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = 0; i < n; ++i)
        cin >> v[i];
    priority_queue<pair<i64,int>> que;
    for(int i = 0; i < n; ++i)
        que.emplace(v[i], i);
    i64 ans = 0;
    while(!que.empty()){
        i64 val;
        int i;
        tie(val, i) = que.top();
        que.pop();
        i64 su = v[(i + 1) % n] + v[(i + n - 1) % n];
        i64 ma = max({v[(i + 1) % n], v[(i + n - 1) % n], a[i]});

        i64 diff = val - ma;
        i64 cnt = (diff + su - 1) / su;
        ans += cnt;
        val -= su * cnt;
        v[i] = val;
        if(val > a[i])
            que.emplace(val, i);
        if(val < a[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << (a == v ? ans : -1) << endl;
}



Measured memory_bytes: 9200
from math import ceil
MOD = 10**9 + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
# 単調減少
for i in range(n-1):
    b = a[i]
    count = 0
    for j in range(i+1, n):
        if b > a[j]:
            count += 1
    if count == 0:
        continue
    ap = (k * (k+1) // 2)
    tmp = (count * ap)
    ans += tmp
    ans %= MOD

# それ以外
for i in range(n):
    b = a[i]
    count = 0
    for j in range(i):
        if b > a[j]:
            count += 1
    if count == 0:
        continue
    ap = ((k-1) * k // 2)
    tmp = (count * ap)
    ans += tmp
    ans %= MOD
print(int(ans))



Measured memory_bytes: 42604
MOD = 10 ** 9 + 7

s = gets.chomp.chars
n = s.size
m = 13
dp = Array.new(n) { Array.new(m, 0) }

# [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]
# [8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7]
n.times do |i|
  if i == 0 && s[i] != "?"
    dp[i][s[i].to_i] = 1
  elsif i == 0
    (0..9).each {|d| dp[i][d] = 1 }
  elsif s[i] != "?"
    c = s[i].to_i
    m.times do |j|
      dp[i - 1][j] %= MOD
      dp[i][(10 * j + c) % m] += dp[i - 1][j]
    end
  else
    m.times do |j|
      dp[i - 1][j] %= MOD
      10.times do |c|
        dp[i][(10 * j + c) % m] += dp[i - 1][j]
      end
    end
  end
end
puts dp[n - 1][5] % MOD

Measured memory_bytes: 46980
N,M = map(int,input().split())
H = list(map(int,input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
    A[i],B[i] = map(int,input().split())
mountains = [0]*N
for i in range(M):
    if H[A[i]-1]>H[B[i]-1]:
        mountains[B[i]-1] -= 1
    elif H[A[i]-1]<H[B[i]-1]:
        mountains[A[i]-1] -= 1
    else:
        mountains[B[i]-1] -= 1
        mountains[A[i]-1] -= 1
print(mountains.count(0))

Measured memory_bytes: 85068
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

double dist(double x1, double y1, double x2, double y2) {
return sqrt((double)pow(abs(x2-x1), 2)+(double)pow(abs(y2-y1), 2));
}

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double ra = 30*(double)h+((double)m/2);
    double rb = 6*(double)m;
    // show(ra);
    // show(rb);
    ra = ra/180*3.14159265358979323846264338327950288419716939937510;
    rb = rb/180*3.14159265358979323846264338327950288419716939937510;


    double xa, ya, xb, yb;
    xa = cos(ra)*a;
    ya = sin(ra)*a;
    xb = cos(rb)*b;
    yb = sin(rb)*b;
    // cout << xa << " " << ya << " " << xb << " " << yb << endl;

    double ans = dist(xa, ya, xb, yb);

    printf("%.10f", ans);
    return 0;
}

Measured memory_bytes: 4072
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;


int main(){

  double h;
  double maxh = 0;
  double minh = 1000000;
  while( cin >> h ){
    maxh = max(maxh, h);
    minh = min(minh, h);
  }
  cout << maxh - minh << endl;

  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9+7;

int main(){
  string S; cin >>S;
  int n = S.size();

  int r[6] = {1,10,9,12,3,4}; // r[i]は10^iを13で割った余り

  vector<vector<long long int> > dp;
  dp.assign(100005, vector<long long int>(13, 0));
  if(S[n-1]=='?'){
    for(int k=0; k<=9; k++){ // 下1桁目に0~9の数kを入れたとき
      dp[1][k] = 1;
    }
  } else {
    dp[1][int(S[n-1])-'0'] = 1;
  }

  for(int i=2; i<=n; i++){ // 下i桁目について
    for(int j=0; j<13; j++){ // 下i-1桁の余りjの数について
      if(S[n-i]=='?'){
        for(int k=0; k<=9; k++){ // i+1桁目に0~9の数kを入れたとき
          dp[i][(j+k*r[(i-1)%6])%13] += dp[i-1][j];
          dp[i][(j+k*r[(i-1)%6])%13] %= M;
        }
      }else{
        dp[i][(j+(int(S[n-i])-int('0'))*r[(i-1)%6])%13] += dp[i-1][j];
        dp[i][(j+(int(S[n-i])-int('0'))*r[(i-1)%6])%13] %= M;
      }
    }
  }

  cout << dp[n][5] << endl;
  return 0;
}


Measured memory_bytes: 13696
#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 n,l;
    cin >> n >> l;
    int s;
    s=n*l+(n-1)*n/2;

    if(l>=0){
        s-=l;
    }
    else if(l+n-1<=0){
        s-=(l+n-1);
    }
    
    cout << s << endl;
    

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i =0 ; i<n; i++) a[i] = in.nextInt();
        Arrays.sort(a);
        int[] colors = new int[8];
        int countgm = 0;
        for(int i = 0; i<n; i++){
            int val = a[i]/400;
            if(val>=8) ++countgm;
            else{
                ++colors[val];
            }
        }
        int min = 0;
        int max = 0;
        boolean check = false;
        for(int i = 0; i<8; i++){
            if(colors[i]>0){
                check = true;
                ++min;
                ++max;
            }
        }
        if(!check) {
            ++min;
        }
        out.print(min + " ");
        out.print(max+countgm);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext() {
            String next = null;
            try {
                next = reader.readLine();
            } catch (Exception e) {
            }
            if (next == null) {
                return false;
            }
            tokenizer = new StringTokenizer(next);
            return true;
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
    }
}



Measured memory_bytes: 36556
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

typedef long long            ll;
typedef long double          ld;
typedef string               str;
typedef pair < ll , ll >     pll;

#define X               first
#define Y               second
#define pb              push_back
#define sep             ' '
#define endl            '\n'
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define dbl_io(x)       cout << fixed << setprecision(x);

const int N = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 10;

ll mark[N], ans[N], now;
vector < ll > adj[N];
set < ll > cmp[N], bad[N];

void dfs(ll v){
    mark[v] = 1;
    cmp[now].insert(v);
    for (ll u : adj[v])
        if (!mark[u])
            dfs(u);
}

int main(){
    fast_io
    //dbl_io(10);
    ll n, m, k;
    cin >> n >> m >> k;
    for (ll i = 0; i < m; i ++){
        ll u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (ll i = 0; i < k; i ++){
        ll u, v;
        cin >> u >> v;
        bad[u].insert(v);
        bad[v].insert(u);
    }
    for (ll v = 1; v <= n; v ++)
        if (!mark[v])
            dfs(v), now ++;
    for (ll i = 0; i < now; i ++){
        for (ll v : cmp[i]){
            ans[v] = cmp[i].size() - 1 - adj[v].size();
            for (ll u : bad[v])
                if (cmp[i].find(u) != cmp[i].end())
                    ans[v] --;
        }
    }
    for (ll i = 1; i <= n; i ++)
        cout << ans[i] << ' ';
    return 0;
}


Measured memory_bytes: 32896
from collections import deque

N, M, X = map(int, input().split())

C = []
A = []

for _ in range(N):
    L = list(map(int, input().split()))
    C.append(L[0])
    A.append(L[1:])


def book_buy_generator():
    for bit_generator in range(1 << N):
        l = [True if bit_generator & (1 << bit) else False for bit in range(N)]
        yield l


big = 10 ** 7
ans = big

for buy in book_buy_generator():
    learn = [0] * M
    cost = 0
    for book_cost, a, bought in zip(C, A, buy):
        if bought:
            cost += book_cost
            for i in range(M):
                learn[i] += a[i]

    learn_ok = True
    for algorithm in learn:
        if algorithm < X:
            learn_ok = False

    if learn_ok:
        ans = min(ans, cost)

print(ans if ans != big else -1)

Measured memory_bytes: 9476
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main()
{
    string s,t;cin>>s>>t;
    vector<vector<int> > d(s.size() + 1,vector<int> (t.size() + 1));
    vector<vector<int> > u(s.size() + 1, vector<int> (t.size() + 1, -22));
    for(int i = 1; i <= s.size() ; i++)
    {
        for(int j = 1 ; j <= t.size() ; j++)
        {
            if(s[i - 1] == t[j - 1])
            {
                d[i][j] = d[i - 1][j - 1] + 1;
                u[i][j] = 0;

            }
            else
            {
                if(d[i - 1][j] > d[i][j - 1])
                {
                    d[i][j] = d[i - 1][j];
                    u[i][j] = -1;
                }
                else
                {
                    d[i][j] = d[i][j - 1];
                    u[i][j] = 1;
                }
                
            }

            
        }
    }
    int i = s.size() ,j = t.size();
    string ans = "";
    while(i > 0 && j > 0)
    {
        if(u[i][j] == 0)
        {
            ans = s[i - 1] + ans;
            i--,j--;
        }
        else
        {
            if(u[i][j] == 1)
            {
                j--;
            }
            else if(u[i][j] == -1)
                i--;
        }
        
    }
        // cout<<d[s.size()][t.size()]<<endl;
        cout<<ans<<endl;

}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int A, B; scanf("%d %d", &A, &B);
  string s; cin >> s;
  int n = s.size();
  bool ok = true;
  for (int i = 0; ok and i < n; ++i) {
    if (i == A and s[i] != '-') { ok = false; }
    if (i != A and not isdigit(s[i])) { ok = false; }
  }
  printf("%s\n", ok ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200010],b[200010],p[200010];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
    cin>>p[i];
}
for(int i=1,j=n;i<=n,j>=1;i++,j--){
    a[i]=i;
    b[i]=j;
}
for(int i=1;i<=n;i++){
    a[i]+=i*(n+1);
}
for(int j=n,i=1;j>=1,i<=n;i++,j--){
    b[j]+=i*(n+1);
}
for(int i=1;i<=n;i++){
    b[p[i]]=b[p[i]]+i;
}
for(int i=1;i<=n;i++){
    cout<<a[i]<<" ";
}
cout<<endl;
for(int i=1;i<=n;i++){
    cout<<b[i]<<" ";
}
}

Measured memory_bytes: 4092
n,k = map(int,input().split())
v = list(map(int,input().split()))
ans = 0
for a in range(k+1):
  for b in range(k+1):
    if a+b>n or a+b>k:
      break
    c = k-a-b
    g = v[:a] + v[n-b:]
    g.sort()
    for i in range(min(c,a+b)):
      if g[i] < 0:
        g[i] = 0
    ans = max(ans,sum(g))
    #print(a,b,c,g)
print(ans)
    

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
const int N=2e5+5;
char s1[N],s2[N];
int a[N],b[N];
int main() {

	scanf("%s %s",s1,s2);
	int len1=strlen(s1),len2=strlen(s2);
	if(len1!=len2)return puts("No"),0; 
	for(int i=1;i<len1;i++) {
		if(!a[s1[i]-'a']&&!b[s2[i]-'a'])a[s1[i]-'a']=s2[i]-'a',b[s2[i]-'a']=s1[i]-'a';
		if(a[s1[i]-'a']==s2[i]-'a'&&b[s2[i]-'a']==s1[i]-'a')continue;
		if(a[s1[i]-'a']!=(s2[i]-'a')||(b[s2[i]-'a']!=s1[i]-'a'))return puts("No"),0;
	}
	puts("Yes");
return 0;
}


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

int main(){
	int n;
	cin>>n;
	int k;
	bool ok = true;
	for (int i = 0; i<n; i++){
		cin>>k;
		if (k%3!=0 && k%5!=0 && k%2==0){
			ok = false;
		}
	}
	if (ok){
		cout<<"APPROVED";
	}
	else{
		cout<<"DENIED";
	}
	return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <functional>

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



signed main()
{
	int n;
	cin >> n;
	int size = 0;
	int sum = 0;
	int tmp;
	int notten = 101;
	REP(i, n) {
		cin >> tmp;
		if (tmp % 10 == 0) sum += tmp;
		else {
			if (tmp < notten) notten = tmp;
			sum += tmp;
		}
	}
	if (sum % 10 == 0) {
		if (notten == 101) cout << 0 << endl;
		else cout << sum - notten << endl;
	}
	else cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <climits>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <string>

using namespace std;

const int len = 110;
int n,m;
long long sum;

void init() {
    sum = INT_MAX;
}

void output(long long k) {
    cout << k << endl;
}

void work() {
    long long k;
    for (long long i=1;i<=n;i++) {
        long long mid = (n-i)/2;
        k = max(i*m,(n-i-mid)*m) - min(i*m,mid*m);
        sum = min(sum,k);
        mid = m/2;
        k = max(i*m,(n-i)*(m-mid)) - min(i*m,(n-i)*mid);
        sum = min(sum,k);
    }
    for (long long i=1;i<=m;i++) {
        long long mid = (m-i)/2;
        k = max(i*n,(m-i-mid)*n) - min(i*n,mid*n);
        sum = min(sum,k);
        mid = n/2;
        k = max(i*n,(m-i)*(n-mid)) - min(i*n,(m-i)*mid);
        sum = min(sum,k);
    }
    output(sum);
}

int main() {
    //freopen("test.in","r",stdin);
    //freopen("test.out","w",stdout);
    cin >> n >> m;
    init();
    work();
    return 0;
}

Measured memory_bytes: 256
<?php
$N =trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
$b = explode(" ",trim(fgets(STDIN)));

for($i=0;$i<$N;$i++){
$c[$i]=$a[$i]-$b[$i];
}

$A = array_sum($a);
$B = array_sum($b);

$k=0;

foreach($c as $value){
if ($value<0){
$k=1;
}
}
 
    
if($A<$B){
echo '-1';
exit;
}
elseif($k==0){
echo '0';
exit;
}

sort($c);
$point=0;
$ans=0;
$j = 0;
while(true){
if($c[$j]<0){
$ans++;
$point +=$c[$j];
$j++;
}else{
break;
}
}

rsort($c);

$k=0;  
while(true){
$point +=$c[$k];

$ans++;
if($point>0){
echo $ans;
exit;
}
$k++;
}

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

int main(void){
    ll n,x; cin >> n >> x;
    vector<ll>a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    ll ans = 0;
    for(int i=1;i<n;i++){
        ll need_cnt = a[i-1]+a[i] - x;
        if(0<need_cnt){
            a[i] -= min(a[i],need_cnt),ans += need_cnt;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//adds two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set]
//(2)set.order_of_key(k)[count of elements strictly less than k]
#define ll long long
#define ld long double
#define vv vector
#define pp pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
typedef pair<ll, ll> pll;
typedef vv<bool> vbool;
typedef vv<ll> vll;
typedef vv<ld> vld;
typedef vv<pll> vpll;
#ifdef LOCAL
#include "prettyprint.hpp"
#define LG(args...)                           \
{                                             \
	string _s = #args;                        \
	replace(_s.begin(), _s.end(), ',', ' ');  \
	stringstream _ss(_s);                     \
	err(istream_iterator<string>(_ss), args); \
	cerr << endl;                             \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "(" << *it << ":" << a << ") ";
	err(++it, args...);
}
#define fastio
#else
#define LG(...)
#define fastio                    \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);
#define endl "\n"
#endif
//:::::::::::::::::::::::::::::::::::::::::::::
const ll INF = 9e18;
const ll MOD = 1e9 + 7;

ld dis(pp<ld,ld> a){
	return sqrt(a.ff * a.ff + a.ss * a.ss);
}

int main(){
	fastio;
	ll n,d;
	cin>>n>>d;
	vv<pp<ld,ld>> v(n);
	ll c=0;
	for(ll i=0; i<n; i++){
		cin>>v[i].ff>>v[i].ss;
		if(dis(v[i]) <= d)
			c++;
	}
	cout<<c;
}

Measured memory_bytes: 9520
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define fa(a,c) for(auto &a:c)
#define yes "YES"
#define no "NO"




int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
ll a;
  cin>>a;
  cout<<a*a*a<<endl;




	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RDR.ARR;
	auto cnt = new long[](N);
	foreach (e; A)
	{
		++cnt[e];
	}
	auto odds = N % 2;
	bool isWrong = false;
	foreach (i, e; cnt)
	{
		if (i == 0)
		{
			if (odds == 1 && e == 1) continue;
			else if (odds == 0 && e == 0) continue;
			isWrong = true;
			break;
		}
		else if (i % 2 == odds && e != 0)
		{
			isWrong = true;
			break;
		}
		else if (i % 2 != odds && e != 2)
		{
			isWrong = true;
			break;
		}
	}

	if (isWrong)
		writeln(0);
	else
	{
		long ans = 1;
		foreach (i; 0..N/2)
			modm(ans, 2);
		writeln(ans);
	}
	stdout.flush();
	//readln();
}

Measured memory_bytes: 4412
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b; cin >> a >> b;
	if (a % b == 0)cout << 0;
	else cout << 1;

	cout << endl;
	return 0;
}

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

int main(){
  int i,j,N,M;
  cin >> N >> M;
  vector<int> A(M);
  int ans;
  for(i=0; i<M; i++){
    cin >> A.at(i);
  }
  int sum = 0;
  for(i=0; i<M; i++){
    sum += A.at(i);
  }
  if(N>=sum)cout << N-sum;
  else cout << "-1";
  return 0;
}

Measured memory_bytes: 3668
import heapq

N, M = map(int, input().split()) 

day_rew = {}
for _ in range(N):
    a, b = map(int, input().split()) 
    day_rew.setdefault(a,[])
    day_rew[a].append(b)

ans = 0
job_rew = []
heapq.heapify(job_rew)
for i in range(1, M+1):
    if i in day_rew:
        for r in day_rew[i]:
            heapq.heappush(job_rew, r*(-1))
    if job_rew:
        this_day_rew = heapq.heappop(job_rew)*(-1)
        ans += this_day_rew

print(ans)



Measured memory_bytes: 27344