akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int N = 100005;
int st[N];
int n, m;

void init() {
    scanf(II,&n,&m);
}

int pe[N];
void solve() {
    int a =0;
    rep (i,m) {
        int p; scanf("%d",&p); string s; cin >> s;
        if (s == "WA") {
            if (st[p] != 2) {
                st[p] = 1;
                pe[p]++;
            }
        }else {
            if (st[p] != 2) a++;
            st[p] = 2;
        }
    }
    int pee =0 ; repa (i,n) if (st[i] == 2) pee+=pe[i];
    printf("%d %d\n", a, pee);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


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

v = []
p = []
count = 0
m = 0
def rec(l, n):
	global count
	if len(l) == n:
		c = 0
		st = set()
		for i in range(n):
			if l[i] == 1:
				st.add(i + 1)
		for k, sw in enumerate(v):
			# print(st)
			if len(sw.intersection(st)) % 2 != p[k]:
				return
		# print("c: {}".format(c))
		count += 1
		# print(l)
		return
	l.append(0)
	rec(list(l), n)
	l.pop()
	l.append(1)
	rec(list(l), n)

def main():
	global v
	global p
	global m
	n, m = map(int, input().strip().split())
	for i in range(m):
		tmp = list(map(int, input().strip().split()))
		v.append(set(tmp[1:]))
	p = list(map(int, input().strip().split()))
	rec([], n)
	print(count)

if __name__ == '__main__':
	main()


Measured memory_bytes: 43368
n = int(input())
ab = []
for i in range(n):
    ai, bi = map(int,input().split())
    abi = [ai,bi]
    ab.append(abi)
sorted_ab = sorted(ab,key=lambda x : x[1])

fin = 0
for j in range(n):
    fin += sorted_ab[j][0]
    if fin > sorted_ab[j][1]:
        print("No")
        quit()
print("Yes")

Measured memory_bytes: 42420
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll h, w;
  cin >> h >> w;
  
  vector<vector<ll>> a(h, vector<ll>(w));
  for (ll i = 0; i < h; i++){
    for (ll j = 0; j < w; j++){
      cin >> a[i][j];
    }
  }

  vector<string> ss(0);
  deque<string> t;

  ll b = -1;
  for (ll i = 0; i < h; i++){
    if (i % 2 == 0){
      for (ll j = 0; j < w; j++){
        if (b == -1 && a[i][j] % 2 == 1){
          b = 1;
        }
        else if (b == 0 && a[i][j] % 2 == 1){
          b = 1;
        }
        else if (b == 1 && a[i][j] % 2 == 1){
          while (!t.empty()){
            ss.emplace_back(t.back());
            t.pop_back();
          }
          b = 0;
        }

        if (b == 1 && j != w - 1){
          t.push_front(to_string(i + 1) + " " + to_string(j + 1) + " " + to_string(i + 1) + " " + to_string(j + 2));
        }
      }
      if (b == 1){
        t.push_front(to_string(i + 1) + " " + to_string(w) + " " + to_string(i + 2) + " " + to_string(w));
      }
    }
    else {
      for (ll j = w-1; j >= 0; j--){
        if (b == -1 && a[i][j] % 2 == 1){
          b = 1;
        }
        else if (b == 0 && a[i][j] % 2 == 1){
          b = 1;
        }
        else if (b == 1 && a[i][j] % 2 == 1){
          while (!t.empty()){
            ss.emplace_back(t.back());
            t.pop_back();
          }
          b = 0;
        }

        if (b == 1 && j != 0){
          t.push_front(to_string(i + 1) + " " + to_string(j + 1) + " " + to_string(i + 1) + " " + to_string(j));
        }
      }
      if (b == 1){
        t.push_front(to_string(i + 1) + " " + to_string(1) + " " + to_string(i + 2) + " " + to_string(1));
      }
    }
  }

  cout << ss.size() << endl;
  for (auto s : ss){
    cout << s << endl;
  }

  return 0;
}


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

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

