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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    const i32 MAXN=1024;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

i64 ar_d_Gcd[256][256];

inline i64 gcd(i64 a,i64 b) { return b?gcd(b,a%b):a; }

int main(){
    i64 d_K=read(),d_Ans=0;
    f(i,1,I,d_K)
        f(j,1,J,d_K)
            ar_d_Gcd[i][j]=gcd(i,j);
    f(i,1,I,d_K)
        f(j,1,J,d_K)
            f(k,1,K,d_K)
                d_Ans+=ar_d_Gcd[ ar_d_Gcd[i][j] ][k];
    print(d_Ans);
    output();
    return 0;
}

Measured memory_bytes: 4040
#include <iostream>
using namespace std;
#define ll long

ll N, M, i, a, l, r, R[100010], P[100010], A[100010], B[100010], C[100010];

int main()
{
    cin >> N >> M;
    for (i = 0; i < M; i++)
        cin >> P[i];
    for (i = 0; i + 1 < N; i++)
        cin >> A[i] >> B[i] >> C[i];
    for (i = 1; i < M; i++)
    {
        l = P[i - 1], r = P[i];
        if (l > r)
            swap(l, r);
        R[l]++, R[r]--;
    }
    for (int i = 1; i <= N; i++)
        R[i + 1] += R[i], a += min(R[i] * A[i - 1], R[i] * B[i - 1] + C[i - 1]);
    cout << a << endl;
}



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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}

