akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

constexpr int MAX = 110;
constexpr int INF = (1 << 20);

int mem[MAX][MAX];

int solve(int L, int R, const vector<int>& c)
{
    if (L > R)  return 0;    
    if (L == R) return -INF;
    
    int& res = mem[L][R];
    if (res != -1) return res;
    
    if (c[L] == c[R]) {
        int nL = L + 1, nR = R - 1;
        while (nL < R  && c[nL] == c[L]) nL++;
        while (nR > nL && c[nR] == c[R]) nR--;
        res = max(res, solve(nL, nR, c) + (nL - L) + (R - nR));

        for (int i = nL + 1; i <= nR - 1; i++) {
            if (c[i] == c[L]) {
                int l = solve(nL, i - 1, c);
                int r = solve(i + 1, nR, c);
                if (l == (i - nL) && r == (nR - i)) {
                    res = max(res, l + r + (nL - L) + (R - nR) + 1);
                }
            }
        }
    }
    
    int nL = L + 1;
    while (nL <= R && c[nL] == c[L]) nL++;
    if (nL - L >= 2) {
        res = max(res, solve(nL, R, c) + (nL - L));
    }
    
    int nR = R - 1;
    while (nR >= L && c[nR] == c[R]) nR--;
    if (R - nR >= 2) {
        res = max(res, solve(L, nR, c) + (R - nR));
    }
        
    for (int i = L; i <= R - 1; i++) {       
        res = max(res, solve(L, i, c) + solve(i + 1, R, c));
    }
    return res;
}

int main()
{
    int N;
    cin >> N;
    vector<int> c(N);
    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }
    memset(mem, -1, sizeof(mem));
    cout << (solve(0, N - 1, c) == N ? "yes" : "no") << endl;
    return 0;
}

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


int main() {
  int x , y ;
  for(int i=1;i<10000;i++){
    cin >> x >> y ;
    if(x==0&&y==0){
      break;
    }
    if(x>y){
      swap(x,y);
    }
    cout << x << " " << y << endl;
  }
}


Measured memory_bytes: 3004
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int (i)=(a);(i)<(b);++(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cout<<#x<<"="<<(x)<<endl;
#define DBG(v) REP(__, LEN((v))) cout<<(v)[__]<<(__==LEN((v))-1 ? '\n' : ' ')
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<vector<int>> vii;
typedef vector<vector<lint>> vll;

const lint MOD = (lint)1e9 + 7;

void mod_add(lint &a, lint b){
    a = (a+b) % MOD;
}

class FCoincidence {
public:
    lint L, R;
    vll dp;

    void input(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in>>L>>R;
        dp = vll(61, vl(8, 0));
    }

    void solve(std::istream& in, std::ostream& out) {
        input(in, out);
        dp[60][0] = 1;
        for(int i=59;i>=0;i--){
            lint lb = (L>>i) & 1, rb = (R>>i) & 1;
            REP(j, 8){
                REP(k, 2) REP(l, 2){
                    int d = 0;
                    if(k<l) continue;
                    if(!(j>>2&1) and lb and !l) continue;
                    if(!lb and l) d |= 4;
                    if(!(j>>1&1) and !rb and k) continue;
                    if(rb and !k) d |= 2;
                    if(!(j&1) and k!=l) continue;
                    if(k&l) d |= 1;
                    mod_add(dp[i][j|d], dp[i+1][j]);
                }
            }
        }
        lint ans = 0;
        REP(i, 8) mod_add(ans, dp[0][i]);
        out<<ans<<'\n';
    }
};


int main() {
	FCoincidence solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 10000000
#define rep(i,a,b) for(ll (i)=a;(i)<(ll)(b);(i)++)
using ipair = pair<ll,ll>;

int main(){
    ll N,tmp,total =0;
    cin >> N;
    vector<ll> a(N,0);
    vector<ll> ans(N,0);
    rep(i,0,N) cin >> a[i];
    for(int i=0;i<N;i=i+2){
        tmp = a[i] ^ a[i+1];
        total = total ^ tmp;
    }
    rep(i,0,N){
        ans[i] = total^a[i];
    }
    for(auto x:ans) cout << x << " ";
    cout << endl;
}

Measured memory_bytes: 6340
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		sc.nextLine();
		for (int i = 0; i < t; i++) {
			String s = sc.nextLine();
			s = s.replaceAll("Hoshino", "Hoshina");
			System.out.println(s);
		}
	}

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

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

ll x(ll a) {
    if (a % 4 == 0) return a;
    if (a % 4 == 1) return 1;
    if (a % 4 == 2) return a + 1;
    return 0;
}

signed main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    rep(i, 2) {
        if(a > b) {
            ans += a;
            --a;
        } else {
            ans += b;
            --b;
        }
    }
    cout << ans << nl;
}


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

