akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const int mod = 1000000007;

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    
    ll res = 0;
    if(k == 1){
        for(int i = 0; i < n; ++i){
            for(int j = i + 1; j < n; ++j){
                if(a[i] > a[j])     ++res;
            }
        }
        cout << res << endl;
        return 0;
    }
    
    ll res1 = 0, res2 = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(a[i] > a[j]){
                ++res1;
            }
        }
    }
    ll mul = 1;
    if(k % 2 == 0){
        mul = (ll)(k / 2 * (k + 1)) % mod;
    }
    else{
        mul = (ll)((k + 1) / 2 * k) % mod;
    }
    
    res1 = (res1 * mul) % mod;
    
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < i; ++j){
            if(a[i] > a[j])     ++res2;
        }
    }
    if(k % 2 == 0){
        mul = (ll)(k / 2 * (k - 1)) % mod;
    }
    else{
        mul = (ll)((k - 1) / 2 * k) % mod;
    }
    
    res2 = (res2 * mul) % mod;
    
    res = (res1 + res2) % mod;
    
    cout << res << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int n,m;
	scanf("%d",&n);
	fprintf(stderr,"\nn=%d\n",n);

	int time[n+1];
	int j;
	for (j=0;j<=n-1;j++)
		{scanf("%d",&time[j]);}
	scanf("%d",&m);
	fprintf(stderr,"m=%d\n",m);

	int px[m][3];
	int h=0,i=0;
	for(i;i<=m-1;i++)
		{
		h=0;
		for(h;h<=1;h++)
			{scanf("%d",&px[i][h]);}
		}

	int sumorg=0;
	i=0;	
	for(i;i<=n-1;i++)
			{sumorg += time[i];}
	int sum;
	fprintf(stderr,"sumrog=%d\n",sumorg);
	
	i=0;
	for(i;i<=m-1;i++)
		{
		sum = sumorg + px[i][1]-time[px[i][0]-1];
		printf("%d\n",sum);
		}

	return 0;
}


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

#define o first
#define t second

int su[500001];
pair<int, int> bst[500001];
int ans[500001];

int main(){
    int n;
    scanf("%d",&n);
    n = (1 << n) - 1;
    for(int i=0;i<=n;i++){
        scanf("%d",&su[i]);
    }
    bst[0] = {0, -1};
    ans[0] = -1;
    for(int i=1;i<=n;i++){
        bst[i] = {i, -1};
        int ii = i;
        while(ii){
            int x = ii & (-ii);
            int tt = i-x;
            int t1 = bst[tt].o;
            if((~t1) && t1 != bst[i].o && t1 != bst[i].t){
                if(su[t1] > su[bst[i].o]){
                    bst[i].t = bst[i].o;
                    bst[i].o = t1;
                }else if(su[t1] > su[bst[i].t]){
                    bst[i].t = t1;
                }
            }
            t1 = bst[tt].t;
            if((~t1) && t1 != bst[i].o && t1 != bst[i].t){
                if(su[t1] > su[bst[i].o]){
                    bst[i].t = bst[i].o;
                    bst[i].o = t1;
                }else if(su[t1] > su[bst[i].t]){
                    bst[i].t = t1;
                }
            }
            ii -= ii & (-ii);
        }
        ans[i] = max(ans[i-1], su[bst[i].o] + su[bst[i].t]);
    }
    for(int i=1;i<=n;i++) printf("%d\n", ans[i]);
}


Measured memory_bytes: 8960
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

int main() {
  int k,a,b,r=0;
  cin>>k;
  cin>>a>>b;
  FOR(i,a,b)
  {
    if(i%k==0)
		r=1;
  }
  if(r==1)
    cout<<"OK";
  else
  cout<<"NG";
}  


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}
template<typename T>
void cout_mat(vector<vector<T>  > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<T> vec = mat[i];
        cout_vec(mat[i]);
    }
}

