akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){

    string s,t;
    cin >> s >> t;

   

    ll j = 0;
    ll cnt = 0;
    rep(i,0,sz(t)){
	int jj = s.find(t[i],j);

	if(jj == -1){
	     cnt++;
	     jj = s.find(t[i],0);
	     if(jj == -1){
		 P(-1);
		 ret 0;		 
	     }
	     j = jj+1;
	}else{
	    j = jj+1;
	}
	//	P(j);
    }
    P(j + (cnt * sz(s)));
    return  0;
}


Measured memory_bytes: 640
#include <iostream>

int main()
{
	unsigned long long int h,w,res;
	std::cin>>w>>h;
	if(w % 3 == 0 || h % 3 == 0)
		res = 0;
	else if(w % 2 == 0)
	{
		if(h % 2 == 0)
		{
			res = w > h ? h : w;
			res /= 2;
		}
		else
			res = w / 2;
	}
	else if(h % 2 == 0)
		res = h / 2;
	else
	{
		if(w > h)
		{
			res = w;
			w = h;
			h = res;
		}
		res = w / 2 * h - h / 2 * (w / 2 + 1);
	}
	if(res > w)
		res = w;
	if(res > h)
		res = h;
	std::cout<<res;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static int N;
    static bool[][] B;
    static int[][] P;

    static void INPUT()
    {
        N = NextInt();
        B = new bool[N][];
        P = new int[N][];
        for (int i = 0; i < N; i++)
            B[i] = LineInt().Select(__ => __ == 1).ToArray();
        for (int i = 0; i < N; i++)
            P[i] = LineInt();
    }
    static void OUT()
    {
        var max = int.MinValue;
        for (var b = 1; b < (1 << 10); b++)
        {
            var sum = 0;
            for(var n = 0; n < N; n++)
            {
                var nn = 0;
                for (var i = 0; i < 10; i++)
                {
                    if ((b >> i) % 2 == 1)
                    {
                        if (B[n][i]) nn++;
                    }
                }
                sum += P[n][nn];
            }

            max = Math.Max(max, sum);
        }

        Console.WriteLine(max);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        TESTINPUT();
        INPUT();
#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
        //S = "1222";
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int k, x; cin >> k >> x;

    if (500 * k >= x) {
        puts("Yes");
    } else {
        puts("No");
    }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int n,c;cin >>n>>c;
    vector<vector<ll>>d(c,vector<ll>(c));
    vector<vector<ll>>cnt(3,vector<ll>(c,0));
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >>d[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            ll a;cin >>a;a--;
            int k=(i+j)%3;
            cnt[k][a]++;
        }
    }
    ll ans=INFll;
    for (int i = 0; i < c; ++i) {
        for (int j = 0; j < c; ++j) {
            for (int k = 0; k < c; ++k) {
                if(i==j||j==k||i==k)continue;
                ll now=0;
                for (int l = 0; l < c; ++l) {
                    now+=d[l][i]*cnt[0][l];
                    now+=d[l][j]*cnt[1][l];
                    now+=d[l][k]*cnt[2][l];
                }
                ans=min(ans,now);
            }
        }
    }
    cout <<ans <<endl;
    return 0;
}

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

struct card{
    char suit;
    int number;
};

int partition(vector<card> &a, int p, int r){
    card base = a.at(r);
    int i = p - 1;
    for(int j = p; j < r; j++){
        if(a.at(j).number <= base.number){
            i++;
            card tmp = a.at(i);
            a.at(i) = a.at(j);
            a.at(j) = tmp;
        }
    }
    a.at(r) = a.at(i+1);
    a.at(i+1) = base;
    return i+1;
}

void quickSort(vector<card> &a, int p, int r){
    if(p < r){
        int q = partition(a, p, r);
        quickSort(a, p, q - 1);
        quickSort(a, q + 1, r);
    }
}


void merge(vector<card> &s, int left, int mid, int right){
    vector<card> n1(mid - left);
    vector<card> n2(right - mid);

    rep(i, mid - left){
        n1.at(i) = s.at(left + i);
    }
    rep(i, right - mid){
        n2.at(i) = s.at(mid + i);
    }
    card sentinel;
    sentinel.suit = 'A';
    sentinel.number = INT_MAX;

    n1.push_back(sentinel);
    n2.push_back(sentinel);

    int n1_index = 0;
    int n2_index = 0;

    // cout << "left mid right " << left << " " << mid << " " << right << endl;
    for(int i = left; i < right; i++){
        if(n1.at(n1_index).number > n2.at(n2_index).number){
            s.at(i) = n2.at(n2_index);
            n2_index++;
        }else{
            s.at(i) = n1.at(n1_index);
            n1_index++;
        }
    }
}

