akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
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);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int x = 1;
            while (x * 2 <= n) x *= 2;

            out.println(x);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21588
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;

#define rep(i,x) for(ll i = 0 ; i < x ; i ++)
#define rep1(i,x) for(ll i = 1 ; i <= x ; i ++)
#define rrep(i,x) for(ll i = x-1 ; i >= 0 ; i --)
#define rrep1(i,x) for(ll i = x ; i > 0 ; i --)
#define sor(vec) sort(vec.begin(),vec.end())
#define rev(vec) reverse(vec.begin(),vec.end())
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(min(a,b),c)
#define max_3(a,b,c) max(max(a,b),c)
#define mp1(a,b,c) P1(a,P(b,c))
#define fr first
#define sc second
#define pb push_back

const ll INF = 1000000000000000000;
const ll dir_4[4][2] = { {1,0} , {0,1} , {-1,0} , {0,-1} };

ll siz;
ll seg[2][400010];

void init(ll n){
	siz = 1;
	while(siz < n)siz *= 2;
	rep(i,siz*2-1){
		seg[0][i] = -INF;
		seg[1][i] = 0;
	}
}

ll query(ll k){
	ll sum = 0;
	k += siz-1;
	ll ret = seg[0][k];
	while(k > 0){
		k = (k-1)/2;
		ret = max ( ret + seg[1][k] , seg[0][k] );
	}
	return ret;
}

void maxi(ll a,ll b,ll x,ll k,ll l,ll r){
	if(b <= l || r <= a)return;
	if(a <= l && r <= b){
		seg[0][k] = max ( seg[0][k] , x );
		return;
	}
	maxi(a,b,x-seg[1][k],2*k+1,l,(l+r)/2);
	maxi(a,b,x-seg[1][k],2*k+2,(l+r)/2,r);
}

void add(ll a,ll b,ll x,ll k,ll l,ll r){
	if(b <= l || r <= a)return;
	if(a <= l && r <= b){
		seg[0][k] += x;
		seg[1][k] += x;
		return;
	}
	add(a,b,x,2*k+1,l,(l+r)/2);
	add(a,b,x,2*k+2,(l+r)/2,r);
}

void updata(ll k,ll x){
	add(k,k+1,x-query(k),0,0,siz);
}

int main(){
	ll n,h;
	static ll c[100010],d[100010];
	
	scanf("%lld%lld",&n,&h);
	rep1(i,n-1){
		scanf("%lld%lld",&c[i],&d[i]);
	}
	
	init(n+10);
	updata(0,h);
	c[0] = 0;
	
	priority_queue<P> que;
	ll ret = 0;
	
	rep1(i,n-1){
		updata(i,query(i-1)-c[i-1]);
		que.push( P ( d[i] , i ) );
		ll t = c[i] - query(i) + 1;
		while(t > 0){
			P p = que.top(); que.pop();
			ll s1 = (t+p.fr-1)/p.fr;
			ll s2 = (h-query(p.sc))/p.fr;
			if(s1 < s2){
				maxi(0,p.sc,query(p.sc)+p.fr*s1,0,0,siz);
				add(p.sc,siz,p.fr*s1,0,0,siz);
				t -= p.fr*s1;
				ret += s1;
				que.push(p);
			}
			else {
				maxi(0,p.sc,query(p.sc)+p.fr*s2,0,0,siz);
				add(p.sc,siz,p.fr*s2,0,0,siz);
				t -= p.fr*s2;
				ret += s2;
				que.push( P ( h-query(p.sc) , p.sc ) );
			}
		}
	}
	
	printf("%lld\n",ret);
				
}

