akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  using P = function<E(E,size_t)>;
  int n;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  P p;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(int n_,F f,G g,H h,T ti,E ei,
	      P p=[](E a,size_t b){return a;}):
    f(f),g(g),h(h),ti(ti),ei(ei),p(p){
    init(n_);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
    laz.assign(2*n-1,ei);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(int len,int k){
    if(laz[k]==ei) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=ei;
  }
  T update(int a,int b,E x,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(int a,int b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return ti;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(int a,int b){
    return query(a,b,0,0,n);
  }
  void update(int k,T x){
    query(k,k+1);//evaluate
    k+=n-1;
    dat[k]=x;
    while(k){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
};
//END CUT HERE
signed main(){
  int n,q;
  cin>>n>>q;
  SegmentTree<int,int> ch(n,
			  [](int a,int b){return a+b;},
			  [](int a,int b){return a+b;},
			  [](int a,int b){return a+b;},
			  0,0,
			  [](int a,int b){return a*b;});
  ch.build(n,vector<int>(n,0));
  for(int i=0;i<q;i++){
    int c,s,t,x;
    cin>>c;
    if(c){
      cin>>s>>t;
      cout<<ch.query(s-1,t)<<endl;
    }else{
      cin>>s>>x;
      ch.update(s-1,s,x);
    }
  }
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int a, b, c;
    cin >> a >> b >> c;

    vector<int> arr({a, b, c});
    sort(arr.begin(), arr.end());

    cout << ((arr[0] * arr[1]) / 2) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    map<int, int> same; // same==1 -> ok
    map<int, int> y;
    rep(i, n) {
        same[a[i]]++;
        int k = a[i];
        while (k <= a[n - 1]) {
            k += a[i];
            y[k]++;
        }
    }
    int cnt = 0;
    rep(i, n) if (same[a[i]] == 1 && y[a[i]] == 0) cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 64164
#include<stdio.h>
#include<string.h>

int main() {
	int k;
	char s[101];
	scanf("%d", &k);
	scanf("%s", &s);
	if (k >= strlen(s)) {
		printf("%s", s);
	}
	else {
		s[k] = '\0';
		printf("%s...", s);
	}
}

Measured memory_bytes: 2148
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>

using namespace std;

#define n 4
#define n2 16
#define LIM 100

static const int dx[4]={0, -1, 0, 1};
static const int dy[4]={1, 0, -1, 0};
static const char dir[4]={'r', 'u', 'l', 'd'};
int MDT[n2][n2];

struct puz {int f[n2], space, MD; };

puz state;
int limit;
int path[LIM];

int getAllMD(puz pz){
  int sum=0;
  for(int i=0 ; i<n2 ; i++){
    if(pz.f[i]==n2)continue;
    sum+=MDT[i][pz.f[i]-1];
  }
  return sum;
}

bool isSolved(){
  for(int i ; i<n2 ; i++)if(state.f[i]!=i+1)return false;
  return true;
}

bool dfs(int depth, int prev){
  if(state.MD==0)return true;
  if(depth+state.MD>limit)return false;
  int sx=state.space/n;
  int sy=state.space%n;
  puz tmp;
  for(int r=0 ; r<4 ; r++){
    int tx=sx+dx[r];
    int ty=sy+dy[r];
    if(tx<0 || ty<0 || tx>=n || ty>=n)continue;
    if(max(prev, r)-min(prev, r)==2)continue;
    tmp=state;
    state.MD-=MDT[tx*n+ty][state.f[tx*n+ty]-1];
    state.MD+=MDT[sx*n+sy][state.f[tx*n+ty]-1];
    swap(state.f[tx*n+ty], state.f[sx*n+sy]);
    state.space=tx*n+ty;
    if(dfs(depth+1,r)){path[depth]=r; return true; }
    state=tmp;
  }
  return false;
}

string indep(puz in){
  in.MD=getAllMD(in);
  for(limit=in.MD ; limit<=LIM ; limit++){
    state=in;
    if(dfs(0, -100)){
      string ans="";
      for(int i=0 ; i<limit ; i++)ans+=dir[path[i]];
      return ans;
    }
  }
  return "unsolvabe";
}

int main(){
  for(int i=0 ; i<n2 ; i++)
    for(int j=0 ; j<n2 ; j++)
      MDT[i][j]=abs(i/n-j/n)+abs(i%n-j%n);
  puz in;
  for(int i=0 ; i<n2 ; i++){
    cin>>in.f[i];
    if(in.f[i]==0){
      in.f[i]=n2;
      in.space=i;
    }
  }
  string ans=indep(in);
  cout<<ans.size()<<endl;
  return 0;
}




Measured memory_bytes: 3196
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
const int N=1e5+7;
ll n,m,x,y,k,ans;
int main(){
    fast;
    string s;
    char t[20];
    cin>>s;
    forn(i,4) t[i]=s[i];
    t[4]=' ';
    for(int i=4;i<12;i++){
        t[i+1]=s[i];
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 256
l,r = map(int,input().split())
if r-l >=2018:
  print(0)
else:
  l_ = l%2019
  r_ = r%2019
  if l_ > r_:
    print(0)
  else:
    t = 2019
    for i in range(l_,r_+1):
      for j in range(l_,r_+1):
        hoge = (i*j)%2019
        if i != j:
          t = min(t,hoge)
        
    print(t)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;


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

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 10000000000+7;
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};

ll GCD(ll a, ll b){
    if(b==0) return a;
    return GCD(b, a%b);
}


//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
ll N, K;
string s;
ll v[51];

int main(void) {
    cin >> N >> K;
    
    ll cnt=0;
    if(K==0) cout << N*N << endl;
    else {
        for(ll i=K+1; i<=N; ++i){
        cnt += N/i*max(ll(0), i-K) + max(ll(0), N%i-K+1);
        }
        cout << cnt << endl;
    }
    
	return 0;
}

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

int main() {
int x,n;
cin>>x>>n;
if(n==0)
cout<<x<<endl;

else{
	int p[n];
	
	for(int i=0;i<n;i++)
	cin>>p[i];
	
	int hash[102]={0};
	
	for(int i=0;i<n;i++)
	hash[p[i]]++;
	
	int ahead,behind;
	for(int i=x;i<102;i++)
	{
		if(hash[i]==0)
		{
			ahead=i;
			break;
		}
	}
	for(int i=x;i>=0;i--)
	{
		
		if(hash[i]==0)
		{
			behind=i;
			break;
		}
	}
	
	if(x-behind<=ahead-x)
	cout<<behind<<endl;
	else
	cout<<ahead<<endl;
}
return 0;
}

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

int main() {
	int N;
	cin >> N;
	for(int i = 0; i < N; i++) {
		double xa, ya, ra, xb, yb, rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double distance;
		distance = sqrt((xa - xb)*(xa - xb) + (ya - yb)*(ya - yb));
		if(distance > ra + rb) cout << "0" << endl;
		else if(distance < rb - ra && distance > ra - rb) cout << "-2" << endl;
		else if(distance < ra - rb && distance > rb - ra) cout << "2" << endl;
		else cout << "1" << endl;  
	}

	return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int a,int b){return a>b;}
int main(){
	int n,k;
	cin>>n>>k;
	int a[n+1],ans=0;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=k;i++) ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
alphabet = "abcdefghijklmnopqrstuvwxyz"

from collections import defaultdict
d = defaultdict(int)
for i in range(N):
    s = input()
    num = 0
    sorted(alphabet)
    for i,a in enumerate(alphabet):
        if s.count(a) == 10:
            continue #アナグラムはない
        num += s.count(a)*10**i
    d[num] += 1

ans = 0

for key in d.keys():
    ans += d[key]*(d[key]-1)//2
print(ans)

Measured memory_bytes: 75864
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int e;
        cin >> e;
        if(e == 0)
            return 0;

        int ret = INT_MAX;
        for(int z=0; z*z*z<=e; ++z){
            for(int y=0; y*y<=e-z*z*z; ++y){
                int x = e - z*z*z - y*y;
                ret = min(ret, x + y + z);
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1160
//jinhaonan
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void read(T &x){
	x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	x=f?-x:x;
}
template<class T>inline void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
template<class T>inline bool chkmax(T &a,T const &b){
	return a<b?a=b,1:0;
}
template<class T>inline bool chkmin(T &a,T const &b){
	return a>b?a=b,1:0;
}
const int N=1000+10;
long long x[N],y[N];
long long d[40];
void Main(){
	int n;read(n);
	bool flag[2]={false,false};
	for(int i=1;i<=n;++i){
		read(x[i]),read(y[i]);
		// cout<<((x[i]+y[i])&1)<<'\n';
		flag[(x[i]+y[i])&1]=1;
	}
	if(flag[0]&&flag[1]){
		puts("-1");
		return;
	}
	int m=31;
	for(int i=0;i<m;++i){
		d[i]=1ll<<i;
	}
	reverse(d,d+m);
	if(flag[0]){
		d[m]=1;
		write(m+1),putchar('\n');
		for(int i=0;i<=m;++i){
			write(d[i]),putchar(i==m?'\n':' ');
		}
	}else{
		write(m),putchar('\n');
		for(int i=0;i<m;++i){
			write(d[i]),putchar(i==m-1?'\n':' ');
		}
	}
	for(int i=1;i<=n;++i){
		if(flag[0]){
			--x[i];
		}
		for(int j=0;j<m;++j){
			bool u=y[i]+x[i]>0,v=y[i]-x[i]>0;
			if(u&&v){
				putchar('U');
				y[i]-=d[j];
			}else if(!u&&!v){
				putchar('D');
				y[i]+=d[j];
			}else if(u&&!v){
				putchar('R');
				x[i]-=d[j];
			}else if(!u&&v){
				putchar('L');
				x[i]+=d[j];
			}
		}
		assert(x[i]==0&&y[i]==0);
		if(flag[0]){
			putchar('R');
		}
		putchar('\n');
	}
}
int main(){
    // freopen("in.txt","r",stdin);
    // int test;read(test);
    // while(test--){
        Main();
    // }
    return 0;
}

Measured memory_bytes: 256
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

ll binpow(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
			res=res*a;
		a=a*a;
		b>>=1;
	}
	return res;
}

int main()
{
	fast;
    
	ll h;
	cin>>h;
	if(h and !( h & (h-1) ))//h is a power of 2
	{
		ll sum=0;
		ll i=0;
		while(binpow(2,i)<=h)
		{
			sum+=binpow(2,i);
			i++;
		}
		cout<<sum<<endl;
	}
	else
	{
		ll temp=(ll)log2(h);
		h=binpow(2,temp);
		//cout<<h<<" "<<temp<<" ";
		ll i=0,sum=0;
		while(binpow(2,i)<=h)
		{
			sum+=binpow(2,i);
			i++;
		}
		cout<<sum<<endl;
	}
}
//Goodbye...

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

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

  if(n>=2100){
    cout<<1<<endl;
  }
  else if(n>99 && n<106){
    cout<<1<<endl;
  }
  else if(n>199 && n<211){
    cout<<1<<endl;
  }
  else if(n>299 && n<316){
    cout<<1<<endl;
  }
    else if(n>399 && n<421){
    cout<<1<<endl;
  }
    else if(n>499 && n<526){
    cout<<1<<endl;
  }
    else if(n>599 && n<631){
    cout<<1<<endl;
  }
    else if(n>699 && n<736){
    cout<<1<<endl;
  }
    else if(n>799 && n<841){
    cout<<1<<endl;
  }
    else if(n>899 && n<946){
    cout<<1<<endl;
  }
    else if(n>999 && n<1051){
    cout<<1<<endl;
  }
    else if(n>1099 && n<1156){
    cout<<1<<endl;
  }
    else if(n>1199 && n<1261){
    cout<<1<<endl;
  }
    else if(n>1299 && n<1366){
    cout<<1<<endl;
  }
    else if(n>1399 && n<1471){
    cout<<1<<endl;
  }
    else if(n>1499 && n<1576){
    cout<<1<<endl;
  }
    else if(n>1599 && n<1681){
    cout<<1<<endl;
  }
    else if(n>1699 && n<1786){
    cout<<1<<endl;
  }
    else if(n>1799 && n<1891){
    cout<<1<<endl;
  }
    else if(n>1899 && n<1996){
    cout<<1<<endl;
  }
    else if(n>1999){
    cout<<1<<endl;
  }
    else{
    cout<<0<<endl;
  }
  
  return(0);
  


}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc158/tasks/abc158_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll A, B;
  cin >> A >> B;

  rep(num, 2000) {
    if (num * 8 / 100 == A && num * 10 / 100 == B) drop(num);
  }

  drop(-1);
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>
#include <algorithm>

int main(){
  long long int N, tmp;
  scanf("%lld", &N);
  std::vector<long long int> order(N);
  
  for(long long int i = 1; i <= N; i++){
    scanf("%lld", &tmp);
    order[tmp-1] = i;
  }
  for(long long int i = 0; i < N; i++){
    std::cout << order[i] << " ";
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vst;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;


const ll mod=1e9+7;
const ll inf=1e16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 ll n;
  cin >> n;
  vll p(n);
  map<ll,ll> mp;
  rep(i,0,n) {
    cin >> p[i];
    mp[p[i]]++;
  }
  bool flag=true;
  for(auto p:mp) if(p.second>1) flag=false;
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}


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

int main()
{
  int a,b,C;
  cin >> a >> b >> C;
  double Crad = C / 180.0 * M_PI;
  double cosC = cos(Crad);
  double sinC = sin(Crad);
  double c;
  c = sqrt( a*a + b*b -2*a*b*cosC);
  double L = a+b+c;
  double h = ( C == 90 ? b : ( sinC * b ) );
  double S = (a * b / 2.0) * sinC;
  printf("%.11lf\n", S);
  printf("%.11lf\n", L);
  printf("%.11lf\n", h);
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

//#define int long long

const ll MOD=1e9+7;
const ll INF=(1LL<<31)-1;
const double pi=acos(-1);
const double eps=1e-10;

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

class SquareDivision{
    private:
        const int BUCKET_SIZE=256;
        ll N, B;
        vector<ll> data, bucket_sum, bucket_min;

    public:
        void prepare(int n){
            B=(n+BUCKET_SIZE-1)/BUCKET_SIZE;
            N=B*BUCKET_SIZE;
            data.assign(N, INF);
            bucket_min.assign(B, INF);
        }

        void add(int x, int y){
            ll k=x/BUCKET_SIZE;
            data[x]+=y;
            int sum=0;
            for(int i=k*BUCKET_SIZE; i<(k+1)*BUCKET_SIZE; i++){
                sum+=data[i];
            }
            bucket_sum[k]=sum;
        }

        // [x, y)
        int getsum(int x, int y){
            int sum=0;
            for(int i=0; i<B; i++){
                int l=i*BUCKET_SIZE, r=(i+1)*BUCKET_SIZE;
                
                if(r<=x || y<=l) continue;

                if(x<=l && r<=y) sum+=bucket_sum[i];
                else{
                    for(int j=max(x, l); j<min(y, r); j++){
                        sum+=data[j];
                    }
                }
            }
            return sum;
        }

        void update(int x, int y){
            int k=x/BUCKET_SIZE;
            ll minval=data[x]=y;
            for(int i=k*BUCKET_SIZE; i<(k+1)*BUCKET_SIZE; i++){
                minval=min(minval, data[i]);
            }
            bucket_min[k]=minval;
        }

        // [x, y)
        int find(int x, int y){
            ll minval=INF;
            for(int i=0; i<B; i++){
                int l=i*BUCKET_SIZE, r=(i+1)*BUCKET_SIZE;
            
                if(r<=x || y<=l) continue;

                if(x<=l && r<=y) minval=min(minval, bucket_min[i]);
                else{
                    for(int j=max(x, l); j<min(y, r); j++){
                        minval=min(minval, data[j]);
                    }
                }
            }
            return minval;
        }
};

signed main(){
    int n, q; cin>>n>>q;
    SquareDivision ans;
    ans.prepare(n);

    while(q--){
        int c, x, y; cin>>c>>x>>y;
        if(c==0){
            ans.update(x, y);
        }
        else{
            cout << ans.find(x, y+1) << endl;
        }
    }
}


Measured memory_bytes: 3572
N,M=map(int,input().split())
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

if N>=2:
    a=combinations_count(N,2)
else:
    a=0
if M>=2:
    b=combinations_count(M,2)
else:
    b=0
print(a+b)

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

#define mp make_pair
#define X first
#define Y second
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FOD(i, a, b) for(int i = a; i >= b; i--)

using namespace std;

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

const int N = 5e3 + 1;
const int M = 201;

struct segmentTree{
    #define mid ((l + r) >> 1)
    ll d[N * 4], lazy[N * 4];
    void doLazy(int id, int l, int r){
        d[id] += lazy[id];
        if (l != r){
            lazy[id << 1] += lazy[id];
            lazy[id << 1 | 1] += lazy[id];
        }
        lazy[id] = 0;
    }
    void update(int id, int l, int r, int u, int v, int val){
        doLazy(id, l, r);
        if (v < l || r < u)
            return;
        if (u <= l && r <= v){
            lazy[id] += val;
            doLazy(id, l, r);
            return;
        }
        update(id << 1, l, mid, u, v, val);
        update(id << 1 | 1, mid + 1, r, u, v, val);
        d[id] = max(d[id << 1], d[id << 1 | 1]);
    }
    ll get(int id, int l, int r, int u, int v){
        doLazy(id, l, r);
        if (v < l || r < u)
            return 0;
        if (u <= l && r <= v){
            return d[id];
        }
        return max(get(id << 1, l, mid, u, v),
                   get(id << 1 | 1, mid + 1, r, u, v));
    }
    #undef mid;
} ST;

int n, m, a[N], b[M][N];
int s[M][N], top[M];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    FOR(i, 1, n - 1)
        cin >> a[i];
    FOR(i, 1, n)
        FOR(j, 1, m)
            cin >> b[j][i];

    ll ans = 0;
    FOR(r, 1, n){
        FOR(i, 1, m){
            while (top[i] > 0 && b[i][s[i][top[i]]] <= b[i][r]){
                ST.update(1, 1, n, s[i][top[i] - 1] + 1, s[i][top[i]], -b[i][s[i][top[i]]]);
                top[i]--;
            }
            ST.update(1, 1, n, s[i][top[i]] + 1, r, b[i][r]);
            s[i][++top[i]] = r;
        }
        ans = max(ans, ST.get(1, 1, n, 1, r));
        if (r < n)
            ST.update(1, 1, n, 1, r, -a[r]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

mat G(100010, vec(0));
vector<bool> used(100010, false);
P dfs(ll v){
    used[v] = true;
    ll sz = G[v].size();
    if(sz == 1) {
        return mp(1, 1);
    }
    bool sleaf = false;
    ll sum = 0;
    rep(i, sz) {
        if (!used[G[v][i]]) {
            P p = dfs(G[v][i]);
            if (p.se == 1) sleaf = true;
            sum += p.fi;
        }
    }
    return mp(sum - (sz != 2 && sleaf ? 1 : 0), sz == 2 && sleaf);
}

int main(){
    cin>>N;
    rep(i,N-1){
        cin>>A>>B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    ll mv, mnum = 0;
    rep(i,N){
        if(mnum < G[i].size()){
            mv = i;
            mnum = G[i].size();
        }
    }
    if(mnum <= 2){
        cout<<1<<endl;
    }else{
        cout<<dfs(mv).fi<<endl;
    }
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
const int N = 51;
int comb[N][N] = {0};
void precompute() {
    for (int i = 1; i < N; i++) {
        comb[i][0] = 1, comb[i][1] = i;
    }
    for (int n = 2; n < N; n++) {
        for (int r = 2; r < N; r++) {
            comb[n][r] = comb[n - 1][r] + comb[n - 1][r - 1];
        }
    }
}
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    precompute();
    int n, A, B;
    cin >> n >> A >> B;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());
    double res = 0.0;
    for (int i = 0; i < A; i++) {
        res += v[i];
    }
    cout << setprecision(8) << fixed << res / A << "\n";
    if (v[0] == v[A - 1]) {
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (v[i] == v[0])
                cnt++;
        }
        int ans = 0;
        for (int i = A; i <= B; i++) {
            ans += comb[cnt][i];
        }
        cout << ans << "\n";
    } else {
        int cnt1 = 0, cnt2 = 0;
        for (int i = 0; i < A; i++) {
            if (v[i] == v[A - 1])
                cnt1++;
        }
        for (int i = 0; i < n; i++) {
            if (v[i] == v[A - 1])
                cnt2++;
        }
        cout << comb[cnt2][cnt1] << "\n";
    }
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
final=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]<h[b-1]:
         final[a-1]=0
  elif h[a-1]>h[b-1]:
         final[b-1]=0
  else:
         final[a-1]=0
         final[b-1]=0
print(sum(final))

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

int main(){
    int N;
    cin >> N;
    int a[3*N];
    for(int i = 0; i < 3*N; i++){
        cin >> a[i];
    }
    sort(a, a + 3*N, greater<int>());
    int64_t sum = 0;
    for(int i =0; i < N; i++){
        sum += a[2*i+1];
    }
    cout << sum << endl;
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n,y;
    cin >> n >> y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if((i*10000+j*5000+(n-i-j)*1000)==y){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
double a[1005];
double dance;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for (ll i = 0; i < n; i++){
		cin >> a[i];
		a[i] = 1 / a[i];
		}
	for (ll i = 0; i < n; i++){
		dance += a[i];
		}
		cout << 1/dance;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');

        int maxCount = int.Parse(input[0]);
        int minNumericSum = int.Parse(input[1]);
        int maxNumericSum = int.Parse(input[2]);

        int resultSum = 0;

        for (int num = 1; num <= maxCount; num++)
        {
            string numStr = num.ToString();
            int numericSum = 0;

            for (int i = 0; i < numStr.Length; i++)
            {
                numericSum += numStr[i] - '0';
            }

            if (minNumericSum <= numericSum && numericSum <= maxNumericSum)
            {
                resultSum += num;
            }
        }
        
        Console.WriteLine(resultSum.ToString());
    }
}

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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A.at(i);
  // 食べるチョコレートの数
  vector<int> c(N, 0);
  for (int i=0; i<N; i++) {
    int j = 0;
    while(j*A.at(i)+1<=D) {
      c.at(i) = j+1;
      j++;
    }
  }
  int ans = X+accumulate(c.begin(), c.end(), 0);
  cout << ans << endl;
}

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

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

    reverse(S.begin(), S.end());
    int size = S.size();
    int cnt[2020] = {0};
    int m = 2019;
    int amari = 0;
    long result = 0;
    int x = 1;

    cnt[0]++;
    for (int i = 0; i < size; i++) {
        amari = amari + (S[i] - '0') * x;
        amari %= m;
        result += cnt[amari];
        cnt[amari]++;
        x = x * 10 % m;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3696
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.Map;
import java.util.HashMap;
 
public class Main {
 	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		for(int i = 0; i < m; i++){
			a[i] = scanner.nextInt()-1;
			b[i] = scanner.nextInt()-1;
		}
		int count = 0;
		for(int i = 0; i < m; i++){
			UnionFind road = new UnionFind(n);
			Map<Integer,Integer> map = new HashMap<Integer,Integer>();
			for(int j = 0; j < m; j++){
				if(i == j) continue;
				road.unite(a[j],b[j]);
			}
			for(int j = 0; j < n; j++){
				if(!map.containsKey(road.find(j))){
					map.put(road.find(j),1);
				}else{
					map.put(road.find(j),map.get(road.find(j))+1);
				}
			}
			if(map.size() > 1){
				count++;
			}
		}
		System.out.println(count);
	}
 
	public static class UnionFind{
		int n;
		int[] parent;
		int[] rank;
		UnionFind(int n){
			this.n = n;
			parent = new int[n];
			rank = new int[n];
			for(int i = 0; i < n; i++){
				parent[i] = i;
				rank[i] = 0;
			}
		}
		public void unite(int x, int y){
			x = find(x);
			y = find(y);
			if(x == y) return;
 
			if(rank[x] < rank[y]){
				parent[x] = y;
			}else{
				parent[y] = x;
				if(rank[x] == rank[y]) rank[x]++;
			}
		}
		public int find(int x){
			if(parent[x] == x){
				return x;
			}else{
				return parent[x] = find(parent[x]);
			}
		}
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
	}
}

Measured memory_bytes: 22996
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long STATES;

int main( void )
{
	STATES free_days[31], dp[50], goal_state, next;
	register int i, j;
	int n, answer, free_day, k;

	while ( scanf( "%d", &n ) == 1 && n )
	{
		memset( free_days, 0, sizeof(free_days) );
		memset( dp, 0, sizeof(dp) );

		goal_state = 0;
		for ( i = 0; i < n; i++ ) goal_state |= 1LL << i;

		for ( i = 0; i < n; i++ )
		{
			scanf( "%d", &k );
			for ( j = 0; j < k; j++ )
			{
				scanf( "%d", &free_day );
				free_days[free_day] |= 1LL << i;
			}
		}

		answer = -1;
		for ( i = 0; i < n; i++ ) dp[i] = 1LL << i;
		for ( i = 1; i <= 30; i++ )
		{
			next = 0;
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) next |= dp[j];
			if ( next == goal_state )
			{
				answer = i;
				break;
			}
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) dp[j] |= next;
		}

		printf( "%d\n", answer );
	}

	return 0;
}

Measured memory_bytes: 764
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define WAIT system ("pause")
#define rt0 return 0
using namespace std;
int main()
{
    int n,m,cnt1,cnt2,cnt,ans=-10,i,j;
    string a[100],b[100];
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i];
    cin>>m;
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
    {
        cnt1=0;
        for(j=0;j<n;j++) if(a[i]==a[j]) cnt1++;
        cnt2=0;
        for(j=0;j<m;j++) if(a[i]==b[j]) cnt2++;
        cnt=cnt1-cnt2;
        if(cnt>ans) ans=cnt;
    }
    if(ans<0) puts("0");
    else cout<<ans;
    WAIT;
    rt0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
	int A,B,T=0;
	cin >> A >> B;

	for(int i=1;i<B-A+1;i++){
		T=T+i;
	}
	cout << T-B << endl;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, "%s", $str);
fscanf(STDIN, "%s", $str2);

$len = strlen($str);
for($i=0; $i<=$len; $i++) {
    if (($isMatch = $str === $str2)) {
        break;
    }
    $str = substr($str, 1).$str[0];
}
echo $isMatch ? 'Yes' : 'No';


Measured memory_bytes: 4604
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
if sum(a) == x:
    print(n)
    exit()
for i in range(n):
    x -= a[i]
    if x >= 0:
        ans += 1
    else:
        print(ans)
        exit()
print(n-1)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll H,W;
    cin>>H>>W;
    ll map2d[H][W];
    ll val[H][W]={};
    rep(i,H){
        rep(j,W){
            val[i][j]=INF2;
        }
    }
    rep(i,H){
        rep(j,W){
            char c; cin>>c;
            if(c=='.') map2d[i][j]=0;
            else map2d[i][j]=1;
        }
    }
    val[0][0]=0;
    rep(i,H){
        rep(j,W){
            if(i>0){
                if(map2d[i][j]==map2d[i-1][j]) mini(val[i][j],val[i-1][j]);
                else mini(val[i][j],val[i-1][j]+1);
            }
            if(j>0){
                if(map2d[i][j]==map2d[i][j-1]) mini(val[i][j],val[i][j-1]);
                else mini(val[i][j],val[i][j-1]+1);
            }
        }
    }
    ll ans=(val[H-1][W-1]+1)/2;
    if(map2d[0][0] and map2d[H-1][W-1]) ++ans;
    cout<< ans <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 384
while True:
    h, w = [int(i) for i in input().split()]
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i % 2 == 0:
            print('#.' * (w // 2) + '#' * (w % 2))
        else:
            print('.#' * (w // 2) + '.' * (w % 2))
    print()


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

#define INF 0x7fffffff

int main() {
	int		i,j,k,n,m,x,y,ans = 0;
	int		tmp = INF;

	cin >> x;

	i = x / 500;
	x = x % 500;

	j = x / 5;

	cout << i*1000+j*5 << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back
#define em emplace_back
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second

/* STL */
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a)   reverse(a.begin(),a.end())
/* loops */
#define fa(i, a, b) for (auto (i) = (a); (i) < (b); ++(i))
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n) i=1;i<=(n);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";

int main()
{

   Ezio
   ll t,m,n,x,a,b;
   string s;

   cin>>n;

   vector<ll>v(n);
   fr(i,n)cin>>v[i];
   a=1e9;
   for (ll i=-100;i<=100;i++){
       b=0;
       fr(j,n){
         b+= ((i-v[j]) * (i-v[j]));
       }
       a=min(a,b);
   }

   cout<<a<<endl;
   return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int top, Stack[1024];

void push(int x){
    Stack[++top] = x;
}

int pop(){
    top--;
    return Stack[top+1];
}

int main(){
    int a, b, res;
    top = 0;
    char input[100];

    while( scanf("%s", input) != EOF ){
        if(input[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if(input[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }else if(input[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            push( atoi(input) );
        }
    }

    printf("%d\n", pop());

    return 0;
}





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

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n)    FOR(i, 0, n)
#define pb           push_back
#define all(a)       (a).begin(), (a).end()
#define UNIQUE(v)    v.erase(unique(all(v)), v.end());
#define fill(a, x)   memset(a, x, sizeof(a))
#define zero(a)      fill(a, 0)
#define minus(a)     fill(a, -1)
#define dbg(x)       cout << #x "=" << x << endl

vi vc_a;
int n;

/* naming rules
// array starts with "ar". for example ar_a
// stack starts with "st". for example st_a
// queue starts with "qu". for example qu_a
// vector starts with "vc". for example vc_a
*/

bool solve(int i, int m) {
  if (m == 0) {
    return true;
  }
  if (i >= n) {
    return false;
  }
  bool res = solve(i + 1, m) || solve(i + 1, m - vc_a[i]);
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  int c = 0;

  cin >> n;

  // receiving input
  while (c < n) {
    int tmp;
    cin >> tmp;
    vc_a.pb(tmp);
    c++;
  }

  int q;
  cin >> q;
  int cc = 0;
  vs vc_r;

  // receiving input
  while (cc < q) {
    int tmp;
    cin >> tmp;
    if (solve(0, tmp)) {
      vc_r.pb("yes");
    } else {
      vc_r.pb("no");
    }
    cc++;
  }

  rep(i, q) {
    cout << vc_r[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 3240
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 410
#define MOD 1000000007
using namespace std;
typedef long long ll;
int n,c;
int a[MAXN],b[MAXN];
ll dp[MAXN][MAXN],nq[MAXN][MAXN];
ll fsp(ll x,int y){
	ll res=1ll;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;	
		y>>=1;
	}
	return res;
}
int main(){
	SF("%d%d",&n,&c);
	for(int i=1;i<=n;i++)
		SF("%d",&a[i]);
	for(int i=1;i<=n;i++)
		SF("%d",&b[i]);
	for(int i=0;i<=c;i++){
		for(int j=1;j<=400;j++)
			nq[i][j]=fsp(j,i);
		for(int j=1;j<=400;j++)
			nq[i][j]=(nq[i][j]+nq[i][j-1])%MOD;
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=c;j++)
			for(int k=0;k<=j;k++){
				dp[i][j]+=(dp[i-1][j-k]*(((nq[k][b[i]]-nq[k][a[i]-1])%MOD+MOD)%MOD))%MOD;
				dp[i][j]%=MOD;
			}
	PF("%lld",dp[n][c]);
}

Measured memory_bytes: 2688
#include<stdio.h>
int binarySearch(int A[],int ,int);
int main(){
  int a,b,A[100000],B[100000],count=0,c;
  scanf("%d",&a);
  for(int i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&b);
  for(int i=0;i<b;i++){
    scanf("%d",&B[i]);
  }
  for(int i=0;i<b;i++){
    c=binarySearch(A,B[i],a);
    if(c==1)count++;
  }
  printf("%d\n",count);
   return 0;
}
int binarySearch(int A[],int x,int g){
  int right,left,mid,key;
  left = 0;
  right = g;
  key=x;
      while(left < right){
        mid = (left + right)/2;
        if (A[mid] == key)return mid=1;
        else if( key < A[mid])right = mid;
        else left = mid + 1;
      }
    return mid=0;
}



Measured memory_bytes: 2460
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

lag = False
if V < W:
    flag = False
else:
    if (V-W)*T >= abs(A-B):
        flag = True
    else:
        flag =False

if flag:
    print('YES')
else:
    print('NO')

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL (vec)(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t make_tuple
#define eb emplace_back
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define cont const auto
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
#define PQ priority_queue
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h,w;
  cin>>h>>w;
  V<str> s(h);
  rep(i,h)cin>>s[i];

  VV(ll,H,h+2,w+2,0);
  VV(ll,W,h+2,w+2,0);
  rep(i,h){
    if(s[i][0]=='.')W[i][0]=1;
    reps(j,w-1){
      if(s[i][j]=='.')W[i][j]=W[i][j-1]+1;
      else W[i][j]=0;
    }
  }
  rep(j,w){
    if(s[0][j]=='.')H[0][j]=1;
    reps(i,h-1){
      if(s[i][j]=='.')H[i][j]=H[i-1][j]+1;
      else H[i][j]=0;
    }
  }
  
  //累積和みたいにまとめた  
  rep(i,h){
    repr(j,w-1){
      if(W[i][j]==0)continue;
      chmax(W[i][j],W[i][j+1]);
    }
  }
  rep(j,w){
    repr(i,h-1){
      if(W[i][j]==0)continue;
      chmax(H[i][j],H[i+1][j]);
    }
  }
  ll res=0;
  rep(i,h)rep(j,w)chmax(res,H[i][j]+W[i][j]-1);
  out(res);
  //ENDL;show(H);ENDL;show(W);
  
  
  return 0;
}




Measured memory_bytes: 67328
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let s = sc
        .read::<String>()
        .chars()
        .map(|c| c as usize - '0' as usize)
        .collect::<Vec<_>>();
    let k: usize = sc.read();

    let mut dp: Vec<Vec<u64>> = vec![vec![0; k + 1]; 4];
    dp[0][0] = 1;

    let n = s.len();
    for i in 0..n {
        let mut next = vec![vec![0; k + 1]; 4];
        for mask in 0..4 {
            let is_started = mask & 1 != 0;
            let is_lower = mask & 2 != 0;
            for prev_k in 0..(k + 1) {
                for next_d in 0..10 {
                    if !is_lower && next_d > s[i] {
                        continue;
                    }

                    let next_started = is_started || next_d > 0;
                    let next_lower = is_lower || next_d < s[i];
                    let next_mask =
                        if next_lower { 2 } else { 0 } + if next_started { 1 } else { 0 };
                    let next_k = if next_d != 0 { prev_k + 1 } else { prev_k };
                    if next_k > k {
                        continue;
                    }
                    next[next_mask][next_k] += dp[mask][prev_k];
                }
            }
        }
        dp = next;
    }

    let ans = dp.into_iter().map(|dp| dp[k]).sum::<u64>();
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352