akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace AtCoderABC086
{
    class Program
    {
        public static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(' ').Select(q => int.Parse(q)).ToArray();
            int N = a[0], M = a[1], X = a[2], Y = a[3];
            int[] x = Console.ReadLine().Split(' ').Select(q => int.Parse(q)).ToArray();
            int[] y = Console.ReadLine().Split(' ').Select(q => int.Parse(q)).ToArray();

            bool flag = false;
            for (int Z = X + 1; Z <= Y; Z++)
            {
                bool temp = true;
                for (int i = 0; i < N; i++)
                {
                    if (x[i] < Z) continue;
                    temp = false;
                }
                for (int i = 0; i < M; i++)
                {
                    if (y[i] >= Z) continue;
                    temp = false;
                }
                if (temp)
                {
                    flag = true;
                    break;
                }
            }
            Console.WriteLine((flag)? "No War": "War");
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    string s;
    cin>>s;
    string t="qwertyuiopasdfghjklzxcvbnm";
    int h=0,a=0,b=0;
    for(int i=2;i<s.size()-1;i++){
    	if(s[i]=='C'){
    		h++;
    	}
    }
    for(int i=0;i<s.size();i++){
    	for(int j=0;j<26;j++){
    		if(t[j]==s[i]){
    			b++;
    		}
    	}
    }
    if(s[0]!='A'||s[1]=='C'||s[s.size()-1]=='C'){
    	a++;
    }
    if(a==0&&h==1&&b==s.size()-2){
    	cout<<"AC"<<endl;
    }
    else{
    	cout<<"WA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Problem : A - September 9
// Contest : AtCoder - AtCoder Beginner Contest 073
// URL : https://atcoder.jp/contests/abc073/tasks/abc073_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
string s;cin>>s;
if(s[0]=='9' or s[1]=='9')
cout<<"Yes";
else
cout<<"No";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

int a[100];

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n-1;i++)ans+=a[i];
	cout<<ans+a[n-1]/2<<endl;
	
	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;
// 入力
int H, W;
vector<vector<char>> field;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;


int main() {

    ll A, B, M;
    cin >> A >> B >> M;
    vector<ll> a(A), b(B), x(M), y(M), c(M);
    ll _mina = MAX, _minb = MAX;

    REP(i, A){
        cin >> a[i];
        _mina = min(_mina, a[i]);
    }
    REP(i, B){
        cin >> b[i];
        _minb = min(_minb, b[i]);
    }
    REP(i, M){
        ll _x, _y, _c;
        cin >> _x >> _y >> _c;
        _x--; _y--;
        x[i] = _x; y[i] = _y; c[i] = _c;
    }

    ll _min = _mina + _minb;
    REP(i, M){
        ll tmp = a[x[i]] + b[y[i]] - c[i];
        _min = min(_min, tmp);
    }
    cout << _min << endl;
  
    
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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

typedef long long int ll;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    
    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n1 = Number(lines.shift());
  const arr1 = lines.shift().split(' ').map(Number);
  const n2 = Number(lines.shift());
  const arr2 = lines.shift().split(' ').map(Number);

  const solve = memoization(function(i, m) {
    if (m == 0) return true;
    if (i >= n1) return false;
    return solve(i + 1, m) || solve(i + 1, m - arr1[i]);
  });

  arr2.map(m => solve(0, m) ? 'yes' : 'no').forEach(res => console.log(res));
})();

function memoization(f) {
  var cache = {};
  function innerFunc(...param) {
    let c = cache[param];
    if (typeof c !== 'undefined') {return c;}
    return cache[param] = f(...param);
  }
  return innerFunc;
}



Measured memory_bytes: 24404
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
char map[505][505];
int def[505][505];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
vector<int>to[200005];
ll a[100005];
ll b[100005];

ll keisan(ll x,ll y) {
	if (x % y == 0) {
		return 0;
	}
	ll k = x / y+1;
	return  y * k - x;
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	ll sum = 0;
	ll ans = 0;
	for (int i = n - 1; i > 0; i--) {
		ll x;
		x= keisan(a[i], b[i]);
		ans += x;
		sum += x;
		a[i - 1] += sum;
	}
	cout << ans + keisan(a[0],b[0])<< endl;
	return 0;
}
	
	

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
using namespace std;
const int M = 1e9+7;
 
int gcd(int a, int b) {
    return b == 0? a:gcd(b, a%b);
}

int gcdt(int a, int b, int c) {
    return gcd(a, gcd(b, c));
}

long long qpow(long long a, long long p) {
    long long ret = 1;
    for (; p; p >>= 1) {
        if (p & 1) ret = (ret * a) % M;
        a = (a * a) % M;
    }
    return ret;
}

int main()
{
    int a, b, c;
    int n, k;
    cin >> n >> k;
    long long ans[200005] = {0}, sum = 0;
    for (int i = k; i >= 1; --i) {
        ans[i] = qpow((int)k/i, n);
        // cout << ans[i] <<' ' << k/i << ' ' << n << endl;
        for (int t = 2; t * i <= k; ++t) {
            ans[i] = (ans[i] + M - ans[t*i]) % M;
        }
        sum = (sum + (ans[i] * i) % M) % M;
    }
    // for (int i = 1; i <= k; ++i) {
    //     cout << ans[i] << ' ';
    // }
    // cout << endl;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

int main()
{
    string str;
    int w;

    cin>>str;
    cin>>w;

    int len = (int) str.length();

    for(int i = 0; i < len; i++){
        if(i % w == 0){
            cout<<str[i];
        }
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
int n;
int S[MAX];
int binarySearch(int);
int main(){
  int q;
  int T[50000];
  int i,j;
  int count=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    if(binarySearch(T[i])==1)
      count++;
  }
  printf("%d\n",count);

  return 0;
}

int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(S[mid]==key){
      return 1;
    }
    else if(key<S[mid]){
      right=mid;
    }
    else {
      left=mid+1;
    }
  }
  return 0;
}

Measured memory_bytes: 1184
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=1e6+10;
	
	int a[N],mx[N];
	int dec[N];
	void main()
	{
		int n=qread();int pre=INF;int ans=0;
		fo(i,1,n)
		{
			int now=qread();ans+=now<=pre;
			chmin(pre,now);
		}write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}

Measured memory_bytes: 384
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  def next(): String = sc.next()
  def nextInt(): Int = next().toInt
  def nextLong(): Long = next().toLong

  def task(): Unit = {
    val n = nextInt()
    val ps = Seq.fill(n)(nextInt())
    val max = ps.max
    println(ps.sum - max + max / 2)
  }

  task()
}


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

