akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())


int main() {
  int N, K, t, d;
  cin >> N >> K;
  vector<pii> s, dbl;
  vector<int> cnt(N, 0);
  ll ans = 0, sum = 0, k = 0;
  rep(i,N) {
    cin >> t >> d;
    t--;
    s.push_back(make_pair(d, t));
  }
  sort(all(s));
  rep(i,K) {
    pii p = s.back();
    s.pop_back();
    if (cnt[p.second] != 0)
      dbl.push_back(p);
    else {
      k++;
      cnt[p.second]++;
    }
    sum += p.first;
  }
  rsort(dbl);
  ans = sum + k*k;
  while (!dbl.empty() && !s.empty()) {
    pii p = s.back();
    s.pop_back();
    if (cnt[p.second] != 0)
      continue;
    k++;
    cnt[p.second]++;
    sum += p.first;
    p = dbl.back();
    dbl.pop_back();
    sum -= p.first;
    ans = max(ans, sum+k*k);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 5108
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val x = in.readLine().toInt

    out.println(
      x / 500 * 1000 + (x - x / 500 * 500) / 5 * 5
    )

    out.flush()
  }
}


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

using namespace std;

int x[100001], y[100001], gx[100001], gy[100001];
vector <int> Dx[100001], Dy[100001];
vector <pair<int,int>> T;

int main()
{
    int n, X, Y, a;
    long long kx, ky, S=0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        Dx[x[i]].push_back(y[i]);
        Dy[y[i]].push_back(x[i]);
    }
    for (int i = 0; i <= 100000; i++)
    {
        gx[i] = 1;
        gy[i] = 1;
    }
    for (int i = 0; i < n; i++)
    {
        if (gx[x[i]] == 1 && gy[y[i]] == 1)
        {
            kx = 1;
            ky = 1;
            gx[x[i]] = 0;
            gy[y[i]] = 0;
            T.push_back({x[i],y[i]});
            for (int y = 0; y < T.size(); y++)
            {
                X = T[y].first;
                Y = T[y].second;
                for (int u = 0; u < Dx[X].size(); u++)
                {
                    a = Dx[X][u];
                    if (gy[a] == 1)
                    {
                        gy[a] = 0;
                        ky++;
                        T.push_back({X,a});
                    }
                }
                for (int u = 0; u < Dy[Y].size(); u++)
                {
                    a = Dy[Y][u];
                    if (gx[a] == 1)
                    {
                        gx[a] = 0;
                        kx++;
                        T.push_back({a,Y});
                    }
                }
            }
            T.clear();
            S += kx*ky;
        }
    }
    S -= n;
    cout << S;
    return 0;
}


Measured memory_bytes: 10744
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353 

using namespace std;
using namespace __gnu_pbds;

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

ordered_set<ll> dp;

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

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

int main()
{
    IOS;
    ll k;
    cin>>k;
    ll ans=0;
    repf(i,1,k+1)
    {
        repf(j,1,k+1)
        {
            repf(l,1,k+1)
            {
                ans+=__gcd(i,__gcd(j,l));
            }
        }
    }
    cout<<ans<<endl;
}     


Measured memory_bytes: 3656
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

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

    int N, A, B;
    cin >> N >> A >> B;

    cout << min(A, B) << " " << max(0ll, (A + B) - N) << endl;
    return 0;
}


Measured memory_bytes: 764
amount = int(input())
inputl = input().split()

flag = True

for i in range(amount):
    a = int(inputl[i])
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            flag = False

if flag:
    print("APPROVED")
else:
    print("DENIED")


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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M,0));
  for (int i=0; i<N; i++) {
    cin >> C[i];
    for (int j=0; j<M; j++) {
      cin >> A[i][j];
    }
  }
  int INF=10000000;
  int count, fin, mm=INF;
  
  for (int b=0; b < (1 << N); b++) {
    bitset<12> s(b);
    vector<int> V(M,0);
    count=0;
    fin=0;
    for (int i=0; i<N; i++) {
      if (s.test(i)) {
        count+=C[i];
        for (int j=0; j<M; j++) {
          V[j]+=A[i][j];
        }
      }
    }
    for (int i=0; i<M; i++) {
      if (V[i]<X) {
        fin=1;
        break;
      }
    }
    if (fin==1) {continue;}
    mm=min(mm, count);
  }
  if (mm==INF) {cout << -1 << endl;}
  else {cout << mm << endl;}
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> p(n);
  r1(i, n) cin >> p.at(i);
  double x,a,b;
  r1(i, k) a+=p.at(i)+1;
  b=a;
  x=a;
  r1(i, n-k) {
    b=b-p.at(i)+p.at(k+i);
    x=max(x,b);
  }
  cout << setprecision(10) << x/2 << endl;
}

