akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
int main(){
    ll n;cin>>n;
    vector<vector<ll>> a(n,vector<ll> (n-1));
    For(i,n){
        For(j,n-1){
            cin>>a.at(i).at(n-2-j);a.at(i).at(n-2-j)--;//pop_back()を使うので後ろから入れる
        }
    }
    ll ans=0,vs=0;//日数と消化済み試合数
    vector<int> match;//試合をしうる人
    For(i,n) match.push_back(i);//初日は全員試合する可能性がある
    while(true){//愚直にシミュレーション
        vector<int> nextmatch,flag(n,0);//翌日試合をしうる人と今日試合をしたかどうか
        for(auto i:match){
            if(flag.at(i)==0){//iが未試合
            int rival=a.at(i).at(a.at(i).size()-1);//iの対戦相手
                if(flag.at(rival)==0){//iの対戦相手が未試合
                    if(a.at(rival).at(a.at(rival).size()-1)==i){//iの対戦相手がiと戦う
                        if(a.at(i).size()>1) nextmatch.push_back(i);//対戦表が残っていたらiを翌日の対戦候補に入れる
                        if(a.at(rival).size()>1) nextmatch.push_back(rival);//対戦表が残っていたら対戦相手を翌日の対戦候補に入れる
                        a.at(i).pop_back();a.at(rival).pop_back();//対戦表を消す
                        flag.at(i)++;flag.at(rival)++;//対戦済みフラグを立てる
                        vs++;//消化数を増やす
                    }
                }
            }
        }
        ans++;//日数更新
        if(nextmatch.size()==0){//1日の試合数が0になったらストップ
            if(vs==(n*(n-1))/2) cout<<ans<<endl;//全試合終わったら終了
            else cout<<-1<<endl;//終わってなかったら不可能なセット
            return 0;
        }
        match=nextmatch;//matchの更新
    }
}


Measured memory_bytes: 8064
#include <stdio.h>

int main(void)
{
    int x, y;
    while (1) {
        scanf("%d %d\n", &x, &y);
        if (x == 0 && y == 0) {
            break;
        } else if (x >= y) {
            printf("%d %d\n", y, x);
        } else {
            printf("%d %d\n", x, y);
        }
    }
    return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i,n) for(ll i = 0; i < n; ++i)
#define rep1(i,n) for(ll i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

const int NMAX=200010; // we can calculate nCk until n is equal to NMAX
mint fact[NMAX],infac[NMAX];
void Make_Fact(){
  fact[0]=fact[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    fact[i]=fact[i-1]*(mint)i;
  }
}
void Make_InvFact(){
  infac[0]=infac[1]=1;
  for(int i=2;i<=NMAX-1;++i){
    infac[i]=infac[i-1]/(mint)i;
  }
}
mint Comb(int n,int k){
  if(n<0||k<0||n-k<0) return 0;
  return fact[n]*infac[k]*infac[n-k];
}

int main()
{
  ll n,m,k; cin >> n >> m >> k;
  Make_Fact();
  Make_InvFact();
  mint res;
  
  rep(i,n) {
    rep(j,m) {
      ll tmp = i*(i+1)/2*m + j*(j+1)/2*n + (n-i-1)*(n-i)/2*m + (m-j-1)*(m-j)/2*n;
      tmp = tmp % MOD;
      res += (mint)tmp;
    }
  }
  res /= 2;
  res *= Comb(n*m - 2, k - 2);
  cout << res.x << "\n";
  
  return 0;
}


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

int main(){
  int n;
  cin>>n;
  vector <int> pn;
  int p[60000];
  for(int i=0;i<55556;i++){
    p[i]=1;
  }

  for(int i=2;i*i<55555;i++){
    for(int j=2;j*i<56000;j++){
      p[i*j]=0;
    }
  }

  pn.emplace_back(2);
  pn.emplace_back(3);
  for(int i=4;i<55556;i++){
    if(p[i]==1){
      pn.emplace_back(i);
    }
  } 
  int k=0;
  while(n){
    if(pn[k]%5==3){
      cout<<pn[k];
      n--;
      if(n){
        cout<<" ";
      }
    }
    k++;
  }
  cout<<endl;
  return 0;
}
 
  

