akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
#define all(cont) cont.begin(), cont.end()
#define unique(a)  sort(all(a)) , (a).erase(unique((a).begin(), (a).end()),(a).end())
#define rall(cont) cont.rbegin(), cont.rend()
#define sz(x) (int)(x).size()
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PB push_back
#define endl "\n"
#define f first
#define s second
#define mset(m,v) memset(m,v,sizeof(m))
#define mod 1000000007
const int N = 2e5 + 5, INF = 1E9 + 7;
#define PI acos(-1.0)
long double EPS = 1e-9;
typedef long long ll;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
#define pqll_max priority_queue<ll> // max heap. push(),pop(),top(),size(),empty()
#define pqll_min priority_queue<ll,vector<ll>,greater<ll> >
#define lb(v,val)   lower_bound(v.begin(),v.end(),val) //first equal to or lower than [------------
#define ub(v,val)   upper_bound(v.begin(),v.end(),val) //first greater than ------------)
#define bs(v,x) binary_search(v.begin(),v.end(),x)
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x; }
inline ll sub(int x, int y) { x -= y; if (x < 0) x += mod; return x; }
inline ll mul(ll x, ll y) { return (x%mod * 1ll * y%mod) % mod; }
inline ll pwr(ll a, ll b) { ll x = 1 % mod; while (b) { if (b & 1) x = mul(x, a); a = mul(a, a); b >>= 1; }return x % mod; }
inline ll inv(ll a) { return pwr(a, mod - 2) % mod; }
ll gcd(ll a, ll b) { if (!a)return b % mod; return gcd(b%a, a) % mod; }
#define debug(x) cout << #x << " = " << x << endl;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#define in(container) for (auto &it : container) cin>>it;
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
void solve() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i != 0) {
			ans += (n / i);
		}
		else {
			ans += (n / i) - 1;
		}
	}
	cout << ans << endl;
}
signed main()
{
	fastio;
	//cout<<fixed<<setprecision(15);
	//clock_t begin = clock();
	int tc;
	tc = 1;
	//cin >> tc;
	while (tc--) {
		solve();
	}
	//clock_t end = clock();double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC;cerr << elapsed_secs;
}


//Error?
// clear lists for every test case
// print new line for each tc
// check for int or ll
// check if problem can be solved without any heavy DS like priority_queue or map



Measured memory_bytes: 3648
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> 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);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, std::vector<long long> d){
  set<string> ans;
  for (int i = 0; i < N; i++) {
    ans.insert(to_string(d[i]));
  }
  cout << ans.size() << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
}


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

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  auto a = new int[][](2); foreach (i; 0..2) readA(n, a[i]);

  auto r = 0;
  foreach (i; 0..n)
    r = max(r, a[0][0..i+1].sum + a[1][i..$].sum);

  writeln(r);
}


Measured memory_bytes: 380
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]

ans=0
for i in range(len(b)):
    if(b[i]>=a[i]):
        ans+=a[i]
        b[i]-=a[i]
        a[i]=0
    else:
        a[i]-=b[i]
        ans+=b[i]
        b[i]=0
    if(b[i]>=a[i+1]):
        ans+=a[i+1]
        b[i]-=a[i+1]
        a[i+1]=0
    else:
        a[i+1]-=b[i]
        ans+=b[i]
        b[i]=0
print(ans)


Measured memory_bytes: 19648
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
int main() {
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    int a[3], b[3];
    a[0] = 0;
    rep(i, 3) b[i] = c[0][i];
    rrep(i, 1, 3) a[i] = c[i][0] - b[0];
    rrep(i, 1, 3) if (b[i] != c[1][i] - a[1]) {
        cout << "No" << endl;
        return 0;
    }
    rrep(i, 1, 3) if (c[2][i] - a[2] != b[i]) {
        cout << "No" << endl;
        return 0;
    }
    /*
    rep(i, 3) cout << a[i] << " ";
    cout << endl;
    rep(i, 3) cout << b[i] << " ";
    cout << endl;
     */
    cout << "Yes" << endl;
    return 0;
}




Measured memory_bytes: 256
#include <cstdio>

typedef long long LL;
const int Mod = 998244353;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

const int MN = 500005;

int Fac[MN], iFac[MN];