Measured memory_bytes: 1024
def main():
  set = ("-", "+")
  d = [int(x) for x in input()]
  for i in range(1 << 3):
    op = []
    total = d[0]
    for j in range(3):
      x = (i >> j) & 1
      op.append(set[x])
      if x == 1:
        total += d[j+1]
      else:
        total -= d[j+1]
    #print(i, total)
    if total == 7:
      print('{}{}{}{}{}{}{}=7'.format(d[0], op[0], d[1], op[1], d[2], op[2], d[3]))
      return 0
  print("error")
  return 0

main()

Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define COM_UPDATE 0
#define COM_FIND 1

// #define DEBUG

template<typename T>
class SegTree {
private:
  std::vector<T> dat_;
  size_t size_;
  T Update_(size_t i_node, size_t left, size_t right,
    size_t left_bound, size_t right_bound) noexcept;
public:
  SegTree() = delete;
  SegTree(size_t num){
    size_t n = 1;
    while(n < num) n <<= 1;
    size_ = n;
    dat_ = std::vector<T>(2 * size_, std::numeric_limits<T>::max());
  }

  size_t size(){return size_;}

  void Update(size_t i, T val) noexcept;

  T Find(size_t left, size_t right) noexcept {
    return Update_(1, left, right + 1, 0, size_);
  }

  void Dump() noexcept;

};

template<typename T>
T SegTree<T>::Update_(size_t i_node, size_t left, size_t right,
  size_t node_left_bound, size_t node_right_bound) noexcept {
  assert(left <= right);
  assert(node_left_bound <= node_right_bound);

  // no overlap(outisde)
  if(right <= node_left_bound || node_right_bound <= left)
    return std::numeric_limits<T>::max();

  // include whole interval
  if(left <= node_left_bound && node_right_bound <= right)
    return dat_[i_node];

  // partial overlap
  return std::min<T>(
    Update_(i_node * 2, left, right, node_left_bound,
      node_left_bound + (node_right_bound - node_left_bound) / 2),
    Update_(i_node * 2 + 1, left, right,
      node_left_bound + (node_right_bound - node_left_bound) / 2,
      node_right_bound));
}

template<typename T>
void SegTree<T>::Update(size_t i, T val) noexcept {
  T orig = dat_[i + size_];
  dat_[i + size_] = val;
  size_t index = (i + size_) / 2;
  while(index > 0){
    dat_[index] = std::min<T>(dat_[index * 2], dat_[index * 2 + 1]);
    index >>= 1;
  }
}

template<typename T>
void SegTree<T>::Dump() noexcept {
  std::cout << "SegTree dump:";
  for (int i = 1; i < 2 * size_; ++i)
  {
      if(i & (i - 1) == 0) {
        std::cout << std::endl;
      }
      std::cout << dat_[i] << " ";
  }
  std::cout << std::endl;
}

int main(){
  std::vector<int> ans;
  int N, Q;
  std::cin >> N >> Q;
  SegTree<int> segtree(N);
  for (int i = 0; i < Q; ++i)
  {
    int c,x,y;
    scanf("%d%d%d", &c, &x, &y);
    if(c == COM_FIND) {
      ans.push_back(segtree.Find(x, y));
    }
    else if(c == COM_UPDATE){
      segtree.Update(x, y);
    }
    else {
      std::cerr << "error: unknown operation\n";
      exit(1);
    }
  }

  #ifdef DEBUG
  segtree.Dump();
  #endif

  for(auto&& i : ans) {
    std::cout << i << std::endl;
  }

  return 0;
}


Measured memory_bytes: 4344
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// #define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define vvv64 vector<vv32>
#define vvvv64 vector<vvv32>
ll exp(ll n, ll e)
{
    if (e==0)
        return 1;
    ll temp=exp((n*n)%MOD,e/2);
    return e%2==0 ? temp : (temp*n)%MOD;
}

ll inverse(ll n)
{
	return exp(n,MOD-2);
}

