akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

struct edge{
    int to;
    ll cost;
};

int n, m, s;
const int S = 3000;

vector<ll> dijkstra(vector<edge> g[], int s, int V) {

    vector<ll> dist(V, LINF);

    priority_queue<pll, vector<pll>, greater<pll>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()) {
        ll cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e: g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

void solve() {
    cin >> n >> m >> s;
    chmin(s, S - 100);
    vector<edge> G[n * (S + 1)];

    auto lift = [](int v, int c) {return v * (S + 1) + c;};

    rep(i, m) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        rep(c, S - a) {
            G[lift(u, c + a)].pb({lift(v, c), b});
            G[lift(v, c + a)].pb({lift(u, c), b});
        }
    }

    rep(v, n) {
        rep(i, S - 1) {
            G[lift(v, i + 1)].pb({lift(v, i), 0});
        }

        int c, d;
        cin >> c >> d;
        chmin(c, S);

        rep(j, S - c) G[lift(v, j)].pb({lift(v, j + c), d});
    }

    auto dist = dijkstra(G, lift(0, s), n * S + 100);

    rep(i, n) {
        if (!i) continue;
        cout << dist[lift(i, 0)] << endl;
    }
    return;
}

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


Measured memory_bytes: 31180
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read()*2+1;
    pr2(ceil(1.0*n/m));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n,r;
  cin >> n >> r;
  int ans=0;
  if(n>=10){ans=r;}else{ans=r+100*(10-n);}

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

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

int main(){
  int n;
  cin>>n;
  map<string,int>r;
  int mx=0;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    r[s]++;
    mx=max(r[s],mx);
  }
  for(auto p:r){
    if(p.second==mx){
      cout<<p.first<<endl;
    }
  }
}
  


Measured memory_bytes: 25216
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000000007

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))
#define mx 6e5 + 100;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//#include<bits/stdc++.h>
#define ll long long
const int maxn = 20005;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


int main ()
{
    fast;
    ll a,b;
    cin>>a>>b;
    if(a%b==0)
        cout<<a/b<<endl;
    else
    {
        cout<<((a/b)+1)<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int read_() {int x_=0,f_=1;char c_=getchar();while(c_<'0'||c_>'9') {if(c_=='-') f_=-1;c_=getchar();}while(c_>='0'&&c_<='9') {x_=(x_<<1)+(x_<<3)+c_-'0';c_=getchar();}return x_*f_;}

#define maxn 100020
int n,head[maxn],tot = 0,sze[maxn],max_sze[maxn],mind,root;
long long ans = 0;
struct edge {
	int v,nxt,w;
}e[maxn<<1];
inline void add_(int u,int v,int w) {
	e[++tot].v = v;
	e[tot].w = w;
	e[tot].nxt = head[u];
	head[u] = tot;
}

void dfs_(int u,int fa)  {
	sze[u] = 1;
	for(int i = head[u];~i;i = e[i].nxt)  {
		int v = e[i].v;
		if( v == fa ) continue;
		dfs_(v,u);
		sze[u] += sze[v];
		max_sze[u] = max( max_sze[u],sze[v] );
		ans += (long long) 2 * e[i].w * min( sze[v],n - sze[v] );
	}
	max_sze[u] = max( max_sze[u],n - sze[u] );
	if( max_sze[u] < mind ) {
		mind = max_sze[u];
		root = u;
	}
}

int main() {
//	freopen("a.txt","r",stdin);
	memset(head,-1,sizeof(head));
	n = read_();int x,y,z;
	for(int i = 1;i < n;++i) {
		x = read_();y = read_();z = read_();
		add_(x,y,z);add_(y,x,z);
	}
	mind = n + 1;
	dfs_(1,0);
	mind = 200000000;
	for(int i = head[root];~i;i = e[i].nxt) {
		int v = e[i].v;
		if( max_sze[root] == max_sze[v] ) {ans -= e[i].w;printf("%lld",ans);return 0;}
		mind = min( mind,e[i].w );
	}	
	printf("%lld",ans-mind);
	return 0;
}

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

using namespace std;

int countDigits(long long a) {
    int res = 0;
    while (a) {
        a /= 10;
        res++;
    }
    return res;
}

int main() {
    long long N;
    cin >> N;
    int sq = ceil(sqrt(N));
    int ans = 99;
    for (int i = 1; i <= sq; ++i) {
        if (N % i == 0) {
            ans = min(max(countDigits(i), countDigits(N / i)), ans);
        }
    }

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


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

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int MAX = 1405;
/* struct */
struct Rectangle {int height; int pos; };
/* global variables */
vector < vector<int> > Area(MAX, vector<int>(MAX)), buffer(MAX, vector<int>(MAX));
int H, W;
/* function */
int getLargestRectangle(int size, vector<int>& buffer) {
    stack<Rectangle> S;
    int maxv = 0;
    buffer[size] = 0;

    for (int i = 0; i <= size; i++) {
        Rectangle rect;
        rect.height = buffer[i];
        rect.pos = i;
        if ( S.empty() ) {
            S.push(rect);
        }
        else {
            if ( S.top().height < rect.height ) {
                S.push(rect);
            }
            else if ( S.top().height > rect.height) {
                int target = i;
                while (!S.empty() && S.top().height >= rect.height) {
                    Rectangle pre = S.top(); S.pop();
                    int area = pre.height * (i - pre.pos);
                    maxv = max(maxv, area);
                    target = pre.pos;
                }
                rect.pos = target;
                S.push(rect);
            }
        }
    }
    return maxv;
}

int getLargestRectangle() {
    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H; i++) {
            if (Area[i][j]) {
                buffer[i][j] = 0;
            }
            else {
                buffer[i][j] = (i > 0) ? buffer[i-1][j] + 1 : 1;
            }
        }
    }

    int maxv = 0;
    for (int i = 0; i < H; i++) {
        maxv = max(maxv, getLargestRectangle(W, buffer[i]));
    }

    return maxv;
}

/* main */
int main() {
    cin >> H >> W;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> Area[i][j];
        }
    }

    cout << getLargestRectangle() << '\n';

}