void mergeSort(vector<card> &s, int left, int right){
    if(left + 1 < right){
        int mid = (right + left) / 2;
        mergeSort(s, left, mid);
        mergeSort(s, mid, right);
        merge(s, left, mid, right);
    }

}


int main(){
    int n; cin >> n;
    vector<card> a(n);
    vector<card> b(n);
    rep(i, n){
        cin >> a.at(i).suit >> a.at(i).number;
    }

    b = a;

    // rep(i, n){
    //     cout << before_sort.at(i).suit << before_sort.at(i).number << " ";
    // }
    // cout << endl;

    quickSort(a, 0, n-1);
    mergeSort(b, 0, n);

    string is_stable = "Stable";
    rep(i, n){
        if(a.at(i).suit != b.at(i).suit){
            is_stable = "Not stable";
            break;
        }
    }
    cout << is_stable << endl;

    rep(i, n){
        cout << a.at(i).suit << " " << a.at(i).number << endl;
    }



}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vll a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  ll g = a[0];
  for (int i = 1; i < n; i++)
    g = gcd(g, a[i]);
  cout << g << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN   
#define linf LLONG_MAX
#define lninf LLONG_MIN   
const ll mod=998244353;
const int N=2e5+4;

int main()                  
{
	int d,t,s; cin>>d>>t>>s;

	if(s*t >= d)
	cout<<"Yes";
	else
	cout<<"No";

    return 0;
}

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

typedef long double ld;
typedef long long ll;

void print()
{
  std::cout << std::endl;
}

template<class T>
void print(T param)
{
  std::cout << param << std::endl;
  return;
}

template<class T, class... S>
void print(T param1, S... param2)
{
  std::cout << param1 << " "; print(std::forward<S>(param2)...);
}

void fail()
{
  print("NO");
  return;
}

void solve()
{
  ll N;
  std::cin >> N;
  std::map<ll, ll> mp;
  for (ll i = 0; i < N; i++) {
    ll x;
    std::cin >> x;
    mp[x]++;
  }

  ll M;
  std::cin >> M;
  for (ll i = 0; i < M; i++) {
    ll d;
    std::cin >> d;
    if (mp[d] == 0) {
      return fail();
    }
    mp[d]--;
  }

  print("YES");
  return;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 12800
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100;
LL dp[MAX][2];
int A[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n, p;
	cin >> n >> p;
	FOR(i, 0, n)
	{
		cin >> A[i];
		A[i] &= 1;
	}

	dp[0][0] = 1;
	FOR(i, 0, n)
	{
		FOR(k, 0, 2)
		{
			dp[i + 1][k] += dp[i][k];
			dp[i + 1][k ^ A[i]] += dp[i][k];
		}
	}

	cout << dp[n][p] << endl;
}


Measured memory_bytes: 256
n, k, q = gets.split("\s").map(&:to_i)
a = Array.new(n, k)

q.times do
  a[gets.to_i - 1] += 1
end

n.times do |i|
  if(a[i] <= q)
    puts "No"
  else
    puts "Yes"
  end
end


Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>a,b;
int main()
{
    int n,temp;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        a.push_back(temp);
   }
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        b.push_back(temp);
    }
    if (includes(a.begin(), a.end(),b.begin(), b.end()) == true)cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 5180
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;


int main(void) {

    int n;
    cin>>n;
    set<int> s;
    rep(i,n){
        int t;
        cin>>t;
        if(s.count(t))s.erase(s.find(t));
        else s.insert(t);
    }
    fin(s.size());


}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
  	cin >> n;
  	long long int dp[n+1],count=0,i=0,j=0;
  	memset(dp,0,sizeof(dp));
  	if(n==1){cout << 1 << endl;return 0;}
  	if(n==2){cout << 5 << endl;return 0;}
  	for(i=1;i<=n;i++){
    	for(j=i;j<=n;j = j+i){
        	dp[j]++;
        }
    }
  count=1;
  for(i=2;i<=n;i++){
    //cout << dp[i]<<" ";
  	count += i*(dp[i]);
  }
  cout << count << endl;
}