int LIM=2e5+100;
void solve()
{
//Read Comments below main
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	v64 p(a+1,0);
	v64 q(b+1,0);
	v64 r(c+1,0);
	for (ll i=1;  i<=a; i++)
		cin>>p[i];
	for (ll i=1; i<=b; i++)
		cin>>q[i];
	for (ll i=1; i<=c; i++)
		cin>>r[i];
	sort(p.begin()+1,p.end());
	sort(q.begin()+1,q.end());
	sort(r.begin()+1,r.end());

	p.push_back(1e12);
	q.push_back(1e12);
	ll x1=a-x+1;
	ll y1=b-y+1;
	ll z1=c;
	ll ans=0;
	// cout<<x1<<" "<<y1<<" "<<z1<<endl;
	while (true)
	{
		if (z1==0)
			break;
		bool f1=0,f2=0;
		if (r[z1]>p[x1])
			f1=1;
		if (r[z1]>q[y1])
			f2=1;
		if (f1 && !f2)
		{
			ans+=r[z1];
			x1++;
		}
		else if (f2 && !f1)
		{
			ans+=r[z1];
			y1++;
		}
		else if (f1 && f2)
		{
			if (p[x1]<q[y1])
			{
				ans+=r[z1];
				x1++;
			}
			else
			{
				ans+=r[z1];
				y1++;
			}
		}
		else
		{
			break;
		}
		z1--;
	}
	// cout<<x1<<" "<<y1<<endl;
	for (ll i=x1; i<=a; i++)
	{
		ans+=p[i];
	}
	for (ll i=y1; i<=b; i++)
	{
		ans+=q[i];
	}
	cout<<ans<<endl;
}
 
int main() {
    fast_cin();
    ll t=1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algo

Measured memory_bytes: 3456
N = int(input())
A = list(map(int,input().rstrip().split(" ")))
flag = True
ans = 1
for i in range(N):
    if A[i] == 0:
        ans = 0
for i in range(N):
    ans *= A[i]
    if ans > 10 ** 18:
        flag = False
        break
if flag:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 21784
import sys

g = [None, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1]

x, y = map(int, sys.stdin.readline().split())

def main():
    return 'Yes' if g[x] == g[y] else 'No'

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int h, w;
	cin >> h >> w;

	string a[h];
	rep(i, h) cin >> a[i];

	bool b[h][w];
	rep(i, h) rep(j, w) b[i][j] = true;

	rep(i, h){
		bool flg = true;
		rep(j, w){
			if(a[i][j] == '#') {
				flg = false;
				// cout << i << "," << j << endl;
				break;
			}
		}

		if(flg){
			rep(j, w) b[i][j] = false;
		}
	}

	rep(j, w){
		bool flg = true;
		rep(i, h){
			if(a[i][j] == '#') {
				flg = false;
				break;
			}
		}

		if(flg){
			rep(i, h) b[i][j] = false;
		}
	}

	// rep(i, h) rep(j, w) cout << b[i][j] << (j == w-1 ? "\n": "");

	rep(i, h){
		bool flg = false;
		rep(j, w){
			if(b[i][j]) {
				flg = true;
				cout << (""s + a[i][j]);
			}
		}
		if(flg) cout << endl;
	}
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())
x -= 1
y -= 1
r = {i: 0 for i in range(1, n)}
for i in range(n - 1):
    for k in range(i + 1, n):
        if (x < i and k < y) or (x <= i and k < y) or (x < i and k <= y):
            t = min(i - x + y - k + 1, k - i)
            r[t] += 1
        elif i <= x and y <= k:
            t = k - i - (y - x - 1)
            r[t] += 1
        elif i < x < k < y:
            t = min(k - i, x - i + 1 + y - k)
            r[t] += 1
        elif x < i < y < k:
            t = min(k - i, i - x + 1 + k - y)
            r[t] += 1
        else:
            t = k - i
            r[t] += 1
for i in range(1, n):
    print(r[i])


Measured memory_bytes: 3700
import numpy as np
import fractions
import functools
N, X = map(int, input().split())
x = np.array(sorted(list(map(int, input().split()))))
x =  np.insert(x, np.where(x > X)[0][0], X) if len(np.where(x > X)[0]) > 0 else np.append(x, X)
x = np.diff(x)
print(functools.reduce(fractions.gcd, x))

Measured memory_bytes: 25024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  int l,r;
  l=A+B;
  r=C+D;
  
  if(l>r) cout<<"Left"<<endl;
  if(l<r) cout<<"Right"<<endl;
  if(l==r)cout<<"Balanced"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
