akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;

struct Knapsack01v{
    int N, W, V, MAX;
    vector<int> v, w, dp;
    Knapsack01v(vector<int> v, vector<int> w, int W): v(v), w(w), W(W){
        N = v.size();
        V = 0; MAX = 0;
        for(int i = 0; i < N; i++){
            V += v[i]; MAX += w[i];
        }
        dp.resize(V + 1, MAX);
    }
    int build(){
        dp[0] = 0;
        for(int i = 0; i < N; i++){
            for(int j = V; j >= v[i]; j--){
                dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
            }
        }
        int ret = 0;
        for(int i = 0; i <= V; i++) if(dp[i] <= W) ret = i;
        return ret;
    }
};

signed main(){
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
    Knapsack01v a(v, w, W);
    cout << a.build() << endl;
}


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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const int INF = 1e9+10;
const ll mod = 998244353;
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 print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

ll f(ll x, ll cnt){
    //fprintf(stderr, "x = %d, cnt = %d\n", x, cnt);
    ll x0 = x;
    if (x == 0)return cnt;
    ll ans = 0;
    while(x){
        if (x % 2 == 1)ans++;
        x/=2;
    }
    //fprintf(stderr, "ans = %d\n", ans);
    return f(x0%ans, cnt + 1);
}
int main()
{

#if 0
    ll N = 20000;
    ll cnt = 0;
        vector<ll> A(N), base0(N + 1),base1(N + 1);

    rep(i, N){
        A[i] = 1;
        cnt += A[i];
    }
#else    
    ll N;
    ll cnt = 0;
    cin >> N;
    
    string S;
    cin >> S;
    vector<ll> A(N), base0(N + 1),base1(N + 1);
    rep(i, N){
        if (S[i] == '0')A[i] = 0;
        else A[i] = 1;
        cnt += A[i];
    }
#endif
    ll r = 0, mod = cnt + 1;
    ll base = 1;
    rep(j, N){
            r += A[N - j - 1] * base;
            r %= mod;
            base0[j] = base;
            (base *= 2) %= mod;
        
    }
    ll rbase0 = r;

    r = 0, mod = cnt - 1;
    if (mod){
    
    base = 1;
    rep(j, N){
            r += A[N - j - 1] * base;
            r %= mod;
            base1[j] = base;
            (base *= 2) %= mod;
    }
    }
    ll rbase1 = r;
    rep(i, N){
        ll mod;
        
        ll r = 0;
        if (A[i] == 0)mod = cnt + 1;
        if (A[i] == 1)mod = cnt - 1;
        if (mod == 0){
            cout << 0 << endl;
            continue;
        }
        if (A[i] == 0){
            ll tmp = (base0[N - i - 1]) % mod;
            r = rbase0 + tmp;
        } else {
            ll tmp = (base1[N - i - 1]) % mod;
            r = rbase1 + mod - tmp;
        }
        r %= mod;
#if 0        
        rep(j, N){
            if (N - j - 1 == i){
                r += (A[N - j - 1]  ^ 1)* base;
            } else {
                r += A[N - j - 1] * base;
            }
            r %= mod;
            //fprintf(stderr, "j = %d, A[x] = %d, r = %d, base = %d\n", j, A[N - j - 1], r, base);
            (base *= 2) %= mod;
            
        }
#endif
        cout << f(r, 1) << endl;
    }       
    return 0;
 
}


Measured memory_bytes: 8404
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;

