akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <queue>
#include <sstream>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)

using namespace std;

typedef long long ll;

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

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main(void) {
	int n, m;
	pair<int, int> ab[100000];

	scanf("%d%d", &n, &m);
	REP(i, n) { scanf("%d%d", &ab[i].second, &ab[i].first); }

	sort(ab, ab + n, [](auto&& a, auto&& b) { return a.second < b.second; });

	int w = 0;
	int result = 0;
	priority_queue<pair<int, int>> pq;
	REP(i, m) {
		while(ab[w].second == i + 1) {
			pq.push(ab[w]);
			w++;
		}

		if(!pq.empty()) {
			auto today = pq.top();
			pq.pop();
			result += today.first;
		}
	}

	printf("%d\n", result);

	return 0;
}


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

int main() {
    int N, A[110];
    cin >> N;

    for (int i = 0; i < N; i++) cin >> A[i];

    int box[110] = {0,};
    for (int i = 0; i < N; i++) {
        box[A[i]]++;
    }
    int res = 0;
    for (int i = 0; i < 110; i++) {
        if (box[i]) ++res;

    }

    cout << res << endl;

    return 0;

                                                                                                                                                      
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
b1 = []
b2 = []
for i in range(n):
    if i % 2 == 0:
        b1.append(a[i])
    else:
        b2.append(a[i])
if n % 2 == 0:
    b2.reverse()
    b = b2 + b1
else:
    b1.reverse()
    b = b1 + b2
    
print(' '.join(map(str, b)))
      

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;

	int n, k; cin >> n >> k;
	mk(a, n + 1, int);
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	int dp[n + 1][k + 1];
	int pre[n + 1][k + 1];

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= k; j++) {
			if (j == 0) {
				dp[i][j] = 1;
				pre[i][j] = 1;
			}

			else if (i == 0) {
				dp[i][j] = 0;
				pre[i][j] = 1;
			}

			else {
				dp[i][j] = pre[i - 1][j];
				if (j - a[i] - 1 >= 0)
					dp[i][j] -= pre[i - 1][j - a[i] - 1];

				dp[i][j] += mod;
				dp[i][j] %= mod;
				pre[i][j] = (pre[i][j - 1] + dp[i][j]) % mod;
			}
		}
	}

	cout << dp[n][k] << endl;

	return 0;
}

Measured memory_bytes: 161316
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,HP=pin()
    weapon=[tupin() for _ in range(N)]
    weapon.sort(key=lambda x:x[0])
    a=weapon[-1][0]
    ans=0
    weapon.sort(key=lambda x:x[1],reverse=True)
    for w in weapon:
        if w[1]>a:
            HP-=w[1];ans+=1
            if HP<=0:break
    if HP>0:
        ans+=((HP-1)//a)+1
    print(ans)
#%%submit!
resolve()

Measured memory_bytes: 59356
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

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

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

template<typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, M;
    string S, T;
    cin >> N >> M >> S >> T;

    auto solve = [&]() {
        ll L = LCM(N, M);
        int n = L / N;
        int m = L / M;
        for (int ni = 0, mi = 0; ni < N &&mi < M; ni += m, mi += n) {
            if (S[ni] != T[mi])return -1LL;
        }
        return L;
    };

    cout << solve() << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	string s; cin >> s;
	string ans = "";
	rep(i, s.size()) {
		if (s[i] == '0') ans += "0";
		else if (s[i] == '1') ans += "1";
		else if (ans.size() > 0 && s[i] == 'B') ans.erase(ans.end()-1);
	}
	cout << ans << endl;
}


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

using namespace std;

int main(){
	int k, s;
	cin >> k >> s;

	int total_ways = 0;
	for(int i=0;i<=k;++i){
		for(int j = 0;j<=k;++j){
		    int miss = s-i-j;
		    if(miss <= k && miss >= 0)total_ways++;
		}
	}

	cout << total_ways << endl;
	return 0;
}

