akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
using namespace std;
#define MAX 100000
int main(){
	char field[31][31];
	int width,height,data[31][31],n;
	char x,y;
	typedef pair<int,int> P;
	P p;
	queue<P> que;
	while(cin>>width>>height){
		if(width==0 && height==0){break;}
		//初期化
		for(x=0;x<=width;x++){
			for(y=0;y<=height;y++){
				field[x][y]=0;
				data[x][y]=MAX;
			}
		}
		//枠組み
		for(x=0;x<width;x++){
			field[x][0]|=2;
			field[x][height]|=2;
		}
		for(y=0;y<height;y++){
			field[0][y]|=1;
			field[width][y]|=1;
		}
		//壁
		for(y=0;y<height;y++){
			for(x=1;x<width;x++){
				cin>>n;
				if(n==1){
					field[x][y]|=1;
				}
			}
			if(y<height-1){
				for(x=0;x<width;x++){
					cin>>n;
					if(n==1){
						field[x][y+1]|=2;
					}
				}
			}
		}
		//初期値
		que.push(P(0,0));
		data[0][0]=1;
		//queが空になるまで繰り返し
		while(que.size()>0){
			p=que.front();
			que.pop();
			if((field[p.first][p.second]&2)==0){
				if(data[p.first][p.second-1]==MAX){
					data[p.first][p.second-1]=data[p.first][p.second]+1;
					que.push(P(p.first,p.second-1));
				}
			}
			if((field[p.first+1][p.second]&1)==0){
				if(data[p.first+1][p.second]==MAX){
					data[p.first+1][p.second]=data[p.first][p.second]+1;
					que.push(P(p.first+1,p.second));
				}
			}
			if((field[p.first][p.second+1]&2)==0){
				if(data[p.first][p.second+1]==MAX){
					data[p.first][p.second+1]=data[p.first][p.second]+1;
					que.push(P(p.first,p.second+1));
				}
			}
			if((field[p.first][p.second]&1)==0){
				if(data[p.first-1][p.second]==MAX){
					data[p.first-1][p.second]=data[p.first][p.second]+1;
					que.push(P(p.first-1,p.second));
				}
			}
		}
		cout<<((data[width-1][height-1]==MAX)?0:data[width-1][height-1])<<endl;
	}
	return 0;
}

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 300007;

void failure(){cout<<"No"<<lf;exit(0);}

struct tla
{
#define lb(a) ((a)&(-(a)))
	lint t[_];
	void add(int x,lint d){while(x)t[x]+=d,x-=lb(x);}
	lint sum(int x){lint d=0;while(x<_)d+=t[x],x+=lb(x);return d;}
	void cls(){memset(t,0,sizeof(t));}
#undef lb
}t;

int n,val[_],ps[_],lps;

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);
	
	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty();

	for(int i=1;i<=n;i++)if((val[i]&1)!=(i&1))failure();

	lint ce=0,co=0,cc=0;
	t.cls();
	for(int i=1;i<=n;i+=2)co+=t.sum(val[i]),t.add(val[i],1);
	t.cls();
	for(int i=2;i<=n;i+=2)ce+=t.sum(val[i]),t.add(val[i],1);
	t.cls();
	for(int i=1;i<=n;i++)cc+=t.sum(val[i]),t.add(val[i],1);
	
	if(cc!=3*(ce+co))failure();

	cout<<"Yes"<<lf;

	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;