inline void Init(int N) {
	Fac[0] = 1;
	for (int i = 1; i <= N; ++i) Fac[i] = (LL)Fac[i - 1] * i % Mod;
	iFac[N] = qPow(Fac[N], Mod - 2);
	for (int i = N; i >= 1; --i) iFac[i - 1] = (LL)iFac[i] * i % Mod;
}
inline int Binom(int N, int M) {
	if (M < 0 || M > N) return 0;
	return (LL)Fac[N] * iFac[M] % Mod * iFac[N - M] % Mod;
}

int N, K, Ans;

int main() {
	scanf("%d%d", &N, &K);
	if (K < N) return puts("0"), 0;
	Init(K);
	for (int R = 0; R <= K; ++R) {
		int B = K - R;
		if (R < B) continue;
		if (R == B) --B;
		Ans = ((LL)Ans + Binom(R + B, R) - Binom(R + B, 2 * R - N + 1) + Mod) % Mod;
	}
	printf("%d\n", Ans);
	return 0;
}

// Luogu : PinkRabbit

Measured memory_bytes: 4224
def bunsan(n,S): #Sはリスト
    ave = sum(S)/n
    D = 0
    
    for i in range(n):
        D += (S[i] - ave)**2
    return (D/n)**(1/2)

while True:
    n = int(input())
    if n == 0:
        break
    S = list(map(int,input().split()))
    print(bunsan(n,S))


Measured memory_bytes: 5664
#!/usr/bin/env python3
#CODE FESTIVAL 2017 Final A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
lst = ['A','K','I','H','B','R']
for i in range(len(s)):
    if s[i] not in lst:
        print('NO')
        quit()
a = s.count('A')
t = ''
for i in range(len(s)):
    if s[i] != 'A':
        t += s[i]
if 'KIHBR' not in t or a > 4 or 'KIH' not in s:
    print('NO')
    quit()
if t.count('K') != 1 or t.count('I') != 1 or t.count('H') != 1 or t.count('B') != 1 or t.count('R') != 1:
    print('NO')
    quit()
for i in range(len(s)):
    if s[i] == 'K':
        if s[:i].count('A') > 1:
            print('NO')
            quit()
    if s[i] == 'H':
        for j in range(i+1,len(s)):
            if s[j] == 'B':
                if s[i:j].count('A') > 1:
                    print('NO')
                    quit()
    if s[i] == 'B':
        for j in range(i+1,len(s)):
            if s[j] == 'R':
                if s[i:j].count('A') > 1:
                    print('NO')
                    quit()
    if s[i] == 'R':
        if s[i:].count('A') > 1:
            print('NO')
            quit()
print('YES')


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
struct node{
	int x,y;
};
double dis(int xa,int xb,int ya,int yb){
	return sqrt((xa - ya) * (xa - ya) + (xb - yb) * (xb - yb));
}
double G[10][10];
int jc(int n){
	if(n == 1){
		return 1;
	}
	else{
		return n * jc(n-1);
	}
}
node sum[10];
int book[10];
int n;
double zong;
void dfs(int u,double num,int js){
	if(js == n){
		zong += num;
		return ;
	}
	for(int i=1;i<=n;i++){
		if(book[i] == 0){
			book[i] = 1;
			dfs(i,num + G[u][i],js+1);
			book[i] = 0;
		}
	}
}
int main(){
	cin >> n;
	for(int i=1;i<=n;i++){
		scanf("%d %d",&sum[i].x,&sum[i].y);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			G[i][j] = dis(sum[i].x,sum[i].y,sum[j].x,sum[j].y);
		}
	}
	for(int i=1;i<=n;i++){
		book[i]=1;
		dfs(i,0,1);
		book[i]=0;
	}
	//cout << jc(n) << endl;
	double ans1 = zong* 1.0 / jc(n);
	printf("%.10f",ans1);
	return 0;
} 

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

using namespace std;

typedef long long ll;
typedef long double K;
typedef pair<int, int> pii;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

const int inf = 1000000000;

main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int n, m, R;
    cin >> n >> m >> R;

    int r[R];
    for(int i = 0; i < R; i++){
        cin >> r[i];
    }

    int d[n + 1][n + 1];
    memset(d, 0, sizeof(d));

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(i != j)d[i][j] = inf;
        }
    }

    for(int i = 0; i < m; i++){
        int q, w, e;
        cin >> q >> w >> e;
        d[q][w] = min(d[q][w], e);
        d[w][q] = min(d[w][q], e);
    }

    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
            }
        }
    }

    int ans = inf;
    do{
        int res = 0;
        for(int i = 1; i < R; i++){
            res = res + d[r[i - 1]][r[i]];
        }
        ans = min(ans, res);
    }while(next_permutation(r, r + R));

    do{
        int res = 0;
        for(int i = 1; i < R; i++){
            res = res + d[r[i - 1]][r[i]];
        }
        ans = min(ans, res);
    }while(next_permutation(r, r + R));

    cout << ans;
}