Measured memory_bytes: 3852
#include<bits/stdc++.h>
#define fuckit(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
int net[100000+10];
int main()
{
	fuckit();
	ll n,i,t=2;
	cin>>n;
	int ara[n];
	for(i=0;i<n;i++){
		cin>>ara[i];
		net[ara[i]]++;
	}
	if(n<=2){
		if(n==1){
			if(ara[0]==0){
			cout<<1<<endl;
			return 0;
			}
			else{
			cout<<0<<endl;
			return 0;
			}
		}
		else{
			if(ara[0]==1==ara[1]){
				cout<<2<<endl;
				return 0;
			}
			else{
				cout<<0<<endl;
				return 0;
			}
		}
	}
	if(n%2){
	if(net[0]!=1){
		cout<<0<<endl;
		return 0;
	}
	}
	for(i=1;i<=n;i+=2){
		if(net[i-n%2]!=2&&(i-n%2)!=0){
			cout<<0<<endl;
			return 0;
		}
	}
	ll ans=1;
	for(i=1;i<=n/2;i++){
		ans*=2;
		ans%=1000000007;
	}
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int long long n;
	cin>>n;
	int long long s=0;
	for(int long long i=1;i<=n;i++)
	{
		if(((i%3)!=0)&&((i%5)!=0))
		{
			s+=i;
		}
	}
	cout<<s;
}


Measured memory_bytes: 3636
def roll_e(d):
    w = []
    w = d
    d[0], d[1], d[2], d[3], d[4], d[5] = w[3], w[1], w[0], w[5], w[4], w[2]
    return d

def roll_s(d):
    w = []
    w = d
    d[0], d[1], d[2], d[3], d[4], d[5] = w[4], w[0], w[2], w[3], w[5], w[1]
    return d

def dice_judge(d1, d2):
    no_flag = 0

    i = 0
    while d1[1] != d2[1]:
        if i == 7:
            no_flag = 1
            break
        elif i == 4:
            d2 = roll_e(d2)
        d2 = roll_s(d2)
        i += 1

    i = 0
    while d1[0] != d2[0] and no_flag == 0:
        if i == 4:
            break
        d2 = roll_e(d2)
        i += 1

    if d1 == d2:
        return True
    else:
        return False

n = int(input())
d = []
no_flag = 0

i = 0
while n > i:
    d.append(input().split())
    i += 1
i, j = 0, 0
while n-1 > i:
    j = i + 1
    while n > j:
        if dice_judge(d[i], d[j]):
            no_flag = 1
        j += 1
    i += 1

if no_flag == 0:
    print("Yes")
elif no_flag == 1:
    print("No")



Measured memory_bytes: 5608
n = input()
#print(n)
#print(n[-1])
nn = int (n[-1])
#print(nn)
if nn == 2:
	print('hon')
if nn == 4:
	print('hon')
if nn == 5:
	print('hon')
if nn == 7:
	print('hon')
if nn == 9:
	print('hon')
if nn == 0:
	print('pon')
if nn == 1:
	print('pon')
if nn == 6:
	print('pon')
if nn == 8:
	print('pon')
if nn == 3:
	print('bon')