Measured memory_bytes: 18308
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

int my(int n, string s) {
    int ans = 1;
    map<char, int> cnt;
    for (auto t : s) {
        cnt[t]++;
    }
    for (char c = 'a'; c <= 'z'; c++) {
        for (char z = c + 1; z <= 'z'; z++) {
            ans += cnt[c] * cnt[z];
        }
    }
    return ans;
}

int stupid(int n, string s) {
    set<string> hv;
    hv.insert(s);
    for (int i = 0; i < n; i++) {
        for (int len = 1; i + len <= n; len++) {
            string t = s;
            reverse(t.begin() + i, t.begin() + i + len);
            hv.insert(t);
        }
    }
    return (int)hv.size();
}

void read() {
    string s;
    cin >> s;
    int n = (int)s.size();
    cout << my(n, s) << endl;
}

void run(int n) {
    string s(n, '$');
    for (auto &t : s) {
        t = rand() % 3 + 'a';
    }
    if (stupid(n, s) != my(n, s)) {
        cout << "wa " << s << endl;
        exit(0);
    } else {
        cout << "ok " << endl;
    }
}

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

    
    // for (int i = 0; i < n; i++) {
    //     for (int j = i; j < n; j++) {
    //         if (s[i] != s[j]) ans++;
    //     }
    // }

    read();

    // int n;
    // cin >> n;
    // while (true) run(n);
}   


Measured memory_bytes: 788
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int x1 = 0, x2 = W, y1 = 0, y2 = H;
    for (int i = 0, x, y, a; i < N; i++) {
        cin >> x >> y >> a;
        if (a == 1 && x > x1) x1 = x;
        else if (a == 2 && x < x2) x2 = x;
        else if (a == 3 && y > y1) y1 = y;
        else if (a == 4 && y < y2) y2 = y;
    }
    cout << max(0, (y2 - y1)) * max(0, (x2 - x1)) << endl;
}


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

int N;
int x[10], y[10];

int main(){

    int A, B;
    cin >> A >> B;
    if(A < 10 && B < 10){
        cout << A * B << endl;
    }
    else{
        cout << -1 << endl;
    }

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readInt()
  val S = readString()
  var cnt = 0
  for (i in 0 until N - 2) {
    if (S.substring(i..(i + 2)) == "ABC") cnt++
  }
  println(cnt)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }


Measured memory_bytes: 33396
n = int(input())
l = [input() for _ in range(n)]
s = input()

def small(l, s):
    p = [s > i.replace('?', 'z') for i in l]
    return sum(p)

def big(l, s):
    p = [s >= i.replace('?', 'a') for i in l]
    return sum(p)