Measured memory_bytes: 384
PROGRAM-ID.                      ABC_049_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 c       PIC X(1).

PROCEDURE                        DIVISION.
    ACCEPT c.

    IF c = 'a' OR 'e' OR 'i' OR 'o' OR 'u'
        DISPLAY "vowel"
    ELSE
        DISPLAY "consonant"
    END-IF.

    STOP RUN.


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX 


int main()
{
  ll n,k,mn;
  cin>>n>>k;
  ll a[10000000],b[10000000];
  for(ll i=0;i<n;i++)
    cin>>a[i];
  
  b[0]=0;
  b[1]=abs(a[1]-a[0]);
  
  for(ll p=2;p<n;p++)
  b[p]=inf;
  
  for(ll j=2;j<n;j++)
  {
      ll x=1;
      while(x<=k&&j-x>=0)
      {
        mn=b[j-x]+abs(a[j]-a[j-x]);
        if(mn<b[j])
        b[j]=mn; x++;
      }
  }
  cout<<b[n-1];
  return 0;
  
}

Measured memory_bytes: 7040
N,M = map(int,input().split())
a = [0]*(max(N,M)+1)
a[0] = 1
a[1] = 1
for i in range(2,len(a)):
    a[i] = i * a[i-1] % 1000000007
    
if N==M:
    print(a[N]*a[M]*2 % 1000000007)
elif abs(N-M)==1:
    print(a[N]*a[M] % 1000000007)
else:
    print(0)

Measured memory_bytes: 12760
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
	int n, k;
	int p[1100] = {};
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> p[i];
	sort(p, p + n);
	int ans = 0;
	for (int i = 0; i < k; i++)
		ans += p[i];
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
    int n,w[300],dp[300][300];
    scanf("%d",&n);
    while(n){
        for(int i=0;i<n;i++){
            scanf("%d",&w[i]);
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                dp[i][j]=0;
            }
        }
        for(int k=1;k<n;k++){
            for(int i=0;i+k<n;i++){
                if(dp[i+1][i+k-1]==k-1&&max(w[i],w[i+k])-min(w[i],w[i+k])<=1){
                    dp[i][i+k]=k+1;
                }
                else{
                    for(int j=i;j<i+k;j++){
                        dp[i][i+k]=max(dp[i][i+k],dp[i][j]+dp[j+1][i+k]);
                    }
                }
            }
        }
        printf("%d\n",dp[0][n-1]);
        scanf("%d",&n);
    }
}


Measured memory_bytes: 2960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define loop(i,a,b) for(int i=a; i<b; i++)
#define INF 10000000000099ll
#define mod 1000000007
#define prDouble(x) cout<<fixed<<setprecision(10)<<x

int solve(vector<int> arr, int n, int k)
{
    int dp[k+1]= {0};
    for(int i=1; i<=k; i++){
        for(int j=1; j<=n; j++){
            if(arr[j]>i) continue;
            if(dp[i-arr[j]]==0){
                dp[i]=1;
                break;
            }
        }
    }
    return dp[k];
}

int main()
{
    FASTIO;
    int n,k;
    cin>>n>>k;
    vector<int> arr(n+1);
    loop(i,1, n+1){
        cin>>arr[i];
    }
    solve(arr, n, k)==1 ? cout<<"First" : cout<<"Second";
    return 0;
}




Measured memory_bytes: 4044
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

lli dat[55];

int main(void){
	int n,K;
	scanf("%d%d",&n,&K);
	rep(i,n)scanf("%lld",&dat[i]);
	
	lli ans=0;
	reg(i,-1,n-1){
		reg(j,i+1,n){
			vector<lli> ds;
			lli ns=0;
			rep(t,n){
				if(i<t && t < j)continue;
				ds.push_back(dat[t]);
				ns += dat[t];
			}
			if(ds.size()>K)continue;
			sort(ds.begin(),ds.end());
			rep(t,K-ds.size()){
				if(t>=ds.size() || ds[t]>=0)break;
				ns -= ds[t];
			}
			ans = max(ans,ns);
		}
	}
	printf("%lld\n",ans);
	return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

using ll = long long;

const int limit = 100010;
using edge = struct { int to; ll cost;};
vector<edge>tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.to == p)continue;
		dfs(e.to, v, d + e.cost);
	}
}

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

	for (int i = 0; i < n - 1; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		tree[a].push_back({ b,c });
		tree[b].push_back({ a,c });
	}

	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);
	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		cout << depth[x] + depth[y] << endl;
	}

	return 0;
}