Measured memory_bytes: 10784
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	vector<int> x(5, 0);
	int ans = -1;
	for (int i = 0; i < x.size(); i++) {
		cin >> x[i];
		if (x[i] == 0) {
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 1000000000000000000
#define mod 1000000007
#define MAX 5005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
lint P[MAX],C[MAX],Cy[MAX],Cysum[MAX],Cylen[MAX],Cymax[MAX][MAX];
void dfs(lint u,lint id){
    Cy[u]=id;
    Cylen[id]++;
    Cysum[id]+=C[u];
    if(!Cy[P[u]]) dfs(P[u],id);
}
void dfs2(lint u,lint l,lint sum){
    lint id=Cy[u];
    sum+=C[u];
    Cymax[id][l]=max(Cymax[id][l],sum);
    if(l<Cylen[id]) dfs2(P[u],l+1,sum);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint n,k;
    cin>>n>>k;
    for(lint i=1;i<=n;i++) cin>>P[i];
    for(lint i=1;i<=n;i++) cin>>C[i];
    lint id=0;
    for(lint i=1;i<=n;i++){
        if(!Cy[i]){
            id++;
            dfs(i,id);
        }
    }
    for(lint i=1;i<=id;i++){
        for(lint j=0;j<=Cylen[i];j++){
            Cymax[i][j]=-inf;
        }
    }
    for(lint i=1;i<=n;i++){
        dfs2(i,1,0);
    }
    lint ans=-inf;
    for(lint i=1;i<=id;i++){
     //   cout<<Cysum[i]<<' '<<Cylen[i]<<endl;
        if(k<=Cylen[i]){
            for(lint j=1;j<=k;j++){
                ans=max(ans,Cymax[i][j]);
            }
        }
        else if(Cysum[i]<=0){
            for(lint j=1;j<=Cylen[i];j++){
                ans=max(ans,Cymax[i][j]);
            }
        }
        else{
            lint sm1=-inf;
            for(lint j=1;j<=Cylen[i];j++){
                sm1=max(sm1,Cymax[i][j]);
            }
            lint sm2=-inf,en=k%Cylen[i];
            for(lint j=1;j<=en;j++){
                sm2=max(sm2,Cymax[i][j]);
            }
            lint tims=k/Cylen[i];
         //   cout<<tims<<' '<<sm1<<' '<<sm2<<endl;
            ans=max(ans,(tims-1)*Cysum[i]+sm1);
            ans=max(ans,tims*Cysum[i]+sm2);
        }
    }
    cout<<ans;
    return 0;
}
/*
10 58
9 1 6 7 8 4 3 2 10 5
695279662 988782657 -119067776 382975538 -151885171 -177220596 -169777795 37619092 389386780 980092719
*/


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

int n;
string s;
int cnt=0;

int main(){
	cin>>n>>s;
	string str=s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='(') break;
		else  str='('+str;
	}
	s=str;
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]==')') break;
		else str+=')';
	}
	s=str;
	str=s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='(') cnt++;
		if(s[i]==')') cnt--;
		if(cnt<0){
			cnt=0;
			str='('+str;
		}
	}
	s=str;
	for(int i=0;i<cnt;i++) s+=')';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

typedef long long ll;
#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int func(int x){
	if(x % 100 != 0) return 0;
	return func(x / 100) + 1;
}