int main(){
	double pi=3.1415926535897932;
	double a,b,x;
	cin >>a>>b>>x;
	double ta=(2.0/a)*(b-x/(a*a));
	double the= atan(ta)*180.0/pi;
	if(ta<=b/a){
		printf("%.10f\n",the);
	}
	
	else {
		ta=(a*b*b)/(2.0*x);
		the =atan(ta)*180.0/pi;
		printf("%.10f\n",the);
	}
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

int n, a, b, c, d;
int mod = 1e9 + 7;
int dp[1010][1010];

typedef long long ll;
ll mod_pow(ll x,ll n){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2);
	if(n&1) res=res*x%mod;
	return res;
}
ll fact[200010];
ll factr[200010];
ll inv[200010];
ll get_nCk(ll n,ll k){
    if(k < 0 || k > n) return 0;
    return fact[n]*factr[k]%mod*factr[n - k]%mod;
}

int f(int p, int s){
    // if(s == 0) return 1;    
    // if(dp[p][s] != -1) return dp[p][s];  
    // if(p > b || s < 0) return 0;
      
    int& res = dp[p][s];
    if(res >= 0) return res;
    res = 0;
    if(s == 0){
        res = 1;
    }else{
        if(p > b) return 0;
        res += f(p + 1, s);
        int v = 1;
        for(int i = 1; i <= d && p <= s; i++){
            (v *= get_nCk(s, p) * inv[i] % mod) %= mod;
            s -= p;
            if(c <= i && i <= d){
                res += v * f(p + 1, s) % mod;
                // cout << p << " " << s << " " << i << " " << v << " " << res << endl;
            }
        }
    }
    res %= mod;
    return res;
 
}
//         }
//     }
//     int tmp[1010];
//     tmp[0] = 1;
//     rep(i, 1, d + 1){
//         if(s - p * (i - 1) < 0) break;
//         tmp[i] = tmp[i - 1] * get_nCk(s - p * (i - 1), p) % mod;
//         tmp[i] = tmp[i] * mod_pow(fact[i], mod - 2) % mod;
//     }
//     rep(i, c, d + 1){
//         if(s - p * i < 0) break;
//         (res += f(p + 1, s - p * i) * tmp[i]) %= mod;
//     }
//     // cout << p << " " << s <<" " <<  res << endl;
    
//     res += f(p + 1, s);
    
//     return dp[p][s] = res % mod;
// }

signed main(){
    cin >> n >> a >> b >> c >> d;
    rep(i, 0, 1010){
        rep(j, 0, 1010){
            dp[i][j] = -1;
        }
    }
    fact[0] = 1;
    factr[0] = 1;
    inv[1] = 1;
	for(int i=1;i<1010;i++) fact[i]=fact[i-1]*i%mod;
    for(int i = 1; i < 1010; i++) factr[i] = mod_pow(fact[i], mod - 2);
    for(int i = 2; i < 1010; i++) inv[i] = mod_pow(i, mod - 2);
    cout << f(a, n) << endl;
    // rep(i, a, b + 1){
    //     rep(j, 0, n + 1){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
}

Measured memory_bytes: 8320
n,m = map(int, input().split())
xl = list(map(int, input().split())) 
yl = list(map(int, input().split())) 

xl = list(map(lambda x: x-xl[0],xl))
yl = list(map(lambda x: x-yl[0],yl))

xi=0
yi=0
mod = 10**9+7
xsum = sum(xl)
ysum = sum(yl)
for i in range(n):
    xi += (xsum - xl[i]*(n-i)) % mod
    xsum -= xl[i] 
    
for j in range(m):
    yi += (ysum - yl[j]*(m-j)) % mod
    ysum -= yl[j]

print(xi*yi % mod)

Measured memory_bytes: 18752
#include<cstdio>
#include<algorithm>
int n,k;
double p[200010],ans=0;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%lf",p+i);
		ans+=(p[i]+1)/2;
	}
	double mxans=ans;
	for(int i=k+1;i<=n;i++)
	{
		scanf("%lf",p+i);
		ans-=(p[i-k]+1)/2;
		ans+=(p[i]+1)/2;
		mxans=std::max(ans,mxans);
	}
	
	printf("%.8lf\n",mxans);
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int main() {
	int N, D, X, i, t;
	scanf("%d %d %d", &N, &D, &X);
	for (i = 1; i <= N; i++) {
		scanf("%d", &t);
		X += (D - 1) / t + 1;
	}
	return !printf("%d\n", X);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)

int main(){
    //input
    int h, w;
    scanf("%d%d", &h, &w);
    char a[10][10];
    rep(i, h) scanf("%s", &a[i]);

    //solve
    int ok = 1, x = 0, y = 0;
    int ch[10][10] = {0};
    while(1){
        ch[x][y] = 1;
        if(x+1 < h){
            if(a[x+1][y] == '#'){
                x++;
                continue;
            }
        }
        if(y+1 < w){
            if(a[x][y+1] == '#'){
                y++;
                continue;
            }
        }
        break;
    }

    rep(i, h){
        rep(j, w){
            if(a[i][j] == '#' && ch[i][j] != 1){
                ok = 0;
                break;
            }
        }
    }

    //output
    if(ok) puts("Possible");
    else puts("Impossible");    
}