Measured memory_bytes: 9192
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <deque>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> testimony(n, vector<pair<int, int>>());

	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		for (int j = 0; j < a; ++j)
		{
			int x, y;
			cin >> x >> y;
			testimony.at(i).emplace_back(make_pair(x - 1, y));
		}
	}

	const int maxNum = (1 << n);

	int res = 0;
	
	for (int i = 0; i < maxNum; ++i)
	{
		bitset<15> flags(i);
		bool isOK = true;

		for (int p = 0; p < n; ++p)
		{
			if (!flags.test(p))
			{
				continue;
			}

			for (const auto& tes : testimony.at(p))
			{
				if ((flags[tes.first] ? 1 : 0) != tes.second)
				{
					isOK = false;
					break;
				}
			}
		}

		if (isOK)
		{
			res = max(res, static_cast<int>(flags.count()));
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
//struct node{
//    ll v;
//    ll d;
//}p[N];
//ll sum;
//ll ans[N];

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin >>n;
    for(int i=1;i<=n;i++)   cin >>a[i],a[i]-=i;
    sort(a+1,a+1+n);
    ll mid=n/2;
    ll b[4]={a[mid],a[mid+1],a[mid-1]};
    ll ans=1e18;
    for(int i=0;i<=2;i++){
        ll tb=b[i];
        ll res=0;
        for(int j=1;j<=n;j++){
            res+=abs(a[j]-tb);
        }
        ans=min(ans,res);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
ll x[2*100000+5];
ll ans[2*100000+5];
vector<int> edges[200005];

void dfs(int v, ll sm){
	ans[v] += sm + x[v];
	for(auto&& y: edges[v]){
		dfs(y, ans[v]);
	}
}

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

	FOR(i,1,n-1){
		int a,b; cin >> a >> b;
		edges[a].push_back(b);
	}

	FOR(i,1,q){
		int p,cur_x; cin >> p >> cur_x;
		x[p] += cur_x;
	}
	dfs(1,0);

	FOR(i,1,n){
		cout << ans[i] << ' ';
	}
    return 0;
}


Measured memory_bytes: 22528
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int gcd(int x,int y) {
    if(y == 0) return x;
    else return gcd(y,x%y);
}

int main() {
    int x,y; cin >> x >> y;
    cout << gcd(x,y) << endl;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

// const i64 mod = 1'000'000'000ll + 7;
const i64 mod = 998244353ll;

const i64 inf = mod;

const long double eps = 1e-8;

struct segtree {
    typedef i64 type;
    const type zero = inf;

    vector<type> st;

    void init(i64 size) {
        i64 n = 1;
        while (n < size) {
            n *= 2;
        }
        st.assign(n * 2, zero);
    }

    void add(i64 l, i64 r, type v, i64 x, i64 lx, i64 rx) {
        if (r <= lx || rx <= l) {
            return;
        }

        if (l <= lx && rx <= r) {
            st[x] = min(st[x], v);
            return;
        }

        i64 mx = (lx + rx) / 2;
        add(l, r, v, 2 * x + 1, lx, mx);
        add(l, r, v, 2 * x + 2, mx, rx);
    }

    void add(i64 l, i64 r, type v) {
        add(l, r, v, 0, 0, st.size() / 2);
    }

    type get(i64 i, i64 x, i64 lx, i64 rx) {
        if (rx - lx == 1) {
            return st[x];
        }

        i64 mx = (lx + rx) / 2;
        if (i < mx) {
            return min(get(i, 2 * x + 1, lx, mx), st[x]);
        }
        else {
            return min(get(i, 2 * x + 2, mx, rx), st[x]);
        }
    }

    type get(i64 i) {
        return get(i, 0, 0, st.size() / 2);
    }
};


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 n, q;
    cin >> n >> q;

    segtree v;
    v.init(n + 1);
    v.add(1, n + 1, n);

    segtree h;
    h.init(n + 1);
    h.add(1, n + 1, n);


    i64 R = (n - 2) * (n - 2);
    for (i64 i = 0; i < q; i++) {
        i64 t, x;
        cin >> t >> x;

        if (t == 1) {
            i64 last = v.get(x);
            h.add(1, last, x);
            R -= last - 2;
        }
        else {
            i64 last = h.get(x);
            v.add(1, last, x);
            R -= last - 2;
        }
    }

    cout << R << endl;
 
    

    return 0;
}

Measured memory_bytes: 11388
import copy
H,W,K = map(int,input().split())
c = [list(str(input())) for _ in range(H)]
ans = 0
count = 0
for i in range(H):
  count += c[i].count("#")
for h in range(2**H):
  PH = bin(h)[2:].zfill(H)
  for w in range(2**W):
    PW = bin(w)[2:].zfill(W)
    # print(PH,PW)
    count1 = copy.copy(count)
    check = [[0 for _ in range(W)]for _ in range(H)]
    for i in range(H):
      for j in range(W):
        if PH[i] == "1" or PW[j] == "1":
          if c[i][j] == "#" and check[i][j] == 0:
            count1 -= 1
            check[i][j] = 1
    if count1 == K:
      ans += 1
print(ans)

Measured memory_bytes: 9296
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "aising2020_d.cpp"

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

  int n;
  cin >> n;
  string x;
  cin >> x;
  int popX = 0;
  REP(i, n) {
    if (x[i] == '1')
      popX++;
  }

  if (popX == 0) {
    REP(i, n) { cout << 1 << endl; }
    return 0;
  }

  if (popX == 1) {
    REP(i, n) {
      if (x[i] == '1') {
        cout << 0 << endl;
      } else {
        if (i == n - 1) {
          cout << 2 << endl;
        } else {
          cout << 1 << endl;
        }
      }
    }
    return 0;
  }

  vi modp(n, 0), modm(n, 0);
  int modpSum = 0, modmSum = 0;
  {
    int tmpp = 1;
    int tmpm = 1;
    REP(i, n) {
      modp[n - 1 - i] = tmpp % (popX + 1);
      modm[n - 1 - i] = tmpm % (popX - 1);

      tmpp = (tmpp * 2) % (popX + 1);
      tmpm = (tmpm * 2) % (popX - 1);
    }
  }

  REP(i, n) {
    if (x[i] == '1') {
      modpSum = (modpSum + modp[i]) % (popX + 1);
      modmSum = (modmSum + modm[i]) % (popX - 1);
    }
  }

  REP(i, n) {
    int ans = 1;
    int sum = 0;
    if (x[i] == '0') {
      sum = (modpSum + modp[i]) % (popX + 1);
    } else {
      sum = (modmSum - modm[i] + popX - 1) % (popX - 1);
    }

    while (sum > 0) {
      ans++;
      sum = sum % __builtin_popcount(sum);
    }
    cout << ans << endl;
  }
}


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

int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	if(k<=a){
		ans = k;
	}
	else if(k>a && k <=a + b){
		ans = a;
	}
	else{
		ans = a;
		ans -= k - (a+b);
	}
	cout << ans << endl;
}

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