map<string, int> dp;
void solve() {
  int n;
  cin >> n;
  ll ret = 0;
  for(int i = 0; i < n; i++) {
    string ss;
    cin >> ss;
    sort(all(ss));
    ret += dp[ss]++;
  }
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 11264
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  startupcpp();
  ll N;
  cin>>N;
  vec v={105,135,165,189,195,201};
  cout<<upper_bound(all(v),N)-v.begin()<<endl;
  return 0;
}


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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll X, Y, A, B, C;

    cin >> X >> Y >> A >> B >> C;
    priority_queue<ll, vector<ll>, std::greater<ll>> p;
    priority_queue<ll, vector<ll>, std::greater<ll>> q;
    ll total = 0;
    REP(i,A) {
        ll v;
        cin >> v;
        p.push(v);
        total+=v;
        if( p.size() > X ){
            total-=p.top();
            p.pop();
        }
    }
    REP(i,B) {
        ll v;
        cin >> v;
        q.push(v);
        total += v;
        if( q.size() > Y ){
            total-=q.top();
            q.pop();
        }
    }

    REP(i,C) {
        ll v;
        cin >> v;
        if( p.top() < q.top() ){
            if( v <= p.top() ){
            }else{
                total -= p.top();
                p.pop();
                p.push(v);
                total += v;
            }
        }else{
            if( v <= q.top() ){
            }else{
                total -= q.top();
                q.pop();
                q.push(v);
                total += v;
            }
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 2420
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right



def solve():
    H, W = MI()
    dist = LLI(10)
    N = 10

    # dist = [[INF]*10 for _ in range(10)]
    # for i in range(N):
    #     dist[i][1] = C[i, 1]

    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    ans = 0
    for i in range(H):
        for r in LI():
            if r != -1:
                ans += dist[r][1]
    print(ans)




if __name__ == '__main__':
    solve()



Measured memory_bytes: 27076
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string col;
  cin >> N;
  for(int i;i<N;i++){
    cin >> col;
    if (col == "Y"){
      cout << "Four" << endl;
      break;
    }
    else if(i == N-1)
      cout << "Three" << endl;
  }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
	int h, w, d;
	cin >> h >> w >> d;

	vvi a(h, vi(w));
	rep(i, 0, h) rep(j, 0, w){
		 cin >> a[i][j];
		 a[i][j]--;
	}

	int n = h*w;
	vector<pii> pos(n);
	rep(i, 0, h) rep(j, 0, w){
		pos[a[i][j]] = {i, j};
	}

	vi cost(n);
	rep(i, 0, n){
		if(i-d >= 0){
			cost[i] = abs(pos[i-d].first-pos[i].first) + abs(pos[i-d].second-pos[i].second);
			cost[i] += cost[i-d];
		}
	}

	int q;
	cin >> q;
	while(q--){
		int l, r;
		cin >> l >> r;
		cout << cost[r-1]-cost[l-1] << endl;
	}

//	rep(i, 0, n) cout << i << " : " << cost[i] << endl;


	return 0;
}


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

void solve(string &str, int m, vector<int> h);

int main()
{
    while (1)
    {
        string str;
        cin >> str;
        if (str == "-") break;

        int m = 0;
        cin >> m;

        vector<int> h(m, 0);
        for (int i = 0; i < m; i++)
        {
            cin >> h[i];
        }
        // 参照渡しの場合，呼び出し時に&は要らない（プロトタイプ宣言と実装についていれば良い）
        solve(str, m, h);

        cout << str << endl;
    }

    return 0;
}

void solve(string &str, int m, vector<int> h)
{
    string res;
    for (int i = 0; i < m; i++)
    {
        rotate(str.begin(), str.begin() + h[i], str.end());
    }
    return;
}



Measured memory_bytes: 3056
#include <stdlib.h>     /* srand, rand */
#include <time.h>       /* time */
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
#include <iterator> 
using namespace std;

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);


#define PI 3.14159265

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

struct node{
	int x, y, z;
	mutable int w;
	node() {
		x = -1, y = -1, z = -1;
	}
	bool operator<(const node& nod) const{
		if (this->x == nod.x) {
			if (this->y == nod.y){
				return this->z < nod.z;
			}
			return this->y < nod.y;
		}
		return this->x < nod.x;
	}
};

int a[N];
bool vis[N];
int main() {
	clr(vis,false);
	ll n, k; cin>> n >>k;
	for (int i = 1; i <= n; i++) {
		cin>>a[i];
	}
	int id = 1;
	while(!vis[id] && k > 0){
		vis[id] = true;
		k--;
		id = a[id];
		//~ cout<<id<<"->";
	}
	if (k > 0) {
		ll cnt = 1;
		int init = id;
		id = a[id];
		while (init != id) {
			id = a[id];
			cnt++;
		}
		
		k = k % cnt;
		//~ cout<<"k:"<< k <<endl;
		while(k){
			k--;
			id = a[id];
		}
		
	}
	cout<<id<<endl;
	return 0;
}


Measured memory_bytes: 4600
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll A,B,C; cin>>A>>B>>C;
    bool kawa=false;
    if(A==B and A!=C) kawa=true;
    if(A==C and A!=B) kawa=true;
    if(B==C and A!=C) kawa=true;
    cout<< ( kawa ? "Yes" : "No" )<<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