int main(){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<vector<ll> > vec(A+B+C,vector<ll>(2,0));
    for(int i=0; i<A+B+C; i++){
        ll p;
        cin >> p;
        if(i<A){
            vec[i]={p,0};
        }else if(i<A+B){
            vec[i]={p,1};
        }else{
            vec[i]={p,2};
        }
    }

    sort(vec.rbegin(), vec.rend());
    ll ans=0;
    int cnt=X+Y;
    for(int i=0; cnt>0; i++){
        ll p=vec[i][0];
        int color=vec[i][1];
        
        if(X==0 && color==0){
            continue;
        }else if(Y==0 && color==1){
            continue;
        }
        if(color==0){
            X--;
        }else if(color==1){
            Y--;
        }
        //cout << p << endl;
        ans+=p;
        cnt--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 16640
fn input_vec<T: std::str::FromStr>()->Vec<T>{
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}
fn main() {
	let input = input_vec::<i64>();
	let l = input[0];
	let r = input[1];
	let d = input[2];
	let result = (r-r%d)/d-(l-1-(l-1)%d)/d;
	println!("{}",result);


    
}


Measured memory_bytes: 2116
N, A, B = map(int, input().split()) 
s = [i for i in input()]
count = 0
sb = 0

for i in range(len(s)):
      if s[i] == 'a':
            if count < (A+B):
                  print('Yes')
                  count +=1
            else:
                  print('No')
  
      elif s[i] == 'b':
            if (count < (A+B)) and (sb < B):
                  print('Yes')
                  count += 1
                  sb += 1
            else:
                  print('No')
      
      elif s[i] == 'c':
            print('No')

Measured memory_bytes: 4696
D,G = map(int,input().split())
pc = []
for i in range(D):
    p,c = map(int,input().split())
    pc.append([i+1,p,c])
pc.sort(reverse = True)
ansc = []
for i in range(2**D):
    count = 0
    sumb = 0
    pc2 = []
    for j in range(D):
        if (i >> j) & 1 == 1:
            sumb += 100*pc[j][0]*pc[j][1] + pc[j][2]
            count += pc[j][1]
        else:
            pc2.append(pc[j])
    pc2 = sorted(pc2,reverse = True)
    c2 = 0
    if sumb < G:
        c2 = (G - sumb)//(100*pc2[0][0])
        if (G - sumb)%(100*pc2[0][0]) != 0:
            c2 += 1
        if c2 >= pc2[0][1]:
            count = 10**9
        else:
            count += c2
    ansc.append(count)
print(min(ansc))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>

#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for (int i=a;i>=b;i--)
#define LL long long
#define INF (2147483647)
#define sqr(x)	((x)*(x))

using namespace std;

inline void read(int &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(int x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

inline void read(LL &data){
    data=0;
	int w=1; char ch=0;
    while (ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if (ch=='-') w=-1,ch=getchar();
    while  (ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
    data=data*w;
}

inline void write(LL x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
} 

int n;
LL s[100005];
int main(){	

	read(n);
	rep(i,1,n)	read(s[i]);
	LL ans1=0,ans2=0;
	LL now=0,e=-1;
	
	rep(i,1,n){
		e=-e;
		now+=s[i];
		if (now*e<=0)
			ans1+=abs(now-e),now=e;
	}
	
	e=1,now=0;
	rep(i,1,n){
		e=-e;
		now+=s[i];
		if (now*e<=0)
			ans2+=abs(now-e),now=e;
	}
		
	write(min(ans1,ans2));
} 

Measured memory_bytes: 1024
from math import gcd

N,K=map(int,input().split())
A=list(map(int,input().split()))

ans=["POSSIBLE","IMPOSSIBLE"]

if max(A)<K:
    print(ans[1])
else:
    g=A[-1]
    for i in range(N-1):
        g=gcd(g,A[i])
    if K%g==0:
        print(ans[0])
    else:
        print(ans[1])

Measured memory_bytes: 20256
// 2011/08/02 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int X, Y;
		cin >> X >> Y;
		if(X==0&&Y==0)
			break;

		int C[17][17];
		for(int i=0; i<=Y+1; i++)
			for(int j=0; j<=X+1; j++)
				C[i][j] = 1;

		for(int i=1; i<=Y; i++)
			for(int j=1; j<=X; j++)
				cin >> C[i][j];

		for(int j=1; j<=X; j++)
			C[Y+1][j] = 0;

		int DP[17][17];
		for(int i=0; i<=Y+1; i++)
			for(int j=0; j<=X+1; j++)
				DP[i][j] = 0;

		for(int j=1; j<=X; j++)
			if(C[1][j]==0)
				DP[1][j] = 1;

		for(int i=1; i<=Y-1; i++)
			for(int j=1; j<=X; j++)
				if(C[i][j]==0){
					for(int k=j-1; k<=j+1; k++)
						if(C[i+1][k]==0){
							DP[i+1][k] += DP[i][j];
						}
						else if(C[i+1][k]==1){
							DP[i+1][k] = 0;
						}
						else if(C[i+1][k]==2){
							if(k==j)
								DP[i+1][k] += DP[i][j];
						}
				}
				else if(C[i][j]==1){
					DP[i][j] = 0;
				}
				else if(C[i][j]==2){
					if(C[i+2][j]==1)
						DP[i+2][j] = 0;
					else
						DP[i+2][j] += DP[i][j];
				}

		for(int j=1; j<=X; j++)
			if(C[Y][j]==1){
				DP[Y][j] = 0;
			}

		int sum = 0;
		for(int i=Y; i<=Y+1; i++)
			for(int j=1; j<=X; j++)
				sum += DP[i][j];

		cout << sum <<endl;
	}

	return 0;
}

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

const double PI = acos(-1);

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double th = double(h*60+m)/720 * 2*PI;
    double tm = double(m)/60 * 2*PI;
    double xh = a*cos(th), yh = a*sin(th);
    double xm = b*cos(tm), ym = b*sin(tm);
    double dx = xh -xm, dy = yh - ym;
    double ans = sqrt(dx*dx + dy*dy);
    printf("%.10f\n", ans); 
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll a,b,c,d; cin>>a>>b>>c>>d;
  
  ll ans=a*c;
  chmax(ans, a*d);
  chmax(ans, b*c);
  chmax(ans, b*d);
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int h,w,ch,cw,dh,dw;
    cin>>h>>w>>ch>>cw>>dh>>dw;
    ch--;
    cw--;
    dh--;
    dw--;
    vector<vector<char>> s(h,vector<char>(w));
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) cin>>s[i][j];
    
    vector<vector<ll>> dist(h,vector<ll>(w,1e9+100));

    deque<pair<int,int>> dq;
    dq.push_back(make_pair(ch,cw));
    dist[ch][cw] = 0;

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

    while(!dq.empty()){
        auto n = dq.front();
        dq.pop_front();

        if(n.first==dh && n.second==dw) break;

        for(int i=-2; i<=2; i++){
            for(int j=-2; j<=2; j++){
                int ny = n.first+i, nx = n.second+j;
                if(!i&&!j) continue;
                if(ny<0 || h<=ny || nx<0 || w<=nx) continue;
                if(s[ny][nx]=='#') continue;

                bool find = false;
                for(int k=0; k<4; k++){
                    if(i==dy[k] && j==dx[k]){
                        find = true;
                        if(dist[n.first][n.second] < dist[ny][nx]){
                            dist[ny][nx] = dist[n.first][n.second];
                            dq.push_front(make_pair(ny,nx));
                        }
                    }
                }
                if(find) continue;

                if(dist[n.first][n.second]+1 < dist[ny][nx]){
                    dist[ny][nx] = dist[n.first][n.second]+1;
                    dq.push_back(make_pair(ny,nx));
                }

            }
        }
    }
    ll ans = dist[dh][dw]==1e9+100 ? -1 : dist[dh][dw];
    cout<<ans<<endl;
}

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

int main()
{
    long int w,a,b;
    cin >>w>>a>>b;
    
    if(b>(a+w))
    cout << (b-(a+w));
    else if(a>(b+w))
    cout <<(a-(b+w));
    else
    cout <<"0";
    
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll X,Y;
    cin >> X >> Y;
    string out = "No";
    rep(i,X+1){
        if(Y==i*2+(X-i)*4){
            out = "Yes";
            break;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;

  vll cnt(n, 1);
  vll mark(n, 0);
  mark[0] = 1;
  rep(i, m) { ll x, y;
    cin >> x >> y;
    x--, y--;
    cnt[x]--, cnt[y]++;
    if (mark[x] == 1) mark[y] = 1;
    if (cnt[x] == 0) mark[x] = 0;
  }

  ll ans = accumulate(mark.begin(), mark.end(), 0);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4644
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
vector <ll> a;
int k,first=0,last=9;
int main(){
cin>>k;
for(int i=0;i<=8;i++) a.push_back(i+1);
if(k<=9)
   {  cout<<a[k-1];return 0; }
while(1)
{
   ll t=a[first];
   for(int i=-1;i<=1;i++)
   {
   	  if(t%10==0&&i==-1)continue;
   	  if(t%10==9&&i==1)continue;
   	  ll nt=t*10+t%10+i;
   	  a.push_back(nt);
   	  if(a.size()>=k)
   	    {  cout<<a[k-1];return 0; }
   }
 first++;
} 
return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  string aki[16]={"AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR","KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR","AKIHBR","KIHABR","KIHBAR","KIHBRA","KIHBR"};
  rep(i,16){
    if(s==aki[i]){cout<<"YES"<<endl;return 0;}
  }
  cout<<"NO"<<endl;
  

  return 0;
}


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


//bool memo[10][10][10];
int spx[10];
int spy[10];
int n;
bool flag = false;

/*
void init(){
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				memo[i][j][k] = false;
			}
		}
	}
}*/


bool spRange(int x, int y, int i){
	int dx[9] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 };
	int dy[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
	for (int j = 0; j < 9; j++)
		if (x == spx[i] + dx[j] && y == spy[i] + dy[j])	return true;
	return false;
}


void solve(int x, int y, int i){
	
	//cout << x << ' ' << y << ' ' << i << endl;
	if (i == n){
		flag = true;
		return;
	}

	int X;
	int Y;
	int dx[12] = { 2, 2, 1, 0, -1, -2, -2, -2, -1, 0, 1, 2 };
	int dy[12] = { 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -1 };
	for (int j = 0; j < 12; j++){
		X = x + dx[j];
		Y = y + dy[j];
		if ((0 <= X && X <= 9) && (0 <= Y && Y <= 9)){
			if (spRange(X, Y, i)) solve(X, Y, 1+i);
		}
	}
}


int main(){
	int px, py;

	while (cin >> px >> py, (px || py) != 0){
		cin >> n;
		for (int i = 0; i < n; i++){
			cin >> spx[i] >> spy[i];
		}
		//init();
		solve(px, py, 0);
		if (flag) cout << "OK" << endl;
		else cout << "NA" << endl;
		flag = false;
	}

	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
int main()
{
	SPEED
	int n, m, temp;
	cin >> n >> m;
	priority_queue <int> q;
	for (int i = 0; i < n; ++i)
	{
		cin >> temp;
		q.push(temp);
	}
	ll cost = 0;
	while(m--)
	{
		temp = q.top();
		q.pop();
		temp = temp/2;
		q.push(temp);
	}
	while(!q.empty())
	{
		temp = q.top();
		q.pop();
		cost += temp;
	}
	cout << cost;
	return 0;
}

Measured memory_bytes: 892
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

struct pt {
  double x, y;
  pt() {}
  pt(double nx, double ny) : x(nx), y(ny) {}
  pt operator + (const pt &o) { return pt(x + o.x, y + o.y); }
  pt operator - (const pt &o) { return pt(x - o.x, y - o.y); }
  pt operator * (double v) { return pt(x * v, y * v); }
  pt operator / (double v) { return pt(x / v, y / v); }
  pt ro() { return pt(-y, x); }
  double dot(const pt &o) { return x * o.x + y * o.y; }
  double cross(const pt &o) { return x * o.y - y * o.x; }
  double norm() { return sqrt((*this).dot(*this)); }
};

pt get(pt a, pt b, pt c, pt d) {
  double A1 = b.y - a.y;
  double B1 = a.x - b.x;
  double C1 = A1 * a.x + B1 * a.y;
  double A2 = d.y - c.y;
  double B2 = c.x - d.x;
  double C2 = A2 * c.x + B2 * c.y;
  double det = A1 * B2 - A2 * B1;
  return pt((B2 * C1 - B1 * C2) / det, (A1 * C2 - A2 * C1) / det);
}

int n;
pt p[59];

bool check(pt s, double r) {
  for (int i = 0; i < n; ++i) {
    if ((p[i] - s).norm() > r + 1e-10) {
      return false;
    }
  }
  return true;
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    p[i] = pt(x, y);
  }
  double ans = 1e18;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      pt s = (p[i] + p[j]) / 2;
      double r = (p[i] - p[j]).norm() / 2;
      if (check(s, r)) {
        ans = min(ans, r);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        if (fabs((p[j] - p[i]).cross(p[k] - p[i])) < 1e-10) {
          continue;
        }
        pt sj = (p[i] + p[j]) / 2;
        pt a = sj + (p[i] - sj).ro();
        pt b = sj + (p[j] - sj).ro();
        pt sk = (p[i] + p[k]) / 2;
        pt c = sk + (p[i] - sk).ro();
        pt d = sk + (p[k] - sk).ro();
        pt s = get(a, b, c, d);
        double r = (p[i] - s).norm();
        if (check(s, r)) {
          ans = min(ans, r);
        }
      }
    }
  }
  printf("%.15f\n", ans);
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

const int maxn = 1e5 + 5;
int n;
int a[maxn];

void solve() {
    cin >> n;
    map<int, int> hs;
    FOR(i, 0, n) {
        cin >> a[i];
        hs[a[i]]++;
    }
    long long ans = 0;
    FORall(it, hs) {
        if (it->se >= 4) {
            chkmax(ans, (long long) it->fi * it->fi);
        }
    }
    vi v;
    FORall(it, hs) if (it->se >= 2) {
        v.pb(it->fi);
    }
    sort(all(v), greater<int>());
    if (sz(v) >= 2) {
        chkmax(ans, (long long) v[0] * v[1]);
    }
    cout << ans << "\n";
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}

Measured memory_bytes: 5376
#include <stdio.h>
int main(){
	int n,k = 1;
	scanf("%d",&n);
	int a[n];
	for (int i = 0;i < n;i++)
		scanf("%d",&a[i]);
	for (int i = 0;i < n;i++){
	if(a[i] % 2 == 0){
	if ((a[i] % 3 != 0)&&(a[i] % 5 != 0)){
			k = 0;
			break;}
	}
	}
	if(k == 1) printf("APPROVED");
	else printf("DENIED");
}
		

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, floor
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(float, input().split())
def LIST(): return list(map(float, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np

A, V = MAP()
B, W = MAP()
T = INT()

if V <= W:
	print("NO")
	exit()

if T*(V-W) >= abs(B-A) :
	print("YES")
else:
	print("NO")

Measured memory_bytes: 10052
#include <stdio.h>
int main(void){
    // Here your code !
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(c>=a&&c<=b)
  {
      printf("Yes\n");
  }
  else
  {
      printf("No\n");
  }
    
    return 0;
    
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>

int main(){
    int N;
    std::string S;
    std::cin >> N >> S;
    
    std::vector< int > R;
    std::vector< int > G;
    std::vector< int > B;
    std::vector< int > index;
    
    for(int i=0; i<N; i++){
        if(S[i] == 'R'){
            index.push_back((int)R.size());
            R.push_back(i);
        }else if(S[i] == 'G'){
            index.push_back((int)G.size());
            G.push_back(i);
        }else{
            index.push_back((int)B.size());
            B.push_back(i);
        }
    }
    
    long long sum = 0;
    
    for(int i=0; i<N; i++){
        for(int j=i+1; j<N-1; j++){
            if(S[i] == S[j]){
                continue;
            }
            if(S[i] == 'R' && S[j] == 'G' || S[i] == 'G' && S[j] == 'R'){
                int k = j+1;
                while(k != N && S[k] != 'B'){ k++;}
                if(k == N){ continue;}
                int index_tmp = index[k];
                int cnt = B.size() - index_tmp;
                if(j + j - i < N && S[j + j - i] == 'B'){
                    cnt--;
                }
                sum += cnt;
            }
            if(S[i] == 'G' && S[j] == 'B' || S[i] == 'B' && S[j] == 'G'){
                int k = j+1;
                while(k != N && S[k] != 'R'){ k++;}
                if(k == N){ continue;}
                int index_tmp = index[k];
                int cnt = R.size() - index_tmp;
                if(j + j - i < N && S[j + j - i] == 'R'){
                    cnt--;
                }
                sum += cnt;
            }
            if(S[i] == 'B' && S[j] == 'R' || S[i] == 'R' && S[j] == 'B'){
                int k = j+1;
                while(k != N && S[k] != 'G'){ k++;}
                if(k == N){ continue;}
                int index_tmp = index[k];
                int cnt = G.size() - index_tmp;
                if(j + j - i < N && S[j + j - i] == 'G'){
                    cnt--;
                }
                sum += cnt;
            }
        }
    }
    
    
    std::cout << sum << std::endl;
    return 0;
}



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

using namespace std;

int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    if(K<=A)
    {
        cout << K << endl;
    }

    else if(K<=A+B)
    {
        cout << A << endl;
    }

    else
    {
         cout << A-(K-(A+B));
    }
}


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

int main(){
    vector<int> x{1,2,3,4,5};
    vector<int> y(5);
    rep(i,0,5) cin >> y[i];
    rep(i,0,5){
        if (find(y.begin(),y.end(),x[i])==y.end()){
            cout << x[i] << endl;
            break;
        }
    }    
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++)
    cin >> p[i];
  int max = 0;
  for (int i = 0; i < n; i++) {
    if(max < p[i]) {
      max = p[i];
    }
  }
  int sum = accumulate(p.begin(), p.end(), 0);
  sum -= max/2;
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
//pro player move
#define int LL

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline T re(){
	T N = 0; char c = getchar(); bool neg = 0;
	for (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';
	for (; c >= '0' && c <= '9'; c = getchar())
		N = (N<<3)+(N<<1) + c - '0';
	return neg ? -N : N;
}

const int mxsz = 1e5 + 3;
int n;
vi adj[mxsz];
int need[mxsz], a[mxsz];

inline void CANNOT(){
	puts("NO"); exit(0);
}
void dfs(int u, int prv = -1){
	int cur = 0, chld = 0;
	for (int nx : adj[u]){
		if (nx == prv) continue;
		dfs(nx, u);
		chld++;
		cur += need[nx];
		if (need[nx] > a[u]) CANNOT();
	}
//	cout << "WORK " << u << '\n';
	if (chld == 0){
		need[u] = a[u];
//		cout << need[u] << '\n' ;
		return;
	} else if (chld == 1){
		if (cur != a[u]) CANNOT();
		need[u] = cur;
		return;
	}
	int now = a[u];
	if (now > cur) CANNOT();
	int p = cur - now;
	int U = now - p;
	if (U < 0 || U > a[u]) CANNOT();
//	cout << now << ' ' << cur << ' ' <<  p << ' ' << U << '\n';
	need[u] = U;
//	cout << need[u] << '\n';
}
int32_t main(){
	n = re<int>();
	for (int i = 1; i <= n; i++){
		a[i] = re<int>();
	}
	for (int i = 1, x, y; i < n; i++){
		x = re<int>(); y = re<int>();
		adj[x].pb(y); adj[y].pb(x);
	}
	if (n == 1){
		if (a[1] == 0) puts("YES");
		else CANNOT();
		return 0;
	} else if (n == 2){
		if (a[1] == a[2]) puts("YES");
		else CANNOT();
		return 0;
	}
	int st = 1;
	while (adj[st].size() == 1) st++;
	dfs(st);
	if (need[st] == 0) puts("YES");
	else CANNOT();
	return 0;
}


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

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

  vector<int> a(3 * n);
  for (auto &u : a) cin >> u;

  sort(a.rbegin(), a.rend());

  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += a[2 * i + 1];
  }

  cout << ans << endl;
}


Measured memory_bytes: 1408
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<a*b-(c*b+d*a-c*d)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, t; cin >> n >> t;
	vector<int>a(n); 
	rep(i, n)cin >> a[i];
	vector<int>dp(n);
	rep(i, n) {
		dp[i] = INF;
	}
	dp[0] = a[0];
	rep(i, n) {
		if (i == 0)continue;
		dp[i] = min(dp[i - 1], a[i]);
	}
	vector<int>b(n); rep(i, n)b[i] = a[i] - dp[i];
	int maxb = 0;
	rep(i, n) {
		maxb = max(maxb, b[i]);
	}
	
	int ans = 0;
	rep(i, n) {
		if (maxb == b[i])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
fn main() {
    let mut board: Vec<Vec<(i32, bool)>> = (0..3).map(|_| read_vec::<i32>().into_iter().zip(vec![false; 3].into_iter()).collect() ).collect();
    let n = read::<i32>();
    let bn = (0..n).map(|_| read::<i32>()).collect::<Vec<i32>>();

    for b in bn.iter() {
        for i in 0..3 {
            for j in 0..3 {
                if board[i][j].0 == *b {
                    board[i][j].1 = true;
                }
            }
        }
    }

    let mut ans = false;
    for i in 0..3 {
        if (board[0][i].1 && board[1][i].1 && board[2][i].1) || (board[i][0].1 && board[i][1].1 && board[i][2].1) {
            ans = true;
        }
    }
    if board[0][0].1 && board[1][1].1 && board[2][2].1 || board[0][2].1 && board[1][1].1 && board[2][0].1 {
        ans = true;
    }

    println!("{}", if ans { "Yes" } else { "No" });
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4476
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int x = 0;
    scanf("%d", &x);

    if (x == 5 || x == 7 || x == 3) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}


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

int main()
{
    std::string S;
    std::cin >> S;
    int count = 0;
    int max = 0;
    for(int i=0; i<3; i++)
    {
        if(S[i]=='R')
        {
            count++;
        }
        else
        {
            count = 0;
        }

        if(max <= count)
            max = count;
    }

    std::cout << max << std::endl;
}

Measured memory_bytes: 3624
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
#include<math.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。



int main(){
      int n,m;
      cin>>n>>m;
      int l[m],r[m];
      int maxl=0;
      int minr=n;
      rep0(i,m){
            cin>>l[i]>>r[i];
            maxl=max(l[i],maxl);
            minr=min(r[i],minr);
      }
      cout<<max(0,minr-maxl+1)<<endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int N = NI();
		int W = NI();
		int item[][] = new int[N][2];
		for (int i = 0; i < N; i++) {
			item[i][0] = NI();
			item[i][1] = NI();
		}
		Arrays.sort(item, (a, b) -> a[0] != b[0] ? a[0] - b[0] : b[1] - a[1]);
		int id[] = new int[5];
		int pop = 1;
		for (int i = 1; i < N; i++) {
			if (item[i][0] != item[i-1][0]) {
				id[pop++] = i;
			}
		}
		id[pop++] = N;
		id = Arrays.copyOf(id, pop);
		long ans = search(item, id, 0, W);
		System.out.println(ans);
	}

	private static long search(int[][] item, int[] id, int k, int W) {
		if (k == id.length - 1) return 0;
		int sum = 0;
		int sumw = 0;
		long ans = search(item, id, k + 1, W);
		for (int i = id[k]; i < id[k + 1]; i++) {
			sumw += item[i][0];
			if (sumw <= W) {
				sum += item[i][1];
				ans = Math.max(sum + search(item, id, k + 1, W - sumw), ans);
			} else {
				break;
			}
		}
		
		return ans;
	}

	static int NI() {
		try {
			int c = System.in.read(), r = 0;
			for (; c != '-' && (c < '0' || '9' < c);) {
				c = System.in.read();
			}
			if (c == '-')
				return -NI();
			for (; '0' <= c && c <= '9'; c = System.in.read()) {
				r = r * 10 + c - '0';
			}
			return r;
		} catch (Exception e) {
			return -1;
		}
	}

	static String next() {
		try {
			StringBuilder res = new StringBuilder("");
			int c = System.in.read();
			while (Character.isWhitespace(c))
				c = System.in.read();
			do {
				res.append((char) c);
			} while (!Character.isWhitespace(c = System.in.read()));
			return res.toString();
		} catch (Exception e) {
			return null;
		}
	}
}


Measured memory_bytes: 26452
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const int inf=0x3fffffff;
const ll mod=1000000007;
const int maxn=1e5+100;
int a[maxn];
char s[maxn];
int n;
void output()
{
    rep(i,1,n+1)
    {
        if(a[i]==1) printf("S");
        else printf("W");
    }
    puts("");
}
bool same(int a,int b)
{
    return a==b;
}
bool diff(int a,int b)
{
    return a!=b;
}
bool ok(int p)
{
    int l=p==1? n:p-1,r=p==n? 1:p+1;
    if(a[p]==1)
    {
        if(s[p]=='o') return same(a[l],a[r]);
        else return diff(a[l],a[r]);
    }
    else
    {
        if(s[p]=='o') return diff(a[l],a[r]);
        else return same(a[l],a[r]);
    }
}
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    bool find=false;
    rep(p,1,3)
    {
        rep(q,1,3)
        {
            a[1]=p,a[2]=q;
            rep(i,3,n+1)
            {
                if(a[i-1]==1)
                {
                    if(s[i-1]=='o') a[i]=a[i-2];
                    else a[i]=3-a[i-2];
                }
                else
                {
                    if(s[i-1]=='x') a[i]=a[i-2];
                    else a[i]=3-a[i-2];
                }
            }
            if(ok(1)&&ok(n))
            {
                output();
                return 0;
            }
        }
    }
    puts("-1");
    return 0;
}












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

int main(){
	int n,k;
	cin>>n>>k;
	long long a,b,c,res=0,tmp=0;
	if(k%2==0){
		for(int i = k; i<=n;i+=k){
			res ++;
		}
		res = res*res*res;
		for(int i=k/2;i<=n;i+=k){
			tmp ++;
		}
		res += tmp*tmp*tmp;
	}else{
		for(int i = k;i<=n;i+=k){
			res ++;
		}
		res = res*res*res;
	}

	cout<<res<<endl;

}


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

using namespace std;

int main() {
	int n;

	while (cin >> n) {
		if (n == 0) {
			break;
		}
		vector< vector<char> > d(n, vector<char>(n));
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> d[i][j];
			}
		}
		vector< vector<int> > dd(n, vector<int>(n));
		int c = 0;
		for (int i = 0; i < n; i++) {
			int cc = 0;
			for (int j = n-1; j >= 0; j--) {
				if (d[i][j] == '.') {
					cc++;
				} else {
					cc = 0;
				}
				dd[i][j] = cc;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (dd[i][j] > c) {
					int ccc = dd[i][j];
					for (int k = 0; i+k < n; k++) {
						if (dd[i+k][j] <= c) {
							break;
						}
						ccc = min(ccc, dd[i+k][j]);
						if (ccc <= k+1) {
							c = max(c, ccc);
						}
					}
				}
			}
		}
		cout << c << endl;
	}

	return 0;
}

Measured memory_bytes: 6084
using System;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int i = int.Parse(Console.ReadLine()); i > 0; --i) {
                int item = int.Parse(Console.ReadLine());
                var block = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int prev = block[0];
                int up = 0, down = 0;
                for(int j = 1; j < item; ++j) {
                    up = Math.Min(up, prev - block[j]);
                    down = Math.Max(down, prev - block[j]);
                    prev = block[j];
                }
                Console.WriteLine("{0} {1}", -1 * up, down);
            }
        }
    }
}

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