using ll = long long int;

ll h, w;
int n;

map<pair<int, int>, int> cnt;
ll ans[10];

int main(void) {
  // Here your code !
  scanf("%lld %lld %d", &h, &w, &n);

  for (int i = 0; i < n; ++i) {
    ll a, b;
    scanf("%lld %lld", &a, &b);
    for (ll x = -2; x <= 0; ++x) for (ll y = -2; y <= 0; ++y) {
      ll cura = a + x;
      ll curb = b + y;
      if (cura < 1 || (h - 2) < cura || curb < 1 || (w - 2) < curb) continue;
      cnt[make_pair(cura, curb)] += 1;
    }
  }

  ans[0] = (h - 2) * (w - 2);
  for (auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
    ans[itr->second] += 1;
    ans[0] -= 1;
  }

  for (int i = 0; i <= 9; ++i) {
    printf("%lld\n", ans[i]);
  }

	return 0;
}

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

long long n, h[100009], dp[100009];

long long call(long long i)
{
    if(i >= n)
        return 0;
    if(dp[i] != -1)
        return dp[i];

    dp[i] = INT_MAX;
    if(i < n)
        dp[i] = min(dp[i], call(i+1) + abs(h[i]-h[i+1]));
    if(i < n-1)
        dp[i] = min(dp[i], call(i+2) + abs(h[i]-h[i+2]));

    return dp[i];
}

int main()
{
    long long i;
    cin >> n;
    for(i = 1; i <= n; i++)
        cin >> h[i];

    memset(dp, -1, sizeof dp);
    cout << call(1);
}