int main(){

  int n;
  long long int k;
  cin >> n >> k;

  //k = k % MOD;
  //cout << k << endl;

  vector<int> v(n*2);
  for(int i = 0; i < n; i++){
    int tmp; cin >> tmp;
    v[i] = tmp; v[i+n] = tmp;
  }
  
  long long int ans  = 0;

  for(int i = 0; i < n; i++){
    for(int j = i+1; j < i+n; j++){
      if(v[i] > v[j]){
        if(j < n) ans += k*(k+1)/2%MOD; 
        else ans += k*(k-1)/2%MOD;
        ans %= MOD;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    int arr[m];
    for(int i=0;i<m;i++) {
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>n) cout<<-1<<endl;
    else cout<<n-sum<<endl;
}


Measured memory_bytes: 3588
h, w = map(int, input().split())
l = ['.'*(w+2)]
l += ['.'+input()+'.' for _ in range(h)]
l += ['.'*(w+2)]
ans = [[0]*(w+2) for _ in range(h+2)]

for i in range(1,h+2):
    for j in range(1,w+2):
        if l[i][j] == '#':
            ans[i-1][j-1] +=1
            ans[i-1][j]   +=1
            ans[i-1][j+1] +=1
            ans[i][j-1]   +=1
            ans[i][j+1]   +=1
            ans[i+1][j-1] +=1
            ans[i+1][j]   +=1
            ans[i+1][j+1] +=1
            
for i in range(1,h+2):
    for j in range(1,w+2):
        if l[i][j] == '#':
            ans[i][j] = '#'

for i in range(h):
    print(''.join(map(str,ans[i+1][1:-1])))

Measured memory_bytes: 3064
// Problem : D - Banned K
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


// Problem : C - Maximum Volume
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
 
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
int f(int n){
    if(n<2)
        return 0;
    else
        return (n * (n - 1)) / 2;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vec v(n);
    fo(i, n)
            cin >>
        v[i];
    vec v1(n + 5, 0);
    fo(i,n){
        v1[v[i]]++;
    }
    int ans = 0;
    fo(i,n+1){
        ans += f(v1[i]);
    }
    //deb(ans);
    fo(i,n){
        int val = ans - f(v1[v[i]]);
        val += f(v1[v[i]] - 1);
        cout << val<<endl;
    }
    

}

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

using namespace std;

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
}

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::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) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


void solve()
{
  long long n;
  cin>>n;

  vector<long  double> items;


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

    long double item;
    cin>>item;
    items.push_back(item);
  }
  sort(items.begin(),items.end());

  long double res=items[0];

  for(int i=1;i<n;i++){
    res=(res+items[i])/2.00;
  }

  cout<<res<<endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;
    while (t--)
    {
        solve();
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int N, W;
    cin >> N >> W;
    vector<ll> w(N + 1), v(N + 1);
    vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, 0));
    for (int i = 1; i <= N; i++)
    {
        cin >> w[i] >> v[i];
        for (int j = W; j >= 0; j--)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= w[i])
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
        }
    }
    ll res = 0;
    for (int i = 0; i <= W; i++)
        res = max(res, dp[N][i]);
    cout << res << endl;
}


Measured memory_bytes: 80256
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

struct point {
    int x, y;
    point () {}
    point (int x, int y): x(x), y(y) {}

    bool operator < (const point& o) const {
        return x+y < o.x+o.y;
    }
};

int INF = 1LL << 29;

int W, H, N;
point pv[500];

int main() {
    cin >> H >> W >> N;
    for (int j = 0; j < N; ++j) { cin >> pv[j].x >> pv[j].y; }
    sort(pv, pv+N);

    int mm[505][505];
    for (int j = 0; j <= H; ++j) { fill(mm[j], mm[j]+W+1, INF); }
    mm[0][1] = mm[1][0] = 0;

    for (int n = 0; n < N; ++n) {
        int x = pv[n].x, y = pv[n].y;

        int mc = INF;
        vector<int> cv;
        for (int d = 1; d <= H+W+1; ++d) {
            for (int dx = -d; dx <= d; ++dx) {
                int px = x + dx, py = y + d - abs(dx);
                if (0 <= px && px <= H && 0 <= py && py <= W) {
                    mc = min(mc, mm[px][py]);
                }

                py = y - d + abs(dx);
                if (0 <= px && px <= H && 0 <= py && py <= W) {
                    mc = min(mc, mm[px][py]);
                }
            }
            cv.push_back(mc + d - 1);
        }

        for (int i = H+W-1; i >= 0; --i) {
            cv[i] = min(cv[i], cv[i+1]);
        }

        for (int d = 0; d <= H+W; ++d) {
            for (int dx = -d; dx <= d; ++dx) {
                int dy = d - abs(dx);

                int px = x + dx, py = y + dy;
                if (1 <= px && px <= H && 1 <= py && py <= W) {
                    mm[px][py] = min(mm[px][py], cv[d]);
                }

                py = y - dy;
                if (1 <= px && px <= H && 1 <= py && py <= W) {
                    mm[px][py] = min(mm[px][py], cv[d]);
                }
            }
        }
    }

    cout << mm[H][W] << endl;

    return 0;
}



