akhauriyash/Code-Regression huggingface dataset:
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define dbg(x) cerr << #x << " is " << x << endl;
//#define F(i,b) for(int i = 0 ; i < (int)(b) ; i++)
#define RF(j,b) for(int j = (int)(b)-1 ; j >= 0 ; j--)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 2e5+7 ;
const int INF = 1e9 ;
const int MOD = INF + 7 ;
string s ;
int dp[52][52][3025] ;

void solve(){
	int n , avg ;
	cin >> n >> avg ;
	vector<int> a(n) ;
	for(auto& x : a) cin >> x ;
	dp[0][0][0] =1 ;
		
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j <= i ; j++){
			for(int k = 0 ; k < 2505 ; k++){
				dp[i+1][j][k] += dp[i][j][k] ;
				dp[i+1][j+1][k+a[i]] += dp[i][j][k] ;
			}
		}
	}	
	int ans = 0 ;
	for(int i = 1 ; i <= n ; i++){
		ans += dp[n][i][avg*i] ;
	}

	cout << ans << endl ;
}

int32_t main(){
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}

}


Measured memory_bytes: 61696
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# 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;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	setIO();
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int l, r;
		cin >> l >> r;
		if(l > r) swap(l, r);
		g[r].pb(l);
	}

	ll ans = 0;
	ll sum = 0;
	for (int i = 1; i <= n; ++i) {
		for (auto it : g[i]) {
			sum += it;
		}
		ans += i * (ll)(i+1)/2ll - sum;
	}
	cout << ans << '\n';

	return Accepted;
}

// B...a

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

