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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  string s;
  cin >> s;
  vector<char> v = {'W', 'S', 'N', 'E'};
  map<char, int> mp;
  rep(i, 4){
    mp[v[i]] = 0;
  }
  rep(i, s.size()){
    mp[s[i]]++;
  }
  bool flag = true;
  if(mp['S'] != 0 || mp['N'] != 0){
    if(mp['S'] == 0 || mp['N'] == 0){
      flag = false;
    }
  }

  bool flag2 = true;
  if(mp['W'] != 0 || mp['E'] != 0){
    if(mp['W'] == 0 || mp['E'] == 0){
      flag2 = false;
    }
  }

  if(flag && flag2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << 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;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    for(char i = 'a'; i <= 'z'; i++) {
        vector<int> idx1, idx2;
        rep(j, s.size()) if(s[j] == i) idx1.push_back(j);
        rep(j, t.size()) if(t[j] == i) idx2.push_back(j);
        rep(j, idx1.size()) if (t[idx1[0]] != t[idx1[j]]) {
            cout << "No" << endl;
            return 0;
        }
        rep(j, idx2.size()) if (s[idx2[0]] != s[idx2[j]]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    bool flg1 = true, flg2 = true, flg3 = true;
    int cn = 0, dn = 0;

    if(s[0] != 'A') flg1 = false;

    Rep(i, 2, s.size()-1){
        if(s[i] == 'C') cn++;
    }
    if(cn != 1) flg2 = false;

    rep(i, s.size()){
        if(s[i] - 'a' >= 0) dn++;
    }
    if(dn != s.size() - 2) flg3 = false;

    if(flg1 && flg2 && flg3){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
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();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class ESecondSum {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<int> P(N);
	    REP(i,0,N) in >> P[i];

	    vector<pair<int,int>> pIndex(N);
	    REP(i,0,N) pIndex[i] = {P[i], i};
	    sort(all(pIndex), greater<pair<int,int>>());


        ll answer = 0;
	    set<int> processed;
	    REP(i,0,N) {
	        const int target = pIndex[i].first;
	        const int targetIndex = pIndex[i].second;
	        const auto itrRight = processed.upper_bound(targetIndex);
	        const auto itrLeft = itrRight != processed.begin() && processed.size() != 0 ? prev(itrRight) : processed.end();
	        if (itrRight != processed.end()) {
                const auto itrRight2 = next(itrRight);
                ll left = itrLeft != processed.end() ? targetIndex - *itrLeft : targetIndex+1;
	            ll right = itrRight2 != processed.end() ? *itrRight2 - *itrRight : N - *itrRight;
	            answer += left * right * target;
            }
	        if (itrLeft != processed.end()) {
                const auto itrLeft2 = itrLeft != processed.begin() && processed.size() != 0 ? prev(itrLeft) : processed.end();
                ll left = itrLeft2 != processed.end() ? *itrLeft - *itrLeft2 : (*itrLeft)+1;
                ll right = itrRight != processed.end() ? *itrRight - targetIndex : N - targetIndex;
                answer += left * right * target;
	        }
	        processed.insert(targetIndex);
	    }
	    out << answer << "\n";
	}
};


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


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,C;cin >> A >> B >> C;
  bool issat = false;
  repp(i,0,B){
    if(A*i%B == C)issat = true; 
  }
  YESNO(issat);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define mem(a,b) memset(a,b,sizeof a) ;
#define vi vector<int>
#define ull unsigned long long
#define ll long long 
#define db double 
#define ldb long double
#define fl float
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lrep(i,a,b) for(ll i=a;i<b;i++)
//#define mod 1000000007
#define mpr make_pair
#define pb push_back
#define fr first
#define sn second
#define bpp(x) __builtin_popcountll(x)
const ldb PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899863;
const int INF = 1e9;
bool ok(string &s ,int l ,int r)
{
while(s[l]==s[r]) l++,r--;
return l>=r; 
}/*
ll por(ll a,int b)
{
ll res=1,M=998244353;
while(b)
{
if(b&1)
res=(res*a)%M;
a=(a*a)%M;
	b/=2;
}
return res;
}
void rev(vector<int>&arr,int l,int r)
{
    for(;l<r;l++,r--) swap(arr[l],arr[r]);
}
void solve()
{
// Dont apply return before taking all the input of particular test case
/* carry operation
int cr=1;
int y=k-1;
while(cr)
{
char op=str[y];
op++;
if(op<='9') cr=0;
else op='0';
str[y]=op;
y--;
}
return;
}
*/
void solve()
{
int n,k,x; cin>>k>>n;
int a[n];
int ans=0,mn=10000000,mx=0;
cin>>a[0];
x=a[0];
for(int i=1;i<n;i++)
{
cin>>a[i];
ans=max(ans,a[i]-x);
x=a[i];
}
ans=max(ans,k-a[n-1]+a[0]);
cout<<k-ans;
return;
}
int main()
{
ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
//	cin>>t;
while(t--)
{
solve();
}
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

const int MAX_H = 50;
const int MAX_W = 50;
string field[MAX_H];
int dist[MAX_H][MAX_W];
int H, W;

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

bool bfs(int x, int y)
{
    queue<P> que;
    que.push(P(y, x));

    while (!que.empty())
    {

        tie(y, x) = que.front();
        que.pop();
        if (y == H - 1 && x == W - 1)
            return true;

        for (int i = 0; i < 4; i++)
        {
            int ny = dy[i] + y;
            int nx = dx[i] + x;

            // field外
            if (ny < 0 || ny >= H || nx < 0 || nx >= W || field[ny][nx] == '#')
                continue;
            // 既に探索済み
            if (dist[ny][nx] != -1)
                continue;

            dist[ny][nx] = dist[y][x] + 1;
            que.push(P(ny, nx));
        }
    }

    return false;
}

int main()
{
    cin >> H >> W;
    for (int i = 0; i < H; i++)
    {
        cin >> field[i];
    }

    // 初期化+黒マスの数をカウント
    int cnt_white = 0;
    for (int y = 0; y < H; y++)
    {
        for (int x = 0; x < W; x++)
        {
            dist[y][x] = -1;
            if (field[y][x] == '.')
            {
                cnt_white++;
            }
        }
    }

    // bfs
    dist[0][0] = 0;
    if (!bfs(0, 0))
    {
        cout << -1 << endl;
        return 0;
    }
    else
    {
        cout << cnt_white - 1 - dist[H - 1][W - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
program Bounding
    implicit none
    integer(4):: n,x,nx,i
    integer(4),allocatable:: l(:)

    read*, n,x
    allocate(l(n))
    read*, l(:)
    nx=0
    do i=1,n
        nx=nx+l(i)
        if (nx > x) then
            print*, i
            stop
        end if
    end do
    print*, n+1


end program Bounding

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846264338327950;
inline int newline() { putchar('\n'); return 0; }

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

    vector<int> a(n);
    rep2(i, n) cin(a[i]);

    ll currentMoney = 1000;

    rep2(i, n - 1) {
        ll stocks = 0;
        if (a[i] < a[i + 1]) stocks = currentMoney / a[i];
        currentMoney += (a[i + 1] - a[i]) * stocks;
    }

    print(currentMoney);

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::pair<ll, ll> pll;

using namespace std;

int main() 
{   
    int n;
    cin >> n;
    v_int index(n, 0);
    v_int p(n), q(n);
    v_string p_vec, q_vec;
    string p_string = "", q_string = "";
    irep(i, n) { index[i] = i; }
    irep(i, n) { cin >> p[i]; p_string += to_string(p[i]); }
    irep(i, n) { cin >> q[i]; q_string += to_string(q[i]); }
    

    do {
        string s = "", t = "";
        irep(i, n) {
            //cout << q[index[i]] << " ";
            s += to_string(p[index[i]]);
            t += to_string(q[index[i]]);
        } //cout << endl;
        //cout << s << endl; cout << t << endl;
        p_vec.push_back(s);
        q_vec.push_back(t);

    } while(next_permutation(index.begin(), index.end())); 
    //for(auto ans : p_vec) { cout << "p_string," << p_string << ",P_vec," << ans << endl; }
    sort(p_vec.begin(), p_vec.end());
    sort(q_vec.begin(), q_vec.end());
    
    int p_index, q_index;
    irep(i, p_vec.size()) {
        if(p_string == p_vec[i]) { 
            p_index = i+1;
        }
        if(q_string == q_vec[i]) { 
            q_index = i+1;
        }
    }

    cout << abs(p_index - q_index) << endl;

    return 0;
}


Measured memory_bytes: 4720
#include<bits/stdc++.h>
#define N 500005
using namespace std;
bool vis[N];
int n,x,k,ans,kk,dep[N],fat[N],head[N];
struct Tree{int nxt,to;}e[N];
inline void link(int x,int y){e[++kk].nxt=head[x];e[kk].to=y;head[x]=kk;}
void dfs(int u,int fa){
	dep[u]=0;
	for (int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if (v==fa) continue;
		dfs(v,u);
		dep[u]=max(dep[u],dep[v]+1);
	}
	if (dep[u]==k-1&&fa!=1) ans++,dep[u]=-1;
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&x);
		if (i==1&&x!=1) ans++;
		if (i!=1) link(x,i);
	}
	dfs(1,1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 13952
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    ll n = s.size();
    Pll res;
    bool ok = false;
    rep(i,n-1){
        if(s[i] == s[i+1]){
            res = Pll(i+1,i+2);
            ok = true;
            break;
        }
    }
    rep(i,n-2){
        if(s[i] == s[i+2]){
            res = Pll(i+1,i+3);
            ok = true;
            break;
        }
    }
    auto print = [&](Pll x){
        cout << x.first << " " << x.second << endl;
    };
    ok ? print(res) : print(Pll(-1,-1));
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main()
{
    int n ;
    cin >> n ;
    if(n%10 == 3)
    {
        cout << "bon\n" ;
    }
    else if( (n%10 == 0) || (n%10 == 1) || (n%10 == 6) || (n%10 == 8) )
    {
        cout << "pon\n" ;
    }
    else
    {
        cout << "hon\n" ;
    }
    
}

Measured memory_bytes: 3636
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long x=sc.nextLong();
        long p=100;
        long yr=0;
        long balance=p;
        while(balance<x)
        {
            long temp=balance/100;
            balance+=temp;
            yr++;
        }
        System.out.println(yr);
    }
}

Measured memory_bytes: 35760
A, B, C, D = map(int,input().split())
cntT = 0
cntA = 0

while (A > 0):
    A = A - D
    cntT = cntT + 1

while (C > 0):
    C = C - B
    cntA = cntA + 1

if cntT >= cntA:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 2; j < 9; j++){
            int p = pow(i, j);
            if(p <= n) {
                ans = max(ans, p);
            }
        }
    }
    cout << ans;
}

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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int a, b, c;
	cin >> a >> b;
	c = a*pow(10, (int)log10(b)+1)+b;
	if ((int)sqrt(c) * (int)sqrt(c) == c) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string S;
	cin >> S;
	if (S == "Sunny"){
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy"){
		cout << "Rainy" << endl;
	}
	else{
		cout << "Sunny" << endl;
	}

	return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int p[n];
    rep(i,n) cin >> p[i]; 
    double num[200001];
    int sum[200001];
    sum[0]=0;
    for(int i=1;i<200001;i++){
        sum[i]=sum[i-1]+i;
    }
    for(int i=1;i<200001;i++){
        num[i]=(1.0/i)*sum[i];
    }
    double save=0;
    rep(i,k) save+=num[p[i]];
    double ans=save;
    //cout << ans << endl;
    for(int i=k;i<n;i++){
        double temp=save+num[p[i]]-num[p[i-k]];
        ans=max(ans,temp);
        save=temp;
    }
    printf("%.16lf\n",ans);

}

Measured memory_bytes: 3328
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
a=[0]
b=[0]
for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])
j=M
for i in range(N+1):
  if a[i]>K:
    break
  while a[i]+b[j]>K:
    j-=1
  ans=max(i+j,ans) 