Measured memory_bytes: 81740
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <limits>
#include <iomanip>

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
}


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

int m, d, ans;

int main () {
	scanf ("%d %d", &m, &d);
	for (int i = 1; i <= m; ++ i) {
		for (int j = 22; j <= d; ++ j) {
			int x = j % 10, y = j / 10;
			if (x >= 2 && y >= 2 && x * y == i)
				++ ans;
		}
	}
	
	printf ("%d\n", ans);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;

    ll x , k , d;
    cin>>x>>k>>d;
    x = abs(x);
    ll tmp = min(k , x/d );

    k -= tmp;

    x -= tmp * d;

    if(k%2) {
        x -= d;
        cout<<abs(x)<<'\n';
    }
    else cout<<x<<'\n';
    return 0;
    
    
}

Measured memory_bytes: 3644
k, n = map(int, input().split())
a_list = list(map(int, input().split()))
max_distance = k + a_list[0] - a_list[n - 1]
for i in range(n - 1):
    max_distance = max(max_distance, a_list[i + 1] - a_list[i])
ans = k - max_distance
print(ans)


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

main()
{

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

    long long i,j,k,l,m,n,p,q;

    while(cin>>m>>n)cout<<m*n<<endl;
    return 0;

}


Measured memory_bytes: 3664
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint i,n,mae=mod,ans=0;
	cin>>n;
	vector<llint>a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	SO(a);REV(a);
	for(i=0;i<n;i++){ans+=a[i]-i-1;}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int x, y;
  bool a = false;
  cin >> x >> y;
  for(int i = 0; i<=x; i++){
    if(2*i + 2*x == y)
      a = true;
  }
  if(a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
#define MAX_N 2000001
bool isPrime[MAX_N];
void init(){
	rep(i,MAX_N) isPrime[i] = true;
	isPrime[0] = false;
	isPrime[1] = false;
	for(int i = 2; i*i <= MAX_N; i++){
		if( isPrime[i] == true){
			for(int j = 2; j*i < MAX_N; j++) isPrime[i*j] = false;
		}
	}
}

bool isItPrime(ll num){
	if( num == 1) return false;
	for(int i = 2; i < MAX_N; i++){
		if( isPrime[i] == true && num % i == 0) return false;
	}
	return true;
}

ll stair(ll num){
	for(int i = 1; i < MAX_N; i++){
		if( i*(i+1)/2 <= num && num < (i+1)*(i+2)/2){
			return i;
		}
	}
}


int main(){
	init();
	ll n;
	cin>>n;
	vector<pair<int,int>> divisors;
	ll ans = 0;
	if( n >= MAX_N && isItPrime(n) == true){
		n = 1;
		ans = 1;
	}
	
	for(int i = 2; i < MAX_N; i++){
		if( n == 1) break;
		if( isPrime[i] == true && n % i == 0){
			divisors.push_back(make_pair(i,1));
			n /= i;
			while( n % i == 0){
				divisors.back().second++;
				n /= i;
			}
		}
	}
	
	if( n >= MAX_N && isItPrime(n) == true){
		n = 1;
		ans += 1;
	}
	
	for(auto iter = divisors.begin(); iter != divisors.end(); iter++){
		//cout<<iter->first<<":"<<iter->second<<endl;
		//ans++;
		ans += stair(iter->second);
	}
	cout<<ans<<endl;
	return 0;
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    int x;
    cin >> x;
    int ans = x / 200;

    cout << 10 - ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long t = a * c;
    long long s = b * d;
    long long t2 = b * c;
    long long s2 = d * a;
    long long g = 0;
    cout << max(t, max(s2, max(t2, s))) << endl;
}

Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static class FenwickTree {
	    int n;
	    long x[];
	    public FenwickTree(int N) {
	    	this.n = N;
	    	x = new long[N + 1] ;
		}
	    int size()  { return n; }
	    long sum(int r) {
	        long S = 0;
	        for (r = r - 1; r >= 0; r = (r & (r + 1)) - 1) S += x[r];
	        return S;
	    }
	    long sum(int l, int r)  { return sum(r) - sum(l); }
	    void add(int k, long a) {
	        for (; k < n; k |= k + 1) {
	        	x[k] += a;
	        }
	    }
	    void set(int k, long a) { add(k, a - sum(k, k + 1)); }
	};
	static class Monster implements Comparable<Monster>{
		long X;
		long H;
		public Monster(long X , long H) {
			this.X = X;
			this.H = H;
		}
		@Override
		public int compareTo(Monster o) {
			return Long.compare(X, o.X);
		}
	}
	static int find(Monster ms[] , long X){
		int left = 0; 
		if(ms[left].X >= X){
			return 0;
		}
		int right = ms.length - 1; 
		while(right - left >= 2){
			int mid = (left + right) / 2;
			if(ms[mid].X >= X){
				right = mid;
			}else{
				left = mid;
			}
		}
		return right;
	}
	static long solveNaive(Monster ms[] , long D , long A){
		int N = ms.length;
		long ret = 0;
		FenwickTree fs = new FenwickTree(N + 1);
		for(int i = 0 ; i < N ; ++i){
			long bombRange = ms[i].X - 2 * D;
			int r = find(ms , bombRange);
			long prevBombNuum = fs.sum(r, i);
			long h = ms[i].H - prevBombNuum * A;
//			System.out.println(i+" "+prevBombNuum+" "+r+" "+ret+" "+bombRange+" "+h);
			if(h < 0){
				continue;
			}
			long bn = (h + A - 1) / A;
//			System.out.println(bn);
			ret += bn;
			fs.add(i, bn);
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long D = sc.nextLong();
		long A = sc.nextLong();
		Monster ms[] = new Monster[N];
		for(int i = 0 ; i < N ; ++i){
			long x = sc.nextLong();
			long h = sc.nextLong();
			ms[i] = new Monster(x, h);
		}
		Arrays.sort(ms);
		System.out.println(solveNaive(ms, D, A));
	}
}


Measured memory_bytes: 110460
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;

int n, m;
struct check {
    int cost; int mbit;
};
vector<check> a(1010);
int bitdp[1010][(1<<15)+1];

int main() {
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        check indata; int b;
        cin >> indata.cost >> b;
        int cbit = 0;
        for(int j = 0; j < b; ++j) {
            int c; cin >> c; c--;
            cbit = cbit | (1<<c);
        }
        indata.mbit = cbit;
        a.at(i) = indata;
    }

    /*boxdata
    for(int i = 0; i < m; ++i) {
        cout << a.at(i).cost << " " << bitset<8>(a.at(i).mbit) << endl;
    }*/

    for(int i = 0; i <= m; ++i) {
        for(int j = 0; j < (1<<n); ++j) {
            bitdp[i][j] = INF;
        }
    }

    bitdp[0][0] = 0;

    for(int i = 0; i < m; ++i) {
        for(int j = 0; j < (1<<n); ++j) {
            chmin(bitdp[i+1][j|a.at(i).mbit], bitdp[i][j]+a.at(i).cost);
            chmin(bitdp[i+1][j], bitdp[i][j]);
        }
    }

    if(bitdp[m][(1<<n)-1] == INF) cout << -1 << endl;
    else cout << bitdp[m][(1<<n)-1] << endl;
}

