akhauriyash/Code-Regression huggingface dataset:
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

struct LazySegmentTree {
private:
	int n;
	vector<LL> node, lazy;
public:
	LazySegmentTree(int sz) {
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1, INF<int>());
		lazy.resize(2 * n - 1, -1);
	}

	void eval(int k, int l, int r) {
		if (lazy[k] != -1) {
			node[k] = lazy[k];;
			if (k < n - 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
			}
			lazy[k] = -1;
		}
	}

	void add(int a, int b, LL x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			eval(k, l, r);
		}
		else {
			add(a, b, x, 2 * k + 1, l, (l + r) / 2);
			add(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	LL getmin(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		if (b <= l || r <= a) return INF<int>();
		if (a <= l && r <= b) return node[k];
		LL vl = getmin(a, b, 2 * k + 1, l, (l + r) / 2);
		LL vr = getmin(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	LazySegmentTree seg(n);
	REP(i, q) {
		int k, s, t, x;
		cin >> k;
		if (k == 0) {
			cin >> s >> t >> x;
			seg.add(s, t + 1, x);
		}
		else {
			cin >> s >> t;
			cout << seg.getmin(s, t + 1) << endl;
		}
	}
}


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

using namespace std;
using llong = long long;

llong N,A,B;

int main(){
  cin >> N >> A >> B;
  
  llong m = B-A;
  llong pat = (N-2)*m+1;
  if(pat<0){
    cout << 0 << endl;
  }else{
    cout << pat << endl;
  }
  return 0;
}

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

struct Node {
  int key;
  Node *right,*left,*parent;
};

Node *root, *NIL;

Node *find(Node *u,int k) {
  while (u!=NIL && k!=u->key) {
    if (k<u->key) {
      u=u->left;
    } else {
      u=u->right;
    }
  }
  return u;
}
void insert(int k) {
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while (x!=NIL) {
    y=x;
    if (z->key<x->key) {
      x=x->left;
    } else {
      x=x->right;
    }
  }
  z->parent=y;
  if (y==NIL) {
    root=z;
  } else {
    if (z->key<y->key) {
      y->left=z;
    } else {
      y->right=z;
    }
  }
}
void inorder(Node *u) {
  if (u==NIL) {
    return;
  }
  inorder(u->left);
  cout<<" "<<u->key<<flush;
  inorder(u->right);
}
void preorder(Node *u) {
  if (u==NIL) {
    return;
  }
  cout<<" "<<u->key<<flush;
  preorder(u->left);
  preorder(u->right);
}
int main() {
  int n;
  scanf("%d",&n);
  string com;
  int x;
  for (int i=0; i<n; i++) {
    cin>>com;
    if (com=="find") {
      scanf("%d",&x);
      Node *t=find(root,x);
      if (t!=NIL) {
        cout<<"yes"<<endl;
      } else {
        cout<<"no"<<endl;
      }
    } else if (com=="insert") {
      scanf("%d",&x);
      insert(x);
    } else if (com=="print") {
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    }
  }
  return 0;
}




Measured memory_bytes: 21852
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    
    int a, b, c;
    
    cin >> a >> b >> c;
    
    int K;
    
    cin >> K;
    
    int list[3] = {a, b, c};
    int maxNum = max({a, b, c});
    
    long bi = 1;
    for(int i=0; i<K; i++) {
        bi *= 2;
    }
    
    long result = 0;
    bool already = false;
    for(int num : list) {
        if(num == maxNum && !already) {
            result += num * bi;
            already = true;
        }
        else {
            result += num;
        }
    }
    
    cout << result << "\n";
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front

typedef long long ll;

using namespace std;

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

vector <vector<int>> edge;
vector<int> du,dv;

void dfs(int now,int par,int d,int uv){
    if(uv == 0)du[now] = d;
    else dv[now] = d;
    for(int nxt : edge[now]){
        if(nxt == par)continue;
        else dfs(nxt, now, d+1, uv);
    }
}

int main(){
    int N,u,v;
    cin>>N>>u>>v;
    u--;v--;
    edge.resize(N);
    int a,b;
    rep(i,0,N-1){
        cin>>a>>b;
        a--;b--;
        edge[a].PB(b);
        edge[b].PB(a);
    }

    du.resize(N);dv.resize(N);
    du[u]=0;dv[v]=0;
    dfs(u, -1, 0, 0);
    dfs(v, -1, 0, 1);
    int max_d=0;
    rep(i,0,N){
        if(du[i]< dv[i])max_d = max(max_d, du[i]+(dv[i]-du[i]-1));
    }
    cout<<max_d;
    return 0;
}

Measured memory_bytes: 11648
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}




  int main()
  {
      fast;
      ll n,W;
      cin>>n>>W;
      ll w[n+1],v[n+1];
      for(int i=1;i<=n;i++)
      {
      	  cin>>w[i]>>v[i];
      	  
      }
      ll dp[n+1][W+1];
      ll ans=0;
      memset(dp,0,sizeof(dp));
      for(int i=1;i<=n;i++)
      {
      	  for(int j=1;j<=W;j++)
      	  {   
      	  	  if(j>=w[i])
      	  	  dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]); 
      	  	  else
      	  	  dp[i][j]=dp[i-1][j];    

      	  	  ans=max(ans,dp[i][j]);
      	  }
      	 
      }

       
      cout<<ans<<endl; 


        
  }