Measured memory_bytes: 256
#不十分だった
n, m = map(int, input().split())
l_max, r_min = 0, 10**5 + 1
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)

print(max(r_min - l_max + 1, 0))

Measured memory_bytes: 43736
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;
string S;
int cntW[200001] ={};

signed main(){
    cin >> N >> S;
    rep(i, N){
        cntW[i+1] = cntW[i];
        if(S[i] == 'R') cntW[i+1]++;
    }
    
    int ans = INT_MAX;
    rep(i, N+1){
        int lR = i-cntW[i];
        int rW = cntW[N]-cntW[i];
        ans = min(ans, max(lR, rW));
    }
    cout << ans << endl;
}

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

int main(){
    int q;cin >> q;
    int l[q],r[q],s[100010];
    for (int i = 0; i < q; ++i)
    {
        cin >> l[i] >> r[i];
    }

    int ch[100010];

    for (int i = 0; i < 100005; ++i)
    {
        ch[i] = 1;
    }
    for (int i = 2; i*i <= 100005; ++i)
    {   
        if (ch[i]==0)continue;
        int flag=1;
        for (int j = 2; j*j <=i; ++j)
        {
            if(i%j==0){flag=0;break;}
        }
        if(!flag)break;
        int k=2;
        while(i*k<=100005){
            ch[i*k] = 0;
            k++;
        }
    }
    ch[0]=0;ch[1]=0;ch[2]=0;ch[3] = 1;s[0]=0;s[1]=0;s[2]=0;s[3]=1;s[4]=1;
    for (int i = 5; i < 100005; ++i)
    {
        if(ch[i]==1&&ch[(i+1)/2]==1) s[i] = s[i-1]+ 1;
        else s[i] = s[i-1];
    }

    for (int i = 0; i < q; ++i)
    {
        cout << s[r[i]]-s[l[i]-1] <<endl;

    }


    return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    string s;
    cin >> s;
    set<char> st;
    for (auto c : s) {
        st.insert(c);
    }
    cout << (st.size() == s.size() ? "yes" : "no") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	int n;
	cin >> n;
	vector<int> c(n-1),s(n-1),f(n-1);
	REP(i,n-1) cin >> c[i] >> s[i] >> f[i];
	
	vector<int> ans(n-1);
	
	for(int i=n-2; i>=0; i--){
		ans[i] = s[i] + c[i];
		for(int j=i+1; j<n-1; j++){
			if(ans[i] >= s[j]){
				if(ans[i]%f[j]==0){
					ans[i] += c[j];
				}else{
					ans[i] += f[j]-ans[i]%f[j];
					ans[i] += c[j];
				}
			}else{
				ans[i] = ans[j];
				break;
			}
		}
	}
	
	REP(i,n-1) cout << ans[i] << endl;
	cout << 0 << endl;
	
	return 0;
}

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

using namespace std;

int main()
{
    string S;
    
    cin >> S;
    
    if(S == "ABC")
    {
        cout << "ARC";
    }
    else if(S == "ARC")
    {
        cout << "ABC";
    }
    
}

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


int main(){
	int n,k;
	cin>>n>>k;
	vector<int> t(n);
	for(int i=0;i<n;i++)cin>>t[i];
	vector<int> d;
	int sum = t[n-1]-t[0]+1;
	for(int i=0;i<n-1;i++)d.push_back(t[i+1]-t[i]-1);
	sort(d.begin(),d.end());
	for(int i=0;i<k-1;i++)sum-=d[n-2-i];
	cout<<sum<<endl;


	return 0;
}



Measured memory_bytes: 3912
// Author: πα

#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long

const int N = 105;
int arr[N];

int main()
{
    IOS;
    int n, i, color = N;
    cin >> n;
    for(i = 0; i < n; i++)
        cin >> arr[i];
    for(i = 0; i < n - 1; i++)
    {
        if(arr[i] == arr[i+1])
            arr[i+1] = color++;
    }
    cout << color - N;
    return 0;
}


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