Measured memory_bytes: 14336
K = int(input())
import math
from functools import reduce
G = []
for a in range(1,K+1):
    for b in range(1,K+1):
        g = math.gcd(a,b)
        for c in range(1,K+1):
            gc = math.gcd(g,c)
            G.append(gc)
print(sum(G))

Measured memory_bytes: 71784
S=list(input())
X="".join(S[:2])
Y="".join(S[2:])
X=int(X)
Y=int(Y)
if (X==0 or 12<X) and 1<=Y and Y<=12 :
  print("YYMM")
elif 1<=X and X<=12 and (12<Y or Y==0):
  print("MMYY")
elif 1<=X and X<=12  and 1<=Y and Y<=12 :
  print("AMBIGUOUS")
else :
  print("NA")


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

using namespace std;

int main() {

    int N, A, B, ans=0;
    int p, q, r, s, t;
    cin >> N >> A >> B;

    for(int i = 1; i <= N; i++) {
        p = i/10000;
        q = (i-10000*p)/1000;
        r = (i-10000*p-1000*q)/100;
        s = (i-10000*p-1000*q-100*r)/10;
        t = i-10000*p-1000*q-100*r-10*s;

        if(p+q+r+s+t >= A && p+q+r+s+t <=B) {
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())


if a<b:
    if b<c:
        print(a,b,c)
    else:
     	print(a,c,b)
elif b<c:
    if c<a:
	    print(b,c,a)
    else:
	    print(b,a,c)
elif c<a:
    if a<b:
    	print(c,a,b)
    else:
	    print(c,b,a)




Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000;
const char ENDL = '\n';


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n[3][3];
	rep(i, 3) {
		rep(j, 3)
			cin >> n[i][j];
	}
	
	ll a[3], b[3];
	bool flag;
	rep(i, n[0][0] + 1) {
		flag = true;
		a[0] = i;
		rep(j, 3) {
			b[j] = n[0][j] - a[0];
			if (b[j] < 0) {
				flag = false;
				break;
			}
		}
		if (flag == false) continue;
		rep1(j, 3) {
			a[j] = n[j][0] - b[0];
			if (a[j] < 0) {
				flag = false;
				break;
			}
		}
		if (flag == false) continue;

		rep1(j, 3) {
			rep1(k, 3) {
				if (n[j][k] != a[j] + b[k]) {
					flag = false;
					break;
				}
			}
			if (flag == false) break;
		}
		if (flag == true)
			break;
	}

	if (flag == true)
		cout << "Yes" << ENDL;
	else
		cout << "No" << ENDL;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int n, c, k; cin >> n >> c >> k;
    vector<ll> t(n);
    for (int i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    sort(t.begin(), t.end());
    ll ans = 1;
    ll s = t[0], e = t[0]+k;
    ll now = 1;
    for (int i = 1; i < n; i++)
    {
        // cout << ans << endl;
        if (t[i] <= e) {
            now++;
        } else {
            ans++;
            s = t[i];
            e = t[i]+k;
            now = 1;
        }

        if (now > c) {
            ans++;
            s = t[i];
            e = t[i]+k;
            now = 1;
        }
        // cout << t[i] << ' ' << ans << endl;
    }
    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

const int N = 102;

int v[N], n, x;

int main(){

	scanf("%d %d", &n, &x);

	for(int i = 0; i < n; i++) scanf("%d", v+i);

	sort(v, v+n);

	int ans = 0;
	for(int i = 0; i < n && v[i] <= x; i++){
		ans++;
		x -= v[i];
	}
	printf("%d\n", ans - (ans == n && x > 0));
}


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


signed main(){
	string S;
	cin>>S;
	int N=S.size();
	int a,z;
	a=-1;
	for(int i=0;i<N;i++){
		if(S.at(i)=='A' && a==-1) a=i;
		if(S.at(i)=='Z')z=i;
	}
	cout<<(z-a+1)<<endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int A,B,C;
vector <int > H;





int main()
{

	cin >> A >> B >> C;

	if(A==B){
		cout << C;
	} else if(B==C){
		cout << A;
	} else {
		cout << B;
	}

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();//偶数
			int M = scan.nextInt();//奇数
			
			
			 // 配列の準備o(n*n)なのでｎ~3000くらいが限界
			int s =100;
			int n = s+5;
	        int c[][] = new int [n][n];//n=2000段作りきれるように、少し余裕を持って作成します。

	        //パスカルの三角形作成
	        int mod = 1000000007;// オーバーフロー対策：問題で指定されます。
	        c[0][0]=1;// 初期値として、最上部の1を与えます。
	        for(int i=0;i<s+2;i++) {//2000段作りきるようにループを回します。細かい事を考えないで済むように少し余裕を持たせて回しています。
	            for(int j=0;j<s+2;j++) {
	                long tmp =  c[i][j]%mod;// オーバーフロー対策
	                c[i+1][j]+=tmp;
	                c[i+1][j+1]+=tmp;
	            }
	        }
			
			//偶数から２つか奇数から二つしかない
			int kisuu = 0;
			int guusuu = 0;
			
			if(N==1&&M==1){//存在しない０
				System.out.println(0);
			}else {
				if(N<2) {
					System.out.println(c[M][2]);
				}else if(M<2) {
					System.out.println(c[N][2]);
				}else {
					System.out.println(c[N][2]+c[M][2]);
				}
			}
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 22612
from itertools import combinations
def main():
    s = [i[0] for i in open(0).read().split()[1:]]
    c = (s.count("M"),s.count("A"),s.count("R"),s.count("C"),s.count("H"))
    a = sum(x*y*z for x, y, z in combinations(c, 3))
    print(a)
main()

Measured memory_bytes: 10864
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(s[k-1])


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

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

using namespace std;
using lint=long long;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(int n):a(n){}
	void add(int i,G val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(val<=G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<=val) val-=a[x+k-1], x+=k;
		return x;
	}
};

template<class T>
long long inversion_number(const vector<T>& a){
	auto X=a;
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());

	long long res=0;
	Fenwick_tree<int> F(X.size());
	rep(i,a.size()){
		int x=lower_bound(X.begin(),X.end(),a[i])-X.begin();
		res+=F.sum(x+1,X.size());
		F.add(x,1);
	}
	return res;
}

int main(){
	string s; cin>>s;
	int n=s.length();

	vector<int> a(n);
	rep(i,n) a[i]=(s[i]=='B'?1:0);
	cout<<inversion_number(a)<<'\n';

	return 0;
}


Measured memory_bytes: 2180
A,B,C= map(int, input().split())
K = int(input())

for i in range(0,K):
    if C <= B or C <= A:
        C = C * 2
        continue

    if B <= A:
        B = B * 2
        continue

if C > B and B > A:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

int main(int argc, char** argv) {
  int N;
  cin >> N;
  string S;
  cin >> S;

  // Check the count of chars from last.
  int cnts[26]; // The count of each chars. The index is chr - 'a'.
  memset(cnts, 0, sizeof(cnts));

  ll ans = 0;
  for (int i = N-1; i >= 0; --i) {
    int cur = S[i] - 'a';

    ll c = 1; // count from S[i..-1]
    rep(j, 26) {
      if (j == cur) { continue; } // current char must not be multiplied.

      c *= (cnts[j] + 1);
      c %= MOD;
    }
    ans += c;
    ans %= MOD;

    ++cnts[cur];
  }

  cout << ans << endl;
}


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

long long cnt;
int A[10000000];
int n,m;
vector<int> G;

void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt+=1;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    while (1) {
        if (m > n) {
            break;
        }
        G.push_back(m); //要素の追加
        m = 4 * m + 1;
    }
    for (int i = G.size() -1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    cnt = 0;
    shellSort(A, n);
    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        cout << G[i];
        if (i) cout << " ";
    }
    cout << endl;
    printf("%lld\n", cnt);
    for (int i = 0; i < n; i++) cout << A[i] << endl;

    return 0;
}




Measured memory_bytes: 7168
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
  //happy coding

  int a;
  cin>>a;
  string s;
  cin>>s;
  if(a<3200){
  	cout<<"red"<<endl;
  }else{
  	cout<<s<<endl;
  }

  
  return 0;
}
int main(){
  int test = 1;
  //scanf("%d", &test);
  while (test--)solve();return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

  ll X;
  cin>>X;
  X-=400;
  X/=200;
  cout<<8-X<<endl;

  return 0;
}


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

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String s = new String(in.readLine());
		String[] ss = s.split(" ");
		
		int a = Integer.parseInt(ss[0]);
		int b = Integer.parseInt(ss[1]);
		if(a < b){
			System.out.println("a < b");
		}
		else if(a > b){
			System.out.println("a > b");
		}
		else{System.out.println("a == b");}
		
	}

}

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

