akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(a, b) << " ";

    if (n >= a + b)
        cout << 0 << endl;
    else
        cout << ((a + b) - n) << endl;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef pair<int, int> pii;
typedef double lf;
typedef long long ll;
const int inf=0x3f3f3f3f, mod=1000000007;

inline int read()
{
    int x=0,f=1; char ch=getchar();
    for (; ch<'0' || ch>'9'; ch=getchar()) if (ch=='-') f=-1;
    for (; ch>='0' && ch<='9'; ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
    char s[10]; int ans=0;
    scanf("%s",s);
    for (int i=0; i<strlen(s); i++) if (s[i]=='2') ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=102;
struct node { int y,next; } a[N*N<<1];
LL an2,a2;
int s[N*N],head[N*N],i,j,k,n,m,len,x,y,an1,a1;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void chkmax(int &a,int b){ a=a<b?b:a; }

void jb(int x,int y)
{
	a[++k]=(node){y,head[x]},head[x]=k,
	a[++k]=(node){x,head[y]},head[y]=k;
}

int dfs(int w,int sp)
{
	int z1=0,z2=0;
	for (register int j=head[w];j;j=a[j].next)
		if ((j^1)!=sp)
		{
			int c=a[j].y;
			int z=dfs(c,j)+1;
			if (z>z1)
				z2=z1,z1=z;
			else
				chkmax(z2,z);
		}
	chkmax(len,z1+z2);
	return z1;
}

void DD(int w,int sp,int H)
{
	int S=0;
	chkmax(a1,H);
	//printf("%d %d %d PPP\n",w,sp,H);
	for (register int j=head[w];j;j=a[j].next)
		if ((j^1)!=sp)
		{
			int c=a[j].y;
			++S,DD(c,j,H+1);
		}
	chkmax(s[H],S);
	//printf("%d %d %d\n",w,s[H],H);
}

int main()
{
	//freopen("1.in","r",stdin);
	n=read(),k=1;
	for (i=1;i<n;++i) x=read(),y=read(),jb(x,y);
	an1=n+3,an2=8e18;
	for (i=1;i<=n;++i)
	{
		a1=0,a2=1,fill(s,s+n+1,0);
		DD(i,0,1);
		for (j=1;j<a1;++j)
			a2*=s[j];
		if (a1<an1)
			an1=a1,an2=a2;
		else
			if (a1==an1)
				an2=min(an2,a2);
	}
	for (i=1;i<=n;++i)
		for (j=head[i];j;j=a[j].next)
			if (j&1)
			{
				x=i,y=a[j].y,
				a1=0,a2=1,fill(s,s+n+1,0);
				//printf("%d %d\n",x,y);
				DD(x,j^1,1),DD(y,j,1);
				for (k=1;k<a1;++k)
					a2*=s[k];
				a2<<=1;
				if (a1<an1)
					an1=a1,an2=a2;
				else
					if (a1==an1)
						an2=min(an2,a2);
			}
	printf("%d %lld\n",an1,an2);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, ans;
  cin >> A;
  ans = 0;
  if(A % 10 == 1) {
    ans += 9;
  }
  else {
    ans += 1;
  }
  if((A + 10) % 100 <= 10) {
    ans += 10;
  }
  else {
    ans += 90;
  }
  if((A + 100) % 1000 <= 100) {
    ans += 100;
  }
  else {
    ans += 900;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    for(int i = 1; i <= 5; i++){
        int n;
        cin >> n;
        if(!n) cout << i;
    }
}

Measured memory_bytes: 3592
#define _GLIBCXX_DEBUG
#include <iostream>
#include <string>
using namespace std;

int main(void){
    string s, t;
    cin >> s >> t;
    int i=0;
    for(char &c : s){
        if(c == t[i]) i++;
        else{
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

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

#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,P> PP;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    long double a;
    long double b;
    cin>>a>>b;

    cout<<(ll)(a*b)<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 3732
require 'prime'
n = gets.to_i
i = 1
ans = 0
while i*2 + 1 <= n
  count = 1
  Prime.prime_division(2*i+1).each do |factor|
    count *= factor[1] + 1
  end
  if count == 8
    ans += 1
  end
  i += 1
end
puts ans


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

int main()
{
	std::string s;
	std::cin >> s;

	for (int i = 0; i < 12; ++i)
	{
		std::cout << s[i];

		if (i == 3)
		{
			std::cout << " ";
		}
	}

	std::cout << std::endl;

	return 0;
}

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

int main() {
	string S; cin >> S;
		
	string ans = "No";
	
	if (S[0]==S[1]) {
		if (S[2]==S[3]) {
			if (S[0] != S[2]) ans = "Yes";
		}
	}
	else if (S[0]==S[2]) {
		if (S[1]==S[3]) {
			if (S[0] != S[1]) ans = "Yes";
		}
	}
	else if (S[0]==S[3]) {
		if (S[1]==S[2]) {
			if (S[0] != S[1]) ans = "Yes";
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

// https://qiita.com/EqualL2/items/b4683db7ab4e90545bb2
int ctoi(const char c){
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

template <typename T>
T tmpl_abs(T n) {
    return n < 0 ? -n : n;
}

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

    const int n = s.size();
    vector<int> ds(n);

    for(int i = 0; i < n; i++) {
        ds[i] = ctoi(s[i]);
    }

    int min_diff = 1000;
    for(int i = 0; i < n-2; i++) {
        int num = ds[i]*100 + ds[i+1]*10 + ds[i+2];
        int diff = tmpl_abs(num-753);
        if (min_diff > diff) min_diff = diff;
    }

    cout << min_diff << endl;
}


Measured memory_bytes: 384
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int max = (int)Math.pow(2, 15)+10;
        int[][] dp = new int[max][5];
        dp[0][0] = 1;
        for(int i=1; i*i<max; i++){
            for(int j=0; j+i*i<max; j++){
                for(int k=1; k<5; k++){
                    dp[j+i*i][k] += dp[j][k-1];
                }
            }
        }

        while(true){
            int n = sc.nextInt();
            if(n==0) break;
            int ans = dp[n][1] + dp[n][2] + dp[n][3] + dp[n][4];
            System.out.println(ans);
        }
    }

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

Measured memory_bytes: 23516
from itertools import permutations
n,m,R = map(int,input().split())
r = [int(i)-1 for i in input().split()]
INF = float("INF")
d = [[INF]*n for _ in range(n)]
for _ in range(m):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])
ans = INF
for p in permutations(r):
    res = 0
    for i in range(R-1):
        res += d[p[i]][p[i+1]]
    ans = min(ans, res)
print(ans)

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

int solve(int a,vector<int> *edges,bool v[],int dp[])
{
    int ans=0; v[a]=1;
    if(dp[a]!=-1) return dp[a];
    if(edges[a].size()==0)
    {
        dp[a]=0;
        return 0;
    }
    for(int i=0; i<edges[a].size(); i++)
        ans=max(ans,solve(edges[a][i],edges,v,dp));
    dp[a]=1+ans;
    return dp[a];
}

int main()
{
    int n,m,ans=0;
    cin>>n>>m;
    vector<int> edges[n+1];
    for(int i=0; i<m; i++)
    {
        int a,b;
        cin>>a>>b;
        edges[a].push_back(b);
    }
    int dp[n+1];
    memset(dp,-1,sizeof(dp));
    bool visited[n+1]={0};
    for(int i=1; i<=n; i++)
        if(!visited[i]) int an=solve(i,edges,visited,dp);
    for(int i=1; i<=n; i++)
        ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}


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

const int N = 300000;

struct Segment_tree {
	int T[1200010];
	void Build(int now, int l, int r) {
		T[now] = 0;
		if (l == r) return ;
		int mid = l + r >> 1;
		Build(now << 1, l, mid), Build(now << 1 | 1, mid + 1, r);
	}
	void Update(int now, int l, int r, int pos, int x) {
		if (l == r) {
			T[now] = max(T[now], x);
			return ;
		}
		int mid = l + r >> 1;
		if (pos <= mid) Update(now << 1, l, mid, pos, x);
		else Update(now << 1 | 1, mid + 1, r, pos, x);
		T[now] = max(T[now << 1], T[now << 1 | 1]);
	}
	int Query(int now, int l, int r, int L, int R) {
		if (l == L && r == R) return T[now];
		int mid = l + r >> 1;
		if (R <= mid) return Query(now << 1, l, mid, L, R);
		if (L > mid) return Query(now << 1 | 1, mid + 1, r, L, R);
		return max(Query(now << 1, l, mid, L, mid), Query(now << 1 | 1, mid + 1, r, mid + 1, R));
	}
}seg;

int main () {
	int n, K; scanf("%d%d", &n, &K);
	seg.Build(1, 0, N);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		int tmp = seg.Query(1, 0, N, max(0, x - K), min(N, x + K)) + 1;
		seg.Update(1, 0, N, x, tmp);
		ans = max(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 7936
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	k = readline() |> parseInt
	a = Int8[1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51]
	println(a[k])
end

main()

Measured memory_bytes: 117784
n, a, b, k = map(int, input().split())

mod = 998244353
factorial = [1]
inverse = [1]
for i in range(1, n+1):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))

def comb(n, r, mod):
    if n < r or r < 0: return 0
    elif r == 0: return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod

ans = 0
for i in range(n+1):
    if a*i > k: break
    sum_b = k - a*i
    if sum_b % b != 0: continue
    j = sum_b // b
    if j > n: continue
    ans = (ans + comb(n, i, mod)*comb(n, j, mod)) % mod
print(ans)

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

vector<vector<int>> l(100002);
int dp[100002];

int dpres(int i){
  if(dp[i] == -1){
    if(l[i].size() == 1){ 
      dp[i] = 0;
    }else{
      int ma = 0;
      for(int j = 1; j < l[i].size();j++){
        ma = max(dpres(l[i][j]),ma);
      }
      dp[i] = ma + 1;
    }
  }
  return dp[i];
}   

int main() {
  int n,m; 
  cin >> n >> m;
  int a,b;
  for(int i = 0;i<n+1;i++){l[i].push_back(0);}   
  for(int i = 0;i< m; i++ ){
    cin >> a >> b;
    l[a].push_back(b);
  }
  
  for(int i = 0;i<n+1;i++){
    dp[i] = -1;
  }
  
  int ma = 0;
  for(int i = 1; i < n+1;i++){
    if(dp[i] == -1){
      dp[i] = dpres(i);
    }
    ma = max(dp[i],ma);
  }
  cout << ma;
}

Measured memory_bytes: 8192
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n, k;in(n),in(k);
  vector<ll> A(n);
  loop(i,0,n) in(A[i]);
  
  auto f = [&](ll x) {
    ll kk = k;
    for (auto &&a: A) {
      ll d = a/x + (a%x!=0);
      d--;
      if (kk < d) return false;
      kk -= d;
    }
    return true;
  };
  ll ng = 0, ok = 100000000000;
  while (ng + 1 < ok) {
    ll mid = (ng+ok)/2;
    if (f(mid)) ok = mid;
    else ng = mid;
  }
  print(ok);
  return 0;
}


Measured memory_bytes: 4852
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int cmpfunc (const void * a, const void * b) {
   return ( *(int *)a - *(int *)b );
}
int main(void)
{
    int n,i;
    float sum=0;
    int v[53];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&v[i]);
    }
    qsort(v,n,sizeof(int),cmpfunc);
    sum = ((float)(v[0]+v[1])/2);
    for(i=2;i<n;i++)
    {
        sum = (float)((sum + v[i])/2);
    }
    printf("%f\n",sum);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
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 modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int sum=0;
	string s=to_string(n);
	for(int i=0;i<(int)s.size();i++){
		sum+=s[i]-'0';
	}
	if(n%sum==0){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
    int n;
    cin >> n;
    vector<vector<int> > a(n+1, vector<int>(n+1, 0));
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            cin >> a[i][j];
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<n; j++){
            a[i][j+1] += a[i][j];
        }
    }
    for(int j=1; j<=n; j++){
        for(int i=1; i<n; i++){
            a[i+1][j] += a[i][j];
        }
    }
    int ans = -inf;
    for(int i=0; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            for(int k=0; k<=n; k++){
                for(int l=k+1; l<=n; l++){
                    ans = max(ans, a[i][k] +a[j][l] -a[i][l] -a[j][k]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> fav(n, vector<bool>(m, false));
  rep(i, n){
    int k; cin >> k;
    rep(j, k){
      int a; cin >> a; a--;
      fav[i][a] = true;
    }
  }
  
  int count = 0;
  rep(i, m){
    bool flag = true;
    rep(j, n){
      if (!fav[j][i]){
        flag = false;
        break;
      }
    }
    if (flag) count++;
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll A(N);
        rep(i, 0, N) cin >> A[i];
        map<ll, ll> mp;
        rep(i, 0, N) mp[A[i]]++;
        vector<pll> tmp(all(mp));
        //rep(i, 0, N) swap(tmp[i].first, tmp[i].second);
        sort(tmp.rbegin(), tmp.rend());



        vll ans;
        rep(i, 0, len(tmp)) {
                if (tmp[i].second >= 2) ans.push_back(tmp[i].first);
        }
        //print1d(ans);
        if (len(ans) == 1 and mp[ans[0]] >=4) cout << mp[ans[0]] * mp[ans[0]] << endl;
        else if (len(ans) < 2) cout << 0 << endl;
        else {
                if (mp[ans[0]] >= 4) cout << ans[0] * ans[0] << endl;
                else cout << ans[0] * ans[1] << endl;
        }
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    string march = "MARCH";
    ll cnt[5] = {};
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        int pos = march.find(s[0]);
        if (pos != string::npos) cnt[pos]++;
    }

    ll total = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i+1; j < 5; j++) {
            for (int k = j+1; k < 5; k++) {
                total += cnt[i] * cnt[j] * cnt[k];
            }
        }
    }
    cout << total << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int read()
{
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        s = s * 10 + ch - '0';
        ch = getchar();
    }
    return s * w;
}
int main()
{
    int n = read(), a = read(), b = read(), ans = 0;
    for (register int i = 1; i <= n; i++)
    {
        int sum = 0, num = i;
        while (num != 0)
        {
            sum += num % 10;
            num /= 10;
        }
        if (a <= sum && sum <= b)
        {
            ans += i;
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
         
int main() {
int N, A;
  cin >> N >> A;
  
  if(A >= 500){
    cout << "Yes" << endl;
  }else if(N % 500 <= A){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
    ll H,W;
    cin >> H >> W;
    ll num =0;
    for(int i=0;i<H;i++){
        string S;
        cin >> S;
        for(int j=0;j<W;j++){
            if(S[j] =='#'){
                num++;
            }
        }
    }
    if(num == H +W-1){
        cout <<"Possible" << endl;
    }else{
        cout <<"Impossible"<< endl;
    }

    return 0;
}

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

const double pi=acos(-1);
typedef long long ll;
const int maxn=1e6+10;

int main()
{
    int h,a;
    cin >> h >>a ;
    int ans=h/a;
    if(h%a)
        ans++;
    cout << ans<<endl;
    return 0;
}

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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int64_t ketawa(int64_t N)
{
    int64_t d = 0;
    while (N != 0)
    {
        d += N % 10;
        N /= 10;
    }
    return d;
}

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    for (int i = 1; i <= N; i++)
    {
        int tmp = ketawa(i);
        if (tmp >= A && tmp <= B)
            ans += i;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int,int> 
#define int long long 


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	
	int t=1;
//	cin>>t;
	while(t--){
		int n,w;
		cin>>n>>w;
		int wei[n],val[n];
		rep(i,n){
			cin>>wei[i]>>val[i];
		}
		int dp[w+1][n+1]={0};
		rep(i,w+1){
			rep(j,n+1){
				dp[i][j]=0;
			}
		}
		REP(i,1,w+1){
			REP(j,1,n+1){
				if(wei[j-1]<=i){
					dp[i][j]=max(dp[i][j-1],val[j-1]+dp[i-wei[j-1]][j-1]);
				}
				else{
					dp[i][j]=dp[i][j-1];
				}
			}
		}
		
		cout<<dp[w][n]<<" ";
	}
	return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, 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;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int a[100010][3];
int dp[100010][3];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k)continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		chmax(ans, dp[n][i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (k % 2 == 0 ? a - b : b - a) << endl;
    return 0;
}

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

int main() {
    int64 N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<int64> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    rep(i, N) A[i] += M;
    vector<int64> sum(N + 1);
    rep(i, N) sum[i + 1] = sum[i] + A[i];
    auto isOK = [&](int x) -> bool {
        if(A[x] + M < A[N - P]) return false;
        int64 S = sum[N - P + 1] - sum[x + 1];
        int64 D = A[x] * (N - P - x);
        return S - D <= M * (N - V);
    };
    int l = -1, r = N - P;
    while(r - l > 1) {
        int mid = (l + r) / 2;
        if(isOK(mid)) r = mid;
        else l = mid;
    }
    cout << N - r << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k; cin >> n >> k;
  vector<int> arr(n);
  for(int i = 0; i < n; i++) cin >> arr[i];
  sort(arr.begin(), arr.end());
  cout << accumulate(arr.begin(), arr.begin()+k, 0) << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		long[][] arr=new long[s[0]][];
		int[,] h=new int[s[1]*2+1,s[1]*2+1];
		int ans=0;
		for(int i=0;i<s[0];i++){
			object[] q=Console.ReadLine().Split(' ');
			arr[i]=new long[]{Convert.ToInt64(q[0]),Convert.ToInt64(q[1]),Convert.ToChar(q[2])};
			if(arr[i][2]==87){arr[i][1]+=s[1];}
			arr[i][0]%=s[1]*2;
			arr[i][1]%=s[1]*2;
			h[arr[i][0]+1,arr[i][1]+1]++;
		}
		for(int i=1;i<=s[1]*2;i++){
			for(int j=1;j<=s[1]*2;j++){h[i,j]+=h[i,j-1];}
		}
		for(int i=1;i<=s[1]*2;i++){
			for(int j=1;j<=s[1]*2;j++){h[j,i]+=h[j-1,i];}
		}
		for(int i=1;i<=s[1];i++){
			for(int j=1;j<=s[1]*2;j++){
				int a=h[i,j]-h[i,Math.Max(j-s[1],0)];
				a+=h[i,s[1]*2]-h[i,Math.Min(j+s[1],s[1]*2)];
				a+=h[i+s[1],Math.Min(j+s[1],s[1]*2)]-h[i,Math.Min(j+s[1],s[1]*2)]-h[i+s[1],j]+h[i,j];
				if(j>s[1]){a+=h[i+s[1],j-s[1]]-h[i,j-s[1]];}
				a+=h[s[1]*2,j]-h[i+s[1],j]-h[s[1]*2,Math.Max(j-s[1],0)]+h[i+s[1],Math.Max(j-s[1],0)];
				if(j<s[1]&&i<s[1]){a+=h[s[1]*2,s[1]*2]-h[s[1]*2,j+s[1]]-h[i+s[1],s[1]*2]+h[i+s[1],j+s[1]];}
				ans=Math.Max(ans,a);
			}
		}
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 38836
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;
    int H, M;
    cin >> H >> M;
    int t = H*60+M;
    long double pi = boost::math::constants::pi<long double>();
    long double x = A*cos(2*pi/720*t)-B*cos(2*pi/60*t);
    long double y = A*sin(2*pi/720*t)-B*sin(2*pi/60*t);
    printf("%.12Lf", sqrtl(x*x+y*y));
}

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

int gcd(int x,int y){
	int t;
	while(1){
		if(x%y==0){
			t=y;
			break;
		}
		t=x;
		x=y;
		y=t%y;
	}
	return t;
}
int main(){
	int a,b,d;
	cin>>a>>b;
	d=a;
	if(a<b){
		a=b;
		b=d;
	}
	d=gcd(a,b);
	cout<<d<<endl;
	return 0;
}

Measured memory_bytes: 1164
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    a -= 2
    b -= 2
    a %= 13
    b %= 13
    if a > b:
        print("Alice")
    elif a < b:
        print("Bob")
    else:
        print("Draw")
    return

#B
def B():
    n, m = LI()
    a = SR(n)
    b = SR(m)
    if a == b:
        print("Yes")
        return
    for y in range(n - m):
        for x in range(n - m):
            if a[y][x] == b[0][0]:
                flg = 0
                for yi in range(m):
                    for xi in range(m):
                        if b[yi][xi] == a[y + yi][x + xi]:
                            continue
                        flg = 1
                        break
                    if flg:
                        break
                if flg:
                    continue
                print("Yes")
                return
    print("No")
    return

#C
def C():
    n, m = LI()
    edg = [[] for i in range(n)]
    for _ in range(m):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
    def dfs(i, c):
        res = 0
        c[i] = False
        if not (True in c):
            return 1
        for e in edg[i]:
            if c[e]:
                c[e] = False
                res += dfs(e, c)
                c[e] = True
        return res
    print(dfs(0, [True] * n))
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 42716
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

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

    int result = A - B * 2;
    if (result < 0)
        cout << 0 << endl;
    else
        cout << result << endl;
    
    return 0;
}

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

{
    int A, B, C;
    cin >> A >> B >> C;
    int M, sum;
    M = max(A, max(B, C));
    sum = A + B + C;
    if ((3 * M % 2 == 0 && sum % 2 == 0) || (3 * M % 2 != 0 && sum % 2 != 0))
    {
        cout << ((M - A) + (M - B) + (M - C)) / 2 << endl;
    }
    else
    {
        M++;
        cout << ((M - A) + (M - B) + (M - C)) / 2 << endl;
    }
}


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

int main(void)
{
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if (x >= r && x + r <= W && y >= r && y + r <= H) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3088
import sys

def gcd(a, b):
    while b:
        a, b = b, a % b
    return abs(a)

n, *a = map(int, sys.stdin.read().split())

def main():
    l_gcd = [None] * n
    r_gcd = [None] * n
    l_gcd[1] = a[0]
    r_gcd[n-2] = a[-1]

    for i in range(2, n):
        l_gcd[i] = gcd(l_gcd[i-1], a[i-1])
    for i in range(n-3, -1, -1):
        r_gcd[i] = gcd(r_gcd[i+1], a[i+1])

    res = max(r_gcd[0], l_gcd[n-1])
    for i in range(1, n-1):
        res = max(res, gcd(l_gcd[i], r_gcd[i]))
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 14476
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;  //このネームスペースを使う

int main(){
  string HEISEI,s1;

  HEISEI = "2019/04/30" ;
  cin >> s1 ;

  if(s1 > HEISEI){
    cout <<"TBD" << endl ;
  }
  else{
    cout <<"Heisei" << endl ;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n,c,k;
ll a[100010];
ll ans;
int main(){
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	
	ll ans=0;
	for(ll i=0;i<n;){
		ans++;
		ll t=i;
		while(t<n&&a[t]==a[i])t++;
		if(a[t]<a[i])while(t<n&&a[t]<=a[t-1])t++;
		else while(t<n&&a[t]>=a[t-1])t++;
		i=t;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 896
#include <stdio.h>

int main() {
    char s[1201], c = 'a';
    int i, len = 0, alpha[26], num;

    for (i = 0; i < 26; i++) {
        alpha[i] = 0;
    }

    while(scanf("%c", &s[len]) != EOF) {
        if (s[len] >= 'a' && s[len] <= 'z') {
            num = s[len] - 'a';
            alpha[num]++;
        }
        else if (s[len] >= 'A' && s[len] <= 'Z') {
            num = s[len] - 'A';
            alpha[num]++;
        }
        len++;
    }

    for (i = 0; i < 26; i++) {
        printf("%c : %d\n", c, alpha[i]);
        c++;
    }

    return 0;
}



Measured memory_bytes: 2052
import sys
input = sys.stdin.readline
Q=int(input())
def solv(A,B):
    if A==B:
        return 2*A-2

    if A>B:
        A,B=B,A

    l=A
    r=B*2
    while r-l>1:
        m=(l+r)//2
        x=(m+1)//2*(m//2+1)
        if x<A*B:
            l=m
        else:
            r=m
    return l-1



for i in range(Q):
    A,B=map(int,input().split())
    print(solv(A,B))


Measured memory_bytes: 38768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long count = 0l;
        long sum = 0l;
        while(sum < x) {
            count++;
            sum += count;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35708
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())


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

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
F = np.array(input().split(), dtype=np.int64)
A = np.sort(A)
F = np.sort(F)[::-1]


def C(x):
    train = np.maximum(0, A - x // F).sum()
    return train <= K


left = -1
right = 10 ** 12 + 1
while right > left + 1:
    mid = (right + left) // 2
    if C(mid):  # 食べきれる場合
        right = mid
    else:
        left = mid

ans = right
print(ans)



Measured memory_bytes: 37200
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    p = i*500
    for j in range(B+1):
        q = j*100
        for k in range(C+1):
            r = k*50
            if p+q+r == X:
                count+=1           
                
print(count)


Measured memory_bytes: 3060
from collections import Counter

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

A.sort()
A_counter = Counter(A)

dp = [True for _ in range(10**6+1)]
for a in A_counter:
    if dp[a] == False:
        continue
    for j in range(a*2, 10**6+1, a):
        dp[j] = False

c = 0
for a, v in A_counter.items():
    if dp[a] and v == 1:
        c += 1

print(c)


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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int x,y;
        cin>>x>>y;
        if(y>4*x)
        {
            cout<<"No"<<endl;
        }
        else
        {
            if(y%2!=0)
            {
                cout<<"No"<<endl;
            }
            else
            {
                if(y==4*x || y==2*x)
                {
                    cout<<"Yes"<<endl;
                }
                else
                {
                    bool flag=0;
                    for(int i=0;i<=x;i++)
                    {
                        if((i*2+(x-i)*4)==y)
                        {
                            flag=1;
                            cout<<"Yes"<<endl;
                            break;
                        }
                    }
                    if(flag==0)
                    {
                        cout<<"No"<<endl;
                    }
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3660
package main

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

var sc *bufio.Scanner

func nextString() string {
	sc.Scan()
	i := sc.Text()
	return i
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ans := 0
	ansB := 0
	for i := 0; i < n; i++ {
		a, b := nextString(), nextString()
		if a < b {
			ansB += 3
		} else if a > b {
			ans += 3
		} else {
			ans++
			ansB++
		}
	}
	fmt.Println(ans, ansB)
}



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

typedef pair<int, int> Pair;
typedef pair<Pair, Pair> PP;

int H;
int W;
int K;
int ans;
char field[114][514];
vector<Pair> around;
queue<PP> q;
map<PP, bool> calced;
map<Pair, int> rev;
map<int, int> dp[114][114][4];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
bool nocost[] = {0, 0, 1, 1};

bool WithinRange(int y, int x) {
  if (y < 0 || H <= y) return false;
  if (x < 0 || W <= x) return false;
  return true;
}

int ShiftHash(int hash, int dy, int dx) {
  int ret = 0;
  for (Pair p : around) {
    int y, x;
    tie(y, x) = p;
    int py = y + dy;
    int px = x + dx;
    if (rev.count(Pair(py, px))) {
      int v = hash >> rev[Pair(py, px)] & 1;
      ret |= v << rev[p];
    }
  }
  return ret;
}

int main() {
  scanf("%d%d%d", &H, &W, &K);
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      scanf(" %c", &field[i][j]);
      if (field[i][j] == '.') field[i][j] = '0';
    }
  }

  for (int i=-3; i<=3; i++) {
    for (int j=-3; j<=3; j++) {
      if (i == 0 && j == 0) continue;
      if (abs(i)+abs(j) <= 3) {
        rev[Pair(i, j)] = around.size();
        around.emplace_back(Pair(i, j));
      }
    }
  }

  dp[0][0][K][0] = 0;
  q.push(PP(Pair(0, 0), Pair(K, 0)));
  while (!q.empty()) {
    PP pp = q.front(); q.pop();
    int y, x, k, hash;
    tie(y, x) = pp.first;
    tie(k, hash) = pp.second;
    if (field[y][x] == '#') continue;
    if (calced.count(pp)) continue;
    calced[pp] = true;
    
    int val = dp[y][x][k][hash];
    //printf("(%d, %d, %d, %d): %d\n", y, x, k, hash, val);
    if (y == H-1 && x == W-1) {
      ans = max(ans, val);
    }

    for (int i=0; i<4; i++) {
      int ny = y + dy[i];
      int nx = x + dx[i];
      if (!WithinRange(ny, nx)) continue;
      if (field[ny][nx] == '#') continue;

      int plus = field[ny][nx] - '0';
      if (hash >> rev[Pair(dy[i], dx[i])] & 1) plus = 0;
    
      int nk = k;
      if (!nocost[i]) {
        if (k == 0) continue;
        nk = k-1;
      }

      int nhash = ShiftHash(hash, dy[i], dx[i]);
      nhash |= 1 << rev[Pair(-dy[i], -dx[i])];
      for (Pair p : around) {
        int a, b;
        tie(a, b) = p;
        int d = -(min(a, 0)+min(b, 0));
        if (d > nk) nhash &= ~(1 << rev[p]);
      }

      dp[ny][nx][nk][nhash] = max(dp[ny][nx][nk][nhash], val+plus);
      q.push(PP(Pair(ny, nx), Pair(nk, nhash)));
    }     
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 42892
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

int main(){	
	
	int n;
	long long d;
	cin >> n >> d;
	int cnt=0;
	for(int i=0;i<n;i++){
		long long x,y;
		cin >> x >> y;
		if(x*x+y*y<=d*d)cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h" // {{{
using namespace std;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define X           first
#define Y           second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#define FAST()      ios::sync_with_stdio(false), cin.tie(nullptr)
#ifndef DEBUG
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
#endif
typedef long long ll;
typedef pair<int,int> pii;
namespace ydk{
TMPLT(T,U) inline bool chmax(T &a, U b){return b>a ? a=b,1 : 0;}
TMPLT(T,U) inline bool chmin(T &a, U b){return b<a ? a=b,1 : 0;}
TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
{ return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
constexpr int INF   = 0x3f3f3f3f;
constexpr ll LINF   = 0x3f3f3f3f3f3f3f3fLL;
// }}}

constexpr int MX = ten(5) + 10;

int N;
int a[MX];
int dp[MX];

void Xx_main_xX()
{
    cin >> N;
    rep(i, N) cin >> a[i];

    FILL(dp, INF);
    rep(i, N) *lower_bound(dp, dp+N, a[i]) = a[i];

    val ans = lower_bound(dp, dp+N, INF) - dp;
    outl(ans);

    return;
}

} // {{{

signed main(){cout << fixed << setprecision(9); ydk::Xx_main_xX(); return 0;} // }}}




Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;


int main() {

    int n;
    cn n;
    ll sum=0;
    for (ll i = 1; i <=n; ++i)
    {
    	if(i%3!=0 && i%5!=0)sum+=i;
    }

    ct sum;nl;







    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No");
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


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

const int MX = 100001;

int main(){
  int n;
  cin >> n;
  vector<int> d(101,0);
  rep(i,n){
    int a;
    cin >> a;
    d[a]++;
  }

  int ans = 0;
  for(int i : d){
    if(i>0) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

class Program
{
 public static void Main(string[] args)
 {
   var s = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
   int num5 = s.Count(n => n == 5);
   int num7 = s.Count(n => n == 7);
   if(num5 == 2 && num7 == 1)
     Console.WriteLine("YES");
   else
     Console.WriteLine("NO");
 }
}

Measured memory_bytes: 11348
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	vector<string> w(n);
	REP(i, n)cin >> w[i];
	for (int i = 1; i < n;++i) {
		for (int j = 0; j < i; ++j) {
			if (w[i] == w[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
		//現在の文字列の最初と前回の文字列の最後の要素の合致判定
		if (w[i][0] != w[i - 1][w[i-1].size() - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

int main() {
 int h;
  int n;
  cin>>h>>n;
  int d=0;
  
  
  
  vector<int> vec(n);
     
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
    d+=vec.at(i);
  }
  if(d<h){
    cout<<"No"<<endl;
  }
    else{
      cout<<"Yes"<<endl;
    }
   
}
 


Measured memory_bytes: 640