akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()

int  main(int argc, char const *argv[])
{
	crap;
	int n;
	cin>>n;
	vi a(n);
	in(a,n);

	sort(all(a));

	deque<int> emni;

	emni.pb(a[0]);
	int mi=1,ma=n-1;
	int r=1;
	while (sz(emni)<n)
	{
		if (r&1)
		{
			ll x=a[ma];
			ll y=(ma-1<mi)? 0 : a[ma-1];
			ma-=2;

			int f=emni.front(),b=emni.back();

			ll conf1=abs(x-f)+abs(y-b);
			ll conf2=abs(x-b)+abs(y-f);

			if (conf1 > conf2)
			{
				emni.pf(x),emni.pb(y);
			}
			else
			{
				emni.pf(y),emni.pb(x);
			}
		}
		else
		{
			ll x=a[mi];
			ll y=(mi+1>ma)? 0 : a[mi+1];
			mi+=2;

			int f=emni.front(),b=emni.back();

			ll conf1=abs(x-f)+abs(y-b);
			ll conf2=abs(x-b)+abs(y-f);

			if (conf1 > conf2)
			{
				emni.pf(x),emni.pb(y);
			}
			else
			{
				emni.pf(y),emni.pb(x);
			}
		}
		r++;
	}
	vi ans;
	for (int i : emni)
	{
		if (i)
			ans.pb(i);
	}

	

	ll val1=0;
	rep(i,n-1)
		val1+=abs(ans[i]-ans[i+1]);
	

	emni.clear();

	emni.pb(a[n-1]);
	ma=n-2,mi=0;
	r=1;
	while (sz(emni)<n)
	{
		if (r&1)
		{
			ll x=a[mi];
			ll y=(mi+1>ma)? 0 : a[mi+1];
			mi+=2;

			int f=emni.front(),b=emni.back();

			ll conf1=abs(x-f)+abs(y-b);
			ll conf2=abs(x-b)+abs(y-f);

			if (conf1 > conf2)
			{
				emni.pf(x),emni.pb(y);
			}
			else
			{
				emni.pf(y),emni.pb(x);
			}
		}
		else
		{
			ll x=a[ma];
			ll y=(ma-1<mi)? 0 : a[ma-1];
			ma-=2;

			int f=emni.front(),b=emni.back();

			ll conf1=abs(x-f)+abs(y-b);
			ll conf2=abs(x-b)+abs(y-f);

			if (conf1 > conf2)
			{
				emni.pf(x),emni.pb(y);
			}
			else
			{
				emni.pf(y),emni.pb(x);
			}
		}
		r++;
	}
	ans.clear();
	for (int i : emni)
	{
		if (i)
			ans.pb(i);
	}



	ll val2=0;
	rep(i,n-1)
		val2+=abs(ans[i]-ans[i+1]);


	cout<<max(val1,val2)<<"\n";
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
typedef long long ll;

using namespace std;

int main(){
  int a[5];
  for (int i = 0; i < 5; i++) cin >> a[i];
  
  int ans = 0;
  int min_1 = 9;
  bool flag = false;
  for ( int i = 0; i < 5; i++) {
    if (a[i] % 10 ==0) ans+= a[i];
    else {
      ans+=a[i] - a[i] % 10 + 10;
      min_1 = min(min_1,a[i]%10);
      flag = true;
    }
  }
  ans = ans -10 + min_1;
  if (flag != true) ans++;
  cout << ans << endl;
}


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

int main() {
	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	if (a == 1 || b == 1 || c == 1 || d == 1) {
    	if (a == 9 || b == 9 || c == 9 || d == 9) {
        	if (a == 7 || b == 7 || c == 7 || d == 7) {
            	if (a == 4 || b == 4 || c == 4 || d == 4) {
                	cout << "YES" << endl;
                  	return 0;
                }
            }
        }
    }
  	cout << "NO" << endl;
  	return 0;
}

Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/abc061/tasks/abc061_a

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int a,b,c;

int main() {
    cin >> a >> b >> c;
    if(c>=a&&c<=b) {
        print("Yes");
    } else {
        print("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstring>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <memory.h>
using namespace std;
typedef long long ll;
typedef long double ldbl;

int c[26], d[26];

int main() {
  string s, t;
  cin >> s >> t;
  auto n = s.size();
  auto m = t.size();

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s[0] < t[0]) {
    puts("Yes");
    return 0;
  }

  if (n < m) {
    for (auto ch : s) {
      c[ch - 'a']++;
    }
    for (auto ch : t) {
      d[ch - 'a']++;
    }
    bool yes = true;
    for (int i = 0; i < 26; i++) {
      if (c[i] > d[i]) {
        yes = false;
        break;
      }
    }
    if (yes) {
      puts("Yes");
      return 0;
    }
  }

  puts("No");
  return 0;
}

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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define inf 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

int gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
 
typedef pair<int, int> pi;
typedef long long i64;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

bool PrimeNumber(int n) {
  if(n < 2) return false;
  for(int i = 2; i * i <= n; ++i) {
    if(n % i == 0) return false;
  }
  return true;
}

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

  int n;
  while(cin >> n, n) {
    int cou = 0;
    rep(i, n + 1, 2 * n + 1) {
      if(PrimeNumber(i)) cou++;
    }
    cout << cou << endl;
  }
}



Measured memory_bytes: 3156
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

int main() {
	//cout << fixed << setprecision(10);
	long long int k, s, t,n,m,a,b,c,d;
	cin >> a>>b>>c;
	if (a==b&&b==c) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	
	

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n;
    string s;
    cin >> n >> s;
    bool ans = true;
    if(n % 2 == 1){
        ans = false;
    }else{
        for(int i = 0; i < n / 2; i++){
            if(s[i] != s[i + (n / 2)]){
                ans = false;
                break;
            }
        }
    }
    cout << (ans? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = [int(stra) // 2 for stra in input().split()]

mod = 1
while a[0] % 2 == 0:
  mod *= 2
  a[0] //= 2

flag = False
for i in range(1, n):
  if a[i] % mod == 0 and a[i] % (mod * 2) != 0:
    a[i] //= mod
  else:
    flag = True
    break

if flag:
  print(0)
else:
  lcm = a[0]
  for i in range(1, n):
    p = lcm
    q = a[i]
    r = p % q
    while r != 0:
      p, q = q, r
      r = p % q
    lcm = lcm * a[i] // q
  lcm *= mod
  print(m // lcm - m // (2 * lcm))

Measured memory_bytes: 14484
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll x,k,d;
    ll ans;

    cin >> x >> k >> d;

    ll min_k = abs(x)/d;

    if(min_k==0){
        ans = min(abs(x+d*(k%2)), abs(x-d*(k%2)));
    }else if(min_k>k){
        ans = abs(x) - k*d;
    }else{
        ans = abs(x)%d;

        if((k-min_k)%2==1){
            ans = d-ans;
        }
    }
    
    cout << ans << endl;
 
    return 0;
}



Measured memory_bytes: 3644
#include<iostream>
#include<string>

using namespace std;

int main()
{
      int K;
      cin>>K;
      string str;
      cin>>str;

      int sz=str.size();
      if(sz<=K){cout<<str<<endl;return 0;}
      str.erase(K,sz);
      str=str+"...";
      cout<<str<<endl;

      return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int n;
    cin >> n;
    vector<int> a(n);
    For(i,0,n) cin >> a[i];
    int allxor=0;
    for(auto i:a){
        allxor ^= i;
    }
    For(i,0,n){
        cout << (a[i]^allxor) << " ";
    }
    cout<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3980
using System;

namespace abc158B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            long N = long.Parse(str[0]);
            long A = long.Parse(str[1]);
            long B = long.Parse(str[2]);
            long M = N / (A + B);
            long L = N % (A + B);
            if (L >= A)
                Console.WriteLine(M * A + A);
            else
                Console.WriteLine(M * A + L);
        }
    }
}


Measured memory_bytes: 13140
import sys
def to_ints(a,b,c,n):
    d=list(a)
    e=list(b)
    f=list(c)
    for i in range(len(d)):
        if d[i]=='X': d[i]=n
    for i in range(len(e)):
        if e[i]=='X': e[i]=n
    for i in range(len(f)):
        if f[i]=='X': f[i]=n
    return map(int,("".join(d),"".join(e),"".join(f)))

for e in sys.stdin.readlines():
    e=e.rstrip()
    i=e.index('+')
    j=e.index('=')
    a=e[:i]
    b=e[i+1:j]
    c=e[j+1:]
    s = 0
    if len(a)>1 or len(b)>1 or len(c)>1:
        s=1 if a[0]=='X' or b[0]=='X' or c[0]=='X' else 0
    ans=-1
    for n in range(s,10):
        x,y,z=to_ints(a,b,c,str(n))
        if x+y==z: ans=n
    print ans if ans>=0 else 'NA'

Measured memory_bytes: 4332
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

int main(){

	int height,width,tmp;
	scanf("%d %d",&height,&width);

	int** table = new int*[height+1];
	table[0] = new int[width+1];
	for(int i=0; i < width+1; i++)table[0][i] = 0;

	int max_r = 0;

	for(int i=1; i <= height; i++){
		table[i] = new int[width+1];
		table[i][0] = 0;
		for(int k=1; k <= width; k++){
			scanf("%d",&tmp);
			table[i][k] = 1-tmp;
			if(tmp != 1){
				table[i][k] = min(table[i-1][k-1],min(table[i][k-1],table[i-1][k]))+1;
				max_r = max(max_r,table[i][k]);

			}

		}
	}

	printf("%d\n",max_r*max_r);

    return 0;
}

Measured memory_bytes: 10308
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
    long long n,ans=0;
    cin >> n;
    long long sqrtn=sqrt(n);
    if(n%2==0){
        long long count=0,x=0;//2で割れる回数，個数
        while(n%2==0){
            n/=2;
            count++;
            if((x+2)*(x+1)/2<=count) x++;
        }
        ans+=x;
    }
    long long N=n;
    for(long long i=3; i*i<=N; i+=2){
        if(n%i==0){
            long long count=0,x=0;
            while(n%i==0){
                n/=i;
                count++;
                if((x+2)*(x+1)/2<=count) x++;
            }
            ans+=x;
        }
    }
    if(n>1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

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

int main(void){
  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == '1') cnt ++;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  map<ll,int> mp;
  rep(i,N) {
    ll x;
    cin >> x;
    mp[x]++;
  }
  int ans = 0;
  auto it = mp.rbegin();
  while(it != mp.rend()) {
    ll n = (1ll<<32);
    while(n>2*(it->first)) {
      n = n>>1;
    }
    for(;n>=it->first;n = n>>1) {
      ll j = n-it->first;
      if(mp.find(j) == mp.end()) continue;
      if(j==it->first) {
        ans += (it->second)/2;
        it->second -= (it->second)/2;
        continue;
      }
      int x = min(it->second,mp[j]);
      mp[j] -= x;
      it->second -= x;
      ans += x;
    }
    it++;
  }
  cout << ans << endl;
  

  return 0;
}

Measured memory_bytes: 12800
import heapq

x,y,a,b,c = map(int,input().split())

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

ans = 0
red_cnt = 0
green_cnt = 0
cnt = 0

heap = []
for i in range(len(p)):
    heapq.heappush(heap,(-p[i],0))
for i in range(len(q)):
    heapq.heappush(heap,(-q[i],1))
for i in range(len(r)):
    heapq.heappush(heap,(-r[i],2))

while len(heap):
    _x,_y = heapq.heappop(heap)
    if _y == 0 and red_cnt < x:
        red_cnt += 1
        ans += _x
        cnt += 1
    elif _y == 1 and green_cnt < y:
        green_cnt += 1
        ans += _x
        cnt += 1
    elif _y == 2:
        cnt += 1
        ans += _x

    if cnt == x + y:
        print(-ans)
        exit()


Measured memory_bytes: 54408
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <functional>
#include <string>
#include <cmath>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	long long a[3]; cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] * a[1] / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vll a(N+1);
  REP(i, N){
    cin >> a[i+1];
  }

  //vvll dp(N, vll(K+1, 0));
  vvll dp(2, vll(K+1, 0));

  dp[0][0] = 1;

  REP(i, N+1){
    ll tmp=0;
    REP(j, K+1){
      /*
      tmp += dp[i-1][j]%MOD;
      dp[i][j] = tmp%MOD;
      if(j>=a[i]) tmp -= dp[i-1][j-a[i]];
      while(tmp<0) tmp+=MOD;
      */
      tmp += dp[0][j]%MOD;
      dp[1][j] = tmp%MOD;
      if(j>=a[i]) tmp -= dp[0][j-a[i]]%MOD;
      /*
      for(int k=0; k<a[i]+1 && j-k>=0; ++k){
        dp[i][j] += dp[i-1][j-k];
      }
      */
    }
    swap(dp[0], dp[1]);
  }

  //mat_print(dp);

  //cout << dp[N-1][K]%MOD << "\n";
  cout << dp[0][K]%MOD << "\n";

  return 0;
}


Measured memory_bytes: 2560
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
out = 0
if n == 1:
    if a[0] != 0:
        out = 1
elif a[0] == 0:
    if n%2 == 0:
        out = 1
    else:
        for i in range(1,n//2+1):
            if a[2*i-1] == a[2*i] and a[2*i] == 2*i:
                None
            else:
                out = 1
elif a[0] == 1:
    if n%2 == 1:
        out = 1
    else:
        for i in range(n//2):
            if a[2*i] == a[2*i+1] == 2*i+1:
                None
            else:
                out = 1
else:
    out = 1
if out:
    print(0)
else:
    a = 1
    for i in range(n//2):
        a *= 2
        a = a%(10**9+7)
    print(a)

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

int main() {
  int n;string s;cin>>n>>s;
  if(n%2){cout<<"No"<<endl;exit (0);}
  for(int i=0;i<n/2;i++){
    if(s.at(i)!=s.at(i+n/2)){cout<<"No"<<endl;exit (0);}
  }cout<<"Yes"<<endl;
}


Measured memory_bytes: 3580
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char ans[1005][1005];
const string S4[4]={"abcc", "abdd", "ccab", "ddab"};
const string S5[5]={"abbcc", "ad..a", "bd..a", "b.eez", "oorrz"};
const string S6[6]={"oorrzz", ".a.b.c", ".a.b.c", "d.e.f.", "d.e.f.", "oorrzz"};
const string S7[7]={".oorrzz", "oabb...", "oa.c...", "rddc...", "r...abb", "z...a.c", "z...ddc"};


int main()
{
	int n=read(); if(n<=2) return puts("-1"),0;
	if(n==3)
	{
		puts("aab"); puts("d.b"); puts("dcc");
		return 0;
	}
	rep(i,1,n) rep(j,1,n) ans[i][j]='.';
	int p=n%4; n-=p; n-=4; p+=4;
	for(int i=1;i<=n;i+=4)
	{
		rep(j,0,3) rep(k,0,3) ans[i+j][i+k]=S4[j][k];
	}
	if(p==4)
	{
		n++;
		rep(j,0,3) rep(k,0,3) ans[n+j][n+k]=S4[j][k]; n+=3;
	}
	else if(p==5)
	{
		n++;
		rep(j,0,4) rep(k,0,4) ans[n+j][n+k]=S5[j][k]; n+=4;
	}
	else if(p==6)
	{
		n++;
		rep(j,0,5) rep(k,0,5) ans[n+j][n+k]=S6[j][k]; n+=5;
	}
	else
	{
		n++;
		rep(j,0,6) rep(k,0,6) ans[n+j][n+k]=S7[j][k]; n+=6;
	}
	rep(i,1,n)
	{
		rep(j,1,n) printf("%c",ans[i][j]); puts("");
	}
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<sstream>
#include<algorithm>
#include<cstdlib>
using namespace std;

bool cmp(const string& a,const string b)
{
  if(a.size() != b.size())
    return a.size() < b.size();
  if(a != b)
    return (atoi)(a.c_str()) < (atoi)(b.c_str());
  return false;
}

int main()
{
  int n;
  vector<string> vec;
  cin >> n; 
  vec.resize(n);

  int men = 100000000;  
  int Size[6];
  for(int i=0;i<6;i++)
    Size[i] = 0;
  for(int i=0;i<n;i++)
    cin >> vec[i],Size[vec[i].size()]++,men = min(men,(int)vec[i].size());

  sort(vec.begin(),vec.end(),cmp);
    
  if(Size[men] >= 4)
      cout << vec[0] << vec[3] << endl;
  else if(Size[men] == 3)
    cout << vec[1] << vec[0] << endl;
  else if(Size[men] == 2)
    {
      string a,b;
      a = vec[0]+vec[2];
      b = vec[2]+vec[0];
      cout << min((atoi)(b.c_str()),(atoi)(a.c_str())) << endl;
    }
  else if(Size[men] == 1)
    {
      vector<string> ans;
      for(int i=0;i<5;i++)
	for(int j=0;j<5;j++)
	  if(i != j)
	    ans.push_back(vec[i]+vec[j]);
      sort(ans.begin(),ans.end(),cmp);
      cout << ans[2] << endl;
    }


  


  return 0;
}

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

int a[10005];

int main()
{
	int n;
	cin>>n;
	double x,y;
	cin>>x>>y;
	int t=1;
	double minx=99999999.9;
	for(int i=1;i<=n;i++)
	{
		double ttt;
		cin>>ttt;
		if(minx>fabs(y-x+ttt*0.006)){
			t=i;
			minx=fabs(y-x+ttt*0.006);
		}
		
	}
	cout<<t<<endl; 
	return 0;
} 

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

int main()
{
	int n, max, tmp, minR;
	cin >> n;
	int input[n];
	for(int i = 0; i < n; i++)
	{
		cin >> tmp;
		input[i] = tmp;
	}

	max = -1000000000;
	minR = input[0];
	for(int i = 1; i < n; i++)
	{
		if(max < input[i]-minR)
			max = input[i]-minR;
		if(minR > input[i])
			minR = input[i];
	}

	cout << max << endl;
	return 0;
}


Measured memory_bytes: 3880
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

count = 0

# いきなりオーバー
if A[0] > x:
    diff = A[0]-x
    count += diff
    A[0] = x

for i in range(1, N):
    # 超えてたら、ギリまで下げる
    if A[i]+A[i-1] > x:
        diff = (A[i]+A[i-1])-x
        A[i] -= diff
        count += diff

print(count)




Measured memory_bytes: 14540
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}
ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
ll g(ll x, ll y) {return x / y;}
ll f(ll x, ll m, ll n) {
    return g(x, m) + g(x, n) - g(x, lcm(m, n));
}
/* main */
int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << B - (A - 1) - (f(B, C, D) - f(A - 1, C, D)) << '\n';
}


Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define Maxn 100000
set<pair<int,int> > st;
int a[Maxn+5],b[Maxn+5];
int x[Maxn+5];
int have[Maxn+5];
int mn(int a,int b){
	return a<b?a:b;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		st.insert(make_pair(a[i],i<<1));
		st.insert(make_pair(b[i],(i<<1)|1));
	}
	set<pair<int,int> >::iterator it;
	int now=n,tmp;
	it=st.begin();
	ll sum=0;
	while(now--){
		tmp=(it->second)>>1;
		sum+=(it->first);
		if((it->second)&1){
			x[tmp]+=1;
		}
		else{
			x[tmp]+=2;
		}
		it++;
	}
	for(int i=1;i<=n;i++){
		have[x[i]]++;
	}
	if(have[0]||(!have[2])||(!have[1])){
		cout<<sum<<endl;
		return 0;
	}
	if(((it->second)>>1)==tmp){
		it--;
		int now_1=(it->first);
		it--;
		int now_2=(it->first);
		it++;
		it++;
		int now_3=(it->first);
		it++;
		int now_4=(it->first);
		sum+=mn(now_3-now_2,now_4-now_1);
		cout<<sum<<endl;
		return 0;
	}
	it--;
	x[tmp]=0;
	sum-=(it->first);
	it++;
	while(it!=st.end()){
		tmp=(it->second)>>1;
		if(x[tmp]){
			sum+=(it->first);
			break;
		}
		it++;
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b;
  cin >> a >> b;
  if(a<=b) {
    cout << a << endl;
  }
  else {
    cout << a-1 << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef int_fast64_t ll;
typedef int_fast64_t intt;
typedef int_fast64_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, a, b) for (tmp_m i = a; i < b; ++i)
#define repp(i, a, b) for (tmp_m i = a; i >= b; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& b) const {
    if (dst != b.dst) return dst > b.dst;
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& b) const {
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

inline bool spoint(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

inline bool spr(pr a, pr b) {
  if (a.dst != b.dst) return a.dst < b.dst;
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

ll modex(ll b , ll e , ll m) {
  ll r = 1;
  while (e > 0) {
    if ((e & 1) == 1) {
      r = (r * b) % m;
    }
    e >>= 1;
    b = (b * b) % m;
  }
  return (ll) r;
}


intt count(intt n, intt k){
  return k * (n - k + 1) % mod + 1;
  // return (n % mod * (n + 1) % mod * modex(2, mod - 2, mod) % mod - (n - k + 1) % mod * (n - k) % mod * modex(2, mod - 2, mod) % mod - (k - 1) % mod * k % mod * modex(2, mod - 2, mod) % mod + 1) % mod;
}

void solve() {
  intt n, k;
  cin >> n >> k;
  intt ans = 0;
  rep(i, k, n + 2){
    // deb(count(n, i));
    ans = (ans + count(n, i)) % mod;
  }
  cout << ans << endl;
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void) {
	int n,a,b;
	long long int ans;
	
	scanf("%d %d %d",&n,&a,&b);
	
	if (a > b) {
		printf("0\n");
		return 0;
	}
	
	if (n == 1) {
		printf("%d\n",a == b ? 1 : 0);
		return 0;
	}
	
	ans = b-a;
	ans *= n-2;
	
	printf("%lld\n",ans+1);
	
	return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[111];
int main() {
    cin >> n;
    li sum = 0;
    rin{cin >> a[i]; sum += a[i];}

    li res = INF;
    li diff = INF;
    rin{
        if (abs(a[i]*n - sum) < diff) {
            res = i;
            diff = abs(a[i] * n - sum);
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<string>
#include<cmath>
#include<vector>
#include<tuple>
using namespace std;
bool iseven(int x){ return x % 2 == 0; }
bool isodd(int x){ return !iseven(x); }
int dist(int x, int y) { return abs(x - y);}
//# Functions for Vector/Matrix
template <typename T>
vector<T> zeros(int length){
    vector<T> vec(length, 0);
    return vec;
}
template <typename T>
vector<vector<T>> zeros(tuple<int, int> dim){
    vector<vector<T>> mat(get<0>(dim), vector<T>(get<1>(dim), 0));
    return mat;
}
template <typename T>
void show(vector<T> &vec){
    for (auto value : vec) {
        cout << value << " ";
    }
    cout << endl;
}
template <typename T>
void show(vector<vector<T>> &mat){
    for (auto vec : mat) {
        show(vec);
    }
}
int main(){
    int A, B; cin >> A >> B;
    if(B % A == 0) cout << A + B;
    else cout << B - A;
    return 0;
}



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

int main(){
	int n;
	cin>>n;
	int m4=0,m2=0,m=0;
	for(int i=0;i<n;++i){
		int a;
		cin>>a;
		if(a%4==0){
			m4++;
		}else if(a%2==0){
			m2++;
		}else m++;
	}
	if(m<=m4)cout<<"Yes"<<endl;
	else if(m==m4+1 && m+m4==n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

int main() {
	
	int A;
	cin >> A;
	
	if ( A / 64 == 1){
		cout << 64 << endl;
	}
	else if ( A / 32 == 1){
		cout << 32 << endl;
	}
	else if ( A / 16 == 1){
		cout << 16 << endl;
	}
	else if ( A / 8 == 1){
		cout << 8 << endl;
	}
	else if ( A / 4 == 1){
		cout << 4 << endl;
	}
	else if ( A / 2 == 1){
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
	
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S == "SAT")
    cout << 1 << endl;
  if(S == "FRI")
    cout << 2 << endl;
  if(S == "THU")
    cout << 3 << endl;
  if(S == "WED")
    cout << 4 << endl;
  if(S == "TUE")
    cout << 5 << endl;
  if(S == "MON")
    cout << 6 << endl;
  if(S == "SUN")
    cout << 7 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, k, cnt = 0;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        int x;
        scanf("%d", &x);
        if(x >= k) cnt++;
    }
    printf("%d\n", cnt);
}

Measured memory_bytes: 128
import java.io._
import scala.io.StdIn.{readInt, readLine}

object Main {
  val tree0 = new Array[Int](500001)
  val tree1 = new Array[Int](500001)
  val tree2 = new Array[Int](500001)
  val out:BufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512)
  var count = 0

  def insert(i:Int, j:Int):Unit =
    if(tree0(i) > tree0(j)) {
      if(tree1(i) == -1) tree1(i) = j
      else insert(tree1(i), j)
    } else {
      if(tree2(i) == -1) tree2(i) = j
      else insert(tree2(i), j)
    }

  def inOrder():Unit = {
    var stack:List[Int] = Nil
    var curr = 0
    var flg = true

    while(flg) {
      while(curr != -1) {
        stack = curr::stack
        curr = tree1(curr)
      }
      if(curr == -1 && stack != Nil) {
        val item = stack.head
        stack = stack.tail
        out.write(" ")
        out.write(tree0(item).toString)
        if(count<10000) count += 1
        else {
          out.flush
          count = 0
        }
        curr = tree2(item)
      } else {
        flg = false
      }
    }
  }

  def scan(list:List[Int]):Unit = {
    list match {
      case Nil => ()
      case hd::tl => {
        out.write(" ")
        out.write(tree0(hd).toString)
        if(count<10000) count += 1
        else {
          out.flush
          count = 0
        }
        val hd2 =
          if(tree2(hd) != -1 && tree1(hd) != -1) tree1(hd)::tree2(hd)::tl
          else if(tree2(hd) != -1 && tree1(hd) == -1) tree2(hd)::tl
          else if(tree2(hd) == -1 && tree1(hd) != -1) tree1(hd)::tl
          else tl
        scan(hd2)
      }
    }
  }

  def preOrder(i:Int):Unit =
    if(i == -1) return
    else scan(i::Nil)

  def main(args:Array[String]) = {
    val n = readInt
    var j = 0

    for(i<-0 until n) {
      val s = readLine.split(" ")
      s(0) match {
        case "insert" => {
          tree0(j) = s(1).toInt
          tree1(j) = -1
          tree2(j) = -1
          if(j!=0) insert(0, j)
          j+=1
        }
        case _ => {
          inOrder()
          out.write("\n")
          out.flush()
          preOrder(0)
          out.write("\n")
          out.flush()
        }
      }
    }
  }
}

Measured memory_bytes: 309528
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);

const int MAX_N=2e5+2;


int main(){
    long N,M;
    cin>>N;
    map<LL,long>D;
    REP(i,N){
        LL tmp;
        cin>>tmp;
        D[tmp]++;
    }
    cin>>M;
    bool f=true;
    REP(i,M){
        LL T;
        cin>>T;
        if(D.find(T)==D.end()||D[T]==0){
            f=0;
        }else{
            D[T]--;
        }
    }
    if(f){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline int sgn(T n) { if (n > 0) return 1; else if (n < 0) return -1; else return 0; }

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

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


int main () {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  vi b;
  rep(i,n) {
    b.push_back(abs(n-1-2*i));
  }
  
  SORT(a);
  SORT(b);
  
  if (a == b) {
    ll ans = 1;
    rep(_,n/2) {
      ans *= 2;
      ans %= mod;
    }
    cout << ans << endl;
  }
  else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 1404
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n, k;
    scanf("%d%d", &n, &k);
    std::vector<int> base;
    while (n) {
        base.push_back(n % k);
        n /= k;
    }
    printf("%d\n", (int)base.size());
}


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

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

typedef long long ll;

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

    int k, a, b;
    cin >> k >> a >> b;

    bool ok = false;
    for (int i = a; i <= b; i++) {
    	if (i % k == 0) {
    		ok = true;
    		break;
    	}
    }

    cout << (ok ? "OK" : "NG");
}  
  

Measured memory_bytes: 3584
def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    dp = [[0]*(3001) for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(1, n+1):
        ai = a[i-1]
        for j in range(ai):
            dp[i][j] += dp[i-1][j]*2
            dp[i][j] %= mod
        for j in range(ai, 3001):
            dp[i][j] += dp[i-1][j]*2 + dp[i-1][j-ai]
            dp[i][j] %= mod
    print(dp[n][s])

if __name__ == "__main__":
    main()

Measured memory_bytes: 135516
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    ll tot=0;
    ll n=s.length();
    ll i,j;
    for(i=n-1,j=1;i>=0;i--)
    {
        if(s[i]=='B')
        {
            tot+=n-i-j;
            j++;
        }
    }
    cout<<tot<<endl;
}


Measured memory_bytes: 640
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [k] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    num_list = []
    for i in range(k):
        num_list.append(long(input_raw[i]))

    max_num = long(2)
    min_num = long(2)
    is_exist = True
    if num_list[k-1] != 2:
        is_exist = False
    for i in range(k-1, -1, -1):
        if is_exist == False:
            break;
        min_min_num = min_num;
        #min_max_num = min_num + num_list[i] - 1
        #max_min_num = max_num;
        max_max_num = max_num + num_list[i] - 1
        if i > 0:
            min_min_num = num_list[i - 1] * (min_min_num / num_list[i - 1] + (0 if (min_min_num % num_list[i - 1] == 0)  else 1) )
            #min_max_num = num_list[i - 1] * long(min_max_num / num_list[i - 1] )
            #max_min_num = num_list[i - 1] * (max_min_num / num_list[i - 1] + (0 if (max_min_num % num_list[i - 1] == 0)  else 1) )
            max_max_num = num_list[i - 1] * long(max_max_num / num_list[i - 1] )

        min_num = min_min_num
        max_num = max_max_num

##        if(min_min_num > min_max_num and max_min_num > max_max_num):
##            is_exist = False
##            break;
##        elif(min_min_num > min_max_num and max_min_num <= max_max_num):
##            min_num = max_min_num
##            max_num = max_max_num
##        elif(min_min_num <= min_max_num and max_min_num > max_max_num):
##            min_num = min_min_num
##            max_num = min_max_num
##        else:
##            min_num = min(min_min_num, max_min_num)
##            max_num = max(min_max_num, max_max_num)
        if min_num > max_num:
            is_exist = False
            break;

    if is_exist == True:
        print min_num, max_num
    else:
        print -1


if __name__ == '__main__':
    main()


Measured memory_bytes: 15876
while True:
    N = int(input())
    if N == 0:
        break
    d = {}
    for n in range(N):
        num, p, q = map(int, input().split())
        if num in d:
            d[num][1] += (p*q)
        else:
            d[num] = [n, p*q]
    else:
        fla = False
        for k, v in sorted(d.items(), key=lambda x: x[1][0]):
            if v[1] >= 1000000:
                print(k)
                fla = True
        else:
            if not fla:
                print('NA')

Measured memory_bytes: 7916
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int N; cin >> N;
  int res{};
  for(int i = 1; i <= N; ++i)
  {
    if(i % 2 == 0) ++res;
  }
  
  auto ans = 1 - ((double)res / N);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

int main(){
  long long int n;
  cin>>n;
  vector<long long int> a(n);
  vector<long long int> b(n);

  long long int asum=0;
  long long int bsum=0;

  for(long long int i=0;i<n;i++){
    cin>>a[i];
    asum+=a[i];
  }
  for(long long int i=0;i<n;i++){
    cin>>b[i];
    bsum+=b[i];
  }

  long long int cs=bsum-asum;
  long long int ps=0;
  long long int ms=0;

  for(long long int i=0;i<n;i++){
    if(a[i]<b[i]){
      ps+=(b[i]-a[i])/2;
      if((b[i]-a[i])%2==1){
        ps++;
        ms++;
      }
    }
    if(a[i]>b[i])ms+=a[i]-b[i];
  }

  //cout<<cs<<" "<<ps<<" "<<ms<<endl;
  //cout<<((cs-ps)*2)<<" "<<(cs-ms)<<endl;

  if(ps>cs||ms>cs||cs<0){
    cout<<"No"<<endl;
    return 0;
  }
  //cout<<cs<<" "<<ps<<" "<<ms<<endl;
  //cout<<(cs-ps)<<" "<<((cs-ms)*2)<<endl;

  if(((cs-ps)*2)==(cs-ms)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

void solve() {
    std::string s;
    std::cin >> s;

    if (s.back() == 's') s.push_back('e');
    s.push_back('s');
    std::cout << s << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3632