Measured memory_bytes: 1632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;


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


int main()
{
    int N,A;
    cin >> N >> A;
    vi x(N);
    in(N,x);
    
    ve<vl> dp(N+1,vl(7000,0));
    rep(i,N) x[i] -= A;
    sort(all(x));
    reverse(all(x));
    A+=3100;
    
    //outve(x);
    
    rep(i,N){
        rep(j,7000){
            if(x[i] == 0){
                if(j == 3100) dp[i+1][j] = dp[i][j]*2+1;
                else dp[i+1][j] = dp[i][j]*2;
            }else{
                if(j == x[i]+3100) dp[i+1][j]++;
                dp[i+1][j] += dp[i][j];
                dp[i+1][j+x[i]] += dp[i][j];
            }
        }
    }
    

    //outmat(dp);
    cout << dp[N][3100] << endl;
    
    
    
    

    return 0;
}


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

int n;
int a[200005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    int c=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==c){
            c++;
        }
    }
    cout<<(n-c+1==n?-1:n-c+1)<<endl;

    return 0;
}

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

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

  if (360 % x == 0)
    cout << 360 / x << endl;
  else {
    cout << (360 / x) * (360 / (360 % x)) << endl;
  }
}

Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

////////// 繰り返し二乗法 //////////

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

//////////////////////////////////////////////////

int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  ll ans=power(2,N)-1;
  
  ll a=1,af=1;
  REP(i,A){
    a*=N-i;
    a%=MOD;
    af*=i+1;
    af%=MOD;
  }
  ans-=a*power(af,MOD-2)%MOD;
  
  ll b=1,bf=1;
  REP(i,B){
    b*=N-i;
    b%=MOD;
    bf*=i+1;
    bf%=MOD;
  }
  ans-=b*power(bf,MOD-2)%MOD;
  
  ans%=MOD;
  if(ans<0) ans+=MOD;
  co(ans);
  return 0;
}

Measured memory_bytes: 3640
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    ll n;
    int ans, prev;

    while (~scanf("%lld", &n)) {
        if (n == -1) break;
        prev = 4280;
        ans = 1150;
        if (10 < n && n <= 20) {
            ans += (n - 10) * 125;
        } else if (20 < n && n <= 30) {
            ans += 1250 + (n - 20) * 140;
        } else if (30 < n) {
            ans += 1250 + 1400 + (n - 30) * 160;
        }
        OUT(prev - ans);
    }


    return 0;
}




