akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main() {
  int A, B, K; cin >> K >> A >> B;
  if(A / K != B / K || A % K == 0 || B % K == 0) {
    cout << "OK" << endl;
  } else cout << "NG" << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
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; }

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...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

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

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


long long N, M;
vector<long long> A;

long long solve() {
    priority_queue<long long> que;
    for (int i = 0; i < N; ++i) que.push(A[i]);
    for (int i = 0; i < M; ++i) {
        long long t = que.top();
        que.pop();
        que.push(t/2);
    }
    long long res = 0;
    while (!que.empty()) res += que.top(), que.pop();
    return res;
}

int main() {
    while (cin >> N >> M) {
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        cout << solve() << endl;
    }
}











Measured memory_bytes: 2168
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
#define NIL -1

int *T;
int n;
int main(){
	cin >> n;
	T = new int[2*(n+1)];
	for(int i = 1;i <= n;i++){
		cin >> T[i];
	}
	for(int i = 1;i <= n;i++){
		cout << "node " << i << ": key = " << T[i] << ", ";
		if(i/2 >= 1){
			cout << "parent key = " << T[i/2] << ", ";
		}
		if(2*i <= n){
			cout << "left key = " << T[2*i] << ", ";
		}
		if((2*i)+1 <= n){
			cout << "right key = " << T[(2*i)+1] << ", ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
int main()
{
   int n,l;
   cin>>n>>l;
   multiset<string>ms;
   for(int i=0;i<n;i++)
   {
       string s;
       cin>>s;
       ms.insert(s);
   }
   for(auto x:ms)
   cout<<x;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

int main() {
  //
  ll mod = 1000000007;
  string L;
  cin >> L;
  int len = L.size();
  vl base(len + 1), acc(len + 1, 0);
  vl arb(len + 1);
  base[0] = 1;
  base[1] = 2;
  arb[0] = 1;
  arb[1] = 3;
  for (int i = 2; i <= len; i++) {
    base[i] = (base[i - 1] * 2) % mod;
    arb[i] = (arb[i - 1] * 3) % mod;
  }
  ll ans = 0;
  int ones = 0;
  for (int x = 0; x < len; x++) {
    if (L[x] == '1') {
      ll add = (base[ones] * arb[len - 1 - x]) % mod;
      ans = (ans + add) % mod;
      ones++;
    }
  }
  ans = (ans + base[ones]) % mod;
  cout << ans << endl;
  return 0;
}


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

int dp[510][510];

//半開区間[0, r)が猫かどうか
bool rec(string s, int l, int r){
    
    if(dp[l][r] != -1) return dp[l][r];

    //空文字列ならok
    if(l == r){
        dp[l][r] = 1;
        return true;
    }
    //cout << l << " " << r << endl;
    if(s[l] != 'm'){
        dp[l][r] = 0;        
        return false;
    }

    if(s[r - 1] != 'w'){
        dp[l][r] = 0;
        return false;
    }

    l++;
    r--;
    //cout << l << r << endl;
    //eの添え字を見つける
    vector<int> idx;
    for(int i = l; i < r; i++){
        if(s[i] == 'e') idx.push_back(i);
    }

    if(idx.size() == 0){
        dp[l - 1][r + 1] = 0;
        return false;
    }

    //各eに対して頑張る
    bool ok = false;
    for(int i = 0; i < idx.size(); i++){
        bool flag1 = rec(s, l, idx[i]);
        bool flag2 = rec(s, idx[i] + 1, r);

        //cout << flag1 << " " << flag2 << endl;
        if(flag1 && flag2){
            ok = true;
            break;
        }
    }

    if(ok) dp[l - 1][r + 1] = 1;
    else dp[l - 1][r + 1] = 0;
    
    return ok;
}

int main(){

    memset(dp, -1, sizeof(dp));

    string s; cin >> s;
    int n = (int)s.size();
    if(rec(s, 0, n)) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	string st;
	cin>>st;
	for(int i=0; i<st.length()-1; i++){
		if(st[i]=='A' && st[i+1]=='C'){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	
	return 0;
}


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

int main(){
    long long int X, K, D;
    cin >> X >> K >> D;
    long long int first = X;
    long long int k = 0;
    //cout << X/D << endl;
    
        if(abs(X) >= D){
            if(X > 0){
                k = X/D;
                X %= D;
                if(k > K){
                    k = K;
                    X = first - D*K;
                    
                }
                
            }else
            {
                k = abs(X)/D;
                X = -(abs(X)%D);
                if(k > K){
                    k = K;
                    X = first + D*K;
                    
                }
            }
        
        }
            if((K - k)%2 == 1){
                if(X > 0){
                    X -= D;
                    
                }else if(X <= 0){
                    X += D;
                    
                }
            }
        
    

    cout << abs(X) << endl;
}


Measured memory_bytes: 3612
A = int(input())
B = int(input())
C = int(input())
X = int(input())
price = 0
ans = 0 

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            price = i * 500 + j * 100 + k * 50
            if price == X:
                ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define     SZ  50500
#define     LIM 2500005
#define     pii pair<int, int>
#define     pb  push_back
#define     ff  first
#define     ss  second


int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i, j, k;
    int n; cin>>n;
    int x;
    set<int> st;
    for (i = 0; i < n; i++)
    {
        cin>>x;
        st.insert(x);
    }
    int sz = st.size();

    if (sz % 2 == 0) cout<<(sz-1)<<"\n";
    else cout<<sz<<"\n";
    return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <cmath>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    float c=2*M_PI*n;
    printf("%.2f",c);
    
}



Measured memory_bytes: 3780
/*
    And I know I may end up failing too
*/




#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int>pii;

#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF          0x3f3f3f3f

struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);
        auto hash2 = hash<T2> {}(p.second);
        return hash1 ^ hash2;
    }
};



ll t;
ll dp[100005][103];
pll p[105];

ll solve(ll n,ll m)
{
    if(n<=0)return 0;
    if(m==0)return 0;
    ll b=0,c=0;
    if(n-p[m].first>=0)
    {
        b=p[m].second;
        if(dp[n-p[m].first][m-1]==-1)
        {
            dp[n-p[m].first][m-1]=solve(n-p[m].first,m-1);
        }
        c=dp[n-p[m].first][m-1];
    }

    if(dp[n][m-1]==-1)dp[n][m-1]=solve(n,m-1);
    return max(dp[n][m-1],b+c);
}

int main()
{
    fast;
    ll a,b,c,d,e,f,g,i,j;
    ll n,k;
    memset(dp,-1,sizeof(dp));
    cin>>n>>a;
    for(i=1; i<=n; i++)
    {
        cin>>b>>c;
        p[i]={b,c};
    }
    cout<<solve(a,n)<<endl;
}


Measured memory_bytes: 80768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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 mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> A)
{
    ll minus = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] < 0)
        {
            minus++;
        }
    }
    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += abs(A[i]);
    }
    if (minus % 2 == 0)
    {
        cout << ans << endl;
    }
    else
    {
        ll minimum = LLONG_MAX;
        for (int i = 0; i < N; i++)
        {
            minimum = min(minimum, abs(A[i]));
        }
        cout << ans - minimum * 2 << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_H = 1000, MAX_W = 1000;
int h,w;
string grid[MAX_H];
bool use[MAX_H][MAX_W];
int d[MAX_H][MAX_W];
int dx[4] = {-1,0,1,0};
int dy[4] =  {0,-1,0,1};

bool is_ok(int i, int j) {
  return 0 <= i && i < h && 0 <= j && j < w;
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> h >> w;
  forn(i,h) cin >> grid[i];

  queue<pii> q;

  forn(i,h) forn(j,w)
    if (grid[i][j] == '#') {
      use[i][j] = true;
      d[i][j] = 0;
      q.push(mp(i,j));
    }

  int max_d = 0;
  while (!q.empty()) {
    pii p = q.front(); q.pop();
    forn(i,4) {
      int x = p.fst+dx[i], y = p.snd+dy[i];
      if (is_ok(x,y) && !use[x][y] && grid[x][y] == '.') {
        use[x][y] = true;
        d[x][y] = d[p.fst][p.snd] + 1;
        chmax(max_d, d[x][y]);
        q.push(mp(x,y));
      }
    }
  }

  cout << max_d << "\n";

  return 0;
}


Measured memory_bytes: 14352
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    if(S.length() == 2) {
        cout << S << endl;
        return 0;
    }
    reverse(S.begin(), S.end());
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
#define N 100010
ll dp[N],a[N];
int main(){
	fast;
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	dp[1]=0;dp[2]=abs(a[1]-a[2]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}cout<<dp[n]<<endl;return 0;
}/*『你强归你强，Siyuan比你强』*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N), B(N-1);
    REP(i,N-1) cin >> B[i];
    A[0] = B[0];
    A[N-1] = B[N-2];
    ll ans = A[0] + A[N-1];
    for(int i=1;i<N-1;i++){
        A[i] = min(B[i-1],B[i]);
        ans += A[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut items = vec![];
    for _ in 0..n {
        let v = read_vec::<usize>();
        let (v, w) = (v[0] as i64, v[1]);
        items.push((w, v));
    }
    let q = read::<usize>();
    let mut queries = vec![];
    for _ in 0..q {
        let v = read_vec::<usize>();
        let (v, l) = (v[0] - 1, v[1]);
        queries.push((v, l));
    }
    let l_max = queries.iter().map(|&x| x.1).max().unwrap();
    let threshold = 1023;
    // let threshold = 7;
    let n_dp_max = min(n, threshold);
    let mut dp = vec![vec![-std::i64::MAX; l_max + 1]; n_dp_max];
    dp[0][0] = 0;
    if items[0].0 <= l_max {
        dp[0][items[0].0] = items[0].1;
    }
    for i in 1..n_dp_max {
        let parent = (i - 1) / 2;
        for prev in (0..l_max + 1).rev() {
            if dp[parent][prev] == -std::i64::MAX {
                continue;
            }
            if prev + items[i].0 > l_max {
                continue;
            }
            dp[i][prev + items[i].0] = max(dp[i][prev + items[i].0], dp[parent][prev] + items[i].1);
        }
        for prev in (0..l_max + 1).rev() {
            if dp[parent][prev] == -std::i64::MAX {
                continue;
            }
            dp[i][prev] = max(dp[i][prev], dp[parent][prev]);
        }
    }

    // accum w
    for i in 0..n_dp_max {
        let mut cur = dp[i][0];
        for li in 1..l_max + 1 {
            dp[i][li] = max(dp[i][li], cur);
            cur = dp[i][li];
        }
    }

    for (v, l) in queries {
        let mut cur = v;
        let mut members = vec![];
        while cur >= threshold {
            members.push(cur);
            cur = (cur - 1) / 2;
        }
        let mut ans = 0;
        for state in 0..1 << members.len() {
            let mut current_weight = 0;
            let mut current_value = 0;
            for i in 0..members.len() {
                if (state >> i) & 1 == 1 {
                    current_weight += items[members[i]].0;
                    current_value += items[members[i]].1;
                }
            }

            if current_weight > l {
                continue;
            }
            ans = max(ans, current_value + dp[cur][l - current_weight]);
        }
        println!("{}", ans);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 810472
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


# inputna
s = input()
d = {"a":0, "b":0, "c": 0}
for c in s:
    d[c] += 1
if max(d.values()) - min(d.values())<=1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 73212
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
int a,b,k;
cin>>a>>b>>k;
int d;
if(a>b)
    d=b;
else
    d=a;
for(int i=d;i>=1;i--)
{
    if(a%i==0 && b%i==0)
    {
        k--;
    }
    if(k==0)
    {
        cout<<i<<endl;
        return 0;
    }
}
    return 0;
}


Measured memory_bytes: 256
N, A = map(int, input().split())

x = list(map(int, input().split()))

maxint = 50 * N

dp = [[[0] * (maxint + 1) for _ in range(N + 1)] for _ in range(N + 1)]

dp[0][0][0] = 1

for xi, xe in enumerate(x, 1):
    for j in range(xi+1):
        for k in range(maxint + 1):
            dp[xi][j][k] = dp[xi - 1][j][k]
            
            if j >= 0 and k >= xe:
                dp[xi][j][k] += dp[xi - 1][j - 1][k - xe]
                

res = 0

for i in range(1, N+1):
    res += dp[N][i][i * A]

print(res)

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

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

	string s; cin >> s;
	int queries; cin >> queries;

	bool is_reversed{ false };
	string extra[2]{ "", "" };
	do
	{
		char op; cin >> op;

		if (op == '1') { is_reversed = !is_reversed; }
		else
		{
			cin >> op;
			char c; cin >> c;

			bool beginning{ op == '1' };
			auto& extra_str{ beginning ? extra[is_reversed] : extra[!is_reversed] };

			if (is_reversed == beginning) { extra_str += c; }
			else { extra_str.insert(extra_str.begin(), c); }
		}

	} while (--queries > 0);

	if (is_reversed)
	{
		reverse(s.begin(), s.end());
		reverse(extra[0].begin(), extra[0].end());
		reverse(extra[1].begin(), extra[1].end());
	}

	cout << extra[is_reversed] << s << extra[!is_reversed] <<  '\n';
}

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

using namespace std;

char S[101010], T[101010];
int X[101010], Y[101010];
int n;

int main()
{
	int q, i, a, b, c, d;
	
	scanf("%s%s", S + 1, T + 1);
	
	for(i=1; S[i]; i++){
		X[i] = X[i - 1] + 1 + (S[i] == 'B');
	}
	
	for(i=1; T[i]; i++){
		Y[i] = Y[i - 1] + 1 + (T[i] == 'B');
	}
	
	scanf("%d", &q);
	
	for(; q--; ){
		scanf("%d%d%d%d", &a, &b, &c, &d);
		printf("%s\n", (X[b] - X[a - 1]) % 3 == (Y[d] - Y[c - 1]) % 3? "YES" : "NO");
	}
	
	return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  //19:51:38~
  int n, a, b; cin >> n >> a >> b;
  if((b-a) % 2 == 1) cout << "Borys" << endl;
  else cout << "Alice" << endl;
}


Measured memory_bytes: 256
x,y = map(int, input().split())

a = [4,6,9,11]
b = [1,3,5,7,8,10,12]


if x==2 or y== 2:
    print('No')
elif x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
else:
    print('No')

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, A[220000], a[220000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        a[i] = A[i];
    }
    sort(a, a + N);
    reverse(a, a + N);
    if (a[0] == a[1]) {
        for (int i = 0; i < N; i++)cout << a[0] << endl;
    } else {
        for (int i = 0; i < N; i++) {
            if (A[i] == a[0])cout << a[1] << endl;
            else cout << a[0] << endl;
        }
    }
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    sort(l.begin(), l.end());

    int res = 0;
    for (int i = 0; i < n - 2; ++i) {
        for (int j = i+1; j < n - 1; ++j) {
            for (int k = j+1; k < n; ++k) {
                if (l[i] != l[j] && l[j] != l[k]){
                    if (l[i] + l[j] > l[k]) res++;
                }
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if (S.equals("Sunny")) System.out.println("Cloudy");
        if (S.equals("Cloudy")) System.out.println("Rainy");
        if (S.equals("Rainy")) System.out.println("Sunny");
    }
}


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

int main() {
    int N,A,B; cin >> N >> A >> B;
    int ans=0;
    rep(i,N+1){
        string S; S=to_string(i);
        int a=0;
        rep(i,S.size()){
            a+=S[i]-'0';
        }
        if(a>=A && a<=B)ans+=i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstdio>
using namespace std;

#define int long long
#define INF 1e18

signed main() {
    string s; cin >> s;
    int ints = stoi(s);
    int sn = 0;

    for(int i = 0; i < s.size(); i++) {
        sn += s[i] - '0';
    }

    if(ints % sn == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n,m,i,j;
    cin >> n >> m;
    int a[n][m],b[m],c[n];
    for (i=0;i<n;i++) {
        for (j=0;j<m;j++) cin >> a[i][j];
    }
    for (j=0;j<m;j++) cin >> b[j];
    for (i=0;i<n;i++) {
        c[i] = 0;
        for (j=0;j<m;j++) {
            c[i] += a[i][j] * b[j];
        }
        cout << c[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3140
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>

using namespace std;

int main()
{
    int n; cin >> n;
    int A[n]; for(int i=0;i<n;++i) cin >> A[i];
    int q; cin >> q;
    int m[q]; for(int j=0;j<q;++j) cin >> m[j];
    bool dp[30][3000];
    memset(dp,false,sizeof(dp));
    dp[0][0]=true;

    for(int i=0;i<n;++i)
    {
        for(int j=0;j<=2000;++j)
        {
            dp[i+1][j] |= dp[i][j];
            if(j >= A[i]) dp[i+1][j] |= dp[i][j-A[i]];
        }
    }
    for(int k=0;k<q;++k)
    {
        if(dp[n][m[k]]) cout << "yes"<<endl;
        else cout << "no"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    if(!n){
        cout << 0 << endl;
        return 0;
    }
    vector<char> ans;
    while(n){
        ans.push_back('0' + abs(n%2));
        if(n%2) n--;
        n /= -2;
    }
    for(int i = ans.size()-1; i >= 0; i--) cout << ans[i];
    cout << endl;
	return 0;
    
}


Measured memory_bytes: 256
n, k = map(int, input().split())
d = set(map(int, input().split()))

while True:
    str_n = str(n)
    hantei = 1
    for i in range(len(str_n)):
        if int(str_n[i]) in d: hantei = 0
    if hantei == 1: break
    n += 1

print(n)

Measured memory_bytes: 2940
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
    };

    // n の約数を列挙する
    let mut d = vec![];
    for i in 1.. {
        if i * i > m {
            break;
        }
        if m % i == 0 {
            d.push(i);
            if i != m / i {
                d.push(m / i);
            }
        }
    }

    let mut ans = 1;
    for &d_i in d.iter() {
        if m / d_i >= n {
            ans = std::cmp::max(ans, d_i);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2156
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.Iterator;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int N = NM[0];
		int K = NM[1];
		double p = 0;
		for(int n=1;n<=N;n++) {
			int cnt = 0;
			for(int i=n;i<K;i*=2) {
				cnt++;
			}
			p+=Math.pow(0.5,cnt)/N;
		}
		print(String.format("%.11f",p));
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 22356
N = int(input())
ans = [0]*4
for i in range(N):
    s = input()
    if s == "AC":
        ans[0] += 1
    elif s == "WA":
        ans[1] += 1
    elif s == "TLE":
        ans[2] += 1
    elif s == "RE":
        ans[3] += 1
print("AC x "+ str(ans[0]),"WA x "+ str(ans[1]),"TLE x "+ str(ans[2]),"RE x "+ str(ans[3]),sep = "\n" )

Measured memory_bytes: 9204
N = int(input())
X = list(map(int,input().split()))
mod = 10**9 + 7

def euclid(a:int,b:int)->(int,int):
    #return x,y s.t ax + by = gcd(a,b)
    #a > b >= 0
    if b == 0:
        return 1,0
    x,y = euclid(b,a%b)
    return y,x - y*(a // b)

def inverse(a:int,mod:int)->int:
    #gcd(p,b) == 1
    if mod > a:
        n,x = euclid(mod,a)
    else:
        x,n = euclid(a,mod)
    return x

def devide_mod(a:int,b:int,mod:int)->int:
    #a // b
    x = inverse(b,mod)
    return  (a*x)%mod


def main():
    ans = 0
    fraq = [1]*(N)
    S = [0]*(N+1)
    for i in range(1,N):
        fraq[i] = (fraq[ i - 1 ]*i)%mod
    
    for i in range(1,N + 1):
        S[ i ] = (S[ i - 1 ] + devide_mod(fraq[ N - 1 ], i ,mod))%mod

    for i in range(N - 1):
        ans = (ans + (X[ i + 1 ] - X[ i ])*S[ i + 1 ])%mod
    print(ans)
    return

if __name__ == "__main__":
    main()

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

int main() {
	int n, m;
  
  cin >> n >> m;
  
  for(int i = 0; i < m; i++) {
  int tmp;
    cin >> tmp;
    n -= tmp;
  }
  
  if(n >= 0) cout << n;
  else
    cout << "-1";

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N=2100;
bitset <N*N> dp;
int n,a[N],sum;
int main()
{
	cin >> n;
	for (int i=1;i<=n;i++) 
    {
        cin >> a[i];
    }
	sort(a+1,a+1+n);
	for (int i=1;i<=n;i++) sum+=a[i];
	dp[0]=1;
	for (int i=1;i<=n;i++) dp|=(dp<<a[i]);
	for (int i=(sum+1)/2;i<=sum;i++)
	{
		if (dp[i]==1)
		{
			cout << i;
			return 0;
		}
	}
}

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


mod = 10**9+7
N, K = map(int, input().split())

fact = [1]
for i in range(1, N+1):
    fact.append(fact[i-1] * i % mod)
inv = [0] * (N+1)
inv[N] = pow(fact[N], mod-2, mod)
for i in range(N, 0, -1):
    inv[i-1] = inv[i] * i % mod
def nCr(n, r):
    if n == 0 and r == 0:
        return 1
    if r < 0 or n < r:
        return 0
    return fact[n] * inv[r] * inv[n-r] % mod


def main():
    if K == 1:
        print(0)
        return

    A = list(map(int, input().split()))

    A.sort()
    mi = 0
    for i in range(N):
        m = nCr(N-i-1, K-1)
        mi += A[i] * m
        mi %= mod

    A.reverse()
    ma = 0
    for i in range(N):
        m = nCr(N-i-1, K-1)
        ma += A[i] * m
        ma %= mod

    ans = (ma - mi) % mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22544
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int h,w,a[555][555],z[500*500+7],x[500*500+7],c[500*500+7],v[500*500+7];
signed main(){
  cin>>h>>w;
  r(i,h)r(j,w)cin>>a[i][j],a[i][j]%=2;
  int cnt=0;
  r(i,h)r(j,w-1){
    if(a[i][j]){
      z[cnt]=i;
      x[cnt]=j;
      c[cnt]=i;
      v[cnt]=j+1;
      a[i][j]=0;
      a[i][j+1]=(a[i][j+1]+1)%2;
      cnt++;
    }
  }
  r(i,h-1){
    int j=w-1;
    if(a[i][j]){
      z[cnt]=i;
      x[cnt]=j;
      c[cnt]=i+1;
      v[cnt]=j;
      a[i][j]=0;
      a[i+1][j]=(a[i+1][j]+1)%2;
      cnt++;
    }
  }
  cout<<cnt<<endl;
  r(i,cnt){
    cout<<z[i]+1<<' '<<x[i]+1<<' '<<c[i]+1<<' '<<v[i]+1<<endl;
  }
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)
        res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
       
        ll n,m;cin>>m>>n;ll sum=0,num;
        for(ll i=0;i<n;i++)cin>>num,sum+=num;
        if(sum<=m){
            cout<<m-sum;
        }
        else
        cout<<"-1";
}


Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
int a,b,c,d;
long int a1,a2;
scanf("%d %d %d %d",&a,&b,&c,&d);
a1=a*b;
a2=c*d;
if(a1>a2)
printf("%ld",a1);
else
printf("%ld",a2);
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <cmath>
#include <algorithm>
#include <climits>
using namespace std;
int main(){
  int arr[3];
  for(int i=0; i<3; i++){
    cin >> arr[i];
  }
  int compare=INT_MIN;
  int index;
  for(int i=0; i<3; i++){
    for(int j=i; j<3; j++){
      if(arr[j]>compare){
        compare=arr[j];
        index=j;
      }
    }
    if(index!=i){
      swap(arr[i], arr[index]);
    }
    compare=INT_MIN;
  }
  int sum=0;
  for(int i=0; i<2; i++){
    sum+=fabs(arr[i]-arr[i+1]);
  }
  cout << sum << "\n";
  
}

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

 using namespace std;
 typedef long long ll;

 int main() {
   int N, P;

   cin >> N >> P;
   vector<int> A(N);
   int odd = 0;
   for (int i = 0; i < N; i++) {
     cin >> A.at(i);
     if (A.at(i) % 2 == 1) odd++;
   }

   if (odd == 0) {
     if (P == 1) cout << 0 << endl;
     else cout << (ll)pow(2, N);
   }

   else cout << (ll)pow(2, N - 1) << endl;
}


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

int main() {
	string str;
	int i;
	int count1 = 0, count0 = 0;
	cin >> str;
	for (i = 0; i<str.size(); i++) {
		if (str[i] == '1') {
			count1++;
		}
		else {
			count0++;
		}
	}
	cout << 2*min(count1, count0) << endl;
	return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
sum_gap = 0

for i in range(len(A)-1):
    if A[i] >= A[i+1]:
        gap = 0
        gap = A[i]-A[i+1]
        A[i+1] = A[i+1] + gap
        sum_gap += gap
print(sum_gap)

Measured memory_bytes: 32212
package main

import "fmt"

func main() {
	var A, B, C, X, cnt int
	fmt.Scan(&A, &B, &C, &X)

	for a := 0; a <= A; a++ {
		for b := 0; b <= B; b++ {
			for c := 0; c <= C; c++ {
				if 500*a+100*b+50*c == X {
					cnt++
				}
			}
		}
	}
	fmt.Println(cnt)
}


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

using namespace std;

const int MAX = 1e5 + 7;
vector<int> g[MAX];
int in_deg[MAX];
int dist[MAX];
bool visited[MAX];

void dfs(int u) {
  visited[u] = true;
  for (int v : g[u]) {
    dist[v] = max(dist[v], dist[u] + 1);
    --in_deg[v];
    if (in_deg[v] == 0) {
      dfs(v);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    ++in_deg[y];
  }

  for (int i = 1; i <= n; i++) {
    if (!visited[i] && in_deg[i] == 0) {
      dfs(i);
    }
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dist[i]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 14636
from functools import reduce

# 入力
N = int(input())
P = [int(input()) for _ in range(N)]

INF = 10**15

# Pの逆写像
Q = {p: i for i, p in enumerate(P, 1)}

# j以上の整数を末尾に移動する場合に、先頭に移動すべき整数の個数を求める
ans = reduce(
    lambda acc, j: (
        min(
            acc[0],
            acc[1] + N - j + 1
        ),
        acc[1] if j > N or Q[j - 1] < Q[j] else
        j - 1
    ),
    range(2, N + 2),
    (INF, 0)
)[0] if N >= 2 else 0

# 出力
print(ans)


Measured memory_bytes: 35468
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define sz size()
#define pi pair <int, int>
#define pii pair <pi, pi>
#define vi vector <int>
#define int long long
int n;
pair <pi, int> g[201];
vector <int> yy;
int ans;

bool s(pair <pi, int> a, pair <pi, int> b){
     return a.x.x<b.x.x;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>g[i].x.x>>g[i].x.y;
        g[i].y=1;
    }
    for(int i=1; i<=n; i++){
        cin>>g[i+n].x.x>>g[i+n].x.y;
        g[i+n].y=2;
    }
    sort(g+1, g+2*n+1, s);
    for(int i=1; i<=2*n; i++){
          //  cout<<g[i].y;
        if(g[i].y==1) yy.pb(g[i].x.y);
        else if(g[i].y==2){
            int j=-1, mx=-1;
            for(int k=0; k<yy.sz; k++){
                if(mx<yy[k] && g[i].x.y>yy[k]){
                    j=k;
                    mx=yy[k];
                }
            }
            if(j!=-1){
                yy[j]=-1;
                ans++;
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,l; cin >> n >> l;
  int sum = (n *(2 *l+n-1))/2;
  int min = 99999;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int a = sum - (l + i); 
   // cout << sum << " " << a << endl;
    if(min > abs(sum - a)){
      min = abs(sum - a);
      ans = a;
    }
  }
  cout << ans;
  
}


Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main()
{
    int w,a,b;
    cin>>w>>a>>b;
    if((b>=a&&b<=a+w)||(b+w>=a&&b+w<=a+w)){
        cout<<"0";
        return 0;
    }
    cout<<min(abs(b-(a+w)),abs((b+w)-a));
}

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

int main(){
    int n;
    int m;
    int r;
    int l;
    int lmax = 0;
    int rmin = 1000000;
    cin >> n >> m ;

    for(int i=0;i<m;i++){
        cin >> l >> r;
        if(l>lmax){
            lmax = l;
        }
        if(r<rmin){
            rmin = r;
        }

    }
    if((rmin - lmax + 1) > 0){
         cout << rmin - lmax + 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
    
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub

		BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Long> list = new ArrayList<Long>();
		long res = 0;
		long sum = 0;
		int n = Integer.parseInt(bi.readLine());
		String st = bi.readLine();
		long MOD = 1000000007;
		
		StringTokenizer str = new StringTokenizer(st, " ");
		
		for(int i = 0; i < n; i++) {
			
			long in = Long.parseLong(str.nextToken());
			res = (res + (sum * in) % MOD) % MOD;
			sum = (sum + in) % MOD;
			
		}
		
		System.out.println(res);		
		
	}

}


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

int main(){
    string s;
    cin >> s;
    for(int i = 0;i < s.length(); i++){
        if(i%2 == 0){
            if(s.at(i) == 'L'){
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s.at(i) == 'R'){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int x,y,i,cnt,z;
cnt=0;
scanf("%d %d",&x,&y);
for(i=1;i<x;i++){
	if(i*y%x==0){
		cnt++;
	}
}
z=x+y-cnt;
printf("%d\n",z);
return 0;
}



Measured memory_bytes: 2760
<?php
while ( ! feof(STDIN) ) {
	$line[] = trim(fgets(STDIN));
}
$N = $line[0];
for($i = 0; $i < $N; $i++){
	$txy[] = explode(" ", $line[$i + 1]);
}
$t = 0;
$x = 0;
$y = 0;
$judge = 0;
for($i = 0; $i < $N; $i++){
	if((($txy[$i][0] - $t) % 2) == ((abs($txy[$i][1] - $x) + abs($txy[$i][2] - $y)) % 2) && ($txy[$i][0] - $t) >= (abs($txy[$i][1] - $x) + abs($txy[$i][2] - $y))){
		$judge = 0;
	}else{
		$judge = 1;
		break;
	}
	$t = $txy[$i][0];
	$x = $txy[$i][1];
	$y = $txy[$i][2];
}
if($judge == 0){
	printf("Yes");
}elseif($judge == 1){
	printf("No");
}
?>

Measured memory_bytes: 102516
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

A, B, C, D = list(map(int, input().split()))
NC = B // C - A // C
if A % C == 0:
  NC += 1
ND = B // D - A // D
if A % D == 0:
  ND += 1
LCM = lcm(C, D)
NCA = B // LCM - A // LCM
if A % LCM == 0:
  NCA += 1
TOTAL = B - A + 1
NOTN = NC+ND-NCA
print (TOTAL - NOTN)

Measured memory_bytes: 5240
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    ll h;
    int i=0;
    cin>>h;
    ll total=0;
    while(1)
    {        
        i++;
        if(pow(2,i)>h)break;
    }
    i--;
    ll ans=0;
    for(ll j=0;j<=i;j++)
    {
        ans+=(ll)(pow(2,i)/pow(2,j));
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
# def find(x):
#     alph=["z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#     return alph[x]
# n=int(input())
# ans=[]
# while(n>0):
#     ans.append(n%26)
#     n=n//26
# a=""
# for i in ans:
#     a+=find(i)
# print(a)
def divmod_excel(n):
    a, b = divmod(n, 26)
    if b == 0:
        return a - 1, b + 26
    return a, b
import string
def to_excel(num):
    chars = []
    while num > 0:
        # print(chars)
        num, d = divmod_excel(num)
        chars.append(string.ascii_lowercase[d - 1])
    return ''.join(reversed(chars))
n=int(input())
print(to_excel(n))

Measured memory_bytes: 9964
#include <bits/stdc++.h>
using namespace std;
int main(){
long long A[3],K;
for(int i=0;i<3;i++){
    cin>>A[i];
}
cin>>K;
sort(A,A+3);
for(int i=0;i<K;i++){
    A[2]+=A[2];
}
cout << fixed << setprecision(0) <<A[2]+A[1]+A[0];


return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    string s, t;
    i32 n,k;
    cin >> n >> k;
    vi p(n); rep(i,n) cin >> p[i];

    sort(all(p));
    i64 ans = 0;
    rep(i, k) {
        ans += p[i];
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;

int main(){
    LL x,y;
    cin >> x >> y;
    if(x%y==0){
        puts("-1");
        return 0;
    }
    LL i=1;
    while(1){
        LL k=x*i;
        if(k%y!=0){
            cout << k << endl;
            return 0;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 256