//By Zank100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define din(t) long long t;cin>>t;
#define in(t) cin>>t;
ll mul(ll a, ll b)
{
    return(((a%mod)*(b%mod))%mod);
}
ll modexp(ll b, ll e){
	ll res = 1;
	for(; e; b = b * b % mod, e >>= 1) if(e & 1) res = res * b % mod;
	return res;
}
ll modinv(ll a){
    ll x=mod-2;
	return modexp(a,x);
}
ll power(ll x, ll y)
{
    ll temp;
    if(y == 0)return 1;
    temp = power(x, y / 2);
    if (y % 2 == 0)return temp*temp;
    else{
        if(y > 0)return x * temp * temp;
        else return (temp * temp) / x;
    }
}
ll cc(ll x,ll y){
    if(x-y>0)return 1;
    else if(x-y<0)return -1;
    else return 0;
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s;
	in(s);
	for(ll i=0;i<s.size();i++)if(s[i]=='?')s[i]='D';
    cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3688
#include <iostream>
#include <vector>

#define MAXNUM 100000
#define MAXVALUE 100000
int n;
int cnt;
int S[MAXNUM];
int L[MAXNUM/2 + 2];
int R[MAXNUM/2 + 2];

int partition(int *A, int p, int r){
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++) {
        if(A[j] <= x) {
            i++;
            std::swap(A[i], A[j]);
        }
    }
    std::swap(A[i+1], A[r]);
    return i+1;
}


void merge(int *A, int left, int mid, int right){
    int nl = mid - left;
    int nr = right - mid;
    for (int i = 0; i < nl; i++) {
        L[i] = A[left+i];
    }
    for (int i = 0; i < nr; i++) {
        R[i] = A[mid+i];
    }
    L[nl] = MAXVALUE;
    R[nr] = MAXVALUE;
    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
}


void mergesort(int *A, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
//         std::cout << "==========" << std::endl;
//         std::cout << mid << std::endl;
//         std::cout << "==========" << std::endl;
        mergesort(A, left, mid);
        mergesort(A, mid, right);
        merge(A, left, mid, right);
    }
}



int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> S[i];
    }
    int pq = partition(S, 0, n-1);
    for(int i = 0; i < n; i++) {
        if (i == pq) {
            std::cout << "[" << S[i] << "]";
        }
        else{
            std::cout << S[i];
        }
        if (i != n-1) {
            std::cout << " ";
        }
    }
    std::cout << std::endl;
}

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

int datas[105];