Measured memory_bytes: 3128
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long
int main(){
	vector<string> strvec;
	string pre,now;
	int N,i;
	cin >> N;
	cin >>pre;
	strvec.push_back(pre);
	for(i=1;i<N;i++){
		cin >> now;
		if(pre[pre.size()-1]!=now[0]){
			cout <<"No";
			return 0;
		}
		vector<string>::iterator ite =find(strvec.begin(),strvec.end(),now);
		if(ite != strvec.end()){
			cout <<"No";
			return 0;
		}
		strvec.push_back(now);
		pre = now;
	}
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

temp1, temp2 = 0, 0
for i in A:
    if 0 < i < X:
        temp1 += 1
    elif X < i < N:
        temp2 += 1
print(min(temp1, temp2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
       int n;
       cin>>n;
    int ans[n+1]={},c=0;
    string x,y;
    cin>>x;
    y=x;
    for(int i=1;i<=n;i++){
      c=(2*c+(x[i-1]-'0'))%MOD;
      y[i-1]=x[i-1];
      if(n%i==0&&n%(2*i)!=0){
        for(int j=i;j<n;j++){
          if(y[j-i]=='0')y[j]='1';
          else y[j]='0';
        }
        ans[i]=(ans[i]+c)%MOD;
        if(y<=x)ans[i]=(ans[i]+1)%MOD;
        for(int j=2*i;j<=n;j+=i){
          if(n%j==0&&n%(2*j)!=0){
            ans[j]=(ans[j]+MOD-ans[i])%MOD;
          }
        }
      }
    }
    int ans2=0;
    for(int i=1;i<=n;i++)ans2=(ans2+ans[i]*i%MOD*2%MOD)%MOD;
    cout<<ans2<<endl;

                  
}


        


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

using namespace std;

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

    string res = "";
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0)
            res = res + s[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main{
	public static void main (String[] ages){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		double sum = 0;
		int count = 0;
		int[] a = new int[n];
		for(int i = 0;i<n;i++){
			a[i] = sc.nextInt();
			sum += a[i];
		}
		for(int i =0;i<n;i++){
			if(a[i]>=sum/(4*m)){
				count++;
			}
		}
		if(count>=m){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s1s2s3;
  cin>>s1s2s3;
  char one='1';
  
  int cnt=0;
  
  for(int i=0;i<3;i++){
    if(s1s2s3[i]==one){
      cnt++;
    }
  }
  
  cout<<  cnt  <<endl;
}

Measured memory_bytes: 256
n = int(input())

if n==1:
  print(1)
  exit()

balls=[]
for i in range(n):
  x,y = map(int, input().split())
  balls.append([x,y])

balls.sort()  
sorted(balls, key=lambda x: x[1])

hyo={}

for i in range(n):
  for j in range(i+1,n):
    difx=balls[j][0]-balls[i][0]
    dify=balls[j][1]-balls[i][1]
    if (difx,dify) in hyo.keys():
      hyo[(difx,dify)] +=1
    else:
      hyo[(difx,dify)] =1

#print(hyo)
p,q=max(hyo,key=hyo.get)

chk=[1]*n

for i in range(n-1,-1,-1):
  x=balls[i][0]-p
  y=balls[i][1]-q
  if [x,y] in balls:
    chk[i]=0
#print(balls)
#print(chk)
print(sum(chk))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if(a >= 13) {
      cout << b << '\n';
  } else if(a >= 6 && a <= 12) {
      cout << b/2 << '\n';
  } else {
      cout << 0 << '\n';
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
// typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  if((n/100)*5>=(n%100)){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
local L = {}
for i=1, 999 do
    L[i] = i * (i + 1) // 2
end
local a, b = io.read("n", "n")
for i=1, 998 do
    if b - a == L[i+1] - L[i] then
        print(L[i] - a)
        return
    end
end


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    string a = s.substr(0, n), b = s.substr(n);
    reverse(b.begin(), b.end());
    map<string,map<string,ll>> m;
    for(int i = 0; i < 1<<n; i++){
        string c = "", d = "";
        for(int j = 0; j < n; j++){
            if((i>>j)&1)    c += a[j];
            else            d += a[j];
        }
        m[c][d]++;
    }
    ll ans = 0;
    for(int i = 0; i < 1<<n; i++){
        string c = "", d = "";
        for(int j = 0; j < n; j++){
            if((i>>j)&1)    c += b[j];
            else            d += b[j];
        }
        ans += m[c][d];
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<pair<int, int>> range(N);
  for(int i = 0; i < N; ++i){
    int x, l;
    cin >> x >> l;
    range.at(i).first = x + l;
    range.at(i).second = x - l;
  }
  
  sort(range.begin(), range.end());
  
  int right = -100000001;
  int num = 0;
  for(int i = 0; i < range.size(); ++i){
    if(right <= range.at(i).second){
      right = range.at(i).first;
      num++;
    }
  }
  cout << num << endl;
  return 0; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
int l,m,n;
cin >> l >> m >> n;
vector<int> a(l);
vector<int> b(m);
rep(i,l) cin >> a.at(i);
rep(i,m) cin >> b.at(i);
vector<vector<int>> x(n,vector<int>(3));

rep(i,n)rep(j,3) cin >> x.at(i).at(j);
int ans = 100000000000000000;
int t;
rep(i,n){
  t = a.at(x.at(i).at(0)-1)+b.at(x.at(i).at(1)-1)-x.at(i).at(2);
  ans = min(ans,t);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
  if(a.at(0)+b.at(0) < ans) ans = a.at(0)+b.at(0);
cout << ans << endl;
}


Measured memory_bytes: 9516
#include <iostream>
using namespace std;
int main() {
  int A;
  int B;

  cin >> A;
  cin >> B;

  if(A >= 13)
  {
    cout << B;
  }else if( A >= 6)
  {
cout << B/2;
  }else if(A <= 5)
  {
cout << 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<queue>
using namespace std;
const int N=2e5+10;
struct Tree
{
	struct edge{int next,to;}a[N<<1];
	int head[N],cnt;
	void link(int x,int y)
		{
			a[++cnt]=(edge){head[x],y};head[x]=cnt;
			a[++cnt]=(edge){head[y],x};head[y]=cnt;
		}
}A,B;
int n,p1,p2,dep[N],dis[N],fr[N],vis[N],ans;
queue<int> Q;
void bfs1()
{
	memset(dis,-1,sizeof(dis));
	if(dep[p1]) Q.push(p1);dis[p1]=0;
	while(!Q.empty())
	{
		int x=Q.front();Q.pop();vis[x]=1;
		for(int i=A.head[x];i;i=A.a[i].next)
		{
			int R=A.a[i].to;
			if(dis[R]==-1)
			{
				dis[R]=dis[x]+1;
				if(dis[R]<dep[R]) Q.push(R);
				else if(dis[R]==dis[R]) vis[R]=1;
			}
		}
	}
}
void bfs2()
{
	memset(dep,-1,sizeof(dep));
	Q.push(p2);dep[p2]=0;
	while(!Q.empty())
	{
		int x=Q.front();Q.pop();
		for(int i=B.head[x];i;i=B.a[i].next)
		{
			int R=B.a[i].to;
			if(dep[R]==-1) dep[R]=dep[x]+1,fr[R]=x,Q.push(R);
		}
	}
}
int Dis(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	if(fr[x]==fr[y]||x==y||fr[x]==y) return 0;
	if(fr[fr[x]]==y) return 0;
	return 1;
}
int main()
{
	cin>>n>>p1>>p2;
	for(int i=1,x,y;i<n;i++) scanf("%d%d",&x,&y),A.link(x,y);
	for(int i=1,x,y;i<n;i++) scanf("%d%d",&x,&y),B.link(x,y);
	bfs2();bfs1();
	for(int x=1;x<=n;x++)
		for(int i=A.head[x];i;i=A.a[i].next)
			if(vis[x]&&vis[A.a[i].to]&&Dis(x,A.a[i].to))
				puts("-1"),exit(0);
	for(int i=1;i<=n;i++) if(vis[i]) ans=max(dep[i],ans);
	cout<<ans*2<<endl;
}


Measured memory_bytes: 12032
N = input()
n = len(N)
dp = [[0,0]for i in range(0,n,1)]#[i][0]その桁はピッタリ払う[i][1]一つ上の桁を１枚つかう　ときの合計枚数

dp[n-1][0] = int(N[n-1])
dp[n-1][1] = int(10 - int(N[n-1]) + 1 )#一つ上の桁で払うandおつり

for i in range(n-2,-1,-1):
    dp[i][0] = int(N[i]) + min(dp[i+1][0],dp[i+1][1])
    dp[i][1] = 10 - int(N[i]) + 1 + min(dp[i+1][0],dp[i+1][1] - 2)#次の桁で払った、の＋１を取り消すマイナス１と繰り下がりの

print(min(dp[0][0],dp[0][1]))

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  vector<int> Y(N);

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

  sort(Y.begin(),Y.end());
  map<int,int> idx;
  for(int i = 0; i < N; i++){
    if(idx[Y[i]] == 0) idx[Y[i]] = i;
  }
  for(int i = 0; i < N; i++){
    int j = idx[X[i]];
    if(j < N / 2){ cout << Y[N / 2] << endl; }
    else{ cout << Y[N / 2 - 1] << endl; }
  }
  return 0;
}

Measured memory_bytes: 12928
# D - Rain Flows into Dams

n = int(input())
a = list(int(x) for x in input().split())

tmp = 0
for i in range(n):
    if i%2==1:
        tmp += a[i] * -1
    else:
        tmp += a[i]
x = tmp//2

tmp2 = x
ans = []
for i in range(n):
    if i==0:
        ans.append(tmp2 * 2)
    else:
        tmp2 = a[i-1] - tmp2
        ans.append(tmp2 * 2)

print(' '.join(map(str, ans)))

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k % 2) cout << b - a << '\n';
  else cout << a - b << '\n';
}


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

using namespace std;

int main()
{
int n,d,c=0;
cin>>n>>d;
while(n--)
{
    int x,y;
    cin>>x>>y;
    double z=  sqrt(pow(x,2)+pow(y,2));
    //cout<<z<<endl;
    if(z<=d ){c++;}

}
cout<<c;
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;


int main(){
    ll n,a,b,x[10],y[10],max=0;
    x[0]=0;
    x[1]=mod;
    y[2]=0;
    y[3]=mod;
    x[4]=0;
    y[4]=0;
    x[5]=mod;
    y[5]=mod;
    x[6]=mod;
    y[6]=0;
    x[7]=0;
    y[7]=mod;

    cin>>n;
    rep(i,n){
        cin>>a>>b;
        if(a>x[0]){
            x[0]=a;
            y[0]=b;
        }
        if(a<x[1]){
            x[1]=a;
            y[1]=b;
        }
        if(b>y[2]){
            x[2]=a;
            y[2]=b;
        }
        if(b<y[3]){
            x[3]=a;
            y[3]=b;
        }
        if(a+b>x[4]+y[4]){
            x[4]=a;
            y[4]=b;
        }
        if(a+b<x[5]+y[5]){
            x[5]=a;
            y[5]=b;
        }
        if(-a+b>-x[6]+y[6]){
            x[6]=a;
            y[6]=b;
        }
        if(-a+b<-x[7]+y[7]){
            x[7]=a;
            y[7]=b;
        }
    }
    rep(i,8){
        rep(j,8){
            if(max<abs(x[i]-x[j])+abs(y[i]-y[j])){
                max=abs(x[i]-x[j])+abs(y[i]-y[j]);
            }
        }
    }
    cout<<max;
}

Measured memory_bytes: 3644
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    ll cnt=0;
    ll n,d;cin>>n>>d;
    REP(i,n){
        ll x,y;cin>>x>>y;
        if(x*x+y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3600
line = input()
num_query = int(input())

for loop in range(num_query):

    input_str = list(input().split())

    if input_str[0] == 'replace':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + input_str[3] + line[right:]

    elif input_str[0] == 'reverse':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + line[left:right][::-1] + line[right:]

    else:  # print
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        for i in range(left, right):
            print(line[i], end="")
        print()



Measured memory_bytes: 5712
N = int(input())
A = list(map(int,input().split()))
B = sorted([(a,i) for i,a in enumerate(A)])

dp = [[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    a,j = B.pop()
    for k in range(i+1):
        dp[k][i-k+1] = max(dp[k][i-k+1], dp[k][i-k] + a * abs(j-(N-1-(i-k))))
        dp[k+1][i-k] = max(dp[k+1][i-k], dp[k][i-k] + a * abs(j-k))

print(max(dp[i][N-i] for i in range(N+1)))

Measured memory_bytes: 100592
let levenshtein_distance s t =
  if s = t then 0
  else begin
    let m = String.length s in
    let n = String.length t in
    if m = 0 then n
    else if n = 0 then m
    else begin
      let v0 = Array.init (n + 1) (fun i -> i) in
      let v1 = Array.make (n + 1) 0 in
      for i = 0 to m - 1 do
        v1.(0) <- i + 1;
        for j = 0 to n - 1 do
          let c = if s.[i] = t.[j] then 0 else 1 in
          let t = if v1.(j) + 1 < v0.(j+1) + 1 then v1.(j) + 1 else v0.(j+1) + 1 in
          v1.(j+1) <- if v0.(j) + c < t then v0.(j) + c else t;
        done;
        Array.iteri (fun j e -> v0.(j) <- e) v1;
      done;
      v1.(n)
    end
  end

let () =
  let s1 = read_line () in
  let s2 = read_line () in
  Printf.printf "%d\n" (levenshtein_distance s1 s2)

Measured memory_bytes: 2340
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

/*
 * ref. [Union-Find](https://www.slideshare.net/chokudai/union-find-49066733)
 * ref. [AtCoder ABC 157 - AtCoder Live](https://www.youtube.com/watch?v=TdR816rqc3s)
 */
class UnionFind {
    public:
        UnionFind(int n = 0): d(n, -1) {}

        // 0-index, [0, n) in other words
        // Time complexity: O(a(n)) (a = inverse Achkermann function)
        int find(int x) {
            if (d[x] < 0) return x;
            return d[x] = find(d[x]);
        }

        // Return false if x and y are alreday in the same group, otherwise return true.
        // 0-index, [0, n) in other words
        // Time complexity: O(a(n)) (a = inverse Achkermann function)
        bool unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) return false;
            if (d[x] > d[y]) swap(x, y);
            d[x] += d[y];
            d[y] = x;
            return true;
        }

        // 0-index, [0, n) in other words
        // Time complexity: O(a(n)) (a = inverse Achkermann function)
        bool same(int x, int y) {
            return find(x) == find(y);
        }

        // 0-index, [0, n) in other words
        // Time complexity: O(1)
        int size(int x) {
            return -d[find(x)];
        }

    private:
        vector<int> d;
};

class Edge {
    public:
        int s;
        int t;
        int w;

        bool operator<(const Edge &other) const {
            return w < other.w;
        }

        bool operator>(const Edge &other) const {
            return w > other.w;
        }
};

// vector<vector<Edge>> edges;

int main(void) {
    int V, E;
    cin >> V >> E;

    priority_queue<Edge, vector<Edge>, std::greater<Edge>> queue;

    // edges.resize(V);
    for (int i = 0; i < E; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        // edges[s].push_back({t, w});
        // edges[t].push_back({s, w});
        queue.push({s, t, w});
    }

    UnionFind uf(V);

    ll ans = 0;
    while (!queue.empty()) {
        Edge edge = queue.top();
        queue.pop();
        if (uf.same(edge.s, edge.t)) continue;
        uf.unite(edge.s, edge.t);
        ans += edge.w;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4580
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func (p *problem) solve() {
	in := p.NextInts()
	A, B := in[0], in[1]
	if A <= 8 && B <= 8 {
		p.Printf("Yay!")
	} else {
		p.Printf(":(")
	}
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


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


#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int f(int x) {
	int ans = 0;
	while (x > 0) {
		ans += x % 10;
		x /= 10;
	}
	return ans;
}
int main() {
	int x;
	cin >> x;
	
	if(x % f(x) == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}






Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	ll X;
	ll sum=0;
	ll i = 1;
	ll sum1 = 0;
	cin >> X;
	while (X > sum) {
		sum += i;
		i += 1;
		sum1 += 1;
	}
	cout << sum1<<endl;
	return 0;
}

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

int main() {
    ll x;
    cin >> x;
    const ll n = 1000;
    vector<ll> convert(2 * n + 1);
    for (ll num = -n; num <= n; num++) {
        convert[n + num] = num * num * num * num * num;
    }
    // for (int i = 0; i <= 2 * n; i++) {
    //     cout << i << " " << convert[i] << endl;
    // }
    for (ll i = -n; i <= n; i++) {
        for (ll j = -n; j <= n; j++) {
            if (convert[n + i] - convert[n + j] == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3640
num = gets.to_i
num.times do
  cage1 = Array.new
  cage2 = Array.new
  data = gets.chomp!.split(/\s+/)
  data.size.times do |i|
    data[i] = data[i].to_i
  end
  cage1[0] = data[0]
  cage2[0] = 0
  j = 0
  k = 0
  switch = 0
  (data.size - 1).times do |l|
    if cage1[j] < data[l+1]
      cage1[j+1] = data[l+1]
      j = j + 1
    elsif cage2[0] == 0
      cage2[0] = data[l + 1]
    elsif cage2[k - 1] < data[l+1]
      cage2[k] = data[l+1]
      k = k + 1
    else
    switch = 1
    end
  end
  if switch == 0
    puts "YES"
  else
    puts "NO"
  end
end   

Measured memory_bytes: 6120
#include<iostream>
#include<map>
#include<string>
#include<set>
using namespace std;

int main(){
    set<string>st;
    int n; cin>>n;
    while(n--){
        string BUFF,c;
        cin>>BUFF>>c;
        if(BUFF=="insert"){
            st.insert(c);
        }
        else{
            cout<<(st.find(c)!=st.end()?"yes":"no")<<endl;
        }
    }
}


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

const ll MOD=1e9+7;
const ll INF=1e18;

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

vector<ll> v;

void calc(ll n){
    if(n>1e9) return;

    v.eb(n);
    calc(n*10+3);
    calc(n*10+5);
    calc(n*10+7);

    return;    
}

int main(){
    int n; cin>>n;
    calc(0);
    vector<ll> ans;
    for(int i=0; i<v.size(); i++){
        ll num=v[i];
        bool exist3=false, exist5=false, exist7=false;
        while(num>0){
            if(num%10==3) exist3=true;
            if(num%10==5) exist5=true;
            if(num%10==7) exist7=true;
            num/=10;            
        }

        if(exist3 && exist5 && exist7) ans.eb(v[i]);
    }

    int cnt=0;
    for(int i=0; i<ans.size(); i++){
        if(ans[i]<=n) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for (int i = l; i<r;i++)
#define dec(i, l, r) for (int i = l; i>=r;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define pb(c) push_back(c)
#define vii vector<pair<int,int>>
#define ii pair<int,int>
#define mp(i, j) make_pair(i,j)
#define ull unsigned long long int
#define ll  long long int
#define pie 3.141592653589793238
#define inf ((ll)1e18)
#define eps 1e-7
#define mod ((int)1e9+7)
#define maxlg 18
const int maxn = ((int) 4e5) +5;
#define left(i) ((i)<<1)
#define right(i) (((i)<<1)+1)
#define STRICTLY_INCREASNG
int pos[maxn];
int ans=0;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifndef ONLINE_JUDGE
 #endif
    int n;
    cin>>n;
    vi arr(n);
    rep (i,0,n) {
        cin>>arr[i];
        pos[arr[i]]=i;
    }
    int curr=1;
    int sz=1;

    while (curr!=n+1) {
        while (curr+1<=n && pos[curr+1]>pos[curr]) {
            curr++;
            sz++;
        }
        ans = max(ans,sz);
        sz=1;
        curr++;
    }
    cout<<n-ans;
    return 0;
}//cout<<"Case #"<<++T<<": ";

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll X;
  cin >> X;
  ll left = -1;
  ll right = 1e+5;

  while(right - left > 1){
    ll mid = left + (right - left) / 2;

    if(mid * (mid + 1) / 2 >= X) right = mid;
    else left = mid;

  }

  cout << right << endl;
  
  return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
C = [list(map(int, input().split())) for i in range(N)]
ans = -1
for i in range(2 ** N):
    rikaido = [0 for k in range(M)]
    kingaku = 0
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(M):
                rikaido[k] += C[j][k + 1]
            kingaku += C[j][0]
    if (min(rikaido) >= X) and (ans > kingaku or ans == -1):
        ans = kingaku
print(ans)

Measured memory_bytes: 9156
for e in iter(input,'0 0'):
 r=int(e.split()[0])
 d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
 a=0
 for i in range(1<<r):
  b=0
  for j in d:
   c=bin(i^j).count('1')
   b+=c if c>r//2 else r-c
  if a<b:a=b
 print(a)


Measured memory_bytes: 6916
def fib(n):
    if n <= 1:
        return n
    result = [1, 0, 0, 1]
    matrix = [1, 1, 1, 0]
    while n > 0:
        if n % 2:
            result = mul(matrix, result)
        matrix = mul(matrix, matrix)
        n //= 2
    return result[2]

def mul(a, b):
    return [a[0]*b[0] + a[1]*b[2],
            a[0]*b[1] + a[1]*b[3],
            a[2]*b[0] + a[3]*b[2],
            a[2]*b[1] + a[3]*b[3]]
    
N, M = map(int, input().split())
if N == 1:
    print(1)
    quit()
S = [-1]
for i in range(M):
    S.append(int(input()))
S.append(N + 1)
S = [S[i + 1] - S[i] for i in range(M + 1)]
if any([x == 1 for x in S]):
    print(0)
    exit()
num = 1
for x in S:
    num *=  fib(x - 1)
    num = num % 1000000007
print(num)

Measured memory_bytes: 13792
chomp(my $n = <>);
my @a = split(/\s/,<>);
my @a_sorted = sort {$a <=> $b } @a;
my $count = 0;
 
foreach my $i (0 .. @a){
    if ($a[$i] != $a_sorted[$i]){ 
        $count++;
    }
 
    if ($count > 2) {
        last;
    }
}
 
if ($count > 2){
    print "NO" . "\n";
} else {
    print "YES" . "\n";
}

Measured memory_bytes: 512
import itertools


N = int(input())

P = "".join(input().split())
Q = "".join(input().split())

# print(P)

p_index = -1
q_index = -1
permutation_list = list(itertools.permutations([x + 1 for x in range(N)]))
# print(permutation_list)
for i in range(len(permutation_list)):
    # print(permutation_list[i])
    param = "".join(map(str, permutation_list[i]))
    if P == param:
        p_index = i
    if Q == param:
        q_index = i
    if p_index != -1 and q_index != -1:
        result = p_index - q_index
        if result < 0:
            result = -result
        print(result)
        exit(0)


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

int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];

  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
string str;

int main(){
  cin>>str;
  if(str=="mew"){
    cout<<"Cat"<<endl;
    return 0;
  }
  bool flag=true;
  while(str.size()>0){
    if(str=="mew"){
      cout<<"Cat"<<endl;
      return 0;
    }
    string str2="";
    bool flagg=true;
    for(int i=0;i<str.size();i++){
      if(str.substr(i,3)=="mew"){
	str2+='1';
	i+=2;
	flagg=false;
      }else
	str2+=str[i];
    }
    str=str2;
    //  cout<<str<<endl;
    if(flagg){flag=false;break;}
    for(int i=0;i<str.size();i++){
      if(i==0&&str.size()!=1&&str[i]=='1'){
	flag=false;
	break;
      }else if(str[i]=='1'){
	if(i==str.size()-1){
	  flag=false;
	  break;
	}else if(!((str[i-1]=='m'&&str[i+1]=='e')||(str[i-1]=='e'&&str[i+1]=='w'))){flag=false;
	  break;
	}
      }
    }
    //cout<<str<<endl;
    if(flag)break;
    string str3="";
    for(int i=0;i<str.size();i++){
      if(str[i]!='1')
	str3+=str[i];
    }
    str=str3;
    //cout<<str<<endl;
  }
  if(flag){
    cout<<"Cat"<<endl;
  }else{
    cout<<"Rabbit"<<endl;
  }
  return 0;
}



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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<8>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<int>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1e9+7

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    int n;
    llint a[100010];
    llint b[100010];

    ci >> n;
    rep(i, 0, n + 1) ci >> a[i];
    rep(i, 0, n) ci >> b[i];

    llint cnt = 0;

    rep(i, 0, n) {
	if(a[i] <= b[i]) {
	    cnt += a[i];
	    b[i] -= a[i];
	} else {
	    cnt += b[i];
	    continue;
	}

	if(a[i + 1] <= b[i]) {
	    cnt += a[i + 1];
	    a[i + 1] = 0;
	} else {
	    cnt += b[i];
	    a[i + 1] -= b[i];
	}
    }

    
    
    co << cnt << en;
    
    return 0;
}


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


int main() {
  int N; cin >> N;
  vector<int> A(N);
  int max_a = 0;
  int min_a = 1000000000;


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

  for(int i=0; i<N; i++){
    max_a = max(max_a, A[i]);
    min_a = min(min_a, A[i]);
  }

  cout << max_a - min_a << endl;

  return 0;
}


Measured memory_bytes: 256
import itertools

a=list(map(int,list(input())))

#print(a)

for i in itertools.product([0,1], repeat=3):
    r=list(i)
    sump=a[0]
    for ii in range(3):
        if r[ii]==0:
            sump=sump-a[ii+1]
        else:
            sump=sump+a[ii+1]
#    print(sump,r) 
    if sump==7:
        stra=str(a[0])
        for ii in range(3):
            if r[ii]==0:
                stra=stra+"-"+str(a[ii+1])
            else :
                stra=stra+"+"+str(a[ii+1])
        stra=stra+"=7"        
        print(stra)
        break

Measured memory_bytes: 3064