int main(){
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(),a.end());
    int res = 0;
    int i;
    for(i = 0; (i < N) && (x >= a[i]); i++){
        x -= a[i];
        res++;
    }
    if (i == N && x != 0) cout << res - 1 << endl;
    else cout << res  << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const LL mod = 998244353;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        vector<LL> A(n); LL sum = 0;
        FOR(i,0,n) {
            cin >> A[i]; sum += A[i];
        }
        vector<LL> dp[2];
        dp[0] = dp[1] = vector<LL>(sum+1); dp[0][0] = dp[1][0] = 1;
        FOR(i,0,n) FORR(j,sum,A[i]-1) {
            dp[0][j] += dp[0][j-A[i]]*2;
            dp[0][j] %= mod;
            dp[1][j] += dp[1][j-A[i]];
            dp[1][j] %= mod;
        }
        LL ans = 1;
        FOR(i,0,n) {
            ans *= 3; ans %= mod;
        }
        FOR(i,0,sum/2+1) {
            ans -= 3*dp[0][i]; ans %= mod;
        }
        if (sum%2 == 0) {
            ans += 3*dp[1][sum/2]; ans %= mod;
        }
        ans += mod; ans %= mod;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}
int main() {
	long long int n, m, num[2000][2] = {}, result=0;
	char str[200005];
	scanf("%s",str);
  	n=strlen(str);
	for (int i = 0; i <n; i+=2) {
		printf("%c", str[i]);
	}
			
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll N; cin >> N;
  vector<ll> a(N), inv(N+1);
  REP(i,N) {
    cin >> a[i];
    inv[a[i]] = i;
  }
  multiset<ll> st;
  REP(_,2) st.insert(-1);
  REP(_,2) st.insert(N);
  ll ans = 0;
  IFOR(i,1,N+1){
    st.insert(inv[i]);
    auto it = st.lower_bound(inv[i]);
    ans += i * (
        (inv[i] - *prev(it)) * (*next(it,2) - *next(it))
        + (*prev(it) - *prev(it,2)) * (*next(it) - inv[i])
    );
  }
  cout << ans << endl;
}


Measured memory_bytes: 6528
#include <stdio.h>

const int MOD = 1000000007;

int main(void)
{
  int N;
  long long int K;
  scanf("%d %lld", &N, &K);
  int A[N];
  for (int i = 0; i < N; i++)
    scanf("%d", &A[i]);
  int n1 = 0;
  int n2 = 0;
  for (int i = 0; i < N; i++) {
      int Ai = A[i];
      for (int j = 0; j < i; j++)
          if(Ai > A[j])
              n1++;
      for (int j = i+1; j < N; j++)
          if(Ai > A[j])
              n2++;
  }
  long long int num = K*(K-1)/2%MOD*n1+K*(K+1)/2%MOD*n2;
  printf("%lld\n", num%MOD);
  return 0;
}


Measured memory_bytes: 128
n=int(input())

lim_keta=len(str(n))

def dfs(keta,num):
  if int(num)<=n and len(set(num))==3:
    global cnt
    cnt+=1

  if keta==lim_keta:
    return

  for i in '753':
    dfs(keta+1,num+i)

cnt=0
for i in '753':
  dfs(1,i)

print(cnt)

Measured memory_bytes: 9192
#include <cstdio>
#include <list>

using namespace std;

struct Flagment {
	int file;
	int loc, len;

	Flagment(int f, int lo, int le) : file(f), loc(lo), len(le) {}
};

typedef list<Flagment>::iterator iter_t;