int main(void){
    int a[3], five=0, seven=0;
    rep(i, 3) cin >> a[i];

    rep(i, 3) {
        if(a[i] == 5) five++;
        if(a[i] == 7) seven++;
    }
    
    if(five==2 && seven==1) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
let readCharArray _ = stdin.ReadLine().ToCharArray()
let choice ok ng bool = if bool then ok else ng

readCharArray ()
|> Array.sort
|> System.String
|> fun x ->
    readCharArray ()
    |> Array.sortDescending
    |> System.String
    |> ((<) x)
    |> choice "Yes" "No"
    |> printfn "%s"


Measured memory_bytes: 29728
#include<cstdio>
#include<iostream>
#include<sstream>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<climits>
#include<functional>

#include<memory.h>

#define ll long long

using namespace std;


int main()
{
	int N(0);
	while (cin >> N) {
		set<int> nums;
		for (int i = 0; i < N; ++i) {
			int num;
			cin >> num;
			if (nums.count(num) == 0) {
				nums.insert(num);
			}
			else {
				nums.erase(num);
			}
		}
		cout << nums.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n, 0);
    vector<int> near(n, 0), index(n, 0);

    for (int i = 0; i < n; ++i) cin >> a[i];

    reverse(a.begin(), a.end());
    for (int i = 0; i < n; ++i) {
        index[a[i]] = i;
    }

    set<int> st;
    st.insert(-1);
    st.insert(n);

    for (int v = 1; v <= n; ++v) {
        auto itr = st.lower_bound(index[v]);
        itr--;
        near[index[v]] = *itr;
        st.insert(index[v]);
    }

    vector<ll> dp(n, 0);
    for (int i = 0; i < n; ++i) {
        int j = near[i];
        if (j == -1) dp[i] = a[i] * (i + 1);
        else dp[i] = a[i] * (i - j) + dp[j];
    }

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += dp[i];
    }

    cout << ans << endl;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

const int maxN = 1e5;
int n;
int a[maxN + 1];
int baCnt[maxN + 1];
int b[maxN + 1];
int bcCnt[maxN + 1];
int c[maxN + 1];

signed main() {
  n = read();
  REP(i, n) { a[i] = read(); }
  REP(i, n) { b[i] = read(); }
  REP(i, n) { c[i] = read(); }
  sort(a, a + n);
  sort(b, b + n);
  sort(c, c + n);
  REP(i, n) {
    baCnt[i] = lower_bound(a, a + n, b[i]) - a;
    bcCnt[i] = (c + n) - upper_bound(c, c + n, b[i]);
  }
  int ans = 0;
  REP(i, n) { ans += baCnt[i] * bcCnt[i]; }
  print(ans);
}


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

using namespace std;
int main()
{
    int n,i,c=0;

    cin>>n;
    int a[n],b[n];
    for(i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a,a+n);
    for(i=0;i<n;i++){
        if(a[i]!=b[i]){
            c++;
        }
    }
    if(c<=2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>


int max(int i, int j){
  if(i <= j) return j;
  return i;
}

int main(){

long N, kk=0;
long K[10000];
int ans=0;

scanf("%ld", &N);
for(int i=0; i< N; i++){
  scanf("%ld", &K[i]);
}

for(int j=0; j<N;j++){
  kk = max(K[j], kk);
}

for(int j=0;j<N;j++){
    if(kk == K[j]){
      K[j] /=2;
      goto AAA;
    }
}

AAA: ;

for(int k=0;k<N;k++){
  ans += K[k];
}

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w; cin >> h >> w;
    vector<string> s(h); rep (i, h) cin >> s[i];
    vector<int> ri(h), rj(w);
    rep (i, h) {
        bool ok = true;
        rep (j, w) if (s[i][j] == '#') ok = false;
        ri[i] = ok;
    }
    rep (j, w) {
        bool ok = true;
        rep (i, h) if (s[i][j] == '#') ok = false;
        rj[j] = ok;
    }
    rep (i, h) { 
        rep (j, w) {
        if (!ri[i] && !rj[j]) cout << s[i][j];
        }
        if (!ri[i]) cout << "\n";
    }
    return 0;
}

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

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);
        }
        
        static void SolveA(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] szarr = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for(int i = 0; i < a.Length; ++i)
            {
                a[i] = int.Parse(szarr[i]);
            }
            int q = int.Parse(Console.ReadLine());
            szarr = Console.ReadLine().Split(' ');
            int[] m = new int[q];
            for (int i = 0; i < m.Length; ++i)
            {
                m[i] = int.Parse(szarr[i]);
            }

            for(int i=0;i<m.Length;++i)
            {
                string szResult = Solve(0, m[i], n, a) ? "yes" : "no";
                Console.WriteLine(szResult);
            }
        }
        private static bool Solve(int i, int m, int n, int[] a)
        {
            if( m == 0)
            {
                return true;
            }
            if( i >= n)
                {
                return false;
            }
            bool res = Solve(i +1, m, n, a) || Solve(i + 1, m - a[i], n, a);
            return res;
        }
    }

}



Measured memory_bytes: 8976
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    vector<int> t(n), a(n);
    rep(i, n) {
        cin >> t[i];
    }
    rep(i, n) {
        cin >> a[i];
    }

    vector<int> v(n);
    int now = 0;  // 現時点での最大値
    rep(i, n) {
        if(now < t[i]) {  // 最大値が変化したとき v[i] = t[i] が確定
            v[i] = t[i];
            now = t[i];
        }
    }

    now = 0;
    for(int i = n-1; i >= 0; i--) {
        if(v[i] == 0) {  // v[i]が未確定のときはt(n)と同様
            if(now < a[i]) {
                v[i] = a[i];
                now = a[i];
            }
        }
        else {  // v[i]が確定しているとき
            if(now < a[i] && v[i] != a[i]) {  // 最大値が変化するとv[i] = a[i]が確定するがa[i] != v[i]だと矛盾
                cout << 0 << endl;
                return 0;
            }
            else if(a[i] < v[i]) {  // 最大値はv[i]以上なのでa[i] < v[i]は矛盾
                cout << 0 << endl;
                return 0;
            }
            else if(now < v[i]) {
                now = v[i];
            }
        }
    }

    vector<ll> x(n);  // x[i] : v[i] = 0 のマスに書き込める数の種類(v[i] != 0 のときは0)
    now = v[0];
    rep(i, n) {
        if(now < v[i]) {
            now = v[i];
        }
        if(v[i] == 0) {
            x[i] = (ll)now;
        }
    }

    now = v[n-1];
    for(int i = n-1; i >= 0; i--) {
        if(now < v[i]) {
            now = v[i];
        }
        if(v[i] == 0) {
            x[i] = min(x[i], (ll)now);
        }
    }

    ll ans = 1LL;
    rep(i, n) {
        if(x[i] > 0) {
            ans *= x[i];
            ans %= mod;
        }
    }

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