Measured memory_bytes: 127488
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    map<int,int>m;
    //vi arr;
    for(int i =0;i<n;i++){
        int no;
        cin>>no;
        m[no]++;
    }
    int ans=0;
    tr(it,m){
        int no = it->first;
        int freq = it->second;
        if(no!=freq){ 
            if(no>freq){
                ans=ans + freq;
            }
            else{
                ans+= freq-no;
            }
        }
    }
    cout<<ans<<endl;





}






























































Measured memory_bytes: 6272
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll N , K ;
vector<ll> A;
vector<ll> candidate;

bool chk(ll inp){
    vector<ll> nums;
    
    rep(i, A.size()){
        if(A[i] % inp != 0)
            nums.pb(A[i] % inp);
    }
    
    sort(all(nums));
    
    ll i = 0; ll j = nums.size() - 1;
    
    ll ps = 0;
    ll cnt = 0;
    
 //   ps = nums[0];
    
    while(i < j){
        if(ps >= (inp - nums[j])){
            ps -= (inp - nums[j]);
            j--;
        }else{
            ps += nums[i];
            cnt += nums[i];
            i ++;
        }
            
    }
    if(cnt <= K) return true;
    else return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> K ;
    ll s = 0;
    
    rep(i, N){
        ll inp; cin >> inp;
        A.pb(inp);
        s += inp;
    }
    
    rep(i, sqrt(s + 1) + 1){
        if(i == 0 ) continue;
        
        if(s % i == 0){
            candidate.pb(i);
            candidate.pb(s/i);
        }
    }
    
    
    sort(rall(candidate));
    
    rep(i, candidate.size()){
        if(chk(candidate[i])){
            cout << candidate[i] << endl;
            return 0;
        }
    }
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define int long long
using namespace std;

int cnt[200000];

signed main() {
	int n, k, i;
	
	cin >> n >> k;
	for (i = 0; i < min(n + 1, k); i++) {
		cnt[i] = (n - i) / k;
		if (i > 0) cnt[i]++;
	}
	
	int ans = 0;
	for (i = 0; i < min(n + 1, k); i++) {
		if ((i + i) % k != 0) continue;
		ans += cnt[i] * cnt[(k - i) % k] * cnt[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INF = 1LL << 60;

 ll rec(int n, long long x) {
     if (n == 0) return 1;
     ll len = (1LL << (n + 1)) - 3; // n - 1のバーガー長
     ll num = (1LL << n) - 1; // n - 1のパティ数
     if (x == 1) return 0;
     else if (x <= len + 1) return rec(n - 1, x - 1);
     else if (x == len + 2) return num + 1;
     else if (x <= (len + 1) * 2) return num + 1 + rec(n - 1, x - len - 2);
     else return num * 2 + 1;
 }

 int main() {
     int N; ll X;
     cin >> N >> X;
     cout << rec(N, X) << endl;
 }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int N, M;
    string s;
    map<string, int> m;
    m.insert({"?", 0});
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> s;
        if(m.count(s) == 0) m.insert({s, 1});
        else m.at(s) ++;
    }
    cin >> M;
    for(int i=0; i<M; i++){
        cin >> s;
        if(m.count(s) != 0) m.at(s)--;
    }
    int ans = 0;
    auto itr = m.begin();
    while(itr != m.end()){
        ans = max(ans, itr -> second);
        ++itr;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    if (n % 2 != 0) n*= 2;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    max_n = 10**5
    fac, inv = [1]*(max_n+1), [0]*(max_n+1)
    for i in range(2, max_n+1):
        fac[i] = fac[i-1] * i % mod
    inv[-1] = pow(fac[-1], mod-2, mod)
    for i in range(max_n, 0, -1):
        inv[i-1] = inv[i] * i % mod

    def ncr(n, r):
        return fac[n]*inv[r]*inv[n-r]%mod

    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()

    res_max,res_min = 0, 0
    for i in range(k-1, n):
        temp = ncr(i, k-1)
        res_max += a[i]*temp
        res_min += a[-(i+1)]*temp

    print((res_max - res_min)%mod)

if __name__ == '__main__':
    main()

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll   = long long;
using Edge = vector<vector<pair<int, int>>>; // src -> dst, weight

void graph_bfs(int          vertex,
               const Edge&  edge,
               vector<int>& vertex_label) {
    REP(i, edge[vertex].size()) {
        int dst    = edge[vertex][i].first;
        int weight = edge[vertex][i].second;
        if(vertex_label[dst] < 0) {
            vertex_label[dst] = (weight % 2 == 0) ? vertex_label[vertex] : abs(vertex_label[vertex] - 1);
            graph_bfs(dst, edge, vertex_label);
        }
    }
    return;
}

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

    int N;
    std::cin >> N;

    Edge        edge(N);
    vector<int> vertex_label(N, -1);

    REP(i, N - 1) {
        int u, v, w;
        std::cin >> u >> v >> w;
        edge[u - 1].emplace_back(v - 1, w);
        edge[v - 1].emplace_back(u - 1, w);
    }

    vertex_label[0] = 0;
    graph_bfs(0, edge, vertex_label);

    REP(i, N) {
        std::cout << vertex_label[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 8192
#include<stdio.h>
int main(void){
	
	int n,i,j,jump,cnt=0;
	scanf("%d",&n);
	
	int A[n];
	
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	
	
	for(j=0;j<n-1;j++){
		for(i=n-1;i>j;i--){
			if(A[i]<A[i-1]){
				jump=A[i];
				A[i]=A[i-1];
				A[i-1]=jump;
				cnt++;
				
			}
		}
	}
	
	for(i=0;i<n-1;i++){
		printf("%d ",A[i]);
	}
	printf("%d\n",A[i]);
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "POSSIBLE" : "IMPOSSIBLE")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
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;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n;
	ll k;
	bool ans;
	ll gcd;
	ll up = 0LL;
	cin >> n >> k;
	ll a;
	rep(i, n) {
		cin >> a;
		if (i == 0) {
			gcd = a;
			up  = a;
		}
		gcd = __gcd(gcd, a);
		chmax(up, a);
	}
	ans = (up >= k) and (k % gcd == 0);
	cout << solve(ans) << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S; cin >> S;
    int cntW = 0, cntR = 0;
    rep(i, N) {
        if(S[i] == 'R') cntR++;
        else cntW++; 
    }
    int ans = cntR;
    int cntW2 = 0, cntR2 = 0;
    rep(i, N) {
        if(S[i] == 'W') cntW--;
        else cntR--;
        if(S[i] == 'W') cntW2++;
        else cntR2++;
        ans = min(ans, max(cntR, cntW2));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>
int main(void){
  int n,k,l[50],i,j,tmp,sum=0;
  //入力
  scanf("%d %d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  //処理 配列lを降順にソートして上澄みのK個を足し合わせるだけ
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(l[i]<l[j]){
        tmp=l[i];
        l[i]=l[j];
        l[j]=tmp;
      }
    }
  }
  for(i=0;i<k;i++)sum+=l[i];
  printf("%d",sum);

  return 0;
}

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

#include <atcoder/fenwicktree>
using namespace atcoder;

void solve(int N, int Q, vector<int> a, vector<int> t, vector<int> l, vector<int> r) {
    fenwick_tree<long long> fw(N);
    for (int i = 0; i < N; i++) {
        fw.add(i, a[i]);
    }
    for (int i = 0; i < Q; i++) {
        if (t[i] == 0) {
            fw.add(l[i], r[i]);
        } else {
            cout << fw.sum(l[i], r[i]) << endl;
        }
    }
}


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    // Failed to predict input format
    int N, Q;
    cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    vector<int> t(Q), l(Q), r(Q);
    for (int i = 0; i < Q; i++) {
        cin >> t[i] >> l[i] >> r[i];
    }
    solve(N, Q, a, t, l, r);
    return 0;
}


Measured memory_bytes: 23908
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;

int main()
{
	long long a[100000],i;
	long long num=0;
	i=1;
	while(num<=1000000000){
		num+=i;
		a[i]=num;
		i++;
	}
	int sum=i;
	int x;
	scanf("%d",&x);
	for(i=1;i<=sum;i++){
		if(x<=a[i]){
			printf("%d\n",i);
			break;
		}
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const lli mod=1e9+7;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define printli(n) printf("%lld\n",n)
#define all(vi) (vi.begin(),vi.end())
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
#define MAX 200005
lli sumf[MAX];
lli sumr[MAX];
lli a[MAX];

int main() {
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++) cin>>a[i];
	
	for(int i=1;i<=n;i++){
	    sumf[i]=sumf[i-1]+a[i];
	}
	
	for(int i=n;i>=1;i--){
	    sumr[i]=sumr[i+1]+a[i];
	}
	
	lli ans=10000000000;
	
	for(int i=1;i<=n-1;i++){
	    ans=min(ans,abs(sumf[i]-sumr[i+1]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<stack>
#define ll long long
using namespace std;
const int mn = 15;
int n;
char s[mn];
ll ans;
void dfs(ll sum, ll wait, int p)
{
	if(p > n)
	{
		ans += sum + wait;
		return;
	}
	wait *= 10, wait += s[p] - '0';
	for(int i = p + 1; i <= n + 1; ++i)
	{
		dfs(sum + wait, 0, i);
		if(i <= n)
			wait *= 10, wait += s[i] - '0';
	}
}
int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	dfs(0, 0, 1);
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;

void main() {
    long mod = 1_000_000_007;
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    bool[] ok = true.repeat(n+2).array;
    foreach (i; 0 .. m) {
        int a = readln.chomp.to!int;
        ok[a+1] = false;
    }
    long[] dp = new long[n+2];
    dp[1] = 1;
    foreach (i; 2 .. n+2) {
        if (ok[i]) dp[i] = (dp[i-1] + dp[i-2]) % mod;
    }
    dp[n+1].writeln;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n;
  cin >> n;

  string s = to_string(n);

  string ans = "No";
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '7') {
      ans = "Yes";
      break;
    }
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3704
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;

int main(){
    string s;
    string t1="";
    string t2="";
    int d1=0;
    int d2=0;
    cin >> s;

    REP(i, s.length()){
        t1 += to_string(i%2);
        t2 += to_string((i+1)%2);
    }

    REP(i, s.length()){
        if(t1[i] != s[i])d1++;
        if(t2[i] != s[i])d2++;
    }

    cout << min(d1, d2) << endl;
}

Measured memory_bytes: 832
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[100100];
bool used[100100];

int main(void){
	ll t,s=0ll,ans=0ll,n=0ll,m,i,p=0ll;
	std::cin >> t >> a[0] >> m;
	while(true){
		used[a[n]] = true;
		a[n+1] = (a[n]*a[n])%m;
		++n;
		if(used[a[n]]){
			break;
		}
	}
	while(a[p]!=a[n]){
		ans += a[p];
		--t; ++p;
		if(!t){
			std::cout << ans << std::endl;
			return 0;
		}
	}
	for(i=p; i<n; ++i){
		s += a[i];
	}
	ans += s*(t/(n-p));
	t %= (n-p);
	for(i=0; i<t; ++i){
		ans += a[p+i];
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii> tri;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

struct UF{
  vi v;
  void vset(int n){
    v.clear();
    FOR(i, 0, n) v.pb(i);
  }
  UF(int n){
    vset(n);
  }
  bool merge(int a, int b){
    int _a = find(a), _b=find(b);
    if(_a == _b) return false;
    if(_a > _b) swap(_a, _b);
    v[_b] = _a;
    return true;
  }
  int find(int a){
    int _a = v[a];
    if(a == _a)return a;
    _a = find(_a);
    v[a] = _a;
    return _a;
  }
  bool same(int a, int b){
    return (find(a) == find(b));
  }
};

int N;
pii x[100005], xy[2][100005];
tri z[200005];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  UF uf = UF(N);
  FOR(i, 0, N){
    int a, b;
    cin >> a >> b;
    xy[0][i] = pii(a, i);
    xy[1][i] = pii(b, i);
  }
  int iz=0;
  FOR(i, 0, 2){
    sort(xy[i], xy[i] + N);
    FOR(j, 1, N){
      z[iz] = tri(xy[i][j].first - xy[i][j-1].first, pii(xy[i][j].second, xy[i][j-1].second));
      iz++;
    }
  }
  sort(z, z+iz);
  ll ans = 0;
  FOR(i, 0, iz){
    if(uf.merge(z[i].second.first, z[i].second.second)) ans += z[i].first;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4856
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <cmath>
#define P 100003
#define N 100000
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	string s = "Christmas";
	int d;
	cin >> d;
	for (int i = 0; i < 25-d; ++i){
		s += " Eve";
	}

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	string s; cin >> s;
	int n = s.size();
	int k; cin >> k;
	vi a(n);
	rep(i,n) a[i] = s[i] - 'a';
	vi add(n);
	rep(i,n) add[i] = (26-a[i])%26;
	rep(i,n){
		if(k<add[i])continue;
		a[i] += add[i];
		a[i] %= 26;
		k -= add[i];
	}
 	
	for(int i=n-1; i>=0; i--){
		if(a[i]==0)continue;
		a[i] += k;
		a[i] %= 26;
		k = 0;
		break;
	}
	if(k>0){
		a[n-1] += k;
		a[n-1] %= 26;
		k = 0;
	}
	
	rep(i,n) printf("%c",'a'+a[i]);
	cout << endl;
}




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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2;

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

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

char a[N];

int cnt[N];

int main() {
	FREOPEN();
	int n;
	cin >> n;
	scanf("\n");
	for (int i = 1; i <= n; i++) scanf("%c", &a[i]);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int p = 1;
		for (int j = 'a'; j <= 'z'; j++) {
			if (char(j) == a[i]) continue;
			p = (p * 1ll * (cnt[j] + 1)) % MOD;
		}
		ans = (ans + p) % MOD;
		cnt[(int)a[i]]++;
	}
	printf("%d", ans);
	return 0;
}


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

int main() {
	int x,y;
	cin >> x >> y;
	/* total animals x */
	/* a turu b kame */
	/* a + b  = x;  a * 2 + b * 4 = y */
	int legs  = 0;
	int a,b;
	bool ans = false;
	for (int i = 0; i <= x; i++) {
		a = i;
		b = x - i;
		if (y == a * 2 + b * 4) {
			ans = true;
			break;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3596