Measured memory_bytes: 4172
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int n, xa[2222], ya[2222], xb[2222], yb[2222];
int xc[4444], yc[4444], xl, yl, imos[4444][4444], sum[4444][4444];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d%d", &xa[i], &ya[i], &xb[i], &yb[i]);
		xc[xl++] = xa[i]; xc[xl++] = xb[i];
		yc[yl++] = ya[i]; yc[yl++] = yb[i];
	}
	sort(xc, xc + xl);
	xl = unique(xc, xc + xl) - xc;
	sort(yc, yc + yl);
	yl = unique(yc, yc + yl) - yc;
	for (int i = 0; i < n; i++) {
		xa[i] = lower_bound(xc, xc + xl, xa[i]) - xc;
		ya[i] = lower_bound(yc, yc + yl, ya[i]) - yc;
		xb[i] = lower_bound(xc, xc + xl, xb[i]) - xc;
		yb[i] = lower_bound(yc, yc + yl, yb[i]) - yc;
	}
	for (int i = 0; i < n; i++) {
		imos[ya[i]][xa[i]]++;
		imos[ya[i]][xb[i]]--;
		imos[yb[i]][xa[i]]--;
		imos[yb[i]][xb[i]]++;
	}
	long long ret = 0;
	for (int i = 0; i < yl; i++) {
		for (int j = 0; j < xl; j++) {
			sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + imos[i][j];
			if (sum[i + 1][j + 1] > 0) ret += 1LL * (xc[j + 1] - xc[j]) * (yc[i + 1] - yc[i]);
		}
	}
	printf("%lld\n", ret);
	return 0;
}

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

