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

using Matrix = std::vector<std::string>;

int count(int h, int w, const Matrix& m, int rows_value, int columns_value)
{
  int result = 0;
  for (int row = 0; row < h; ++row) {
    if (rows_value & (1 << row)) continue;
    for (int col = 0; col < w; ++col) {
      if (columns_value & (1 << col)) continue;
      if (m.at(row).at(col) == '#') ++result;
    }
  }
  return result;
}

int solve(int h, int w, int k, const Matrix& m)
{
  int result = 0;
  for (int i = 0; i < 1 << h; ++i) {
    for (int j = 0; j < 1 << w; ++j) {
      if (count(h, w, m, i, j) == k) {
        ++result;
      }
    }
  }
  return result;
}

int main()
{
  int h, w, k;
  std::cin >> h >> w >> k;
  Matrix m(h);
  for (int row = 0; row < h; ++row) {
    std::cin >> m.at(row);
  }

  std::cout << std::setprecision(20);
  std::cout << solve(h, w, k, m) << std::endl;
}


Measured memory_bytes: 3624
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod = 1e9+7;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[r]);}

var g, child, parent;
function main(){
  var n = o.a();
  var a = o.m(n-1);
  child = xArray(0,n);
  parent = Array(n);
  g = xArray("[]",n);
  for(var i = 0; i < n-1; i++){
    var u = a[i][0]-1, v = a[i][1]-1;
    g[u].push(v);
    g[v].push(u);
  }
  dfs(0,-1);
  var p2 = Array(n+1);
  p2[0] = 1;
  for(var i = 1; i <= n; i++){
    p2[i] = p2[i-1]*2%mod;
  }
  var ans = 0;
  for(var i = 0; i < n; i++){
    //if(child[i] === 0)continue;
    ans += p2[n-1]-1;
    for(var v of g[i]){
      if(child[v] > child[i])ans -= p2[n-child[i]-1] - 1;
      else ans -= p2[child[v]+1] - 1;
    }
  }
  ans %= mod;
  if(ans < 0)ans += mod;
  return mul(ans,inv(p2[n]));
}
function dfs(v,p){
  parent[v] = p;
  for(var i of g[v]){
    if(i === p)continue;
    dfs(i,v);
    child[v] += child[i]+1;
  }
}

if (process.argv.length <= 2) require("child_process").fork("Main.js", ["1"], { execArgv: ["--stack-size=240000"] });
else {
  console.log(main());
}

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

int main()
{
	int N, X;
	cin >> N >> X;
	vector<int> M(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> M[i];
		sum += M[i];
	}
	sort(M.begin(), M.end());
	int ans = (X - sum) / M[0];
	cout << N + ans << endl;
}

Measured memory_bytes: 256
n, p = map(int, input().split())
a = list(map(int, input().split()))
    
odd = 0
for num in a:
    if(num % 2 == 1):
        odd += 1
if(odd == 0):
    if(p == 0):
        print(2 ** n)
    else:
        print(0)    
else:
    print(2 ** (n-1))

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >>vec.at(i);
    }
    sort(vec.begin(),vec.end());
    cout << vec.at(n-1) - vec.at(0) << endl;
    }

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int x;
    cin >> x;

    if(x < 100) cout << 0 << '\n';
    else if(x % 100 == 0) cout << 1 << '\n';
    else{
        int a = x/100;
        int b = x%100;
        if(5 * a >= b) cout << "1\n";
        else cout << "0\n";
    }


    return 0;
}

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

int N,K;
ll A[200000],DP[222222][3];
int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int i=0;i<222222;i++){
		for(int j=0;j<3;j++){
			DP[i][j]=-1e18;
		}
	}
	DP[0][0]=DP[1][1]=DP[2][2]=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<3;j++){
			DP[i][j]+=A[i];
			for(int k=0;j+k<3;k++){
				DP[i+2+k][j+k]=max(DP[i+2+k][j+k],DP[i][j]);
			}
		}
	}
	if(N&1){
		cout<<DP[N+1][2]<<endl;
	}
	else{
		cout<<DP[N+1][1]<<endl;
	}
}


Measured memory_bytes: 10404
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

#define LB(v, x) distance(v.begin(), lower_bound(ALL(v), x))
#define UB(v, x) distance(v.begin(), upper_bound(ALL(v), x))