Measured memory_bytes: 4992
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    dp=[0]*(n+1)
    for i in range(n+1):
        if i==0 or i==1:
            dp[i]=1
        else:
            dp[i]=dp[i-1]+dp[i-2]

    print(dp[n])
    
if __name__=="__main__":
    main()


Measured memory_bytes: 5600
a,b=map(int,input().split())
s=input()
flag=True
for i in range(len(s)):
    if i==a:
        if s[i]!='-':
            flag=False
            break
        continue
    if not(s[i]>='0' and s[i]<='9'):
        flag=False
        break
print("Yes") if flag else print("No")

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

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;


void shuffle(int p, int c, int A[]) {
    rotate(A, A+p-1, A+p+c-1);
}

int main()
{   
    int n, r;
    while (cin >> n >> r && n > 0) {

        int p, c;
        int A[n];

        /* 山札を作成 */

        for (int i = 0; i < n; i++) 
            A[i] = i+1;
            
        reverse(A, A+n);

        /* シャッフルする */

        for (int i = 0; i < r; i++) {
            cin >> p >> c;
            shuffle(p, c, A);
        }

        /* 山札の一番上を表示 */
        
        cout << A[0] << endl;
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] || s[1] == s[2] || s[3] == s[2]) cout << "Bad";
  else cout << "Good";
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,b,a) for(i=b-1;i>=(ll)a;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  if(n<r)return 0;
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j=0,N,M,ans=0;
  cin>>N>>M;
  vec v(N);
  rep(i,N){
    cin>>v[i];
    j+=v[i];
  }
  vrsort(v);
  if(v[M-1]*(4*M)>=j){
    printyes;
  }else printno;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
  
	map<string, int> m;
	int q;
	cin >> q;
	while(q--){
		int op;
		cin >> op;
		if(op == 0){
			string key;int x;
			cin >> key >> x;
			m[key] = x;
		}else if(op == 1){
			string key;
			cin >> key;
			cout << m[key] << '\n';
		}else if(op == 2){
			string key;cin >> key;
			m.erase(key);
		}else{
			string lef, rig;
			cin >> lef >> rig;
			auto pos1 = m.lower_bound(lef);
			auto pos2 = m.upper_bound(rig);
			while(pos1 != pos2){
				if(pos1->second)
					cout << pos1->first << ' ' << pos1->second << '\n';
				pos1++;
			}
		}
			
	}
    return 0;
}