int main() {
	while (true) {
		int N;

		scanf("%d", &N);
		if (N == 0) break;

		list<Flagment> files;
		files.push_back(Flagment(-1, 0, 1000000001));

		for (int i = 0; i < N; i++) {
			char c[2];
			scanf("%s", c);

			if (c[0] == 'R') {
				int loc;
				int found = 0;
				scanf("%d", &loc);


				for (iter_t it = files.begin(); it != files.end(); ++it) {
					Flagment &flag = *it;
					if (flag.loc <= loc && loc < flag.loc + flag.len) {
						printf("%d\n", flag.file);
					} 
				}
			}
			if (c[0] == 'W') {
				int file, len;
				scanf("%d%d", &file, &len);

				for (iter_t it = files.begin(); it != files.end(); ++it) {
					Flagment &flag = *it;
					if (flag.file != -1) continue;

					flag.file = file;
					if (flag.len <= len) {
						len -= flag.len;
						if (len == 0) break;
					} else {
						files.insert(++it, Flagment(-1, flag.loc + len, flag.len - len));
						flag.len = len;
						len = 0;
						break;
					}
				}
			}
			if (c[0] == 'D') {
				int file;
				scanf("%d", &file);

				for (iter_t it = files.begin(); it != files.end(); ++it) {
					Flagment &flag = *it;
					if (flag.file == file) flag.file = -1;
				}
			}
		}

		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(true){
            int m = s.nextInt(); int f = s.nextInt(); int r = s.nextInt();
            if(m==-1 && f==-1 && r == -1){ break;}
            if(m==-1 || f==-1){
                System.out.println("F");
            }else if(m+f>=80){ 
                System.out.println("A");
            }else if(m+f>=65){
                System.out.println("B");
            }else if(m+f>=50){
                System.out.println("C");
            }else if(m+f>=30 && r>=50){
                System.out.println("C");
            }else if(m+f>=30){
                System.out.println("D");
            }else{
                System.out.println("F");
            }
        }
        s.close();
    }
}


Measured memory_bytes: 26164
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	char S[1000];
	scanf("%s", S);
	int len = strlen(S);
	S[len - 8] = 0;
	printf("%s\n", S);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
long p=1,q;
int N,M,X;
void solve(){
  if(M<=5){
    for(int i=0;i<M;i++){
      p=p*2;
    }
    q=(1900*M+(N-M)*100)*p;
    printf("%ld\n",q);
  } else if(M>5){
    q=(1900*5+100*(N-5))*32;
    printf("%ld\n",q);
  }
}
int main(){
  scanf("%d %d",&N,&M);
  solve();
  return 0;
}


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

int main() {
	int n, k;
	cin>>n>>k;
	int c=0;
	while(n--){
		int x;
		cin>>x;
		c+=min(x,k-x);
	}
	c*=2;
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define int long long

signed main(){
	int A, B, C, K;
	scanf("%lld%lld%lld%lld", &A, &B, &C, &K);
	if(K % 2 == 0){
		printf("%lld\n", A - B);
	}
	else{
		printf("%lld\n", B - A);
	}
	return 0;
}

Measured memory_bytes: 128
input = gets.chomp.scan(/.{1,#{2}}/).map(&:to_i)
if input[0] > 12 then
  a = 1
else
  if input[0] == 0 then
    a = 1
  else
    a = 0
  end
end
if input[1] > 12 then
  b = 1
else
  if input[1] == 0 then
    b = 1
  else
    b = 0
  end
end
if a == 1 then
  if b == 1 then
    print "NA"
  else
    print "YYMM"
  end
else
  if b == 1 then
    print "MMYY"
  else
    print "AMBIGUOUS"
  end
end

Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
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 ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  vector<int>c(n);
  map<int,int>ma;
  map<int,int>mb;
  map<int,int>mc;
  rep(i,n) cin >> a[i] >> b[i] >> c[i];
  rep(i,n){
    ma[a[i]]++;
    mb[b[i]]++;
    mc[c[i]]++;
  }
  rep(i,n){
    int ans=0;
    if(ma[a[i]]==1)ans+=a[i];
    if(mb[b[i]]==1)ans+=b[i];
    if(mc[c[i]]==1)ans+=c[i];
    cout << ans << endl;
  }
    
}



Measured memory_bytes: 3192
def main():
    N = int(input())
    S = list(map(int, input().split()))
    INF = float('inf')
    n = 2 ** N + 1

    S.sort()

    parents = [S[-1]]
    S[-1] = INF

    for _ in range(N):
        checking = 2
        parents.sort(reverse=True)
        for i in parents[:]:
            while True:
                if S[-checking] < i:
                    parents.append(S[-checking])
                    S[-checking] = INF
                    break
                else:
                    checking += 1
                if checking == n:
                    print('No')
                    exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Measured memory_bytes: 34404
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int n = s.length();
    int a = s.indexOf("A");
    int b = s.indexOf("C");
    int c = s.lastIndexOf("C");
    String w = "AC";
    if(a==0){
      if(b==c && b>=2 && b<=(n-2)){
        for(int i=1; i<n; i++){
          if(i!=b){
            int d = s.codePointAt(i);
            if(d>=65 && d<=90){
              w = "WA";
            }
          }
        }
      }
      else{
        w="WA";
      }
    }
    else{
      w = "WA";
    }
    System.out.println(w);
  }
}