int main()
{
	int n;
	scanf("%d", &n);
	for(int a=0;a<n;a++)
	{
		cin>>datas[a];
	}
	sort(datas, datas+n);
	int alice=0, Bob=0;
	bool check=0;
	for(int a=n-1;a>=0;a--)
	{
		if(!check)
		{
			alice+=datas[a];
			check=1;
		}
		else
		{
			Bob+=datas[a];
			check=0;
		}
	}
	cout<<alice-Bob<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define fib_max 44

int answer_cal(int);
int fib[fib_max];

int main(){
  int n;

  scanf("%d" ,&n);
  printf("%d\n" ,answer_cal(n));

  return 0;
}

int answer_cal(int n){
  if(fib[n] > 0){
    return fib[n];
  }

  if(n <= 1){
    return 1;
  }else{
    return fib[n] = answer_cal(n-1) + answer_cal(n-2);
  }
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;

	int ans = 0;
	while (n) {
		if (to_string(n).size() & 1)
			ans++;
		n--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
base = 1000000007

x = [0] * (N+1)
x[0] = 1
ai = 0
if ai >= M or 1 != a[ai]:
    x[1] = x[0]
else:
    ai += 1
for i in range(2, (N+1)):
    if ai >= M or i != a[ai]:
        x[i] = (x[i-1] + x[i-2]) % base
    else:
        ai += 1
print(x[N])

Measured memory_bytes: 44124
#include<stdio.h>
 
int main(void){
  
  char str[4];
  int i,count;
  
  count = 0;
  
  fgets(str,sizeof str,stdin);
  
  for(i = 0;i <= 2;i++){
    
    if(str[i] == '7'){
      
      count += 1;
      
    }
    
  }
  
  if(count > 0){
    
    printf("Yes\n");
    
  }
  
  else{
    
    printf("No\n");
    
  }
  
  return 0;
  
}

Measured memory_bytes: 1532
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int x, a;
  cin >> x >> a;
  if (x < a) P(0);
  else P(10);

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k, x;
    cin >> k >> x;
    int Xmin = x - k + 1, Xmax = x + k - 1;
    for (int i = max(-1000000, Xmin); i < min(1000000, Xmax); i++) {
        cout << i << " ";
    }
    cout << min(1000000, Xmax) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
n = int(input())
edges = [[]for _ in range(n)]
for i in range(n):
    s = list(map(int, list(input().rstrip())))
    for j in range(n):
        if s[j]:
            edges[i].append(j)


def dfs(v, parent, d):
    visited[v] = 1
    depth[v] = d
    for v2 in edges[v]:
        if v2 == parent:
            continue
        if visited[v2]:
            d2 = depth[v2]
            n_cycle = d-d2+1
            if 0 < n_cycle:
                cycle.append(n_cycle)
            continue
        dfs(v2, v, d+1)


cycle = []
depth = [0]*n
visited = [0]*n
dfs(0, -1, 0)


def bfs(init_v):
    next_v = deque([init_v])
    INF = 10**18
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        v = next_v.popleft()
        for v2 in edges[v]:
            if dist[v2] <= dist[v]+1:
                continue
            dist[v2] = dist[v]+1
            next_v.append(v2)
    return dist


if all(c % 2 == 0 for c in cycle):
    ans = 0
    for i in range(n):
        dist = bfs(i)
        x = max(dist)
        if ans < x:
            ans = x
    print(ans+1)
else:
    print(-1)


Measured memory_bytes: 3956
#!/usr/bin/env python3
from sys import stdin


def solve(tc):
    s = stdin.readline().strip()
    k = int(stdin.readline().strip())

    n = len(s)
    li = [list() for i in range(26)]
    for i in range(n):
        li[ord(s[i])-ord('a')].append(i)
    
    p = 0
    while len(li[p])==0:
        p += 1
    
    ans = set()
    while len(ans)<k and p<26:
        for i in range(k):
            for j in range(len(li[p])):
                b = li[p][j]
                e = min(n, li[p][j] + i + 1)
                ans.add(s[b:e])
        p += 1
    lans = list(ans)
    lans.sort()
    print(lans[k-1])
    # print(lans[k-1])
    pass


LOCAL_TEST = not __debug__
if LOCAL_TEST:
    infile = __file__.split('.')[0] + "-test.in"
    stdin = open(infile, 'r')

tcs = (int(stdin.readline().strip()) if LOCAL_TEST else 1)
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Measured memory_bytes: 3316
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = InputNum();
            WriteLine(x > 1199 ? "ARC" : "ABC");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}



Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll n, d;
ll f(ll p) {
	ll s = 0;
	while (p > 0) {
		s += p % 10;
		p /= 10;
	}
	return s;
}

int main()
{
	ll i, j, c;
	cin >> n;
	printf("1\n");
	for (i = d = c = 1; c < n; i += d, c++) {
		if ((i + d) * f(i + d * 2) > (i + d * 2) * f(i + d)) {
			d *= 10;
		}
		printf("%lld\n", i + d);
	}
    return 0;
}


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

int main(void)
{
	int A, B;
	string S;
	cin >> A >> B;
	cin >> S;
	for (int i = 0; i < S.size(); i++){
		if (i == A && S[i] != '-'){
			cout << "No" << endl;
			return 0;
		}
		else if (i != A && S[i] < '0' || S[i] > '9'){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF pow(2,31)-1
#define B 300
using namespace std;

long long n,q,com,x,y;
vector<long long> dt;
vector<long long> backet;

void find(long long a,long long b){
	long long res=INF;
	for(long long i=a;i<b+1;){
		if(i%B==0 && i+B-1<=b){
			res=min(res,backet[i/B]);
			i+=B;
		}else{
			res=min(res,dt[i]);
			i++;
		}
	}
	cout<<res<<endl;
}

void update(long long i,long long x){
	dt[i]=x;
	long long res=INF;
	for(long long j=i-i%B;j<min(n,i-i%B+B);j++){
		res=min(res,dt[j]);
	}
	backet[i/B]=res;
}

int main(){
	cin>>n>>q;
	rep(i,n)dt.push_back(INF);
	rep(i,n/B+1)backet.push_back(INF);
	rep(i,q){
		cin>>com>>x>>y;
		if(com==0)update(x,y);
		else find(x,y);
	}
	return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<vector<char>> vecA(N,vector<char>(N));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cin >> vecA.at(i).at(j);
    }
  }
  
  vector<vector<char>> vecB(M,vector<char>(M));
  for(int k=0; k<M; k++){
    for(int l=0; l<M; l++){
      cin >> vecB.at(k).at(l);
    }
  }
  
  bool flag = false;
  
  for(int m=0; m<N-M+1; m++){
    for(int n=0; n<N-M+1; n++){
      int count = 0;
      if(vecA.at(m).at(n) == vecB.at(0).at(0)){
        for(int x=0; x<M; x++){
          for(int y=0; y<M; y++){
            if(vecA.at(m+x).at(n+y) == vecB.at(x).at(y)){
              count++;
            }
            if(count == M*M){
              flag = true;
            }
          }
        }
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
s=array(N)
N.times do|i|
    s[i]=gets.chomp
end
puts s.uniq.size

Measured memory_bytes: 34968
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll a[100002];

int main()
{
	int N;  cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	ll res1=0, res2=0,sum=0;
	for (int i = 1; i <= N; i++) {
		sum += a[i];
		if (i & 1) {
			if (sum >= 0) {
				res1 += abs(sum) + 1;
				sum = -1;
			}
		}else{
			if (sum <= 0) {
				res1 += abs(sum) + 1;
				sum = 1;
			}
		}
	}
	
	sum = 0;
	for (int i = 1; i <= N; i++) {
		sum += a[i];
		if (i & 1) {
			if (sum <= 0) {
				res2 += abs(sum) + 1;
				sum = 1;
			}
		}
		else {
			if (sum >= 0) {
				res2 += abs(sum) + 1;
				sum = -1;
			}
		}
	}
	cout << min(res1, res2) << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = Str;
		for (var i = 0; i < 3; i++) if (S[i] == S[i + 1]) { WriteLine("Bad"); return; }
		WriteLine("Good");
	}
}
static class Func
{
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	public static long GCD(long a, long b)
	{
		var n = (ulong)Math.Abs(a); var m = (ulong)Math.Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Math.Min(zm, zn);
	}
	public static long Inverse(long a, long mod)
	{
		if (a < 0) { a %= mod; if (a < 0) a += mod; }
		var t = SolveLinear(a, mod);
		return t.Item1 > 0 ? t.Item1 : t.Item1 + mod;
	}
	public static long Pow(long a, long b, long mod)
	{
		var p = 1L;
		var x = a;
		while (b > 0)
		{
			if ((b & 1) == 1) p = (p * x) % mod;
			b >>= 1;
			x = (x * x) % mod;
		}
		return p;
	}
	public static Tuple<long, long> SolveLinear(long n, long m)
	{
		if (n < 0) { var p = SolveLinear(-n, m); return p == null ? p : new Tuple<long, long>(-p.Item1, p.Item2); }
		if (m < 0) { var p = SolveLinear(n, -m); return p == null ? p : new Tuple<long, long>(p.Item1, -p.Item2); }
		if (n < m) { var p = SolveLinear(m, n); return p == null ? p : new Tuple<long, long>(p.Item2, p.Item1); }
		long a = 1, b = 0, c = 0, d = 1;
		while (m > 0)
		{
			var r = n % m;
			var q = n / m;
			n = m;
			m = r;
			var tmp = a;
			a = -a * q + b;
			b = tmp;
			tmp = c;
			c = -c * q + d;
			d = tmp;
		}
		return n != 1 ? null : new Tuple<long, long>(d, b);
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;
//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll n,k;
ll a[200010];
ll f[200010];
ll sum;

bool ok(ll line) {
    ll need[n];
    REP(i,n) {
        need[i] = line / f[i];
    }
    ll cnt = 0;
    for (int i = n - 1; i >= 0; i--) {
        cnt += max(a[i] - need[i], 0LL);
    }
    return cnt <= k;
}

void solve() {
    cin >> n >> k;
    REP(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    REP(i,n) cin >> f[i];
    sort(f,f+n);
    reverse(f,f+n);
    sort(a,a+n);
    ll mi = 0, ma = 1e13;
    while (mi < ma) {
        ll mid = (mi + ma) / 2;
        if (ok(mid)) {
            ma = mid;
        } else {
            mi = mid + 1;
        }
    }
    cout << ma << endl;
}

int main(int argc, char *argv[]){
    // /* Regular */
    // int case_num = 1;
    // if (argc > 1 && stoi(argv[1])) cin >> case_num;
    // REP(case_no, case_num) {
    //   cerr << endl << "case " << case_no + 1 << endl;
    //   solve();
    // }
    /* AOJ */
    solve();
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>

using namespace std;

int h, w;
vector<vector<int> > fi(20, vector<int>(20, 0));

int bfs(int a, int b, int c, int d){
  vector<vector<int> > dist(h, vector<int>(w, 0));
  vector<vector<int> > used(h, vector<int>(w, 0));
  queue<pair<int, int> > q;
  pair<int, int> now;

  q.push({a, b});
  int x, y;
  used[a][b] = 1;
  int ret = 0;
  while(!q.empty()){
    now = q.front();
    q.pop();
    y = now.first;
    x = now.second;
    for(int k = -1; k < 2; k++){
      for(int l = -1; l < 2; l++){
        if( (k && !l) || (!k && l)){
          if(y + k >= 0 && y + k < h && x + l >= 0 && x + l < w){
            if(!fi[y+k][x+l] && !used[y+k][x+l]){
              q.push({y+k, x+l});
              dist[y+k][x+l] = dist[y][x] + 1;
              ret = max(ret, dist[y+k][x+l]);
              used[y+k][x+l] = 1;
              // cout<< k << ' ' << l << ' ' << dist[y+k][x+l] << endl;
            }
          }
        }

      }
    }
  }
  return ret;
}

int main(){
  cin >> h >> w;
  char r;

  for(int i = 0; i < h ; i++){
    for(int j = 0; j < w; j++){
      cin >> r;
      if(r == '.'){
        fi[i][j] = 0;
      }
      else{
        fi[i][j] = 1;
      }
    }
  }

  int maxi = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      for(int k = 0; k < h; k++){
        for(int l = 0; l < w; l++){
          if(i == k && j == l) continue;
          if(fi[i][j]) continue;
          maxi = max(maxi, bfs(i, j, k, l));
        }
      }
    }
  }
  cout << maxi << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 1000000
int main(){
  int a[MAX + 1],b[MAX + 1];
  a[0] = b[0] = 0;
  for(int i = 1; i < MAX + 1; i++){
    a[i] = b[i] = i;
    for(int j = 1;  ; j++ ){
      int java = j * (j + 1) * (j + 2) / 6;
      if(i - java < 0) break;
      a[i] = min( a[i], a[i - java] + 1);
      if(java & 1) b[i] = min( b[i], b[i - java] + 1);
    }
  }
  int n;
  while(cin >> n, n){
    cout << a[n] << " " << b[n] << endl;
  }
}


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

int main() {

  int n;
  while( cin >> n, n ) {
    string way;
    int left=4, right=3, front=2, back=5, top=1, under=6;
    int sum = 0, temp;
    for(int i=0; i<n; i++) {
      cin >> way;
      if( way == "North" ) {
	temp = top;
	top = front;
	front = under;
	under = back;
	back = temp;
      }

      else if( way == "East" ) {
	temp = top;
	top = left;
	left = under;
	under = right;
	right = temp;
      }

      else if( way == "West" ) {
	temp = top;
	top = right;
	right = under;
	under = left;
	left = temp;
      }

      else if( way == "South" ) {
	temp = top;
	top = back;
	back = under;
	under = front;
	front = temp;
      }

      else if( way == "Right" ) {
	temp = front;
	front = right;
	right = back;
	back = left;
	left = temp;
      }

      else if( way == "Left" ) {
	temp = front;
	front = left;
	left = back;
	back = right;
	right = temp;
      }

      sum += top;
    }
  
    cout << sum+1 << endl;
  }
}

Measured memory_bytes: 1212
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    A.sort()
    filt = list(filter(lambda x: x >= sum(A)/(4*M), A))
    if len(filt) >= M:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, long long D, long long X, std::vector<long long> A){
  int ans=X;
  for (int i = 0; i < N; i++) {
    int l=0;
    while(A[i]*l+1 <= D){
      int x = A[i]*l+1;
      ans++;
      l++;
    }
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, D, X, std::move(A));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ll long long
#define CL(a,b) memset(a,b,sizeof a)
#define pb push_back
#define fi first
#define sc second
#define pi pair<int,int>
#define pii pair<int,pair<int,int>>
char s[21][21];
int x[401],vis[21][21];
int y[401];
int k,n,m;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
struct node
{
    int x,y,step;
    node(int _x=0,int _y=0,int _s=0)
    {
        x=_x;
        y=_y;
        step=_s;
    }
};
int bfs(int x1,int y1,int x2,int y2)
{
    queue<node>q;
    node st(x1,y1,0);
    vis[x1][y1]=1;
    q.push(st);
    while(!q.empty())
    {
        node t=q.front();
        q.pop();

        for(int i=0;i<4;i++)
        {
            int fx=t.x+dx[i];
            int fy=t.y+dy[i];
          //  cout<<fx<<' '<<fy<<'\n';
            if(fx>=1&&fx<=n&&fy>=1&&fy<=m&&s[fx][fy]=='.'&&!vis[fx][fy])
            {
                if(fx==x2&&fy==y2)
                {
                    return t.step+1;
                }
                vis[fx][fy]=1;
                q.push(node(fx,fy,t.step+1));

            }
        }
    }
}
int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        scanf("%s",s[i]+1);
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            if(s[i][j]=='.')
            {
                x[++k]=i;
                y[k]=j;
            }
    int ans=0;
    for(int i=1; i<=k; i++)
        for(int j=i+1; j<=k; j++)
        {
            CL(vis,0);
            ans=max(ans,bfs(x[i],y[i],x[j],y[j]));
        }
    printf("%d",ans);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>

using ll = long long;

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

    std::vector<int> x(N), y(N), h(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> x[i] >> y[i] >> h[i];
    }

    int X, Y, H;
    for (int i = 0; i < N; i++)
    {
        if (h[i] > 0)
        {
            X = x[i];
            Y = y[i];
            H = h[i];
        }
    }

    for (int cx = 0; cx <= 100; cx++)
    {
        for (int cy = 0; cy <= 100; cy++)
        {
            int high = H + std::abs(X - cx) + std::abs(Y - cy);

            bool flag = true;
            for (int i = 0; i < N; i++)
            {
                if (h[i] != std::max(0, high - std::abs(x[i] - cx) - std::abs(y[i] - cy)))
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                std::cout << cx << " " << cy << " " << high << std::endl;
            }
        }
    }
}

Measured memory_bytes: 256
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for i in range(N)]
V=10**3

DP_V=[float("inf")]*(V*N+1)
DP_V[0]=0
for i in range(N):
    for j in range(V*N,-1,-1):
        if j+WV[i][1]<=V*N:
            DP_V[j+WV[i][1]]=min(DP_V[j+WV[i][1]],DP_V[j]+WV[i][0])

for i in range(V*N,-1,-1):
    if DP_V[i]<=W:
        print(i)
        break

Measured memory_bytes: 94924
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 500005; 
  

struct Query 
{ 
    int l, r, idx; 
}; 
  

bool cmp(Query x, Query y) 
{ 
    int z;
    z=1;
    z++;
    z--;
    return x.r < y.r; 
} 
//sidhfsiodfjslddfjssddffs
//sskjdfhkljshfkjsdf
//sakjhaskljfhasdf/
//asakhdlkjsafh
//sadklashflkjfhkjsjdfhsdf
//aaskjhasakjjhkslfj  

void update(int idx, int val, int bit[], int n) 
{ 
    int j;
    j=2;
    j++;
    if(j)
    j++;
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  

int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
    int x=2;
    if(x)
    {
    	x++;
	}
    ///sdkjfhksdjf
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
     
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
         
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
        if(x==1)
        x++;
        
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
   x++;
    
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
}
    int main()
    {
    	int n,q,i,j;
    	cin>>n>>q;
    	int a[n];
    	for(i=0;i<n;i++)
    	{
    		cin>>a[i];
		}
		Query qu[q];
		for(i=0;i<q;i++)
		{
			qu[i].idx=i;
			
			cin>>qu[i].l>>qu[i].r;
			qu[i].l--;
			qu[i].r--;
		}
		sort(qu, qu+q, cmp); 
		answeringQueries(a, n, qu, q);
		
	}

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

int main() {
    int N, M, A;
    cin >> N >> M;
    priority_queue<int> pq;
    rep(i, N) {
        cin >> A;
        pq.push(A);
    }
    rep(i, M) {
        int X = pq.top();
        pq.pop();
        pq.push(X / 2);
    }
    long sum = 0;
    rep(i, N) {
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 892
import sys
A,B,C=map(int,input().split())
if A==B and B==C:
    if A%2==1:
        print(0)
        sys.exit()
    print(-1)
    sys.exit()
num=0
while A%2==0 and B%2==0 and C%2==0:
    num+=1
    A,B,C=(B+C)//2,(C+A)//2,(A+B)//2
print(num)

Measured memory_bytes: 38384
import java.util.Scanner;

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

        A -= 2 * B;
        A = Math.max(A, 0);
        System.out.println(A);
    }
}


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

#define S size()
#define EN end()
#define BE begin()
#define LEN length()

#define endl "\n"
#define cnt count
#define in insert
#define er erase
#define fi first
#define se second
#define ld double
#define ll long long

#define gcd __gcd
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define np next_permutation

#define si set<ll>
#define sc set<char>
#define mll map<ll,ll>
#define vi vector<ll>
#define vc vector<char>
#define pll pair<ll,ll>
#define vpi vector<pll>
#define msi multiset<ll>
#define msc multiset<char>
#define vvi vector<vector<ll> >

#define all(v) v.BE,v.EN
#define godv(v) sort(all(v))
#define god(ar,n) sort(ar,ar+n)
#define godvr(v) godv(v) ; reverse(all(v))
#define godr(ar,n) god(ar,n) ; reverse(ar,ar+n)

#define iter(s) for(auto it:s)
#define forl(i,n) for(ll i=0;i<n;i++)
#define fore(i,n) for(ll i=1;i<=n;i++)
#define fora(i,v) for(ll i=0;v[i];i++)
#define forn(i,n) for(ll i=n-1;i>=0;i--)
#define forls(i,l,r) for(ll i=l;i<r;i++)
#define forns(i,l,r) for(ll i=r-1;i>=l;i--)

#define pat ll n;cin>>n;
#define wq ll q;cin>>q;while(q--)
#define tak(s) string s;cin>>s;ll n=s.LEN;
#define nokay if(ok) cout<<"YES\n";else cout<<"NO\n";
#define pat1 ll n;cin>>n;ll ar[n];forl(i,n) cin>>ar[i];
#define pat2 ll n,k;cin>>n>>k;ll ar[n];forl(i,n) cin>>ar[i];

#define inf 1e18
#define mod1 1000000007
#define mod2 998244353
#define PI 3.1415926535897932384626433832
#define eness(x) __builtin_ctzll(x)//trailing 0s
#define nhigh(x) __builtin_popcountll(x)//number of high terms
//**********************************
void Fast();
ll mf(ll x,ll mod);
ll mi(ll x,ll mod);
ll C(ll n,ll r,ll mod);
ll bpow(ll a,ll b,ll mod);

void Fast(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}
ll mf(ll x,ll mod=mod1){
    if(x<2) return 1;
    return (x*mf(x-1))%mod;
}
ll mi(ll x,ll mod=mod1){
    return bpow(x,mod-2,mod);
}
ll C(ll x,ll y,ll mod=mod1){
    if(x<y) return 0;
    return (((mf(x)*mi(mf(y)))%mod)*mi(mf(x-y)))%mod;
}
ll bpow(ll x,ll y,ll mod){
    x%=mod;
    ll res=1;
    while(y>0){
        if(y&1){
            res=res*x%mod;
        }
        x=x*x%mod;
        y>>=1;
    }
    return res;
}
//**********************************

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    Fast();
    pat;
    ll x=0,ok=0;
    fore(i,n){
        x*=10;
        x+=7;
        x%=n;
        if(x==0){
            cout<<i;
            ok=1;
            break;
        }
    }
    if(!ok){
        cout<<-1;
    }
}


Measured memory_bytes: 3600