int L[22],L2[22],n,i,j,k,x;
ll ans;

int main(){
    cin >> n;
    for(i=1;i<=n;i++){
        cin >> x;
        j = 0;
        for(k=0;k<20;k++){
            if(x & (1 << k)){
                L2[k] = L[k];
                L[k] = i;
            }
            j = max(j , L2[k]);
        }
        ans += i-j;
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; string s, t; cin >> n >> s >> t;
	for(int i = 0; i <= n; i++){
		bool ok = true;
		for(int j = i; j < n; j++) ok &= s[j] == t[j - i];
		if(ok) return !printf("%d\n", n + i);
	}
	return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 1003
//int mod=1e9+7;
//int mod=998244353;

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

    string s;
    cin>>s;
    int i,j,n=s.length();
    int ans=0;
    stack<char> st;
    for(i=0;i<n;++i)
    {
        if(st.empty())
            st.push(s[i]);
        else if(st.top()==s[i])
            st.push(s[i]);
        else
        {
            st.pop();
            ans+=2;
        }
    }
    cout<<ans;



    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

using int64 = long long;

using vint = vector<int>;

constexpr int INF = (1 << 30) - 1;
constexpr int64 INF64 = (1ll << 60) - 1;

#define rep(i, N) for(int i=0;i<(int)(N);++i)
#define fs first
#define sc second
#define e_b emplace_back
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& m) {
	os << "{" << endl;
	for (auto& e : m) os << "(" << e.first << ", " << e.second << ")" << endl;
	return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
	os << "{" << endl;
	for (auto& e : s) os << ", " << e << endl;
	return os << "}";
}

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int64 gcd(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	int64 r;
	while ((r = y % x) != 0) {
		y = x;
		x = r;
	}
	return x;
}
int64 lcm(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	return x / gcd(x, y) * y;
}

// int dx[] = { -1, 0, 1, 0 };
// int dy[] = { 0, 1, 0, -1 };

void Main();
signed main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	Main();
}


/*----------------------------Insert from here!----------------------------*/



/*----------------------------Insert above here----------------------------*/