print(*list(range(small(l, s) + 1, big(l, s) + 2)))

Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int N;
	cin >> N;
	print(N / 3);





	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    long ans = 1;
    for(int i=1;i<=n;i++){
        ans = ans * i;
        if(ans >= (10e9 + 7)){
            ans = ans % (int(1e+9 + 7));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
    
int main(void) {
 int i,j,tmp;
 scanf("%d",&tmp);
 for(i=1;i<tmp+1;i++){
  if((i%3)==0){
   printf(" %d",i);
  }else{
   j=i;
   while(1){
    if((j%10)==3){
     printf(" %d",i);
     break;
    }
    j=j/10;
    if(j==0){
     break;
    }
   }
  }
 }
 printf("\n");
    return 0;
}

Measured memory_bytes: 596
k = int(input())
a, b = map(int, input().split())
if k == 1:
    print("OK")
else:
    if a % k == 0:
        print("OK")
    elif b % k == 0:
        print("OK")
    elif a + (k - a%k) <= b:
        print("OK")
    else:
        print("NG")

Measured memory_bytes: 61772
// After contest.
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;

	cin >> n;

	vector<int> b(n);

	for (int i = 0; i < n; ++i) {
		cin >> b[i];
		if (b[i] > i+1) {
			cout << -1 << endl;
			return 0;
		}
	}

	vector<int> a(1, 1);
	for (int i = 1; i < n; ++i)
		a.insert(a.begin() + (b[i]-1), b[i]);

	for (int i = 0; i < n; ++i)
		cout << a[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int num=0;
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    while(a%2==0){
      a/=2;
      num++;
    }
  }
  cout << num << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Mod=1e9+7;
struct node{
	int x,y,z;
}e[2005];
int n,m,f[1005];
ll X;
bool cmp(node a,node b){
	return a.z<b.z;
}
ll power(ll a,ll b){
	ll res=1,tmp=a;
	while(b){
		if(b&1)res=res*tmp%Mod;
		tmp=tmp*tmp%Mod;
		b>>=1;
	}
	return res;
}
int find(int x){
	if(x==f[x])return x;
	return f[x]=find(f[x]);
}
ll kru(int t){
	for(int i=0;i<=n+1;i++)f[i]=i;
	ll res=0;
	if(t){
		int rx=find(e[t].x),ry=find(e[t].y);
		f[rx]=ry;
		res+=e[t].z;
	}
	for(int i=1;i<=m;i++)
		if(i!=t){
			int rx=find(e[i].x),ry=find(e[i].y);
			if(rx!=ry){
				f[rx]=ry;
				res+=e[i].z;
			}
		}
	return res;
}
int main(){
	scanf("%d%d%lld",&n,&m,&X);
	for(int i=1;i<=m;i++)
		scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].z);
	sort(e+1,e+m+1,cmp);
	ll tmp=kru(0);
	if(tmp>X){
		puts("0");
		return 0;
	}
	int sum1=0,sum2=0;
	for(int i=1;i<=m;i++){
		ll x=kru(i);
		if(x==X)sum1++;
		else if(x>X)sum2++;
	}
	if(tmp==X)printf("%lld",(power(2,sum1)-2)*power(2,sum2)%Mod);
	else printf("%lld",(2LL*power(2,sum1)-2)%Mod*power(2,sum2)%Mod);
	return 0;
}

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

#define int long long
const int N = 1e5+5;
int w, h, n;
int ans[10];
map<pair<int,int>,int> cnt, black;
int x[N], y[N];
int dir_x[9] = {-1,-1,-1,0,0,0,1,1,1};
int dir_y[9] = {-1,0,1,-1,0,1,-1,0,1};

signed main()
{
    cin >> w >> h >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        black[{x[i],y[i]}] = 1;
    }
    for (int i = 0; i < n; i++)
    {
        for (int k = 0; k < 9; k++)
        {
            int tmp_x = x[i]+dir_x[k], tmp_y = y[i]+dir_y[k];
            if (tmp_x <= 1 || tmp_y <= 1 || tmp_x >= w || tmp_y >= h)
                continue;
            ans[cnt[{tmp_x,tmp_y}]]--;
            cnt[{tmp_x,tmp_y}]++;
            ans[cnt[{tmp_x,tmp_y}]]++;
        }
    }
    //for (int i = 1; i <= w; i++)
    //{
    //    for (int j = 1; j <= h; j++)
    //    {
    //        cout << i << ' ' << j << ' ' << cnt[{i,j}] << endl;
    //    }
    //}
    int tmp = 0;
    for (int i = 1; i <= 9; i++)
        tmp += ans[i];
    ans[0] = (w-2)*(h-2) - tmp;
    for (int i = 0; i <= 9; i++)
        cout << ans[i] << endl;
}


Measured memory_bytes: 64384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	int ans=a[0];
	rep(i,n)ans=gcd(ans,a[i]);
	cout<<ans<<endl;
	return 0;


}


Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

void rec(vector<long long> &L, long long current_num) {
  L.push_back(current_num);
  if (current_num > 999999999) return;
  
  for (int i = 0; i < 10; i++) {
    if (abs(current_num % 10 - i) <= 1) rec(L, current_num * 10 + i); 
  }
}

int main() {
  int K;
  cin >> K;
  vector<long long> L;

  for (int i = 1; i < 10; i++) rec(L, i);

  sort(L.begin(), L.end()); 
  
  cout << L[K - 1] << endl;
}


Measured memory_bytes: 2420
#include<stdio.h>

int main(void){

 int x[10000];

 int i = -1, cnt = -1;
 do{
  i++;
  scanf("%d", &x[i]);
  cnt++;
 }while(x[i]);

 for(i = 0; i < cnt; i++){
  printf("Case %d: %d\n", i+1, x[i]);
 }

 return 0;

}


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