Measured memory_bytes: 79232
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,cnta=0,cntb=0,cntc=0;
    char s[10],t[10],u[10];
    scanf("%s%s%d%d%s",s,t,&a,&b,u);
    for(int i=0;u[i]!='\0';i++){
        if(s[i]==u[i])cnta++;
        else if(t[i]==u[i])cntb++;
        cntc++;
    }
    if(cntc==cnta)printf("%d %d\n",a-1,b);
    else printf("%d %d\n",a,b-1);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(void) {
	double x1, y1, x2, y2, xq, yq, xr, yr;
	
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF) {
		double a, b, c; //a,b,cはそれぞれ辺P1P2,P1Q,P2Q
		double cos, sin; //求める角は角QP1P2
		a = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
		b = sqrt((x1-xq)*(x1-xq) + (y1-yq)*(y1-yq));
		c = sqrt((xq-x2)*(xq-x2) + (yq-y2)*(yq-y2));
		cos = (a*a + b*b - c*c) / (2*a*b);
		sin = sqrt(1 - cos*cos);
		
		//P1を中心にP2を回転、長さを調整
		xr = ((x2-x1)*cos - (y2-y1)*sin) * b/a + x1;
		yr = ((x2-x1)*sin + (y2-y1)*cos) * b/a + y1;
		
		//逆回転させた場合Qと一致するので、修正
		if(abs(xr - xq) < 0.000001 && abs(yr - yq) < 0.000001) {
			sin = -sin;
			xr = ((x2-x1)*cos - (y2-y1)*sin) * b/a + x1;
			yr = ((x2-x1)*sin + (y2-y1)*cos) * b/a + y1;
		}
		
		printf("%.6lf %.6lf\n", xr, yr);
	}
	
	return 0;
}


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

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    int r = 0;

    cin >> r;

    cout << 2 * r * 3.141592 << endl;
}


Measured memory_bytes: 3760
# coding: utf-8

import sys
from collections import deque

n = int(input())

task_name = (
    "insert",
    "delete",
    "deleteFirst",
    "deleteLast",
)

a = deque()

for task in map(lambda x: [x] if x in task_name else x.split(), sys.stdin.readlines()):
    #deleteFirst,deleteLast
    if len(task) == 1:
        if task[0] == "deleteFirst":
            a.popleft()
        else:
            a.pop()

    #insert,delete
    else:
        if task[0] == "insert":
            a.appendleft(task[1])
        elif task[1] in a:
            a.remove(task[1])

print(*a)

Measured memory_bytes: 214328
#include "iostream"
#include <algorithm>
#include <stdlib.h>
#include <cstring>
using namespace std;
using ll=long long;

int main(int argc, char const *argv[]) {
  string a,b;
  std::cin >> a >> b;

  int i=0,j=0,k=0,m;
  m=a.size() + b.size();

  while(i<m){
    if(i%2==0){
      std::cout << a[j];
      j++;
    }

    else{
      std::cout << b[k];
      k++;
    }
    i++;
  }

	std::cout <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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; }
const long long INF = 1LL << 60;

