akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n, q, s, t;
int a[200000 + 5], diff[200000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> q >> s >> t;
    cin >> a[0];
    rep2(i, 1, n + 1) {
        cin >> a[i];
        diff[i] = a[i] - a[i - 1];
    }
    int ans = 0;
    rep2(i, 1, n + 1) {
        if (diff[i] >= 0) ans -= diff[i] * s;
        else ans += -diff[i] * t;
    }
    rep(i, q) {
        int l, r, x;
        cin >> l >> r >> x;
        if (diff[l] >= 0) ans += diff[l] * s;
        else ans -= -diff[l] * t;
        if (diff[r + 1] >= 0) ans += diff[r + 1] * s;
        else ans -= -diff[r + 1] * t;
        diff[l] += x;
        if (diff[l] >= 0) ans -= diff[l] * s;
        else ans += -diff[l] * t;
        if (r + 1 != n + 1) {
            diff[r + 1] -= x;
            if (diff[r + 1] >= 0) ans -= diff[r + 1] * s;
            else ans += -diff[r + 1] * t;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;


int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  VI iw(n), ib(n);
  for (int i = 0; i < 2 * n; i++) {
    char c; cin >> c;
    int a; cin >> a;
    a--;
    (c == 'W' ? iw[a] : ib[a]) = i;
  }

  VVI ww(n, VI(n + 1)), wb(n, VI(n + 1)), bw(n, VI(n + 1)), bb(n, VI(n + 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      ww[i][j + 1] = ww[i][j] + (iw[i] < iw[j]);
      wb[i][j + 1] = wb[i][j] + (iw[i] < ib[j]);
      bw[i][j + 1] = bw[i][j] + (ib[i] < iw[j]);
      bb[i][j + 1] = bb[i][j] + (ib[i] < ib[j]);
    }
  }

  VVI dp(n + 1, VI(n + 1));
  for (int i = 0; i < n; i++) {
    dp[i + 1][0] = dp[i][0] + ww[i][i];
    dp[0][i + 1] = dp[0][i] + bb[i][i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i + 1][j + 1] = min(dp[i][j + 1] + ww[i][i] + wb[i][j + 1], dp[i + 1][j] + bw[j][i + 1] + bb[j][j]);
    }
  }

  cout << dp[n][n] << '\n';
  return 0;
}

Measured memory_bytes: 78848
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  double a, b, c;
  double PI, deg, rad, S, L, h;
  cin >> a >> b >> deg;

  PI = acos(-1);
  rad = deg * PI/180;

  S = 0.5 * a * b * sin(rad);
  c = sqrt(a*a + b*b - 2*a*b*cos(rad));
  L = a + b + c;
  h = 2*S / a;

  printf("%lf\n%lf\n%lf\n", S, L, h);

  return 0;
}

Measured memory_bytes: 3532
# S = '0'
S = input()

def cnt_even(prev):
    global S
    cnt = 0

    for x, y in enumerate(list(S)):
        y = int(y)
        if prev == y:
            cnt += 1
            y = 1 if y == 0 else 0
        prev = y
    return cnt

A = cnt_even(0)
B = cnt_even(1)

print(min(A, B))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll a,b,c,d;
  cin >> a >> b >> c >> d;

  ll ans = max({a*c, a*d, b*c, b*d});
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll a, b, x;
    cin >> a >> b >> x;
    if(x == a * a * b){
        cout << 0 << endl;
        return 0;
    }
    if(2 * x == a * a * b){
        cout << 45 << endl;
        return 0;
    }
    double r;
    if(2 * x < a * a * b){
        r = acos(-1) * 0.5 - atan2(2.0 * x / (a * b), b);
        r = 180 * r / acos(-1);
    }
    if(2 * x > a * a * b){
        r = 180 * atan2(2.0 * (a * a * b - x) / (a * a), a) / acos(-1);
    }
    printf("%.10f\n", r);

    return 0;
}

Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
ll t=1;
vll_t a,b;
ll gcd(ll a,ll b){
	if(a==0){
		return b;
	}
	return gcd(b%a,a);
}
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	//scanf("%d",&t);
	while(t--){
		ll n;
		cin>>n;
		ll ans=0;
		for(ll i=0;i<n;i++){
			ll a;
			cin>>a;
			ans=gcd(ans,a);
		}
		cout<<ans<<endl;
		//cout<<1<<endl;
	}
}	

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

#define test(t) while(t--)

#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "

#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);



using namespace std;

void solve()
{ char c[3];
  for(ll i=0;i<3;i++)
     cin>>c[i];
  if(c[1] == 'B')
    out "ARC"<<en;
  else
    out"ABC"<<en;
}

int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }
return 0;}