int n,k,a[105],dp[M];
bool vis[M];
int dfs(int cur) {
    if (vis[cur]) return dp[cur];
    if (cur == 0) return 0;
    vis[cur] = true;
    int &res = dp[cur];

    res = 0;
    REP(i,1,n) if(cur >= a[i] && !dfs(cur-a[i])) {
        res = 1;
    }
    return res;
}
int main()
{
    scanf("%d %d", &n, &k);
    REP(i,1,n) scanf("%d", &a[i]);
    printf("%s\n", dfs(k) ? "First" : "Second");
    return 0;
}


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n;
  cin >> n;
  int t, a;
  cin >> t >> a;
  vector<double> h(n);

  double diff = 1e9;
  int ans;
  REP(i, 0, n){
      cin >> h[i];
      h[i] = t - h[i] * 0.006;
      if(abs(h[i] - a) < diff){
        diff = abs(h[i] - a);
        ans = i + 1;
      }
  }

  cout << ans << endl;


  return 0;
}


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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    string s;cin >> s;
    vector<int> a;
    for (int i = 0; i <= n; i++) {
        if (s[i]=='0') a.push_back(i);
    }

    vector<int> res;
    int x = n;
    while (x != 0) {
        int y = *lower_bound(a.begin(), a.end(), x-m);
        if (y == x) {
            cout << -1; return;
        }
        res.push_back(x-y);
        x = y;
    }
    reverse(res.begin(), res.end());
    for (auto& x: res) {
        cout << x << ' ';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1480
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;

#define INF 1e18
#define int long long
const int MOD = 1000000007;

signed main() {
    int n; cin >> n;
    string s; cin >> s;
    vector<int> cnt(26, 1);

    for(int i = 0; i < n; i++) {
        cnt[s[i] - 'a']++;
    }

    int ans = 1;
    for(int i = 0; i < 26; i++) {
        ans = (ans * cnt[i]) % MOD;
    }

    cout << (ans - 1) << endl;
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP=pair<P, int>;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

string s;
int n;
int k = 1;
int ans;
char a;
signed main() {
	cin >> s;
	n = s.size();
	rep(i, n) {
		if (i == 0) {
			a = s[i];
			ans++;
		}
		else if (k == 1) {
			if (a != s[i]) {
				ans++;
				a = s[i];
			}
			else {
				k = 2;
			}
		}
		else {
			ans++;
			k = 1;
			a = '0';
		}
	}
	cout << ans << endl;
}

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

int main()
{
    long long N, K,a;
    cin >> N >> K;
    vector<long long> x(1);
    x.at(0) = N;

    if(N>K)
    {
        x.at(0) = N % K;
    }

    for (int i = 1; ; i++)
    {

        x.push_back(x.at(i - 1) - K);
        x.at(i) = abs(x.at(i));

        if(i>3 && x.at(i)==x.at(i-2))
        {
            a = min(x.at(i), x.at(i - 1));
            cout << a << endl;
            break;
        }
        //cout << x.at(i) << endl;
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
	int val[15]={0,14},a,b;
	for(int i=2;i<=13;++i) val[i]=i;
	cin>>a>>b;
	cout<<(val[a]!=val[b]?(val[a]>val[b]?"Alice":"Bob"):"Draw");
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;

 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

int d[205][205];
int N,M,R;
vector<int> r;
#define INF (1<<29)

int main(){
	cin >> N >> M >> R;
	FORI(0,R) {
		int t;
		cin >> t; t--;
		r.push_back(t);
	}
	sort(r.begin(), r.end());
	FORI(0, N) {
		FORJ(0,N) {
			if (i != j)
				d[i][j] = INF;
		}
	}
	FORI(0, M) {
		int a, b, c;
		cin >> a >> b >> c; a--; b--;
		d[a][b] = d[b][a] = c;
	}
	FORK(0, N) {//
		FORI(0, N) {
			FORJ(0, N) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}

		}
	}
	int ans = INF;//
	do {
		int t = 0;
		FORI(1, r.size()) {
			t += d[r[i]][r[i - 1]];
		}
		ans = min(ans, t);
	} while (next_permutation(r.begin(), r.end()));//
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
open Printf
open Scanf

let () =
  let n = scanf "%d " (fun x -> x) in
  let rec loop i sm =
    if i = 0 then sm
    else let l, r = scanf "%d %d " (fun x y -> (x, y)) in loop (i-1) (sm + r - l + 1) in
  loop n 0 |> printf "%d\n"


Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=105;
int n,m;
int f[N][N];
char a[N][N];
int main() {
    scanf("%d%d",&n,&m);
    getchar();
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=m;j++) {
            scanf("%c",&a[i][j]);
        }
        getchar();
    }
    for (int i=1;i<=n;i++) {
        bool flag=true;
        for (int j=1;j<=m;j++) {
            if (a[i][j]=='#') {
                flag=false;
                break;
            }
        }
        if (flag) {
            for (int j=1;j<=m;j++) f[i][j]=1;
        }
    }
    for (int i=1;i<=m;i++) {
        bool flag=true;
        for (int j=1;j<=n;j++) {
            if (a[j][i]=='#') {
                flag=false;
                break;
            }
        }
        if (flag) {
            for (int j=1;j<=n;j++) f[j][i]=1;
        }
    }
    for (int i=1;i<=n;i++) {
        bool flag=false;
        for (int j=1;j<=m;j++) {
            if (f[i][j]==0) {
                printf("%c",a[i][j]);
                flag=true;
            }
        }
        if (flag) printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
#include<cstdio>
 
 
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007
#define MAX_H 101
#define MAX_W 101

int h,w;
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,1,-1};
char tmp[3] = {'@','#','*'};

char mp[MAX_H][MAX_W];


void dfs(int x,int y,int k){

     //今いるところをHに置き換える
    mp[x][y] = 'H';
    //移動方向をループ
    for(int i = 0;i <= 4;i++){
        //for(int dy = -1;dy <= 1;dy++){
            //x方向にdx,ｙ方向にdy移動した場所を(nx,ny)とする
            int nx = x + dx[i], ny = y + dy[i];
            //nx,nyが庭の範囲内にあるか、また、現在の場所field[nx][ny]が@か#か*かの判定
            if(0 <= nx && nx < h && 0 <= ny && ny < w && mp[nx][ny] == tmp[k]){
                dfs(nx,ny,k);
            }
         //}
     }
     return;
}




void solve(){

    int res = 0;
    REP(k,3){
        for(int i = 0;i < h;i++){
            for(int j = 0;j < w;j++){
                if(mp[i][j] == tmp[k]){
                    //@や#、*が残っているならばその場所からdfsを始める
                    dfs(i,j,k);
                    //ここで1つの島が見つかったことになるので水たまりの個数を１つ足す
                    res++;
                }
            }
        }
    }
    //島の個数を表示
    cout << res << endl;
}


int main(){

    while(cin >> h >> w,h){

        REP(i,h){
            REP(j,w){
                cin >> mp[i][j];
            }
        }
        solve();
    }
    return 0;
}



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

int main()
{
  int x,y;
  
  scanf("%d %d",&x,&y);
  
  if(x>y)
  {
    printf("safe");
  }
  else
  {
    printf("unsafe");
  }
  
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
 
using namespace std;
 
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++) 
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define all(i) (i).begin(),(i).end()
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
 
int main(void)
{
  int pw[10] = {512, 256, 128, 64, 32, 16, 8, 4, 2, 1};
  int n;
  
  while (cin >> n){
    vi li;
    int cnt = 0;
    REP(i, 10){
      if (n - pw[i] >= 0){
        n -= pw[i];
        li.pb(pw[i]);
        cnt++;
      }
    }
    sort(all(li));
    REP(i, cnt){
      if (i == cnt - 1) cout << li[i] << endl;
      else cout << li[i] << " ";
    }
  }

  return 0;
}

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>


int main(){
  long int h;
  scanf("%ld",&h);
  long int sum;
  long int num=0;
  if(h==1){
    printf("%d\n",1);}
  else{
    num=1;
    while(h>0){
      sum+=num;
      h/=2;
      num*=2;}
    printf("%ld\n",sum);}
  


  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;
long long l[51];
long long p[51];
long long n, x;

long long calc(long long d, long long pos){
    if(d == 1){
        if(x - pos <= 4) return x - pos - 1;
        else return 3;
    }
    if(pos + 1 >= x) return 0;
    else if(pos + 1 + l[d - 1] >= x) return calc(d - 1, pos + 1);
    else if(pos + 2 + l[d - 1] == x) return (p[d] + 1) / 2;
    else if(pos + 2 + 2 * l[d - 1] >= x) return calc(d - 1, pos + 2 + l[d - 1]) + p[d - 1] + 1;
    else return p[d];
}

int main(){
    long long ans = 0;
    cin >> n >> x;
    l[0] = p[0] = 1;
    for(int i = 1; i <=50; i++){
        l[i] = 2 * l[i - 1] + 3;
        p[i] = 2 * p[i - 1] + 1;
    }
    ans = calc(n, 0);
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using namespace std;
//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<class T> inline bool chmin(T a, T b) { if (a > b) { a = b; return 1; } return 0; }

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


#define INF 2000000000


int main() {
 
    int h,n;
    cin >> h >> n ;
    
    ll tmp = 0;
    vector<int> a(n);
    
    for(int i=0;i<n;i++){
        cin >> a[i] ;
        tmp = tmp + a[i];
    }
    
    (tmp >= h) ? (cout << "Yes" << endl) : (cout << "No" << endl);

    

   // cout << tmp ;
}


Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N; long long X;
	cin >> N >> X;
	vector<long long> B(N), L(N), R(N);
	for (int i = 0; i < N; ++i) {
		cin >> B[i] >> L[i] >> R[i];
	}
	long long ini = 0;
	vector<long long> sum(N);
	for (int i = 0; i < N; ++i) {
		sum[i] = B[i] * L[i] + (X - B[i]) * R[i];
		ini += B[i] * L[i];
	}
	vector<int> irank(N);
	for (int i = 0; i < N; ++i) {
		irank[i] = i;
	}
	sort(irank.begin(), irank.end(), [&](int i, int j) { return sum[i] > sum[j]; });
	vector<int> rank(N);
	for (int i = 0; i < N; ++i) rank[irank[i]] = i;
	vector<long long> s(N + 1);
	for (int i = 0; i < N; ++i) s[i + 1] = s[i] + sum[irank[i]];
	long long l = -1, r = N * X + 1;
	while (r - l > 1) {
		long long m = (l + r) >> 1;
		bool ok = false;
		if (m / X == N) {
			if (s[N] >= ini) ok = true;
		}
		else {
			for (int i = 0; i < N; ++i) {
				long long score = s[m / X + (rank[i] < m / X ? 1 : 0)];
				if (rank[i] < m / X) score -= sum[i];
				score += L[i] * min(B[i], m % X);
				score += R[i] * max(0LL, m % X - B[i]);
				if (score >= ini) ok = true;
			}
		}
		if (ok) r = m;
		else l = m;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int K,X;
  cin>>K>>X;
  
  for(int i=X-K+1;i<X+K-1;i++){
    cout<<i<<" ";
  }
  cout<<X+K-1<<endl;
}

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

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll a, b, c, k; cin >> a >> b >> c >> k;
    rep(i, k){
        if(a >= b) b*= 2;
        else if(b >= c) c *= 2;
    }
    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b,c;
	cin>>a>>b>>c;
	if(c<=b) cout<<"delicious";
	else if(c<=a+b) cout<<"safe";
	else cout<<"dangerous";
	return 0;
}


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

int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    for(size_t i = 0; i < N; i++)
    {
        cin >> x[i];
    }
    for(size_t i = 0; i < M; i++)
    {
        cin >> y[i];
    }
    int x_max = *max_element(x.begin(), x.end());
    int y_min = *min_element(y.begin(), y.end());
    if(x_max < Y && X < y_min && x_max < y_min)
        cout << "No War" << endl;
    else
        cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int a = N/100;
		int x = a*100 + a*10 + a;
		
		if(N <= x) {
			System.out.println(x);
		}else {
			a++;
			x = a*100 + a*10 + a;
			System.out.println(x);
		}
		
		
		
		in.close();
	}
}


Measured memory_bytes: 23508
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	abc := [][]int{{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}}

	var xGroup, yGroup int
	for groupNumber, v := range abc {
		for _, vv := range v {
			switch vv {
			case x:
				xGroup = groupNumber
			case y:
				yGroup = groupNumber
			}
		}
	}

	if xGroup == yGroup {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const 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 true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=5005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S,T;cin>>S>>T;
    T.pop_back();
    if(S==T) cout<<"Yes\n";
    else cout<<"No\n";
}



Measured memory_bytes: 3660
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
//        int kazu = int.Parse(ReadLine());
        string[] input0 = ReadLine().Split(' ');
        string[] input1 = ReadLine().Split(' ');
        string[] input2 = ReadLine().Split(' ');
        int[,] suuji = new int[3,3];
        for(int i=0;i<3;i++){
            suuji[0,i] = int.Parse(input0[i]);
            suuji[1,i] = int.Parse(input1[i]);
            suuji[2,i] = int.Parse(input2[i]);
        }
/*        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                Write(suuji[i,j]);
            }
            WriteLine("");
        }*/
        int count = 0;
        for(int a1=0;a1<=suuji[0,0];a1++){
            for(int a2=0;a2<=suuji[1,0];a2++){
                for(int a3=0;a3<=suuji[2,0];a3++){
                    int[] b = new int[3];
                    for(int i=0;i<3;i++){
                        b[i] = suuji[0,i] -a1;
                        if(b[i] != suuji[1,i]-a2 || b[i] != suuji[2,i]-a3){
                            count = 0;
                            break;
                        }else{
                            count++;
                        }
                    }
                    if(count > 0){ break; }
                }
                if(count > 0){ break; }
            }
            if(count > 0){ break; }
        }
        if(count > 0){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}


Measured memory_bytes: 15184
# import sys
# input = sys.stdin.readline
def main():
    N = int( input())
    A = list( map( int, input().split()))
    B = list( map( int ,input().split()))
    dpOne = [0]*(N+1)
    for i in range(3):
        a, b = A[i], B[i]
        for j in range(N-a+1):
            if dpOne[j+a] < dpOne[j]+b:
                dpOne[j+a] = dpOne[j]+b
    donguri = N
    for i in range(N+1):
        if donguri < N-i+dpOne[i]:
            donguri = N - i +dpOne[i]
    K = donguri
    dpTwo = [0]*(K+1)
    for i in range(3):
        a, b  = A[i], B[i]
        for j in range(K-b+1):
            if dpTwo[j+b] < dpTwo[j]+a:
                dpTwo[j+b] = dpTwo[j]+a
    ans = K
    for i in range(K+1):
        if ans < K - i + dpTwo[i]:
            ans = K-i+dpTwo[i]
    print( ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 228508
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
#define MAX_N 100000
int a[MAX_N];
int main(){
    int N,L;
    cin >> N >> L;
    REP(i,N) cin >> a[i];
    bool ans = false;
    int last;
    REP(i,N-1){
        if(a[i]+a[i+1] >= L){
            ans = true;
            last = i+1;
            break;
        }
    }
    if(! ans) cout << "Impossible" << endl;
    else{
        cout << "Possible" << endl;
        REP1(i,last-1) cout << i << endl;
        for(int i=N-1;i>last;i--) cout << i << endl;
        cout << last << endl; 
    }
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;

void Swap(int arr[], int x, int y){
    int temp;
    temp = arr[x];
    arr[x] = arr[y];
    arr[y] = temp;
}

int main(){

    int w, n;
    cin >> w >> n;
    vector<int> arr(w+1);

    for(int i=1; i<w+1; i++){
        arr[i] = i;
    }

    for(int m=0; m<n; m++){
        int a, b;
        scanf("%d,%d", &a, &b);

        Swap(arr.data(), a, b);
    }

    for(int i=1; i<w+1; i++){
        cout << arr[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>
#include<string.h>
int main()
{
int n=0,i,N;
char a[200000];
scanf("%s",&a);
N=strlen(a);

for(i=0;i<N-1;i++)
{
if(a[i]!=a[i+1])
n++;              //反转一次
}

printf("%d",n);


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 _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int n;
  cin >> n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  while (n--)
  {
    string input;
    cin >> input;
    if (input == "AC")
      ac++;
    else if (input == "WA")
      wa++;
    else if (input == "TLE")
      tle++;
    else
      re++;
  }
  printf("AC x %d\n", ac);
  printf("WA x %d\n", wa);
  printf("TLE x %d\n", tle);
  printf("RE x %d\n", re);
}


Measured memory_bytes: 3724
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;

long long binom[300001];
long long MOD;

long long mult(long long a, long long b, long long p) {
	return (a*b) % p;
}

long long inverse(long long a, long long p) {
	long long q;
	long long ans;
	long long d = a;
	q = p-2;
	ans = 1;

	while (q > 0) {
		if (q % 2 == 1) {
			ans = mult(ans, d, p);
		}
		d = mult(d, d, p);
		q = q / 2;
	}
	return ans;
}

long long div(long long a, long long b, long long p) {
	return mult(a, inverse(b,p), p);
}


int main(void){
	long long A, B, K, N;
	scanf("%lld %lld %lld %lld", &N, &A, &B, &K);

	MOD = 998244353;


	/*二項係数の計算*/
	binom[0] = 1;
	for (int i = 0; i < N; i++) {
		binom[i + 1] = div(mult(binom[i], N - (long long)i, MOD), (long long)i + 1, MOD);
	}

	long long ans = 0;



	for (int i = 0; i <= N; i++) {
		if ((K - i * A) % B == 0 && 0<= (K - i * A) / B && (K - i * A) / B <= N) {
			ans = (ans + mult(binom[i], binom[(K - i * A) / B], MOD)) % MOD;
		}
	}

	printf("%lld\n", ans);
	
}









Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define MOD 1000000007

int main() {
    string a, b, c;
    while (cin >> a && a != "0"){
        cin >> b >> c;
        reverse(a.begin(), a.end());
        reverse(b.begin(), b.end());
        reverse(c.begin(), c.end());
        int n = a.length();
        vector<vector<ll> > dp(n+1, VL(2));
        dp[0][0] = 1;
        REP(i,n) REP(j,2){
            int lower = (i == n-1 ? 1: 0);
            FOR(ai,lower,9) FOR(bi,lower,9) FOR(ci,lower,9){
                if (a[i] != '?' && ai != a[i] - '0') continue;
                if (b[i] != '?' && bi != b[i] - '0') continue;
                if (c[i] != '?' && ci != c[i] - '0') continue;
                int x = ai + bi + j;
                if (x % 10 != ci) continue;
                dp[i+1][x/10] = (dp[i+1][x/10] + dp[i][j]) % MOD;
            }
        }
        cout << dp[n][0] << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		int[][] ma;
		int[][] mb;
		
		String x = "";
		try {
			x = in.readLine();
			String[] data = x.split(" ");
			int n = Integer.parseInt(data[0]);
			int m = Integer.parseInt(data[1]);
			int l = Integer.parseInt(data[2]);
			
			ma = new int[n][m];
			mb = new int[m][l];

			for (int i = 0; i < n; i++) {
				x = in.readLine();
				data = x.split(" ");
				
				for (int j = 0; j < m; j++) {
					ma[i][j] = Integer.parseInt(data[j]);
				}
			}
			
			for (int i = 0; i < m; i++) {
				x = in.readLine();
				data = x.split(" ");
				
				for (int j = 0; j < l; j++) {
					mb[i][j] = Integer.parseInt(data[j]);
				}
			}
			
			long[][] mc = new long[n][l];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < l; j++) {
					mc[i][j] = 0;
					for (int k = 0; k < m; k++) {
						mc[i][j] = mc[i][j] + ma[i][k] * mb[k][j];
					}
				}
			}

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < l; j++) {
					if (j != 0) System.out.print(" ");
					System.out.print(mc[i][j]);
				}
				System.out.println();
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 33392
A, B, C, X, Y = map(int, input().split())

if A + B > 2 * C:
    z = min(X, Y)
    x, y = X - z, Y - z
    ans = 2 * C * z + min(A, 2 * C) * x + min(B, 2 * C) * y
else:
    ans = A * X + B * Y

print(ans)

Measured memory_bytes: 3060
#include<cstdio>
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	if(a<0&&b>0)
		printf("Zero\n");
	else if(a>0&&b>0)
		printf("Positive\n");
	else{
		if((-b+a+1)%2==0)
			printf("Positive\n");
		else
			printf("Negative\n");
	}
}

Measured memory_bytes: 128
N, M, Q = map(int, input().split())

# 入力
A = [[0 for j in range(N+1)] for i in range(N+1)]
for _ in range(M):
    L, R = map(int, input().split())
    A[L][R] += 1


# 二次元累積和
Cum = [[0 for j in range(N+1)] for i in range(N+1)]
for i in range(N):
    for j in range(N):
        Cum[i+1][j+1] = Cum[i][j+1] + Cum[i+1][j] - Cum[i][j] + A[i+1][j+1]

# クエリ処理
for _ in range(Q):
    p, q = map(int, input().split())
    print(Cum[q][q]-Cum[p-1][q]-Cum[q][p-1]+Cum[p-1][p-1])


Measured memory_bytes: 59608
#include <iostream>
using namespace std;
long long gcd(long long a,long long b){
	
	return b==0?a:gcd(b,a%b);
}



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	long long result=0;
	cin>>n;
	for(int i=0;i<n;i++){
		long long t;
		cin>>t;
		result=result==0?t:result*(t/gcd(result,t));
	}
	cout<<result<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#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 dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};




int main(){
    int n,x;cin >> n >> x;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    int ans = 0;
    int t=0;
    for (int i = 0; i < n; i++) {
        if(t<=x) ans++;
        t+=l[i];
    }
    if(t<=x) ans++;
    cout << ans << endl;
    return 0;
}


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

int main() {
  string N, ans;
  cin >> N;
  ans = "No";
  
  int sum = 0;
  for (int i = 0; i < N.size(); i++) {
    sum += (N.at(i) - 48);
    // cout << N.at(i) << "," << sum << endl;
  }
  if (sum % 9 == 0) ans = "Yes";
  cout << ans << endl;
  return 0;
}


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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

long long dp[1000005];

const long long MOD = 1e9+7;

int main(){
    int N, H, D;
    scanf("%d%d%d", &N, &H, &D);

    long long retainWays = 0;
    long long fact = 1;
    for(int i = 1; i <= N; i ++){
        fact = fact*i%MOD;
        retainWays += fact;
    }
    retainWays %= MOD;

    //printf("retainWays=%lld\n", retainWays);

    dp[0] = fact;
    long long slidingWindowSum = dp[0];
    for(int i = 1; i < H; i ++){
        dp[i] = slidingWindowSum*retainWays%MOD;

        slidingWindowSum += dp[i];
        if(i >= D){slidingWindowSum -= dp[i-D];}

        if(slidingWindowSum >= MOD){slidingWindowSum -= MOD;}
        else if(slidingWindowSum < 0){slidingWindowSum += MOD;}

        //printf("dp[%d]=%lld\n", i, dp[i]);
    }

    printf("%lld", slidingWindowSum);
    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
map<char,int>M;
main()
{
	string t="qwertasdfgzxcvb";
	for(int i=0;i<t.size();i++)M[t[i]]=1;
	while(cin>>t,t!="#")
	{
		int cnt=0,n=M[t[0]];
		for(int i=1;i<t.size();i++)
		{
			if(n!=M[t[i]])cnt++;
			n=M[t[i]];
		}
		cout<<cnt<<endl;
	}
}


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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      for(; x; x /= 10) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
      }
    }
  }
  cout << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    long long N;
    cin >> N;
    long long ans=0;
    for(long long i=1; i*i<N; i++){
        if(N%i==0){
            long long m=N/i;
            m--;
            if(m>i){
                ans+=m;
            }
        }
    }
    cout << ans << endl;
    cin >> N ;
}

Measured memory_bytes: 256