int main(){
  string w;
  cin >> w;
  sort(ALL(w));
  int n = w.size();
  if(n % 2 == 1){
    cout << "No" << endl;
    return 0;
  }

  bool flag = true;
  for(int i = 0; i < n-1; i+=2){
    if(w.at(i) != w.at(i+1)){
      flag = false;
      break;
    }
  }
  cout << (flag? "Yes": "No") << endl;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define cout4(x, y, z, w)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << ", " << #w << ": " << w << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n;
    cin1(n);
    lli f[n][10];
    REP(i,0,n) {
        REP(j,0,10) {
            cin >> f[i][j];
            //cout3(i,j,f[i][j]);
        }
    }
    lli p[n][11];
    REP(i,0,n) {
        REP(j,0,11) {
            cin >> p[i][j];
            //cout3(i,j,p[i][j]);
        }
    }

    lli ans = -LLONG_MAX;
    REPE(state,1,(1<<10)-1) {
        // i の bit が立っている部分が営業している時間
        // その営業時間の時に各店から得られる利益を計算する
        lli benefit = 0;
        REP(shop, 0, n) {
            lli bit = state;
            lli i = 0;
            lli count = 0;
            REP(i,0,10) {
                if (bit == state) {
                    //cout3(shop, i, f[shop][i]);
                }
                if ((bit & 1) & f[shop][i]) {
                    //cout2(bit, i);
                    count++;
                }
                bit >>= 1;
            }
            benefit += p[shop][count];
            //cout4(state, shop, count, p[shop][count]);
        }
        ans = max(ans, benefit);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void) {
  int n, m, x;
  int a[100];
  int l=0, r=0;
  cin>>n>>m>>x;
  for(int i=0; i<m; i++) {
    cin>>a[i];
  }
  for(int i=0; i<m; i++) {
    if(a[i]<x) l++;
    else r++;
  }
  cout<<min(l, r)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int _=5e5+20;
ll n,L,x[_],y[_],sx[_],sy[_],ans;
ll f(int l,int r){ return sx[r]-sx[l-1];}
ll g(int l,int r){ return sy[r]-sy[l-1];}
void solve(){
	ans=max(ans,x[n]);
	for(int i=1;i<=(n>>1);++i){
		int A=i,B=i,no=n-A-B;
		ans=max(ans,x[no]+x[no+B]+(f(no+1,no+B-1)+g(no+B+1,n))*2);
		ans=max(ans,y[no+B+1]+(f(no+1,no+B)+g(no+B+2,n))*2);
		if(i*2+1<=n){
			A=i+1;B=i;no=n-A-B;
			ans=max(ans,x[no]+y[no+B+1]+(f(no+1,no+B)+g(no+B+2,n))*2);
			A=i;B=i+1;no=n-A-B;
			ans=max(ans,x[no+B]+(f(no+1,no+B-1)+g(no+B+1,n))*2);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin>>L>>n;
	for(int i=1;i<=n;++i)cin>>x[i],sx[i]=x[i];
	for(int i=1;i<=n;++i)sy[i]=y[i]=L-x[i];
	for(int i=1;i<=n;++i)sx[i]+=sx[i-1],sy[i]+=sy[i-1];
	solve();reverse(x+1,x+n+1);reverse(y+1,y+n+1);swap(x,y);
	for(int i=1;i<=n;++i)sx[i]=sx[i-1]+x[i],sy[i]=sy[i-1]+y[i];
	solve();cout<<ans<<endl;
	return 0;
}



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    ll beki[45];
    beki[0] = 1;
    for(int i = 1; i <= 42; i++){
        beki[i] = beki[i - 1] * 2;
    }
    ll n;
    cin >> n;
    ll k;
    cin >> k;
    ll a[1005];
    ll sum[1005];
    sum[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
    }
    vector<ll> combi;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j <= n; j++){
            combi.push_back(sum[j] - sum[i]);
            //cout << sum[j] - sum[i] << endl;
        }
    }
    ll minimum = 0;
    for(int i = 42; i >= 0; i--){
        ll now = beki[i];
        int count = 0;
        for(int j = 0; j < combi.size(); j++){
            if((combi[j] & minimum) != minimum) continue;
            if((combi[j] & now) > 0) {
                count++;
                //cout << combi[j] << " " << beki[i] << endl;
            }
        }
        if(count >= k) {
            minimum += now;
            //cout << now << endl;
        }
    }
    cout << minimum << endl;
    return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;
const ll mod = INF + 7;

int main(){
  int n, m;
  cin >> n >> m;

  vector<bool> oks(n+1, true);
  rep(i, m){
    int a;
    cin >> a;
    oks[a] = false;
  }

  vector<ll> dp(n+1);
  dp[0] = 1;
  rep(now, n){
    REP(next, now+1, min(n, now+2)){
      if(oks[next]){
        dp[next] += dp[now];
        dp[next] %= mod;
      }
    }
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 85
#define maxSum (2 * N * N)

using namespace std;

const int del = maxSum + 105;

int n, m;
int a[N][N];
bool f[2][N][maxSum * 2 + 500];

int main() {
	cin >> n >> m;
	
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			cin >> a[i][j];
	for(int i = 1; i <= n; ++i)
		for(int j = 1, d; j <= m; ++j)
			cin >> d, a[i][j] -= d;
	
	int u = 0, v = 1;
	f[0][1][a[1][1] + del] = true;
	for(int i = 2; i < n + m; ++i) {
		memset(f[v], 0, sizeof f[v]);
		for(int x = 1, y; x <= n; ++x) {
			y = i - x;
			if(y < 1 || y > m) continue;
			if(x + 1 <= n) {
				for(int o = -maxSum; o <= maxSum; ++o)
					if(f[u][x][o + del]) {
						f[v][x + 1][o + a[x + 1][y] + del] = true;
						f[v][x + 1][o - a[x + 1][y] + del] = true;
					}
			}
			if(y + 1 <= m) {
				for(int o = -maxSum; o <= maxSum; ++o)
					if(f[u][x][o + del]) {
						f[v][x][o + a[x][y + 1] + del] = true;
						f[v][x][o - a[x][y + 1] + del] = true;
					}
			}
		}
		swap(u, v);
	}
	
	int ans = INT_MAX;
	for(int i = -maxSum; i <= maxSum; ++i)
		if(f[u][n][i + del] && abs(i) < ans)
			ans = abs(i);
			
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5120
t = int(input())

count = 0
hasIs = False
while t > 0:
  s = input().split(" ")
  if s[0] == s[1]:
    count +=1
  else:
    count  = 0
  if count  >= 3:
    hasIs =True
    break
  t-=1
if hasIs:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9196
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_set>
#include <queue>
#include <unordered_map>
#include <set>

#pragma GCC optimize("O3")

using namespace std;
using ll = long long;
using ull = unsigned long long;

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repd(i, n) for(ll i = (n) - 1; i >= 0; --i)
#define FOR(i, a, b) for(ll i = a; i <= ll(b); ++i)
#define FORD(i, a, b) for(ll i = a; i >= ll(b); --i)
#define asort(array, size) std::sort(array, array + size)
#define cauto const auto&
#define bit(n) (1LL << (n))

int main()
{
    string S, T;
    cin >> S >> T;
    int min = T.size();
    rep(i, S.size() - T.size() + 1) {
        int count = T.size();
        rep(j, T.size()) {
            if (S[i + j] == T[j]) --count;
        }
        if (min > count) min = count;
        if (min == 0) break;
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<cmath>
#include<utility>
#include<cstdlib>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iomanip>
using namespace std;                       

#define ll long long
#define pb push_back
#define mp make_pair

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const ll M = 1e9 + 7;
int N = 1e5 + 4;
vector<int> tree(N, 0);

int read(int idx) {
  int sum = 0;
  while (idx > 0) {
    sum += tree[idx];
    idx -= (idx & -idx);
  }
  return sum;
}

void update(int idx, int val) {
  while (idx <= N) {
    tree[idx] += val;
    idx += (idx & -idx);
  }
}

int readSingle(int idx) {
  int sum = tree[idx];
  if (idx > 0) {
    int z = idx - (idx & -idx);
    idx--;
    while (idx != z) { 
      sum -= tree[idx];
      idx -= (idx & -idx);
    }
  }
  return sum;
}

int bs(vector<int> &a, int lo, int hi, int key){
    if(lo == hi){
        if(key < a[lo]) return 0;
        return lo;
    }
    if(lo + 1 == hi){
        if(key >= a[hi]) return hi;
        if(key < a[lo]) return 0;
        return lo;
    }
    int mi = (lo+hi)/2;
    if(key >= a[mi]){
        return bs(a, mi, hi, key);
    }
    return bs(a, lo, mi, key);
}

int main(){
    // clock_t time_req;
    // time_req = clock();
    fastio;
    char a;
    cin>>a;
    if(a >= 'a' && a <= 'z'){
        cout<<'a'<<endl;
    }
    else{
        cout<<"A"<<endl;
    }
    // time_req = clock()-time_req;
    // cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
    return 0;
}

Measured memory_bytes: 3660
import math
from functools import lru_cache

ls_gcd  = [[None for _ in range(201)] for _ in range(201)]
for i in range(201):
    for j in range(201):
        ls_gcd[i][j] = math.gcd(i,j)

# def gcd(a,b,c):
#     # ab = math.gcd(a,b)
#     # abc = math.gcd(ab,c)
#     ab = ls_gcd[a][b]
#     abc = ls_gcd[ab][c]
#     return abc

K = int(input())
ans = 0
for i in range(K):
    for j in range(K):
        ab = ls_gcd[i+1][j+1]
        t = ls_gcd[ab]
        for k in range(K):
            ans += t[k+1]
print (ans)

Measured memory_bytes: 9904
#include <algorithm>
#include <iostream>
#include <vector>

int main(void) {
    int n;
    std::cin >> n;

    std::vector<int> vec{};
    for (int i = 1; i <= n; ++i) vec.push_back(i);

    do {
        for (auto iter = vec.begin(); iter != vec.end(); ++iter) {
            std::cout << *iter;
            if (iter != vec.end() - 1) std::cout << ' ';
        }
        std::cout << std::endl;
    } while (std::next_permutation(vec.begin(), vec.end()));
}


Measured memory_bytes: 3124
#include <iostream>
#include <queue>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <cmath>
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int, int>
#define ppi pair<pair<int, int>, int>
#define mp make_pair
#define show(v) for(int i : v)cout << i << " ";cout << endl;

using namespace std;
typedef long long ll;
int inf = 1e9;
const int N = 2e5 + 5;
ll a[N], b[N];

int main(){
    faster
    ll n, m, k;
    cin >> n >> m >> k;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for(int i = 1;i <= m;i++){
        cin >> b[i];
        b[i] += b[i - 1];
    }
    ll ans = 0;
    ll j = m;
    for(ll i = 0;i <= n;i++){
        if(a[i] > k)break;
        while(b[j] > k - a[i])
            j--;
        ans = max(ans, j + i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6308
def resolve():
    n, m = map(int, input().split())
    a = [list(map(int, input().split())) for i in range(m)]
    a = [[x, y, -z] for x, y, z in a]
    print(BF(a, n, 1)[-1])


def BF(p, n, s):
    inf = float("inf")
    d = [inf for i in range(n)]
    d[s-1] = 0
    for i in range(n+1):
        for e in p:
            if e[0] != inf and d[e[1]-1] > d[e[0]-1]+e[2]:
                d[e[1]-1] = d[e[0]-1] + e[2]
        if i == n-1:
            t = d[-1]
        if i == n and t != d[-1]:
            return [0, 'inf']
    return list(map(lambda x: -x, d))


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3700
#include <iostream>
#include<cmath>

using namespace std;

void Solution()
{
//    int a1, a2, a3, a4;
//    int b1, b2, b3, b4;
//    
//    int a[2][4] = {a1, a2, a3, a4, b1, b2, b3, b4};
    
    int a[4];
    int b[4];
    
    while(cin>>a[0]>>a[1]>>a[2]>>a[3])
    {
        int hit = 0;  // should define hit and below inside the loop, otherwise, it can be accumulated
        int blow = 0;
        
        cin>>b[0]>>b[1]>>b[2]>>b[3];
        
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                if(a[i] == b[j])
                {
                    if (i == j)
                    {
                        hit++;
                    }
                    
                    if(i != j)
                    {
                        blow++;
                    }
                }
                else
                    continue;
            }
        }
        
        cout<<hit<<" "<<blow<<endl;
    }
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1160
///
// File:  d.cpp
// Author: ymiyamoto
//
// Created on Sat Oct 14 21:55:52 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<pair<int64_t, int64_t>> points;
static vector<int64_t> xs;
static vector<int64_t> ys;

int32_t main()
{
  uint32_t N, K;
  cin >> N >> K;

  for (uint32_t i = 0; i < N; i++) {
    int64_t x, y;
    cin >> x >> y;
    points.push_back({x, y});
    xs.push_back(x);
    ys.push_back(y);
  }

  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());

  int64_t area = INT64_MAX;

  for (int32_t i = 0; i < (int32_t)xs.size(); i++) {
    for (int32_t j = 0; j < (int32_t)ys.size(); j++) {
      for (int32_t k = xs.size() - 1; k >= i; k--) {
        for (int32_t l = ys.size() - 1; l >= j; l--) {
          uint32_t count = 0;
          for (uint32_t m = 0; m < points.size(); m++) {
            if (xs[i] <= points[m].first && points[m].first <= xs[k] && ys[j] <= points[m].second && points[m].second <= ys[l]) {
              count++;
            }
          }
          if (count >= K) {
            area = min(area, abs(xs[i] - xs[k]) * abs(ys[j] - ys[l]));
          }
        }
      }
    }
  }

  cout << area << endl;
  return 0;
}


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n) for (int i = 1; i < n; i++)

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

#define mod (int)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, i;
  cin >> n >> i;

  cout << n - i + 1 << endl;

  return 0;
}


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

int main() {
  
  int N, Q;
  cin >> N >> Q;
  
  int64_t num = N-2;
  num *= num;
  
  int d, n, f, s;
  f = 0;
  vector<int> V(1,N), H(1,N);
  
  for (int i = 0; i < Q; i++) {
    cin >> d >> n;
    
    if (f == 0) {
      f = d;
    }
    if (f == 1) {
      d = abs(d-3);
    }
    
    if (d == 2) {
      s = H.size();
      int a = 0, b = s;
        
      while (a+1 != b) {
        if (H.at((a+b)/2) < n) {
          b = (a+b)/2;
        }
        else {
          a = (a+b)/2;
        }
      }
      
      if (b < s) {
        num -= V.at(b-1)-2;
      }
      else {
        if (s == V.size()) {
          num -= V.at(s-1)-2;
          H.push_back(n);
        }
        else {
          num -= V.at(s-2)-2;
          H.at(s-1) = n;
        }
      }
      
    }
    else {
      s = V.size();
      int a = 0, b = s;
      
      while (a+1 != b) {
        if (V.at((a+b)/2) < n) {
          b = (a+b)/2;
        }
        else {
          a = (a+b)/2;
        }
      }
      
      if (b < s) {
        num -= H.at(b)-2;
      }
      else {
        if (s + 1 == H.size()) {
          num -= H.at(s)-2;
          V.push_back(n);
        }
        else {
          num -= H.at(s-1)-2;
          V.at(s-1) = n;
        }
      }
      
    }
    
    
  }                                  

  
  cout << num << endl; 

return 0;
}


Measured memory_bytes: 3660
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long double r;
	cin >> r;
	cout << fixed << setprecision(20) << 2 * PI * r << "\n";
	return 0;
}


Measured memory_bytes: 3812
st='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
h,w=map(int,input().split())
s = [input().split() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == 'snuke':
            print(st[j],i+1,sep='')
            exit()


Measured memory_bytes: 38256
const MOD = Int(10^9+7)

function mpow(a, n)
    res = 1
    for i = 1:n
        res *= a
        res %= MOD
    end
    return res
end

function solve()
    N = parse(Int, readline())
    res = mpow(10, N) - mpow(9, N) - mpow(9, N) + mpow(8, N)
    println((res%MOD + MOD)%MOD)
end

solve()


Measured memory_bytes: 159112
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int A,B;
    string S;
    cin >> A >> B >> S;
    for(int i = 0;i < S.length();i++){
        if(i == A){
            if(S[i] != '-')break;
            continue;
        }
        if(S[i] == '-')break;
        if(i == S.length()-1){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MOD 1000000007

int main(){
  int N,M,S,T;
  cin>>N>>M;
  Graph G(N);
  for(int i=0;i<M;i++){
    int u,v;
    cin>>u>>v;
    u--;v--;
    G.at(u).push_back(v);
  }
  cin>>S>>T;
  S--,T--;
  vector<vector<int>> visit(N,vector<int>(3,-3));
  queue<pair<int,int>> q;
  q.push(make_pair(S,0));
  visit.at(S).at(0)=0;
  while(!q.empty()){
    int v=q.front().first;
    int i=q.front().second;
    for(auto nv :G.at(v)){
      if(visit.at(nv).at((i+1)%3)==-3){
        visit.at(nv).at((i+1)%3)=visit.at(v).at(i)+1;
        q.push(make_pair(nv,(i+1)%3));
      }
    }
    q.pop();
  }

  cout<<visit.at(T).at(0)/3<<endl;
}


Measured memory_bytes: 11136
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

vector<int> tov(string s){
  vector<int> v(128);
  for(auto e:s){
    v[e]++;
  }
  sort(begin(v),end(v));
  return v;
}

int main(){
  int n;
  cin>>n;
  string S;
  cin>>S;
  string T;
  cin>>T;
  auto sv=tov(S);
  auto tv=tov(T);
  int ans=0;
  for(int i=0;i<sv.size();i++){
    ans+=abs(sv[i]-tv[i]);
  }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 1528
#include <stdio.h>
int main(void){
  int i,co=0;
  int judge=0;
  int n;
  int a[200];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  while(1){
    for(i=0;i<n;i++){
      if(a[i]%2){
	judge=1;
	break;
      }
      a[i]=a[i]/2;
    }
    if(judge) break;
    co++;
  }
  printf("%d\n",co);
  return(0);
}


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


int main(void){
    string s;
    cin>>s;
    bool flag=0;
    for(int i=0;i<s.size();i++){
        //cout<<s[i]<<endl;
        //cout<<i<<endl;
        if(s[i]=='d'){
            if(s[i+7]=='a' || s.size()<i+7 || s[i+5]=='d'){
                //cout<<"dream"<<endl;
                if(s.substr(i, 5) != "dream")flag=1;
                //dream
                i+=4;
            }
            else{
                //cout<<"dreamer"<<endl;
                //dreamer
                if(s.substr(i, 7) != "dreamer")flag=1;
                i+=6;
            }            
        }
        else if(s[i]=='e'){
            if(s[i+5]=='r'){
                //eraser
                if(s.substr(i, 6) != "eraser")flag=1;
                //cout<<"eraser"<<endl;
                i+=5;
            }
            else{
                //erase
                if(s.substr(i, 5) != "erase")flag=1;
                //cout<<"erase"<<endl;
                i+=4;
            }
        }
    }
    if(flag) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26



int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
     
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 0; i < 1e7; i++){
      if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
        cout << i << endl;
        return 0;
      }
      int cur_a = (b + c) / 2;
      int cur_b = (a + c) / 2;
      int cur_c = (b + a) / 2;
      a = cur_a, b = cur_b, c = cur_c;
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a,int b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
int main(){
ios::sync_with_stdio(false);
	int gcda=0,maxa=0;
	int n,r,x;
	cin>>n>>r;
	for(int i=0;i<n;i++){
		cin>>x;
		gcda=gcd(gcda,x);
		maxa=max(maxa,x);
	}
	if(maxa>=r&&r%gcda==0)printf("POSSIBLE");
	else printf("IMPOSSIBLE");
	return 0;
}

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

int main()
{
int a,b,c,k,m=0;
cin>>a>>b>>c>>k;
//while(k==0)
{
    if(k>=a){
    k-=a;
    m+=a;
    if(k>=b)
    k-=b;
    if(k<=0){
   
        exit;
    }
    if(k>=c)
    {
        k-=c;
        m-=c;
    }
        else
        {
            m-=k;
        }
    }
    else
    {
        m+=k;
    }
}
  cout<<m;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define T int t = 0; cin >> t; while(t--)
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef  long double lld;
const ll mod = 1e9 + 7;
const ll mx = 1e5 + 1;
const ll inf = 1e13;
ll memo[10001][1001];
vector<ll>a(1001), b(1001);
ll solve(ll h, ll n){
    if(h <= 0)return 0LL;
    if(n < 0)return inf;
    if(memo[h][n] != -1)return memo[h][n];
    return memo[h][n] = min(b[n] + min(solve(h - a[n], n), solve(h - a[n], n - 1)), solve(h, n - 1));
}
void input(){
    memset(memo, -1, sizeof(memo));
    ll h, n;
    scanf("%lld%lld", &h, &n);
    f(i, n) cin >> a[i] >> b[i];
    cout << solve(h, n - 1) << endl;

}
int main(){
    input();
    return 0;
}


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

using namespace std;

int main(){
	long N, k;
	long sum=0;
	cin>>N;
	vector<int> A(N);
	for(int i=0; i<N; i++){
		cin>>A[i];
		sum+=A[i];
	}
	if(sum%(N*(N+1)/2)!=0){
		cout<<"NO"<<endl;
		return 0;
	}
	k=sum/(N*(N+1)/2);

	for(int i=0; i<N; i++){
		if(abs(A[(i+1)%N]-A[i]-k)%N!=0 || (A[(i+1)%N]-A[i]-k)>0){
			cout<<"NO"<<endl;
			return 0;
		}
	}

	cout<<"YES"<<endl;

	return 0;
}


Measured memory_bytes: 640
import sys
def f0070(A,n,s):
  if n==1:
    if s in A: return 1
    else: return 0
  c=0
  A=sorted(A)
  A1=A[:n][::-1]
  A2=A[-n:]
  N=range(n)
  b1=sum([(i+1)*A1[i] for i in N])
  b2=sum([(i+1)*A2[i] for i in N])
  if s<b1 or s>b2: return 0
  for i in range(len(A)):
    b=s-A[i]*n
    c+=f0070(A[:i]+A[i+1:],n-1,b)
  return c

for a in sys.stdin:
  c=0
  n,s=map(int,a.split())
  c=f0070(range(10),n,s)
  print c

Measured memory_bytes: 4260
#include<stdio.h>
int main(void){
  int x=0;
  int n;
  char s[n];
  int i;
 // int j,k;
  int t=0;
  scanf("%d",&n);
  scanf("%s",s);
  for(i=0;i<n;i++){

   
    if(s[i]=='I'){
      x++;
      if(x>t){
        t=x;
      }
    }
    else if(s[i]=='D'){
      x--;
    }
  }
  printf("%d",t);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main() 
{
  int S, W;
  scanf("%d", &S) ;
  scanf("%d", &W) ;
  if((S>=1||S<=100) &&(W>=1||W<=100)) 
  {
    if(S<=W) 
    {printf("unsafe") ;}
    else
    {printf("safe") ;}
  }
}

Measured memory_bytes: 1736
#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 998244353
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;

// dp[0][i][j] : 合計がiになる場合の数
li dp[2][3030];

li b[3030];
li a[3030];

int main() {
    b[0] = 1;
    repp(i, 1, 3030) {
        b[i] = b[i - 1] * 2 % MOD;
    }

    li n, s;
    cin >> n >> s;
    dp[0][0] = 1;
    rin{
        cin >> a[i];
        for (li j = s; j >= a[i]; j--) {
            dp[1][j] = (dp[0][j - a[i]] + dp[0][j] * 2) % MOD;
        }
        rep(j, a[i]) {
            dp[1][j] = (dp[0][j] * 2) % MOD;
        }
        swap(dp[0], dp[1]);
    }
    cout << dp[0][s] << endl;

    return 0;
}

Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var points = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
            Console.WriteLine(points.Max() - points.Min());
        }
    }
}

Measured memory_bytes: 13524
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: x[0]+x[1], reverse=True)

taka = ao = 0

for i in range(N):
    if i%2==0:
        taka += AB[i][0]
    else:
        ao += AB[i][1]
print(taka-ao)


Measured memory_bytes: 33836
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; 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 rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
int c[27];
int s[366][27];
int last[26];

ll evaluate(int day, int t) {
  ll score = 0;
  score += s[day][t];
  rep(j, 26) {
    if(t == j)continue;
    score -= c[j] * (day+1 - last[j]);
  }
  return score;
}

vi greedy(int d) {
  vi t(d);
  rep(i, d) {
    ll score = -100100100;
    int tt = -1;
    rep(j,26){
      ll tmp = evaluate(i,j);
      if(tmp>score){
        score = tmp;
        tt = j;
      }
      //show(score);
    }
    //cout<<"----"<<endl;
    t[i] = tt;
    //last[t[i]] = i;
  }
  return t;
}

int main() {
  int d;
  cin >> d;
  rep(i, 26) cin >> c[i];
  rep(i, d) rep(j, 26) cin >> s[i][j];
  auto t = greedy(d);
  rep(i,d)cout<<t[i]+1<<endl;
  return 0;
}

Measured memory_bytes: 3664
/* author   : mpily :-()
title : Competing.cpp
time :Sun Apr 26 15:01:19 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	double a ,b,c,d;
	cin >> a >> b >> c >>d;
	if(ceil(c /b) <= ceil(a/d)){
		//cout << ceil(c/b);
		//cout << ceil(a/d);
		cout << "Yes\n";	
	}
	else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 3720
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007ll
//作者:中国江苏南京丁天行
using namespace std;
int n,x,y,ans;
ll f[605][605],g[605][605],h[605][605];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            char c;
            scanf(" %c",&c);
            f[i][j]=f[i+n][j]=f[i][j+n]=f[i+n][j+n]=c-96;
        }
    }
    for(int i=1;i<=n*2;++i){
        for(int j=1;j<=n;++j){
            for(int k=0;k<n;++k)g[i][j]=g[i][j]*31ll+f[i][j+k];
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            for(int k=0;k<n;++k)h[i][j]=h[i][j]*orz+g[i+k][j];
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n*2;++j){
            g[i][j]=0;
            for(int k=0;k<n;++k)g[i][j]=g[i][j]*31ll+f[i+k][j];
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            ll o=0;
            for(int k=0;k<n;++k)o=o*orz+g[i][j+k];
            if(o==h[i][j])++ans;
        }
    }
    printf("%d\n",ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;



int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS

    string s,t;
    cin >> s >> t;

    int ans = t.size();


    for(int i = 0; i + t.size()-1< s.size(); i++)
    {
    	string sub = s.substr(i,t.size());
    	int ans1 = 0;

    	for(int i = 0; i < sub.size(); i++)
    	{
    		if(sub[i] != t[i])
    		{
    			ans1++;
    		}
    	}

    	ans = min(ans,ans1);
    }


    cout << ans;



    return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=200200;
int n,u,o[N],sz[N],fa[N];
ll t,a[N],su[N];
map<ll,int>h;
bool cmp(int x,int y){return a[x]>a[y];}
int main(){
	scanf("%d",&n);
	FOR(i,1,n) scanf("%lld",&a[i]),h[a[i]]=o[i]=i,sz[i]=1;
	sort(o+1,o+n+1,cmp);
	FOR(i,1,n-1){
		u=o[i];t=a[u]+2*sz[u]-n;
		if(!h.count(t) || h[t]==u || fa[h[t]]) return puts("-1"),0;
		sz[fa[u]=h[t]]+=sz[u];
		su[fa[u]]+=su[u]+sz[u];
	}
	if(su[o[n]]!=a[o[n]]) return puts("-1"),0;
	FOR(i,1,n)if(fa[i]) cout<<i<<' '<<fa[i]<<'\n';
}

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

#define int long long

#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trrep(i, n) for(int i = (n); i >= 0; i--)

bool u[1111];

int count(int x, int n) {
  if(x % n) {
    return 0;
  }
  return count(x / n, n) + 1;
}

signed main() {
  int n;
  cin >> n;
  trep(i, n) {
    u[i] = true;
  }
  int ans = 1;
  for(int i = 2; i <= n; i++) {
    if(u[i]) {
      int now = 0;
      for(int j = i; j <= n; j += i) {
        now += count(j, i);
        u[j] = false;
      }
      ans = (ans * (now + 1)) % 1000000007;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int key, i, j, len, a[101];
  scanf("%d", &len);
  for(i = 0;i < len;i++) scanf("%d", a + i);
 
  for(j = 1;j < len;j++){
    for(i = 0;i < len;i++) printf(i != 0 ? " %d":"%d", a[i]);
    puts("");
    key = a[j];
    for(i = j - 1;i >= 0 && a[i] > key;i--) a[i + 1] = a[i];
    a[i + 1] = key;
  }
 
  for(i = 0;i < len;i++) printf(i != 0 ? " %d": "%d", a[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 1928
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n / 2; ++ i) {
        if (s[i] != s[n - 1 - i]) ans ++;
    }
    cout << ans;
    
}

Measured memory_bytes: 256