print(ans)

Measured memory_bytes: 47348
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, b, n) for (int i = b; i < n; ++i)

using namespace std;

void solve(long N, long K, vector<long> A) {
  cout << ceil(float(N - 1) / (K - 1)) << endl;
}

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

  long N, K;
  cin >> N >> K;

  vector<long> A(N);
  REP(i, N)
    cin >> A[i];

  solve(N, K, move(A));

  return 0;
}


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


string str;
int idx;
char c;

bool next(){
	if(idx < str.length()){
		c = str[idx++];
		return true;
	}else{
		return false;
	}
}

bool recur(){
	while(1){
		if(c == '('){
			if(!next()) return false;
			if(!recur()) return false;
			if(c != ')') return false;
		}else if(c == '['){
			if(!next()) return false;
			if(!recur()) return false;
			if(c != ']') return false;

		}else if(c == ')' || c == ']'){
			return true;
		}

		if(!next()) return true;
	}
}

int main(){
	while(getline(cin, str), str != "."){
		idx = 0;
		next();
		cout << (recur() && idx == str.length() ? "yes" : "no") << endl;

	}
}

Measured memory_bytes: 1172
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

const double PI = acos((double)-1);
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double t1 = (double) (h * 60.0 + m) / (12 * 60) * 2 * PI,
         t2 = (double) 2 * PI * m / 60.0;
  double theta = abs(t1 - t2);
  theta = min(theta, 2 * PI - theta);
  double c = a * sin(theta), e = a * cos(theta);
  double f = b - e;
  double ans = sqrt((double) c * c + f * f);
  cout << setprecision(10) << fixed << ans << "\n";
}