int main() {
    int a[5];
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    int k;
    cin >> k;
    sort(a,a+5);
    int dis;
    dis = a[4] - a[0];
    if(dis <= k)
    {
        cout << "Yay!";
    }
    else
    {
        cout << ":(";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

struct Let {
    char c;
    int num;
    Let(){}
    Let(char c, int num):c(c),num(num){}
};

int main(int argc, char const *argv[]) {
    string s,t;
    cin>>s>>t;
    int n = s.length(); int m = t.length();
    vector<bool> us(26),ut(26);

    rep(i,n) us[s[i]-'a']=true;
    rep(i,m) ut[t[i]-'a']=true;
    bool ok = true;
    rep(i,26) if (ut[i]&&!us[i]) {
        cout << -1 << endl;
        return 0;
    }

    map<char, vector<int>> mp;
    rep(i,n) {
        mp[s[i]].push_back(i);
    }
    vector<Let> x;
    string u(t);
    u.push_back('?');
    int cnt = 1;
    rep(i,m) {
        if (u[i]!=u[i+1]) {
            x.emplace_back(u[i],cnt);
            cnt=1;
        }
        else cnt++;
    }

    ll ans = 0ll;
    int nind = 0;

    rep(i,m) {
        char c = t[i];
        auto itr = lower_bound(mp[c].begin(), mp[c].end(), nind);
        if (itr!=mp[c].end()) {
            int tmp = *itr; ++tmp;
            ans += (tmp-nind);
            nind = tmp;
        }
        else {
            ans += (n-nind);
            nind = *mp[c].begin();
            nind++;
            ans += nind;
        }
    }

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


Measured memory_bytes: 2300
# E

import sys

n, k = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
l = []

def check(b) :
    r1 = [x % b for x in a]
    r1.sort()
    s1 = sum(r1)
    
    mn = 1e9
    s2 = 0
    for i in range(n):
        s2 += r1[i]
        mn = min(max(s2, (n-1-i)*b - (s1-s2)), mn)
        
    if mn <= k :
        print(int(b))
        sys.exit(0)
        

for p in range(1,int((s+1)**0.5+1)) :
    if s % p != 0:
        continue
    b = s // p
    l.append(p)
    check(b)
    
l.reverse()

for b in l:
    check(b)
        
    

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s[k-1] = (s[k-1]- ('A'-'a'));
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int lena,lenb;
int main(){
    getline(cin,a),getline(cin,b);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<char>());
    if(a<b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
d = int(raw_input())

a = d/1000
d -= a*1000
b = d/100
d -= b*100
c = d/10
d -= c*10

sumt = range(8)
op = ["+", "-"]

sumt[0] = a+b+c+d
sumt[1] = a+b+c-d
sumt[2] = a+b-c+d
sumt[3] = a+b-c-d
sumt[4] = a-b+c+d
sumt[5] = a-b+c-d
sumt[6] = a-b-c+d
sumt[7] = a-b-c-d

for i,s in enumerate(sumt):
    if s == 7:
        x = op[i/4]
        i -= (i/4)*4
        y = op[i/2]
        i -= (i/2)*2
        z = op[i]



print '%s%s%s%s%s%s%s=7' %(a,x,b,y,c,z,d)


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
vector<int> adjlist[100005];
int a[100005];
int d[100005];
int mx[100005];
int ans = 0;
int n,k;
void dfs(int u){
    mx[u] = 0;
    for (auto v : adjlist[u]){
        d[v] = d[u]+1;
        dfs(v);
        //printf("%d ->%d: %d %d\n",u,v,d[v],mx[v]);
        if (mx[v] == k && u != 1){
            ans++;
        }
        else{
            mx[u] = max(mx[u],mx[v]);
        }
    }
    mx[u]++;
}
int main(){
    scanf("%d%d",&n,&k);
    for (int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        if (i == 1){
            if (a[i] != 1){
                ans++;
            }
        }
        else adjlist[a[i]].push_back(i);
    }
    d[1] = 0;
    dfs(1);
    printf("%d",ans);
}


Measured memory_bytes: 11520
n = int(input())
a = list(map(int,input().split()))

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a * b // gcd(a, b)

k = a[0]
for ai in a:
    k = lcm(ai, k)

res = 0
for ai in a:
    res += k//ai

print(res % 1000000007)



Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#define ll long long; int
using namespace std;


int main(void) {
 int n;
 cin >> n;
 vector<int> d(n+5);
 int ans = 0;
 for(int i = 0; i < n; i++) {
     cin >> d.at(i);
 }
 for(int i = 0; i < n; i++) {
     for(int j = 0; j < n; j++) {
         if(i < j) {
             ans += d.at(i) * d.at(j);
         }
     }
 }
 cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#include<string>
using namespace std;

#define ll long long
typedef pair<ll , ll > pii;
const int MOD = 998244353;
const int N=500004;


const int MAX_VAL = 300001;
vector<int> BIT(MAX_VAL);

void update(int i, int add)
{
    while (i > 0 && i < BIT.size())
    {
        BIT[i] += add;
        i = i + (i & (-i));
    }
}

int sum(int i)
{
    int ans = 0;
    while (i > 0)
    {
        ans += BIT[i];
        i = i - (i & (-i));
    }

    return ans;
}
int findKthSmallest(int k)
{
    int l = 0;
    int h = BIT.size();
    while (l < h)
    {
        int mid = (l + h) / 2;
        if (k <= sum(mid))
            h = mid;
        else
            l = mid+1;
    }

    return l;
}

void insertElement(int x)
{
    update(x, 1);
}

void deleteElement(int x)
{
    update(x, -1);
}

int findRank(int x)
{
    return sum(x);
}

///


void min_self(int &a , int b){
    a=min(a,b);
}

int add(int x, int y)
{
    return (x + y) % MOD;
}

int sub(int x, int y)
{
    return add(x, MOD - y);
}

int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}

int binpow(int x, int y)
{
    int z = 1;
    while(y > 0)
    {
        if(y % 2 == 1)
            z = mul(z, x);
        x = mul(x, x);
        y /= 2;
    }
    return z;
}

int inv(int x)
{
    return binpow(x, MOD - 2);
}

int fact[N];

int C(int n, int k)
{
    return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}





int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  // freopen("input.txt", "r", stdin);

   string s; cin>>s;
   for(int i=0; i<s.length();i++){
       if(s[i] == '?') s[i]='D';
   }
   cout<<s<<endl;
}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(l.begin(), l.end());
    int s = 0;
    rep(i,n-1){
        s += l[i];
    }
    if(l[n-1]<s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;


int main(){
	ll A,B,C,K,ans; cin >> A >> B >> C >> K;
    if(A > K) ans = K;
    else if(A + B >= K ) ans = A;
    else ans = A - (K - A - B);
    cout << ans;
  	return 0;
}

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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define rrep(i,x) for(int i=x-1;i>=0;--i)

int dp[1010][1010];

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

    rep(_, q) {
        memset(dp, -1, sizeof(dp));
        dp[0][0] = 0;

        string a,b; cin >> a>>b;

        int n = a.size(), m = b.size();

        a += '$';
        b += '!';

        rep(i, n+1) {
            rep(j, m+1) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
                dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);

                if (a[i] == b[j]) {
                    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                }
            }
        }

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

Measured memory_bytes: 7068
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}

// TODO: write
int main() {
  int n,k;cin>>n>>k;
  ll ans = 0;
  for(int b = 1;b <= n;++b){
    int p = n/b;
    int r = n%b;
    if(k == 0)r--;
    ans += max(b-k,0)*p;
    ans += max(r-k+1,0);
  }
  print(ans);
  return 0;
}

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

int main()
{
	int u = 0, a[6] = {0}, temp = 0;
	string mov;

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

	cin >> mov;

	for (unsigned int j = 0; j < mov.size(); j++) {
		switch (mov[j]) {
			case 'E':
				temp = a[0];
				a[0] = a[3];
				a[3] = a[5];
				a[5] = a[2];
				a[2] = temp;
				break;

			case 'W':
				temp = a[0];
				a[0] = a[2];
				a[2] = a[5];
				a[5] = a[3];
				a[3] = temp;
				break;

			case 'S':
				temp = a[0];
				a[0] = a[4];
				a[4] = a[5];
				a[5] = a[1];
				a[1] = temp;
				break;

			case 'N':
				temp = a[0];
				a[0] = a[1];
				a[1] = a[5];
				a[5] = a[4];
				a[4] = temp;
				break;
		}
	}

	cout << a[0] << endl;

    return 0;
}

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

int main() {
    int n; cin >> n;  
    while(n--){
        int balls[10] = {0};
        for(int i = 0; i < 10; i++){ cin >> balls[i]; }
        
        bool isYES = true;  
        int topB = 0, topC = 0; 
        for(int i = 0; i < 10; i++){
            if (topB < balls[i]){
                topB = balls[i];
            } else if (topC < balls[i]) {
                topC = balls[i];
            } else {
                isYES = false;
                break;
            }
        }
        cout << (isYES ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f;
const int MAX = 1e6;

int n, m;
vector<int> G[MAX];
int degree[MAX], dp[MAX];

int dfs(int v)
{
	if(dp[v] != -1) return dp[v];
	int ans = 0;
	for(int &u : G[v])
		ans = max(ans, 1 + dfs(u));
	return dp[v] = ans;
}

int main()
{
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		int u, v;
		cin >> u >> v; u--; v--;
		G[u].push_back(v);
		degree[v]++;
	}
	memset(dp, -1, sizeof(dp));
	int ans = 0;
	for(int i = 0; i < n; i++)
		ans = max(ans, dfs(i));
	cout << ans << '\n';

	return 0;
}

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

int main() {
  char s[3];
  cin >> s[0] >> s[1] >> s[2] >> s[3];
  cout << ((s[0] == s[1] && s[1] == s[2])||(s[1] == s[2] && s[2] == s[3])?"Yes":"No") << endl;
}

Measured memory_bytes: 384
#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;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    ll ans = k;
    rep (i, n - 1) ans *= k - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    n, k = mput()
    p = lput()
    p.sort()
    ans = sum(p[:k])
    print(ans)
    return 0

if __name__ == "__main__":
    solve()



Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int a[5];
  sa(a,5,d);
  rep(i,5) if(!a[i]) cout<<i+1;
  nline;
  return 0;
}


Measured memory_bytes: 3652
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
use std::cmp::min;
fn main(){
    let _n=read::<i32>();
    let m=read::<usize>();
    let x=read::<i32>();
    let a=(0..m).map(|_|read::<i32>()).filter(|c|x>*c).count();
    println!("{}",min(a,m-a))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, N;
  cin >> N >> A;
 
  if (A >= 500) {
    cout << "Yes" << endl;
  }
  else if ((N % 500) <= A) {
    cout << "Yes" << endl;
  }
 
  else {
    cout << "No" << endl;
  }
}

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

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 80;
const int M = 160 * 80;

int n, m, a[N][N];

bitset<M * 2> BS[N][N];

int main(){
    int x, y;
    scanf("%d %d", &n, &m);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            scanf("%d", &x);
            a[i][j] = abs(a[i][j] - x);
        }
    }

    BS[0][0].set(a[0][0] + M);

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(i < n - 1){
                BS[i+1][j] |= (BS[i][j] << a[i+1][j]) | (BS[i][j] >> a[i+1][j]);
            }
            if(j < m - 1){
                BS[i][j+1] |= (BS[i][j] << a[i][j+1]) | (BS[i][j] >> a[i][j+1]);
            }
        }
    }

    for(int i=0; ;i++){
        if(BS[n-1][m-1].test(M+i) || BS[n-1][m-1].test(M-i)){
            printf("%d\n", i);
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 20224
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)

using namespace std;

long long X, Y;
int ans;

int main() {
	scanf("%lld%lld", &X, &Y);
	for(; X <= Y; X <<= 1) ++ans;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    int y,m,d;
    cin >> S;
    while(S != "#"){
        cin >> y >> m >> d;
        if(y > 31 || y == 31 && m > 4){
            S = "?";
            y -= 30;
        }
        cout << S << " " << y << " " <<  m << " " <<  d << endl;
        cin >> S;
    }
}


Measured memory_bytes: 3040
M,D = map(int,input().split())

res = 0
for m in range(1,M+1):
    for d in range(10,D+1):
        d = str(d)
        c = 1
        for x in d:
            x = int(x)
            if x < 2:
                x = 0
            c *= x
        if c == m:
            res += 1
print(res)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll n; cin >> n;
  long double ans = 0;
  rep(i,n){
    long double m; cin >> m;
    string s; cin >> s;
    if(s == "JPY"){
      ans += m;
    }
    else{
      ans += m*380000;
    }
  }
  cout << fixed << setprecision(10) << ans;
}

Measured memory_bytes: 3760