int main(){
	ll D, N;
	cin >> D >> N;

	int count = 0;
	for(int i = 1; ; ++i){
		if(func(i) == D){
			count++;
			if(count == N){
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=300005;
int a[maxn],f[maxn];
int n;
int ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
		f[i]=i;
	for(int i=n;i>=1;i--){
		if(a[i]<=a[i-1])
			f[i-1]=f[i];
	}
	for(int i=1;i<=n;i++){
		ans=max(ans,f[i]-i);
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 1024
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve() {
  int n;
  cin >> n;
  double d;
  cin >> d;
  int count = 0;
  for(int i = 0; i < n; i++) {
    double x, y;
    cin >> x >> y;
    double dst = sqrt((x*x)+(y*y));
    if(dst <= d)
      count++;
  }
  cout << count << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(10);
  int t = 1;
  // cin >> t;
  for(int tt = 1; tt <= t; tt++) {
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 3836
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in(gcu());}
_sc(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
//_sc(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename H,typename... T> _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
template <typename T>
_vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
//_vo(string &s){for (char c: s) pcu(c);}
template <typename H,typename... T> _vo(H&& h, T&&... t){out(h);out(move(t)...);}
//template <typename T> _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
_vl(){out('\n');}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	int n = in();
	vector<int> v;
	while (n--) {
		switch (in()) {
		case 0:
			v.push_back(in());
			break;
		case 1:
			outl(v[in()]);
			break;
		default:
			v.pop_back();
		}
	}
}


Measured memory_bytes: 3320
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		double x,h,c,s,ans;
		while(true){
			x=sc.nextDouble();
			h=sc.nextDouble();
			if(x==0 && h==0) break;
			c=Math.sqrt(h*h+(x/2)*(x/2));
			s=c*x*2;
			ans=s+x*x;
			System.out.printf("%.6f\n",ans);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>

using namespace std;

template<class T> inline void chmin(T &x, const T &y) {if (x > y) x = y;}

int n;
long long sum_dp[410][410], cost_dp[410][410];

int main()
{
  cin >> n;
  for (int l = 0; l < n; l++) {
    cin >> sum_dp[l][l+1];
  }

  for (int l = n-2; l >= 0; l--) {
    for (int r = l+2; r <= n; r++) {
      cost_dp[l][r] = 1LL << 62;
      for (int k = l+1; k < r; k++) {
        if (cost_dp[l][r] > sum_dp[l][k] + sum_dp[k][r]
            + cost_dp[l][k] + cost_dp[k][r]) {
          sum_dp[l][r] = sum_dp[l][k] + sum_dp[k][r];
          cost_dp[l][r] = sum_dp[l][k] + sum_dp[k][r]
            + cost_dp[l][k] + cost_dp[k][r];
        }
      }
    }
  }
  
  cout << cost_dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 2816
import math
from functools import reduce
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
def hcf(l):
    return reduce(math.gcd, l)
gcd = hcf(A)
m = max(A)
if k%gcd == 0 and k<=m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 20444
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}

int main(){
    int n,i,t;
    long long res;
    const int LENGTH = 10;
    string tmp;
    vector<string> s;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> tmp;
        s.push_back(tmp);
    }
    for(i=0;i<n;i++){
        tmp = s[i];
        sort(tmp.begin(), tmp.end());
        s[i] = tmp;
    }
    sort(s.begin(), s.end());
    t=0;
    res = 0;
    for(i=1;i<n;i++){
        if(s[i-1]==s[i]) t++;
        else t=0;
        res += t;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>N;
    reps(a,1,200){
        reps(b,-200,a){
            ll d = a - b;
            if(N%d == 0){
                A = ll(a);
                B = ll(b);
                if(N/d == A*A*A*A + A*A*A*B + A*A*B*B + A*B*B*B + B*B*B*B){
                    cout<<a<<' '<<b<<endl;
                    return 0;
                }
            }
        }
    }
}

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

using namespace std;

using int64 = long long;

constexpr int DEBUG = 1;

struct Edge {
  int from, to, w;
};

int fls(int x) {
  int count = 0;
  while (x > 0) {
    x /= 2;
    count++;
  }
  return count;
}

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

  int l;
  cin >> l;
  int n = fls(l);

  vector<Edge> edges;
  for (int i = 0; i < n - 1; i++) {
    edges.push_back(Edge({i + 1, i, 0}));
    edges.push_back(Edge({i + 1, i, 1 << i}));
  }


  int current = 1 << (n - 1);
  int r = l - (1 << (n - 1));
  while (r > 0) {
    int v = fls(r) - 1;
    edges.push_back(Edge({n - 1, v, current}));
    current += 1 << v;
    r -= 1 << v;
  }

  cout << n << " " << edges.size() << endl;
  for (const auto& edge : edges) {
    int output_from = n - edge.from;
    int output_to = n - edge.to;
    cout << output_from << " " << output_to << " " << edge.w << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
#define F first
#define S second

int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

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

    int n,k; cin >> n >> k;
    vint b(n); rep(i,n) cin >> b[i];

    int res=INF;
    for(int bit=0; bit<(1<<n); bit++){
        vint a=b;
        int tmp=0;
        map<int,bool> vis;
        //if(!bit&(1<<0)) continue;
        //if(!bit&(1<<(n))) continue;
        //if(bit<pow(2,n-1)) continue;
        if(__builtin_popcount(bit)<k) continue;
        rep(i,n){
            if(bit&(1<<i)){
                vis[(n-1)-i]=true;
                
            }   
        }
       
        int tallest=a[0];
        FOR(i,1,n){
            if(vis[i]==true && a[i]<=tallest){
                tmp+=tallest-a[i]+1;
                a[i]=tallest+1;
            }
            chmax(tallest,a[i]);
        }
        
        chmin(res,tmp);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main()
{
	int N;

	cin >> N;

	std::vector<int> a(N);
	std::vector<int> M(N);

	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		M[i] = 0;
	}

	int ball_cnt = 0;
	for (int i = N; 1 <= i; i--)
	{
		int bai_idx = i * 2;
		int cnt = 0;
		while (bai_idx <= N)
		{
			if (M[bai_idx - 1] == 1)
			{
				cnt++;
			}

			bai_idx += i;
		}



		if (a[i-1] == 0)
		{
			{
				if (cnt%2 == 0)
				{
					M[i - 1] = 0;
				}
				else
				{
					M[i - 1] = 1;
					ball_cnt++;
				}
			}
		}
		else
		{

			{
				if (cnt%2 == 0)
				{
					M[i - 1] = 1;
					ball_cnt++;
				}
				else
				{
					M[i - 1] = 0;
				}
			}
		}
	}

	if (0 < ball_cnt)
	{
		cout << ball_cnt << endl;
		for (int i = 0; i < N; ++i)
		{
			if (M[i] == 1)
			{
				cout << i + 1 << " ";
			}
		}
	}
	else
	{
		cout << 0;
	}


	return 0;
}


Measured memory_bytes: 2432
/*huzaifa242 copyright*/
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535897932384626
#define mod 1000000007
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifdef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);  
    #endif
    int n,i;
    cin>>n;
    int a[n],h[n];
    for(i=0;i<n;i++)
    {
    	cin>>h[i];
    	if(i==0)
    	a[i]=0;
    	else if(i==1)
    	a[i]=abs(h[i]-h[0]);
    	else
    	a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<a[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

type Diff struct {
	from, to, diff int
}

type ByDiff []Diff

func (a ByDiff) Len() int           { return len(a) }
func (a ByDiff) Less(i, j int) bool { return a[i].diff > a[j].diff }
func (a ByDiff) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	N, M := sc.nextInt(), sc.nextInt()
	X := sc.nextIntSlice(M)
	if N >= M {
		fmt.Println(0)
		return
	}
	sort.Ints(X)
	D := make([]Diff, M-1)
	for i := 0; i < M-1; i++ {
		D[i] = Diff{X[i], X[i+1], abs(X[i] - X[i+1])}
	}
	sort.Sort(ByDiff(D))
	koma := make([]int, N)
	koma[0] = X[0]
	j := 0
	for i := 1; i < N; i++ {
		koma[i] = D[j].to
		j++
	}
	sort.Ints(koma)
	ans := 0
	idx := 1
	for i := 1; i < M; i++ {
		if idx < N && X[i] == koma[idx] {
			idx++
		} else {
			ans += abs(X[i] - X[i-1])
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5120
#include<iostream>
using namespace std;
int main(){
string s;
  int i,ans=0;
  cin >> s;
  for(i=0;i < s.size();i++){
  ans+=(s[i]-'0');
  }
  if(ans%9==0){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,l,q;
ll x[500005],y[500005],z[500005];
ll dp[5][200005];
char s[500005],t[500005];
bool flag,dame;

ll  fact[400005];
ll rfact[400005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<400000; i++){
        fact[i] = (fact[i-1]*i) % mod;
        rfact[i] = rui(fact[i],mod - 2);
    }
}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;
}


int main(){
    cin >> b >> w;
	c3_init();
	for(i=0;i<b+w;i++){
		if(i == 0){
			dp[1][i] = 1;
			y[i] = 500000004ll;
			p(500000004);
		}else{
			if(i == b){
				dp[0][i] = 1;
			}else if(i > b){
				dp[0][i] = dp[0][i-1] * 2 + c3(i-1,i-b);
			}else{
				dp[0][i] = 0;
			}
			if(i == w){
				dp[2][i] = 1;
			}else if(i > w){
				dp[2][i] = dp[2][i-1] * 2 + c3(i-1,i-w);
			}else{
				dp[2][i] = 0;
			}
			dp[1][i] = (dp[0][i-1] + dp[1][i-1] + dp[2][i-1]) * 2
				+ (mod - dp[0][i]) + (mod - dp[2][i]);


			dp[0][i] %= mod;
			dp[1][i] %= mod;
			dp[2][i] %= mod;
			//pe(i);
			//p(dp[1][i] + 2 * dp[2][i]);
			y[i] = y[i-1] * 500000004ll;
			y[i] %= mod;
			ans = (((dp[1][i] + 2 * dp[2][i]) % mod) * y[i])%mod;
			p(ans);
		}
	}


	return 0;
}

Measured memory_bytes: 42112
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    string s;
    cin >> s;

    set<char> set;
    REP(i, s.size()) {
        set.insert(s[i]);
    }

    bool hasN = set.count('N') > 0;
    bool hasS = set.count('S') > 0;
    bool hasE = set.count('E') > 0;
    bool hasW = set.count('W') > 0;

    if (hasN ^ hasS) {
        cout << "No" << endl;
        return 0;
    }
    if (hasE ^ hasW) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

typedef long long ll;
ll x[50];
ll dp[51][51][2510];

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

	ll N, A;
	cin >> N >> A;

	dp[0][0][0] = 1;
	for(int i = 0; i < N; i++) {
		ll x;
		cin >> x;
		for(int j = 0; j < N; j++) {
			for(int k = 0; k <= 2500; k++) {
				dp[i + 1][j + 1][k + x] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}

	ll ans = 0;
	for(int j = 1; j <= N; j++) {
		for(int k = 1; k <= 2500; k++) {
			if(A * j == k) {
				ans += dp[N][j][k];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 50304
import java.util.Scanner;

public class Main  {

	public static  void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int k = sc.nextInt();
	String s = sc.next();
		
			if(s.length() <= k) {
				System.out.println(s);
			}else {
				s = s.substring(0 , k);
				System.out.print(s + "...");
			}

	}

}


Measured memory_bytes: 27096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;cin>>n>>k;
    vector<pair<ll,ll>> ab(n);
    rep(i,n) cin>>ab[i].first>>ab[i].second;
    sort(all(ab));
    ll tmp = 0;
    for(auto a : ab){
        tmp+=a.second;
        if(tmp>=k){
            cout<<a.first<<endl;
            return 0;
        }
    }
    return 0;

}

Measured memory_bytes: 1792
#include <cstdio>
int N, E, head[100001], next[199999], to[199999], f[100001], q[100001], fa[100001];
int main()
{
	scanf("%d", &N);
	for (int i = 1, u, v; i < N; i++)
	{
		scanf("%d%d", &u, &v);
		next[++E] = head[u], to[E] = v, head[u] = E;
		next[++E] = head[v], to[E] = u, head[v] = E;
	}
	int H = 0, T = 1, u;
	q[1] = 1;
	while (H < T)
		for (int e = head[u = q[++H]]; e; e = next[e])
			if (to[e] != fa[u])
				fa[q[++T] = to[e]] = u;
	for (int i = N; i; i--)
	{
		int u = q[i], count = 0;
		for (int e = head[u]; e; e = next[e])
			if (to[e] != fa[u])
				count += f[to[e]];
		if (count > 1)
		{
			puts("First");
			return 0;
		}
		f[u] = !count;
	}
	puts(f[1] ? "First" : "Second");
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int n, t, a;
    int h[1005] = {};
    double num = 1e9+1;
    int ans = 0;
    cin >> n >> t >> a;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
        double tmp = (double)t - (double)h[i] * 0.006;
        // cout << tmp <<endl;
        if (fabs(tmp - (double)a) < (double)num)
        {
            num = fabs(tmp - (double)a);
            ans = i;
        }
    }
    cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int a,b;
  cin >> a >> b;
  if(a <= 0 && 0 <= b) {
    cout << "Zero" << endl;
    return 0;
  }
  if(a < 0) {
    int d = b - a;
    if(d%2==0) {
      cout << "Negative" << endl;
    } else {
      cout << "Positive" << endl;
    }
  } else {
    cout << "Positive" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(x,y) for(ll i=x;i<y;i++)
#define vll vector<ll>
#define sll set<ll>
#define pb push_back
#define in insert
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define MOD 1000000007
#define all(x) x.begin(),x.end()
#define tc ll t;cin>>t;while(t--)
#define rev(x) reverse(all(x))
#define low_str(x) transform(all(x),x.begin(),::tolower)
#define up_str(x) transform(all(x),x.begin(),::toupper)
#define to_digit(c) c-'0';
int main()
{
string s; cin >> s;
if(s[0] == 'R')
{
    if(s[1] == 'R')
    {
        if(s[2] == 'R')
            cout << 3 << endl;
        else
        {
            cout << 2 << endl;
        }
    }
    else
    {
        cout << 1 << endl;
    }
}
else if(s[1] == 'R')
{
    if(s[2] == 'R')
    cout << 2 << endl;
    else
    {
        cout << 1 << endl;
    }
}
else if(s[2] == 'R')
{
    cout << 1 << endl;
}
else
{
    cout << 0 << endl;
}


return 0;
}

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

int main(){
  int n;
  cin >> n;
  map<int, bool> mp;
  int a;
  for ( int i = 0; i < n; i++){
    cin >> a;
    mp[a] = !mp[a];
  }

  int ans = 0;
  for ( map<int, bool>::iterator it = mp.begin(); it != mp.end(); it++){
    ans += it->second;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
  map<int, int> mp;
int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0; i<n; i++)cin>>v[i],mp[v[i]]++;
  int ans = 0;
  for(int i = 0; i<n; i++){
    int f = 1;
    mp[v[i]]--;
    for(int j = 1; j*j<=v[i]; j++) {
      if(v[i]%j == 0 and (mp[j] or mp[v[i]/j])){
        f = 0;
        break;
      }
      
    } 
    mp[v[i]]++;
    ans += f;
  } 
  cout<<ans<<endl;
  return 0;
} 

Measured memory_bytes: 33040
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int n, a, b, c, d, i, op1, op2, op3;
  scanf("%d", &n);
  a=(n/1000)%10;
  b=(n/100 )%10;
  c=(n/10  )%10;
  d=(n/1   )%10;
  
  for(i=0;i<8;i++){
    op1=((i>>2)%2)?1:-1;
    op2=((i>>1)%2)?1:-1;
    op3=((i>>0)%2)?1:-1;
    if(a+(op1)*b+(op2)*c+(op3)*d==7){
      printf("%d%c%d%c%d%c%d=7\n", a,
                                   op1==1?'+':'-',
                                   b,
                                   op2==1?'+':'-',
                                   c,
                                   op3==1?'+':'-',
                                   d);
      break;
    }
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const double EPS  = 1e-10;
const bool debug = 0;
//-----------------------------------//

struct UnionFind {
	vector<int> par, rank;
	UnionFind() {}
	UnionFind(int n) {
		par.resize(n);
		rank.resize(n);
		REP(i, n) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	int operator[] (int x) {
		return find(x);
	}
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (rank[x] > rank[y]) swap(x, y);
		par[x] = y;
		if (rank[x] == rank[y]) rank[y]++;
	}
};

int N, M;
int g[700][700];
vector<int> nog[700];
int col[700];
UnionFind uf;
bool done[700], dp[701][701];

bool bin_col(int u, int c) {
	col[u] = c;
	REP(i, nog[u].size()) {
		int v = nog[u][i];
		if (col[v] == 0) {
			uf.unite(u, v);
			if (!bin_col(v, -c)) return false;
		}
		else {
			if (col[v] == col[u]) return false;
		}
	}
	return true;
}

int main() {
	cin >> N >> M;
	REP(i, M) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		g[a][b] = g[b][a] = 1;
	}
	REP(i, N) g[i][i] = 1;

	REP(i, N) REP(j, N) if (!g[i][j]) nog[i].push_back(j);

	uf = UnionFind(N);
	REP(i, N) if (col[i] == 0) {
		if (!bin_col(i, 1)) {
			puts("-1");
			return 0;
		}
	}

	vector<pii> v;
	REP(i, N) if (!done[i]) {
		pii cur(0, 0);
		REP(j, N) if (uf[i] == uf[j]) {
			done[j] = true;
			if (col[i] == col[j]) cur.fi++;
			else cur.se++;
		}
		v.push_back(cur);
	}

	dp[0][0] = 1;
	REP(i, v.size()) {
		REP(j, N + 1) if (dp[i][j]) {
			dp[i + 1][j + v[i].fi] = true;
			dp[i + 1][j + v[i].se] = true;
		}
	}

	int ans = INF;
	REP(i, N + 1) if (dp[v.size()][i]) {
		int x = i, y = N - i;
		chmin(ans, max(x*(x-1)/2, 0) + max(y*(y-1)/2, 0));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	int i;
	for(i=0;i<s.length()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout<<"no"<<endl;
			return 0;
		}
	}
	cout<<"yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FIO;
    long long n,s=0,i;
    cin>>n;
    if(n&1)
    {
        cout<<0<<endl;
        return 0;
    }
    n/=2;
    while(n>=5)
    {
        s+=(n/5);
        n/=5;
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int cnt1=0,cnt2=0,n=(int)s.size();
for(int i=0;i<n;i++){
    if(i%2==0){
        if(s[i]!='1')cnt1++;
        if(s[i]!='0')cnt2++;
    }
    else {
        if(s[i]!='1')cnt2++;
        if(s[i]!='0')cnt1++;
    }
}
cout<<min(cnt1,cnt2);
return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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


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

    string S1, S2, S3;
    cin >> S1 >> S2 >> S3;
    
    string S;
    S += S1[0];
    S += S2[1];
    S += S3[2];    
    
    cout << S << endl;

    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

long long int INF = 1e18;
using namespace std;

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

int main(){
	
	int n;
	cin >> n;
	
	int A[2000];
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	
	int ans = 0;
	
	for(int i = 0; i < n; i++){
		int minj = i;
		for(int j = i; j < n; j++){
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		if(A[i] != A[minj]){
			ans++;
			swap(A[i], A[minj]);
		}
	}
	
	sort(A, A + n);
	for(int i = 0; i < n - 1; i++){
		cout << A[i] << " ";
	}
	cout << A[n - 1] << endl;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
const ll inf = INT_MAX;

int main(void){
  const string correct = "CODEFESTIVAL2016";
  string in;
  cin >> in;
  int ans = 0;
  REP(i, in.size()) {
    if (in[i] != correct[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 10


int main(){

    int ch[200002];
    int N,C; cin >> N >> C;
    int s[100000], t[100000], c[100000];
    REP(i,N){
        cin >> s[i] >> t[i] >> c[i];
    }

    REP(i,200002) ch[i] = 0;

    int temp[200002];

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

        REP(j,200002) temp[j] = 0;


        REP(j,N){
            if(c[j]==i){
                temp[s[j]*2-1]++;
                temp[t[j]*2]--;
            }
        }

        for(int j=1; j<200002; ++j) temp[j] += temp[j-1];

        for(int j=0; j<200002; ++j){
            if(temp[j]==1){
                ch[j]++;
            };
        }
    }

    int ans = 0;
    REP(i, 200002){
        if(ans<ch[i]){
            ans = ch[i];
        }
    }

    cout << ans << endl;



    return 0;

}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.nextLine();
        char[] c = s.toCharArray();
        boolean isWhite = false;

        int count = 0;
        if (c[0] == 'W')
            isWhite = true;

        for (int i = 1; i < c.length; i++) {
            if (isWhite && c[i] == 'B') {
                count++;
                isWhite = !isWhite;
            } else if (!isWhite && c[i] == 'W') {
                count++;
                isWhite = !isWhite;
            }
        }

        System.out.println(count);
        sc.close();
    }
}

Measured memory_bytes: 26436
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]

n=i1()
a=[]
e=0
for i in range(n):
    a.append(i2())
    e+=sum(a[-1])
d=[x[:] for x in a]
dd=[x[:] for x in a]
c=0
for i in range(n):
    for j in range(n):
      for k in range(n):
        if a[j][k]>d[j][i] + d[i][k]:
            c=-1
        elif a[j][k]==d[j][i] + d[i][k] and d[j][i]>0 and d[i][k]>0:
            dd[j][k]=0
        d[j][k] = min(d[j][k], d[j][i] + d[i][k])
if c<0:
    print(-1)
else:
    s=0
    for i in range(n):
        for j in range(i,n):
           s+=dd[i][j]
    print(s)

Measured memory_bytes: 47708
A = int(input())
B = int(input())
C = int(input())
X = int(input())
answer = 0
for i in range(A+1) :
    for j in range(B+1) :
        for k in range(C+1) :
            if X == i*500+j*100+k*50 :
                answer += 1
print(answer)



Measured memory_bytes: 3060
a = [list(map(int, input().split())) for _ in range(3)]
c = [[False for j in range(3)] for i in range(3)]
n = int(input())
ans = False

for k in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                c[i][j] = True

for i in range(3):
    flag1 = 1
    flag2 = 1
    for j in range(3):
        flag1 *= c[i][j]
        flag2 *= c[j][i]
    if flag1 or flag2:
        ans = True
        break

if not ans:
    flag1 = 1
    flag2 = 1
    for i in range(3):
        flag1 *= c[i][i]
        flag2 *= c[i][2 - i]
    if flag1 or flag2:
        ans = True

if ans:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-


def main():
    n, m, q = map(int, input().split())
    lr = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
    c = [[0 for _ in range(n + 1)] for _ in range(n + 1)]

    for _ in range(m):
        li, ri = map(int, input().split())
        lr[li][ri] += 1

    for i in range(n + 1):
        for j in range(n + 1):
            c[i][j] = c[i][j - 1] + lr[i][j]

    ans = list()

    for _ in range(q):
        pi, qi = map(int, input().split())
        count = 0

        for i in range(pi, qi + 1):
            count += c[i][qi] - c[i][pi - 1]

        ans.append(count)

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78424
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());

		int sum = 0;

		if(b <= a){
			if(c <= a){
				sum = a*10 + b + c;
			}else{
				sum	= c*10 + b + a;
			}
		}else{
			if(c <= b){
				sum = b*10 + a + c;
			}else{
				sum	= c*10 + b + a;
			}
		}

			System.out.println(sum);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
int a[100];
int main() {
  int n; cin >> n;
  for (auto i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int aScore = 0;
  int bScore = 0;
  for (auto i = n - 1; i >= 0; i--) {
    if ((n - i) % 2 == 1) aScore += a[i];
    else bScore += a[i];
  }
  cout << aScore - bScore << endl;
}

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


string S, T, U;
int A, B;


void input() {
    cin >> S >> T >> A >> B >> U;
}


int main() {
    input();
    if (S == U) A--;
    else B--;
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int (i) = (int)a; (i) < (int)b;(i)++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;



int main(){
    int N,K;
    cin >> N >> K;
    vector<char> ten = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
    map<char, int> D;
    rep(i,10){
        D[ten[i]] = 0;
    }
    rep(i,K){
        char d;
        cin >> d;
        D[d] = 1;
    }
    int x = 1;
    N--;
    while(x){
        N++;
        x = 0;
        string S = to_string(N);
        rep(i,S.size()){
            if (D[S[i]]==1){
                x = 1;
                break;
            }
        }
    }
    cout << N << endl;
}


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

const int MAXN = 300005;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	if (A+B <= N+1 && (long long)A*B >= N) {
		int cur = 0;
		while (N-cur-B > A-1) {
			for (int i = B; i >= 1; i--)
				printf("%d ", cur+i);
			cur += B;
			A--;
		}
		int t = N-cur-A+1;
		// cerr << cur << "," << t << endl;
		for (int i = t; i >= 1; i--)
			printf("%d ", cur+i);
		cur += t;
		for (int i = cur+1; i <= N; i++)
			printf("%d ", i);
		puts("");
	} else puts("-1");
	return 0;
}


Measured memory_bytes: 2176
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;

#define         rep(i,n)       for ( i=0 ; i<n ; i++ )
#define         rep1(i,n)      for ( i=1 ; i<=n ; i++ )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rev(str)       reverse(str.begin(),str.end())
#define         usajo(str)     sort(str.rbegin(),str.rend())
#define         pi             2*acos(0.0)
#define         nel            printf("\n")
#define         longmx         92233720368547758
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pb             push_back
#define         prl            pair< ll , ll >
#define         mkp(x,y)       make_pair(x,y)
#define         ff             first
#define         ss             second
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef         long long int  lli;
typedef         long long      ll;

int main(){Faysal

    ll ans,sum,tot,cnt,mx,mn,idx,chk,rem,ret,tmp,mid,lft,rgt,pos;

    ll tc,n,m,a,b,c,d,g,h,l,r,x,y,i,j,k;

    cin>>n;
    vector<ll>v;
    rep(i,n)
    {
        cin>>x;
        if(x&1) continue;
        v.push_back(x);
    }
    rep(i,v.size())
    {
        if(v[i]%3==0 || v[i]%5==0) continue;
        else {printf("DENIED\n");
                return 0;}
    }
    printf("APPROVED\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
   	#endif
    int a,b,c;
    cin>>a>>b>>c;
    if(a*b>=c) cout<<c;
    else cout<<a*b;
   return 0;
}

Measured memory_bytes: 3636
#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define ALL(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
const int N=1000+10;
int main(){
	ll n,m;
	cin>>n>>m;
	if (n==1&&m==1) cout<<1<<endl;
	else if (n==1&&m!=1) cout<<m-2<<endl;
	else if (n!=1&&m==1) cout<<n-2<<endl; 
	else cout<<n*m-n*2-m*2+4<<endl;
    return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<bool> flag(10,true);
  vector<int> ok;
  rep(i,k){
    int d;
    cin>>d;
    flag[d]=false;
  }
  rep(i,10){
    if(flag[i]) ok.push_back(i);
  }
  int ans=1e9;
  rep(o,10-k) rep(i,10-k) rep(j,10-k) rep(l,10-k) rep(m,10-k){
    if(ok[o]*10000+ok[i]*1000+ok[j]*100+ok[l]*10+ok[m]>=n) {
      ans=min(ans,ok[o]*10000+ok[i]*1000+ok[j]*100+ok[l]*10+ok[m]);
    }
    if(ok[i]*1000+ok[j]*100+ok[l]*10+ok[m]>=n) {
      ans=min(ans,ok[i]*1000+ok[j]*100+ok[l]*10+ok[m]);
    }
    if(ok[j]*100+ok[l]*10+ok[m]>=n) {
      ans=min(ans,ok[j]*100+ok[l]*10+ok[m]);
    }
    if(ok[l]*10+ok[m]>=n) {
      ans=min(ans,ok[l]*10+ok[m]);
    }
    if(ok[m]>=n) {
      ans=min(ans,ok[m]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

const int maxN = 1e5 + 10;


int main(){
    float d, t, s;
    cin >> d >> t >> s;
    if(d/s <= t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3716