Measured memory_bytes: 4188
dim = 7
prime = [1]*(10**dim+1)
from collections import Counter
p = Counter()
p_set = []
for i in range(2,10**dim+1):
    j = i
    if prime[i] != 0:
        p[i] += 1
        p_set.append(i)
        while(j <= 10**dim):
            prime[j] = 0
            j += i

N = int(input())
cnt = 0
for n in p_set:
    if n > N:
        break
    while(1):
        if N%(n**p[n])==0:
            N //= n**p[n]
            cnt += 1
            p[n] += 1
        else:
            break
for n in p_set:
    if n > N:
        break
    while(1):
        if N%n == 0:
            N //= n
        else:
            break
if N > 1:
    cnt += 1
print(cnt)

Measured memory_bytes: 226852
#include<iostream>

using namespace std;

int main(){
    int n;
    int d[1001][11][21];
    int i,j,k,l;
    l = 0;
    for(i = 1;i < 1001;i++){
        for(j = 1;j < 11;j++){
            for(k = 1;k < 21;k++){
                if((!(j%2))&&(i%3)){
                    if(k == 20) continue;
                }
                d[i][j][k] = l;
                l++;
            }
        }
    }
    cin >> n;
    for(i = 0;i < n;i++){
        cin >> j >> k >> l;
        cout << d[1000][1][1]-d[j][k][l] << endl;
    }
}