Measured memory_bytes: 3652
import java.util.Arrays;import java.util.Scanner;public class Main {public static void main(String[]h){Scanner s=new Scanner(System.in);while(s.hasNext()){int n=s.nextInt();if(n==0){break;}int[] a=new int[n];for(int i=0;i<n;i++){a[i]=s.nextInt();}Arrays.sort(a);int o=0;for(int i=1;i<n-1;i++){o+=a[i];}System.out.println(o/(n-2));}}}

Measured memory_bytes: 21120
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
char proto[][19]={"%d%d%%c%d%%c%d%%c","%d%d%%c%d%d%%c%%c",
	"%d%d%d%%c%%c%d%%c","%d%d%d%%c%d%%c%%c","%d%d%d%d%%c%%c%%c"};
char op[]="+-*";

vector<int> stk;

string toInfix(char expr[]){
	vector<string> cstk;
	char c; char t[29];
	for(int i=0;c=expr[i];i++){
		if('0'<=c&&c<='9'){
			sprintf(t,"%c",c);
			cstk.push_back(t); continue;
		}
		int s=cstk.size();
		sprintf(t,"(%s %c %s)",cstk[s-2].c_str(),c,cstk[s-1].c_str());
		cstk.erase(cstk.end()-2,cstk.end());
		cstk.push_back(t);
	}
	return cstk[0];
}
int eval(char expr[]){
	stk.clear();
	char c;
	for(int i=0;c=expr[i];i++){
		if('0'<=c&&c<='9'){
			stk.push_back(c-'0'); continue;
		}
		int t,a=stk[stk.size()-2],b=stk[stk.size()-1];
		if(c=='+')t=a+b;
		if(c=='-')t=a-b;
		if(c=='*')t=a*b;
		stk.erase(stk.end()-2,stk.end());
		stk.push_back(t);
	}
	return stk[0];
}
int main(){
	int nm[4]; char expr[30],tmp[30];
	
	while(cin>>nm[0]>>nm[1]>>nm[2]>>nm[3],nm[0]){
		sort(nm,nm+4);
		do{
			rep(o1,3)rep(o2,3)rep(o3,3)rep(e,5){
				sprintf(tmp,proto[e],nm[3],nm[2],nm[1],nm[0]);
				sprintf(expr,tmp,op[o1],op[o2],op[o3]);
				if(eval(expr)==10){
					cout<<toInfix(expr)<<endl;
					goto NEXT;
				}
			}
		}while(next_permutation(nm,nm+4));
		cout<<0<<endl;
		NEXT:;
	}
	return 0;
}

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

int main() {
    ll X, Y;
    cin >> X >> Y;
    int len_max_seq = 0;
    ll cur_val = X;
    while (cur_val <= Y) {
        len_max_seq += 1;
        cur_val *= 2;
    }
    cout << len_max_seq << "\n";
}


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

int main() {
#define rep(i, n) for(int i = 2; i < (int)(n); i++)

  int N;
  cin>>N;
  vector<int64_t> L(N+1);
  L[0]=2;
  L[1]=1;
  rep(i,N+1){
    L[i]=L[i-1]+L[i-2];
  }
  cout<<L[N];
    
}

Measured memory_bytes: 256
import sys

#+++++
		
def main():
	a, b, c = map(int, input().split())
	ret=max(0, c-(a-b))
	print(ret)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>
#include<functional>
#include<algorithm>
#include<string>
 
using namespace std;
 
struct edge{int to,cost;};
typedef pair<int,int> P;
typedef pair<int,P> PP;

const int INF=1<<15;
 
int main(void)
{
    int n,m,l,k,a,h;
    while(cin>>n>>m>>l>>k>>a>>h,n){
        vector<vector<edge> > G(n);
        vector<int> cold(l);
        vector<vector<int> > memo(n,vector<int>(m+1,INF));
        priority_queue<PP,vector<PP>,greater<PP> > q;
        for(int i=0;i<l;i++) cin>>cold[i];
        for(int i=0;i<k;i++){
            int from,to,cost;
            cin>>from>>to>>cost;
            G[from].push_back(edge{to,cost});
            G[to].push_back(edge{from,cost});
        }
 
        memo[h][m]=0;
        q.push(PP(0,P(h,m)));
        while(!q.empty()){
            PP p=q.top(); q.pop();
            int cost=p.first;
            int from=p.second.first;
            int rest=p.second.second;
			
			if(memo[from][rest]<cost) continue;
			
            for(int i=0;i<G[from].size();i++){
                int to=G[from][i].to;
                int cost=G[from][i].cost;
                if(find(cold.begin(),cold.end(),from)!=cold.end()){
                    for(int j=0;j+rest<=m;j++){
                        if(rest-cost+j >= 0 && memo[to][rest-cost+j]>memo[from][rest]+cost+j){
                            memo[to][rest-cost+j]=memo[from][rest]+cost+j;
                            q.push(PP(memo[to][rest-cost+j],P(to,rest-cost+j)));  
                        }
                    }
                }else if(rest-cost >= 0 && memo[to][rest-cost]>memo[from][rest]+cost){
                            memo[to][rest-cost]=memo[from][rest]+cost;
                            q.push(PP(memo[to][rest-cost],P(to,rest-cost)));    
                }
            }
        }
 
        int res=INF;
        for(int i=0;i<=m;i++) res=min(res,memo[a][i]);
        if(res==INF) cout<<"Help!"<<endl;
        else cout<<res<<endl;
 
    }
 
    return 0;
}