Measured memory_bytes: 25044
n, d = map(int, input().split())
count = 0
l = []

for _ in range(n):
  x = list(map(int, input().split()))
  l.append(x)
    
for i in range(n-1):
  for j in range(i+1,n):
    k = 0
    for a,b in zip(l[i], l[j]):
      k += (a-b)**2
    if (k**0.5).is_integer():
      count += 1

print(count)
    

Measured memory_bytes: 62580
n = int(input())
days_ls = [0] * n
for i in range(n):
    days_ls[i] = list(map(int, input().split()))

dp = [[0]*3 for _ in range(n)]
dp[0] = days_ls[0]
for i in range(1,n):
    dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + days_ls[i][0]
    dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + days_ls[i][1]
    dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + days_ls[i][2]
print(max(dp[-1]))

Measured memory_bytes: 101288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, M; cin >> N >> M;
    ll cake[N][3];
    for(int i=0; i<N; i++) cin >> cake[i][0] >> cake[i][1] >> cake[i][2];

    ll ans = 0LL;
    for(int bit=0; bit<(1<<3); bit++){
        vector<ll> ctr(N ,0);
        for(int i=0; i<N; i++){
            for(int j=0; j<3; j++){
                if((bit&1<<j)) ctr[i] += cake[i][j];
                else ctr[i] -= cake[i][j];
            }
        }

        sort(ctr.begin(), ctr.end(), greater<ll>());
        ll tmp = 0L;
        for(int i=0; i<M; i++) tmp += ctr[i];
        ans = max(ans, tmp);
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <functional>
#include <unordered_set>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

const int N = 101 + 1;
const int K = 1e5 + 1;
const int MOD = 1e9 + 7;

int a[N];
int dp[N][K];
int prefsum[N][K];

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

int getsum(int row, int l, int r) {
	if (l == 0)
		return prefsum[row][r];
	return sub(prefsum[row][r], prefsum[row][l - 1]);
}

void add(int& a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int plus(int a, int b) {
	add(a, b);
	return a;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		prefsum[i][0] = dp[i][0];
		for (int j = 1; j <= k; ++j) {
			prefsum[i][j] = prefsum[i][j - 1];
			add(prefsum[i][j], dp[i][j]);
		}
		for (int j = 0; j <= k; ++j) {
			int l = max(0, j - a[i]);
			int r = j;
			dp[i + 1][j] = getsum(i, l, r);
		}
	}
	int answer = 0;
	cout << dp[n][k] << "\n";

	return 0;
}

Measured memory_bytes: 79616
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
int main()
{
    string a;
    while(cin>>a){

        int ans=inf;
        for(char i='a';i<='z';i++){
            string w=a;
            for(int j=1; ;j++){

                int sum=0;
                for(int r=0;r<w.sz;r++){
                    if(w[r]==i)
                        sum++;
                }
                if(sum==w.sz){
                    ans=min(ans,j-1);
                }
                string tmp="";
                for(int r=0;r<w.sz-1;r++){
                    if(w[r]==i||w[r+1]==i){
                        tmp+=i;
                    }
                    else{
                        tmp+=w[r];
                    }
                }
                w=tmp;
                if(w=="")
                    bk;
            }
        }
        cout<<ans<<endl;







    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   RFOR(i,n,0)

using namespace std;

int main(){
	int H, W;
	char s[52][52];
	REP(i, 52){
		REP(j, 52){
			s[i][j] = '.';
		}
	}
	scanf("%d %d", &H, &W);
	FOR(i, 1, H){
		scanf("%s", s[i]);
	}
	bool f = true;
	REP(i, H){
		REP(j, W){
			if (s[i][j] == '#'){
				if (s[i - 1][j] != '#'&&s[i][j - 1] != '#'&&s[i + 1][j] != '#'&&s[i][j + 1] != '#'){
					f = false;
				}
			}
		}
	}
	if (f){
		printf("Yes\n");
	}
	else{ printf("No\n"); }

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,k,sum=0;
    cin>>n;
    cin>>k;
    int arr[n];
    for(i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    for(i=0;i<k;i++)
    sum+=arr[i];
    cout<<sum;


}

Measured memory_bytes: 3620
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

map<int,int>cnt;

 main()

{
    fast
    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    int sum=0;
    int ses=0;
    int ten=1;
    if(p==2 || p==5)
    {

         f(i,0,n-1)
         {
             if((s[i]-'0')%p==0)
             {
                 ses+=(n-i);
             }
         }
        cout<<ses<<endl;
        return 0;
    }
    cnt[0]++;
    f(i,0,n-1)
    {
        int val=(s[i]-'0')*ten;
        val=val%p;
        sum=(sum+val)%p;
        if(sum<0)sum+=p;
        sum=sum%p;
        cnt[sum]++;
        ten=(ten*10)%p;
    }
   for(auto x:cnt)
   {
       int yo=x.si;
       int val=(yo*(yo-1))/2;
       ses+=val;
   }
    cout<<ses<<endl;
    return 0;

}














Measured memory_bytes: 1044
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

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

int main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	int M=min(B,D),m=max(A,C);
	if(M-m>0)cout<<M-m;
	else cout<<0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX=1e5+10;
void solve(int n,int *a){
    int num=0,cnt[MAX],ans=0,odd=0,even=0;
    for(int i=1,j=0;i<=n;i++){
        if(a[i]!=a[j]||i==n){
            cnt[num]=i-j;
            j=i;
            if(cnt[num]&1)
                odd++;
            else
                even++;
            num++;
        }
    }
    ans=num;
    if(even&1)
        ans--;
    cout<<ans<<endl;
}
int main(){
    int n,a[MAX];
    while(cin>>n){
        for(int i=0;i<n;i++) scanf("%d",&a[i]);
        sort(a,a+n);
        solve(n,a);
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int N, M;
int h, w;
string maze[100];
int a[100][100];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1};

int bfs(int sx, int sy, int gx, int gy) {
	Fill(a, INF);
	queue<P> que;
	que.push(P(sx, sy));
	a[sy][sx] = 0;
 
	while(que.size()) {
		P p = que.front();
		que.pop();
		
		rep(i, 4) {
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];
			if(0 <= nx && nx < w && 0 <= ny && ny < h) {
				if(a[ny][nx] == INF && maze[ny][nx] != '#') {
					a[ny][nx] = a[p.second][p.first] + 1;
					que.push(P(nx, ny));
				}
			}
		}
	}
	return a[gy][gx];
}

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

	cin >> h >> w;
	rep(i, h) cin >> maze[i];

	int ans = 0;

	rep(i1, h) {
		rep(j1, w) {
			if(maze[i1][j1] == '#') continue;
			rep(i2, h) {
				rep(j2, w) {
					if(maze[i2][j2] == '#') continue;
					int now = bfs(j1, i1, j2, i2);
					//cout << now << endl;
					if(now != INF) chmax(ans, now);
				}
			}
		}
	}

	cout << ans << endl;

	//cout << bfs(0, 0, 2, 2) << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(){
  int field[6][6]={0};
  string s;
  for(int i=0; i<5; i++){
    cin >>s;
    for(int j=0; j<4; j++){
      if(s[j] == '1'){
	field[j+1][i]+=4;
	field[j+1][i+1]+=1;
      }
    }
    if(i<4){
      cin >>s;
      for(int j=0; j<5; j++){
	if(s[j] == '1'){
	  field[j][i+1]+=2;
	  field[j+1][i+1]+=8;
	}
      }
    }
  }
  int px = 1,py=0,d=2;
  for(int i=0;; i++){
    if(d == 1){
      if(!(field[px][py]&2)){px++;d = 2;}
      else{
	if(field[px][py]&1){cout <<"U";d = 8;}
	else{cout <<"U";py--;}
      }
    }
    else if(d == 2){
      if(!(field[px][py]&4)){py++;d = 4;}
      else{
	if(field[px][py]&2){cout <<"R";d = 1;}
	else{cout <<"R";px++;}
      }
    }
    else if(d == 4){
      if(!(field[px][py]&8)){px--;d = 8;}
      else{
	if(field[px][py]&4){cout <<"D";d = 2;}
	else if(field[px][py]&8){cout <<"D";py++;}
      }
    }
    else if(d == 8){
      if(!(field[px][py]&1)){py--;d = 1;}
      else{
	if(field[px][py]&8){cout <<"L";d = 4;}
	else{cout <<"L";px--;}
      }
    }
    if(px == 1 && py == 0){cout <<endl; break;}
  }
  return 0;
}

Measured memory_bytes: 1176
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    if(a==b&&b==c){
      System.out.println("No");
    }else if(a!=b&&b!=c&&c!=a){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}

Measured memory_bytes: 22480
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    int a = k * x;
    int b = n - k;
    int c = b * y;

    if(n <= k) {
      System.out.println(n * x);
    }else {
      System.out.println(a+c);
    }
  }
}


Measured memory_bytes: 8788
#include<bits/stdc++.h>
#define cases long long test;cin>>test;while(test--)
#define f_io ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
#define INF 1000000000
using namespace std;

int main()
{
    f_io;
    vector<ll> primes(1000001);
    foi(2,1000001)
    {
        if(!primes[i])
        {
            primes[i] = 1;
            ll j=i*2;
            while(j<1000001)
            {
                primes[j] = i;
                j+=i;
            }
        }
    }
    ll n,ans=0;
    cin >> n;
    foi(1,n)
    {
        ll num=1,tmp=i;
        map<ll,ll> mp;
        while(tmp>1 and primes[tmp]>1)
        {
            ll x = primes[tmp];
            while(tmp%x==0)
            {
                mp[x]++;
                tmp/=x;
            }   
        }
        if(tmp>1)
            mp[tmp]++;
        for(auto x:mp)
        {
            num*=(x.second+1);
        }
        ans+=num;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 11056
#include "bits/stdc++.h"
using namespace std;

int main(){
    string s;
    cin >> s;
    int n = s.size()+1;
    vector<int> a(n);
    int last = 0;
    a[0] = 0;
    for(int i = 0; i < n-1; i++){
        if(s[i] == '<'){
            last++;
            a[i+1] = last;
        }else{
            last = 0;
        }
    }
    last = 0;

    for(int i = n-2; i >= 0; i--){
        if(s[i] == '>'){
            last++;
            a[i] = max(a[i], last);
        }else{
            last = 0;
        }
    }
    long long ans = 0;
    for(int i = 0; i < n; i++) ans += a[i];
    
    cout << ans << endl;
}

Measured memory_bytes: 2820
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()

    var min = Integer.MAX_VALUE
    for (i in 1..n/2) {
        val j = n - i
        val sum = cal(i) + cal(j)
        if (sum < min) min = sum
    }

    println(min)
}

fun cal(num: Int): Int {
    var ans = 0
    var tmp = num
    while(tmp > 0) {
        ans += tmp % 10
        tmp /= 10
    }
    return ans
}

Measured memory_bytes: 31652
package main

import "fmt"

const (
	BNUM = 4
	FNUM = 3
	RNUM = 10
)

func main() {
	var (
		rooms         [BNUM][FNUM][RNUM]int
		n, b, f, r, v int
	)
	fmt.Scanln(&n)
	for ; n > 0; n-- {
		fmt.Scanln(&b, &f, &r, &v)
		rooms[b-1][f-1][r-1] += v
	}
	for b := 0; b < BNUM; b++ {
		for f := 0; f < FNUM; f++ {
			for r := 0; r < RNUM; r++ {
				fmt.Printf(" %d", rooms[b][f][r])
			}
			fmt.Println("")
		}
		if b < BNUM-1 {
			for s := 0; s < 20; s++ {
				fmt.Print("#")
			}
			fmt.Println("")
		}
	}
}


Measured memory_bytes: 1168
#include<iostream>
#include<set>
#include<fstream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)
#define esta(x,v) (find((v).begin(),(v).end(),(x)) !=  (v).end())
#define index(x,v) (find((v).begin(),(v).end(),(x)) - (v).begin())
#define debug(x) cout << #x << " = "  << x << endl
#define pb push_back
#define mp make_pair

typedef long long tint;
typedef unsigned long long utint;
typedef long double ldouble;

typedef vector<int> vint;


int main (){
	int a, b, n;
	set<int> s;
	forn(i, 3){
		int p;
		cin>>p;
		s.insert(p);
	}
	cout<<s.size()<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <cstring>
using namespace std;

#define M 1000000000
int mycount = 0;

struct card {
    char mark;
    int num;
};

void merge(card *A, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int i, j;

    card L[n1+1], R[n2+1];

    for(i=0; i<n1; i++) {
        L[i] = A[left+i];
    }
    for(i=0; i<n2; i++) {
        R[i] = A[mid+i];
    }

    L[n1].num = M;
    R[n2].num = M;
    i = 0;
    j = 0;

    for(int k=left; k<right; k++) {
        mycount++;
        if(L[i].num<=R[j].num) {
            A[k] = L[i];
            i++;
        }
        else {
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(card *A, int left, int right) {
    if(left+1<right) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int _partition(card *A, int p, int r) {
    int x = A[r].num;
    int i = p-1;
    for(int j=p; j<r; j++) {
        if(A[j].num<=x) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i+1], A[r]);
    return i+1;
}

void quickSort(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);
    }
}

int main() {
    int n;
    int stable = 1;

    cin >> n;
    card A[n], B[n];

    for(int i=0; i<n; i++) {
        cin >> A[i].mark;
        cin >> A[i].num;
        B[i].mark = A[i].mark;
        B[i].num = A[i].num;
    }

    mergeSort(A, 0, n);
    quickSort(B, 0, n-1);

    for(int i=0; i<n; i++) {
        if(A[i].mark!=B[i].mark) {
            stable = 0;
        }
    }
    if(stable==1) {
        cout << "Stable\n";
    }
    else {
        cout << "Not stable\n";
    }
    for(int i=0; i<n; i++) {
        cout << B[i].mark << " " << B[i].num << endl;
    }

    return 0;
}


Measured memory_bytes: 5420
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
using namespace std;
int main(){
     int X;
     cin >> X;
     int a,b = 0;
     a = (X / 500) * 1000;
     b = ((X % 500) / 5) * 5;
     cout << a + b << endl;
     return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    count = 0
    N, D = [int(x) for x in input().split(" ")]

    for _ in range(N):
        x, y = [int(x) for x in input().split(" ")]
        if x ** 2 + y ** 2 <= D ** 2:
            count += 1
    print(count)


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

int main() {
  int N,K;
  cin>>N>>K;
  int ans=0;
  if(N==K) ans=1;
  else ans=(N-1+K-2)/(K-1);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256