Measured memory_bytes: 2060
n,m=map(int,input().split())
sc=[[0]*2 for ii in range(m)]
for ii in range(m):
  sc[ii][:]=map(int,input().split())
s=[0]*n
f=[False]*n
for ii in range(m):
  if f[sc[ii][0]-1]:
    if s[sc[ii][0]-1]!=sc[ii][1]:
      print(-1)
      exit()
  else:
    f[sc[ii][0]-1]=True
    s[sc[ii][0]-1]=sc[ii][1]
    
if n>1 and s[0]==0:
  if not f[0]:
    s[0]=1
  else:
    print(-1)
    exit()
print(int("".join([str(ii) for ii in s])))

Measured memory_bytes: 3064
n=int(input())
p=list(map(int,input().split()))
a=0
for i in range(1,n-1):
    if p[i-1]>p[i] and p[i]>p[i+1]:
        a+=1
    elif  p[i+1]>p[i] and p[i]>p[i-1]:
        a+=1
print(a)

Measured memory_bytes: 61744
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
public class Test {  
static public void Main() { 
var HN = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); var H = HN[0]; var N = HN[1]; 
  
   Console.WriteLine((3*H+N)/2); } 
} 


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W,N;cin>>H>>W>>N;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin>>S[i];
    }
    bool ans=false;
    
    for(int p=0;p<H;p++){
        for(int q=0;q<W;q++){
            vector<string> sub=S;
            swap(S[p][q],S[p][q+1]);
            
            for(int t=0;t<=H;t++){
                for(int i=H-1;i>=1;i--){
                    for(int j=0;j<W;j++){
                        if(S[i][j]=='.'&&S[i-1][j]!='.') swap(S[i][j],S[i-1][j]);
                    }
                }
            }
            
            while(1){
                bool did=false;
                vector<vector<int>> change(H,vector<int>(W));
                
                for(int i=0;i<H;i++){
                    for(int j=0;j<W;j++){
                        if(S[i][j]=='.') continue;
                        int inow=i,jnow=j;
                        while(jnow<W&&S[inow][jnow]==S[i][j]) jnow++;
                        if(jnow-j>=N){
                            for(int k=j;k<jnow;k++) change[i][k]=1;
                            did=true;
                        }
                        
                        inow=i;jnow=j;
                        while(inow<H&&S[inow][jnow]==S[i][j]) inow++;
                        if(inow-i>=N){
                            for(int k=i;k<inow;k++) change[k][j]=1;
                            did=true;
                        }
                    }
                }
                
                for(int i=0;i<H;i++){
                    for(int j=0;j<W;j++){
                        if(change[i][j]) S[i][j]='.';
                    }
                }
                
                for(int t=0;t<=H;t++){
                    for(int i=H-1;i>=1;i--){
                        for(int j=0;j<W;j++){
                            if(S[i][j]=='.'&&S[i-1][j]!='.') swap(S[i][j],S[i-1][j]);
                        }
                    }
                }
                
                if(!did) break;
            }
            
            int cnt=0;
            
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(S[i][j]!='.') cnt++;
                }
            }
            
            if(cnt==0) ans=true;
            
            S=sub;
            
            //if(cnt==0) cout<<p<<" "<<q<<endl;
        }
    }
    
    if(ans) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}



