akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    ll n,k;
    cin>>n>>k;
    ll m = n/k;
    cout<<min(abs(n - (k * m)),abs(n - (k * (m + 1))))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }




int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<long long> p(A), q(B), r(C);
    for (int i = 0; i < A; ++i) cin >> p[i];
    for (int i = 0; i < B; ++i) cin >> q[i];
    for (int i = 0; i < C; ++i) cin >> r[i];
    sort(p.begin(), p.end(), greater<long long>());
    sort(q.begin(), q.end(), greater<long long>());
    sort(r.begin(), r.end(), greater<long long>());

    long long res = 0;
    priority_queue<pair<long long, int> > que;
    int x = 0, y = 0, z = 0;
    for (int i = 0; i < A; ++i) que.push({p[i], 0});
    for (int i = 0; i < B; ++i) que.push({q[i], 1});
    for (int i = 0; i < C; ++i) que.push({r[i], 2});
    while (x + y + z < X + Y) {
        auto p = que.top();
        que.pop();
        if (p.second == 0) {
            if (x == X) continue;
            ++x;
            res += p.first;
        }
        else if (p.second == 1) {
            if (y == Y) continue;
            ++y;
            res += p.first;
        }
        else {
            ++z;
            res += p.first;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 12908
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

Int N, W;
Int weight[110], value[110], dp[110][100010];

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

    cin >> N >> W;
    rep(i, 0, N) cin >> weight[i] >> value[i];

    rep(w, 0, W+1) dp[0][w] = 0;

    rep(i, 0, N) {
        rep(w, 0, W+1) {
            if (w >= weight[i]) dp[i+1][w] = max(dp[i][w], dp[i][w-weight[i]] + value[i]);
            else dp[i+1][w] = dp[i][w];
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80128
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=100000000;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll 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;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}

int main(){
	string s;
	cin>>s;
	int a[4];
	rep(i,0,4)a[i]=s[i]-'0';
	rep(i,0,2){
		int x;
		char c;
		if(i){
			x=a[0]+a[1];
			c='+';
		}
		else {
			x=a[0]-a[1];
			c='-';
		}
		rep(j,0,2){
			int y;
			char d;
			if(j){
				y=x+a[2];
				d='+';
			}
			else {
				y=x-a[2];
				d='-';
			}
			rep(k,0,2){
				int z;
				char e;
				if(k){
					z=y+a[3];
					e='+';
				}
				else{
					z=y-a[3];
					e='-';
				}
				if(z==7){
					cout<<a[0]<<c<<a[1]<<d<<a[2]<<e<<a[3]<<"=7"<<endl;
					return 0;
				}
			}
		}
	}
	
	
}

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int p = 10*b + c;
	if(p%4 == 0){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
import math
n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))
for p in [1.0, 2.0, 3.0]:
    a = 0
    for i in range(n):
        a += abs(x[i] - y[i]) ** p
    D = a ** (1/p)
    print(D)
inf_D = float("-inf")
for i in range(n):
    if abs(x[i] - y[i]) > inf_D:
        inf_D = abs(x[i] - y[i])
print(inf_D)


Measured memory_bytes: 5716
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int T;cin>>T;while(T--) 
    {
        ll a,b,ans;
        cin>>a>>b;
        
        if(a==1 || b==1) {
            cout<<"1\n";
            return 0;
        }

        ans = ( 1ll * a * b + 1)/2;

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
#include<numeric>
#include<functional>

using namespace std;
#define ll long long
#define ull unsigned long long
#define rrep(i,m,n) for(ll (i)=(ll)(m);(i)>=(ll)(n);(i)--)
#define rep(i,m,n) for(ll (i)=(ll)(m);i<(ll)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
constexpr long double m_pi = 3.1415926535897932L;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 61;
constexpr long double EPS = 1e-10;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

template<typename T, typename F>
class SegmentTree {
private:
	T identity;
	F merge;
	ll n;
	vector<T> dat;
public:
	SegmentTree(F f, T id,vector<T> v) :merge(f), identity(id) {
		int _n = v.size();
		n = 1;
		while (n < _n)n *= 2;
		dat.resize(2 * n - 1, identity);
		REP(i, _n)dat[n + i - 1] = v[i];
		for (int i = n - 2; i >= 0; i--)dat[i] = merge(dat[i * 2 + 1], dat[i * 2 + 2]);
	}
	SegmentTree(F f, T id, int _n) :merge(f), identity(id) {
		n = 1;
		while (n < _n)n *= 2;
		dat.resize(2 * n - 1, identity);
	}
	void set_val(int i, T x) {
		i += n - 1;
		dat[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			dat[i] = merge(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	T query(int l, int r) {
		T left = identity, right = identity;
		l += n - 1; r += n - 1;
		while (l < r) {
			if ((l & 1) == 0)left = merge(left, dat[l]);
			if ((r & 1) == 0)right = merge(dat[r - 1], right);
			l = l / 2;
			r = (r - 1) / 2;
		}
		return merge(left, right);
	}
};

ll imos[5050][5050];

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

	ll n, m;
	cin >> n >> m;
	Array a(n,0);
	REP(i, n - 1)cin >> a[i + 1], a[i + 1] += a[i];
	vector<vector<P>> b(m, vector<P>(n));
	REP(i, n)REP(j, m)cin >> b[j][i].first;
	REP(i, m)REP(j, n)b[i][j].second = j;
	P id = { -INF,-1 };
	auto merge = [](P a, P b) {return max(a, b); };
	
	auto f = [](auto f, ll l,ll r,SegmentTree<P,decltype(merge)>& seg) -> void {
		if (l == r)return;
		P mx = seg.query(l, r);
		imos[l][mx.second] += mx.first;
		imos[l][r] -= mx.first;
		imos[mx.second+1][mx.second] -= mx.first;
		imos[mx.second+1][r] += mx.first;
		f(f, l, mx.second, seg);
		f(f, mx.second + 1, r, seg);
	};
	REP(i, m) {
		SegmentTree<P, decltype(merge)> seg(merge, id, b[i]);
		f(f, 0, n, seg);
	}
	REP(i, n)REP(j, n) imos[i][j + 1] += imos[i][j];
	REP(i, n)REP(j, n)imos[i + 1][j] += imos[i][j];
	ll ans = 0;
	REP(i, n) rep(j, i, n) chmax(ans, imos[i][j] - (a[j] - a[i]));
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 214912
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
public static class P {
  public static void Main() {
    var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int n = nm[0];
    int m = nm[1];
    var graph = new List< List < int > >();
    for (int i = 0; i < n; i++) {
      graph.Add(new List< int >());
    }
    for (int i = 0; i < m; i++) {
      var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
      int s = st[0] - 1;
      int t = st[1] - 1;
      graph[s].Add(t);
    }

    var dp = new List < double >();
    dp.AddRange(Enumerable.Repeat(0.0, n));
    for (int i = n - 2; i >= 0; i--) {
      foreach (int j in graph[i]) {
        dp[i] += dp[j];
      }
      dp[i] /= graph[i].Count();
      dp[i] += 1;
    }

    var ep = new List < double >();
    ep.AddRange(Enumerable.Repeat(0.0, n));
    ep[0] = 1;
    for (int i = 0; i < n; i++) {
      foreach (int j in graph[i]) {
        ep[j] += ep[i] / graph[i].Count();
      }
    }

    double full = dp[0];
    double ans = full;
    for (int i = 0; i < n; i++) {
      int sz = graph[i].Count();
      if (sz < 2) continue;
      double sum = 0;
      double max = 0;
      foreach (int j in graph[i]) {
        sum += dp[j];
        max = Max(max, dp[j]);
      }
      double x = sum / sz;
      double y = (sum - max) / (sz - 1);
      ans = Min(ans, full - ep[i] * (x - y));
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 19816
from collections import defaultdict

N, T = map(int, input().split())
A = [int(x) for x in input().split()]

B = [0] * N
for i in range(N - 1):
    a = A[N - i - 1]
    B[i + 1] = max(B[i], a)
B = B[::-1]

c = defaultdict(int)
for i in range(N - 1):
    c[B[i] - A[i]] += 1
print(c[max(c)])


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

int main(void) {
    string S;
    cin >> S;
    for (int i=0; i<3; ++i){
        if (S[i] == S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

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

using namespace std;
typedef long long ll;
int a, b, c, k;

template <class T>
void read(T &x, T f = 1) {
    char ch = getchar();
    x = 0;
    while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

void dfs(int a, int b, int c, int cnt) {
    if (cnt > k) return;
    if (c > b && b > a) cout << "Yes", exit(0);
    dfs(a * 2, b, c, cnt + 1);
    dfs(a, b * 2, c, cnt + 1);
    dfs(a, b, c * 2, cnt + 1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> a >> b >> c;
    cin >> k;
    dfs(a, b, c, 0);
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3644
///====================== TEMPLATE STARTS HERE =====================///
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"
#define pb push_back
#define MP make_pair
#define ff first
#define ss second
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define POPCOUNT __builtin_popcountll
#define Set(N,p) ((N)|((1LL)<<(p)))
#define Reset(N,p) ((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)

#define LL long long
#define LLU long long unsigned int
typedef pair < int, int > pii;
typedef pair < LL, LL > pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pll> vll;

#ifdef s_da_sailor
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif // s_da_sailor

inline LL gcd ( LL a, LL b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}

LL ext_gcd ( LL A, LL B, LL *X, LL *Y ){
    LL x2, y2, x1, y1, x, y, r2, r1, q, r;
    x2 = 1; y2 = 0;
    x1 = 0; y1 = 1;
    for (r2 = A, r1 = B; r1 != 0; r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y ) {
        q = r2 / r1;
        r = r2 % r1;
        x = x2 - (q * x1);
        y = y2 - (q * y1);
    }
    *X = x2; *Y = y2;
    return r2;
}

inline LL modInv ( LL a, LL m ) {
    LL x, y;
    ext_gcd( a, m, &x, &y );
    x %= m;
    if ( x < 0 ) x += m;
    return x;
}

inline LL bigmod ( LL a, LL p, LL m ) {
    LL res = 1 % m, x = a % m;
    while ( p ) {
        if ( p & 1 ) res = ( res * x ) % m;
        x = ( x * x ) % m; p >>= 1; /// For bigmod2 multiply here using mulmod
    }
    return res;
}


//int knightDir[8][2] = { {-2,1},{-1,2},{1,2},{2,1},{2,-1},{-1,-2},{1,-2},{-2,-1} };
//int dir4[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
//int dir8[8][2] = {{-1,0},{0,1},{1,0},{0,-1},{-1,-1},{1,1},{1,-1},{-1,1}};
const LL inf = 2147383647;
const LL mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-11;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); /// For generating random numbers

///======================  TEMPLATE ENDS HERE  =====================///

void solve() {
    string S;
    cin >> S;
    int cnt=0, mx=0;
    for(int i=0; i<S.size(); i++) {
        if(S[i]=='R') {
            cnt++;
            mx = max(mx, cnt);
        }
        else {
            cnt=0;
        }
    }
    cout << mx << endl;
}

int main () {
    #ifdef s_da_sailor
    freopen ( "input.txt", "r", stdin );
    //freopen ( "output.txt", "w", stdout );
    #endif // s_da_sailor

    fast_cin;

    solve();

    return 0;
}


Measured memory_bytes: 3612
s = input()
Ccnt = 0
cnt = 0
a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
b = s[2:-1]
for i in range(len(b)):
    if b[i] == 'C':
        Ccnt += 1
for i in range(len(s)):
    if s[i] in a:
        cnt += 1
if s[0] == 'A' and Ccnt == 1 and cnt == 2:
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3064
s=input()
q=int(input())
a=""
b=""
res=0
for i in range(q):
    l=list(input().split())
    if l[0]=="1":
        res+=1
        a,b=b,a
    else:
        if l[1]=="1":
            a+=l[2]
        else:
            b+=l[2]
if res%2==0:
    print(a[::-1]+s+b)
else:
    print(a[::-1]+s[::-1]+b)

Measured memory_bytes: 4468
//abc119_b.cpp
//Tue Mar  5 21:36:52 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	double x[n];
	string u[n];
	double ans = 0;
	for (int i=0;i<n;i++){
		cin >> x[i] >> u[i];
		if (u[i] == "BTC"){
			ans += 380000.0*x[i];
		}else{
			ans += x[i];
		}
	}

//	cout << ans << endl;
	printf("%.6f\n",ans);
}

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

using ll = long long;
using P  = std::pair<int, int>;
using LP = std::pair<ll, int>;

const ll INF = 1e18;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int h, w, k;
    int si, sj, gi, gj;
    std::cin >> h >> w >> k;
    std::cin >> si >> sj >> gi >> gj;
    --si; --sj; --gi; --gj;
    std::vector<std::string> g(h);
    for (int i=0; i<h; ++i) std::cin >> g[i];

    auto toId = [&](int i, int j, int v) {
        return (i*w+j)*4+v;
    };

    auto modCeilK = [&](ll x) {
        return (x+k-1)/k*k;
    };
    std::vector<ll> dist(h*w*4, INF);

    std::priority_queue<LP, std::vector<LP>, std::greater<LP> > q;
    auto push = [&](int i, int j, int v, ll x) {
        int id = toId(i, j, v);
        if (dist[id] <= x) return;
        dist[id] = x;
        q.emplace(x, id);
    };

    for (int v=0; v<4; ++v) push(si, sj, v, 0);

    while (!q.empty()) {
        ll d = q.top().first;
        int id = q.top().second;
        q.pop();

        if (dist[id] != d) continue;

        int i = id / w / 4;
        int j = id / 4 % w;
        int v = id % 4;

        for (int nv=0; nv<4; ++nv) push(i, j, nv, modCeilK(d));
        {
            int ni = i+di[v], nj = j+dj[v];
            if (0 <= ni && ni < h && 0 <= nj && nj < w) {
                if (g[ni][nj] == '.')
                    push(ni, nj, v, d+1);
            }
        }
    }
    ll ans = INF;
    for (int v=0; v<4; ++v)
        ans = std::min(ans, dist[toId(gi, gj, v)]);
    if (ans == INF) {
        std::cout << -1 << std::endl;
    } else {
        ans = modCeilK(ans)/k;
        std::cout << ans << std::endl;
    }

    return 0;
}


Measured memory_bytes: 44112
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int M = 1000005;

int main(){
    int n;
    cin >> n;
    vector<int> a(n,0);
    vector<int> d(M,0);
    for(int i = 0;i < n;i++) cin >> a.at(i);
    for(int i = 0;i < n;i++){
        if(d.at(a.at(i)) != 0){
            d.at(a.at(i)) = 2;
            continue;
        }
        for(int j = a.at(i); j < M;j += a.at(i)) d.at(j)++;
    }
    int ans = 0;
    for(int i = 0;i < n;i++)if(d.at(a.at(i)) == 1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 7932
from collections import deque

def input_bordered_grid(h, w, wall):
    grid = [wall * (w + 2)]
    for _ in range(1, h+1):
        grid.append(wall + input() + wall)
    grid.append(wall * (w + 2))
    return grid

h, w = map(int, input().split())
grid = input_bordered_grid(h, w, '#')

move = [(-1, 0), (1, 0), (0, -1), (0, 1)]

longest = 0
for sy in range(1, h+1):
    for sx in range(1, w+1):
        if grid[sy][sx] == '#':
            continue
        dist = [[-1] * (w+2) for _ in range(h+2)]
        dist[sy][sx] = 0
        q = deque()
        q.append((sy, sx))
        while q:
            y, x = q.popleft()
            longest = max(longest, dist[y][x])
            for dy, dx in move:
                yy = y + dy
                xx = x + dx
                if dist[yy][xx] == -1 and grid[yy][xx] == '.':
                    q.append((yy, xx))
                    dist[yy][xx] = dist[y][x] + 1
print(longest)


Measured memory_bytes: 69548
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll N;
    cin >> N;
    ll n = -1;
    ll cnt = 1;
    rep(i,1000){
        n += pow(26,i);
        if(N>n){
        }else{
            cnt = i;
            break;
        }
    }
    n = N;
    ll p = 0;
    string out = "";
    rep(i,cnt){
        p = n%26;
        if(p==0) p = 26;
        char add = 'a'+p-1;
        out = add + out;
        n = (n-p)/26;
    }
    cout << out << endl;
    return 0;
}



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



int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    sort(a.rbegin(), a.rend());
    
    long int sum = 0;
    int cnt = n - 1;
    rep(i,n) {
        int us = 2;
        if(i == 0)
            us = 1;
        
        rep(j,us) {
            sum += a[i];
            cnt--;
            
            if(cnt <= 0)
                break;
        }
        
        if(cnt <= 0)
            break;
    }
    
    cout << sum << endl;
    
    return 0;
}




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

class dsu {
  int N;
  vector<int> PS;

public:
  dsu() : N(0) {}
  dsu(int n) : N(n), PS(n, -1) {}

  int merge(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    int x = leader(a), y = leader(b);
    if (x == y) return x;
    if (-PS.at(x) < -PS.at(y)) swap(x, y);
    PS.at(x) += PS.at(y);
    PS.at(y) = x;
    return x;
  }

  bool same(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < N);
    return leader(a) == leader(b);
  }

  int leader(int a) {
    assert(0 <= a && a < N);
    if (PS.at(a) < 0) return a;
    return PS.at(a) = leader(PS.at(a));
  }

  int size(int a) {
    assert(0 <= a && a < N);
    return -PS.at(leader(a));
  }

  vector<vector<int>> groups() {
    vector<int> leader_buf(N), group_size(N);
    for (int i = 0; i < N; i++) {
      leader_buf.at(i) = leader(i);
      group_size.at(leader_buf.at(i))++;
    }
    vector<vector<int>> result(N);
    for (int i = 0; i < N; i++) {
      result.at(i).reserve(group_size.at(i));
    }
    for (int i = 0; i < N; i++) {
      result.at(leader_buf.at(i)).push_back(i);
    }
    result.erase(
      remove_if(result.begin(), result.end(), [&](const vector<int>& v) { return v.empty(); }),
      result.end()
    );
    return result;
  }
};

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int N, Q;
  cin >> N >> Q;
  dsu D(N);
  for (int i = 0; i < Q; i++) {
    int t, u, v;
    cin >> t >> u >> v;
    if (t)
      cout << D.same(u, v) << "\n";
    else
      D.merge(u, v);
  }
}

Measured memory_bytes: 3976
x = int(input())
def function(a,b):
    return a**5-b**5

a = 0
for i in range(-119,119):
    for j in range(i+1,120):
        if function(j,i)==x:
            print(j,i)
            a = 1
            break
    if a == 1:
        break

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int,int> P;

int main() {
    ll H;cin >> H;
    ll count = 1;ll attack = 0;ll turn = 0;
    if (H == 1) {
        cout << 1 << endl;
        return 0;
    }
    while(true){
        turn++;
        H /= 2;
        attack += pow(2,turn - 1);
        if (H == 1) {
            attack += pow(2,turn);
            break;
        }
    }
    cout << attack << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cmath>
using namespace std;

int main(void)
{		
	double r;
	cin >> r;
	
	double area = r * r * M_PI;
	double leng = r * 2 * M_PI;
	
	cout << fixed << area << " " << leng << endl;
	
	return 0;
}

Measured memory_bytes: 3256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.AbstractCollection;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Megalomania solver = new Megalomania();
        solver.solve(1, in, out);
        out.close();
    }

    static class Megalomania {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            PriorityQueue<Pair> pq = new PriorityQueue<>(n, (o1, o2) -> Long.compare(o1.time, o2.time));
            for (int i = 0; i < n; i++) {
                Long task = Long.parseLong(in.next());
                Long time = Long.parseLong(in.next());
                pq.add(new Pair(task, time));
            }

            long time = 0;
            while (!pq.isEmpty()) {
                Pair p = pq.poll();
                time += p.task;
                if (time > p.time) {
                    out.append("No");
                    return;
                }
            }
            out.append("Yes");
        }

        class Pair {
            public final Long task;
            public final Long time;

            public Pair(Long task, Long time) {
                this.task = task;
                this.time = time;
            }

        }

    }
}



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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	for(int i=0;i<n;++i){
		vector<int>v(3); for(auto&&j:v)cin>>j;
		sort(v.begin(),v.end());
		int&a=v.back(),&b=v.front(),&c=v.at(1);
		cout<<(a*a==b*b+c*c?"YES"s:"NO"s)<<"\n"s;
	}
}


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

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  int a[n+1] = {};
  int map[n+1] = {};
  for(int i = 0; i < m; i++){
    cin >> a[i];
    map[a[i]] = 1;
  }
  int sum1 = 0, sum2 = 0;
  for(int i = x; i <= n; i++) sum1 += map[i];
  for(int i = x; i >= 0; i--) sum2 += map[i];
  cout << min(sum1, sum2) << 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++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int h, w;
    cin >> h >> w;
    auto v = make_vec<char>(h, w);
    rep(i, h) rep(j, w) cin >> v[i][j];
    rep(i, h) rep(j, w) {
        if (v[i][j] != '.') continue;
        int cnt = 0;
        for (int dy = -1; dy <= 1; dy++) {
            for (int dx = -1; dx <= 1; dx++) {
                int ny = i + dy, nx = j + dx;
                if (!(0 <= ny && ny < h && 0 <= nx && nx < w)) continue;
                if (v[ny][nx] == '#') cnt++;
            }
        }
        v[i][j] = (char)(cnt + '0');
    }
    rep(i, h) {
        rep(j, w) cout << v[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	for (int n; cin >> n&&n;) {
		vector<string> ac;
		for (int i = 0; i < n; i++) {
			string s; cin >> s;
			string t = "";
			t += s[0];
			for (size_t j = 0; j < s.size() - 1; j++) {
				if (s[j] == 'a' || s[j] == 'i' || s[j] == 'u' || s[j] == 'e' || s[j] == 'o') {
					t += s[j + 1];
				}
			}
			ac.push_back(t);
		}
		int k = -1;
		for (int h = 1; h <= 60; h++) {
			vector<string> tmp;
			for (int i = 0; i < ac.size(); i++) {
				tmp.push_back(ac[i].substr(0, h));
				//cout << ac[i].substr(0, h) << endl;
			}
			sort(tmp.begin(), tmp.end());
			tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
			//cout << h << " " << tmp.size() << endl;
			if (tmp.size() == n) {
				k = h; break;
			}
		}
		cout << k << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
# -*- coding: utf-8 -*-
C=[[0]*3 for i in range(3)]
for ii in range(3):
    C[ii]=list(map(int,input().split()))

#Flag=0

#if C[0][0]-C[1][0]==C[0][1]-C[1][1] and C[0][1]-C[1][1]==C[0][2]-C[1][2] and C[1][0]-C[2][0]==C[1][1]-C[2][1] and C[1][1]-C[2][1]==C[1][2]-C[2][2]:
#    Flag=1
Flag=1
for ii in range(1,3):
    for jj in range(1,3):
        if C[ii-1][jj-1]-C[ii][jj-1]!=C[ii-1][jj]-C[ii][jj]:
            Flag=0
            break
    if Flag==0:
        break

if Flag==1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9196
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  vector<vector<int> > edge(10);
  int c;
  for(int i=0;i<10;++i) {
    for(int j=0;j<10;++j) {
      cin>>c;
      edge[j].push_back(c);
    }
  }
  map<int, int> amap;
  for(int i=0;i<10;++i) amap[i] = -1;
  pair<int, int> state;
  priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
  que.push(mp(0, 1));
  int node, cost;
  while(!que.empty()) {
    state = que.top();que.pop();
    node = state.se;
    cost = state.fi;
    if(amap[node]>-1) continue;
    amap[node] = cost;
    for(int i=0;i<10;++i) {
      if(amap[i]>-1) continue;
      que.push(mp(cost+edge[node][i], i));
    }
  }
  int ans = 0;
  int A;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      cin>>A;
      if(A==-1) continue;
      ans += amap[A];
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3592
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
const ll inf=1ll<<29;
int main(){
      ll n;
      cin>>n;
      ll a[n];
      rep0(i,n)cin>>a[i];
    int mochi=0;
  rep0(i,n-1) if(a[i+1]<=a[i]) mochi=1;
  if(!mochi){
    cout<<1<<endl;
    return 0;
  }
      ll ng=1;
      ll ok=200002;
      map<ll,ll> counter;
      while(ok-ng>1){
            bool good=true;
            ll now=(ok+ng)/2;
            map<ll,ll> counter;
            rep0(i,n-1){
                  if(a[i+1]>a[i]) continue;
                  ll j=a[i+1];
                  while(1){
                        if(j<=-1){
                          good=false;
                          break;
                        }
                        if(counter[j]==(now-1)){
                              --j;
                        }
                        else if(counter[j]<now-1){
                          	counter[j]++;
                              counter.erase(counter.lower_bound(j+1),counter.end());
                              break;
                        }
                  }
                  //rep0(i,10) cout<<counter[i]<<" ";
                  //cout<<endl;
                  }
            if(counter[0]>0) good=false;
                  //cout<<endl;
            if(good) ok=now;
            else ng=now;
      }
      cout<<ok<<endl;
      return 0;
}


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

int main(){
  int n,t = 0;
  int min_c = 1001;
  int c[n];
  int d[n];
  cin >> n >> t;
  for(int i=0;i<n;++i){
    cin >> c[i] >> d[i];  
  }
  for(int j=0;j<n;++j){
    //cout << c[j] << " " << d[j] << endl;    
    if(d[j] <= t){
      if(c[j] < min_c){
        min_c = c[j];
      }    
    }
  }
  if(min_c == 1001){
    cout << "TLE"  << endl;
  }else{
    cout << min_c << endl;
  }
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
    int N;
    int res = 0;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        while(a % 2 == 0) {
            a /= 2;
            ++res;
        }
    }

    cout << res << endl;  
}

Measured memory_bytes: 256
function main(input) {
  	const inputs = input.split("\n")
    const max = inputs[0]
  	const nums = inputs[1].split(" ")
    flag1 = false
    for(let i = 0; i < max+1; i++){
 
      input2 = nums.map(item =>{
          if( parseInt(item) / (2**i) % 2  === 0){
              return item
          }else{
              flag1 = true
              return
          }
      })
      if(flag1 === true){
          console.log(i)
          break
      }
  }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

string str;
#define MXN 200005
typedef long long ll;

int N;
ll TOT[MXN], DP[MXN];
int rec[MXN], mt[MXN], popp[MXN];

int main()
{
    cin>>str;
    N = str.size();
    int pos = 0;
    deque<int> stk;

    for(int i = 1; i <= N; i++)
    {
        if(str[i-1]=='-')
        {
            deque<int> rst;//restore stack
            int att=pos, cnt = 0;
            while( i<=N && str[i-1]=='-' )
            {
                cnt++;
                pos--;
                cout<<TOT[pos]<<'\n';
                i++;
            }
            //restore
            i--;
            int l = att-cnt+1, r = att;
            for( int j = r; j >= l; j-- )
            {
                if( !stk.empty() && stk.back()==j )stk.pop_back();
            }
            for( int j = r; j >= l; j-- )
            {
                if( rec[j]==2 && mt[j]>0 && mt[j]<l )
                {
                    stk.push_back( mt[j] );
                }
            }
        }
        else if(str[i-1]=='(')
        {
            pos++;
            rec[pos] = 1;
            DP[pos] = 0;
            stk.push_back(pos);
            popp[pos] = 0;
            TOT[pos] = TOT[pos-1];
        }
        else
        {
            pos++;
            rec[pos] = 2;
            if(stk.empty())
            {
                DP[pos] = 0;
                mt[pos] = 0;
                TOT[pos] = TOT[pos-1];
            }
            else
            {
                assert( !(pos==1 && !stk.empty()) );
                int lf = stk.back();
                stk.pop_back();
                mt[pos] = lf;
                popp[lf] = 1;
                DP[pos] = DP[lf-1]+1;
                TOT[pos] = TOT[pos-1]+DP[pos];
            }
        }
        if(str[i-1]!='-')cout<<TOT[pos]<<'\n';
    }

    return 0;
}

/*

()--()()----)(()()))

*/



Measured memory_bytes: 8916
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start

// SegTree
module SegTree =
  type SegTree<'a>(f: 'a -> 'a -> 'a, zero: 'a, num: int, data: 'a array) =
    static member Create f zero (src: _ array): _ SegTree =
      let num =
        let rec loop n' = if n' < src.Length then loop (n'*2) else n'
        loop 1
      let data = Array.create (2*num-1) zero

      for i in 0..(src.Length-1) do
        data.[i+num-1] <- src.[i]

      let rec loop n =
        for i in (n-1)..(2*n-2) do
          data.[i] <- f data.[2*i+1] data.[2*i+2]
        if n > 1 then do loop (n/2)

      loop (num/2)
      SegTree(f, zero, num, data)

    // [a, b)
    member this.Query a b =
      let rec loop i l r =
        let ave = (l+r)/2
        if r <= a || b <= l then zero
        elif a <= l && r <= b then data.[i]
        else
          f (loop (2*i+1) l ave) (loop (2*i+2) ave r)
      loop 0 0 num

    member private this.Update i =
      let rec loop n j =
        let i' = j + n - 1
        data.[i'] <- f data.[2*i'+1] data.[2*i'+2]
        if n > 1 then do loop (n/2) (j/2)
      loop (num/2) (i/2)

    member this.Item
      with get(i) = data.[i + num - 1]
      and set i v =
        data.[i + num - 1] <- v
        this.Update i
    member this.Data = data
  
  // utils
  let create = SegTree<_>.Create
  /// query in [a, b) (logN)
  let query a b (segTree: SegTree<_>) = segTree.Query a b
  let modify (segTree: SegTree<_>) i f = segTree.[i] <- f segTree.[i]
// SegTree

let rec popCnt = function | 0 -> 0 | n -> popCnt (n>>>1) + if (n&&&1) = 1 then 1 else 0

let N = readInt ()
let S = readStr ()

let charToSet c = 1<<<(int c - int 'a')

let seg =
  let src = S.ToCharArray() |> Array.map charToSet
  SegTree.create (|||) 0 src

type Query = Modify of int * Char | Range of int * int
let readQuery () =
  let qs = readStr().Split()
  match Array.head qs with
  | "1" -> Modify (int qs.[1], qs.[2].ToCharArray().[0])
  | "2" -> Range (int qs.[1], int qs.[2])
  | _ -> failwith "okasii"

let Q = readInt ()

let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
seq {
  for _ in 1..Q do
    let q = readQuery ()
    match q with
    | Modify (i, c) ->  seg.[i-1] <- charToSet c
    | Range (l, r) -> yield (SegTree.query (l-1) r seg |> popCnt)
    
}
|> Seq.map (sprintf "%d")
|> Seq.iter writer.WriteLine 

writer.Dispose()

Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,m;
    cin >> n >> m;
    long long int ans=0;
    priority_queue<int> maxqueue;
    for(int i=0;i<n;i++){
        int a;
        cin >>  a;
        maxqueue.push(a);
    }
    while(m>0){
        int element=maxqueue.top();
        maxqueue.pop();
        maxqueue.push(element/2);
        m--;
    }

    while(maxqueue.empty()==false){
        ans+=maxqueue.top();
        maxqueue.pop();
    }
    cout<<ans;
}


Measured memory_bytes: 892
n,m = map(int,input().split())
t = [[] for _ in range(n)]
for i in range(m):
    t_1,t_2 = map(int,input().split())
    t[t_1-1].append(t_2)

ans = ""
for i in range(n):
    if len(set(t[i])) == 1:
        ans += str(t[i][0])
    elif not t[i]:
        if i == 0:
            if n == 1:
                ans += "0"
            else:    
                ans += "1"
        else:
            ans += "0"
    else:
        print(-1)
        exit()
if ans[0] == "0":
    if n == 1:
        print(0)
    else:
        print(-1)
else:
    print(ans)


Measured memory_bytes: 61948
import sys

def input():
    return sys.stdin.readline().rstrip('\n')


DAYS = {
    'SUN':7,
    'MON':6,
    'TUE':5,
    'WED':4,
    'THU':3,
    'FRI':2,
    'SAT':1,
}

S = input()
#A,B = list(map(int,input().split()))

print(DAYS[S])


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<double, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i,d;
	ll a[225816],b[225816],pq,rs,ans=INFLL,mx,mn;
	cin >> n;
	for(i=1; i<=n; ++i){
		cin >> a[i];
	}
	b[0] = 0ll;
	for(i=1; i<=n; ++i){
		b[i] = a[i] + b[i-1];
	}
	for(i=2; i<n; ++i){
		pq = b[i-1];
		rs = b[n] - b[i-1];
		d = (int)(lower_bound(b,b+n+1,pq/2)-b);
		if(d > 1 && abs(pq-b[d]*2) > abs(pq-b[d-1]*2)){
			--d;
		}
		if(d < (i-2) && abs(pq-b[d]*2) > abs(pq-b[d+1]*2)){
			++d;
		}
		mx = max(b[d],pq-b[d]);
		mn = min(b[d],pq-b[d]);
		d = (int)(lower_bound(b,b+n+1,b[i-1]+rs/2)-b);
		if(d > i && abs(b[n]+pq-b[d]*2) > abs(b[n]+pq-b[d-1]*2)){
			--d;
		}
		if(d < (n-1) && abs(b[n]+pq-b[d]*2) > abs(b[n]+pq-b[d+1]*2)){
			++d;
		}
		mx = max(mx,max(b[d]-pq,b[n]-b[d]));
		mn = min(mn,min(b[d]-pq,b[n]-b[d]));
		ans = min(ans,mx-mn);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    if ((s.front() == s.back()) ^ (s.size() % 2 == 0)) {
        cout << "Second" << endl;
    }
    else {
        cout << "First" << endl;
    }
}


Measured memory_bytes: 512
c_one = list(map(int, input().split()))
c_two = list(map(int, input().split()))
c_thr = list(map(int, input().split()))

a_b_ones = [(x, c_one[0]-x) for x in range(c_one[0]+1)]
a_b_twos = [(x, c_two[1]-x) for x in range(c_two[1]+1)]
a_b_thrs = [(x, c_thr[2]-x) for x in range(c_thr[2]+1)]

ans = 'No'

for p in a_b_ones:
    for q in a_b_twos:
        for r in a_b_thrs:
            a1, b1 = p[0], p[1]
            a2, b2 = q[0], q[1]
            a3, b3 = r[0], r[1]
            if (c_one[1] == a1 + b2) and (c_one[2] == a1 + b3) and (c_two[0] == a2 + b1) and (c_two[2] == a2 + b3) and (c_thr[0] == a3 + b1) and (c_thr[1] == a3 + b2):
                ans = 'Yes'
print(ans)

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define EPS (1e-5)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int N, M;

int X[MAX];
int Y[MAX];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	cin>>N>>M;
	
	rep(i,M){
		cin>>X[i];
	}
	
	sort(X, X+M);
	
	for(int i = 1; i < M; i++){
		Y[i-1] = X[i]-X[i-1];
	}
	
	sort(Y,Y+M-1);
	
	int t = M-N, ans = 0;
	// cout<<t<<endl;
	for(int i = 0; i < t; i++){
		ans += Y[i];
		// cout<<Y[i]<<endl;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
   long long n,k,q;
   cin >> n >> k >> q;
   long long a;
   long long mochiten[n] = {0};
   REP(i,q){
      cin >> a;
      mochiten[a-1] += 1;
   }
   REP(i,n){
      if(mochiten[i]+k-q <= 0) cout << "No\n";
      else cout << "Yes\n";
   }
   
   
   return 0;
}

Measured memory_bytes: 1408
N = int(input())
scores = []

for i in range(N):
    score = int(input())
    scores.append(score)

maximum = sum(scores)
if maximum % 10 != 0:
    print(maximum)
else:
    scores.sort()
    ans = 0
    for score in scores:
        if score % 10 != 0:
            ans = maximum - score
            break
    print(ans)

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

using namespace std;

#define int long long
#define N 100005

int n, m, a, b, c, cnt = 0, from[N], to[N], f, t, s = 1, e = 1;
int ans = 0;

signed main ()
{
	ios_base::sync_with_stdio (0);
	cin >> n >> m;
	cin >> t;
	for (int i = 1; i < m; ++i)
	{
		f = t;
		cin >> t;
		from[i] = min(f, t);
		to[i] = max(f, t);
	}
	sort (from + 1, from + m);
	sort (to + 1, to + m);
	for (int i = 1; i < n; ++i)
	{
		cin >> a >> b >> c;
		while (i==from[s])
		{
			cnt++;
			s++;
		}
		while (i==to[e])
		{
			cnt--;
			e++;
		}
		ans += min (a * cnt, c + b * cnt);
	}
	
	cout << ans << "\n";
}

Measured memory_bytes: 4756