int cuth = 9;
int maxw = 1e5;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, i, j;
    cin >> n;
    vi v(n), w(n);
    for(i=0;i<n;i++){
        cin >> v[i] >> w[i];
    }
    /*
        dp[v][l] = max value selecting itens in v-path
        s.t total_weight <= l

        1) compute dp[v][l] for h(v) <= 9 ; O(2^10 * maxL)
        2) for v in query q s.t h(v) > 9
            try all subsets of S(v) = {w | w anc v ^ h(w) > 9}
            rt : O(2^|S(v)|)) <= 2^9

        Total rt O(2^9 * maxL + Q*2^9)
    */
    int limv = (1<<(cuth+1)) - 1;
    limv = min(limv, n);
    vvi dp(limv, vi(maxw + 1, 0));
    for(j = w[0];j<=maxw;j++){
        dp[0][j] = v[0];
    }
    for(i=1;i<limv;i++){
        int p = (i-1)>>1;
        for(j=0;j<=maxw;j++){
            dp[i][j] = dp[p][j];
            if(w[i] <= j){
                dp[i][j] = max(dp[i][j] , dp[p][j - w[i]] + v[i]);
            }
        }
    }
    int q;
    cin >> q;
    while(q--){
        int u, l;
        cin >> u >> l;
        u--;
        vi S;
        while(u >= limv){
            S.push_back(u);
            u = (u-1)>>1;
        }
        int ans = dp[u][l];
        int N = (S.size());
        int M = (1<<N);
        for(int msk = 1; msk < M; msk++){
            int cap = 0, val = 0;
            for(i=0;i<N;i++){
                if(msk & (1<<i)){
                    cap += w[S[i]];
                    val += v[S[i]];
                }
                if(cap > l) break;
            }
            if(cap > l) continue;
            ans = max(ans , dp[u][l-cap] + val);
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 406592
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x;
    string s,s1,s2;
    cin >> a >> b;   
    cout << max(max(a+b,a-b),a*b) << endl;
    return 0;
} 

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

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b){
    if(b>a) swap(a,b);
    if (b==0) return a;
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll a[100010];
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    
    ll l[100010],r[100010];
    l[0]=0;
    r[n+1]=0;
    for(int i=0;i<n-1;i++){
        l[i+1]=gcd(l[i],a[i]);
    }
    for(int i=n;i>0;i--){
        r[i]=gcd(r[i+1],a[i]);
    }
    ll ans=0;
    for(int i=0;i<=n;i++){
        ll tempans = gcd(l[i],r[i+1]);
        if(tempans>ans) ans =tempans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/dp/tasks/dp_l
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;

int N;
LL a[3000];

LL ans = INF;

void solve(){
	vector<vector<LL>> dp(N+1,vector<LL>(N+1,0));
	// dp[i][j] :
	//  ai+1からajでゲームをするときのX-Yの最大値
	//  ただし、手番は「元のゲームを行ってその局面になった時の手番」とする
 
	for(int len=1;len<=N;len++){
		for(int left=0;left<N-len+1;left++){
			int right = left + len;
			if((N - len) % 2 == 0){
				dp[left][right] = max(dp[left+1][right]+a[left],dp[left][right-1]+a[right-1]);
			}else{
				dp[left][right] = min(dp[left+1][right]-a[left],dp[left][right-1]-a[right-1]);
			}
		}
	}
	ans = dp[0][N];
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++) cin >> a[i];
 
	solve();

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

Measured memory_bytes: 70784
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

string s;
int n;
signed main() {
    cin >> s >> n;
    rep(i,0,s.length()) {
        int nd = 'z' - s[i] + 1;
        if(nd < 26 && nd <= n) {
            n -= nd;
            s[i] = 'a';
        }
        if(i == s.length() - 1) {
            int cur = s[i] - 'a';
            s[i] = 'a' + ((cur + n) % 26);
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<
//        pair<int, int>, // change type
//        null_type,
//        less<pair<int, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
const double PI = 3.14159265358979323846;
const double eps = (1e-8);




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("facebook.txt", "w", stdout);
#endif
    int a[4] = {0};
    rep(i,0,3)
    {
        int x, y;
        cin >> x >> y;
        --x; --y;
        a[x]++;
        a[y]++;
    }
    int one = 0, two = 0;
    rep(i,0,4)
    {
        one += a[i] == 1;
        two += a[i] == 2;
    }
    if (one == 2)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>
#include <math.h>
#include <functional>

#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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

int main() {
	int n;
	cin >> n;
  string s;
  cin >>s;
	if (n >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;


}


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

long long solve(long long n, long long k, vector<long long> a, vector<long long> b) {
    long long res = 0;
    for(long long i=0; i<n; i++) {
        if ((a[i] | k) == k){
            res += b[i];
        }
    }
    return res;
}

int main() {
    long long n, k;
    cin >> n >> k;
    vector<long long> a(n), b(n);
    for(long long i=0; i<n; i++) {
        cin >> a[i] >> b[i];
    }
    long long res = solve(n, k, a, b);
    for(long long i=0; i<=30; i++) {
        if(k & (1<<i)) {
            long long k1 = k - (1<<i);
            k1 |= (1<<i) - 1;
            long long r = solve(n, k1, a, b);
            if(r > res)
                res = r;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    string last, now;
    cin >> last;
    bool f = true;
    map<string, int> used;
    used[last]++;
    rep(i, n - 1)
    {
        cin >> now;
        f &= (last[last.size() - 1] == now[0] && used[now] == 0);
        used[now]++;
        last = now;
    }
    cout << (f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
//問題文が難しい…（a_i -> b_iと値を変更します。b_i -> f(b_i)と値を変更します。最終的な列が同じになるfは一意でしょうか？という問題。）
//全射かをチェックするだけ。注意点としては、f(1), f(2), …ではなく、f(a_1), f(a_2)…の順で出力することくらいか。
#include <iostream>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[100000];
int b[100000];
bool isExist[100001];

int main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	rep(i, n) isExist[b[i]] = true;
	
	int cnt = 0;
	rep(i, n) cnt += isExist[i + 1];
	
	if (cnt == n) { cout << "Yes" << endl; return 0; }
	
	cout << "No" << endl;
	
	vector<int> g, h;
	rep(i, n) {
		if (isExist[a[i]]) { g.push_back(1); h.push_back(1); }
		else { g.push_back(1); h.push_back(2); }
	}
	rep(i, n) { cout << g[i]; if (i + 1 < n) cout << " "; } cout << endl;
	rep(i, n) { cout << h[i]; if (i + 1 < n) cout << " "; } cout << endl;
	return 0;
}


Measured memory_bytes: 4868
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
    int n;
    cin >> n ;
    int A[n] ;
    int B[n] ;
    rep(i,n) cin >> A[i] ;
    rep(i,n) cin >> B[i] ;
    ll ans = 0 ;
    ll count = 0 ;
    rep(i,n-1) A[i+1] += A[i] ;
    rep(i,n-1) B[i+1] += B[i] ;
    B[-1] = 0 ;
    rep(i,n){
        count = B[n-1] - B[i-1] + A[i] ;
        ans = max(count,ans) ;
        count = 0 ;
    }
    cout << ans << endl;
    }

Measured memory_bytes: 256
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

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


int main()
{
    ll i,j,n,sum=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        sum+=(s[i]-'0');
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    
    //cout<<"YES"<<endl;
    //cout<<"NO"<<endl;

    return 0;
}


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

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, s, n) for(int i = s; i < n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << endl
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define FOREACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;

//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );

//global-----------------------------------------------------------------------------------------------------------------------
int n, m;
int cost[ 100 ][ 100 ];
bool visit[ 100 ];
int a, b, c;

//function---------------------------------------------------------------------------------------------------------------------

int main() {
	while ( scanf( "%d %d", &n, &m ) != 0 ) {
		if ( n == 0 && m == 0 )
			return 0;
		rep( i, n ) {
			rep( j, n ) {
				cost[ i ][ j ] = INF;
				if ( i == j )
					cost[ i ][ j ] = 0;
			}
			visit[ i ] = false;
		}
		rep( i, m ) {
			scanf( "%d %d %d", &a, &b, &c );
			cost[ a ][ b ] = c;
			cost[ b ][ a ] = c;
		}
		int ans = 0;
		visit[ 0 ] = true;
		FOR( i, 1, n ) {
			int min_cost = INF;
			int can_visit;
			rep( j, n ) {
				if ( !visit[ j ] )
					continue;
				rep( k, n ) {
					if ( cost[ j ][ k ] < min_cost && !visit[ k ] ) {
						min_cost = cost[ j ][ k ];
						can_visit = k;
					}
				}
			}
			ans += min_cost;
			visit[ can_visit ] = true;
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 10000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

//////////

signed main()
{
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	int ans=0;
	if(n<=2)
	{
		cout<<"0";
		return 0;
	}
	set<int> s;
	for(int i=1;i*i<=n;++i)
	{
		if(n%i==0)
		{
			s.insert(i);
			s.insert(n/i-1);
			s.insert(i-1);
			s.insert(n/i);
		}
	}
	for(auto m:s)
	{
		if(m!=0)
		{
			if(n/m==n%m)
				ans+=m;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;

// 插入此處
vector<LL> getPrime(LL N) {
	vector<LL> res;
	for (int i = 1; 1LL * i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			if (N/i != i) {
				res.push_back(N/i);
			}
		}
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	LL N; cin >> N;
	int ans = 0;
	for (auto x : getPrime(N)) {
		if (x == 1)  continue;
		LL res = N;
		while (res % x == 0) {
			res /= x;
		}
		if ((res - 1) % x == 0)  {
			// cout << x << endl;
			++ans;
		}
	}
	for (auto x : getPrime(N-1)) {
		if (x == 1)  continue;
		// cout << x << endl;
		++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <map>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define efo(i,q) for(int i=A[q];i;i=B[i][0])
using namespace std;
typedef long long LL;
const int N=100500,mo=1e9+7;
int m,n;
int fj[N][2],fj0;
int d[N];
LL ans;
map<int,int>f;
LL ksm(LL q,int w)
{
	LL ans=1;
	for(;w;w>>=1,q=q*q%mo)if(w&1)ans=ans*q%mo;
	return ans;
}
int ss1(int q,int w,int e)
{
	if(q>w)return f[e];
	int ans=ss1(q+1,w,e);
	fo(i,1,d[q])((ans+=ss1(q+1,w,(e=e*fj[q][0])))>=mo?ans-=mo:0);
	return ans;
}
int EB(int q)
{
	for(;q;q>>=1)if((q&1)&&q>1)return 1;
	return 0;
}
void ss(int q,int e)
{
	if(q>fj0)
	{
		LL t=(((n/e)%2?ksm(m,(e+1)>>1):ksm(m,e))-ss1(1,q,1)+mo)%mo;
		f[e]=t;
		ans=(ans+t*e)%mo;
		return;
	}
	d[q]=0;ss(q+1,e);
	fo(i,1,fj[q][1])d[q]=i,ss(q+1,(e*=fj[q][0]));
}
int main()
{
	int q,w;
	scanf("%d%d",&n,&m);
	if(n==1)return printf("%d\n",m),0;
	q=n;
	for(int i=2;i*i<=q;++i)if(q%i==0)
	{
		for(fj[++fj0][0]=i;!(q%i);++fj[fj0][1],q/=i);
	}
	if(q>1)fj[++fj0][0]=q,fj[fj0][1]=1;
	ss(1,1);
	printf("%lld\n",(ans+mo)%mo);
	return 0;
}

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

//template
#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 ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
   int n; scanf("%d",&n);
   vector<int> a(n),b(n);
   rep(i,0,n)scanf("%d",&a[i]);
   rep(i,0,n)scanf("%d",&b[i]);
   int res=0,cnt=0; vector<int> ord(n); iota(ALL(ord),1);
   do{
      bool f1=1,f2=1;
      rep(i,0,n){
         if(ord[i]!=a[i])f1=0;
         if(ord[i]!=b[i])f2=0;
      }
      if(f1)res-=cnt; if(f2)res+=cnt;
      cnt++;
   }while(next_permutation(ALL(ord)));
   printf("%d\n",abs(res));
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main ()
{
  int a[100],n,num,i,j,temp;
  scanf("%d",&n);
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]); 
    for (j = 0; j < n-1; j++)
    printf("%d ",a[j]);
    printf("%d\n",a[n-1]);
  for (i = 1; i < n; i++) {
    num = i;
    for (j = 0; j < i; j++) {
      if (a[i] < a[j]) {
        num = j;
        break;
      }
    }
    temp = a[i];
    for(j = i; j > num; j--) {
      a[j]=a[j-1];
    }
    a[num] = temp;
    for (j = 0; j < n-1; j++)
    printf("%d ",a[j]);
    printf("%d\n",a[n-1]);
    }
  return 0;
}

Measured memory_bytes: 1844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << endl;}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
string s;
int n = 10;
ll ans = 0;
void f(int a, string ss) {
	if (a == n - 1) {
		ss += s.back();
		ss += '+';
		ll x = 0, y = 0;
		each(b, ss) {
			if (b == '+') {
				x += y;
				y = 0;
			} else {
				y = y * 10 + (b - '0');
			}
		}
		ans += x;
		return;
	}
	ss += s[a];
	f(a + 1, ss);
	f(a + 1, ss + '+');
}
int main() {
	cin >> s;
	n = len(s);
	f(0, "");
	print(ans);
	return 0;
}


Measured memory_bytes: 256
def find(x):
    global s
    if s[x] == x:
        return x
    s[x] = find(s[x])
    return s[x]

n, q = map(int, input().split())

s =[i for i in range(n)]

for i in range(q):
    com, x, y = map(int, input().split())
    if com:
        if find(x) == find(y): print(1)
        else: print(0)
    else:
        s[find(y)] = find(x)

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

int main()
{
    int r, c;
    cin >> r >> c;
    vector<vector <int> > a(r+1, vector<int>(c + 1));

    for (int i = 0; i <  r; i++)
    {
        int sum = 0;
        for (int j = 0; j < c; j++)
        {
            cin >> a[i][j];
            sum += a[i][j];
        }
        a[i][c] = sum;
    }

    for (int j = 0; j <= c; j++)
    {
        int sum = 0;
        for (int i = 0; i < r; i++)
        {
            sum += a[i][j];
        }
        a[r][j] = sum;
    }

    for (int i = 0; i <= r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cout << a[i][j] << " ";
        }
        cout << a[i][c] << endl;
    }

    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <utility>
#include <algorithm>

int count = 0;

void selectionSort(int* num, int N)
{
  for(int i=0; i<N-1; ++i){
    int minj = i;
    for(int j=i+1; j<N; ++j){
      /*
        std::cout << "i = " << i << " / num[" << j << "] = "
        << num[j] << " / num[minj] = " << num[minj]
        << " / minj = " << minj << std::endl;
      */
      if( num[j] < num[minj] ){
        minj = j;
      }
    }
    if( i != minj ){
      std::swap(num[i], num[minj]);
      count++;
    }
  }
}


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

  int num[n];
  for(int i=0; i<n; ++i){
    std::cin >> num[i];
  }

  selectionSort(num, n);

  for(int i=0; i<n; ++i){
    if(i != 0) std::cout << " ";
    std::cout << num[i];
  }
      std::cout << std::endl;
    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N,ans=0; cin >> N;
  if(N < 3){
    cout << "0";
    return 0;
  }
  ans += N-1;
  for(ll i = 1;i*i < N;i++){
    if(i == 1){
      continue;
    }
    if(N % i == 0 && i*(i+1) != N){
      ans += N/i;
      ans--;
    }
  }
  cout << ans;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
vector<int> rank1;
vector<int> par;
int find(int x){
    if (par[x]==x){
        return x;
    }
    else{
        par[x]=find(par[x]);
        return par[x];
    }
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y){
        return;
    }
    if (rank1[x]<rank1[y]){
        par[x]=y;
    }
    else{
        par[y]=x;
        if(rank1[x]==rank1[y]){
            rank1[x]++;
        }
    }
}

int main() {
    int n,m;
    cin>>n>>m;
    par.push_back(0);
    rank1.push_back(0);
    rep(i,n){
        par.push_back(i+1);
        rank1.push_back(1);
    }
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        unite(x,y);
    }
    int ans=0;
    rep(i,n){
        if (par[i+1]==i+1){
            ans+=1;
        }
    }
    cout<<ans<<endl;
    


    return 0;
}

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

class Problem {
    public static void Main() {
        var str = "";
        while ((str = Console.ReadLine()) != "0 0") {
            var data = str.Split().Select(int.Parse).ToArray();
            var od = "";
            var ev = "";
            for (var i = 0; i < data[1]; i++) {
                od += i % 2 == 1 ? "#" : ".";
                ev += i % 2 == 1 ? "." : "#";
            }
            for (var i = 0; i < data[0]; i++) Console.WriteLine(i % 2 == 1 ? od : ev);
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 9284
#include "bits/stdc++.h"
using namespace std;
int main(void){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int x[N],y[M];
    
    for(int i=0;i<N;i++) cin >> x[i];
    for(int i=0;i<M;i++) cin >> y[i];
    sort(x,x+N,greater<int>());
    sort(y,y+M);
    if((x[0]>=y[0]) || (x[0]<=y[0] && y[0]<=X) || (x[0]<=y[0] && x[0]>= Y)) cout << "War";
    else cout<< "No War";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 int main() { 
   int A, B; cin >> A >> B; 
   int ans = 0; 
   int outlet = 1; 
   while (outlet < B) { 
     --outlet; 
     outlet += A; 
     ++ans; 
   } 
   cout << ans << endl;
 }

Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        scanner.nextLine();
        int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        Gcd gcd = new Gcd();
        long lcm = n[0] * n[1] / gcd.gcd(n[0], n[1]);
        for (int i = 2; i < n.length; i++) {
            lcm = lcm * n[i] / gcd.gcd(lcm, n[i]);
        }
        System.out.println(lcm);
    }

}

class Gcd {
    class GcdResult {
        // xa + yb = n;
        final long a;
        final long b;
        final long gcd;

        public GcdResult(long a, long b, long gcd) {
            this.a = a;
            this.b = b;
            this.gcd = gcd;
        }
    }

    public GcdResult extGcd(long x, long y) {
        if (x < y) {
            return extGcd(y, x);
        }
        if (y == 0) {
            return new GcdResult(1, 0, x);
        }
        GcdResult res = extGcd(y, x % y);
        long a = res.b;
        long b = res.a - (x / y) * res.b;
        return new GcdResult(a, b, res.gcd);
    }

    public long gcd(long x, long y) {
        if (x < y) {
            return gcd(y, x);
        }
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);
    }
}




Measured memory_bytes: 32416
import java.util.Scanner;
import java.util.Stack;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int Q = scanner.nextInt();
    char[] s = scanner.next().toCharArray();
    char[][] queries = new char[Q][2];
    for (int i = 0; i < Q; i++) {
      queries[Q - i - 1][0] = scanner.next().charAt(0);
      queries[Q - i - 1][1] = scanner.next().charAt(0);
    }

    Stack<Character> stack = new Stack<>();
    int i = s.length - 1;
    for (int j = 0; j < Q; j++) {
      if (i >= 0 && s[i] == queries[j][0] && queries[j][1] == 'R') {
        stack.push(s[i]);
        i--;
      }
      if (!stack.isEmpty() && stack.peek() == queries[j][0] && queries[j][1] == 'L') {
        stack.pop();
        i++;
      }
    }
    int mr = stack.size();

    stack.clear();
    i = 0;
    for (int j = 0; j < Q; j++) {
      if (i < N && s[i] == queries[j][0] && queries[j][1] == 'L') {
        stack.push(s[i]);
        i++;
      }
      if (!stack.isEmpty() && stack.peek() == queries[j][0] && queries[j][1] == 'R') {
        stack.pop();
        i--;
      }
    }
    int ml = stack.size();

    System.out.println(N - Math.min(ml + mr, N));
  }
}


Measured memory_bytes: 79152
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    return N,


def solve(N):
    if N % 1000 > 0:
        return 1000 - N % 1000
    return 0


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

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

using ll = long long;
using lb = long double;
using P = pair<string,string>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  char X,Y;
  cin>>X>>Y;
  int t = X - 'A',s = Y-'A';
  if(t<s) cout<<'<'<<endl;
  else if(t==s) cout<<'='<<endl;
  else cout<<'>'<<endl;
}

Measured memory_bytes: 3640
e1,e2,e3,e4=map(int,input().split())
if e1==e2 and e3==e4:
    print('yes')
elif e1==e3 and e2==e4:
    print('yes')
elif e1==e4 and e2==e3:
    print('yes')
elif e1==e2==e3==e4:
    print('yes')
else:
    print('no')
   


Measured memory_bytes: 5596
#include <stdio.h>

int main(void)

{
	int a,b;
	int area= 0,round= 0;
	int result= 0;

	scanf("%d %d",&a,&b);
	area = a * b;
	round = a * 2 + b * 2;
	printf("%d %d\n",area,round);

	return(0);

}

Measured memory_bytes: 596
a, b, c = (int(x) for x in input().split())
if a == b and b == c:
    print('No')
if a != b and b!= c and a != c:
    print('No')
if a == b and b != c:
    print('Yes')
if b == c and a != b:
    print('Yes')
if a == c and b != c:
    print('Yes')


Measured memory_bytes: 3060
[A,B,C] = list(map(int,input().split()))
l = [A,B,C]
l.sort()

if (l[0]+l[1]+l[2])/3 > l[0]:
  if l[0] == l[1] or l[1] == l[2]:
    print("Yes")
  else:
    print("No")
else:
  print("No") 

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int W, H;
int N;    
std::vector<int> X1, X2, Y1, Y2;
bool board[6005][6005];

int compress(std::vector<int> &v1, std::vector<int> &v2, int w){
    std::vector<int> v;

    REP(i, N){
        int s = v1[i], t = v2[i];
        FOR(j, -1, 2){
            int ns = s + j, nt = t + j;
            if(0 <= ns && ns < w){
                v.push_back(ns);
            }
            if(0 <= nt && nt < w){
                v.push_back(nt);
            }
        }
    }

    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    REP(i, N){
        v1[i] = std::find(v.begin(), v.end(), v1[i]) - v.begin();
        v2[i] = std::find(v.begin(), v.end(), v2[i]) - v.begin();
    }

    return v.size();
}

int main(){
    while(std::cin >> W >> H, W){
        X1.clear();
        Y1.clear();
        X2.clear();
        Y2.clear();

        std::cin >> N;

        REP(i, N){
            int x1, y1, x2, y2;
            std::cin >> x1 >> y1 >> x2 >> y2;

            X1.push_back(x1);
            Y1.push_back(y1);
            X2.push_back(x2);
            Y2.push_back(y2);
        }

        int wx = compress(X1, X2, W),
            wy = compress(Y1, Y2, H);

        REP(i, wx){
            REP(j, wy){
                board[i][j] = 0;
            }
        }

        REP(i, N){
            int x1 = X1[i], y1 = Y1[i], x2 = X2[i], y2 = Y2[i];
            //std::cout << x1 << " " << y1 << " " << x2 << " " << y2 << std::endl;

            FOR(j, x1, x2){
                FOR(k, y1, y2){
                    board[j][k] = 1;
                }
            }
        }

        // REP(i, wy){
        //     REP(j, wx){
        //         printf("%d, ", board[j][i]);
        //     }
        //     puts("");
        // }

        int res = 0;
        REP(i, wy){
            REP(j, wx){
                if(!board[j][i]){
                    res++;

                    std::stack<P> s;
                    s.push(mp(j, i));
                 
                    while(!s.empty()){
                        P p = s.top(); s.pop();
                        board[p.first][p.second] = 1;

                        REP(k, 4){
                            int nx = p.first + dx[k], ny = p.second + dy[k];
                            if(0 <= nx && nx < wx && 0 <= ny && ny < wy && !board[nx][ny]){
                                s.push(mp(nx, ny));
                            }
                        }
                    }
                }
            }
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 13504
n = int(input())
p = list(map(int,input().split()))
def hantei(aa,b,c):
    if(b<=c and aa<=c and b <= aa):
        return 1
    elif (c<=b and aa <= b and c <= aa):
        return 1
    else:
        return 0

ans = 0
for i in range(n-2):
    if(hantei(p[i+1],p[i],p[i+2])):
        ans+=1
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		print();
	}

	private static void print() {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> list = new ArrayList<>();
		int[] highs = new int[10];

		try {
			for (int i = 0; i <= 9; i++) {
				highs[i] = Integer.parseInt(br.readLine());
			}

			for (int i = 0; i <= 9; i++) {
				list.add(highs[i]);
			}

			Collections.sort(list);
			Collections.reverse(list);

			for (int i = 0; i <= 2; i++) {
				System.out.println(list.get(i));
			}

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}

Measured memory_bytes: 24168
#include <iostream>

using namespace std;

long long int MAX_N = 200000;

int main(int argc, char const *argv[]) {
  long long int N, T;
  long long int t[MAX_N];

  cin >> N >> T;
  for (long long int i = 0; i < N; i++) cin >> t[i];

  long long int ans = 0;
  for (long long int i = 1; i < N; i++) {
    if (t[i]-t[i-1] > T) ans += T;
    else ans += t[i]-t[i-1];
  }
  ans += T;

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


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


LL dp[5001][5001];

LL fpow(LL a, LL n){
    int x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            dp[i+1][j+1]=(dp[i+1][j+1]+2*dp[i][j])%mod;
            if(j==0) dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
            else dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j])%mod;
        }
    }
    cout << (dp[N][s.length()]*fpow(fpow(2,s.length()),mod-2))%mod << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  string s;
  cin >> s;
  int n = sz(s);
  bool ans = false;
  rep(i,n) {
    if(s[i] == '7') ans = true;
  }
  YesorNo(ans);
}

Measured memory_bytes: 3700
using System;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;

namespace Tutorial
{
    class Program
    {
        static void Main(string[] args)
        {
            int inp = Convert.ToInt32(Console.ReadLine());
            int res = inp + inp * inp + inp * inp * inp;
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 27548
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		ArrayList<Integer> ans = new ArrayList<>();

		if (n==0){
			ans.add(0);
		}
		while (n != 0){
			int b = Math.abs(n%-2);
			ans.add(b);
			n = (n-b)/-2;
		}
		Collections.reverse(ans);

		for (int degit : ans){
			System.out.print(degit);
		}
		System.out.println();
	}
}


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

  ld N,M;//NがS　Mがc

//dこSCCが作れるかを判定
bool C(ld d){
  ld t=M;
  //cout<<"d="<<d<<endl;
  if(d-N > 0){
    t=M-(d-N)*2;
  }

  if(t-d*2>0){
    return true;
  }else{
    return false;
  }
}
int main(){

  cin>>N>>M;

  ld lb=0;
  ld ub=1000000000010;
  ld mid;
  while(ub-lb > 0.1){
    mid = (lb + ub)/2;
    if(C(mid))lb=mid;
    else ub = mid;
  }

  cout<<(ll)(ub+lb)/2<<endl;
}


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

int main(){
	long n =0;
	cin >> n;
	long long* a=new long long[n+1];
	long long* b=new long long[n];
	for(int i=0;i<n+1;i++){
		cin >> a[i];
	}for(int i=0;i<n;i++){
		cin >> b[i];
	}
	long long mnstr_n = 0;
	for(int i=0;i<n;i++){
		if(a[i] + a[i+1] <= b[i]){
			mnstr_n+=(a[i] + a[i+1]);
			a[i] = 0;
			a[i+1] = 0;
		}else{
			mnstr_n += b[i];
			a[i+1] = min(a[i]+a[i+1]-b[i],a[i+1]);
		}
	}
	cout << mnstr_n << endl;
	return 0;
}


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

struct Node{
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  Node *cur = nil->next;
  while(cur != nil){
    if(cur != nil->next) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deleteKey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  x->prev = nil;
  nil->next->prev = x;
  nil->next = x;
}

int main(){
  int n;
  scanf("%d", &n);
  init();
  rep(i, n){
    char com[20];
    int key;
    scanf("%s%d", com, &key);
    if(com[0] == 'i') insert(key);
    else if(com[0] == 'd'){
      if(com[6] == 'F') deleteFirst();
      else if(com[6] == 'L') deleteLast();
      else deleteKey(key);
    }
  }

  printList();

  return 0;
}





Measured memory_bytes: 34424
#include<iostream>
using namespace std;
int main(){
    int n,i;
    double x,sum=0.0;
    string s;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> x >> s;
        if(s=="JPY")
            sum+=x;
        else
            sum+=x*380000.0;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
function Main(input){
	input1 = input.trim().split(' ').map(v=>parseInt(v,10));
    a = input1[0];
    b = input1[1];
    c = input1[2];
    d = input1[3];
    
    if((Math.abs(a-c) <=d) || (Math.abs(a-b) <=d && Math.abs(b-c) <=d)) {
    console.log('Yes');
    }else{
    console.log('No');
    }
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
//#define _GLIBCXX_DEBUG
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1000000000;
const int MOD = 1000000007;

ll factorial(ll N){
    ll ret = 1;
    for (int i=1; i<N; i++){
        ret *= i;
        ret %= MOD;
    }
    return ret;
}

ll mod_pow(ll x, ll n){
    ll res = 1;
    while (n > 0){
        if(n & 1)res = res*x % MOD;
        x = x*x % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    IOS;
    int N;
    cin >> N;
    ll ans = 0;
    ans += mod_pow(10,N);
    ans %= MOD;
    ans -= 2*mod_pow(9,N) % MOD;
    ans %= MOD;
    ans += mod_pow(8,N)%MOD;
    ans %= MOD;
    if (ans < 0)ans += MOD;
    cout << ans << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    ll a,b,k;
    scanf("%lld%lld%lld",&a,&b,&k);
    if (a>=k)
    printf("%lld %lld\n",(a-k),b);
    else if ((a+b)>=k)
    printf("0 %lld\n",(b-(k-a)));
    else
    printf("0 0\n");
    return 0;
}


Measured memory_bytes: 3820