akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;                       // to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

template<class T> long long inversion_number(const vector<T> &a) {
    int n = (int)a.size();
    vector<T> b = a;
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    
    long long res = 0;
    BIT<int> bit(n);
    for (int i = 0; i < n; ++i) {
        int order = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
        ++order;
        res += bit.sum(1,order+1);
        bit.add(order, 1);
    }
    return res;
}

int main(){
  ll n,k; cin >> n >> k;
  vector<ll> a(n),sum(n+1);
  for(int i = 0; i < n; ++i){
    cin >> a[i]; a[i]-= k;
    sum[i+1]= sum[i]+ a[i];
  }
  ll ans = inversion_number(sum);
  cout << ans << endl;
}


Measured memory_bytes: 5760
char buf[20000];sz;
int rd()
{
	int ret=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		ret=ret*10+k-'0';
	}
	return ret;
}
int d[3001];
main()
{
	read(0,buf,20000);
	int N=rd();
	int S=rd();
	int ans=0;
	for(int i=0;i<N;i++)
	{
		++d[S];
		for(int j=rd(),k=0;j<=S;j++,k++)
		{
			d[k]+=d[j];
			if(d[k]>=998244353)d[k]-=998244353;
		}
		ans+=d[0];
		if(ans>=998244353)ans-=998244353;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <regex>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int cnt = 0;
    REP(i,s.size()) {
        if (s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N,A,B;
	cin>>N>>A>>B;
	string S;
	cin>>S;
  	int q=0;
	int inl=0;
	rep(i,N){
		if(S[i]=='a'){
			if(q<A+B){q++;cout<<"Yes"<<endl;}
			else cout<<"No"<<endl;
		}
		if(S[i]=='b'){
			if(q<A+B&&inl<B){q++;inl++;cout<<"Yes"<<endl;}
			else cout<<"No"<<endl;
		}
		if(S[i]=='c'){
			cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(){
    int n,k,t,u,v,l,tmp;
    bool car[10002];
    cin >> n >> k >> t >> u >> v >> l;

    memset(car,false,sizeof(car));

    for(int i=0;i<n;i++){
        cin >> tmp;
        car[tmp] = true;
    }

    int stock = 0,fast = 0, slow = 0, rem = 0;
    for(int i=0;i<l;i++){
        if(rem == 0 && stock > 0){
            rem = v*t;
            stock--;
        }
        if(car[i]){
            if(rem == 0){
                rem = v*t;
            }else{
                if(stock == k){
                    rem = v*t;
                }else{
                    stock++;
                }
            }
        }
        if(rem > 0){
            fast++;
            rem--;
        }else{
            slow++;
        }
    }
    printf("%.10f\n", (double)fast/v + (double)slow/u);
}

Measured memory_bytes: 1208
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, k,in,ans=100000000; cin>>n>>k; 
    vi a(n+1);
    for (int i=1;i<=n;i++){
    	cin >> a[i];
    	if (a[i]==1) in = i; 
    }
    for (int i=max(1LL,in-k+1);i<=min(n,in+k-1);i++) {
    	ans = min(ans,((i-1)/(k-1)+((i-1)%(k-1)>0))+((n-i)/(k-1)+((n-i)%(k-1)>0)));
    }
    cout << ans << endl;
}
/*
7 3
4 3 2 1 5 6 7

*/

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4032
loop do
   n = gets.to_i
   break if n == 0
   table = []
   n.times do
      row = gets.split(" ").map{|x| x.to_i}
      row.push row.inject{|m,x| m += x}
      table.push row
   end
   colsum = Array.new n + 1,0
   table.each do |row|
      row.each_with_index do |x,i|
         colsum[i] += x
      end
   end
   table.push colsum
   table.each do |row|
      row.each do |x|
         printf "%5d",x
      end
      puts ""
   end
end

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

int main() {
    string x, y;
    cin >> x >> y;
    string ans;

    if(x < y) {
        ans = '<';
    } else if(x > y) {
        ans = '>';
    } else {
      ans = '=';
    }


    cout << ans << endl;


}


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


Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3 2
2000000000 -9000000000 4000000000
7000000000 -5000000000 3000000000
6000000000 -1000000000 8000000000
)");
#define cin input
#endif

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

	vector<long long> x(n);
	vector<long long> y(n);
	vector<long long> z(n);
	for (int i=0; i<n; i++)
		cin >> x[i] >> y[i] >> z[i];

	vector<long long> total(8);

	vector<long long> sum1(n);
	for (int j=0; j<n; j++)
		sum1[j] = x[j]+y[j]+z[j];
	sort(sum1.begin(), sum1.end(), greater<long long>());
	for (int k=0; k<m; k++)
		total[0] += sum1[k];

	vector<long long> sum2(n);
	for (int j=0; j<n; j++)
		sum2[j] = x[j]+y[j]-z[j];
	sort(sum2.begin(), sum2.end(), greater<long long>());
	for (int k=0; k<m; k++)
		total[1] += sum2[k];

	vector<long long> sum3(n);
	for (int j=0; j<n; j++)
		sum3[j] = x[j]-y[j]+z[j];
	sort(sum3.begin(), sum3.end(), greater<long long>());
	for (int k=0; k<m; k++)
		total[2] += sum3[k];

	vector<long long> sum4(n);
	for (int j=0; j<n; j++)
		sum4[j] = x[j]-y[j]-z[j];
	sort(sum4.begin(), sum4.end(), greater<long long>());
	for (int k=0; k<m; k++)
		total[3] += sum4[k];

	vector<long long> sum5(n);
	for (int j=0; j<n; j++)
		sum5[j] = -x[j]+y[j]+z[j];
	sort(sum5.begin(), sum5.end(), greater<long long>());
	for (int k=0; k<m; k++)
		total[4] += sum5[k];

	vector<long long> sum6(n);
	for (int j=0; j<n; j++)
		sum6[j] = -x[j]+y[j]-z[j];
	sort(sum6.begin(), sum6.end(), greater<long long>());
	for (int k=0; k<m; k++)
		total[5] += sum6[k];

	vector<long long> sum7(n);
	for (int j=0; j<n; j++)
		sum7[j] = -x[j]+y[j]+z[j];
	sort(sum7.begin(), sum7.end(), greater<long long>());
	for (int k=0; k<m; k++)
		total[6] += sum7[k];

	vector<long long> sum8(n);
	for (int j=0; j<n; j++)
		sum8[j] = -x[j]-y[j]-z[j];
	sort(sum8.begin(), sum8.end(), greater<long long>());
	for (int k=0; k<m; k++)
		total[7] += sum8[k];

	sort(total.begin(), total.end());
	cout << total[7] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	vl a(n);
	cin>>a;
	vl ltr(n+1,0),rtl(n+1,0);
	rep(i,n)ltr[i+1]=ltr[i]+a[i];
	rrep(i,n)rtl[i]=rtl[i+1]+a[i];
	// puta(ltr);
	// puta(rtl);
	ll ans=0;
	rep(l,n+1)rep(r,n+1){//n^2
		if(l+r>n or l+r>k)continue;
		ll val=ltr[l]+rtl[n-r];
		int remain=k-l-r;
		if(l+r>0){
			vl x;
			rep(i,l)x.push_back(a[i]);
			rep(i,r)x.push_back(a[n-i-1]);//n
			chmin(remain,(int)x.size());
			sort(all(x)); //nlog(n)
			rep(i,remain)if(x[i]<0)val-=x[i];
		}
		chmax(ans,val);
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 256
program hi;
var n: integer;

begin
    readln(n);
    n := n mod 10;
    if n in [2, 4, 5, 7, 9] then
        writeln('hon')
    else if n in [0, 1, 6, 8] then
        writeln('pon')
    else 
        writeln('bon')
end.

Measured memory_bytes: 1376
'use strict'

function main(input) {
  input = input.trim().split('\n')
  const n = input[0]
  const nums = input[1]
    .split(' ')
    .map(v => parseFloat(v))
    .sort((a, b) => a - b)
    .reduce((a, b) => {
      return (a + b) / 2
    })

  console.log(nums)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main(){
  double a, b, x;
  double p = 3.1415926535897932384626;
  cin >> a >> b >> x;
  double V = a*a*b;
  double tan;
  if(x<=V/2){
    tan = 2*x/a/b/b;
  }
  else{
    tan = a*a*a/2/(a*a*b-x);
  }
  cout << fixed << setprecision(7);
  cout << 90-atan(tan)*180/p << endl;
}

Measured memory_bytes: 512
#pragma GCC diagnostic ignored "-Wunused-result"
#define NDEBUG

#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstdio>
#include <vector>

#ifdef NDEBUG
#  define debug(...)
#else
#  define debug(...)                                \
  do {                                              \
    fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
    fprintf(stderr, __VA_ARGS__);                   \
    fputc('\n', stderr);                            \
  } while (false)
#endif

using namespace std;

void rotate(int & x, int & y, int x0, int y0, int x1, int y1) {
  int dx = x1-x0, dy = y1-y0;
  x = x1 - dy, y = y1 + dx;
}

int main() {
  int x[4], y[4];
  scanf("%d %d %d %d", x, y, x+1, y+1);
  rotate(x[2], y[2], x[0], y[0], x[1], y[1]);
  rotate(x[3], y[3], x[1], y[1], x[2], y[2]);
  printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
///////////////////////////////////////////////

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

int main() {
    double w, h, x, y; cin >> w >> h >> x >> y;

    double ans = w*h/2;

    if (w/2==x && h/2==y) {
        printf("%lf 1\n", ans);
    } else {
        printf("%lf 0\n", ans);
    }

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}
//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,total=0;
    cin>>n;
    vec<ll> c(n);
    rep(i,n) cin>>c[i];
    sort(ALL(c));
    
    rep(j,n){
        for(ll k=j+1;k<n;k++){
            auto itr=lower_bound(ALL(c), c[j]+c[k]);
            ll dist=itr-(k+1+c.begin());
            total+=dist;
        }
    }
    cout<<total<<endl;
    return 0;
}


Measured memory_bytes: 256
const 
  base = 1000000007;
var
  a,f:array[0..1010,0..1010] of int64;
  n,m,j,i:longint;
  s : ansistring;
BEGIN
  ///assign(input,'a.in'); reset(input);
  readln(n,m);
  for i:=1 to n do begin
    readln(s);
    for j:=1 to m do if s[j]='.' then a[i,j]:=1 else a[i,j]:=0;
  end;

  fillchar(f,sizeof(f),0);
  f[1,1] := 1;
  for i:=1 to n do
    for j:=1 to m do
      if a[i,j]=1 then f[i,j] := (f[i,j] + f[i-1,j] + f[i,j-1]) mod base;
  writeln(f[n,m]);
END.


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

using namespace std;

const int maxn = 1e5;

int a[maxn];
int n;

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    int t; cin >> t;
    a[i] = t;
  }
  //always bite off the largest chunk that you can.
  int ans = 0;
  int pos = 0;
  while(pos < n){
    int i_incr = pos + 1;
    while(a[i_incr] >= a[i_incr - 1] && i_incr < n) i_incr++;
    int i_decr = pos + 1;
    while(a[i_decr] <= a[i_decr - 1] && i_decr < n) i_decr++;
    pos = max(i_incr, i_decr);
    ans++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 640
package main

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

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		//fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s := make([]int, n)
	for i := range s {
		s[i] = nextInt()
	}

	// 16
	// (4,1) 4,3,7,6,10,9,13,12,16 (4,12)
	// (7,4) 7,3,10,6,13,9,16 (7, 9)
	// (10,7) 10,3,13,6,16 (10,6)
	// (13,10) 13,3,16 (13,3)
	// (16,13) 16
	//
	// n-1 = (a-b)*x+a -> n-a-1 = (a-b) * x
	// a!=2(a-b) -> a != 2b
	// a!=3(a-b) -> 2a != 3b

	// 0 -4 0 -99 31 14 -15 -39 43 18 0`
	// (6,4) 6,2,8,4,10
	// -15+0+43+31+0
	// (10,8) 10
	// (8,6) 8,2,10 (8,2)
	// (6,4) 6,2,8,4,10 (6,4)
	// (4,2) 4,2,6,4 (xx)
	ans := 0
	//dp := make([]int, n)
	u := make([]bool, n)
	for c := 1; c < n; c++ {
		a := n - 1
		sc := s[a]
		//ans = max(ans, sc)
		//dp[0] = s[a]
		//ans = max(ans, dp[0])
		//debugf("i: %d, a: %d, score: %d\n", 0, a, dp[0])
		i := 1
		a -= c
		for a > c {
			u[i*c] = true
			//if i*c >= n-1-i*c {
			if u[n-1-i*c] {
				break
			}
			/*if a%c == 0 && i*c >= a {
				debugf("skip. a: %d, c: %d\n", a, c)
				//a -= c
				break
			}*/
			sc += s[n-1-c*i] + s[c*i]
			ans = max(ans, sc)
			//dp[i] = dp[i-1] + s[n-1-c*i] + s[c*i]
			//ans = max(ans, dp[i])
			//debugf("i: %d, a: %d, score: %d\n", i, a, dp[i])
			i++
			a -= c
		}
		for k := 0; k*c < n-1; k++ {
			u[k*c] = false
		}
	}
	_, _ = fmt.Fprintf(writer, "%d", ans)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 3072
#def main(S, b):
if __name__ == '__main__':
    # n, w, k, V = map(int, input().split())

    n = int(input())

    n = str(n)

    f = False
    for i in range(3):
        if (n[i] == '7'):
            f = True

    if (f):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9104
use proconio::*;
use proconio::marker::Usize1;

fn run() {
    input! {
        n: usize,
        m: usize,
        h: [u32; n],
        e: [(Usize1, Usize1); m],
    }
    let mut g = vec![vec![]; n];
    for (a, b) in e {
        g[a].push(b);
        g[b].push(a);
    }
    let mut ans = 0;
    for (&x, g) in h.iter().zip(g.iter()) {
        let mut ok = true;
        for &u in g.iter() {
            if h[u] >= x {
                ok = false;
            }
        }
        if ok {
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<double> X(0), Y(0);
    for (int i = 0; i * 100 * A <= F; i++){
        for (int j = 0; j * 100 * B + i * 100 * A <= F; j++){
            X.push_back(j * 100 * B + i * 100 * A);
        }
    }
    for (int i = 0; i * C <= F; i++){
        for (int j = 0; j * D + i * C <= F; j++){
            Y.push_back(j * D + i * C);
        }
    }
    
    int ansSW = 100 * A, ansS = 0;
    double per = 0;
    rep(i, 0, X.size()){
        rep(j, 0, Y.size()){
            if (X.at(i) + Y.at(j) > F) continue;
            if (X.at(i) * E < 100 * Y.at(j)) continue;
            if (Y.at(j) * 100 > (X.at(i) + Y.at(j)) * per){
                per = Y.at(j) * 100 / (X.at(i) + Y.at(j));
                ansSW = X.at(i) + Y.at(j);
                ansS = Y.at(j);
            }
            //cout << fixed << setprecision(5) << per << " ";
            //cout << X.at(i) << " " << Y.at(j) << " " << ansSW << " " << ansS << endl;
        }
    }
    cout << ansSW << " " << ansS << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	ll sq = (ll)W * H;
	int ans;
	if (x == (double)W/2 && y == (double)H/2)
		ans = 1;
	else
		ans = 0;
	printf("%.10f %d\n", sq/2.0, ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    long long  N; cin >> N;

    long long sum =0,ans1=0,ans2=0,a;

    

    vector<long long> vec(N);
    REP(i,N) cin >> vec[i];
    
        for(long long i=0;i<N;i++){
            a = vec[i];
            sum += a;

            if((i%2==0)&&(0<=sum)){
                int x = abs(sum+1);
                sum -= x;
                ans1 += abs(x);
            }else if((i%2==1)&&(sum<=0)){
                int x = abs(1-sum);
                sum +=x;
                ans1 += abs(x);
            }

        }
    
    
    sum = 0;
        for(long long i=0;i<N;i++){
            a = vec[i];
            sum += a;

            if((i%2==0)&&(sum<=0)){
                int x = abs(1-sum);
                sum += x;
                ans2 += abs(x);
            }else if((i%2==1)&&(0<=sum)){
                int x = abs(sum+1);
                sum -= x;
                ans2 += abs(x);
            }
        }
    

    cout << min(ans1,ans2) <<endl;


}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a=0,b=0,c=0,d=0;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	long long ans=-1000000000000000000;
	ans=max(ans,a*c);
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	ans=max(ans,b*d);
	printf("%lld",ans);	
	return 0;
}

Measured memory_bytes: 3816
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
cou=0
for i in range(n):
    a=list(map(int,input().split()))
    x=c
    for j in range(m):
        x+=a[j]*b[j]
    if x>0:
        cou+=1
print(cou)

Measured memory_bytes: 38432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;

const int MAX = 510000;
const int MOD = 998244353;

ll fac[MAX], finv[MAX], inv[MAX];

ll l[35];

ll power(ll m, ll n){

    l[0]=m;
    for(ll i=1; i<35; i++){
        l[i] = (l[i-1]*l[i-1]) % MOD;
    }
    /*
    rep(i,35){
        cout << l[i] << " ";
    }
    cout << endl;
    */

    ll tmp = n;
    ll ans = 1;
    rep(i,35){
        if(tmp%2==1){
            ans = (ans*l[i]) % MOD;
        }
        tmp /= 2;
        //cout << ans << " ";
    }
    //cout << endl;
    return ans%MOD;

}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve(){

    ll n,m,k;
    cin >> n >> m >> k;
    COMinit();


    ll ans = 0;
    rep(i,k+1){
        ans = (ans + (((power(m-1,n-i-1) % MOD) * (COM(n-1,i))%MOD)%MOD*m)%MOD )%MOD;
    }

    cout << ans << endl;
    
}

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


Measured memory_bytes: 15608
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n,l,tmp = 0;
	cin >> n;
	ll m = n;
	ll flag = 0;
	ll count  = 0;
	for(ll i = 0; i < n; i++) {
		cin >> l;
		if (l %2==0&&l%4!=0){
			count ++;
		}
		else if(l % 4 == 0){
			tmp += 1;
		}
		else{
		  flag++;
		}
	}
	// cout << m << endl;
	if (flag <= tmp + 1&&count == 0){
		cout << "Yes" << endl;
	}
	else if(flag<=tmp&&count !=0){
	  cout << "Yes"<<endl;
	  }
	else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <tuple>
#include <cmath>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    int k;
    for (k = 2; k <= 447; k++) {
        int M = k * (k - 1) / 2;
        if (N == M) {
            goto YES;
        }
    }
    cout << "No" << endl;
    return 0;
YES:
    vector<vector<int>> T(k);
    int n = 1;
    for (int a = 0; a < k; a++) {
        for (int b = a + 1; b < k; b++) {
            T[a].push_back(n);
            T[b].push_back(n);
            n++;
        }
    }
    cout << "Yes" << endl;
    cout << k << endl;
    for (int i = 0; i < k; i++) {
        cout << T[i].size() << ' ';
        for (int j = 0; j < T[i].size(); j++) {
            cout << T[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
  int a, b;
  int c;
  
  cin >> a >> b;
  c = a * b;
  
  if(c % 2 == 0){
    cout << "Even" << endl;
  }else {
    cout << "Odd" << endl;
  }
}
  

Measured memory_bytes: 764
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <utility>
#include <random>
#include <chrono>

using namespace std;

#define ll long long

int n, m, total;

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        int a; scanf("%d", &a);
        total += a;
    }
    if (total > n) {
        printf("-1");
    } else {
        printf("%d", n - total);
    }
    return 0;
}


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

namespace B_0_or_1_Swap
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ');
            var a = new List<int>();
            var count = 0;
            for (var i = 1; i <= n; i++)
            {
                a.Add(i);
            }
            for (var i = 0; i < n; i++)
            {
                if (int.Parse(input[i]) != a[i])
                {
                    count++;
                }
            }
            if (count == 0 || count == 2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#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>;

int A[101010];
ll L[101010], R[1010101];
int main() {
    int n;
    cin >> n;
    rep(i,n+1) cin >> A[i];
    L[n] = R[n] = A[n];
    for(int i = n-1; i >= 0; --i){
        L[i] = A[i] + (L[i+1]+1)/2;
        R[i] = A[i] + R[i+1];
    }
    if(L[0]>1) {cout << -1 << endl; return 0;}
    ll now = 1;
    ll ans = 0;
    rep(i,n+1) {
        ans += now;
        now-=A[i];
        now = min(now*2, R[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5520
// Aizu Vol-10 1031: Simple GUI Application
// 2017.8.19 bal4u@uu

#include <stdio.h>
#include <ctype.h>
#include <string.h>

char *gets(char *);
char buf[100], *p;
int getInt(void)
{
	int n = 0;
	while (isspace(*p) || *p == ',') p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

char tag[1005];
int x, y;
char ans[100]; int no;

char *parse(char *tp, int *done, int *k)
{
	int x1, y1, x2, y2;
	int ok = 0;
	int sum = 0, s;
	char name[100], *np;

	*k = 0;
//	while (isspace(*tp)) tp++;
	if (!*tp) return tp;
	tp++;	// '<'
	np = name; while (*tp != '>') *np++ = *tp++; *np = 0;
	tp++;	// '>'
	p = tp, x1 = getInt(), y1 = getInt(), x2 = getInt(), y2 = getInt(),	tp = p;
	if (x1 <= x && x <= x2 && y1 <= y && y <= y2) ok = 1;
	while (*tp) {
//		while (isspace(*tp)) tp++;
		if (*(tp + 1) == '/') break;
		tp = parse(tp, done, &s), sum++;  // sum += s+1;
	}
	while (*tp++ != '>') ;
	if (!*done && ok) strcpy(ans, name), no = sum, *done = 1;
	*k = sum;
	return tp;
}

int main()
{
	int n, i, d, k;

	while (1) {
		gets(p = buf); if (!(n = getInt())) break;
		gets(tag);
		for (i = 0; i < n; i++) {
			gets(p = buf), x = getInt(), y = getInt();
			no = -1, d = 0;
			parse(tag, &d, &k);
			if (no < 0) puts("OUT OF MAIN PANEL 1");
			else printf("%s %d\n", ans, no);
		}
	}
	return 0;
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e9;
const int MOD = 1e9+7;

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()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    double R; cin >> R;
    cout << 2*acos(-1)*R << endl;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    int h[100001];
    rep(i, n){
        cin >> h[i];
    }
    int dp[100001];
    dp[0]=0;
    for(int i=1; i<n; i++){
        int temp;
        for(int j = 1; j <= k && i-j >= 0; j++){
            if(j==1){
                temp = dp[i-1] + abs(h[i-1] - h[i]);
            }else{
                temp = min(temp, dp[i-j] + abs(h[i-j] - h[i]));
            }
        }
        dp[i] = temp;
    }

    cout << dp[n-1] << endl;

    return 0;
}


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

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

    if(s.size()<=n)cout<<s<<endl;
    else
    {
        for(int i=0;i<n;i++)cout<<s[i];
        cout<<"..."<<endl;
    }
}


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

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

mint choose(int n,int k,int type=0){
	if(k==0) return 1;
	if(n< k) return 0;
	if(type==0){
		return fact(n)*fact_inverse(k)*fact_inverse(n-k);
	}
	else{
		if(k>n-k) k=n-k;
		mint res=fact_inverse(k);
		rep(i,k) res*=n-i;
		return res;
	}
}

mint multichoose(int n,int k,int type=0){
	return choose(n+k-1,k,type);
}

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

	mint ans=0;
	for(int k=n-1;k>0;k--){
		ans+=fact(n-1);
		if(2*k-n-2>=0) ans-=multichoose(n-k+1,2*k-n-2)*fact(n-k)*fact(k-1);
	}
	cout<<ans<<'\n';

	return 0;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> h(n+2,0);
  for (size_t i = 1; i <= n; i++) {
    cin>>h[i];
  }
  int sum=0;
  for(size_t i = 0; i <= n; i++){
    sum+=abs(h[i]-h[i+1]);
  }
  cout<<sum/2;
}

Measured memory_bytes: 256
/*
Aldew
PROB:
CLASSIFICATION:
DIFFICULTY:
*/

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <map>
#include <math.h>
#include <cstdio>
#include <stack>
#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


typedef long long ll;
typedef unsigned long long ull;

using namespace std;

//void io()
//{
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif
//}

vector <int> factors(int x) {
    vector <int> result;
    int i = 1;
    while(i*i <= x) {
        if(x % i == 0) {
            result.push_back(i);
            if(x/i != i) {
                result.push_back(x/i);
            }
        }
        i++;
    }
    return result;

}

int main()
{
    io;
    string s, t;
    cin >> s >> t;

    int ans = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != t[i]) ans ++;
    }

    cout << ans << endl;

    return 0;

}


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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<ll, ll> Pair;
typedef vector<Pair> VP;

#define MOD 1000000007
#define times(n) rep(_idx, n)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define in(a, l, r) (l <= a && a < r)
#define pb push_back
#define mk make_pair
#define out(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;

template<typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}

int main() {
    int r; cin >> r;
    out(r * r);
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 1000000
#define mod 1000000007
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,p[MN+5],inv[MN+5],ans;
inline int C(int n,int m){return m<=n?1LL*p[n]*inv[m]%mod*inv[n-m]%mod:0;}
int main()
{
    n=read();p[0]=p[1]=inv[0]=inv[1]=1;
    for(int i=2;i<=MN;++i) p[i]=1LL*p[i-1]*i%mod,inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for(int i=2;i<=MN;++i) inv[i]=1LL*inv[i-1]*inv[i]%mod;
    ans=1LL*p[n-1]*(n-1)%mod;
    for(int i=2;i<n;++i) ans=(ans-1LL*C(i-2,(n-2-(i-2)))*p[i-1]%mod*p[n-i]%mod+mod)%mod;
    cout<<ans;
    return 0;
}


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

typedef long long lli;

int main() {
  for(lli n; cin >> n && n; ) {
    vector<vector<lli> > g(n, vector<lli>(31));
    for(lli i = 0; i < n; ++i) {
      lli f; cin >> f;
      while(f--) {
        lli a; cin >> a;
        g[i][a] = 1;
      }
    }
    lli ans = -1;
    try {
      vector<lli> bit(n);
      for(lli i = 0; i < n; ++i) bit[i] = 1LL << i;
      for(lli k = 1; k <= 30; ++k) {
        lli sum = 0;
        for(lli i = 0; i < n; ++i) if(g[i][k]) sum |= bit[i];
        for(lli i = 0; i < n; ++i) {
          if(g[i][k]) {
            bit[i] = sum;
            if(bit[i] == (1LL << n) - 1LL) {
              ans = k;
              throw 0;
            }
          }
        }
      }
    } catch(...) {};
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 100
#define maxk 100000

using namespace std;

int n;
int d[maxk+5][5], v[maxn+5];
bool viz[maxk+5][5];

int Dp (int k, int wh) {
  if (k < v[0]) return 3-wh;
  if (viz[k][wh]) return d[k][wh];
  viz[k][wh] = 1; d[k][wh] = 3-wh;
  for (int i = 0; i < n && d[k][wh] == 3-wh; i++)
    if (k >= v[i] && k-v[i] < v[0]) d[k][wh] = wh;
  for (int i = 0; i < n && d[k][wh] == 3-wh; i++)
    if (k >= v[i] && Dp(k-v[i], 3-wh) == wh) d[k][wh] = wh;
  return d[k][wh];
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int k; cin >> n >> k;
  int i, j, z;
  for (i = 0; i < n; i++) cin >> v[i];
  sort(v, v+n);
  if (Dp(k, 1) == 1) cout << "First\n";
  else cout << "Second\n";
  return 0;
}


Measured memory_bytes: 8960
import java.util.Scanner;

public class Main{

 public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
     
        int[][] arrCards = new int[4][13];
        
        int n = scan.nextInt();
        
        for (int i = 0; i < n; i++) {
            String a = scan.next();
            int ranks = scan.nextInt();
            if (a.equals("S")) {
                arrCards[0][ranks - 1] = 1;
            }else if(a.equals("H")){
                arrCards[1][ranks-1] = 1;
            }else if(a.equals("C")){
                arrCards[2][ranks-1] = 1;
            }else{
                arrCards[3][ranks-1] = 1;
            }
        }
        
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                if (arrCards[i][j] == 0) {
                    if (i==0) {
                        System.out.println("S " + (j+1));
                    }else if(i == 1){
                        System.out.println("H " + (j+1));
                    }else if(i==2){
                        System.out.println("C " + (j+1));
                    }else if(i==3){
                        System.out.println("D " + (j+1));
                    }
                }
            }
        }
       
    }
}


Measured memory_bytes: 26212
#include <iostream>

using std::cout;
using std::endl;
using std::cin;

int main()
{
	int N;

	cin >> N;

	int M = 0;
	int P;
	int T = 0;

	for (int i = 0; i < N; i++) {
		cin >> P;
		if (P > M) {
			M = P;
		}
		T += P;
	}

	T -= M / 2;

	cout << T << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int N;

int main() {
  scanf("%d", &N);
  if (N % 10 == 3) printf("bon\n");
  else if (N % 10 <= 1 || N % 10 == 6 || N % 10 == 8) printf("pon\n");
  else printf("hon\n");
}


Measured memory_bytes: 1660
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,p=-inf,ans=0; cin>>n;
    vector<pp> r(n);
    rep(i,n){
        int x,l; cin>>x>>l;
        r[i]=mk(x+l,x-l);
    }
    sort(al(r));
    rep(i,n){
        if(p<=r[i].second){
            ans++;
            p=r[i].first;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	map<string, int> w;
	string x = "";
	bool result = true;

	for( int i = 0; i < N; ++i ) {
		string s;
		cin >> s;
		w[s] += 1;

		if( (!x.empty() && x.back() != s.front()) || w[s] > 1 ) {
			result = false;
			break;
		}

		x = s;
	}

	cout << (result ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  int g;
  rep(i, n){
    int in;
    cin >> in;
    if(i == 0) g = in;
    else g = gcd(in, g);
  }
  cout << g << endl;
  return 0;
}

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

#define QUEUE_INITIAL_SIZE 100

typedef struct Process {
    char name[11];
    int time;
} Process;

typedef struct Queue {
    Process *processList;
    int size;
    int head;
    int tail;
} *Queue;

void enqueue(Queue queue, Process process);
Process dequeue(Queue queue);
Queue newQueue(int queueMax);
bool empty(Queue queue);
void freeQueue(Queue queue);

Queue
newQueue(int queueMax)
{
    Queue queue = (Queue)malloc(sizeof(struct Queue));
    queue->processList =
	(Process*)malloc(sizeof(struct Process) * queueMax);
    queue->size = queueMax;
    queue->head = 0;
    queue->tail = 0;
    return queue;
}

void
enqueue(Queue queue, Process process)
{
    if ((queue->tail+1) % queue->size != queue->head) {
	queue->tail = (queue->tail+1) % queue->size;
	queue->processList[queue->tail] = process;
    }
    else
    {
	Process *newProcessList =
	    (Process*)malloc(sizeof(struct Process) * queue->size * 2);
	int i;
	for (i=0; i<queue->size; i++)
	    newProcessList[i] = 
		queue->processList[(queue->head+i) % queue->size];
	free(queue->processList);
	queue->processList = newProcessList;
	queue->head = 0;
	queue->tail = queue->size;
	queue->size *= 2;
	queue->processList[queue->tail] = process;
    }
}

Process
dequeue(Queue queue)
{
    if (empty(queue))
	return (Process) {
	    .name = "",
	    .time = 0
	};
    else {
	queue->head = (queue->head + 1) % queue->size;
	return queue->processList[queue->head];
    }
}

bool
empty(Queue queue)
{
    return queue->head == queue->tail;
}

void
freeQueue(Queue queue)
{
    free(queue->processList);
    free(queue);
}

int
main(void)
{
    int i, n, q, time;
    char buf[128], name[11];
    
    Queue queue = newQueue(QUEUE_INITIAL_SIZE);
    
    scanf("%d %d\n", &n, &q);
    for (i=0; i<n; i++)
    {
	Process process;
	fgets(buf, 128, stdin);
	sscanf(buf, "%s %d\n", name, &time);
	strcpy(process.name, name);
	process.time = time;
	enqueue(queue, process);
    }

    int currentTime = 0;
    while (!empty(queue))
    {
	Process process = dequeue(queue);
	if (process.time <= q)
	{
	    currentTime += process.time;
	    printf("%s %d\n", process.name, currentTime);
	}
	else
	{
	    currentTime += q;
	    process.time -= q;
	    enqueue(queue, process);
	}
    }

    freeQueue(queue);

    return 0;
}

Measured memory_bytes: 1444
#include <iostream>
#include <cmath>
#define PI 3.14159265359
using namespace std;

int main(){
	double x = 0;
	double y = 0;
	double theta = PI/2, kyori, yobi;
	for(int i = 0; i < 1000; i++){
		char trash;
		cin >> kyori >> trash >> yobi;
		if(kyori == 0 && yobi == 0){
			break;
		}
		yobi = yobi*PI/180;
		x = x + kyori*cos(PI-theta);
		y = y + kyori*sin(theta);
		theta = theta+yobi;
	}
	cout << (int)x << endl << (int)y << endl;
}

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

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

using ll = long long;
using pll = pair<ll, ll>;

const ll MAXN = 1002;
ll C[MAXN][MAXN];

int main()
{
    ll H, W;
    cin >> H >> W;

    ll CH, CW, DH, DW;
    cin >> CH >> CW >> DH >> DW;
    --CH;
    --CW;
    --DH;
    --DW;

    vector<string> S(H);
    rep (i, H) { cin >> S[i]; }

    rep (x, MAXN)
    rep (y, MAXN)
    { C[x][y] = MAXN * MAXN; }

    using Node = tuple<ll, ll, ll>;
    priority_queue<Node, vector<Node>, greater<Node> > Q;

    C[CH][CW] = 0;
    Q.emplace(0, CW, CH);

    ll ans = -1;

    while (!Q.empty())
    {
        const auto node = Q.top();
        Q.pop();

        const auto cost = get<0>(node);
        const auto cx = get<1>(node);
        const auto cy = get<2>(node);

        if (cx == DW && cy == DH) { ans = cost; break; }

        // if (C[cy][cx]) { continue; }
        // C[cy][cx] = cost;

        const auto insert = [&](ll xx, ll yy, ll newCost)
        {
            if (xx < 0 || W <= xx) { return; }
            if (yy < 0 || H <= yy) { return; }
            if (S[yy][xx] == '#') { return; }
            if (C[yy][xx] <= newCost) { return; }

            C[yy][xx] = newCost;
            Q.emplace(newCost, xx, yy);
        };

        insert(cx - 1, cy, cost);
        insert(cx + 1, cy, cost);
        insert(cx, cy - 1, cost);
        insert(cx, cy + 1, cost);

        for (ll dx=-2;dx<=2;++dx)
        for (ll dy=-2;dy<=2;++dy)
        {
            insert(cx + dx, cy + dy, cost + 1);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13480