Measured memory_bytes: 1584
#include<iostream>
#include<vector>
#include <cassert>
#include<algorithm>
#include <tuple>
#include <utility>
#include<string>
#include <functional>
#define ll long long
using namespace std;

typedef pair<int, int> pair;

ll A[15][15];
ll C[15];

int main(){
    int N,M,X;
    int ans = 1e9;
    cin >> N >> M >> X;
    for(int i = 0; i < N; i++){
        cin >> C[i];
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    int n = N;
    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit) {
        vector<int> Sum(15,0);
        ll tmp = 0;
        int f = 1;
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        // cout << bit << ": {";
        for (int i = 0; i < (int)S.size(); ++i) {
            // cout << S[i] << " ";
            for(int j=0; j < M;j++){
                Sum[j] += A[S[i]][j];
            }
            tmp += C[S[i]];
        }
        // cout << endl;
        for(int j=0; j < M;j++){
            if(Sum[j] < X) f = 0;
        }
        if(f == 1 && ans > tmp){
            ans = tmp;
            // cout << tmp;
        }
        // cout << endl;
    }
    if(ans == 1e9){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<climits>
#include<random>
using namespace std;
 
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;
 
/////////////////////////////////////////////
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
////////////////////////////////
 
#define int long long

const int mod = 1e9 + 7;
const int N = 1e5 + 6;

int dp[N][2];
vector<int> v[N];


// dp[s][1] tells us the number of ways if we color node s with white .
// dp[s][0] tells us the number of ways if we color node s with black .


void dfs(int s , int par = -1){

	dp[s][0] = dp[s][1] = 1;
	for(int it : v[s]){

		if(it==par)
			continue;
		dfs(it , s);

		dp[s][1]*=(dp[it][0] + dp[it][1]); // Doesn't matter white or black .
		dp[s][1]%=mod;
		dp[s][0]*=(dp[it][1]); // chidren node can only be white .
		dp[s][0]%=mod;
	}
}

void solve(){

	int n;
	cin>>n;

	for(int i = 1 ; i < n ; ++i){

		int x , y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	//int ans = 2;

	dfs(1);
	//debug(dp[1][0] , dp[1][1]);
	int ans = dp[1][0] + dp[1][1];
	ans%=mod;

	cout<<ans<<endl;
}
 
signed main(){
 
    fast;
    int t = 1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 17632
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    cities = [[] for _ in range(N)]
    for i in range(N):
        s, p = list(input().split())
        cities[i] = [i+1, s, int(p)]
    cities.sort(key=lambda x: (x[1], 100 - x[2]))
    for c in cities:
        print(c[0])

main()


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

#define  int        long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff             first
#define  ss             second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int power(int x, int y, int p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0; 
    while (y > 0)  
    {     
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res; 
}

int32_t main()
{
    fast
    int n,k;
    cin>>n>>k;
    int a[n+1];
    f(i,1,n)
        cin>>a[i];
    f(i,k+1,n)
    {
        if(a[i]>a[i-k])
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    
}

Measured memory_bytes: 5216
import itertools

n, m = map(int, input().split())

#繋がっている頂点リスト
a_list = []
for j in range(m) :
    a = list(map(int, input().split()))
    a_list.append(a)
a_list.sort()

#道順リスト(最初が1に限る)
b_list = [k for k in itertools.permutations([l for l in range(1, n + 1)]) if k[0] == 1]

#道順リストの中で頂点リストが含まれているもの
cnt = 0
for x in b_list :
    tf_list = []
    for y in range(n - 1) :
        tf_list.append([x[y], x[y + 1]] in a_list or [x[y + 1], x[y]] in a_list)
    
    if all(tf_list) == True :
        cnt += 1

print(cnt)

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

int main(){
  long long n;cin>>n;
  vector<bool> x(36,0);
    
  REP(i,35){
    long long btm=1,top=0,now=n%(long long)pow(2,i+1);
    if(now<0) now+=(long long)pow(2,i+1);
    for(int j=1;j<=i;j+=2) btm+=(long long)pow(2,j-1);      
    top=btm+(long long)pow(2,i)-1;    
    if((btm<=now)&&(now<=top)) x.at(i)=1;
  }

  bool one=0;
  if(!n) cout<<"0";
  else for(int i=35;i>=0;i--){
    if(one||x.at(i)){
      cout<<x.at(i);
      one=1;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
string a;   
bool v[2];

int main() {    
    cin >> a;
    for(int i = 0; i < a.length(); i ++) {
        if(a[i]=='C') v[0] = 1;
        if(a[i]=='F' && v[0]) {
        	printf("Yes\n");
        	return 0;
		}
    }
    printf("No\n");
}

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> x(m);
    rep(i, m) cin >> x[i];

    sort(x.begin(), x.end());
    vector<int> y(m-1);
    rep(i, m-1) y[i]=x[i+1]-x[i];
    sort(y.rbegin(), y.rend());
    int ans = 0;
    for (int i = n-1; i < m-1; i++) {
        ans += y[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(void){
  int p,q;
  int remain;
  while(cin >> p >> q){
	map<int, bool> m;
	map<int, int> digit;
	string str="";
	int i=0;
	bool loop=false;
	char tmp;
	remain = p%q;
	m[remain] = true;
	digit[0] = remain;
	remain *= 10;
	while(1){
	  tmp = remain / q + '0';
	  remain = remain % q;
	  //	  cout << "remain=" << remain << endl;
	  str += tmp;
	  if(remain == 0 || m[remain] == true) break;
	  digit[i+1] = remain;
	  m[remain] = true;
	  remain *= 10;
	  i++;
	}
	cout << str <<endl;
	if(remain == 0){
	  //do nothing
	}else{
	  for(int i=0;i<str.size();i++){
		if(digit[i] == remain) loop = true;
		if(!loop){
		  cout << " ";
		}else{
		  cout << "^";
		}
	  }
	  cout << endl;
	}
  }
}

Measured memory_bytes: 0
#include <cstdio>

int main(){
    int a,b,c,x;
    scanf("%d %d %d %d",&a,&b,&c,&x);
    int count = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(500 * i + 100 * j + 50 * k == x){
                    count++;
                }
            }
        }
    }
    printf("%d\n",count);
    
    return 0;
}

Measured memory_bytes: 256
// problem: "https://atcoder.jp/contests/abc157/tasks/abc157_e"

#include<bits/stdc++.h>

using namespace std;

void updateST(vector<vector<bool>>&ST,int t,char c1,char c2,int i,int j,int p)
{
    // c1 - old
    // c2 - new

    if(i == j)
    {
        ST[p][c1-'a'] = 0;
        ST[p][c2-'a'] = 1;
        return ;
    }

    int m = (i+j)/2;

    if(t <= m)
        updateST(ST,t,c1,c2,i,m,2*p);
    else
        updateST(ST,t,c1,c2,m+1,j,2*p+1);

    ST[p][c1-'a'] = ST[2*p][c1-'a'] || ST[2*p+1][c1-'a'];
    ST[p][c2-'a'] = ST[2*p][c2-'a'] || ST[2*p+1][c2-'a'];

    return ;
}

void findST(vector<vector<bool>>&ST,int l,int r,int i,int j,int p,vector<bool>&V)
{
    if(l == i && r == j)
    {
        int k;
        for(k=0;k!=26;k++)
            V[k] = V[k] || ST[p][k];

        return ;
    }

    int m = (i+j)/2;

    if(r <= m)
        findST(ST,l,r,i,m,2*p,V);
    else if(l > m)
        findST(ST,l,r,m+1,j,2*p+1,V);
    else
    {
        findST(ST,l,m,i,m,2*p,V);
        findST(ST,m+1,r,m+1,j,2*p+1,V);
    }

    return ;
}

void printST(vector<vector<bool>>&ST,int n)
{
    int k,x;
    for(k=1;k!=2*n;k++)
    {
        cout<<k<<'\n';
        for(x=0;x!=26;x++)
            cout<<ST[k][x]<<' ';

        cout<<'\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    string s;

    cin>>n>>s;

    int k;
    vector<vector<bool>>ST(4*n,vector<bool>(26,false));
    for(k=0;k!=n;k++)
        updateST(ST,k,'a',s[k],0,n-1,1);        // define


    int q;
    cin>>q;

    while(q--)
    {
        int j;
        cin>>j;

        if(j == 1)
        {
            int i;
            char c2,c1;
            cin>>i>>c2;

            // c1 - old character
            // c2 - new character
            i--;
            c1 = s[i];
            s[i] = c2;

            updateST(ST,i,c1,c2,0,n-1,1);       // define

            // cout<<s<<'\n';
            // printST(ST,n);
        }
        else
        {
            int l,r;
            cin>>l>>r;

            l--;
            r--;
            vector<bool>V(26,false);
            findST(ST,l,r,0,n-1,1,V);     // define

            int t,c=0;
            for(t=0;t!=26;t++)
                if(V[t])
                    c++;

            cout<<c<<'\n';
        }
    }

    return 0;
}


Measured memory_bytes: 141468
from fractions import gcd
MOD=(10**9)+7
n=int(input())
a=list(map(int,input().split()))
a_lcm=a[-1]

for ai in a:
    a_lcm=(a_lcm*ai) // gcd(a_lcm, ai)

sum_b=0
for ai in a:
    bi=a_lcm//ai
    sum_b+=bi
print(sum_b%MOD)

Measured memory_bytes: 6112
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define gap ' '
#define abs(x) ((x)>0?(x):-(x))
#define INF 1e18
#define mod  998244353
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
       cin>>a[i];
    ll dp[n]={0};
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        int t1=dp[i-1]+abs(a[i-1]-a[i]);
        int t2=dp[i-2]+abs(a[i-2]-a[i]);
        dp[i]+=min(t1,t2);
    }
    cout<<dp[n-1];

}


Measured memory_bytes: 1408
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int t = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            out.println((t - a) % b);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21588
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,ch[100010];ll a[100010];
ll dp0,dp1,dp2;
int main(){
	n=read();int i;char c;
	for(i=1;i<=n;i++){
		a[i]=read();
		if(i==n) break;
		c=getchar();
		while(c!='+'&&c!='-') c=getchar();
		ch[i+1]=(c=='-');
//		cout<<"finish readin "<<i<<' '<<a[i]<<' '<<ch[i+1]<<'\n';
	}
	dp0=0;dp1=dp2=-1e15;
	for(i=1;i<=n;i++){
		if(ch[i]){
			dp0-=a[i];
			dp1+=a[i];
			dp2-=a[i];
			if(dp1>dp2) dp2=dp1;
			if(dp0>dp2) dp1=dp0;
		}
		else{
			dp0+=a[i];
			dp1-=a[i];
			dp2+=a[i];
		}
		if(dp2>dp1) dp1=dp2;
		if(dp1>dp0) dp0=dp1;
	}
	cout<<dp0<<'\n';
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1);
    vector<int> ans(N+1, 0);
    for (int i = 1; i < N + 1;i++)
        cin >> A[i];
    int cnt = 0;
    for (int i = N; i > 0;i--){
        int tmp = 0;
        for (int k = 1; k * i < N+1;k++)
            tmp += ans[k * i];

        if(tmp % 2 != A[i]){
            ans[i] = 1;
            cnt++;
        }
    }
    cout << cnt << endl;
    vector<int> Ans(cnt);
    int x = 0;
    for (int i = 1; i < N + 1;i++){
        if(ans[i] == 1){
            Ans[x] = i;
            x++;
        }
    }
    for (int i = 0; i < cnt;i++)
        cout << Ans[i] << " ";
    cout << endl;
    return 0;
}

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

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

    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = 0;
    ll mod = 1e9+7;
    ll ret = 0;
    ll f=1;
    ll inv[n]={};
    inv[1]=1;
    for(int i=1;i<n;i++){
        f *= i;
        f%=mod;
        if(i>=2)inv[i] = mod - inv[mod%i] * (mod/i) %mod;
    }
    for(int i=1;i<n;i++){
        ret += f*inv[i];
        ret %= mod;
        ans += (a[i]-a[i-1]) * ret;
        ans %= mod;
    }
    cout << ans << endl;
}

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

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {

	int len;
	string T,ans;
	cin >> T;
	


	len = T.length();

	ans = "";

	for (int i = 0; i < len; i++) {
		if (T[i] == 'P') {
			ans.push_back('P');
		}
		else {
			ans.push_back('D');
		}
	}
	
	

	cout << ans << endl;

	cin >> ans;

	return 0;


}

Measured memory_bytes: 3924
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	list := getStdinIntArr64()
	N := list[0]
	var base int64 = 'z' - 'a' + 1

	n := N - 1

	str := ""
	for {
		mod := n % base
		str2 := fmt.Sprintf("%c", 'a'+mod)
		str = str2 + str

		n /= base
		if n == 0 {
			break
		}
		n--
	}
	fmt.Printf("%s\n", str)

}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2156
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define rint register int
#define rep(i,l,r) for(rint i=l;i<=r;i++)
#define per(i,l,r) for(rint i=l;i>=r;i--)
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back 
#define fir first
#define sec second
template<typename T1,typename T2>void ckmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2>void ckmax(T1 &a,T2 b){if(a<b)a=b;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
int read(){
  int x=0,f=0;
  char ch=getchar();
  while(!isdigit(ch))f|=ch=='-',ch=getchar();
  while(isdigit(ch))x=10*x+ch-'0',ch=getchar();
  return f?-x:x;
}
int x;
int main(){
  x=read();
  puts(x>=30?"Yes":"No");
  return 0;
} 

Measured memory_bytes: 3624
fn main() {
    let (w, h, x, y) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let mut i = s.split_whitespace().map(|e| e.parse::<f64>().unwrap());
        (i.next().unwrap(), i.next().unwrap(), i.next().unwrap(), i.next().unwrap())
    };

    let ok = if x + x == w && y + y == h {
        1
    } else {
        0
    };

    println!("{} {}", w * h / 2f64, ok);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >> D;
  vector<int> C(26);
   for (int i = 0; i < 26; i++) {
    cin >> C.at(i);
  }
  vector<vector<int>> S(365, vector<int>(26));
  for (int i = 0; i < 365; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> S.at(i).at(j);
    }
  }
  for (int i = 0; i < 365; i++) {
    int memo = 0;
    int ans = 0;
    for (int j = 0; j < 26; j++) {
      if (S.at(i).at(j) > memo) {
        memo = S.at(i).at(j);
        ans = j + 1;
      }
    }
    cout << ans << endl; 
  }
}

Measured memory_bytes: 3680
using System;

namespace ITP1_3_D
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] inputs = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(inputs[0]);
            int b = Convert.ToInt32(inputs[1]);
            int c = Convert.ToInt32(inputs[2]);

            int cnt = 0;

            for(int i = a; i <= b; i++)
            {
                if (c % i == 0) cnt++;
            }

            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 20000
#include <stdio.h>
long long int max(long long int x, long long int y){
    /*
    if(x>=y)
        return x;
    else 
        return y;
    */
    { return x>y ? x:y ;}
}
int main (){
    long long int m,a,b,c,d;
    scanf("%lld %lld %lld %lld", &a,&b,&c,&d);

    printf("%lld\n", max( max(a*c, a*d), max(b*c,b*d) ));
    

    return 0;
}

Measured memory_bytes: 1732
from collections import deque

N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(N+M-1):
    u, v = map(int, input().split())
    adjL[u-1].append(v-1)
    indegs[v-1] += 1

parents = [-1] * N
Q = deque([v for v in range(N) if indegs[v] == 0])
while Q:
    vNow = Q.popleft()
    for v2 in adjL[vNow]:
        parents[v2] = vNow
        indegs[v2] -= 1
        if indegs[v2] == 0:
            Q.append(v2)

for v in range(N):
    print(parents[v] + 1)


Measured memory_bytes: 20768
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rep3(var, min, max) for (ll (var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll (var) = (max) - 1; (var) + 1 > (min); --(var))
#define Mp(a,b) make_pair((a),(b))
#define F first
#define S second
#define Icin(s) ll (s);cin>>(s);
#define Scin(s) ll (s);cin>>(s);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF =1e18;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    V vec(n+1);
    rep(i,m){
        int x,y;
        cin>>x>>y;
       // x--;y--;
        vec[x]++;
        vec[y]--;
    }
    rep(i,n){
        vec[i+1]+=vec[i];
    }
    rep3(i,1,n){
        if(vec[i]%2!=0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


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

int main() {
	string n;
	cin>>n;
	int sm=0;
	for(int i=0;i<n.length();i++)
	{
	    int dg=n[i]-'0';
	    sm+=dg;
	    sm%=9;
	}
	if(sm)  cout<<"No"<<endl;
	else    cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll a,b;cin>>a>>b;
    if(a==b)cout<<"a == b"<<endl;
    else if(a<b)cout<<"a < b"<<endl;
    else cout<<"a > b"<<endl;
}

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



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


int main(void) {
  int A, B, X;
  cin >> A >> B >> X;

  int c = X - A;
  if (c >= 0 && c <= B) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	char s[5];
	while(cin>>s){
		int ans=700;
		for(int i=0;i<3;++i){
			if(s[i]=='o'){
				ans+=100;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N=int(input())

str_list = input().split(' ')
A = [int(x) for x in str_list]
A = np.array(A)
total = A.sum()
prod = A.prod()
#print( prod/( (prod/A).sum() ) )
print( 1.0/np.sum(1.0/A) )

Measured memory_bytes: 12444
#include <stdio.h>

int main ()
{
 
 	int i;
 	int a, b;
 	scanf("%d %d", &a, &b);
 	
	char str [a + b +1];
 	scanf("%s", &str);

 	int ans = 0;
 	
	for(i = 0; i<a+b+1; i++)
 	{
  		if (i != a) 
  		{
  		
			if (str[i]>='0' && str[i]<='9')
			{
  			 	ans++;
  			}
 		
		}
 		
		else if (str[i] == '-')
		{
 			 ans++;
 		}
 	}
 	
	if (ans == a + b + 1)
	{
  		printf("Yes");
 	} 
 	
	 else 
	 {
  		printf("No");
	 }
 
 return 0;
}

Measured memory_bytes: 1736
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())

n = n-1

ans = (1+n)*n//2

print(ans)
# print("{:.10f}".format(ans))


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

int main(){
    int n,m,cN,cM,cT;
    cin >> n >> m;
    if(n>1){
        cN=(n*(n-1))/2;
    }else{cN=0;}
    if(m>1){
        cM=(m*(m-1))/2;
    }else{cM=0;}
    cT=cN+cM;
    cout << cT << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    vector <int> w(n);
    for(int i=0;i<n;i++){
        cin>>w[i];
    }
    int ans = 1e9;
    for(int i=1;i<=n;i++){
    int ue=0, shita=0;
    for(int j=0;j<n;j++){
        if(j<=i) shita+= w[j];
        else ue += w[j];
        }
        ans = min(ans, abs(shita-ue));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N, K;
    cin >> N >> K;
    int a = N / K;
    int b = N / (K / 2) - a;
    if (K % 2 == 0)
        cout << b * b * b + a * a * a << endl;
    else
        cout << a * a * a << endl;
   // system("pause");
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"fmt"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	a := nextInt()
	b := nextInt()
	h := nextInt()
	fmt.Println((a + b) * h / 2)
}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
#define M 1000000007 
using namespace std;
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int nlcm(vector<int> numbers) {
    int res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}
int main() { 
    vector<int> v;
    int n, m; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> m;
        v.push_back(m);
    }
    cout << nlcm(v) << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define rep(i,n) REP(i,0,n)
#define REP(i, k, n) for (int(i) = k; (i) <(int)(n); (i)++)
#define vi vector<int>
#define pii pair<int,int>

using ll = long long;

using namespace std;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;

    ll ansa = max(0LL, a - c);

    if(a-c < 0){
        b = max(0LL, b+a-c);
    }

    cout << ansa << " " <<b<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=200200;
bool f[N];
int n,m;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=1;i<=m;++i)
    {
        int x,y;
        cin>>x>>y;
        if(x>y) swap(x,y);
        if(x==1)
            if(f[y])
            {
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
            else
                f[y]=true;
        if(y==n)
            if(f[x])
            {
                cout<<"POSSIBLE"<<endl;
                return 0;
            }
            else
                f[x]=true;
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int ans = 0;
  int curMin = 1e9;
  rep(i,n) {
    curMin = min(curMin, p[i]);
    if (curMin == p[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> L(n);
    rep(i,n) cin >> L[i];
    vector<int> D(n+1);
    for(int i=1;i<n+1;i++){
        D[i]=D[i-1]+L[i-1];
    }
    int ans=0;
    for(int i=0;i<n+1;i++){
        if(D[i]<=x) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
int main() {
	int n, a[100002], sum = 0;
	scanf("%d", &n);
	a[0] = a[n + 1] = 0;
	for (int i = 1; i <= n + 1; i++) {
		if (i != n + 1) scanf("%d", &a[i]);
		sum += abs(a[i] - a[i - 1]);
	}
	for (int i = 1; i <= n; i++) {
		printf("%d\n", sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) +
						   abs(a[i + 1] - a[i - 1]));
	}
	return 0;
}

Measured memory_bytes: 1536
x = input()
x_len = len(x)

x_1 = x[0:(x_len-1)//2]
x_2 = x[(x_len+2)//2:]

if x == x[::-1] and x_1 == x_1[::-1] and x_2 == x_2[::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
N=int(input())
hlist=list(map(int,input().split()))

hlist[0]-=1
for i in range(1,N):
  if hlist[i-1]<hlist[i]:
    hlist[i]-=1
    
#print(hlist)
for i in range(N-1):
  if hlist[i]>hlist[i+1]:
    print("No")
    break
else:
  print("Yes")

Measured memory_bytes: 14252
#include<stdio.h>
int flg[1000000];
int main(void)
{
	int n,i,j,cnt;
	while(scanf("%d",&n)!=EOF){
		cnt=0;
		for(i=2;i<=n;i++){
			flg[i]=0;
		}
		for(i=2;i*i<=n;i++){
//			printf("%d\n",i);
			if(flg[i]!=2){
				flg[i]=0;
				for(j=2;j*i<=n;j++){
					flg[j*i]=2;
				}
			}
		}
		for(i=2;i<=n;i++){
			if(flg[i]==0){
				cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 4500
n,m = map(int, input().split())
from collections import defaultdict

inc=[0]*n
out=defaultdict(list)
link = [[] for _ in range(n)]
for i in range(n-1+m):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    inc[b]+=1
    out[a].append(b)
    link[a].append(b)

s=[]
for i in range(len(inc)):
    if inc[i]==0:
        s.append(i)

res=[]
ans=[-1]*n
ans[s[0]]=0

while s:
    n=s.pop()
    res.append(n)
    for m in out[n]:
        inc[m]-=1
        if inc[m]==0:
            ans[m]=n+1
            s.append(m)

for a in ans:
    print(a)

Measured memory_bytes: 85152
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n, p, k, count;
	vector<int> num(1000000, 1);
	while(cin>>n){
		count=0;
		num[0]=0; num[1]=0;
		for(int i=4; i<=n; i+=2){
		num[i]=0;
		}
		for(int i=0; i<=n; i++){
			p = i+i+3;
			for(k=p+p; k<=n; k+=p){
				num[k]=0;
			}
		}
		for(int i=0; i<=n; i++){
			if(num[i]==1)
				count++;
		}
		cout<<count<<endl;
	}
	return 0;
}


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

class LCA{
public:
	vector<vector<pair<int,int>>>E;
	vector<vector<int>>par;
	vector<int>d1;
	vector<long long>d2;
	const int MAX_LOG=22;
	int n;
	LCA(int N){
		n=N;
		E=vector<vector<pair<int,int>>>(n);
		par=vector<vector<int>>(MAX_LOG,vector<int>(n));
		d1=vector<int>(n);
		d2=vector<long long>(n);
	}
	void add_edge(int a,int b,int c){
		E[a].push_back(make_pair(c,b));
		E[b].push_back(make_pair(c,a));
	}
	void add_edge(int a,int b){
		E[a].push_back(make_pair(1,b));
		E[b].push_back(make_pair(1,a));
	}
private:
	void dfs(int u,int p,int a,long long b){
		par[0][u]=p;d1[u]=a;d2[u]=b;
		for(auto&v:E[u]){
			if(v.second!=p)dfs(v.second,u,a+1,b+v.first);
		}
	}
	bool flag=false;
	void init(){
		dfs(0,-1,0,0);
		for(int i=1;i<MAX_LOG;i++)for(int j=0;j<n;j++){
			if(par[i-1][j]==-1)par[i][j]=-1;
			else par[i][j]=par[i-1][par[i-1][j]];
		}
		flag=true;
	}
public:
	int lca(int u,int v){
		if(!flag)init();
		if(d1[u]>d1[v])swap(u,v);
		for(int i=0;i<MAX_LOG;i++){
			if((d1[v]-d1[u])>>i&1)v=par[i][v];
		}
		if(u==v)return u;
		for(int i=MAX_LOG-1;i>=0;i--){
			if(par[i][u]!=par[i][v]){
				u=par[i][u];
				v=par[i][v];
			}
		}
		return par[0][u];
	}
	long long dist(int u,int v){
		int l=lca(u,v);
		return d2[u]+d2[v]-d2[l]*2;
	}
};
int main(){
	int n;scanf("%d",&n);
	LCA G(n);
	rep(i,n-1){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);a--;b--;
		G.add_edge(a,b,c);
	}
	int q,k;scanf("%d%d",&q,&k);k--;
	rep(i,q){
		int x,y;scanf("%d%d",&x,&y);x--;y--;
		printf("%lld\n",G.dist(x,k)+G.dist(k,y));
	}
}

Measured memory_bytes: 20728
// problem: "https://atcoder.jp/contests/abc126/tasks/abc126_b"

#include<iostream>
#include<string>

using namespace std;

string check(string &s)
{
    string s1 = s.substr(0,2);
    string s2 = s.substr(2,2);

    if(stoi(s1)<=12 && stoi(s1)>0 && stoi(s2)<=12 && stoi(s2)>0)
        return "AMBIGUOUS";

    else if(stoi(s1)<=12 && stoi(s1)>0)
        return "MMYY";

    else if(stoi(s2)<=12 && stoi(s2)>0)
        return "YYMM";

    return "NA";
}

int main()
{
    string s;
    cin>>s;

    cout<<check(s);

    return 0;
}


Measured memory_bytes: 256
#coding: utf-8
N = int(input())
h = list(map(int, input().split()))
cnt = 1
for i in range(1, N):
    tmp = 0
    for j in range(i+1):
        if h[j] > h[i]:
            tmp += 1
    if tmp == 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  ll A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
  return 0;
}


Measured memory_bytes: 3648