int main() {
	int n;
	cin >> n;
	vector<LL> v(n);
	inc(i, n) { cin >> v[i]; }
	sort(ALL(v));
	
	LL ans = 0;
	inc(i, n) {
	inc(j, i) {
		int k = UB(v, v[i] - v[j]);
		ans += max(0LL, j - k);
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,m,min,ans,mi,mj,i,j,k,a,b,s;
  int d[10][10],c[10],f[10];
  while(scanf("%d",&n),n){
    for(i=m=0;i<100;i++)d[i/10][i%10]=100000000;
    while(n--){
      scanf("%d %d %d",&a,&b,&k);
      d[a][b]=d[b][a]=k;
      if(m<a)m=a;
      if(m<b)m=b;
    }
    m++;
    ans=2100000000;
    for(i=0;i<m;i++){
      for(j=0;j<10;j++)c[j]=100000000;
      int f[10]={0};
      c[mi=i]=0;
      for(j=0;j<m;j++){
	f[mi]=1;
	for(k=0;k<m;k++){
	  if(c[k]>c[mi]+d[mi][k])c[k]=c[mi]+d[mi][k];
	}
	min=2100000000;
	for(k=0;k<m;k++){
	  if(f[k])continue;
	  if(min>c[k])min=c[mi=k];
	}
      }
      for(j=s=0;j<m;j++)s+=c[j];//,printf("%d ",c[j]);printf("\n");
      if(ans>s){
	ans=s;
	mj=i;
      }
    }
    printf("%d %d\n",mj,ans);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll r,g,b,n;
  cin >> r >> g >> b >> n;
  ll ans=0;
  rep(i,3001) {
    rep(j,3001) {
      ll x=n-i*r-j*g;
      if(0<=x&&x%b==0) ans++;
    }
  }
  pr(ans);
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int H, W;
	int i, j;
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0) break;
		for(i=0; i<H; i++){
			for(j=0; j<W; j++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


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

int main(void)
{
	int n;
	float money,sum=0;
	char a[5];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%f",&money);
		scanf("%s",a);
		if(strcmp(a,"JPY")==0){
			sum+=money;
		}
		else sum+=money*380000;
	}
	printf("%f",sum);
 	return 0;
 }


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int A,B,C,D; cin>>A>>B>>C>>D;
  
  cout<< min(A,B)+min(C,D)<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

using namespace std;

int main()
{
	int a, b, c, d, n;
	scanf("%d%d%d%d%d", &a, &b, &c, &d, &n);
	b = min(b, a << 1);
	c = min(c, b << 1);
	d = min(d, c << 1);
	printf("%lld\n", 1ll * n / 2 * d + (n % 2) * c);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
string S,T;
signed main(){
  cin >> S >> T;
  vector<int> start(26,-1);
  vector<int> goal(26,-1);
  for(int i=0;i<S.size();i++){
    int a=S[i]-'a';
    int b=T[i]-'a';

    if(start[a]!=-1 || goal[b]!=-1){
      if(start[a] != b || goal[b]!=a){
        cout << "No" << endl;
        return 0;
      }
    }
    start[a]=b;
    goal[b]=a;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
import java.util.*;

public class Main {
	static Scanner scan = new Scanner(System.in);
	
	public static void main(String[] args) {
		int n = scan.nextInt();
		long sum = 0;
		long ans = 0;
		long mod = 1000000007;
		int a[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = scan.nextInt();
			sum += a[i];
		}
		
		for(int i=0;i<n-1;i++) {
			sum -= a[i];
			long kari = (sum%mod)*(a[i]%mod);
			ans = (ans+kari)%mod;
		}
		
		System.out.println(ans);
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 





Measured memory_bytes: 60904
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N=1003;
const ll lmod = 1e9+7;

int main(){
  int N,M,K;
  int dp[MAX_N][MAX_N];
  cin >> N >> M >> K ;
  rep(i,N+1){
    dp[i][0] = M*i;
  }
  rep(i,N+1){
    rep(j,M){
      //dp[i][j]には交点がiこある
      dp[i][j+1] = dp[i][j] + N-2*i;
    }
  }
  bool ans = false;
  rep(i,N+1){
    // rep(j,M+1) cout << dp[i][j] << ",";
    // cout  << endl;
    rep(j,M+1) if(dp[i][j]==K) ans = true;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 4224
# coding: utf-8
def modcomb(n, r, mod):
    "nCr = X/Yとおく"
    r = min(r, n - r)
    X, Y = 1, 1
    for i in range(1, r + 1):
        X = X * (n + 1 - i) % mod
        Y = Y * i % mod
    # return ue * modpow(sita, mod-2, mod)
    return X * pow(Y, mod-2, mod) % mod

N, A, B = map(int, input().split())
mod = 10 ** 9 + 7
ans = pow(2, N, mod) - 1
a = modcomb(N, A, mod)
# ans %= mod
b = modcomb(N, B, mod)
ans -= a + b
print(ans % mod)

Measured memory_bytes: 3064
import java.util.*;

public class Main
{
    static long dp[][];
    static long min(int pos , int value , int w[] , int v[])
    {
        if(value == 0)
        return 0;
        
        if(value < 0)
        return Integer.MAX_VALUE;
        
        if(pos == w.length)
        return Integer.MAX_VALUE;
        
        if(dp[pos][value] != -1)
        return dp[pos][value];
        
        dp[pos][value] = Math.min(w[pos]+min(pos+1,value-v[pos],w,v),min(pos+1,value,w,v));
        
        return dp[pos][value];
    }
    public static void main(String []args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int W = sc.nextInt();
        
        int w[] = new int[n];
        int v[] = new int[n];
        
        for(int i = 0 ; i < n ; i++)
        {
           w[i] = sc.nextInt();
           v[i] = sc.nextInt();
        }
        
       dp = new long[n][100001];
       for(int i = 0 ; i < n ; i++)
       {
           for(int j = 0 ; j <= 100000 ;j++)
           {
               dp[i][j] = -1;
           }
       }
       
       for(int i = 100000 ; i >= 0 ; i--)
       {
           if(min(0,i,w,v) <= W)
           {
           System.out.println(i);
           break;
           }
       }
    }
}

Measured memory_bytes: 139764
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define ed endl
using namespace std;
int a[100010];
int ans=0;
bool aa[100010]={false};
int main()
{
	int i,n;
	cin>>n;
	fo(i,1,n)
	cin>>a[i];
	fo(i,1,n)
	{
		if(a[a[i]]==i)
		if(aa[i]==false)
		if(aa[a[i]]==false)
		{
		ans+=1;
		aa[i]=true;
		aa[a[i]]=true;
	}
	}
	cout<<ans<<ed;
}

Measured memory_bytes: 768
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e.split()[1])
  else:
   if' '==e[6]:
    m=e.split()[1]
    if m in d:d.remove(m)
   elif len(e)%2:d.pop()
   else:d.popleft()
 print(*d)
if'__main__'==__name__:s()


Measured memory_bytes: 69736
# スペース区切りの整数の入力
n = int(input())
a, b = input().strip().split(' ')
a, b = [int(a),int(b)]
arrayP = list(map(int, input().split()))
m = 0
l = 0
s = 0
for i in range(n):
    if arrayP[i] <= a:
        m = m + 1
    elif arrayP[i] > a and arrayP[i] <= b:
        l = l + 1
    else:
        s = s + 1
array = [m,l,s]
array.sort()
print(array[0])


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

int main(){
  ll x,k,d,a,b;
  cin>>x>>k>>d;
  x=abs(x);
  a=x/d;
  b=x%d;
  if(a>k)cout<<x-d*k<<endl;
  else if((a-k)%2==0)cout<<b<<endl;
  else cout<<abs(b-d)<<endl;
}


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

int main(){
	ll a, b, c; cin >> a >> b >> c;
	if(a >= c){ cout << "No" << endl; return 0; }
	ll n = c+a-b;
	if(n*n > 4*a*c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

lis = []
tot = 0
count = 0

for i in range(N):
    AB = map(int,raw_input().split())
    tot += AB[0]
    if AB[0] > AB[1]:
        lis.append(AB[1])

if len(lis) == 0:
    print 0

else:
    lis = np.array(lis)
    print tot - np.min(lis)

Measured memory_bytes: 19912
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var BIT = (function(){
  function f(n){return new BIT(n);}
  function BIT(n){
    this.a = Array(n+1).fill(0);
  }
  BIT.prototype.add = function(x,i){
    for(;i<this.a.length;i+=i&-i)this.a[i]+=x;
  };
  BIT.prototype.get = function(i){
    for(var r=0;i;i-=i&-i)r+=this.a[i];
    return r;
  };
  return f;
})();

var n,p,bit,a;
console.log(main());
function main(){
  n = o.a();
  p = o.l();
  var ans = 0;
  bit = BIT(n+2);
  bit.add(2,1);
  bit.add(2,n+2);
  a = xArray(0,n);
  for(var i = 0; i < n; i++){
    a[p[i]-1] = i;
  }
  bit.add(1,a[n-1]+2);
  for(i = n-1; i--;){
    var x = bit.get(a[i]+2);
    var l1 = solve(0,a[i]+2,x);
    var l0 = solve(0,l1,x-1);
    var r1 = solve(a[i]+2,n+2,x+1);
    var r0 = solve(r1-1,n+2,x+2);
    ans += (l1-l0) * (r1-a[i]-2) * (i+1);
    ans += (r0-r1) * (a[i]+2-l1) * (i+1);
    bit.add(1,a[i]+2);
  }
  return ans;
}

function solve(ng,ok,x){
  while(ok-ng > 1){
    var m = ok+ng>>1;
    if(bit.get(m) >= x)ok = m;
    else ng = m;
  }
  return ok;
}

Measured memory_bytes: 28572
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
n, k  = map(int, input().split())
#s = list(str(input()))
#n = int(input())
a = list(map(int, input().split()))

a1 = collections.Counter(a)
num = [0]*len(a1)
counter = 0

for i in a1.keys():
  num[counter] = a1[i]
  counter = counter + 1

num.sort()
tot = 0
for i in range(len(num)-k):
  tot = tot + num[i]

print(tot)

Measured memory_bytes: 41976
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {  // 名前なし名前空間 みんなも使ってみてね
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}

	void warshallFloyd(vector<vector<int>>& path, int n) {
		rep(k, n) {
			rep(i, n) {
				rep(j, n) {
					path[i][j] = min(path[i][j], path[i][k] + path[k][j]);
				}
			}
		}
	}
}

int main() {

	int n, m, R;
	cin >> n >> m >> R;
	vector<int> r(R);
	rep(i, R) cin >> r[i];
	vector<vector<int>> path(n, vector<int>(n, inf));
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		path[a - 1][b - 1] = path[b - 1][a - 1] = c;
	}

	// ワーシャルフロイド
	// からの全探索 良い問題
	warshallFloyd(path, n);

	int ans = inf;

	// next_permutation
	sort(allof(r));
	do {
		int score = 0;
		rep(i, R - 1) {
			score += path[r[i] - 1][r[i + 1] - 1];
		}
		ans = min(ans, score);
	} while (next_permutation(allof(r)));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a << ' ' << b << ' ' << c << endl;
  return 0;
}

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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if((abs(b-a)<=d and abs(c-b)<=d )or abs(c-a)<=d) cout << "Yes";
	else cout << "No";




	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

inline bool isEven(const int128_t a) { return 0 == a % 2; }

int main() {
	int128_t X, K, D;
	cin >> X >> K >> D;
	int128_t absX = abs(X);

	int128_t minAbs;


	if(absX >= D) {
		if(K <= absX / D) {
			minAbs = absX - K * D;
		} else {
			if(isEven(K)) {
				if(isEven(absX / D)) {
					minAbs = absX - (absX / D) * D;
					if(K >= absX / D + 2) {
						int128_t _abs = abs(minAbs - 2 * D);
						minAbs = min(minAbs, _abs);
					}
				} else {
					minAbs = absX - (absX / D - 1) * D;
					if(K >= absX / D + 1) {
						int128_t _abs = abs(minAbs - 2 * D);
						minAbs = min(minAbs, _abs);
					}
				}
			} else {
				if(isEven(absX / D)) {
					minAbs = absX - (absX / D - 1) * D;
					if(K >= absX / D + 1) {
						int128_t _abs = abs(minAbs - 2 * D);
						minAbs = min(minAbs, _abs);
					}
				} else {
					minAbs = absX - (absX / D) * D;
					if(K >= absX / D + 2) {
						int128_t _abs = abs(minAbs - 2 * D);
						minAbs = min(minAbs, _abs);
					}
				}
			}
		}
	} else {
		if(isEven(K)) {
			minAbs = absX;
		} else {
			minAbs = abs(absX - D);
		}
	}

	cout << minAbs << endl;

	return 0;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;
int n,a[100010],i,tree[4*100010],x1,x2,maxim,x,y;
int cmmdc(int a,int b)
{
    if(a==0)return b;
    if(b==0)return a;
    int r=a%b;
    while(r)
    {
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
void build(int st,int dr,int nod)
{
    if(st==dr)tree[nod]=a[st];
    else {
        int mij=(st+dr)/2;
        build(st,mij,nod*2);
        build(mij+1,dr,nod*2+1);
        tree[nod]=cmmdc(tree[nod*2],tree[nod*2+1]);
    }
}
int querry(int st,int dr,int nod)
{
    if(x<=st&&dr<=y)return tree[nod];
    else {
        int mij=(st+dr)/2,x1=0,x2=0;
        if(x<=mij)
        x1=querry(st,mij,nod*2);
        if(mij<y)
        x2=querry(mij+1,dr,nod*2+1);
        return cmmdc(x1,x2);
    }
}
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    cin>>a[i];
    build(1,n,1);
    for(i=1;i<=n;i++)
    {
        if(i!=1){x=1;y=i-1;x1=querry(1,n,1);}
        else x1=0;
        if(i!=n){x=i+1;y=n;x2=querry(1,n,1);}
        else x2=0;
        if(cmmdc(x1,x2)>maxim)maxim=cmmdc(x1,x2);
    }
    cout<<maxim;
    return 0;
}


Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100000 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

int A[MAX];
LL P[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	LL s = 0;
	FOR(i, 0, n)
	{
		cin >> A[i];
	}

	sort(A, A + n);
	FOR(i, 0, n)
	{
		P[i] = A[i];
		if (i) P[i] += P[i - 1];
	}

	int ind = -1;
	RFOR(i, n - 1, 0)
	{
		if (P[i] * 2 < A[i + 1])
		{
			ind = i;
			break;
		}
	}

	cout << n - ind - 1 << endl;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int ac =0;
		int wa = 0;
		int tle = 0;
		int re= 0;
		
		for(int i=0;i<n;i++) {
			String s = scan.next();
			
			if(s.equals("AC")) {
				ac += 1;
			}else if(s.equals("WA")) {
				wa ++;
			}else if(s.equals("TLE")) {
				tle ++;
			}else {
				re ++;
			}
			
		}
		
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);
		
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 


Measured memory_bytes: 58256
#include <cstdio>
#include <string.h>
#include <set>

int main()
{
    int N;
    scanf("%d", &N);

    std::set<int> data;
    for (int i = 0; i < N; ++i)
    {
        int A;
        scanf("%d", &A);

        if (data.find(A) != data.cend())
        {
            printf("NO");
            return 0;
        }
        data.emplace(A);
    }

    printf("YES");
}


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

//11 -> 21
int main() {
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(all(a));
    int ans = a[2]*2 - a[0] - a[1];
    if(ans%2){
        ans+=3;
    }
    cout << ans/2 << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define forn(i,n) for(ll i=0;i<(n);i++)
#define maxx ((ll)1e6+5)
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
  	 ll n;
  	 cin>>n;
  	 ll ans=1;
  	 for(ll i=2;i*i<=n;i++)
  	 {
  	 	if(n%i==0)
  	 	ans=max(ans,i);
	}
	ll ans1=n/ans;
	cout<<abs(1-ans1)+abs(1-ans);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("happy,newyear,enjoy");
            //happy newyear enjoy
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("haiku,atcoder,tasks");
            //haiku atcoder tasks
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("abcde,fghihgf,edcba");
            //abcde fghihgf edcba
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];

        Console.WriteLine(S.Replace(',', ' '));
    }
}


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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int n; cin >> n;
    forab(i, 1, 50000) {
        int p = i * 1.08;
        if(p == n) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << ":(\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
#include<bitset>
typedef long long ll;
using namespace std;

int main(){
    string S;
    cin>>S;
    ll ans=0;
    for(ll i=0; i<S.size(); ++i){
    if(S[i]=='+') ++ans;
    if(S[i]=='-') --ans;
    }
    cout<<ans<<endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int k;
  cin >> k;
  
  int maximum = max(max(a, b), c);
  int answer = a + b + c - maximum;
  
  for(int i = 0; i < k; i++) {
    maximum *= 2;
  }
  answer += maximum;
  
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=1;i<=n;i++) scanf("%d",&A[i]);

  for(i=0;i<=VMAX;i++) C[i]=0;

  for(j=1;j<=n;j++) C[A[j]]++;

  for(i=1;i<VMAX;i++) C[i]+=C[i-1];

  for(j=n;j>0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i!=n) printf(" ");
  }
  printf("\n");

  free(A);
  free(B);
  return 0;
}



Measured memory_bytes: 9204
N = int(input())
# cnt[i][j] := 先頭がi, 末尾がjで始まるような数
cnt = [[0] * 10 for i in range(10)]
for n in range(1, N + 1):
    cnt[int(str(n)[0])][int(str(n)[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]

print(ans)

Measured memory_bytes: 40428
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int m,n;
  cin>>n>>m;
  int a[n+1];
  for(int i=1;i<=n;i++)
    cin>>a[i];
  sort(a+1,a+n+1);
  int s=0,t=0;
  for(int i=n;i>=1;i--)
  {
    t+=a[i];
    s++;
    if(s==m)
      break;
  }
  cout<<t;
  return 0;
}

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

int n;

int main(){
	cin >> n;
	int t = n, c = 0;
	while(t > 0){
		c += t%10;
		t /= 10;
	}
	if(n % c == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 1000000007
#define PI 3.1415926535
using namespace std;
ll power(ll x, ll y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return power(x, y / 2) * power(x, y / 2);
	else
		return x * power(x, y / 2) * power(x, y / 2);
}
ll modExpo(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modExpo((x*x)%mod,n/2);
    else                            
        return (x*modExpo((x*x)%mod,(n-1)/2))%mod;
 
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	ll n;
	cin>>n;
	ll a[n],i,s=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s+=a[i];
		s%=mod;
	}
	ll ans=0;
	for(i=0;i<n;i++)
	{
		s-=a[i];
		if(s<0)
			s+=mod;
		ans+=a[i]*s;
		ans%=mod;
	}
	cout<<ans<<endl;
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}

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

using ll = long long;

int main() {
    ll x, y;
    cin >> x >> y;

    ll ans = 1LL << 60;
    for (int sgn1 = -1; sgn1 <= 1; sgn1 += 2) {
        for (int sgn2 = -1; sgn2 <= 1; sgn2 += 2) {
            ll nx = sgn1 * x,
               ny = sgn2 * y,
               cost = (sgn1 < 0 ? 1 : 0) + (sgn2 < 0 ? 1 : 0);
            if (nx <= ny) ans = min(ans, cost + (ny - nx));
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
def f():
    if (A+B) <= C*2:
        return A*X+B*Y
    elif X==Y:
        return X*C*2
    else:
        if X > Y:
            if A > C*2:
                return (C*2)*(X-Y)+Y*C*2
            return A*(X-Y)+Y*C*2
        else:#Yの方が多い
            if B > C*2:
                return (C*2)*(Y-X)+X*C*2
            return B*(Y-X)+X*C*2
A,B,C,X,Y = map(int,input().split())
print(f())

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=0;
    cout<<pow(n,3)<<endl;
    return  0;
}


Measured memory_bytes: 384
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

//Author: Jiangsu Nanjing Li Zongtai
//强壮标记*10000,手牌*10000,血量10000 lyl+hzj也打不死我哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈~~~~

const int inf=2147483647;
const double pi=3.14159265358979323846264338327950288419716939937510;

int xx1,xx2;
int yy1,yy2;
bool flag;

int num;

struct pp
{
	int x,y;
	
	bool operator < (pp nw) const{
		return x<nw.x;
	}
};

pp pnt[222222];

int mx[222222];
int mnum;

int main()
{
	cin>>xx1>>yy1>>xx2>>yy2;
	
	if(xx1>xx2)
	{
		swap(xx1,xx2);
		swap(yy1,yy2);
	}
	
	if(yy1>yy2)
	{
		yy1=-yy1;
		yy2=-yy2;
		flag=1;
	}
	
	int n;
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		
		if(flag) y=-y;
		
		if(x<xx1 || xx2<x || y<yy1 || yy2<y) continue;
		
		num++;
		pnt[num]={x,y};
	}
	
	sort(pnt+1,pnt+num+1);
	
	for(int i=1;i<=num;i++)
	{
		int nw=pnt[i].y;
		
		if(mnum==0 || nw>mx[mnum])
		{
			mnum++;
			mx[mnum]=nw;
		}
		else
		{
			*lower_bound(mx+1,mx+mnum+1,nw)=nw;
		}
	}
	
	double ans=0;
	if(min(yy2-yy1,xx2-xx1)+1==mnum)
	{
		ans+=10*pi-20;
		mnum--;
	}
	
	ans+=(yy2-yy1+xx2-xx1)*100.0-(20-pi*5)*mnum;
	
	printf("%.20lf",ans);
	
	return 0;
}


Measured memory_bytes: 2560
#include<algorithm>
#include<cstdio>
#define s(A)std::sort(A,A+10);
main(){
int Z[20];
for(int i=0;i<20;)
scanf("%d",Z+i++);
s(Z);
s(Z+10);
printf("%d %d\n",Z[7]+Z[8]+Z[9],Z[17]+Z[18]+Z[19]);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // input
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        String ans = "";
        int x = a / k;
        int y = b / k;
        int z = a % k;
        int w = b % k;
        if (y - x >= 1 || (z == 0 || w == 0)) ans = "OK";
        else ans = "NG";

        System.out.println(ans);
    }
}


Measured memory_bytes: 35712
#include <cstdio>

int main(void)
{
    int n, ans;
    
    while (1){
        scanf("%d", &n);
        if (n == 0) break;
        
        ans = 0;
        while (n != 0){
            n /= 5;
            ans += n;
        }
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		int[] dircon = new int[4];
		boolean flg = true;
		for (int i = 0; i < A.length(); i++) {
			char dir = A.charAt(i);

			switch(dir) {
			case 'S':
				dircon[0]++;
				break;
			case 'N':
				dircon[1]++;
				break;
			case 'E':
				dircon[2]++;
				break;
			case 'W':
				dircon[3]++;
				break;
			default:
				break;
			}
		}

		if (dircon[0] > 0 && dircon[1] == 0 ) {
			flg=false;
		}

		if (dircon[1] > 0 && dircon[0] == 0 ) {
			flg=false;
		}

		if (dircon[2] > 0 && dircon[3] == 0 ) {
			flg=false;
		}

		if (dircon[3] > 0 && dircon[2] == 0 ) {
			flg=false;
		}

		if (flg) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


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

int main() {
    //
    string strA, strB, strC;
    int indexA = 0;
    int indexB = 0;
    int indexC = 0;
    string turn = "a";
    string kekka;

    cin >> strA >> strB >> strC;

    while (true) {
        if (turn == "a") {
            if (strA.size() == indexA) {
                cout << "A";
                return 0;
            }
            turn = strA.at(indexA);
            indexA++;
        } else if (turn == "b") {
            if (strB.size() == indexB) {
                cout << "B";
                return 0;
            }
            turn = strB.at(indexB);
            indexB++;
        } else if (turn == "c") {
            if (strC.size() == indexC) {
                cout << "C";
                return 0;
            }
            turn = strC.at(indexC);
            indexC++;
        }
    }
    //
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int i,j,n,d[100],k;
int main()
{ 
  cin >> n;
  for(i=0;i<n;i++){
  cin >> d[i];
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(d[i]==d[j])d[j]=0;
    }
  }
  for(i=0;i<n;i++){
  if(d[i]!=0)k++;
  }
  printf("%d",k);
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define all(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COUT(x) cout << x << endl
//#define int long long

template<typename T> constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	int r;
	cin >> r;

	int ans = 3 * r * r;

	COUT(ans);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(b==1)
  {
    cout<<0;
    return 0;
  }
  int temp=a;
  int cnt=1;
  while(temp<b)
  {
    cnt++;
    temp+=(a-1);
  }
cout<<cnt;
  
 
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int N, K;
  scanf ("%d %d", &N, &K);
  int scores[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &scores[i]);
  }
  for (int i = 0; i < N-K; i++) {
    (scores[i] < scores[i+K]) ? printf("Yes\n") : printf("No\n");
  }
    
  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int partition(vector<int>& A, int p, int r)
{
	int x = A[r];
	int i = p - 1;

	for (int j = p; j < r; ++j)
		if (A[j] <= x)
			i++, swap(A[i], A[j]);
	swap(A[i + 1], A[r]);

	return i + 1;
}

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

	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; ++i)
		cin >> A[i];

	int q = partition(A, 0, n - 1);

	for (int i = 0; i < n; ++i)
	{
		if (i == q)
			cout << "[" << A[i] << "] ";
		else {
			cout << A[i];
			i != n - 1 ? cout << " " : cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 100000007
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define pi atan(1)*4
#define ALL(x) x.begin(),x.end()
#define int ll

int n,k;
int a[10000005];
int dp[10000005];

main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		dp[i]=1e15;
	}
	dp[1]=0;
	for(int i=1;i<n;i++)
	{
		int q=min(n,i+k);
		//cout<<i<<" "<<q<<endl;
		for(int j=i+1;j<=q;j++)
		{
			dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
inline int read() {
    int x=0,f=1,c=getchar();
    for (;c< 48;c=getchar()) if (c=='-') f=0;
    for (;c>=48;c=getchar()) x = x*10 + c-'0';
    return f?x:-x;
}
int main() {
    int n = read();
    cout << (n - 2) * 180;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	int *ptr = new int[n];

	for(int i=0; i<n; i++)
		cin>>ptr[i];

	int count = 0;
	for(int i=1; i<n-1; i++)
	{
		if(((ptr[i]>ptr[i-1])&&(ptr[i]<ptr[i+1])) ||((ptr[i]>ptr[i+1])&&(ptr[i]<ptr[i-1])))
		{
			count+=1;
		}
	}

	cout<<count<<endl;
	delete[] ptr;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	private static int[] a = new int[4];
	private static String[] op = new String[3];

	public static boolean dfs(int i, int sum) {
		if(i==4) {
			return sum == 7;
		}
		if(dfs(i+1, sum + a[i])) {
			op[i-1] = "+";
			return true;
		}
		if(dfs(i+1, sum-a[i])) {
			op[i-1] = "-";
			return true;
		}
		return false;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		for(int i=3; i>=0; i--) {
			a[i] = n%10;
			n/=10;
		}
		if(dfs(1,a[0])) {
			System.out.print(a[0]);
			for(int i=1; i<4; i++) {
				System.out.print(op[i-1]);
				System.out.print(a[i]);
			}
			System.out.println("=7");
		}else {
			System.out.println("-1");
		}

	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
//#define ll long long
using namespace std;
int a[1001];
const double PI = 3.141592653589793238462643383279;
int main()
{
	double a, b, x, v1, v2;
	double jd;
	double h;
	cin >> a >> b >> x;
	v1 = a * a * b;
	if (v1 - (2 * x) >= 1e-6)
	{
		h = x / (a * b) * 2.0;
		jd = b / h;
		jd = (atan(jd) / PI * 180.0);
		printf("%.10lf\n", jd);
		return 0;
	}
	v2 = (v1 - x) * 2.0;
	h = v2 / (a * a);
	jd = h / a;
	jd = (atan(jd)/PI*180.0);
	printf("%.10lf\n",jd);
	return 0;
}

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

typedef long long ll;
#define WIN true
#define LOSE false

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<bool> dp(k + 1);
    for (int i = 0; i <= k; i++) {
        dp[i] = LOSE;
        for (auto stones : a) {
            if (i >= stones && dp[i - stones] == LOSE)
                dp[i] = WIN;
        }
    }
    cout << (dp[k] == WIN ? "First" : "Second") << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        mut num: isize,
    }

    let mut ans_vec = vec![];

    for i in 1..50 {
        //println!("num: {}", num);

        let tmp = num % 2isize.pow(i as u32);
        if tmp.abs() == 2isize.pow((i-1) as u32) {
            ans_vec.push(1);
        } else {
            ans_vec.push(0);
        }
        if i%2 == 0 {
            num += tmp.abs();
        } else {
            num -= tmp.abs(); 
        }

        if num == 0 {
            break;
        }
    }

   for a in ans_vec.iter().rev() {
       print!("{}", a);
   } 
   println!("");
    
}


Measured memory_bytes: 4352