Measured memory_bytes: 2176
#include<iostream>

using namespace std;

int main(){
	int a,b,c;

	cin >> a >> b >> c;
	
	if(a >= c){
		cout << c << endl;
		return 0;
	}

	if((a+b)%60 == 0){
		cout << -1 << endl;
		return 0;
	}

	int t;
	if(c <= a + b) t = c + 60;
	else t = c;

	int i = 0;
	while(t % (a+b) > a){
		t += 60;
		i++;
		if(i > 60){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << t << endl;

	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

const double g=10.0,eps=1e-12;
const int N=200000+10,maxn=200000+10,inf=0x3f3f3f3f;

int a[N];
map<int,int>m;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        m[a[i]]++;
    }
    int ans=0;
    for(auto x:m)
    {
        if(x.fi<=x.se) ans+=x.se-x.fi;
        else ans+=x.se;
    }
    printf("%d\n",ans);
    return 0;
}
/********************

********************/


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

#define ll              long long
#define Ull             unsigned long long
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);

const int N = 2;
const ll MOD = 1e9 + 7;


/*bool comp(const pii &p1, const pii &p2)
{

}*/


void Solve()
{

	double a, b, h, m;
	cin >> a >> b >> h >> m;
	if (h == 12) h = 0;
	if (m == 60) m = 0;

	// Calculate the angles moved
	// by hour and minute hands
	// with reference to 12:00
	double hour_angle = 0.5 * (h * 60 + m);
	double minute_angle = 6 * m;

	// Find the difference between two angles
	double angle = abs(hour_angle - minute_angle);

	// Return the smaller angle of two possible angles
	angle = min(360 - angle, angle);
	double pi = 3.14159265358979323846264338327;
	double p = (angle * pi) / 180;


	double ans = ((a * a + b * b) - (2 * a * b * cos(p)));
	ans = sqrt(ans);
	cout << fixed << setprecision(20) << ans << "\n";


}