int main() {
  int n;
  cin >> n;
  vector<tuple<int,int,int>>d[n];
  rep(i,n-1){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    d[a].push_back(tuple<int,int,int>(a,b,c));
    d[b].push_back(tuple<int,int,int>(b,a,c));
  }
  vector<bool>v(n);
  v[0]=true;
  vector<int>ans(n);
  ans[0]=0;
  queue<tuple<int,int,int>>q;
  rep(i,d[0].size()){
    q.push(tuple<int,int,int>(get<0>(d[0][i]),get<1>(d[0][i]),get<2>(d[0][i])));
  }
 
  while(!q.empty()){
    tuple<int,int,int>p=q.front();
    q.pop();
    if(!v.at(get<1>(p))){
      ans.at(get<1>(p))=abs(ans.at(get<0>(p))-get<2>(p)%2);
      v.at(get<1>(p))=true;
      rep(i,d[get<1>(p)].size()){
        if(!v.at(get<1>(d[get<1>(p)][i]))){
          q.push(tuple<int,int,int>(get<0>(d[get<1>(p)][i]),get<1>(d[get<1>(p)][i]),get<2>(d[get<1>(p)][i])));
        }
      }
    }
  }
          
  
  rep(i,n){
    printf("%d\n",ans[i]);
  }
}





Measured memory_bytes: 10068
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int time = 0;
		int x = 0;
		int y = 0;
		boolean ans = true;
		for(int i = 0; i < n; i++) {
			int nexttime = sc.nextInt();
			int nextx = sc.nextInt();
			int nexty = sc.nextInt();
			int dtime = nexttime - time;
			int dx = Math.abs(nextx - x);
			int dy = Math.abs(nexty - y);
			if(dtime >= dx + dy && dtime % 2 == (dx + dy) % 2) {
				time = nexttime;
				x = nextx;
				y = nexty;
			} else {
				ans = false;
				break;
			}
		}
		if(ans) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 87124
import java.math.*

fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toLong() }
    val AArr = readInputLine().split(" ").map { it.toLong() }.sortedDescending().toLongArray()
    val Amax = AArr[0]

    // パワーがi以上の人数
    // カウント人数配列のインデックスA_kの値を加算後、上から累積和を取ることで求められる
    val powCnt = LongArray(Amax.toInt() * 2 + 1)

    for (A in AArr) {
        powCnt[A.toInt()]++
    }

    for (i in Amax.toInt() - 1 downTo 0) {
        powCnt[i] += powCnt[i + 1]
    }

    // M以上の回数増やせる幸福度X最大値の二分探索
    // 左手のパワーを固定すれば、先に求めた配列からO(1)で求められ、左手がN人いるため1回あたりO(N)で求められる
    var l = 0L
    var r = Amax * 2L + 1L

    while (r - l > 1L) {
        val m = (l + r) / 2L
        val cnt = AArr.fold(0L) { acc, A -> acc + powCnt[Math.max(0L, m - A).toInt()] }
        if (cnt >= M) {
            l = m
        } else {
            r = m
        }
    }

    // 答えを求める
    // 幸福度Xを増やせるパターンがMより多い可能性があるため、X + 1増やせるパターンの個数を求め、M - その個数分だけ最後に足すことにする
    var already = 0L
    var ans = 0L

    // Aの降順累積和
    // 幸福度X + 1での総和を求める際、先のpowCntをインデックスとすれば各左手について総和が求められる
    // ただし、カウントは0を取る場合があるため、1から使用することにする
    val sumArr = LongArray(N.toInt() + 1)
    for (i in 0 until N.toInt()) {
        sumArr[i + 1] = sumArr[i] + AArr[i]
    }

    for (A in AArr) {
        val cnt = powCnt[Math.max(0L, r - A).toInt()]
        ans += A * cnt + sumArr[cnt.toInt()]
        already += cnt
    }

    ans += l * (M - already)

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 65876
#include <bits/stdc++.h>
#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;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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



int main() {
int n;
cin>>n;
vector<int> x(n,0);
vector<int> m(n,0);
cin>>x[0];
REP(i,n) cin>>m[i];
int sum=accumulate(m.begin(),m.end(),0);
sort(m.begin(), m.end());
x[0]=x[0]-sum;
int ans=n;
for(int i=0; i<n; i++){
    x[i+1]=x[i]%m[i];
    ans+=x[i]/m[i];
    if(x[i]/m[i]==0) break;
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#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>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#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 SUM(vec) accumulate(all(vec),0LL)
#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;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
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;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> h(n);rep(i,n)cin>>h[i];
  h[0]--;
  rep(i,n){
    if(!i)continue;
    if(h[i-1] != h[i]){
      --h[i];
    }
    if(i+1 < n && h[i] > h[i+1]){
      print("No");
      return 0;
    }
  }
  print("Yes");
  return 0;
}


Measured memory_bytes: 3032
import java.util.*;

public 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();
      	int D = sc.nextInt();
      	
      	int max = 0;
      	int min = 0;
      	if(A <= C){
          max = C;
        }else{
          max = A;
        }
      
      	if(B <= D){
          min = B;
        }else{
          min = D;
        }
		int result = 0;
      	if(max <= min){
          result = min - max;
        }
      
      	System.out.println(result);
    }
}