Measured memory_bytes: 3244
def main():
    N = int(input())
    pl = tuple(map(float, input().split()))
    v = [1 - pl[0], pl[0]]
    mid = (N + 1) // 2
    for i, p in enumerate(pl[1:mid], 1):
        v = v + [0.0]
        t = v[0]
        v[0] = t * (1 - p)
        for j, uu in enumerate(v[1:], 1):
            v[j] = t * p + uu * (1 - p)
            t = uu
    for i, p in enumerate(pl[mid:], mid):
        t = v[i - mid + 1]
        for j, uu in enumerate(v[i - mid + 2:-1], i - mid + 2):
            v[j] = t * p + uu * (1 - p)
            t = uu
        v[mid] += t * p
    print(v[mid])

main()


Measured memory_bytes: 41436
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;	// 998244353
using ll = long long;
using namespace std;

const int bound = 1e5+10;

int memo[bound];
bool visited[bound];

int k;
vector<int> h;

int f( int x ){
	if( visited[x] ) return memo[x];
	visited[x] = true; 
	int ans = inf;
	for( int i = x-1; x-k <= i and 0 <= i; --i ){
		ans = min( ans, f(i)+abs(h[x]-h[i]) );
	}
	return memo[x] = ans;
}

int main(){
	int n; cin >> n >> k;
	h.resize(n);
	visited[0] = true;
	for( auto &k : h ) cin >> k;
	cout << f(n-1) << endl;
}

Measured memory_bytes: 7424
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

ll f(ll b, ll n) {
    ll ans = 0;
    while (n) {
        ans += n%b;
        n /= b;
    }
    return ans;
}