void Main() {
	int H, W; cin >> H >> W;
	vector<string> c(H);
	rep(i, H) cin >> c[i];

	vector<pair<int, int>> v;
	rep(i, H) {
		rep(j, W) {
			if (c[i][j] == 'B') v.emplace_back(i, j);
		}
	}

	int ans = 0;
	rep(i, v.size()) {
		for (int j = i + 1; j < v.size(); ++j) {
			ans = max(ans, abs(v[j].fs - v[i].fs) + abs(v[j].sc - v[i].sc));
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3264
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

N = Int()
D = {}
ans = 0
for i in range(N):
    s = input()
    if not s in D:
        ans += 1
        D[s] = 1
print(ans)

Measured memory_bytes: 126340
while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break
 
    total = m + f
    if m == -1 or f == -1 or total < 30:
        print('F')
    elif total < 50 and r < 50:
        print('D')
    elif total < 65:
        print('C')
    elif total < 80:
        print('B')
    else:
        print('A')

Measured memory_bytes: 6720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int x;
const int maxn=1e5+7;
int vis[maxn],p[maxn];
int cnt=0;
void prime(){
    memset(vis,0,sizeof vis);
    memset(p,0,sizeof p);
    for(int i=2;i<=maxn;i++){
        if(!vis[i]) p[cnt++]=i;
        for(int j=2*i;j<=maxn;j+=i){
            vis[j]=1;
        }
    }
    
}
int main()
{
    prime();
    cin>>x;
    for(int i=0;i<cnt;i++){
        if(p[i]>=x){
            cout<<p[i];
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] A = in.nextIntArray(N);
            int sum = IntStream.of(A).sum();
            int cnt = (int) IntStream.of(A).filter(n -> n >= sum / (4.0 * M)).count();
            out.println(cnt >= M ? "Yes" : "No");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

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

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 28372
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>


int main() {
	long long a, b;

	std::cin >> a >> b;

	std::cout << a * b << std::endl;

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	if(a>9 || b>9){
		cout<<-1<<endl;
	}else{
		cout<<a*b<<endl;
	}
	return 0;
}



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

int main(){
    int n;
  	cin >> n;
    vector<vector<int>> g(n,vector<int>(n,-1));
    rep(i,n){
        int ai;
        cin >> ai;
        rep(j,ai){
            int xij, yij;
            cin >> xij >> yij;
            xij--;
            g[i][xij] = yij;
        }
    }
    int ans = 0;
    rep(i,1<<n){
        vector<int> d(n);
        rep(j,n){
            if(i>>j&1){
                d[j] = 1;
            }
        }
        bool ok = true;
        rep(j,n){
            if(d[j]){
                rep(k,n){
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if(ok){
            ans = max(ans,__builtin_popcount(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node *Node;

void insert(int);
void Inorder(Node);
void Preorder(Node);

Node root;

int main()
{
  char mozi[7];
  int a,n,i;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    if(i<n)break;
  }
  
  for(i=0;i<n;i++){
    scanf("%s",mozi);
    if(mozi[0]=='i'){
      scanf("%d",&a);
      insert(a);
    }
    else{
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
  
}

void insert(int p){
  Node x=root,y=NULL,z;
  z = malloc(sizeof(struct node));
  z->key=p;
  z->left=NULL;
  z->right=NULL;

  while(x!=NULL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;

  if(y==NULL)root=z;
  else if(z->key < y->key)y->left=z;
  else y->right=z;
}

void Inorder(Node q){
  if(q==NULL)return;
  Inorder(q->left);
  printf(" %d",q->key);
  Inorder(q->right);
}

void Preorder(Node q){
  if(q==NULL)return;
  printf(" %d",q->key);
  Preorder(q->left);
  Preorder(q->right);
}



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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll a[200005];
ll base[35];
set<ll>set1;
//<<-----Implement Functions Here---->>//



//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;
		cout<<n+n*n+n*n*n<<endl;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

   
}

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


int main(){
    double w,h,x,y;
    cin >>w>>h>>x>>y;

    double ans;
    ans = w*h/2;
    if(x==w/2 && y==h/2)
        cout << ans << " " << 1 << endl;
    else
        cout << ans << " " << 0 << endl;

return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
using namespace std;
using ll = long long;

int main() {
    ll N; cin >> N;
    vector<ll> W(N);
    for (auto &w : W) cin >> w;
    ll ans = 10000000;
    ll S1 = 0;
    ll S2 = accumulate(W.begin(), W.end(), 0);
    for (int i = 0; i < N; i++) {
        S1 += W[i];
        S2 -= W[i];
        ans = min(ans, abs(S1 - S2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (int)(v).size()
#define ll long long
#define mod 1000000007

int main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int n; cin >> n;
        vector<int> v(220);
        lp(i, n-1) cin >> v[i];
        int an = v[0] + v[n - 2];
        lp(i, n - 2) an += min(v[i], v[i + 1]);
        cout << an;
return 0;
}



Measured memory_bytes: 256
w, h, n = list(map(int, input().split()))
xya = []
for i in range(n):
    xya.append(list(map(int, input().split())))

max_x_1 = 0
min_x_2 = w
max_y_3 = 0
min_y_4 = h
for i in range(n):
    ai = xya[i][2]
    if ai == 1:
        if xya[i][0] > max_x_1:
            max_x_1 = xya[i][0]
    if ai == 2:
        if xya[i][0] < min_x_2:
            min_x_2 = xya[i][0]
    if ai == 3:
        if xya[i][1] > max_y_3:
            max_y_3 = xya[i][1]
    if ai == 4:
        if xya[i][1] < min_y_4:
            min_y_4 = xya[i][1]

x = min_x_2 - max_x_1
if x <= 0:
    print("0")
else:
    y = min_y_4 - max_y_3
    if y <= 0:
        print("0")
    else:
        print(x * y)


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    long long rounds=n/(a+b),left=n%(a+b);
    long long ans=rounds*a+min(left,a);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Runtime.ConstrainedExecution;

namespace Contest
{


    class Program
    {

        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());

            string ans = "";
            bool flag = true;

            while(n > 0)
            {
                var temp = int.Parse(((n) % 26).ToString());
                if (temp == 0)
                {
                    ans += 'z';
                    n--;
                }
                else ans += (char)('a' + temp - 1);
                n /= 26;
            }


            Console.WriteLine(ans.Reverse().ToArray());
        }
    }
}

Measured memory_bytes: 28204
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

int main()
{
    long long a,b,c,x,y;
    long long n;
    cin>>a>>b>>c>>x>>y;
    n=max(x,y)*2*c;
    n=min(n,min(x,y)*2*c+(y>x?(y-x)*b:(x-y)*a));
    n=min(n,a*x+b*y);
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int c[2002];
int merge(int *L,int a,int b){
  if(a!=b){
    merge(L,a,(a+b)/2);
    merge(L,(a+b)/2+1,b);
    int i=a,j=(a+b)/2+1,num=a;
    while(i<(a+b)/2+1 && j<=b){
      if(L[i]>L[j]){
        c[num]=L[j];
        j++;
      }
      else{
        c[num]=L[i];
        i++;
      }
      num++;
    }
    while(i<(a+b)/2+1){
      c[num]=L[i];
      i++;
      num++;
    }
    while(j<=b){
      c[num]=L[j];
      j++;
      num++;
    }
    for(i=a;i<=b;i++)
        L[i]=c[i];
  }
}

int main(){
  int n,i,j,k,count=0;
  scanf("%d",&n);
  int L[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&L[i]);
  merge(L,0,n-1);
  for(i=0;i<n-2;i++){
    for(j=i+1;j<n-1;j++){
      k=j+1;
      while(L[i]+L[j]>L[k] && k<n){
        count++;
        k++;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [-a for a in A]

from heapq import heapify, heappop, heappush
heapify(A)

for i in range(M):
    cur_max = heappop(A)
    new = -((-cur_max) // 2)

    heappush(A, new)


print(-sum(A))


Measured memory_bytes: 15020
n = int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
for i in range(1,n):
    a1[i] += a1[i-1]
for i in range(n-2,-1,-1):
    a2[i] += a2[i+1]
x=[]
for i in range(n):
    x.append(a1[i]+a2[i])
print(max(x)) 

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

int N;
int A[20], B[20];
int DP[(1<<20)][20];

int solve(int S, int x) {
  if(DP[S][x]>0) return DP[S][x];
  if(S==0) return DP[S][x] = x;
  DP[S][x] = inf;
  int num = 0;
  for(int i=0;i<x;++i) {
    if((S&(1<<i))==0) num++;
  }
  int pos = -1;
  for(int i=0;i<N;++i) {
    if((S&(1<<i))!=0) pos++;
  }
  int tmp1, tmp2;
  for(int i=0;i<N;++i) {
    if((S&(1<<i))==0) continue;
    if((i-pos)%2==0) tmp1 = A[i];
    else tmp1 = B[i];
    if((x-(pos+1))%2==0) tmp2 = A[x];
    else tmp2 = B[x];
    if(tmp1>tmp2) continue;
    DP[S][x] = min(DP[S][x], solve(S^(1<<i), i) + num);
  }
  return DP[S][x];
}

int main() {
  cin>>N;
  for(int i=0;i<N;++i) cin>>A[i];
  for(int i=0;i<N;++i) cin>>B[i];
  int S = (1<<N) - 1;
  int ans = inf;
  for(int i=0;i<N;++i) ans = min(ans, solve(S^(1<<i), i));
  if(ans==inf) cout<<-1<<endl;
  else cout<<ans<<endl;
}



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

int main(){
  int n,i;
  cin >> n;
  vector<int> a(n+1,0);
  for(i=0;i<n-1;i++){
    int k;
    cin >> k;
    a.at(k)++;
  }
  
  for(i=1;i<=n;i++){
    cout << a.at(i) << endl;
  }
}

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

double dist(double x1, double y1, double x2, double y2){
    const double dx = (x1 - x2);
    const double dy = (y1 - y2);
    return sqrt(dx * dx + dy * dy);
}

void solve(
    long long N,
    std::vector<long long> x,
    std::vector<long long> y){

    double ans = 0;
    REP(i, N){
        REP(j, N){
            ans += dist(
                x.at(i), y.at(i),
                x.at(j), y.at(j)
            );
        }
    }
    ans /= N;
    printf("%.8f\n", ans);
}

// 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);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
    }
    solve(N, std::move(x), std::move(y));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

lint app() {
  int n;
  cin>>n;

  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }

  map<int,int> count;
  lint ans=0;
  rep(i,n){
    int jaj=i-a[i];
    if(jaj>0){
      auto cp=count.find(jaj);
      if(cp!=count.end()){
        ans+=cp->second;
      }
    }

    int aii=a[i]+i;
    auto cp=count.find(aii);
    if(cp!=count.end()){
      cp->second++;
    }else{
      count.emplace(aii,1);
    }
  }

  return ans;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 13216
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int retu[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {2, 4, 6}};

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != s[s.size() - i - 1]){
            s[i] = s[s.size() - i - 1] = '*';
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

struct train {
    int c, s, f;
};

int main() {
    int n;
    cin >> n;
    vector<train> trains(n - 1);
    for (auto &t : trains) {
        cin >> t.c >> t.s >> t.f;
    }
    forin(i, 0, n - 1) {
        auto time = 0;
        forin(j, i, n - 1) {
            auto tr = trains[j];
            if (time < tr.s)
                time = tr.s + trains[j].c;
            else {
                auto wait = (time - tr.s) % tr.f;
                if (wait == 0)
                    time += tr.c;
                else
                    time += tr.f - wait + tr.c;
            }
        }
        cout << time << endl;
    }
    cout << 0 << endl;
}



Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	s=input().rstrip().decode('utf-8')
	if s=="SUN":ans=7
	elif s=="MON":ans=6
	elif s=="TUE":ans = 5
	elif s=="WED":ans = 4
	elif s=="THU":ans =3
	elif s=="FRI":ans = 2
	elif s=="SAT":ans = 1
	
	
	
	print(ans)
	
	
	
	







if __name__ == "__main__":
		main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc162/abc162_d.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

bool isIJK(vector<vector<int>> &c, int target) {
  int id = lower_bound(c[2].begin(), c[2].end(), target) - c[2].begin();
  if (id < 0 || id >= c[2].size()) return false;
  return c[2][id] == target;
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<vector<int>> c(3, vector<int>(0));
  rep(i, N) {
    char s;
    cin >> s;
    int t = 0;
    if (s == 'R') {
      t = 0;
    } else if (s == 'G') {
      t = 1;
    } else if (s == 'B') {
      t = 2;
    }
    c[t].push_back(i);
  }

  ll ans = c[0].size() * c[1].size() * c[2].size();
  if (ans == 0) {
    cout << ans << endl;
    return 0;
  }
  for (int i : c[0]) {
    for (int j : c[1]) {
      int diff = abs(i - j);
      int mi = min(i, j);
      int ma = max(i, j);
      if (mi > diff) {
        if (isIJK(c, mi - diff)) ans--;
      }
      if (isIJK(c, ma + diff)) ans--;
      if (diff % 2 == 0) {
        if (isIJK(c, ma - diff / 2)) ans--;
      }
    }
  }

  cout << ans << endl;
}

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

int main() {

  int a,b,c;
  cin >> a >> b >> c;

  if (a < b) {
    if (b < c) {
      cout << a + b << endl;
    } else {
      cout << a + c << endl;
    }
  } else {
    if (a < c) {
      cout << a + b << endl;
    } else {
      cout << b + c << endl;
    }
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt[26]={0};
 
int main(){
	for(int i=0;i<4;i++){
		char c;
		cin>>c;
		cnt[c-'A']++;
	}
	for(int i=0;i<26;i++){
		if(!(cnt[i]==0||cnt[i]==2)){
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long
ll gcd(ll a,ll b){
    ll s=1,c;
    while(a&&b){
        if((~a&1)&&(~b&1))
            a>>=1,b>>=1,s<<=1;
        else if(~a&1)a>>=1;
        else if(~b&1)b>>=1;
        else if(a>b)a=a-b;
        else c=b-a,b=a,a=c;
    }
    if(!a)return b*s;
    if(!b)return a*s;
}
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(b%2==1){
		cout<<"No"<<endl;
		return 0;
	}
	else{
		if(b<2*a||b>4*a){
			cout<<"No"<<endl;
		}
		else
			cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define MOD 1000000007
using namespace std;
vector <int> occ (100000);
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vector <int> a (N);
    sort(a.begin(), a.end());
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        occ[a[i]]++;
    }
    int ans = 0;
    for(int i = 1; i < 99999; i++){
        ans = max(ans, occ[i-1]+occ[i]+occ[i+1]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	
	if(s.size() == 2) cout << s << endl;
	else {
		reverse(begin(s), end(s));
		cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();//宿泊日数
        int k = sc.nextInt();
        int x = sc.nextInt();//n泊までの値段
        int y = sc.nextInt();//n+1泊以降の値段
        if(n > k){
            System.out.println( (k*x) + ((n-k)*y) );
        } else {
            System.out.println( n*x );
        }
    }
    
}


Measured memory_bytes: 21844
/*==============================================*\
ID:          shahidul_brur

Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh

 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;
const int LOGN = 20;
int n, k, a[maxn][4];
ll dp[maxn][4];
ll cal(int i, int p)
{
    if(i>n) return 0LL;
    ll &ret=dp[i][p];
    if(ret!=-1) return ret;
    ret = 0LL;
    f1(j,3){
        if(p==j) continue;
        ret = max(ret, cal(i+1, j) + a[i][j]);
    }
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n;
    f1(i,n) cin>>a[i][1]>>a[i][2]>>a[i][3];
    mem(dp, -1);
    cout << cal(1,0) << "\n";
    return 0;
}


Measured memory_bytes: 16256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値
		int N = scan.nextInt();
		int M = scan.nextInt();

		Integer[] A = new Integer[N];

		int sum = 0;

		for (int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
			sum += A[i];
		}

		Arrays.sort(A, Comparator.reverseOrder());

		int Mth = A[M-1];

		System.out.println(Mth >= sum /(4.0 * M) ? "Yes" : "No");
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
double a,b,x,theta;
double f(double a,double b,double x,double theta){
  if(theta > M_PI /2.0){
    return 0.0;
  }
  double rest=0.0;
  if(a*a*b>=x*2){
    rest+=b*a*b/tan(theta)/2.0;
  }
  else{
    rest+=(b*a*a)-a*a*a*tan(theta)/2.0;
  }
  return rest;
}

int main(){
  cin >> a >> b >> x;
  double tyoku = M_PI/2.0;
  double hei = 0.0;
  for(int i=0;i<100000;i++){
    theta=(tyoku+hei)/2.0;
    if(f(a,b,x,theta)<x){
      tyoku=theta;
    }
    else{
      hei=theta;
    }
  }
  cout << fixed << setprecision(10) << theta/M_PI*180 << endl;
}
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
const int mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string s; cin >> s;
    int n = s.size();
    rep(i,n) cout << 'x';
    cout << endl;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 200200;
const int MIN = 20;

int A[MAX];
VI V;

int L[MIN][MAX];
int R[MIN][MAX];

int DP1[1<<MIN];
int DP2[1<<MIN];

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n, v;
	scanf("%d%d", &n, &v);

	FOR (i, 0, n)
	{
		scanf("%d", &A[i]);
	}

	while(v > 0)
	{
		V.PB(v);
		v /= 2;
	}

	V.PB(0);

	int m = SZ(V);

	FOR (it, 0, m)
	{
		int w = V[it];

		L[it][0] = 0;

		FOR (i, 1, n)
		{
			if (A[i] - A[i-1] <= w) L[it][i] = L[it][i-1];
			else L[it][i] = i;
		}

		R[it][n-1] = n-1;
		RFOR(i, n-1, 0)
		{
			if (A[i+1] - A[i] <= w) R[it][i] = R[it][i+1];
			else R[it][i] = i;
		}
	}


	FOR (mask, 0, 1<<m)
	{
		int ind = DP1[mask];

		FOR (i, 0, m)
		{
			if (mask & (1<<i)) continue;
			int nm = mask | (1<<i);
			if (ind == n)
			{
				DP1[nm] = n;
				continue;
			}

			int to = R[i][ind] + 1;

			DP1[nm] = max(DP1[nm], to);
		}
	}

	FOR (mask, 0, 1<<m)
	{
		DP2[mask] = n-1;
	}

	FOR (mask, 0, 1<<m)
	{
		int ind = DP2[mask];

		FOR (i, 0, m)
		{
			if (mask & (1<<i)) continue;
			int nm = mask | (1<<i);
			if (ind == -1)
			{
				DP2[nm] = -1;
				continue;
			}

			int to = L[i][ind] - 1;
			DP2[nm] = min(DP2[nm], to);
		}
	}

	int x = 0;
	while(x < n)
	{
		int to = R[0][x];

		bool ok = false;

		FOR (mask, 0, 1<<m)
		{
			if (mask & (1<<0)) continue;
			int m1 = mask;
			int m2 = (((1<<m)-1) - (1<<0)) ^ m1;

			if (DP1[m1] >= x && DP2[m2] <= to ) ok = true;
		}

		string res;
		if (ok) res = "Possible";
		else res = "Impossible";

		while(x <= to)
		{
			printf("%s\n", res.c_str());
			x++;
		}
	}


}


Measured memory_bytes: 42112
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

typedef pair<int, int> Pa;
typedef long long ll;

int main() {
    cin >> N >> K;
    int count = 0, num;
    rep(i, N){
        cin >> num;
        if(num >= K) count++;
    }
    cout << count;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.next();
            char[] cs = S.toCharArray();
            Arrays.sort(cs);
            System.out.println("abc".equals(new String(cs)) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27024
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    string x;
    cin >> n >> x;
    ll pcnt = 0;
    ll idx1 = -1;
    for(ll i = 0; i < n; i++) {
        if(x[i] == '1') {
            pcnt++;
            idx1 = i;
        }
    }
    if(pcnt != 1) idx1 = -1;
    ll remp = 0, remm = 0;
    for(ll i = 0; i < n; i++) {
        remp *= 2;
        remm *= 2;
        if(x[i] == '1') {
            ++remp;
            ++remm;
        }
        remp %= pcnt + 1;
        if(pcnt > 1) remm %= pcnt - 1;
    }
    vll remvp(n + 10), remvm(n + 10);
    ll remcp = 1, remcm = 1;
    for(ll i = 0; i < n; i++) {
        remcp %= pcnt + 1;
        if(pcnt > 1) remcm %= pcnt - 1;
        remvp[n - 1 - i] = remcp;
        remvm[n - 1 - i] = remcm;
        remcp *= 2;
        remcm *= 2;
    }
    vll ans(n);
    for(ll i = 0; i < n; i++) {
        if(i == idx1) {
            ans[i] = -1;
        }
        else if(x[i] == '1') {
            if(pcnt > 1) ans[i] = (remm - remvm[i] + pcnt - 1) % (pcnt - 1);
//            ans[i] %= pcnt - 1;
        }
        else {
            ans[i] = (remp + remvp[i]) % (pcnt + 1);
//            ans[i] %= pcnt + 1;
        }
    }
    vll ans2(n, 1);
    for(ll i = 0; i < n; i++) {
        if(ans[i] == -1) {
            ans2[i] = 0;
            continue;
        }
        while(ans[i] != 0) {
            ll p = __builtin_popcount(ans[i]);
            ans[i] %= p;
            ++ans2[i];
        }
    }
    for(ll i = 0; i < n; i++) cout << ans2[i] << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 9596
#include <iostream>


int leap_year(int y) {
	if( y % 400 == 0) {
		return 1;/*Leap Year*/
	} else if (y % 100 == 0 && y % 400 != 0) {
		return 0;/*Not Leap Year*/
	} else if (y % 4 == 0 && y % 100 != 0) {
		return 1;
	} else {
		return 0;
	}
}
int main()
{
	int a, b;
	int n =0;/*output kaisuu - 1*/
	while (true) {
		std::cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		} else {
			if (n >0) {
				std::cout << std::endl;/*2 kaime ikou no output de kuugyou*/
			}
			int sum = 0;
			for (int k = a; k <= b; k++) {
				sum = sum + leap_year(k);
			}
			if (sum == 0 /*Subete Leap Year de nai*/) {
				std::cout << "NA" << std::endl;
			} else {
			    for (int i =a; i <= b; i++) {
					if (leap_year(i) == 1) {
						std::cout << i << std::endl;
					}
				}
			}
		}
	n++;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
    int N,X,D=0,count=0;
    int L[101];
    L[0] = 0;
    scanf("%d %d",&N,&X);
    for(int i = 1 ; i <= N ; i++){
        scanf("%d",&L[i]);
    }
    for(int i = 1 ; i <= N ; i++){
        D += L[i];
        if(D <= X){
            count++;
        }else{
            break;
        }
    }
    printf("%d\n",count+1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {     
    int n, k;
    cin >> n >> k;
    vector<pair<long long int, long long int>> vp;
    vector<long long int> vx, vy;
    for (int i = 0; i < n; i++) {
        long long int x, y;
        cin >> x >> y;
        vx.push_back(x);
        vy.push_back(y);
        vp.emplace_back(x, y);
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());
    long long int res = -1;
    for (int x1 = 0; x1 < n; x1++) {
        for (int x2 = x1; x2 < n; x2++) {
            for (int y1 = 0; y1 < n; y1++) {
                for (int y2 = y1; y2 < n; y2++) {
                    int c = 0;
                    for (auto p : vp) {
                        if (p.first >= vx[x1] && p.first <= vx[x2] && p.second >= vy[y1] && p.second <= vy[y2]) {
                            c++;
                        }
                    }
                    if (c >= k) {
                        long long int area = (vx[x2] - vx[x1]) * (vy[y2] - vy[y1]);
                        if (res == -1 || area < res) {
                            res = area;
                        }
                    }
                }
            }
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 3636
D,G=map(int,input().split())
p=list()
c=list()
for _ in range(D):
  P,C=map(int,input().split())
  p.append(P)
  c.append(C)
ans=1<<29
for bit in range(1<<D):
  sum_=0
  num_=0
  for i in range(D):
    if bit&(1<<i):
      sum_+=c[i]+p[i]*100*(i+1)
      num_+=p[i]
  if sum_>=G:
    ans=min(ans,num_);
  else:
    for i in range(D-1,-1,-1):
      if bit&(1<<i):
        continue
      for j in range(p[i]):
        if sum_>=G:
          break
        sum_+=100*(i+1)
        num_+=1
    ans=min(ans,num_);
print(ans)


Measured memory_bytes: 9216