int main()
{

	FastRead;
	int T = 1;
	//cin>>T;
	while (T--)
	{
		Solve();
	}

	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

bool hargyaddo(int n)
{
    int s = 0, ck = n;
    while (ck)
    {
        s += ck % 10;
        ck /= 10;
    }

    return n % s == 0;
}

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

    cout << (hargyaddo(n) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
arr.forEach(function(value){
   var vd=value.split(" ").map(Number);
   var v=vd[0];
   var d=vd[1];
   var f=[];
   f[0]=1;
   f[1]=2;
   for(var i=2;i<=v;i++){
      f[i]=(f[i - 1] + f[i - 2])%1001;
   }
   f.shift();
   f.sort(function(a,b){return a-b});
   var cnt=0;
   for(var i=1;i<f.length;i++){
         if(f[i]-f[i-1]<d)cnt++;
   }
   console.log(f.length-cnt);
});

Measured memory_bytes: 17016
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
#include<fstream>
using namespace std;
typedef long long LL;

int main(void)
{
	string s;
	cin >>s;
	sort(s.begin(),s.end());
	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
		cout <<"Yes"<<endl;

	}
	else {
		cout <<"No"<<endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include<cstdio>

const int MAXN=(4*1e5)+5;
int a[MAXN],n;


int main()
{
	scanf("%d",&n);
	int l=2*1e5+2,r=2*1e5+2;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(i==1){
			a[l]=x;
			l--;
			r++;
			continue;
		}
		if(i%2==n%2){//加到前面 
			a[l]=x;
			l--;
		}
		else{//加到后面 
			a[r]=x;
			r++;
		} 
	}
	for(int i=l+1;i<=r-1;i++){
		printf("%d ",a[i]);
	}
	return 0;
}	 


Measured memory_bytes: 2816
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
typedef long long ll;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define Rep(i,n) REP(i,0,n)
ll longinf=1ll<<60;

ll n,p[101],m[101][101];
int main(){
    cin>>n;
    Rep(i,n){
        cin>>p[i]>>p[i+1];
    }
    REP(i,1,n+1) m[i][i]=0;
    REP(l,2,n+1){
        REP(i,1,n-l+2){
            int j=i+l-1;
            m[i][j]=longinf;
            REP(k,i,j+1){
                m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }
    cout<<m[1][n]<<endl;
    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)cout<<c<<endl;
    else if(a==c)cout<<b<<endl;
    else cout<<a<<endl;
}

Measured memory_bytes: 256
MOD=10**9+7
S=input()

dp=[]
for i in range(len(S)+1):
  dp.append([0,0,0,0])
  
dp[-1][3]=1
for i in reversed(range(len(S))):
  if S[i]=="?":
    m1=3
  else:
    m1=1        
  dp[i][3]=m1*dp[i+1][3]
  dp[i][3]%=MOD
  
  for j in range(3):
    if S[i]=="?":
      m2=1
    else:
      if S[i]==["A","B","C"][j]:
        m2=1
      else:
        m2=0    
    dp[i][j]=m1*dp[i+1][j]+m2*dp[i+1][j+1]
    dp[i][j]%=MOD
    
print(dp[0][0])

Measured memory_bytes: 27600
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N,K;
  cin >>N>>K;

  int a=1,sum=0;
  for(int i=0;i<N;i++){ 
    a*=2;
  
    if(K<a/2){
      break;
    }
    sum++;
  }
  if(a/2<=K){
    cout<<a<<endl;
  }
  else{
    
  
   cout<<a/2+(N-sum)*K<<endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] ss0 = br.readLine().trim().split(" ", 0);
		int N = Integer.parseInt(ss0[0]);
		int M = Integer.parseInt(ss0[1]);
		
		int[] city = new int[N];
		for(int i = 0; i < M; i++){
			ss0 = br.readLine().trim().split(" ", 0);
			city[Integer.parseInt(ss0[0])-1] += 1;
			city[Integer.parseInt(ss0[1])-1] += 1;
		}

		StringBuilder sb = new StringBuilder();
		for(int i: city) {
			sb.append(i);
			sb.append(System.getProperty("line.separator"));
		}



        System.out.println(sb);
        return;
    }


}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	vector<int> X(N);
	vector<int> Y(N);
	vector<int> XX(N);
	vector<int> YY(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
	}
	set<int>st;
	map<int, int> mp;
	map<int, int> mpX;
	map<int, int> mpY;
	int c = 0;
	for (int i = 0; i < N; i++) {
		st.insert(X[i]);
	}
	c = 0;
	for (int s: st) {
		mp[s] = c;
		mpX[c] = s;
		c++;
	}
	for (int i = 0; i < N; i++) {
		XX[i] = mp[X[i]];
	}
	mp.clear();
	st.clear();
	for (int i = 0; i < N; i++) {
		st.insert(Y[i]);
	}
	c = 0;
	for (int s : st) {
		mp[s] = c;
		mpY[c] = s;
		c++;
	}
	for (int i = 0; i < N; i++) {
		YY[i] = mp[Y[i]];
	}
	for (int i = 0; i < N; i++) {
		cerr << XX[i] << " " << YY[i] << endl;
	}
	vector<vector<pair<int, int> > > vv(N, vector<pair<int, int> >(N));
	vector<vector<int> > sum(N + 1, vector<int>(N + 1, 0));
	for (int i = 0; i < N; i++) {
		sum[XX[i] + 1][YY[i] + 1] = 1;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			sum[i][j] += -sum[i - 1][j - 1] + sum[i][j - 1] + sum[i - 1][j];
			cerr << sum[i][j] << " ";
		}
		cerr << endl;
	}
	res = (int)1 << 62;
	for (int x1 = 0; x1 < mpX.size(); x1++) {
		for (int y1 = 0; y1 < mpY.size(); y1++) {
			for (int x2 = x1; x2 < mpX.size(); x2++) {
				for (int y2 = y1; y2 < mpY.size(); y2++) {
					if (sum[x2+1][y2+1] + sum[x1][y1] - sum[x2+1][y1] - sum[x1][y2+1] >= K) {
						//cerr << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
						res = min(res, (mpX[x2] - mpX[x1])*(mpY[y2] - mpY[y1]));
					}
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
#define Max(a,b) a>b?a:b
#define Min(a,b) a<b?a:b

using namespace std;
template<typename T>inline void read(T &x)
{
	T s=0,f=1;static char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())s=s*10+(c^48);
	x=s*f;
}
const int MAXN=2e5+7;

static int n;

static long long w[MAXN];

static map<long long,int>G;

static long long ans;

inline void init()
{
	read(n);
	G[0]=1;
	Rep(i,1,n)
	{
		read(w[i]);
		w[i]+=w[i-1];
		if(!G[w[i]])G[w[i]]=1;
		else ++G[w[i]];
		ans+=G[w[i]]-1;
	}
	printf("%lld\n",ans);
}

inline void solve()
{
}

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



Measured memory_bytes: 14336
#include<cstdio>
int main() {
    int n, x;
    scanf("%d %d", &n, &x);
    int l[111];
    for (int i = 0; i < n; ++i)
        scanf("%d", &l[i]);
    int ans = 1;
    int d = 0;
    for (int i = 0; i < n; ++i)
    {
        d += l[i];
        if (d <= x) ans++;
    }
    printf("%d\n", ans);
}


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

string divide[4]={"dream","dreamer","erase","eraser"};

int main(){
    string S;
    cin >> S;
    reverse(S.begin(),S.end());
    for(int i=0; i<4; ++i) reverse(divide[i].begin(),divide[i].end());

    bool can = true;
    for (int i=0; i< S.size();){
        bool can2 = false;
        for (int j=0; j<4; ++j){
            string d = divide[j];
            if(S.substr(i,d.size()) == d){
                can2 =true;
                i += d.size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout <<"YES"<<endl;
    else cout <<"NO"<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    ll N; cin >> N;
    string S; cin >> S;
    vector<ll> E(N), W(N);
    for(int i = 0; i < N; i++) if(S[i] == 'E') E[i]++;
    for(int i = 1; i < N; i++) E[i] = E[i]+E[i-1];
    for(int i = 0; i < N; i++) if(S[i] == 'W') W[i]++;
    for(int i = 1; i < N; i++) W[i] = W[i]+W[i-1];

    ll ans = 1e9;
    for(int i = 0; i < N; i++){
        ll cnt = 0;
        if(S[i] == 'E'){
            if(i-1 >= 0) cnt += W[i-1];
            cnt += E[N-1]-E[i];
        }
        else{
            if(i-1 >= 0) cnt += W[i-1];
            cnt += E[N-1]-E[i];
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;

}

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

int main(){
    vector<int> a(12);
    for(int i=0; i<12; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    bool yes = true;
    for(int i=0; i<3; i++){
        for(int j=1; j<4; j++){
            if(a[4*i +j] != a[4*i]){
                yes = false;
            }
        }
    }
    if(yes){
        cout << "yes" << endl;
    }else{
        cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
/*input

*/
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 

using namespace std;
long long mod=1e9+7;
long long INF=1e7;
typedef long long int lld;
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define popcount __builtin_popcountll
typedef pair<lld,lld> PA;
#define lim 200010
#define lim2 4023
#define qqqqqq 210
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

lld B[lim],A[lim],C[lim];
// PA P[lim],Q[lim];
lld n,m,p,q;
// string S[lim],R[lim];
map<PA,lld> M;
vector<lld> V[lim];
// unordered_map<lld,lld> Ind;


lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}

bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}

lld solve(lld n, lld x){
    lld sum=0,t=x;
    while(n/t>0){
        sum+=n/t;
        t*=x;
    }
    return sum+1;
}

int main(){
    lld T,i,p,j,l,r,b,k,c,a,d,w,x,y,v,z,t,curr,prev,sum,ans,pos,val,countA,secondMin,indicator;
    sc(n);
    sc2(a,b);
    rep(i,1,n) sc(A[i]);
    ans=0;
    rep(i,2,n){
        if((A[i]-A[i-1])*a < b) ans+=(A[i]-A[i-1])*a;
        else ans+=b;
    }
    prL(ans);
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
int main()
{
	int a, b, c, n = 0, m = 0;
	char t;
	while (std::cin >> a >> t >> b >> t >> c)
	{
		if (a*a + b*b == c*c) n++;
		if (a == b) m++;
	}
	std::cout << n << '\n' << m << '\n';
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];

    vector<int> diff(n);
    for(int i = 0; i < n - 1; i++) {
        if(h[i] >= h[i + 1]) diff[i] = 1;
    }

    vector<int> sum(n);
    for(int i = n - 2; i >= 0; i--) {
        if(diff[i] > 0) sum[i] = sum[i + 1] + diff[i];
        else sum[i] = 0;
    }

    int num = 0;
    for(int i = 0; i < n; i++) {
        if(sum[i] > num) num = sum[i];
    }

    cout << num << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long

int n,x;
vint B(51),P(51);

int rec(int nn,int xx){
  if(nn == 0){
    return 1;
  }
  else if(xx <= 1){
    return 0;
  }
  else if(xx <= 1 + B[nn-1]){
    return rec(nn-1,xx-1);
  }
  else if(xx == 2 + B[nn-1]){
    return P[nn-1] + 1;
  }
  else if(xx <= 2 + 2*B[nn-1]){
    return P[nn-1] + 1 + rec(nn-1,xx-2-B[nn-1]);
  }
  else{
    return 2*P[nn-1] + 1;
  }
}

signed main(){
  cin >> n >> x;
  B[0] = 1;
  P[0] = 1;
  rep1(i,n){
    B[i] = B[i-1]*2 + 3;
    P[i] = P[i-1]*2 + 1;
  }
  cout << rec(n,x) << endl;
  //rep(i,n) cout << B[i] << endl;
}

Measured memory_bytes: 256
from collections import Counter
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]

cnt=Counter(a)

ans=['No' if k-q<=0 else 'Yes']*(n+1)

for key,value in cnt.items():
    if k-q+value>0:
        ans[key]='Yes'

for i in range(1,n+1):
    print(ans[i])

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

int n;
int main() {
    cin >> n;
    int ans = 0;
    
    if (n == 1)
        ans = 0;
    if (n&1)
        ans = (n-1)/2;
    else 
        ans = n/2-1;
    cout << ans << "\n";
    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,ll md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    ll h,n,x=0,y;
    cin>>h>>n;
    f(i,0,n){
        cin>>y;x+=y;
    }
    if(x>=h)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();

		if (X >= 30) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27068
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 2e5 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, m, c[N];
vector < int > g[N];
bool used[N], fail;

void dfs(int v, int col) {
  c[v] = col;
  used[v] = 1;
  for (auto to : g[v]) {
    if (used[to]) {
      if (col == c[to]) fail = 1;
    } else dfs(to, col ^ 1);
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 1;i <= m;i++) {
    int a, b; cin >> a >> b;
    g[a].pb(b);
    g[b].pb(a);
  }
  int x = 0, y = 0, z = 0;
  for (int i = 1;i <= n;i++) {
    if (used[i]) continue;
    if (g[i].size() == 0) {
      z++;
      continue;
    }
    fail = 0;
    dfs(i, 0);
    if (!fail) x++;
    else y++;
  }
//  cout << x << " " << y << " " << z << endl;
  ll ans = 1ll * x * x * 2 + 1ll * 2 * x * y + 1ll * y * y;
  ans += 1ll * z * z;
  ans += 2ll * (n - z) * z;
  cout << ans << endl;
}

int main() {
  srand(time(0));
  #ifdef wws
   freopen("in", "r", stdin);
   //freopen("out", "w", stdout);
  #endif 
  //ios_base::sync_with_stdio(0);
  int tt = 1;
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 12416
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();

		int count = 0;
		boolean saisyo = true;
		for (int i = 0; i < n; i++) {
			int add = scan.nextInt();
			list.add(add);
			if(list.get(i)%2==1) {
				saisyo=false;
				break;
			}
		}

			if(saisyo==false) {
				System.out.println(0);
			}else {

				for(int i=0;;i++) {
					//if(saisyo==true) {
					int temp=list.get(i);
					if(temp%2==0) {
					temp = temp/2;
					list.add(temp);
					}else {

						//saisyo=false;
						break;
				}



			}

				count=list.size()/n-1;
				//System.out.println(list);
				System.out.println(count);

			}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int N, i, j;
unsigned long long X;

unsigned long long layer[51]; //layer[i]:レベルiバーガーの厚さ
unsigned long long p[51];
unsigned long long b[51];
unsigned long long dp[51][51]; //dp[N][X]:レベルNバーガーの下からX層に含まれるパティの総数

unsigned long long solve (int N, unsigned long long X) {
    if (X == layer[N]) {
        return p[N];
    } else if (X > layer[N-1] + 2) {
        return solve(N-1, X - layer[N-1] - 2) + p[N-1] + 1;
    } else if (X == layer[N-1] + 2) {
        return p[N-1] + 1;
    } else if (X >= 2 && X < layer[N-1] + 2) {
        return solve(N-1, X-1);
    } else {
        return 0;
    }
}

int main(void) {
    cin >> N >> X;
    
    layer[0] = 1;
    p[0] = 1;
    b[0] = 0;
    //レベルNまでのバーガーの厚さを調べる
    for (i=1; i<=N; i++) {
        p[i] = p[i-1] * 2 + 1;
        b[i] = b[i-1] * 2 + 2;
        layer[i] = p[i] + b[i];
    }
    
    unsigned long long ans = solve(N, X);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
import 'dart:io';

void main(){
  List<String> inputStrList = stdin.readLineSync().split(' ');
  int a = int.parse(inputStrList[0]);
  int b = int.parse(inputStrList[1]);
  int n = int.parse(inputStrList[2]);

  if(b <= n){
    print((a * (b - 1) / b).floor() - a * ((b - 1) / b).floor());
  }else{
    print((a * n / b).floor() - a * (n / b).floor());
  }
}

Measured memory_bytes: 13100
import itertools

N = int(input())

count = 0
for n in range(3, 10):
    for p in itertools.product(['3', '5', '7'], repeat=n):
        pstr = ''.join(p)
        if len(set(pstr)) < 3 or int(pstr) > N:
            continue
        count += 1
print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> P;
  tools::read(P, N);

  i64 min = std::numeric_limits<i64>::max();
  i64 answer = 0;
  for (const i64& P_i : P) {
    if (P_i < min) {
      min = P_i;
      ++answer;
    }
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int m[100001];
long long n,a,b,s=0;
void print()
{
	cout<<s;
}
void search(int t)
{
	if((m[t]-m[t-1])*a<b) s+=(m[t]-m[t-1])*a;
	else s+=b;
	if(t==n) print();
	else search(t+1);
}
int main()
{
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		cin>>m[i];
	}
	m[0]=m[1];
	search(1);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int r, D, this_year;
  cin >> r >> D >> this_year;
  
  int cnt = 10;
  int next_year;
  while(cnt--) {
  	next_year = r * this_year - D;
    cout << next_year << endl;
    this_year = next_year;
  }
  return 0;
}


Measured memory_bytes: 3544
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

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

  int cnt = 0;
  for (int c = 1; c < n; c++) {
    for (int a = 1; a * a <= n - c; a++) {
      if ((n - c) % a == 0) {
        if (a * a == n - c) {
          cnt++;
        } else {
          cnt += 2;
        }
      }
    }
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
  int h,w;
  cin >> h >> w;

  vector<string> grid(h);
  for(int i = 0;i < h;i++){
    cin >> grid[i];
  }

  int ans = 0;
  for(int i = 0;i < w;i++){
    for(int j = 0;j < h;j++){
      int sx = i;
      int sy = j;

      if(grid[sy][sx] == '.'){
        queue<pair<int,pair<int,int>>> que;
        
        int dist[20][20];
        for(int k = 0;k < h;k++){
          for(int l = 0;l < w;l++){
            dist[k][l] = -1;
          }
        }

        que.push(make_pair(0,make_pair(sy,sx)));
        dist[sy][sx] = 0;
        while(que.size()){
          pair<int,pair<int,int>> now = que.front();
          que.pop();

          int d = now.first;
          int now_y = now.second.first;
          int now_x = now.second.second;
          ans = max(ans,d);

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

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

            if(0 <= nx && nx < w && 0 <= ny && ny < h && dist[ny][nx] == -1 && grid[ny][nx] == '.'){
              que.push(make_pair(d+1,make_pair(ny,nx)));
              dist[ny][nx] = d+1;
            }
          }
        }
      }
    }
  }

  cout << ans << endl;
}

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

using namespace std;

int main() {
    int n, debt = 100000;

    cin >> n;

    for(int i = 0;i < n;i++){
        debt *= 1.05;
        if(debt % 1000 != 0){
            debt += 1000;
        }
         debt -= (debt % 1000);
    }

    cout << debt << endl; 

    return 0;
}

Measured memory_bytes: 3076
(let ((n (read))
      (s (concatenate 'list (read-line)))
      (lst '(0))
      (x 0))

  (loop for i in s
        if (char= i #\I) do (push (incf x) lst)
        else do (push (decf x) lst))

  (format t "~A~%"
          (apply #'max lst)))


Measured memory_bytes: 4072
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>

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

int main() {
    int l, r, d;
    cin >> l >> r >> d;

    while (l % d != 0)l++;
    while (r % d != 0)r--;
    int ans = (r-l)/d + 1;
    cout << ans << endl;
    

}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
string s;

int main(){
	cin >> s;
	
	if(s[0]=='9' or s[1]=='9') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n, d;
    cin >> d >> n;
    if(d == 0) {
        if(n == 100) cout << 101 << endl;
        else cout << n << endl;
    }
    else if(d == 1) {
        if(n == 100) cout << 10100 << endl;
        else cout << n * 100 << endl;
    }
    else {
        if(n == 100) cout << 1010000 << endl;
        else cout << n * 10000 << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1, s2;
    string s3;
    int p;
    cin >> s1 >> s2;
    s3 = s1 + s2;
    p = stoi(s3);
    int sq = sqrt(p);
    if((sq * sq) == p)
    {
        cout << "Yes"<< endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

   

}

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

int main(){
  int N;
  cin >> N;
  
  int64_t a;
  
  vector<int> v;
  for(int i=0; i<3*N; i++){
    cin >> a;
    v.push_back(a);
  }
  
  sort(v.begin(),v.end());
  reverse(v.begin(), v.end());
  
  int64_t sum =0;
  for(int i=1;i<2*N; i+=2){
    sum += v.at(i);
  }
  
  cout << sum << endl;
 
}


Measured memory_bytes: 5320