int main() {
    ll n, s;
    cin >> n >> s;
    for (ll b = 2; b <= TEN(6); b++) {
        if (f(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }
    ll ans = TEN(18);
    if (n == s) ans = n+1;
    for (ll u = 1; u <= TEN(6); u++) {
        // u, s-u
        // u * b + (s-u) = n
        // b = (n-s)/u + 1
        ll b = (n-s)/u + 1;
        if (b < 2) continue;
        if (f(b, n) != s) continue;
        ans = min(ans, b);
    }
    if (ans == TEN(18)) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N,M,K = map(int,input().split())

flag = False
for i in range(N+1):
    for j in range(M+1):
        cnt = 0

        cnt += i * M
        cnt += j * N
        cnt -= (i*j)*2

        if cnt == K:
            flag = True
            break
    if flag:
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#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 MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
//setprecision(15)

int main() {
	int N, M; cin >> N >> M;
	vector<int> v(N, -1);
	int s, c;
	rep(i, M) {
		cin >> s >> c;
		if ((N > 1) && (s == 1) && (c == 0)) goto ERR_END;
		if (v[s-1] != -1 && v[s-1] != c) goto ERR_END;
		v[s-1] = c;
	}
	rep(i, N) {
		if (v[i] != -1) continue;
		if (i == 0) {
			if (N == 1) v[i] = 0;
			else v[i] = 1;
		} else {
			v[i] = 0;
		}
	}
	rep(i, N) cout << v[i];
	cout << endl;
	return 0;
ERR_END:
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int main() {
    int A, P;
    cin >> A >> P;
    cout << (3*A+P)/2 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>

#define rep(i,n) for(int i = 0;i < (n);i++)
#define repp(i,j, n) for(int i = (j);i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int size = s.size();
  if(s[0] == s[size-1]){
    if(size%2 == 0){
      cout << "First" << endl;
    }else{
      cout << "Second" << endl;
    }
  }else{
    if(size%2 == 0){
      cout << "Second" << endl;
    }else{
      cout << "First" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> Y(M);
    vector<int> P(M);
    rep(i, 0, M) {
        cin >> P[i] >> Y[i];
        --P[i];
    }

    vector<vector<int>> vals(N);
    rep(i, 0, M) vals[P[i]].push_back(Y[i]);
    rep(i, 0, N) {
        sort(vals[i].begin(), vals[i].end());
        //普通はダブリをなくすらしい
        vals[i].erase(unique(vals[i].begin(), vals[i].end()), vals[i].end());
    }

    rep(i, 0, M) {
        int v = P[i];
        printf("%06d", v + 1);
        
        int id = lower_bound(vals[v].begin(), vals[v].end(), Y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
    }
}

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



int nearUp(int x, int a[]){
    int r=-1;
    int k=0;
    while(x-1+k<102){
        if(a[x+k]==1){
            r=x+k;
            break;
        }
        k++;
    }
    return r;

}

int nearDn(int x, int a[]){
    int r=-1;
    int k=0;
    while(x-1-k>-5){
        if(a[x-k]==1){
            r=x-k;
            break;
        }
        k++;
    }
    return r;

}

int near(int x,int a[]){
    int up=nearUp(x,a);
    int dn=nearDn(x,a);
    if(up==-1){
        return dn;
    }else if(dn==-1){
        return up;
    }else{
        if(x-dn>up-x){
            return up;
        }else{
            return dn;
        }
    }
}


int main(){
    int x;
    int n;
    int a[103];
    int r=0;
    int hoge;

    cin>>x;
    cin>>n;


    for(int i=0;i<103;i++){
        a[i]=1;
    }

    for (int i=0;i<n;i++){
        cin>>hoge;
        a[hoge]=-1;
    }

  
    

    cout<<near(x,a);
    return 0;

}

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

using namespace std;

int main(){
	string a, b;
	cin >> a >> b;
	if(a.size() < b.size()){
		cout << "LESS" << endl;
		return 0;
	}else if(a.size() > b.size()){
		cout << "GREATER" << endl;
		return 0;
	}
	for(int i = 0; i < a.size(); ++i){
		if(a[i] < b[i]){
			cout << "LESS" << endl;
			return 0;
		}else if(a[i] > b[i]){
			cout << "GREATER" << endl;
			return 0;
		}
	}
	cout << "EQUAL" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public class MainClass
{
    public static void Main()
    {
        string line = System.Console.ReadLine();
        string[] strs = line.Split(' ');
        long A = long.Parse(strs[0]);
        long B = long.Parse(strs[1]);
        long K = long.Parse(strs[2]);

        if(A >= K)
        {
            A -= K;
        }
        else
        {
            B -= K - A;
            if(B < 0){
                B = 0;
            }
            A = 0;
        }
        /*
        for(long i =0; i < K; i++)
        {
            if(A > 0)
            {
                A--;
            }
            else if (B > 0)
            {
                B--;
            }
            else
            {
                break;
            }
        }*/


        System.Console.WriteLine(A + " " + B);
    }
}

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

int main() {
  string S;
  cin >> S;
  string R;
  if (S == "Sunny") R = "Cloudy";
  if (S == "Cloudy") R = "Rainy";
  if (S == "Rainy") R = "Sunny";
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[1]:


MOD = 10 ** 9 + 7
N = int(input())


# In[2]:


# N = 1000


# In[3]:


yakusu = [0 for _ in range(10**3 + 1)]
for n in range(2, N+1):
    for i in range(2, 10 ** 3):
        count = 0
        while n % i == 0:
            count += 1
            n //= i
        if count > 0:
            yakusu[i] = (yakusu[i]+count) % MOD
        if n == 1:
            break
    


# In[4]:


yakusu


# In[5]:



ans = 1
for i in yakusu:
    if i > 0:
        ans = ans * (i+1) % MOD
print(ans)


# In[ ]:






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

struct unionfind {
  vector<int> parent;
  vector<int> per_size;

  unionfind(int n): parent(n, -1), per_size(n, 1) {}

  int root(int x){
    return parent[x] != -1 ? parent[x] = root(parent[x]) : x; 
  }

  void unite(int x, int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry) return;
    if(per_size[rx] < per_size[ry]) swap(rx, ry);
    per_size[rx] += per_size[ry];
    parent[ry] = rx; 
  }

  bool is_same(int x, int y){
    return root(x) == root(y);
  }

  int tree_size(int x){
    return per_size[root(x)];
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> edges(m);
  for(int i = 0, x, y; i < m; ++i){
    cin >> x >> y;
    x--; y--;
    edges[i] = make_pair(x, y);
  }
  int ans = 0;
  for(int i = 0; i < m; ++i){
    unionfind uf(n);
    for(int j = 0; j < m; ++j){
      if(i == j) continue;
      uf.unite(edges[j].first, edges[j].second);
    }
    if(uf.tree_size(n - 1) != n) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  vector<int>p(N);
  for (int i = 0; i < N; i ++) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < K; i ++) ans += p[i];
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
int n, k, a[2000001], b[2000001], c[2000001];
static void csort(void) {
    for (int i = 0; i <= k; ++i) {
        c[i] = 0;
    }
    for (int i = 1; i <= n; ++i) {
        ++c[a[i]];
    }
    for (int i = 1; i <= k; ++i) {
        c[i] += c[i - 1];
    }
    for (int i = n; i > 0; --i) {
        b[c[a[i]]] = a[i];
        --c[a[i]];
    }
}
int main() {
    std::cin >> n;
    k = 0;
    for (int i = 1; i <= n; ++i) {
        std::cin >> a[i];
        if (k < a[i]) {
            k = a[i];
        }
    }
    csort();
    for (int i = 1; i <= n; ++i) {
        std::cout << ((i == 1) ? "" : " ") << b[i];
    }
    std::cout << std::endl;
}



Measured memory_bytes: 18760
declare function require(x: string): any;

const main = (input: string[][]) => {
    const n: number = Number(input[0][0]);
    const a: number = Number(input[0][1]);
    const b: number = Number(input[0][2]);
    let count = 0;
    for (let i = 1; i <= n; i++) {
        let digitSum = String(i)
            .split('')
            .map(Number)
            .reduce((a, b) => a + b);
        if (a <= digitSum && digitSum <= b) count+= i;
    }
    console.log(count);
};

const whole_input: string = require('fs').readFileSync('/dev/stdin', 'utf8');

main(whole_input.split('\n').map((s: string) => s.split(' ')));


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n+1, 0);
    for(int i = 1; i <= n; i++)  cin >> v[i];
    vector<bool> ans(n+1, 0);
    for(int i = n; i >= n/2+1; i--){
        if(v[i] == 1)   ans[i] = true;
    }
    for(int i = n/2; i >= 1; i--){
        int cnt = 0;
        for(int j = i+i; j <= n; j+=i)   cnt += ans[j];
        if(cnt%2 != v[i]%2) ans[i] = true;
    }
    vector<int> ret;
    for(int i = 1; i <= n; i++) if(ans[i])  ret.push_back(i);
    cout << ret.size() << endl;
    for(int i = 0; i < ret.size(); i++) cout << ret[i] << " \n"[i+1==ret.size()];
    return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl



int main() {
    IN(string, s);
    ll sum = 0;
    for (int bit = 0; bit < (1<<(s.length()-1)); bit++) {
        int head = 0;
        for (int i = 0; i < s.length()-1; i++) {
            if ((1<<i) & bit) {
                string hoge;
                for (int j = head; j <= i; j++) {
                    hoge += s[j];
                }
                head = i+1;
                sum += stoll(hoge);
            }
        }
        string hoge;
        for (int j = head; j <= s.length()-1; j++) {
            hoge += s[j];
        }
        sum += stoll(hoge);

    }

    COUT(sum);
    
}





Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	static int n;
	
	public static boolean seven(long ans) {
		int count[];
		count = new int[3];
		
		long tmp = ans, tmp2 = tmp;
		
		while(tmp > 0) {
			tmp /= 10;
			tmp2 = tmp2 - tmp * 10;
			if(tmp2 == 3 || tmp2 == 5 || tmp2 == 7) {
				int n = (int)((tmp2 - 3) / 2);
				count[n]++;
			}
			tmp2 = tmp;
		}
		
		for(int i : count) {
			if(i <= 0)return false;
		}
		
		return true;
	}
	
	public static int solve(long ans) {
		int count = 0;
		
		if(ans > n)return 0;
		
		if(seven(ans))count = 1;
		
		for(int i = 1; i <= 3; ++i) {
			long tmp = ans * 10 + (2 * i + 1);
			count += solve(tmp);
		}
		
		return count;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		sc.close();
		int ans = 0;
		
		ans = solve(0);
		
		System.out.println(ans);
	}

}


Measured memory_bytes: 24020
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

int main(){

    int n, m; cin >> n >> m;

    int k;
    vector<int> v[n];
    for(int i=0; i<n; i++){
        cin >> k;
        for(int j=0; j<k; j++){
            int temp;
            cin >> temp;
            v[i].push_back(temp);
        }
    }


    int checkCnt[m] = {};

    for(int i=0; i<n; i++){
        for(int j=0; j<v[i].size(); j++){
            checkCnt[v[i][j]-1]++;
        }
    }

    int totalCnt = 0;
    for(int j=0; j<m; j++){
        if(checkCnt[j] == n) totalCnt++;
        // cout << checkCnt[j] << endl;
    }

    cout << totalCnt << endl;

    // for(int i=0; i<n; i++){
    //     for(int j=0; j<v[i].size(); j++){
    //         cout << v[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    return 0;
}

Measured memory_bytes: 256
/* Parth Manubhai Patel */
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define int long long
#define ull unsigned long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).size())
#define f(a, b) for (int i = a; i < b; i++)
#define fr(a, b) for (int i = a - 1; i >= b; i--)
#define tr(x, m) for (auto x : m)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define X first
#define Y second
#define fill(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) reverse(v.begin(), v.end())
#define unq(v) v.erase(unique(all(v)), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(all(v), (ll)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
#define MOD = 1e9 + 7;
#define EPS = 0.0000001;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {
    start();
    int n;
    cin>>n;
    int x=n%10;
    if(x==2 || x==4 || x==5 | x==7 || x==9)cout<<"hon";
    else if(x==0 || x==1 || x==6 || x==8) cout<<"pon";
    else cout<<"bon";
    return 0;
}


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

#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fst first
#define snd second

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

const int mod = 998244353;

int mul(int a, int b)
{
    return ((ll)a * b) % mod;
}

int sub(int a, int b)
{
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int add(int a, int b)
{
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

const int maxN = 2e5 + 47;
int dp[maxN][3][3];

int solve(string s)
{
    set<char> ss(ALL(s));
    if (SZ(ss) == 1)
        return 1;
    if (SZ(ss) == 3 && SZ(s) == 3)
        return 3;
    dp[0][0][0] = 1;
    dp[0][1][1] = 1;
    dp[0][2][2] = 1;
    for (int i = 0; i < maxN - 1; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                for (int l = 0; l < 3; l++)
                {
                    if (j != l)
                    {
                        dp[i + 1][l][(k + l) % 3] = add(dp[i + 1][l][(k + l) % 3], dp[i][j][k]);
                    }
                }
            }
        }
    }
    int pw = 1;
    bool bad = true;
    int z = s[0] - 'a';
    for (int i = 1; i < SZ(s); i++)
    {
        z = (z + s[i] - 'a') % 3;
        pw = mul(pw, 3);
        if (s[i] == s[i - 1])
            bad = false;
    }
    int ans = sub(pw, add(add(dp[SZ(s) - 1][0][z], dp[SZ(s) - 1][1][z]), dp[SZ(s) - 1][2][z]));
    if (bad)
        ans = add(ans, 1);
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    cout << solve(s) << endl;
    return 0;
}

Measured memory_bytes: 7828
ss = str(input())
while (ss != '-'):
    slist = []
    for s in ss:
        slist.append(s)
    m = int(input())
    for i in range(m):
        n = int(input())
        for k in range(n):
            slist.append(slist[k])
        for k in range(n):
            del slist[0]
    for i in range(len(slist)):
        print(slist[i], end = '')
    print()
    ss = str(input())
        


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

int main() {
  string num;
  cin >> num;
  
  if (num[0] == num[1]) {
    if (num[1] == num[2]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else if (num[1] == num[2]) {
  	if (num[2] == num[3]) {
    	cout << "Yes" << endl;
  	} else {
    	cout << "No" << endl;
  	}
  } else {
  	cout << "No" << endl;
  }
}

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

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	k = 0
	for i in 1:n
		if i%2==1&&a[i]%2==1
			k += 1
		end
	end
	println(k)
end

main()

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

int main() {
    const long long int MOD = pow(10, 9) + 7;
    int N;
    cin >> N;
    long long int ans=1;
    
    for (int i=1; i<=N; ++i) ans = ans * i % MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define PI 3.1415926535897932
using namespace std;

int main(){
	long long N,A,B;
	cin>>N>>A>>B;
	long long M,ans;
	
	if(N>A+B){
		long long SetN = N/(A+B);
		long long Nokori = N%(A+B);
		if(Nokori<=A)M=Nokori;
		if(Nokori>A)M=A;
		ans=M+SetN*A;
	}else if(N<=A+B){
		if(N<=A)ans=N;
		if(N>A)ans=A;
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 3624