akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vi C, S, F; C = S = F = vi(n-1);
    rep(i, n-1){
        cin >> C[i] >> S[i] >> F[i];
    }

    rep(i, n - 1){
        int t = S[i] + C[i];
        rep(j, i + 1, n-1){
            chmax(t, S[j]);
            t += (F[j] - t % F[j]) % F[j];
            t += C[j];
        }
        cout << t << endl;
    }
    cout << 0 << endl;

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vi a(n), b(n-1);
  rep(i,n-1) cin >> b[i];
  a[0] = b[0];
  for(int i=1; i<n; i++){
    a[i] = b[i-1];
    if(a[i] > b[i] && i!=n-1) a[i] = b[i];
  }
  int ans = 0;
  rep(i,n) ans += a[i];
  cout << ans << endl;
}


Measured memory_bytes: 3636
/*input
2 5
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 4;

int pos[N], mn[N], mx[N], el[N];

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int s, t;
    cin >> s >> t;
    if (s > 9 || t > 9) {
        cout << -1;
    } else {
        cout << s * t;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>

using namespace std;

const static int32_t N = 4;

class Board {
    friend bool operator==(const Board &b1, const Board &b2);
    friend bool operator!=(const Board &b1, const Board &b2);

private:
    uint64_t board;

public:
    Board() {
        board = 0;
    }

    void set(int32_t r, int32_t c, int64_t v) {
        uint32_t shift = 4 * (r * N + c);
        uint64_t mask = 0xf;
        board = (board & ~(mask << shift)) | (v << shift);
        return;
    }

    int32_t get(int32_t r, int32_t c) const {
        int32_t shift = 4 * (r * N + c);
        return (board >> shift) & 0xf;
    }

    void swap(int32_t r1, int32_t c1, int32_t r2, int32_t c2) {
        int32_t temp = get(r1, c1);
        set(r1, c1, get(r2, c2));
        set(r2, c2, temp);
        return;
    }

    void show() const {
        cout << hex << board << endl;
    }
};

bool operator==(const Board &b1, const Board &b2) {return b1.board == b2.board;};
bool operator!=(const Board &b1, const Board &b2) {return !(b1 == b2);}

int32_t manhattan(const Board &board) {
    int32_t d = 0;

    for (int32_t r = 0; r < N; r++) {
        for (int32_t c = 0; c < N; c++) {
            int32_t v = board.get(r, c);
            if (v != 0) d += abs(r - (v-1) / N) + abs(c - (v-1) % N);
        }
    }

    return d;
}

vector<Board> children(const Board &board) {
    vector<Board> c;
    int32_t zr, zc;

    for (int32_t z = 0; z < N*N; z++) {
        if (board.get(z/N, z%N) == 0) {
            zr = z/N;
            zc = z%N;
            break;
        }
    }

    array<int32_t, 4> dr = {1, 0, -1, 0}, dc = {0, 1, 0, -1};

    for (int32_t i = 0; i < 4; i++) {
        if (0 <= zr+dr[i] && zr+dr[i] < N && 0 <= zc+dc[i] && zc+dc[i] < N) {
            Board board_new = board;
            board_new.swap(zr, zc, zr+dr[i], zc+dc[i]);
            c.push_back(board_new);
        }
    }

    return c;
}

bool dfs(const Board &board, const Board &parent, int32_t depth, int32_t dist, int32_t limit) {
    if (dist == 0) {
        cout << depth << endl;
        return true;
    }

    if (depth + dist > limit) return false;

    bool flag = false;
    for (Board child : children(board)) {
        if (child != parent) {
            if (dfs(child, board, depth + 1, manhattan(child), limit)) {
                flag = true;
                break;
            }
        }
    }

    return flag;
}


int main() {
    Board board;

    for (int32_t r = 0; r < N; r++) {
        for (int32_t c = 0; c < N; c++) {
            int32_t v;
            cin >> v;
            board.set(r, c, v);
        }
    }

    int32_t limit = 0;

    while (!dfs(board, board, 0, manhattan(board), limit)) limit++;

    return 0;
}

Measured memory_bytes: 3112
#include <stdio.h>

int main(void){
    int ANS=0, i;
    char S[6];
    scanf("%s", S);
    for(i=0; i<4; i++){
        if(S[i] == '+') ANS++;
        else ANS--;
    }
    printf("%d\n", ANS);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const int MAXN = 1e9+7;

using LL = long long;

int main() {
    int h, w, n; scanf("%d%d%d", &h, &w, &n);

    vector<pair<int, int>> ps;
    for (int i = 0; i < n; ++i) {
        int x, y; scanf("%d%d", &x, &y);
        ps.push_back({x, y});
    }

    LL ans[10] = {};

    map<pair<int, int>, int> M;
    for (auto &&p : ps) {
        for (int dx = -1; dx <= 1; ++dx) {
            for (int dy = -1; dy <= 1; ++dy) {
                int x = p.first + dx;
                int y = p.second + dy;
                if (x <= 1 or y <= 1 or x >= h or y >= w) continue;

                M[{x, y}] += 1;
            }
        }
    }

    for (auto &&p : M) ans[p.second] += 1;

    ans[0] = 1LL * (h-2) * (w-2);
    for (int i = 1; i <= 9; ++i) ans[0] -= ans[i];

    for (int i = 0; i <= 9; ++i) printf("%lld\n", ans[i]);

    return 0;
}


Measured memory_bytes: 57204
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <vector>
using namespace std;

int main()
{
    int n,k;
    string s;
    int count=1;
    cin >> n >> k >> s;
    string out;
    for(char c: s){
        if(count == k)
            out += tolower(c);
        else
            out += c;
        count++;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a, b, c, i = 0;
	scanf("%d %d %d",&a ,&b ,&c);
	for(; a <= b; a++ ){
		if (c % a == 0) i++;
		}
	
	printf("%d\n", i);
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, t; cin >> n >> t;
	int ans = t;
	VE a(n); rep(i, n)cin >> a[i];
	rep(i, n - 1) {
		ans += min(t, a[i + 1] - a[i]);
	}
	cout << ans << endl;
	return 0;
}


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

int res=1e9;
bool Free[200];
string s;

int Check(char c)
{
    string ss=s;
    int rs=0;
    while(1)
    {
        bool check=false;
        for(int i=1;i<ss.size();i++)
            if(ss[i]!=ss[i-1])
            {
                check=true;
                break;
            }
        if(check==false)
            return rs;
        rs++;
        string sss="";
        for(int i=0;i<ss.size()-1;i++)
            if(ss[i]==c||ss[i+1]==c)
                sss+=c;
            else
                sss+=ss[i];
        ss=sss;
    }
}

int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
        Free[s[i]]=true;
    for(int i='a';i<='z';i++)
        if(Free[i]==true)
            res=min(res,Check(i));
    cout<<res;
}


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

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

struct UF {
    vi data;
    void init(int n)
    {
        data.resize(n);
        fill(all(data), -1);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (size(x) < size(y)) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x)
    {
        return -data[x];
    }
    bool is_root(int x)
    {
        return x == root(x);
    }
};

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

    UF uf;
    uf.init(N + M + 1);

    rep(i, N) {
        int K;
        cin >> K;

        rep(j, K) {
            int l;
            cin >> l;

            uf.unite(i, N + l);
        }
    }

    rep(i, N) {
        if (!uf.same(0, i)) {
            cout << "NO\n";
            return 0;
        }
    }

    cout << "YES\n";
}


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

Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(i) for i in input().split()]

first = {}
first[1] = 0
second = {}
flag = 1
i = 0
warp = 0
while flag:
    warp += 1
    if A[i] in first.keys():
        second[A[i]] = warp
        flag = 0
        break
    first[A[i]] = warp
    i = A[i] - 1

loop_town = []
stand = 0
loop = 0
small = 0
for key, value in second.items():
    stand = first[key]
    if K < value:
        small = 1
    loop = value - first[key]
    for key2, value2 in first.items():
        if first[key] <= value2 < value:
            loop_town.append(key2) 

if small == 0:
    print(loop_town[(K-stand)%loop])
else:
    keys = [k for k, v in first.items() if v == K]
    print(keys[0])

Measured memory_bytes: 120256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var (A, B, C) = Scanner.Scan<int, int, int>();
            var ok = false;
            if(A == B && A != C) ok = true;
            if(A == C && A != B) ok = true;
            if(B == C && B != A) ok = true;
            Console.WriteLine(ok ? "Yes" : "No");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int z = 0;
  if (2 * c < a + b) {
    int t = min(x, y);
    x -= t;
    y -= t;
    z += 2 * t;
  }
  if (2 * c < a) {
    int t = x;
    x -= t;
    z += 2 * t;
  }
  if (2 * c < b) {
    int t = y;
    y -= t;
    z += 2 * t;
  }
  cout << a * x + b * y + c * z << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
odd = N * M
a = N + M
print(a * (a - 1) // 2 - odd)



Measured memory_bytes: 5768
#include <bits/stdc++.h>
     
    using namespace std;
    int dp[500][500];
    int a[55],b[55],c[55];
    int main(){
        int n,x,y,xx,yy;
        scanf("%d%d%d",&n,&xx,&yy);
        int total = 0;
        int i,fir=0,sec=0,j;
        for(i=1;i<=n;i++)
            {
            scanf("%d%d%d",&a[i],&b[i],&c[i]);
            fir += a[i];
            sec += b[i];
        }
       // printf("max sum %d %d\n",fir,sec);
        int first,second;
        int ma = 1000000007;
        for(i=0;i<=fir;i++)for(j=0;j<=sec;j++)dp[i][j] = ma;
            dp[0][0] = 0;
        for(i=1;i<=n;i++)
        for(first = fir; first>=0;first--)
            for(second = sec; second>=0; second--)
            {
            if(dp[first][second]<ma)
                {
               x = first + a[i];
               y = second + b[i];
                if(x<=fir && y<=sec)
                    dp[x][y] = min(dp[x][y],dp[first][second] + c[i]);
            }
        }
        int ans = ma;
        for(i=1;;i++)
            {
            x = xx*i;
            y = yy*i;
            if(x>fir)break;
            if(y>sec)break;
          //  printf("check for %d %d\n",x,y);
            ans = min(ans, dp[x][y]);
        }
        if(ans==ma)ans = -1;
        printf("%d\n",ans);
        return 0;
    }

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll, int, int>T;
#define PI 3.14159265358979


int main(){
  ll N,K,C;
  cin>>N>>K>>C;
  string S;
  cin>>S;
  vector<P>A(N+2);
  vector<P>B(N+2);
  rep(i,N+2){A[i]=P(0,0);B[i]=P(0,0);}
  A[0]=P(0,-300000);
  B[N+1]=P(0,500000);
  //前から最適に働く
  for(ll i=0;i<N;i++){
    if(S[i]=='x'){
      A[i+1]=A[i];
    }
    else{
      ll k=i+1;
      //働ける場合
      if(k-A[i].second>C){
      auto t=A[i];  
      t.first+=1;
      t.second=k; 
       
      A[i+1]=P(t.first,t.second);
      }
      if(k-A[i].second<=C){A[i+1]=A[i];}
    }
    
  }
  //後ろから最適に働く
  for(ll i=N-1;i>=0;i--){
    if(S[i]=='x'){
      B[i+1]=B[i+2];continue;
    }
    auto t=B[i+2];
    ll k=i+1;
    //働ける場合
    if(t.second-k>C){
      t.first++;
      t.second=k;
      B[i+1]=t;
    }
    else{B[i+1]=B[i+2];}
  }
  rep(i,N){
    if(S[i]=='x'){continue;}
    auto p=B[i+2];
    auto q=A[i];
    ll sum=p.first+q.first;
    if(sum<K){cout<<i+1<<endl;}
  }  
}


Measured memory_bytes: 9716
#include <stdio.h>
#include <math.h>

int main (void){
	int N, N_a;
	int m = 0;
	int i = 0;

	scanf("%d", &N);
	N_a = N;

	while(N > 0){
		N /= 10;
		i++;
	}

	if(N_a == 0){
		printf("0\n");
	}else{
		if(i % 2 == 0){
			for(int j = 1; j < i; j++){
				if(j % 2 == 1){
					m += pow(10, j) - pow(10, j - 1);
				}
			}

			printf("%d\n", m);
		}else{
			m += N_a - pow(10, i - 1) + 1;
			for(int j = 1; j < i - 1; j++){
				if(j % 2 == 1){
					m += pow(10, j) - pow(10, j - 1);
				}
			}

			printf("%d\n", m);
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <map>
#include <complex>
#include <ctime>
#include <numeric>
#include <set>
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)

using namespace std;

typedef long long ll;

typedef struct node{
    int s, e, val, pos;
    bool operator<(const node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    node(){};
    node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}node;

int occs[(int)1e6 + 5], tree[500100], n, ans[500100];

void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}

int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}

int main()
    {
   Boost();
        
    int q, s, e;
    vector<node> v;
    scanf("%d", &n);
    scanf("%d", &q);
    for(int i = 1; i <= n; i++){
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    
    for(int i = 0; i < q; i++){
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }
    
    sort(v.begin(), v.end());
    
    for(int i = 0;i < v.size(); i++){
        if(v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        }else{
            if(occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }
    
    for(int i = 0; i < q; i++){
        printf("%d\n", ans[i]);
    }
    
    return 0;
}



Measured memory_bytes: 25340
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	set<int> notUsedColors;
	for (int i = 1; i <= 10000; i++)
		notUsedColors.insert(i);
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		notUsedColors.erase(a[i]);
	}
	
	int result = 0;
	for (int i = 1; i < n; i++)
	{
		if (a[i] == a[i - 1])
		{
			result++;
			auto it = notUsedColors.begin();
			a[i] = *it;
			notUsedColors.erase(it);
		}
	}
	cout << result << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define vectorp vector<pair<int,int>>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	int x,a;
	cin >> x >> a;
	if(x<a){
		cout<<"0";return 0;
	}
	cout<<"10";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define foreach(i, vec) for(auto &&i : vec)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) cerr << #x << ": " << (x) << endl
using namespace std;
typedef long long LL;
typedef long long int64;
typedef std::vector<int> VI;
typedef std::vector<VI> VVI;
typedef std::vector<LL> VL;
typedef std::vector<VL> VVL;
typedef std::vector<string> VS;
typedef std::pair<int, int> PII;
typedef std::pair<int64, int64> PLL;
typedef std::queue<int> QI;
typedef std::priority_queue<int> PQI;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>inline void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}

const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;
// M_PI 3.1415...

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cill(n);
    VVL dp(100100, VL(3));
    VVL abc(100100, VL(3));
    rep(i, n){
        cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    }
    dp[0][0]=0;
    dp[0][1]=0;
    dp[0][2]=0;
    rep(i, n){
        rep(j, 3){
            rep(k, 3){
                if (j != k) chmax(dp[i+1][k], dp[i][j] + abc[i][k]);
            }
        }
    }
    LL ans = max({dp[n][0], dp[n][1], dp[n][2]});
    co(ans);
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
class UF{
    public:
        int par[100000];
        int ran[100000];

        void init(int n){
            for(int i = 0;i < n;i++){
                par[i] = i;
                ran[i] = 0;
            }
        }

        int find(int x){
            if(par[x] == x)return x;

            else return par[x] = find(par[x]);
        }

        void unite(int x,int y){
            x = find(x);
            y = find(y);

            if(ran[x] < ran[y])par[x] = y;
            else{
                par[y] = x;
                if(ran[x] == ran[y])ran[x]++;
            }
        }

        bool same(int x,int y){
            return find(x) == find(y);
        }
};

int main(){
    UF uf;//友達関係で連結かどうか.
    int n,m,k;
    cin >> n >> m >> k;
    uf.init(n);

    map<int,int> friends;//各頂点に対して友達関係にあるもの.
    map<pair<int,int>,bool> fri_mp;//後のために保存.
    for(int i = 0;i < m;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        uf.unite(a,b);
        friends[a]++;
        friends[b]++;
        fri_mp[make_pair(a,b)] = true;
        fri_mp[make_pair(b,a)] = true;
    }

    vector<int> block(n,0);
    vector<int> plus(n,0);
    for(int i = 0;i < k;i++){
        int c,d;
        cin >> c >> d;
        c--,d--;
        if(uf.same(c,d)){
            block[c]++;
            block[d]++;
        }
        if(fri_mp[make_pair(c,d)]){
            plus[c]++;
            plus[d]++;
        }
    }

    map<int,int> uf_cnt;

    for(int i = 0;i < n;i++){
        int a = uf.find(i);
        uf_cnt[a]++;
    }

    for(int i = 0;i < n;i++){
        int cnt = uf.find(i);
        cout << uf_cnt[cnt] - 1 - friends[i] - block[i] + plus[i] << endl;
    }
}


Measured memory_bytes: 30080
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
  string s;
  cin >> s;
  long long int K;
  cin >> K;

  string alpha = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";

  long long int j = 0;
  long long int i;
  for(i = K; i >= 0;) {
    //cout << s[j] << " " << s[j]-'a' << " " << i << " " << j << endl;
    if(j == s.size()) break;
    if(s[j] == 'a') {j++; continue;}
    if(i >= 26-(s[j]-'a')) {
      i -= 26-(s[j]-'a');
      s[j] = 'a';
    }
    j++;
  }
  s[s.size()-1] = alpha[s[s.size()-1]-'a'+i%26];
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 640
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
#define LL long long
const LL two=2;
int main()
{
  //  freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    LL n,m,a,ans=0;
    cin>>n>>m;
    a=min(n,m/2);
    ans+=a;
    n-=a,m-=a*two;
    if (!n) ans+=m/4; 
    cout<<ans<<endl;
  //  system("pause");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        char[] c = s.toCharArray();
        
        for(int i = 0; i < 3; i++){
            if(c[i] == c[i+1]){
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
}

Measured memory_bytes: 21844
from collections import deque
x,y,a,b,c = map(int,input().split())

p = deque(sorted(list(map(int,input().split()))))
q = deque(sorted(list(map(int,input().split()))))
r = deque(sorted(list(map(int,input().split()))))

ans = deque(maxlen=(x+y))

def insertion(z):
	global x,y
	if z == p:
		x -= 1
	else:
		y -= 1
	return ans.append(z.pop())

while x > 0 or y > 0:
	if x and y:
		if p[-1] > q[-1] :
			insertion(p)
		else:
			insertion(q)
	elif not x:
		insertion(q)
	else:
		insertion(p)

while r:
	if ans[-1] < r[-1]:
		ans.appendleft(r.pop())
	else:
		break

print(sum(ans))



Measured memory_bytes: 23712
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
  if ( !v.empty() ) {
    out << '[';
    copy (v.begin(), v.end(), ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}

int dp[10010];

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

    int n;
    cin >> n;
    int ss[n];
    REP(i, n) cin >> ss[i];

    for(int i = 0; i < n; i++) {
        for(int j = 10000; j >= 0; j--) {
            if(dp[j] == 1) {
                dp[j + ss[i]] = 1;
            }
        }
        dp[ss[i]] = 1;
    }

#if DEBUG
	cout << "** RESULT **" << endl; // debug
#endif
    int ans = 0;
    for(int i = 10000; i >= 0; i--) {
        if(dp[i] == 1 && i % 10 != 0) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
Tmp = []
Tmp = input().rstrip().split(' ')
 
nN = int(Tmp[0])
nT = int(Tmp[1])
 
nCost = 1001
nAns = 0
 
for i in range(nN):
  Tmp = input().rstrip().split(' ')
 
  nTmpCost = int(Tmp[0])
  nTmpT = int(Tmp[1])
  
  if nTmpT <= nT and nTmpCost < nCost:
    nCost = nTmpCost
    nAns = i+1

if nAns == 0:
  print('TLE')
else:
  print(nCost)
 


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int r,D,x;
    cin>>r>>D>>x;

    for(int i=0;i<10;i++){
        x=r*x-D;
        cout<<x<<endl;
    }
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
typedef unsigned long long int ull;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  double d;
  string s,t;
  cin >>a;
  b=a/2;
  if(a%2!=0)b++;
  cout <<(double)b/a;
}

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

int main(){
                                                                     

    string s;

    string a = "abcdefghijklmnopqrstuvwxyz";

    int k, i, t;


    cin >> s >> k;


    for( i = 0 ; i < s.size() ; i = i + 1 ){

         if( s.at(i) != 'a' ){

             t = 26 - ( s.at(i) - 'a' + 1 ) + 1;

             if( k >= t ){

                 s.at(i) = 'a';

                 k -= t;

                 }

             }

         }


    if( k > 0 ){

        if( k >= 26 ) k = k % 26;

        t = s.at( s.size() - 1 ) - 'a' + 1;

        if( t + k > 26 ) t = ( t + k ) % 26;

        t = t + k;

        s.at( s.size() - 1 ) = a.at(t - 1);

        }


    cout << s << endl;


    return 0;

    }

Measured memory_bytes: 512
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5+10;

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

    int cnt = 0;
    int ans = 0;
    for(int x=1; x<=n; x += 2){
        cnt = 0;
        for(int i=1; i<=x; ++i){
            if(x%i==0) ++cnt;
        }
        if(cnt==8) ans += 1; 
    }
    cout(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define RevRange(container) container.rbegin(), container.rend()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(){
    Cin(int, n);
    if(n == 0){ Cout(0); return 0; }
    string str;
    while(n){
        if(n & 1){
            str.push_back('1');
            n -= 1;
        }
        else str.push_back('0');
        n /= -2;
    }
    reverse(Range(str));
    Cout(str);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n;
int a[224514];
map<int, int>mp;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)mp[a[i]]++;
	for (auto x : mp) {
		if (x.second >= 2) {
			puts("NO");
			ggr
		}
	}
	puts("YES");
	ggr
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, K;
signed main() {
    cin >> N >> K;
    double sum = 0;
    reps(i, N) {
        int cur = i;
        double p = 1;
        while (cur < K) { cur *= 2, p /= 2; }
        sum += p;
    }
    cout << sum / N << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d\n",&a,&b);
  if(a > b){
    printf("a > b\n");
  }else if(a < b){
    printf("a < b\n");
  }else if(a == b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 584
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, A):
    q = [-v for v in A]
    heapq.heapify(q)
    for _ in range(M):
        v = -heapq.heappop(q)
        v /= 2
        heapq.heappush(q, -v)
    
    return -sum(map(int, q))


def main():
    N, M = read_int_n()
    A = read_int_n()
    print(slv(N, M, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16648
/**
*   @Author : MeGaCrazy
*   @InitTime : Thu Jan 03 02:42:19 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
   long long n,k;
   cin>>n>>k;
   vector<pair<int,int> >v;
   for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
   	v.emplace_back(a,b);
   }
   sort(v.begin(),v.end());
   long long sum=0;
   for(int i=0;i<n;i++){
   	sum+=v[i].second;
   	if(sum>=k){
   		cout<<v[i].first<<endl;
   		return 0;
   	}
   }


}

Measured memory_bytes: 1528
s = gets.chomp!.chars
alp = ["0","0"]

s.each_with_index do |c,index|
    if (i = alp.index(c)) then
        puts "#{index + 1 + i - 2} #{index + 1}"
        exit
    else
        alp.shift
        alp << c
    end
end

puts "-1 -1"

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

namespace MSBPC2019
{
    class C
    {
        static void Main(string[] args)
        {
            long X = long.Parse(Console.ReadLine());
            int[] price = new int[] { 100, 101, 102, 103, 104, 105 };
            List<long> list = new List<long>();
            for (int bit = 0; bit < (1 << 6); bit++)
            {
                long sum = 0;
                for (int i = 0; i < 6; i++)
                {
                    if ((bit & (1 << i)) > 0)
                    {
                        sum += price[i];
                    }
                }
                list.Add(sum);
            }

            //Console.WriteLine(string.Join(",", list));
            //Console.WriteLine(list.Count);

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] != 0 && (X % list[i] == 0 || (X % list[i]) % 100 == 0)) { Console.WriteLine(1); return; }
            }
            Console.WriteLine(0);
        }
    }
}


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

int main() {
    while(1) {
        int h, w; cin >> h >> w;
        
        if(h==0) return 0;
        
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

int main() {
    int n; cin >> n;
    int x[n];
    rep(i,n) cin >> x[i];
    int m; cin >> m;
    int a[m];
    rep(i,m) cin >> a[i];

    rep(i,m) {
        if (x[a[i]-1]+1 == x[a[i]] || x[a[i]-1] == 2019) continue;
        x[a[i]-1]++;
    }

    rep(i,n) cout << x[i] << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<math.h>
using namespace std;

long long GCD(long long a, long long b){
	long long r,temp;
	if(a<b)swap(a,b);
	while(b!=0){
		temp=b;
		b=a%b;
		a=temp;
	}
	return a;
}

int main(){
	long long a,b,r;
	while(cin>>a>>b){
		cout<<GCD(a,b)<<' '<<a*b/GCD(a,b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a;
  for(int i=0;i<n;i++){
    int value;
    cin>>value;
    a.push_back(value);
  }
  vector<int> p;
   p.push_back(0);
  int t=p[0]+abs(a[1]-a[0]);
  p.push_back(t);
  for(int i=2;i<n;i++){
    int value=min((p[i-2]+abs(a[i]-a[i-2])),(p[i-1]+abs(a[i]-a[i-1])));
    p.push_back(value);
  }
  cout<<p[n-1];
  return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;

  bool f=true;
  rep1(i,n){
    int x = i*108/100;
    if(x==n){
      cout << i << "\n";
      f=false;
    }
  }
  if(f) cout << ":(" << "\n";
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

class BCoins {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll a,b,c,x;in>>a>>b>>c>>x;
        ll cnt=0;
        for (int i = 0; i <= a; ++i) {
            for (int j = 0; j <= b ; ++j) {
                for (int k = 0; k <= c; ++k) {
                    if(i*500+j*100+k*50==x) ++cnt;
                }
            }
        }
        out<<cnt<<endl;
	}
};


int main() {
	BCoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {   
    if (v == 0)
        return 1 % mod;
    if (v % 2 == 1)
        return (x * bpow(x, v - 1)) % mod;
    ll r = bpow(x, v / 2);
    return (r * r) % mod;   
}

ll solve(){ 
    ll a,b,c; cin>>a>>b>>c;
    ll d = c-a-b;
    if((4*a*b) < d*d and d>0){
        cout<<"Yes";
    }
    else {

        cout<<"No";
    }
}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256