int main(){
    int n;
    cin >>n;
    int d[n];
    rep(i,n){
        cin >> d[i];
    }
    int ans = 0;
    rep(i,n){
        REP(j,i,n){
            if(i!=j){
                ans += d[i]*d[j];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();


	public void run() {
		int[] hc=new int[1500010];
		int[] wc=new int[1500010];
		while(true){
			int W=sc.nextInt(),H=sc.nextInt();
			if(W==0 && H==0)return;

			int[] w=nextIntArray(W);
			int[] h=nextIntArray(H);

			Arrays.fill(hc,0);
			Arrays.fill(wc,0);

			for(int i=0;i<H;i++){
				int s = 0;
				for(int j=i;j<H;j++){
					s+=h[j];
					hc[s]++;
				}
			}
			for(int i=0;i<W;i++){
				int s = 0;
				for(int j=i;j<W;j++){
					s+=w[j];
					wc[s]++;
				}
			}

			int res=0;
			for(int i=1;i<1500010;i++){
				res+=hc[i]*wc[i];
			}

			ln(res);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 73984
#include <bits/stdc++.h>
using namespace std;
int main() {
	long int n; cin >> n;
	long long int a;
	long long int x[200005];
	long long int s = 0;
	for(long int i=0;i<n;i++){
		cin >> a;
		s += a;
		x[i] = s;
	}
	long long int ans = 1000000000000000005;
	for(long int i=0;i<n-1;i++){
		ans = min(abs(2*x[i]-s), ans);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

long long a, b, c, mx;

int main () {
	cin >> a >> b >> c;
	mx = max(a, max(b, c));
	if(mx == a) {
		cout << (a - a / 2) * b * c - a / 2 * b * c;
	}
	else if(mx == b) {
		cout << (b - b / 2) * a * c - b / 2 * a * c;
	}
	else if(mx == c) {
		cout << (c - c / 2) * b * a - c / 2 * b * a;
	}
	return 0;
}

Measured memory_bytes: 256
#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;
/*
         ########     ########   ########   #########   ##       #######   ##       #######
         #      #     #      #   #      #       #       # #      #     #   # #      #     #
         #      #     #      #   #      #       #       #  #     #     #   #  #     #     #
         ########     #      #   #      #       #       #   #    #     #   #   #    #     #
         ###          #      #   #      #       #       #    #   #######   #    #   #######
         #  #         #      #   #      #       #       #   #    #     #   #   #    #     #
         #   #        #      #   #      #       #       #  #     #     #   #  #     #     #
         #    #       #      #   #      #       #       # #      #     #   # #      #     #
         #     #      ########   ########       #       ##       #     #   ##       #     #     
*/

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define ll unsigned long long int
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
    rootdada;

    long long int n;
    cin >> n;
    vector<long long> a(n);
    rep(i, 0, n)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    __int128 ans = 1;
    rep(i, 0, n)
    {
        ans *= a[i];
        if (ans > 1000000000000000000)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << (long long int)(ans) << endl;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int a, b, _;
  cin >> a >> b >> _;
  cout << (a * b) / 2 << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.txt","r",stdin);
 	// freopen("out2.txt","w",stdout);
 	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int n ;
		cin >> n ;
		if(n&1){
			cout << n/2 <<endl;
		}
		else
			cout <<n/2-1 <<endl;


	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                
using namespace std;
int i, N, A, B, tmp, P[3];
int main(void){
	cin >> N >> A >> B;

	for(i = 0; i < N; i++){
		cin >> tmp;
		if(tmp <= A) P[0]++;
		else if(tmp <= B) P[1]++;
		else P[2]++;
  }
  
	//sort(P, P+2);
	//cout << P[0] << endl;
	cout <<min(P[0],min(P[1],P[2]))<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int Q, H, S, D;
  double N;
  cin >> Q >> H >> S >> D >> N;
  H = min(H, 2*Q);
  S = min(S, 2*H);
  S = min(S, 4*Q);
  D = min(D, 2*S);
  D = min(D, 4*H);
  D = min(D, 8*Q);
  long long int total = 0;
  while(N>=2){
    N-=2;
    total+=D;
  }
  while(N>=1){
    N-=1;
    total+=S;
  }
  while(N>=0.5){
    N-=0.5;
    total+=H;
  }
  while(N){
    N-=0.25;
    total+=Q;
  }
  cout << total << "\n";
  return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
ks_list = [list(map(int,input().split())) for i in range(M)]
p_list = list(map(int, input().split()))

all_list = []
for i in range(2**N):
    all_list.append([])
    num_str = bin(i)[2:]
    if len(num_str) < N:
        for j in range(N - len(num_str)):
            all_list[i].append(0)
    for k in range(len(num_str)):
        all_list[i].append(int(bin(i)[2:][k]))


ans_num = 0
a = 0
for ans in all_list:#答えのこうほ
    flag = True

    for i, ks in enumerate(ks_list):# 条件
        middle_ans = 0
        for j in range(1,len(ks)):
            
            middle_ans += ans[ks[j]-1]
        
        if middle_ans % 2 == p_list[i]:
            a += 1
        else:
            flag = False
        
    if flag == True:
        ans_num += 1
print(ans_num)

Measured memory_bytes: 3188
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
nums = map(int, input().split(" "))

out = 0
for i, num in enumerate(nums):
    if i == 0:
        cur_max = num
    else:
        if cur_max > num:
            out += cur_max - num
        else:
            cur_max = num

print(out)

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while (1) {
    a -= d;
    c -= b;
    if (c <= 0) {
      cout << "Yes";
      break;
    } else if (a <= 0) {
      cout << "No";
      break;
    }
  }
}

Measured memory_bytes: 3592
from heapq import*
i=input
for s in[0]*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r)
 for x in x,y:
  x.sort();n=len(x);h=[(0,0)]*n*2
  while h:
   while[[n]]<x[-1:]:k,l,r=x.pop();heappush(h,(r-l,l,r))
   s+=heappop(h)[~(n>0)];n-=1
 print(s)

Measured memory_bytes: 49536
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var ans = arrayOfNulls<Int>(n)
    val a = readLine()!!.split(" ").map(String::toInt)
    repeat(n){ ans[a[it] -1] = it + 1 }
    println(ans.joinToString(separator = " "))
}

Measured memory_bytes: 58240
using System;
using System.Linq;

namespace ABC054
{
    class B
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];

            string[] A = new string[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = Console.ReadLine();
            }

            string[] B = new string[M];
            for (int i = 0; i < M; i++)
            {
                B[i] = Console.ReadLine();
            }

            string sb;
            string sa;
            int indexA = 0;
            int indexB = 0;
            bool isMatch = false;
            int count = 0;
            for (int i = 0; i < N - M + 1; i++)
            {
                sb = B[indexB];
                indexA = i;
                for (int j = 0; j < N - M + 1; j++)
                {
                    sa = A[i].Substring(j, sb.Length);
                    while (sa == sb && indexB < M && indexA < N)
                    {
                        count++;
                        sa = A[indexA].Substring(j, sb.Length);
                        sb = B[indexB];
                        indexA++;
                        indexB++;
                    }
                    if (indexB == M) { isMatch = true; }

                    indexB = 0;
                    if (isMatch) break;
                }
                if (isMatch) break;
            }

            if (isMatch) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;
//0632
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt(), r = sc.nextInt(), count = 0, a[][] = new int[h+1][w+1], b[][] = new int[h+1][w+1];
        char[][] t=new char[h][w];
        for(int i=1;i<=h;i++) {
            t[i-1]=sc.next().toCharArray();
            for(int j=1;j<=w;j++) {
                if(t[i-1][j-1]=='#')continue;
                a[i][j]=a[i-1][j]+1;
                b[i][j]=b[i][j-1]+1;
                if(a[i][j]>=r)count++;
                if(b[i][j]>=r)count++;
            }
        }
        System.out.println(count);
    }
}


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

int keisan(int x) {
  int ret_val = 0;
  while (x > 0) {
    ret_val += x % 10;
    x /= 10;
  }

  return ret_val;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int Ans = 0;

  for (int i=1; i<=N; i++) {
    int temp = keisan(i);
    if ((A <= temp) && (temp <= B)) Ans += i;
  }

  cout << Ans << endl;
}


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
     ifstream in("input.txt");
     cin.rdbuf(in.rdbuf());
  //*/
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << min(A, B) + min(C, D) <<endl;
}


Measured memory_bytes: 3592
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
p = [min(a) + min(b)]
for _ in range(M):
    x,y,c = map(int,input().split())
    p.append(a[x-1]+b[y-1]-c)

print(min(p))

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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=10;
int a[N];
int b[N];
int c[N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",a+i);
    for(int i=0;i<n;i++)scanf("%d",b+i);
    bool q=1;    int x,y;
    for(int i=0;i<n;i++)c[i]=i+1;

    for(int i=0;i<n;i++){
        if(a[i]!=c[i])
            q=0;
    }
    if(q)
        x=1;
    q=1;
    for(int i=0;i<n;i++){
        if(b[i]!=c[i])
            q=0;
    }
    if(q)
        y=1;
    int cnt=1;
    while(next_permutation(c,c+n)){
            cnt++;
    bool q=1;
        for(int i=0;i<n;i++){
            if(a[i]!=c[i])
                q=0;}
        if(q)
            x=cnt;
        q=1;
        for(int i=0;i<n;i++){
            if(b[i]!=c[i])
                q=0;
        }
        if(q)
            y=cnt;
    }
    cout<<abs(x-y);
}


Measured memory_bytes: 3656
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let l = line[1] as u64;

    let a: Vec<u64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut pos = None;
    for i in 0..n-1 {
        if a[i] + a[i+1] >= l {
            pos = Some(i);
            break;
        }
    }

    if let Some(p) = pos {
        println!("Possible");
        for i in 0..p {
            println!("{}", i+1);
        }
        for i in (p+1..n-1).rev() {
            println!("{}", i+1);
        }
        println!("{}", p+1);

    } else {
        println!("Impossible");
    }
}


Measured memory_bytes: 8444
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int a,b;
    cin>>a>>b;
    if(a<b){
        for(int i=0;i<b;i++){
            cout<<a;
        }
        cout<<endl;
    }
    else{
        for(int i=0;i<a;i++){
            cout<<b;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define LLIandI pair<long long int , int>
#define ll long long

int main(){
    int A,B,K;
    scanf("%d %d %d",&A,&B,&K);
    rep(i,K/2){
        if(A%2==1)A-=1;
        A/=2;B+=A;
        if(B%2==1)B-=1;
        B/=2;A+=B;
    }
    if(K%2==1){
        if(A%2==1)A-=1;
        A/=2;B+=A;
    }
    printf("%d %d\n",A,B);
    return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()

	s := make([][]int,m)
	for i := 0; i < m; i++ {
		k := scanInt()
		s[i] = scanInts(k)
	}

	p := scanInts(m)

	ans := 0
	bitExhaustiveSearch(n, func(a []bool) {
		f := true
		for i := 0; i < m; i++ {
			c := 0
			for _, e := range s[i] {
				if a[e-1] {
					c++
				}
			}

			if c%2 != p[i] {
				f = false
			}
		}

		if f {
			ans++
		}
	})

	fmt.Fprintln(wr, ans)
}


func bitExhaustiveSearch(n int, fn func(a []bool)) {
	all := 1 << uint(n)
	a := make([]bool, n)
	for i := 0; i < all; i++ {
		for j := 0; j < n; j++ {
			if i >> uint(j) & 1 == 1 { a[j] = true } else { a[j] = false }
		}
		fn(a)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int main(){
    int n, d;
    cin >> n >> d;
    cout << (n + 2 * d) / (2 * d + 1) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  string s,t;
  cin >> s;
  cin >> t;
  bool ok=false;
  int l=s.length();
  for(int i=0;i<l;++i) {
    if(s==t) {
      ok=true;
      break;
    }
    s=s.back()+s.substr(0,l-1);
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int q,l,r,a[100005]={},b[100005]={};
  cin >> q;
  a[2]=1;
  for(int i=3; i<=100000; i+=2) {
    int cnt=0;
    for(int j=2; j*j<=i; j++) {
      if(i%j==0) {
        cnt++;
      }
    }
    if(cnt==0) {
      a[i]=1;
    }
  }
  for(int i=3; i<=100000; i+=2) {
    if(a[i]&&a[(i+1)/2]) {
      b[i]=1;
    }
  }
  for(int i=1; i<=100000; i++) {
    b[i]+=b[i-1];
  }
  while(q--) {
    cin >> l >> r;
    cout << b[r]-b[l-1] << endl;
  }
  
}



Measured memory_bytes: 1408
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        k: i32,
        x: i32
    }

    let result = if k * 500 >= x {
        "Yes"
    } else {
        "No"
    };
    println!("{}", result)
}


Measured memory_bytes: 2128
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	cin >> n;
	string ans = "APPROVED";
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 2 == 0 && (a % 3 && a % 5))ans = "DENIED";
	}
	cout << ans << endl;


	return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d){
    cout <<"Yes"<<endl;
  }else if(abs(a-b)<=d&&abs(b-c)<=d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    cout << d.at(n / 2) - d.at(n / 2 - 1) << endl;
    return 0;
}


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

int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    int no;
    cin >> no;
    cout << arr[--no] << endl;
    return 0;
}

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

using namespace std;

#define ll long long




void solve() {

	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2;

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
int main(){
  long long int n;
  scanf("%lld",&n);
  int a[200],i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int count=0;
  while(1){
    for(i=0;i<n;i++){
      if(a[i]%2==0) a[i]/=2;
      else {printf("%d",count);return 0;}
    }
    count++;
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll sum=0, ss;
    vector<int> s;
    int n;
    cin >> n;
    rep(i, n){
        cin >> ss;
        s.push_back(ss);
        sum += ss;
    }

    sort(s.begin(), s.end());

    if(sum%10 == 0){
        for(auto ss : s){
            if(ss%10 != 0){
                cout << sum-ss << endl;
                return 0;
            }
        }
    }else{
        cout << sum << endl;
        return 0;
    }

    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
using namespace std;
int main(void){
    unsigned long long q, h, s, d, n, hmin, smin, dmin;
    
    cin >> q >> h >> s >> d;
    cin >> n;
    
    if (h < q * 2) hmin = h;
    else hmin = q * 2;
    
    if (s < hmin * 2) smin = s;
    else smin = hmin * 2;
    
    if (d < smin * 2) dmin = d;
    else dmin = smin * 2;
    
    cout << (n / 2) * dmin + (n % 2) * smin << endl;;
    return 0;
}



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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int n;
int x[24],y[24],r[24],c[24];

inline bool intersect(int p, int q)
{
    double dist=sqrt((x[p]-x[q])*(x[p]-x[q])+(y[p]-y[q])*(y[p]-y[q]));
    return dist<(r[p]+r[q]);
}

inline bool available(int p, int state)
{
    rep(i,p)
    {
        if(state>>i&1 && intersect(p,i)) return false;
    }
    return true;
}

unordered_map<int,int> dp;
int dfs(int state)
{
    if(dp.find(state) != dp.end()) return dp[state];
    if(__builtin_popcount(state)<2) return 0;

    int ret=0;
    rep(i,n)
    {
        if(state>>i&1)
        {
            if(!available(i,state)) continue;

            rep(j,n)
            {
                if(i==j) continue;
                if(c[i]!=c[j]) continue;

                if(state>>j&1)
                {
                    if(!available(j,state)) continue;
                    ret = max(ret,dfs(state-(1<<i)-(1<<j))+2);
                }
            }
        }
    }

    return dp[state]=ret;
}

int main()
{
    while(cin >>n,n)
    {
        rep(i,n) scanf(" %d %d %d %d", &x[i], &y[i], &r[i], &c[i]);
        dp.clear();
        cout << dfs((1<<n)-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 43952
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i,s,e) for (int64_t i=s; i<e; i++)
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main(){
  int X, N, i=0;
  cin >> X >> N;
  vector<int> p(N);
  rep(i,0,N) {
    cin >> p[i];
  }
  while(true) {
    int A=X-i, B=X+i;
    bool a=true, b=true;
    rep(i,0,N) {
      if(A==p[i]){
        a=false;
      }
    }
    if(a){
      cout << A << endl;
      return 0;
    }
    rep(i,0,N) {
      if(B==p[i]){
        b=false;
      }
    }
    if(b){
      cout << B << endl;
      return 0;
    }
    i++;
  }
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;

int n, k;
vector<int> arr;

void solve() {
  // number of ways to disrtibute k candies
  vector<int> dp1(k+1), dp2(k+1);
  dp1[0] = 1;
  for (int i=0; i<n; ++i) {
    vector<int> pre(k+2);
    for (int j=0; j<=k; ++j) {
      pre[j+1] = (pre[j] + dp1[j]) % MOD;
    }
    for (int j=k; ~j; --j) {
      dp2[j] = (pre[j+1] - pre[max(0, j-arr[i])]) % MOD;
    }
    swap(dp1, dp2);
  }
  cout << (dp1[k] + MOD) % MOD;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  arr = vector<int>(n);
  for (int i=0; i<n; ++i) {
    cin >> arr[i];
  }
  solve();
  return 0;
}

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

using namespace std;
typedef long long ll;


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

#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

#define PB push_back //vectorヘの挿入
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

ll n;vector<vector<ll>> vw;vector<vector<ll>> dp;
ll c1,c2;

void dfs(ll i){
    if(i==1){
        dp[i-1][vw[i-1][1]]=vw[i-1][0];
    }else{
        ll j=i/2;
        FORD(k,c2,0){
            if(dp[j-1][k]!=0 or k==0){
                ll ne=k+vw[i-1][1];
                if(ne<=c2)dp[i-1][ne]=max(dp[j-1][k]+vw[i-1][0],dp[i-1][ne]);
            }
            dp[i-1][k]=dp[j-1][k];
        }
    }
    if(i*2<=min(c1,n))dfs(i*2);
    if(i*2+1<=min(c1,n))dfs(i*2+1);
}

signed main(){
    cin>>n;
    vw.resize(n);
    REP(i,n){ll x,y;cin>>x>>y;vw[i]={x,y};}
    c1=1<<10;c2=100000;
    dp.resize(c1);REP(i,c1)dp[i].resize(c2+1);
    dfs(1);
    REP(i,c1)REP(j,c2)dp[i][j+1]=max(dp[i][j],dp[i][j+1]);
    ll q;cin>>q;
    REP(i,q){
        ll v,l;cin>>v>>l;
        vector<ll> cand;
        while(v>c1){
            cand.PB(v);
            v=v/2;
        }
        ll r=SIZE(cand);
        ll ans=0;
        REP(j,1<<r){
            ll v_sub=0;ll w_sub=0;
            REP(k,r){
                if((j>>k)&1){
                    v_sub+=vw[cand[k]-1][0];
                    w_sub+=vw[cand[k]-1][1];
                }
            }
            if(w_sub<=l)ans=max(ans,dp[v-1][l-w_sub]+v_sub);
        }
        cout<<ans<<endl;
    }
}


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

using namespace std;


long long dp[123][123456];

int main() {
	int N;
	int W;
	cin >> N >> W;
	
	vector<int> w(N);
	vector<long long> v(N);
	memset(dp, -1, sizeof dp);

	for(int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}

	dp[0][w[0]] = v[0];

	for(int i = 1; i < N; i++) {
		dp[i][w[i]] = v[i];
		for(int u = 0; u <= W; u++) {
			if(dp[i][u]==-1) dp[i][u] = dp[i-1][u];
			if(u > w[i] and dp[i-1][u-w[i]] > 0)
				dp[i][u] = max(dp[i][u], dp[i-1][u-w[i]] + v[i]);
		}
	}
	long long res = -1;

	for(int i = 0; i <= W; i++) {
		res = max(res, dp[N-1][i]);
	}
	cout << res << endl;

}


Measured memory_bytes: 118912
import java.util.*;
import java.lang.Math;

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

  		
      	int h = sc.nextInt();
      	int n = sc.nextInt();
      	int dm = 0;
      	String str = "No";
      
      	for(int i = 0;i < n && h > 0;i++) {
			h -= sc.nextInt();        
        }
      	
      	if(h <= 0) str = "Yes";      	
      	
      	System.out.println(str);
        
	}
}


Measured memory_bytes: 58552
#include <iostream>
#include <map>
#include <vector>
#include <cstring>

using namespace std;

constexpr int MAX = 514;
constexpr int UNVISITED = (1 << 25);

struct Edge {
    int to, cost;
    Edge() {}
    Edge(int to, int cost) :
        to{to}, cost{cost} {}
};

vector<Edge> G[MAX];
int dist[MAX];

bool dfs(int v, int p, int d)
{
    if (dist[v] != UNVISITED) {
        return (dist[v] != d);
    }
    
    dist[v] = d;
    for (const auto& g : G[v]) {
        if (g.to == p) continue;
        if (dfs(g.to, v, d + g.cost)) {
            return true;
        }
    }
    return false;
}

bool run()
{
    int N;
    cin >> N;
    if (N == 0) {
        return false;
    }

    for (int i = 0; i < MAX; i++) {
        G[i].clear();
    }
    
    int n = 0;
    map<string, int> s2i;
    
    string t, u, v;
    for (int i = 0; i < N; i++) {
        cin >> u >> u;

        if (s2i.count(u) == 0) {
            s2i[u] = n++;
        }
        
        cin >> t >> t >> v;
        t = t.substr(3);

        if (s2i.count(v) == 0) {
            s2i[v] = n++;
        }
        
        int num = stoi(t);        
        G[s2i[v]].emplace_back(s2i[u], -num);
        G[s2i[u]].emplace_back(s2i[v], num);
    }
   
    bool ok = 1;
    for (int i = 0; i < n; i++) {
        fill(dist, dist + MAX, UNVISITED);
        if (dfs(i, -1, 0)) {
            ok = 0;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return true;
}

int main()
{
    while (run())
        ;
    return 0;
}

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

int main() {
  string s,t;
  cin>>s;
  cin>>t;
  int a=s.length(),b=t.length(),p=b;
 for(int i=0;i<a-b+1;i++){
   int count=b;
	for(int j=i;j<i+b;j++){
	if(s.substr(j,1)==t.substr(j-i,1)){
      count-=1;
   }
    }
   if(p>=count){
     p=count;
   }
 }
   cout<<p<<endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#define sqr(x) (x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len) {char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
int n,m,i,j,cnt,dis[1100005],vis[100005],x,y,z,fa[100005];
vector<pair<int,int> > bi[1000005];
vector<int> all[1000005],bi2[1100005];
queue<int> qx;
int find(int x)
{
	if (fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
int main()
{
	cin>>n>>m;
	cnt=n;
	fz1(i,m)
	{
		cin>>x>>y>>z;
		bi[z].push_back(make_pair(x,y));
		all[z].push_back(y);
		all[z].push_back(x);
	}
	fz1(i,1000000)
	{
		sort(all[i].begin(),all[i].end());
		all[i].resize(unique(all[i].begin(),all[i].end())-all[i].begin());
		ff(all[i],it)
		{
			fa[*it]=*it;
		}
		ff(bi[i],it)
		{
			fa[find(it->first)]=find(it->second);
		}
		map<int,int> mp;
		ff(all[i],it) mp[find(*it)]=1;
		ff(mp,it) it->second=++cnt;
		ff(all[i],it)
		{
			bi2[*it].push_back(mp[find(*it)]);
			bi2[mp[find(*it)]].push_back(*it);
		}
	}
	memset(dis,22,sizeof(dis));
	qx.push(1);
	dis[1]=0;
	while (!qx.empty())
	{
		int x=qx.front();qx.pop();
		ff(bi2[x],it)
		{
			if (dis[*it]>dis[x]+1)
			{
				dis[*it]=dis[x]+1;
				qx.push(*it);
			}
		}
	}
	if (dis[n]>=0x16161616) cout<<-1<<endl; else cout<<dis[n]/2<<endl;
	return 0;
}

Measured memory_bytes: 99712