Measured memory_bytes: 21844
import static java.lang.Math.*;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner in=new Scanner(System.in);
        int N=in.nextInt();
        int Y=in.nextInt();
        // boolean flag=false;
        out:for(int i=0;i<=N;i++){
            for(int j=0;j<=N-i;j++){
                if(Y==10000*i+5000*j+1000*(N-i-j)){
                    // flag=true;
                    System.out.println(i+" "+j+" "+(N-i-j));
                    return;
                    // break out;
                }
            }
        }
        System.out.println("-1 -1 -1");
        
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
char a[100006];
int main(){
	int s=0,sn=0,x;
	//for(int i=1;i<=strlen(a);i++)
	gets(a);
	for(int i=0;i<strlen(a);i++)
	{if(a[i]=='p')
	s++;
	if(a[i]=='g')
	sn++;
	}
	x=(sn-s)/2;
	cout<<x;
	return 0;
	
	
} 

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

int n;
int A[2][300001];
string str;

int main() {
    cin >> n >> str;
    int lw = 0, re = 0;
    for (int i=0; i<n; i++) {
        if (str[i] == 'W') {
            lw++;
            A[0][i] = lw;
        } else
            A[0][i] = lw;
    }
    for (int i=n-1; i>=0; i--) {
        if (str[i] == 'E') {
            re++;
            A[1][i] = re;
        } else
            A[1][i] = re;
    }

    int ans = 0x7fffffff;
    for (int i = 0; i<n; i++)
            ans = min(ans, A[0][i] + A[1][i] - 1);
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector <int> d(n+1);
    rep(i,n){
        cin >> d[i];
    }
    d[n]=0;
    sort(d.begin(),d.end());
    rep(i,n+1){
        if((i%2)==1){
            d[i]=24-d[i];
        }
    }

    sort(d.begin(),d.end());
    int ans=25;
    rep(i,n){
        if((d[i+1]-d[i])<ans){
            ans=d[i+1]-d[i];
        }
    }

    ans=min(ans,24-d[n]);
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3632
N,M = gets.split.map(&:to_i)
from1 = []
toN = []
M.times{
  a,b = gets.split.map(&:to_i)
  from1 << b if a == 1
  toN << a if b == N
}

puts (from1&toN).size > 0 ? "POSSIBLE":"IMPOSSIBLE"

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

int main(){
    int N;
    string S;
    cin >> N >> S;
    bool flag = false;
    if (N % 2){
        flag = true;
    } else if (N == 2){
        if (S.at(0) != S.at(1)){
            flag = true;
        }
    } else {
        rep(i, N / 2 - 1){
            if (S.at(i) != S.at(i + N / 2)){
                flag = true;
            }
            if (flag){
                break;
            }
        }
    }
    if (flag){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define WR "txt"

void Open() { freopen(WR".in", "r", stdin); freopen(WR".out", "w", stdout); }
void Close() { fclose(stdin); fclose(stdout); }
using namespace std;
int Read()  {
	int val = 0, opt = 1; char ch;
	while (!isdigit(ch = getchar() )) if (ch == '-') opt = -1;
	while (isdigit( ch )) (val *= 10) += ch - '0', ch= getchar();
	return val * opt;
}

int a[100100], n, p;

void work()  {
	n = Read();
	for (int i = 1;i <= n; i++)	a[i] = Read();
	sort(a + 1, a + 1 + n);
	p = a[1];
	for (int i = 2;i < n; i++) 
		if (abs(a[i] - a[n] / 2.) < abs(p - a[n] / 2.)) p = a[i];
	printf("%d %d", a[n], p);
}

int main(void)  {
	//Open();
	work();
	//Close();
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cmath>
#include <limits>
#include <algorithm>
using namespace std;

int main() {
  int64_t N, A; scanf("%" SCNd64 "%" SCNd64, &N, &A);
  int64_t min_score = INT64_MAX;
  for(int K = 0; K <= 45; ++K) {
    int64_t lo = 0, hi = N;
    while(hi - lo > 1) {
      int64_t mid = (hi + lo) / 2;
      if(pow(mid, K + 1) > 2 * N) {
        hi = mid;
      } else {
        int64_t p = 1;
        for(int x = 5; x >= 0; --x) {
          p *= p;
          if(((K+1)>>x)&1) p *= mid;
        }
        if(p >= N) {
          hi = mid;
        } else {
          lo = mid;
        }
      }
    }
    int lo2 = 0, hi2 = K+1;
    while(hi2 - lo2 > 1) {
      int mid = (hi2 + lo2) / 2;
      int64_t p_hi = 1;
      for(int x = 5; x >= 0; --x) {
        p_hi *= p_hi;
        if((mid>>x)&1) p_hi *= hi;
      }
      int64_t p_lo = 1;
      for(int x = 5; x >= 0; --x) {
        p_lo *= p_lo;
        if(((K+1-mid)>>x)&1) p_lo *= lo;
      }
      if(p_hi * p_lo >= N) {
        hi2 = mid;
      } else {
        lo2 = mid;
      }
    }
    int64_t score = (K+1-hi2) * lo + hi2 * hi + K * A;
    // printf("%" PRId64 "^%d, %" PRId64 "^%d, %" PRId64 "\n", lo, K+1-hi2, hi, hi2, score);
    min_score = min(min_score, score);
  }
  printf("%" PRId64 "\n", min_score);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

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



int main() {
  int N;
  cin >> N;
  vector<int> a(N), _a(N);
  rep(i, N) {
    cin >> a[i];
    _a[i] = a[i];
  }

  sort(all(a));

  rep(i, N) {
    if(_a[i] == a[N-1]) {
      cout << a[N-2] << endl;
    } else {
      cout << a[N-1] << endl;
    }
  }

  return 0;
}

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

using namespace std ;

const int MAX = 2e5 + 10 ;

long long arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	sort(arr , arr + n) ;
	reverse(arr , arr + n) ;
	long long ans = arr[0] ;
	int idx = n ;
	for(int i = 2 ; i < idx ; ++i)
	{
		ans += min(arr[i-1] , arr[i-2]) ;
		idx-- ;
		if(i < idx)
			ans += min(arr[i-1] , arr[i-2]) ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 5068
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>
 
using namespace std;
 
const int MOD = 1000000007;
 
 
inline int add(int a, int b)
{ 
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}
 
inline int sub(int a, int b)
{ 
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
 
int main()
{ 
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
 
  int N, K;
 
  std::cin >> N >> K;
 
  vector<vector<int>> dp = vector<vector<int>>(N+1, vector<int>(K+1, 0));
  vector<vector<int>> prefix = dp;
  prefix[0] = vector<int>(K+1, 1);
 
  for (int i = 1; i <= N; ++i)
  { 
    int kid;
    cin >> kid;
 
    for (int sum = 0; sum <= K; ++sum)
    { 
      int R = min(kid, sum);
 
      dp[i][sum] = sub(prefix[i - 1][sum], (sum - R > 0 ? prefix[i - 1][sum - R - 1] : 0));
      prefix[i][sum] = add(dp[i][sum], (sum > 0 ? prefix[i][sum - 1] : 0));
    }
  }
 
  std::cout << dp[N][K];
 
  return 0;
}

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

int N;
vector<int> a;

int main() {
    cin >> N;
    a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());

    int M = 1000001;
    vector<int> cnt(M);

    for (int x: a) {
        if (cnt.at(x) != 0) {
            cnt.at(x) = 2;
            continue;
        }
        for (int i = x; i < M; i += x) {
            cnt.at(i)++;
        }
    }

    int res = 0;
    for (int x: a) {
        if (cnt.at(x) == 1) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 7988
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

// ただの辺
struct edge {
    int to;
    long long cost;
    // 引数一つの時は距離1
    edge(int t, long long c = 1) : to(t), cost(c) {}
};

int n;
vector<int> a;
vector<vector<edge>> g;
vector<int> dp;
vector<int> ans;

void dfs(int now, int from) {
    int target = lower_bound(dp.begin(), dp.end(), a[now]) - dp.begin();
    int prev = dp[target];
    dp[target] = a[now];
    ans[now] = lower_bound(dp.begin(), dp.end(), INT_MAX) - dp.begin();
    for (auto e : g[now]) {
        if (e.to == from) {
            continue;
        }
        dfs(e.to, now);
    }
    dp[target] = prev;
}

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

    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dp.resize(n, INT_MAX);
    ans.resize(n);
    dfs(0, -1);
    for (auto e : ans) {
        cout << e << endl;
    }
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  rep(i, D) cin >> p[i] >> c[i];

  int ans = 10000000;
  rep(i, (1 << D)) {
    int sum = 0;
    int cnt = 0;
    vector<int> vi;
    rep(j, D) {
      if ((i >> j) & 1) {
        sum += c[j] + p[j] * 100 * (j + 1);
        cnt += p[j];
      } else {
        rep(k, p[j]) vi.eb(100 * (j + 1));
      }
    }
    sort(rall(vi));
    rep(j, vi.size()) {
      if (sum >= G) break;
      sum += vi[j];
      cnt++;
    }
    ans = min(ans, cnt);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>
#include <typeinfo>
#include <memory>

#define NN 2000

using namespace std;

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

#define fs first
#define sc second

int s[2][NN][NN];
int t[NN][2][NN];

int main(){
    int N, K;
    cin >> N >> K;
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < NN; j++){
            fill(s[i][j], s[i][j]+NN, 0);
        }
    }
    for(int i = 0; i < N; i++){
        int x, y;
        char c;
        cin >> x >> y >> c;
        x %= 2*K;
        y %= 2*K;
        if(c == 'B'){
            s[0][x][y]++;
        }
        else{
            s[1][x][y]++;
        }
    }

    for(int i = 0; i < 2*K; i++) {
        fill(t[i][0], t[i][0] + NN, 0);
        fill(t[i][1], t[i][1] + NN, 0);
    }


    for(int i = 0; i < 2*K; i++){
        for(int j = 0; j < 2*K; j++){
            if((i / K) ^ (j / K) == 0){
                t[0][0][i] += s[0][i][j];
                t[0][1][i] += s[1][i][j];
            }
            else{
                t[0][1][i] += s[0][i][j];
                t[0][0][i] += s[1][i][j];
            }
        }
    }

//    for(int i = 0; i < 2*K; i++){
//        for(int j = 0; j < 2*K; j++){
//            cout << s[0][i][j] << " ";
//        }
//        cout << endl;
//    }
//    cout << endl;
//
//    for(int j = 0; j < 2*K; j++){
//        cout << t[0][0][j] << " ";
//    }
//    cout << endl;
//    cout << endl;

    for(int i = 1; i < 2*K; i++){
        for(int j = 0; j < 2*K; j++){
            int change;
            if(j < K){
                int b2w = i-1;
                int w2b = (i-1 + K) % (2*K);
                int numb2w = -s[0][j][b2w] + s[1][j][b2w];
                int numw2b = - s[1][j][w2b] + s[0][j][w2b];
                change = -s[0][j][b2w] + s[1][j][b2w] - s[1][j][w2b] + s[0][j][w2b];
            }
            else{
                int w2b = i-1;
                int b2w = (i-1 + K) % (2*K);
                change = -s[0][j][b2w] + s[1][j][b2w] - s[1][j][w2b] + s[0][j][w2b];
            }
            t[i][0][j] = t[i-1][0][j] + change;
            t[i][1][j] = t[i-1][1][j] - change;
        }
    }

//    for(int i = 0; i < 2*K; i++){
//        for(int j = 0; j < 2*K; j++){
//            cout << t[i][0][j] << " ";
//        }
//        cout << endl;
//    }

    int res = 0;
    for(int i = 0; i < 2*K; i++){
        int su = 0;
        for(int j = 0; j < 2*K; j++){
            su += t[i][0][j];
        }
        // cout << su << endl;

        res = max(res, su);
        for(int j = 1; j < 2*K; j++){
            int x  = j-1;
            int y = (j-1+K) % (2*K);
            int change = -t[i][0][x] + t[i][1][x] - t[i][0][y] + t[i][1][y];
            swap(t[i][0][x], t[i][1][x]);
            swap(t[i][0][y], t[i][1][y]);
            su += change;
            res = max(res, su);
        }
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 62720
import math
def main():

    N = int(input())

    d = [2 for _ in range(N+1)]
    d[1] = 1

    # v = int(math.sqrt(N))
    for i in range(2, N//2+1):
        for j in range(i+i, N+1, i):
            d[j] += 1
            # if j//i > v: d[j] += 1

    ans = 0
    for i in range(1, N+1):
        ans += i * d[i]
    return ans

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


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

int main(){
    int n,c,k;
    cin>>n>>c>>k;
    vector<int>t(n);
    rep(i,n)cin>>t[i];
    sort(t.begin(),t.end());
    int ans=1,cnt=1,start=t[0];
    for(int i=1; i<n; ++i){
        if(t[i]<=start+k){
            if(cnt<c)cnt++;
            else cnt=1,ans++,start=t[i];
        }
        else cnt=1,ans++,start=t[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	int a[n];
	int flag = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];	
	}
	for(int i=0;i<n;i++){
		
		if(a[i]%2==0){
			if((a[i]%3!=0)&&(a[i]%5!=0)){
				cout << "DENIED" << endl;
				flag++;
				break;
			}
		}
	}
	if(flag == 0){cout << "APPROVED" << endl;}
	
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef long double LD;
const int N = 6, M = 50;

int n, C, a[N], id[N], dfn[N];
LL fans, alltot, f[N * M + 1][(1 << (N - 1)) + 1];

LL Solve() {
	for (int i = 0; i <= n * C; ++i)
		fill(f[i], f[i] + (1 << (n - 1)), 0LL);
	f[n * a[0]][0] = 1;
	for (int i = 0; i < n * C; ++i)
		for (int j = max(i, n * a[0]); j <= n * C; ++j)
			for (int k = 0; k < (1 << (n - 1)); ++k)
				if (f[j][k] && i % n != 0 && !(k >> (i % n - 1) & 1))
					f[min(n * C, max(j, i + n * a[dfn[i % n]]))][k | (1 << (i % n - 1))] += f[j][k];
	return f[n * C][(1 << (n - 1)) - 1];
}

int main()
{
	scanf("%d%d", &n, &C);
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	sort(a, a + n, [](int x, int y){ return x > y; });
	for (int i = 0; i < n; ++i)
		dfn[i] = i;
	alltot = 1;
	for (int i = 1; i < n; ++i)
		alltot *= i;
	for (int i = 1; i < n; ++i)
		alltot *= C;
	do {
		for (int i = 0; i < n; ++i)
			id[dfn[i]] = i;
		fans += Solve();
	} while (next_permutation(dfn + 1, dfn + n));
	printf("%.16Lf\n", (LD)fans / (LD)alltot);

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define rall(v)     (v).rbegin(),(v).rend()
#define gcd(a,b)    __gcd((a),(b))
#define fill(a,value) memset(a,value,sizeof(a));
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
#define sum(v)+x    accumulate(v.begin(), v.end(),x);
typedef pair<int,int> pii;  
typedef vector<int> vi;
int lowerBound(vi a,int n,int key){
    int s =0,e=n-1;
    int ans = -1;
    while(s<=e){
        int mid = (s+e)/2;

        if(a[mid]==key){
            ans = mid;
            e = mid - 1;
        }
        else if(a[mid]>key){
            ans=mid;
            e = mid - 1;
        }
        else{
            
            s = mid + 1;
        }
    }

    return ans;
}
int upperBound(vi a,int n,int key)
{
    int s =0,e=n-1;
    int ans = -1;

    while(s<=e){
        int mid = (s+e)/2;

        if(a[mid]==key){
            ans = mid;
            s = mid+1;
        }
        else if(a[mid]>key){
            e = mid - 1;
            ans = mid;
        }
        else{
            s = mid + 1;
        }
    }
    return ans;
}
signed main() 
{
    fastio;
    cout << fixed << setprecision(12);
    int n;
    cin>>n;
    int a[n];
    f(i,n)cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int x=lower_bound(a,a+n,a[i]+a[j])-a;
            ans+=max(0ll,x-j-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pii> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    sort(all(v));

    priority_queue<int> que;
    int id = 0;
    ll res = 0;
    for (int i = m-1; i >= 0; --i) {
        if (id < n) {
            while (v[id].first <= m-i) {
                que.push(v[id].second);
                id++;
                if (id == n) break;
            }
        }
        if (que.empty()) continue;
        res += que.top();
        que.pop();
    }
    cout << res << endl;
}

Measured memory_bytes: 4640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a;
  int n[200];
  for (int i = 0; i < a; i++){
    cin >> n[i];
  }
  bool odd = false;
  while(1){
   for (int i = 0; i < a; i++){
     if (n[i]%2 == 1){
       odd = true;
     }
   }
     if(odd)break;
    b++;
    for (int i = 0; i < a;i++){
      n[i] /= 2;
    }
  }
  cout << b << endl;
}

Measured memory_bytes: 256
import math
while True:
    n = int(input())
    if n == 0:
        break

    s = list(map(int, input().split()))
    m = sum(s) / n
    v = 0
    for si in s:
        v += (si - m) ** 2
    ans = math.sqrt(v/n)      
    print("{:.5f}".format(ans))


Measured memory_bytes: 5704
N = int(input())
ans = []
for _ in range(N - 1):
    C, S, F = map(int, input().split())
    ans.append(S + C)
    for i in range(len(ans) - 1):
        if ans[i] <= S:
            ans[i] = S + C
        else:
            if (ans[i] - S) % F == 0:
                ans[i] += C
            else:
                ans[i] = S + F * ((ans[i] - S) // F + 1) + C

ans.append(0)
for a in ans:
    print(a)


Measured memory_bytes: 41964
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
 
using namespace std;
const int maxn = 1e6 + 5;
long long a[maxn], b[maxn], c[maxn];
 
int main()
{
    long long n;
    long long sum = 0;
    scanf("%lld", &n);
    for(int i = 0; i < n; i++)
        scanf("%lld", &a[i]);
    for(int i = 0; i < n; i++)
        scanf("%lld", &b[i]);
    for(int i = 0; i < n; i++)
        scanf("%lld", &c[i]);
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    int l = 0, r = 0;
    for(int i = 0; i < n; i++)
    {
        while(l < n && a[l] < b[i])
            l++;
        while(r < n && c[r] <= b[i])
            r++;
        sum += l * (n - r);
    }
    printf("%lld\n", sum);
    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll n,a[N],mk[25],nx[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	ll res=0;
	for(int i=1;i<=n;i++)	cin>>a[i];
	int nxt=n+1;
	for(int i=n;i>=1;i--)
	{
		nx[i]=nxt;
		if(a[i]>0)
			nxt=i;
	}
	for(int i=1;i<=n;i++)
	{
		memset(mk,0,sizeof(mk));
		bool flag=true;
		for(int j=i;j<=n&&flag;)
		{
			int x=a[j];
			for(int k=0;k<=20&&flag;k++)
			{
				if((x>>k)&1)
				{
					if(!mk[k])
						mk[k]=true;
					else
						flag=false;
				}
			}
			if(flag)
			{
					res++;
				res+=nx[j]-j-1;
				j=nx[j];
			}
		}
	}
	cout<<res<<'\n';
	
	return 0;
}

Measured memory_bytes: 3328
N = gets.to_i
xy = []
N.times { |i| xy << gets.split.map(&:to_i) }

xyc = Hash.new(0)
N.times do |i|
  N.times do |j|
    next if i == j
    xi, yi = xy[i]
    xj, yj = xy[j]
    xyc[ [xi-xj, yi-yj] ] += 1
  end
end

if N == 1
  puts 1
else
  puts N - xyc.sort_by { |k, v| -v }.first[1]
end

Measured memory_bytes: 2044