Measured memory_bytes: 25960
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    ll X, Y;
    cin >> X >> Y;
    Y /= X;
    ll ans = 0;
    while (Y >= (1LL << ans)) {
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)

	var diff1to2 struct {
		x int
		y int
	}
	diff1to2.x = x2 - x1
	diff1to2.y = y2 - y1

	x3 := x2 - diff1to2.y
	y3 := y2 + diff1to2.x

	x4 := x3 - diff1to2.x
	y4 := y3 - diff1to2.y

	fmt.Println(x3, y3, x4, y4)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    bool ok = false;
    rep(i, n){
        int d1, d2;
        cin >> d1 >> d2;
        if(d1 == d2){
            cnt++;
            if(cnt >= 3) ok = true;
        }
        else cnt = 0;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
} 

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
int main(){
	ll N, D;
	cin >> N >> D;
	vector< vector<ll> > X(N, vector<ll>(D));
	REP(i,N){
		REP(j,D){
			cin >> X[i][j];
		}
	}
	vector< vector<ll> > root(N, vector<ll>(N));
	REP(i,N){
		REP(j,N){
			root[i][j] = 0;
		}
	}
	REP(i, N){
		REP(j, N){
			if(i > j){
				REP(k, D){
					root[i][j] += pow((X[i][k] - X[j][k]), 2);
				}
			}
		}
	}
	ll ans = 0;
	REP(l, N){
		REP(m, N){
			if(l > m && root[l][m] != 0){
				if(floor(sqrt(root[l][m])) == ceil(sqrt(root[l][m]))){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}


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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

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

  int K;
  cin >> K;
  long now = 7;
  for (int i = 1; i < 1e7; i++) {
    if (now % K == 0) return cout << i << "\n", 0; 
    now *= 10;
    now %= K;
    now += 7;
    now %= K;
  }
  cout << -1 << "\n";
}

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

public class hello
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
		var n = int.Parse(line[0]);
		var m = int.Parse(line[1]);
		line = Console.ReadLine().Trim().Split(' ');
		var a = Array.ConvertAll(line, int.Parse);
		line = Console.ReadLine().Trim().Split(' ');
		var b = Array.ConvertAll(line, int.Parse);
		var pa = a.Intersect(b).ToArray();
		var paL = pa.Length;
		var po = a.Union(b).ToArray();
		Array.Sort(po);
		var poL = po.Length;
		Console.WriteLine("{0} {1}", paL, poL);
		if (paL > 0) Console.WriteLine(string.Join("\n", pa));
		if (poL > 0) Console.WriteLine(string.Join("\n", po));
	}
}



Measured memory_bytes: 53912
/*
      Ashraful Islam Paran
      15-August-2020
      18:39:41
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i >= 0; i--)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)

typedef unsigned long long ull;
typedef vector<long long> vi;
#define ull unsigned long long
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) x.begin(), x.end()
#define ff first
#define ss second

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    // online submission
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

     long long a,b,c,p,q;
    cin>>a>>b>>c;
    a=abs(a);
    if (abs(a/c)>b)cout<<abs(a-(b*c));
    else 
    {
        if (a<0)a=-a;
        p=(a%c);
        q=abs(p-c);
        if (p<q)
        {
            if ((b-(a/c))%2==0)cout<<p;
            else cout<<q;
        }
        else
        {
            if ((b-(a/c))%2==0)cout<<p;
            else cout<<q;
        }
    }
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3764
using System;

class Plogram
{
    static void Main()
    {

        string str = Console.ReadLine();
        int count = 0;

        if(str.Substring(0,1) == "0")
        {
            for (int i = 0; i < str.Length; i++)
            {
                if (i % 2 == 0 && str.Substring(i,1) == "1")
                {
                    count++;
                }
                if (i % 2 != 0 && str.Substring(i,1) == "0")
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
        if (str.Substring(0, 1) == "1")
        {
            for (int i = 0; i < str.Length; i++)
            {
                if (i % 2 == 0 && str.Substring(i, 1) == "0")
                {
                    count++;
                }
                if (i % 2 != 0 && str.Substring(i, 1) == "1")
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 15164
#include <iostream>
#define llint long long

using namespace std;

llint a, b, x;

int main(void)
{
	cin >> a >> b >> x;
	
	a = (a+x-1) / x;
	b = b / x;
	
	cout << b - a + 1 << endl;
	return 0;
}

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



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

    int r, g;
    cin >> r >> g;
    cout << 2*g - r << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define P pair<ll,ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod=1000000007;
constexpr ll INF=(1ll<<60);
constexpr double pi=3.14159265358979323846;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<typename T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}

int main(){
    ll r;cin>>r;
    cout<<r*r<<endl;
    return 0;
}

Measured memory_bytes: 3640
N, K = map(int, input().split())
S = list(input())

if(S[K-1] == "A"):
    S[K-1] = "a"
elif(S[K-1] == "B"):
    S[K-1] = "b"
elif(S[K-1] == "C"):
    S[K-1] = "c"

S = "".join(S)

print(S)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e3 + 10;
char s[N][N];
int dp[N][N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '#') continue;
      if (i - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
      if (j - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
    }
  }
  printf("%d\n", dp[n - 1][m - 1]);
  return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int k; cin >> k;
    if (k & 1)
    {
        cout << (k/2) * (k/2+1) << endl;
    }
    else
    {
        cout << pow(k/2, 2) << endl;
    }

}

Measured memory_bytes: 256
h1, m1, h2, m2, k = map(int, input().split())
if h2 >= h1:
    m = 60 *(h2 - h1) + (m2 - m1)
else:
    m = 60 * (24 + h2 - h1) + (m2 - m1)
print(m - k)


Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int ii = a; ii <= (b); ++ii) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	

	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll temp = 0;
	int ans = 51234552;
	vector<ll>a(n + 1,0);
	rep0(i, n - 1) {
		if (s[i] == 'W') {
			temp++;
		}
		a[i + 1] = temp;
	}
	rep0(j, n - 1) {
		int num = a[j] + n - j - 1 - a[n] + a[j + 1];
		ans = min(ans, num);
	}
	cout << ans << endl;
	return 0;
}


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

int main (void){
  long long int n = 0,m = 0,a = 0,b = 0,z = 0;
  cin >> n >> m;
  vector<vector<long long int>> G(n,vector<long long int>());
  vector<long long int> h(n);

  for(int i = 0;i < n;i++){
    cin >> h[i];
  }
  for(int i = 0;i < m;i++){
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }


  for(int i = 0;i < n;i++){
    if(G[i].size() > 0){
      for(int k = 0;k < G[i].size();k++){
        if(h[i] <= h[G[i][k]]){
          break;
        }
        if(k == G[i].size() - 1){
          z++;
        }
      }
    }else{
      z++;
    }
  }

  cout << z << endl;

  return 0;
}

Measured memory_bytes: 9820
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 100000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int bit[200050];
void update(int p, int v) {
	for (; p <= 200020; p += p & (-p)) bit[p] += v;
}
int getsum(int p) {
	int rv = 0;
	for (; p; p -= p & (-p)) rv += bit[p];
	return rv;
}

int in[100050];
int u[100050];
int sum[100050];

int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &in[i]);

	int st = 1, en = INF, mi, rv = INF;
	while (st <= en) {
		mi = (st + en) / 2;

		ll cnt = 0;
		memset(bit, 0, sizeof(bit));
		update(100010, 1);
		for (i = 1; i <= N; i++) {
			u[i] = 1;
			if (in[i] > mi) u[i] = -1;
			sum[i] = sum[i - 1] + u[i];

			cnt += getsum(100010 + sum[i] - 1);
			update(100010 + sum[i], 1);
		}

		ll cnt2 = (ll)N * (N + 1) / 2 - cnt;
		if (cnt > cnt2) {
			rv = mi;
			en = mi - 1;
		}
		else st = mi + 1;
	}
	return !printf("%d\n", rv);
}

Measured memory_bytes: 2176
#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

int main(void){
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  vector<int> dp(N, 1000000000);
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  
  dp[0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < min(i+K+1, N); j++){
      dp[j] = min(dp[j], abs(H[j] - H[i])+dp[i]);
    }
  }
  
  cout << dp[N-1] << endl;  

  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		if (n - h >= 0 || n - w >= 0) {
			System.out.println((n - h + 1) * (n - w + 1));
		} else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 50001;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> isPrime(MAX_N, 1), prime;
    isPrime[0] = isPrime[1] = 0;
    for(ll i = 2; i * i <= MAX_N; i++)
    {
        if(isPrime[i] == 0) continue;
        for(int j = 2 * i; j <= MAX_N; j += i) isPrime[j] = 0;
    }
    for(int i = 2; i < MAX_N; i++) if(isPrime[i]) prime.push_back(i);
    int n;
    while(cin >> n, n)
    {
        int ans = 0;
        for(int i = 0; i < prime.size(); i++)
        {
            int x = n - prime[i];
            if(x < prime[i]) break;
            if(isPrime[x]) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3140
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define all(x) (x).begin(), (x).end()   // sort(all(v)) instead sort(v.begin(),v.end())
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vi vector<int>
#define vl vector<int>
#define pb push_back
#define eb empalce_back
int main()
{   fast;
    int t=1;
    //cin>>t;
    while(t--){
  int n,x,tl;
  cin>>n>>x>>tl;

  if(n%x==0)cout<<(n/x)*tl;
  else cout<<(floor(n/x)+1)*tl;
}

}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define fi first
#define se second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(i,a,b) for(int i = a; i <= b; i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vvi = vector<vi>;
using vpi = vector<pii>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}
template<class T> bool uin(T &a, T b){ return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b){ return a < b ? (a = b, true) : false; }

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
const int N = 100100;
ll mod=1000000007;
const ll oo = 9876543210;

vll operator*(const vll &a, const vll &b){
	vll ans(a.size());
	rep(i,a.size()){
		ans[i] = a[b[i]];	
	}
	return ans;
}

vll powe(vll a,ll k){
	vll ans(a.size());
	iota(ans.begin(),ans.end(),0);
	while( k > 0){
		if(k&1) ans = ans*a;
		a = a*a;
		k>>=1;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	startTime = clock();
	srand(time(0));
	ll n,k;
	cin>>n>>k;
	vll a(n+1);
	for(int i = 1; i <= n; i++){
		cin>>a[i];
	}
	vll ans = powe(a,k);
	cout<<ans[1]<<nl;
	return 0;
}



Measured memory_bytes: 9576
/*ex4_2
 S_S_S */

#include <stdio.h>
#include <math.h>

int main(void) {
    double pi=3.141592653589;
    double h_hand,m_hand,hour,minute;
    scanf("%lf",&h_hand);
    scanf("%lf",&m_hand);
    scanf("%lf",&hour);
    scanf("%lf",&minute);
    double h_arg=(pi*hour/6)+(pi*minute/360);/*短針のテッペンからの回転度*/
    double m_arg=pi*minute/30;
    double arg=h_arg-m_arg;/*針のなす角*/
    double ans=m_hand*m_hand+h_hand*h_hand-2*m_hand*h_hand*cos(arg);/*A^2+B^2-2ABcosθ*/
    ans=sqrt(ans);/*余弦定理*/
    printf("%.10f\n",ans);/*下10桁出力*/
}

Measured memory_bytes: 2544
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let buttons = read_vec::<i32>();
    let mut a = buttons[0];
    let mut b = buttons[1];

    let mut coins = 0;
    for _x in 0..2 {
        if a > b {
            coins += a;
            a -= 1;
        } else {
            coins += b;
            b -= 1;
        }
    }

    println!("{}", coins);
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        bool ans = inpt.Sum() % 2 == 0 && inpt.Any(a => a == inpt.Sum() / 2);
        Console.WriteLine(ans ? "Yes" : "No");

    
    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

56 25 31


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 3032
n, m = list(map(int, input().split()))
paths = [list(map(int, input().split())) for _ in range(m)]

visited = [1]
rest = [i for i in range(2, n + 1)]
ans = 0

def dfs(num):
    if rest == []:
        # print(visited)
        global ans
        ans += 1
    for i in range(m):
        if num in paths[i]:
            other = paths[i][1 - paths[i].index(num)]
            if other in rest:
                # print(other)
                visited.append(other)
                rest.remove(other)
                # print(visited, rest)
                dfs(other)
                visited.remove(other)
                rest.append(other)

dfs(1)
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def combination(n: int, r:int, mod=MOD):
    n1 = n+1
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

def solve(S: int):
    p = S //3
    ans = 0
    for i in range(1,p+1):
        s_ = S-i*3
        ans += combination(s_+1 + (i-1) -1, i-1)
        ans%=MOD
    print(ans)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
N=int(input())
X=list(map(int,input().split()))
SX = sorted(X)

if N == 2:
  print(X[1])
  print(X[0])
else:
  Y = N//2
  MIN_M = SX[Y-1]
  MAX_M = SX[Y]
  for i in range(N):
    #print(MIN_M, MAX_M,X[i])
    if X[i] < MAX_M:
      print(MAX_M)
    else:
      print(MIN_M)
    

Measured memory_bytes: 25224