using ll = long long;

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }

  int d = 0;
  int ans = 1;
  for (int i = 0; i < N; i++) {
    d += L[i];
    if (d<=X) {
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

static const int N = 100;

int main()  {
  int i,j,l,k,n,p[N + 1],m[N + 1][N + 1];
  scanf("%d\n", &n);
  for(i=1;i<=n;i++) {
    scanf("%d%d\n", &p[i-1],&p[i]);
  }

  for(i = 1;i<=n;i++)m[i][i]=0;
  for(l = 2;l<=n;l++) {
    for(i=1;i<=n - l + 1; i++) {
       j=i+l-1;
       m[i][j] = (1<<21);
       for(k=i;k<=j-1;k++) {
         m[i][j] = fmin(m[i][j],m[i][k] + m[k+1][j]+p[i-1]*p[k]*p[j]);
       }
    }
  }

  printf("%d\n", m[1][n]);

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define fout(x) cout << fixed << setprecision(10) << x << endl
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

auto print = [](auto &v) {
  for (auto x : v) {
    cout << x << " ";
  }
  cout << endl;
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VL c(n);
  rep(i, n) cin >> c[i];

  sort(rall(c));

  ll ans = 0;

  ll p = 1;
  rep(i, n - 1) p = (p * 4) % MOD;
  rep(i, n) ans = (ans + c[i] * (i + 2) % MOD) % MOD;
  out((p * ans) % MOD);

  return 0;
}


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

using ll = long long;

// 辺の情報
struct edge {
   ll to, cost;
};

const ll INF = 1e18;
ll N, M; // Nはノードの個数、Mは辺の個数
ll dist[1010]; // 最短距離
vector<edge> Graph[2010]; // グラフ

// ベルマンフォード法
void bellmanFord() {
   for (int k = 0; k < N-1; k++) { // なんか適当な回数操作する
      for (int i = 0; i < N; i++) {
         if (dist[i] == -INF) continue;
         for (edge e : Graph[i]) {
            dist[e.to] = max(dist[e.to], dist[i] + e.cost);
         }
      }
   }
}

int main() {
   cin >> N >> M;
   for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      // a~bまでの距離で、コストはc
      Graph[a].push_back(edge{b, c});
   }

   // 最短距離を-INFで初期化
   for (int i = 0; i < N; i++) {
      dist[i] = -INF;
   }

   // 始点は0で初期化
   dist[0] = 0;
   // 1回ベルマンフォード法を使う
   bellmanFord();
   ll ans1 = dist[N-1];

   // もう1回ベルマンフォード法を使う
   bellmanFord();
   ll ans2 = dist[N-1];

   // 2つの答えが違えば負の閉路が存在するため"inf"となる
   if (ans1 != ans2) {
      puts("inf");
   } else {
      cout << ans1 << endl;
   }

   return 0;
}

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

int main() {
    string c;
    cin >> c;
    if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o" ) {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
using R = double;

const ll INF = 1LL << 50;

//最短経路問題は知っている。
//最長になったとき、どうしますか？
//辺のコストの正負を切り替えて、最短経路問題に置き換えるだけ。
//ループが発生しているかどうかも、BF法の基本。

int main() {

	int N, M;
	cin >> N >> M;
	
	const int NMAX = 1000;
	const int MMAX = 2000;

	int a[MMAX], b[MMAX];
	ll c[MMAX];

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

	ll dist[NMAX];
	for (int i = 0; i < N; ++i) {
		dist[i] = INF;
	}

	dist[0] = 0;

	for (int loop = 0; loop < N - 1; ++loop) {
		for (int i = 0; i < M; i++) {
			if (dist[a[i] - 1] ==INF)continue;

			if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
				dist[b[i] - 1] = dist[a[i] - 1] + c[i];
			}
		}
	}

	ll ans = dist[N - 1];

	bool negative[NMAX];
	for (int i = 0; i < N; i++) {
		negative[i] = false;
	}

	for (int loop = 0; loop < N; ++loop) {
		for (int i = 0; i < M; ++i) {
			if (dist[a[i] - 1] == INF)continue;

			if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
				dist[b[i] - 1] = dist[a[i] - 1] + c[i];
				negative[b[i] - 1] = true;
			}

			if (negative[a[i] - 1] == true) {
				negative[b[i] - 1] = true;
			}
		}
	}

	if (negative[N - 1]) {
		cout << "inf" << endl;
	}
	else {
		cout << -ans << endl;
	}


	return 0;
}


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

int H[100005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> H[i];
    sort(H, H + N);
    int res = H[K - 1] - H[0];
    for (int i = K; i < N; i++) if (H[i] - H[i - K + 1] < res) res = H[i] - H[i - K + 1];
    cout << res << '\n';
    return(0);
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i+k<n; i++){
        if(a[i] < a[i+k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    char c;
    cin>>c;

    cout << (char)(c + 1) << endl;

    return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll l;
  cin >> l;

  double a = l / double(3);
  cout << fixed << setprecision(10);
  cout << (a*a*a) << endl;
  
  return 0;
}

Measured memory_bytes: 256
import math

var = [int(s) for s in input().split()]
 
a = var[0]
b = var[1]
c = var[2]

judge1 = c - a - b
judge2 = (c - a - b)**2 - 4 * a * b

ans = "No"
if judge1>0 and judge2>0:
    ans = "Yes"

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, q, a, b;
bool flag[100002];

int main() {
	cin >> n >> q;
	int i, pos = 1;
	
	flag[1] = flag[2] = true;
	rep(i, q) {
		cin >> a >> b;
		if (pos == a) pos = b;
		else if (pos == b) pos = a;
		swap(flag[a], flag[b]);
		flag[pos-1] = flag[pos] = flag[pos+1] = true;
	}
	
	int ans = 0;
	rep(i, n) ans += flag[i+1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        long W = long.Parse(s[0]);
        long H = long.Parse(s[1]);
        long x = long.Parse(s[2]);
        long y = long.Parse(s[3]);
        double area = (double)W / 2.0 * (double)H;
        bool flag = false;
        if ((x + x == W) && (y + y == H)) flag = true;
        int l = (flag)? 1: 0;
        Console.WriteLine("{0:f6} {1}", area, l);
    }
}

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1  : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=4e2+50, H=201;
int n,d[N],vis[N],ok[N];
vector <int> edge[N];
inline void add(int x,int y) {
	x+=H; y+=H; ok[x]=ok[y]=1;
	--d[x]; ++d[y]; 
	edge[x].push_back(y);
	edge[y].push_back(x);
}
int tag;
inline bool dfs(int x) {
	if(x<=H && d[x]>0) return false;
	if(x>H && d[x]<0) return false;
	vis[x]=1; tag|=(d[x]!=0);
	for(auto v:edge[x])
		if(!vis[v]) if(!dfs(v)) return false;
	return true;
}
int main() {
	n=rd(); rd();
	for(int i=1;i<=n;i++) {
		int a=rd(), b=rd(), c=rd(), d=rd();
		add(c?c:-a,d?-d:b);
	} 
	for(int i=1;i<=2*H;i++) if(ok[i] && !vis[i]) {
		tag=0;
		if((!dfs(i)) || (!tag)) return puts("NO"),0;
	} puts("YES");
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
#define input(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,h,w,t,p,q,ans=0;
vl v,vv;
string s1,s2;
ll solve(){
    vv.push_back(-v[0]);
    for(ll i=1;i<n;i++){
        a=upper_bound(all(vv),-v[i])-vv.begin();
        if(a==vv.size()){
            vv.push_back(-v[i]);
        }
        else{
            vv[a]=-v[i];
        }
        /*cout<<vv.size()<<endl;
        rep(k,vv.size()){
        	cout<<vv[k]<<" ";
        }
        cout<<endl;*/
    }
    return vv.size();
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    input(v,n);
    cout<<solve()<<endl;
 
}

Measured memory_bytes: 2548
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

bool mp[10][10] = {};
int h, w;
int how = 0;

bool check(int x, int y, int num){
	if(x == w - 1 && y == h - 1){
		if(num == how) return true;
		else return false;
	}

	bool a = false, b= false;
	if(x + 1 < w && mp[x + 1][y]){
		a = check(x + 1, y, num + 1);
	}
	if(y + 1 < h && mp[x][y + 1]){
		b = check(x, y + 1, num + 1);
	}

	return (a || b);
}

int main() {
	cin >> h >> w;
	string str;
	REP(i, h){
		cin >> str;
		REP(j, str.size()){
			if(str[j] == '#') {
				mp[j][i] = true;
				how++;
			}else{
				mp[j][i] = false;
			}
		}
	}

	bool ans = check(0, 0, 1);
	if(ans) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  string s;cin>>s;
  int n=s.size();
  if(n&1)fin("No");
  for(int i=0;i<n;i+=2){
    if(s[i]!='h'||s[i+1]!='i')fin("No");
  }
  fin("Yes");
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	double ans = 0;
	for(int i = 0; i < n; i++) {
		double t;
		cin >> t;
		ans += 1/t;
	}
	cout << 1 / ans << "\n";
	return 0;
}

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

namespace Christmas_Eve
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(int.Parse);
            int n = nk.ElementAt(0);
            int k = nk.ElementAt(1);
            var list = new List<int>();
            for (int i = 0; i < n; i++)
            {
                list.Add(int.Parse(Console.ReadLine()));
            }
            list.Sort();
            int result = int.MaxValue;
            for (int i = 0; i < n - k + 1; i++)
            {
                var temp = list[k + i - 1] - list[i];
                result = result < temp ? result : temp;
            }
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 16224
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;

bool can1[200001], can2[200001];

int main() {
  int n, m; cin >> n >> m;
  int a, b;
  REP(i,m) {
    cin >> a >> b;
    if (a == 1) can1[b] = true;
    if (b == n) can2[a] = true;
  }
  FOR(i,1,n)
    if (can1[i]&&can2[i]) { cout << "POSSIBLE" << endl; return 0; }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


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

using namespace std;

const int maxn=1e4+5;
const int inf=(1<<20);
const int white=0;
const int gray=1;
const int black=2;

int n;
vector<pair<int,int> >adj[maxn];

void dijkstra()
{
    priority_queue<pair<int,int> >q;
    int book[maxn],d[maxn];
    for(int i=0;i<n;i++){
        d[i]=inf;
        book[i]=0;
    }
    d[0]=0;
    q.push(make_pair(0,0));
    while(!q.empty()){
        pair<int,int>f=q.top();
        q.pop();
        int u=f.second;
        book[u]=1;
//        if(d[u]<f.first*(-1)){
//            continue;
//        }
        for(int j=0;j<adj[u].size();j++){
            int v=adj[u][j].first;
            if(book[v]==1){
                continue;
            }
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                q.push(make_pair(d[v]*(-1),v));
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<i<<" "<<(d[i]==inf?-1:d[i])<<endl;
    }
}

int main()
{
    scanf("%d",&n);
    int u,k,v,c;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int i=0;i<k;i++){
            cin>>v>>c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    return 0;
}



Measured memory_bytes: 8120
#include<stdio.h>
int main()
{
    int n,i=0,r;
    scanf("%d", &n);
    while(n>0)
    {
        r=n%10;
        if(r==7)
        {
            i=1
            ;break;
        }
        n=n/10    ;
    }
    if(i==1)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1616
import re
import math
def comb(n, r):
    if n == 0 or r == 0:
        return 1
    return int(comb(n, r-1) * (n-r+1) / r)

if __name__ == '__main__':
    
    N, H = [int(x) for x in input().split()]
    A = []
    B = []
    for i in range(N):
        ta, tb = [int(x) for x in input().split()]
        A.append(ta)
        B.append(tb)

    B = sorted(B)
    B.reverse()
    maxA = max(A)

    cntAtk = 0
    dmg = 0
    for b in B:
        if b <= maxA:
            break
        cntAtk += 1
        dmg += b
        if dmg >= H:
            print(cntAtk)
            exit()

    cntAtk += math.ceil((H-dmg) / maxA)
    print(cntAtk)


Measured memory_bytes: 12276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,i,hantei,sum;
  cin>>n;
  vector<string>blue(n);
  vector<int>count(n,1);
  for(i=0;i<n;i++) 
    cin>>blue.at(i);
  int m;
  cin>>m;
  vector<string>red(m);
  for(i=0;i<m;i++)
    cin>>red.at(i);
  for(i=0;i<n;i++){
    hantei=0;
    for(int i2=0;i2<i;i2++){
      if(blue.at(i)==blue.at(i2)) {hantei=1; count.at(i)=0;}
    }
    if(hantei==0){
      string temp=blue.at(i);
      for(int i_blue=0;i_blue<n-1-i;i_blue++)
        if(temp==blue.at(n-1-i_blue))  count.at(i)++;
      for(int i_red=0;i_red<m;i_red++)
        if(temp==red.at(i_red))  count.at(i)--;
     }
  }
   if(n==1){
     if(count.at(0)>0) sum=count.at(0);
     else sum=0;
   }
   else {for(sum=0,i=0;i<n;i++) if(sum<count.at(i)) sum=count.at(i);}
  
  cout << sum <<endl;
     
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=1e5+10;
const int mod=1e9+7;
ll x[maxn],y[maxn];
ll n,m;
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%lld",&x[i]);
    for(int i=1;i<=m;i++)
        scanf("%lld",&y[i]);
    ll sumx=0,sumy=0;
    for(ll i=1;i<=n;i++)
    {
        sumx=(sumx+(i-1)*x[i]%mod-(n-i)*x[i]%mod+mod)%mod;
    }
    for(ll i=1;i<=m;i++)
    {
        sumy=(sumy+(i-1)*y[i]%mod-(m-i)*y[i]%mod+mod)%mod;
    }
    //cout<<sumx<<" "<<sumy<<endl;
    printf("%lld\n",(sumx*sumy)%mod);
}


Measured memory_bytes: 1792
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.collection.immutable.TreeMap
import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    if (input == "1") return "0"
    val y = factorize(input.toLong).groupBy(identity).map(_._2.size).map(getListMax(_)).sum
    y.toString
  }

  def getListMax(x: Long): Long = {
    val list = (2L to 50L).scanLeft(1L)(_+_)
    list.count(_ <= x).toLong
  }
  
  def factorize(x: Long): List[Long] = {
    def foo(x: Long, a: Long = 2, list: List[Long] = Nil): List[Long] = a*a > x match {
      case false if x % a == 0 => foo(x / a, a    , a :: list)
      case false               => foo(x    , a + 1, list)
      case true                => x :: list
    }
    foo(x)
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """24""".stripMargin -> """3
                              |""".stripMargin,
    """1""".stripMargin -> """0
                                                 |
                                                 |
                                                 |
                                                 |
                                                 |
                                                 |
                                                 |""".stripMargin,
    s"""64""" -> """3
                   |""".stripMargin,
    """1000000007""".stripMargin -> """1
                                      |""".stripMargin,
    """997764507000""" -> """7"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 55980
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N = int(input())
A = [int(i) for i in input().split()]
K = gcd(A[0], A[1])

for i in range(2, N):
    K = gcd(K, A[i])

print(K)

Measured memory_bytes: 14224
# coding: utf-8

import sys
input = sys.stdin.readline

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

bimi = []

for a in range(X):
        for b in range(Y):
                if (a + 1) * (b + 1) > K:
                                break

                for c in range(Z):
                        if (a + 1) * (b + 1) * (c + 1) > K:
                                break

                        bimi.append(A[a] + B[b] + C[c])

bimi.sort(reverse=True)

for i in range(K):
        print(bimi[i])



Measured memory_bytes: 8712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];

int n,m;

int bfs(int s)
{
    vector<bool> vis(n);
    queue<int> que;
    que.push(s);
    vis[s] = true;

    int ret = 1;
    while(!que.empty())
    {
        int v = que.front();
        que.pop();
        for(int e:G[v])
        {
            if(!vis[e])
            {
                ++ret;
                vis[e] = true;
                que.push(e);
            }
        }
    }
    return ret;
}

ll f(ll x)
{
    return x*(x-1)/2;
}

int main()
{
    cin >>n >>m;
    rep(i,m)
    {
        int a,b;
        cin >>a >>b;
        --a;
        --b;
        G[a].pb(b);
        G[b].pb(a);
    }

    int X = bfs(0), Y = bfs(1);
    int Z = n-X-Y;

    ll U = f(X)+f(Y)+f(Z)+max(X,Y)*Z-m;
    cout << U << endl;
    return 0;
}


Measured memory_bytes: 5888
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int n, ans;
    
    cin >> n;
    
    if(n % 2 == 0) ans = n / 2;
    else ans = n / 2 + 1;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<list>
#include<string>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl;


int main()
{
	while (1)
	{
		int n;
		cin >> n;
		if (n == 0)break;
		PII mine = MP(10, 10);
		vector <PII> jem;
		REP(i, n)
		{
			int x, y;
			cin >> x >> y;
			PII temp = MP(x, y);
			jem.push_back(temp);
		}
		int m;
		bool ans = true;
		cin >> m;
		REP(i, m)
		{
			char com;
			int value;
			cin >> com >> value;
			if (com == 'N' || com == 'S')
			{
				if (com == 'S')value = -value;
				REP(j, n)
				{
					if (jem[j].first != mine.first)continue;
					int a = min(mine.second, mine.second + value);
					int b = max(mine.second, mine.second + value);
					if (a <= jem[j].second&&jem[j].second <= b)
					{
						jem[j].first = -1;
						jem[j].second = -1;
					}
				}
				mine.second += value;
			}
			else
			{
				if (com == 'W')value = -value;
				REP(j, n)
				{
					if (jem[j].second != mine.second)continue;
					int a = min(mine.first, mine.first + value);
					int b = max(mine.first, mine.first + value);
					if (a <= jem[j].first&&jem[j].first<= b)
					{
						jem[j].first = -1;
						jem[j].second = -1;
					}
				}
				mine.first += value;
			}
		}
		REP(i, n) 
		{ 
			if (jem[i].first != -1)
			{
				ans = false;
				break;
			}
		}
		if (ans)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3020
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>

using namespace std;
typedef pair<int,bool> Pair;

int main(){

  int A,B;
	
  cin >> A >> B;
	
  if( (1 <=A && A <= 9) && (1 <=B && B <= 9) ) cout << A*B << endl;
  else cout << "-1" << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int n;
bool checkarray(int array[], int a[])
{
    REP(i, n)
    {
        if (a[i] != array[i])
        {
            return false;
        }
    }
    return true;
}

int main(void)
{
    cin >> n;
    int a[n], b[n];
    int array[n];

    REP(i, n)
    {
        cin >> a[i];
    }

    REP(i, n)
    {
        cin >> b[i];
    }

    REP(i, n)
    {
        array[i] = i + 1;
    }

    int aval = 0;
    int bval = 0;
    int cnt = 1;
    do
    {
        if (aval == 0)
        {
            if (checkarray(array, a))
            {
                aval = cnt;
            }
        }
        if (bval == 0)
        {
            if (checkarray(array, b))
            {
                bval = cnt;
            }
        }
        cnt++;
    } while (next_permutation(array, array + n));

    cout << abs(aval - bval) << endl;
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int one=0,two=0;
		rep(i,n){
			int k; scanf("%d",&k);
			if(k>=1) one++;
			if(k>=2) two++;
		}
		if(two==0) puts("NA");
		else       printf("%d\n",one+1);
	}
	return 0;
}

Measured memory_bytes: 1040
#include<stdio.h>
#include<set>
#include<string.h>
void calc(int n){
int t,data[5001],p=0,up,ans[5001];
std::set<int> c1;
memset(ans,0,5001*4);

for(int i=1;i<n;i++){
	t=(i*i)%n;
	if(c1.find(t)==c1.end()){
		c1.insert(t);
		data[p]=t;
		p++;
	}
}
up=(n-1)/2;
for(int i=0;i<p;i++){
	for(int j=0;j<p;j++){
		if(i==j) continue;
		t=data[i]-data[j];
		t+=t<0?n:0;
		t=t>up?n-t:t;
		ans[t]++;
	}
}
for(int i=1;i<=up;i++){
	printf("%d\n",ans[i]);
}
}
int main(){
int n;
scanf("%d",&n);
while(n!=0){
	calc(n);
	scanf("%d",&n);
}
}

Measured memory_bytes: 972
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define int long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<int> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const int ths = 1LL << 40;
const int NN = 5e3 + 6;

const int maxN = 1000007;

///abc 169_e
///median of b - median of a + 1 (odd) --- similarly for even

void solve()
{

    int n;
    cin>>n;
    int a[n + 1], b[n + 1];
    for(int i = 1; i <= n; i ++) {
        cin>>a[i]>>b[i];
    }
    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + n);

    if(n & 1) {
        int id = (n + 1) / 2;
        int ans = b[id] - a[id] + 1;
        cout<<ans;
    }
    else {
        int id = n / 2;
        int ans = (b[id] + b[id + 1] - a[id] - a[id + 1] + 1);
        cout<<ans;
    }

    cout<<"\n";
    return ;
}

/*
*/

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

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


Measured memory_bytes: 6780
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

string s;
char m;
bool iseven;
int x;

int main(){
    iseven = false;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(iseven == true && s[i] != 'R'){
            x++;
        } else if(iseven == false && s[i] != 'L'){
            x++;
        } else{
            break;
        }
        iseven = !iseven;
    }

    if(x == s.length()){
        cout << "Yes";
    } else{
        cout << "No";
    }

}

Measured memory_bytes: 256
#                         author:  kagemeka 
#                         created: 2019-11-08 23:31:18(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():

    k, s = (int(i) for i in sys.stdin.readline().split())
    
    count = 0
    for x in range(k + 1):
        if 0 <= s - x <= k * 2:     # s - x = y + z
            for y in range(k + 1):
                if 0 <= s - x - y <= k:
                    count += 1
    
    print(count)


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int t = fs.nextInt();
		int a = fs.nextInt();
		
		int[] hArr = fs.nextIntArr(n);
		
		double minAbs = Math.abs((double) a - ((double)t-0.006*hArr[0]));
		int minIndex = 0;
		for(int i = 1; i < hArr.length; i++) {
			double absTemp = Math.abs((double) a - ((double)t-0.006*hArr[i]));
			if(minAbs > absTemp) {
				minIndex = i;
				minAbs = absTemp;
			}
		}
		System.out.println(minIndex+1);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 21588