int main()
{
  int n;
  cin>>n;
  int a[n];
  int sum =0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    sum += a[i];
  }
    int sum1 = 0;
    int mani = INT_MAX;

    for(int i=0;i<n;i++)
    {
        sum1+=a[i];
        sum -= a[i];
        if(abs(sum-sum1)<mani)
            mani = abs(sum - sum1);

        
    }
    cout<<mani<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <iomanip>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  int k;
  cin >> n >> k;

  vector<double> v(n);
  REP(i,n){
    v[i] = 1.0 / double(n);
  }

  REP(i,n){
    int tmp = i+1;
    while(tmp < k){
      tmp *= 2;
      v[i] *= 0.5;
    }
  }

  //cout << v[0] << endl;
  double ans = 0;
  REP(i,n){
    ans += v[i];
  }

  cout << setprecision(10) << ans << endl;
  return 0;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {
 	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] field = new char[h][];
		for (int i = 0; i < h; i++) {
		    field[i] = sc.next().toCharArray();
		}
		int[][] verCounts = new int[h][w];
		for (int i = 0; i < h; i++) {
		    if (field[i][0] == '.') {
		        verCounts[i][0] = 1;
		    }
		    for (int j = 1; j < w; j++) {
		        if (field[i][j] == '.') {
		            verCounts[i][j] = verCounts[i][j - 1] + 1;
		        }
		    }
		    for (int j = w - 2; j >= 0; j--) {
		        if (verCounts[i][j] != 0 && verCounts[i][j + 1] != 0) {
		            verCounts[i][j] = verCounts[i][j + 1];
		        }
		    }
		}
		int[][] horCounts = new int[h][w];
		for (int i = 0; i < w; i++) {
		    if (field[0][i] == '.') {
		        horCounts[0][i] = 1;
		    }
		    for (int j = 1; j < h; j++) {
		        if (field[j][i] == '.') {
		            horCounts[j][i] = horCounts[j - 1][i] + 1;
		        }
		    }
		    for (int j = h - 2; j >= 0; j--) {
		        if (horCounts[j][i] != 0 && horCounts[j + 1][i] != 0) {
		            horCounts[j][i] = horCounts[j + 1][i];
		        }
		    }
		}
		int max = 0;
		for (int i = 0; i < h; i++) {
		    for (int j = 0; j < w; j++) {
		        max = Math.max(max, verCounts[i][j] + horCounts[i][j] - 1);
		    }
		}
	    System.out.println(max);
   }
}




Measured memory_bytes: 68940
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    println!("{}", n * (n - 1) / 2);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

u64 N;
vector<u64> D;
u64 d;

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

    cin >> N;

    rep (i, N)
    {
        cin >> d;
        D.emplace_back(d);
    }

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

    u64 lower = D[(N >> 1) - 1];
    u64 higher = D[(N >> 1)];

    cout << higher - lower << "\n";

    return 0;
}



Measured memory_bytes: 1400
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
const ll maxN=2e5+5 , N=1e7+1;
ll n , a[N];
void pre(){
	for(ll i=1;i<N ;i++){
		for(ll j=i ; j<N ; j+=i){
			a[j]++;
		}
	}
}
void solve(){
	pre();cin>> n ;
	ll ans=0;
	for(ll i=1;i<=n ;i++){
		ans+=(i*a[i]);
	}
	cout<<ans<<endl;
}

int main(){
	// mahakal(),
	fast;
	ll t=1;
	// cin>>t ;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 81768