akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, k;
	int v[60];
	cin>>n>>k;
	REP(i, n){
		cin>>v[i];
	}
	int ans=0;
	REP(i, k+1){
		REP(j, k-i+1){
			if(i+j>n){
				continue;
			}
			int x2[i+j];
			REP(j2, i){
				x2[j2]=v[j2];
			}
			int cnt=i-1;
			FORR(j2, n-j, n){
				x2[++cnt]=v[j2];
			}
			sort(x2, x2+i+j);
			int sum=0;
			REP(a, i+j){
				sum+=x2[a];
			}
			REP(a, min(k-i-j, i+j)){
				if(x2[a]>=0){
					break;
				}
				sum-=x2[a];
			}
			CHMAX(ans, sum);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

int main(){
  
  int p;cin>>p;
  int arr[p];
  int A,B; cin>>A>>B;
  int u=0,d=0,t=0;
  
  for(int i=0; i<p; i++){
    cin>>arr[i];
  }
  
  for(int i=0; i<p; i++){
    if(arr[i]<=A)u++;
    else if(arr[i]<=B)d++;
    else t++;
  }
  int rta = min({u,d,t});
  cout<<rta<<'\n';
}

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

ll choose2(ll n) {
    return n * (n - 1) / 2;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    rep(i,N) A[i] --;
    vector<int> Am(N, 0);
    rep(i,N) Am[A[i]] += 1;
    ll sum = 0;
    rep(i,N) sum += choose2(Am[i]);
    rep(i,N) {
        ll ret = sum - (Am[A[i]] - 1);
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll i,j;
    cin >> i >> j;
    ll ans = i*j;
    if (9 >=i && 9 >= j)cout << ans << endl;
    else cout << -1 << endl;
    
    
    return 0;
}



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

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

using namespace std;



int main()
{
	string p="01234567";
	unordered_map<string, int> mp;
	mp[p] = 0;
	
	int dr[]={0,1,0,-1,0};
	int ct=0;
	queue< string > que;
	que.push(p);
	while(!que.empty()){
		auto cr = que.front(); que.pop();
		int zps = -1;
		rep(i,8) if(cr[i]=='0'){zps = i; break;}
		int cy = zps/4, cx = zps%4;
		rep(i,4){
			int ny=cy+dr[i], nx=cx+dr[i+1];
			if(ny<0 || ny>=2 || nx<0 || nx>=4) continue;
			auto wv=cr;
			swap(wv[zps], wv[ny*4+nx]);
			if(mp.count(wv)) continue;
			mp[wv] = mp[cr]+1;
			que.push(wv);
		}
	}

	//printf("%d::%d\n", 0, mp.size());

	string su;
	while(cin >> su){
		string ba = su;
		rep(i,7){ cin >> su; ba += su;} 
		
		cout << mp[ba] << endl;
	
	}
	
	return 0;
}

Measured memory_bytes: 5060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M;
  cin >> N >> M;
  vector<long long> H(N), c(N,0);
  int sum =0;
  for(long long i=0;i<N;i++){
  cin >> H[i];
  }
  
  for(long long i=0; i<M;i++){
    vector<int> p(2);
    cin >> p[0] >>p[1];
    if(H[p[0]-1] <= H[p[1]-1]){
    	c[p[0]-1]=1;
    }
    if(H[p[0]-1] >= H[p[1]-1]){
    	c[p[1]-1]=1;
    }
  }
  for(int i=0;i<N;i++){
  	if(c[i]==0){
    sum=sum+1;
    }
  }
  cout << sum <<endl;
  return 0; 
}




Measured memory_bytes: 4844
from collections import deque

q = int(input())

L = deque()
cursor = 0
for i in range(q):
    inp = input()

    # insert
    if inp[0] == "0":
        operation, x = inp.split()
        L.appendleft(x)

    # move
    elif inp[0] == "1":
        operation, d = list(map(int, inp.split()))
        L.rotate(-d)
        cursor += d

    # erase
    else:
        L.popleft()

L.rotate(cursor)
[print(a) for a in L]


Measured memory_bytes: 39732
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 3005;
char s[N], t[N];
int f[N][N], h[N][N];

void recover(int i, int j) {
    if(i < 0 || j < 0) {
        return;
    }
    if(h[i][j] == 0) {
        recover(i - 1, j - 1);
    }
    if(h[i][j] == 1) {
        recover(i - 1, j);
    }
    if(h[i][j] == 2) {
        recover(i, j - 1);
    }
    if(s[i] == t[j]) {
        cout << s[i];
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> t;
    int ls = strlen(s), lt = strlen(t);
    rep(i, 0, ls) {
        rep(j, 0, lt) {
            if(s[i] == t[j]) {
                f[i][j] = 1;
            }
            if(i && j) {
                f[i][j] += f[i - 1][j - 1];
            }
            if(i && f[i - 1][j] > f[i][j]) {
                f[i][j] = f[i - 1][j];
                h[i][j] = 1;
            };
            if(j && f[i][j - 1] > f[i][j]) {
                f[i][j] = f[i][j - 1];
                h[i][j] = 2;
            }
        }
    }
    recover(ls - 1, lt - 1);
    cout << endl;
}

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


int main() {
  int K,N, i,j;
  int show=1;
  cin >> N >> K ;

  for(i=0;i<N;i++){
    if(K<show)show+=K;
    else show*=2;
  }
  cout<<show<<endl;
  }


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

typedef pair<ll, ll> pair_t;
const double eps = 1e-7;

double dist (vector<double> p1, vector<double> p2) {
  return sqrt((p2[0] - p1[0]) * (p2[0] - p1[0]) + (p2[1] - p1[1]) * (p2[1] - p1[1]));
}

vector<double> midpoint (vector<double> p1, vector<double> p2) {
  return {(p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2};
}

vector<double> normal_vector (vector<double> vec) {
  double l = dist({0, 0}, vec);
  return {vec[1] / l, -vec[0] / l};
}

bool found (vector<vector<double>> &points, vector<vector<double>> &crosses, double r) {
  for (vector<double> c : crosses) {
    bool ng = false;
    for (vector<double> p : points) {
      if (dist(c, p) > r + eps) {
        ng = true;
        break;
      }
    }
    if (!ng) return true;
  }
  return false;
}

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

  vector<vector<double>> p(n, vector<double>(2));
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    p[i] = {(double)x, (double)y};
  }
  
  vector<vector<double>> crosses;
  
  double rmax = dist({0, 0}, {1000, 1000}) / 2 + eps;
  double rmin = -eps;
  double r = rmax / 2;

  while (rmax - rmin > eps) {
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        if (dist(p[i], p[j]) <= 2 * r) {
          vector<double> mid = midpoint(p[i], p[j]);
          vector<double> normal = normal_vector({p[j][0] - p[i][0], p[j][1] - p[i][1]});

          double b = dist(p[i], mid);
          double h = sqrt(r * r - b * b);

          crosses.push_back({mid[0] + normal[0] * h, mid[1] + normal[1] * h});
          crosses.push_back({mid[0] - normal[0] * h, mid[1] - normal[1] * h});
        }
      }
    }

    if (found(p, crosses, r)) {
      rmax = r;
      r = (r + rmin) / 2;
    } else {
      rmin = r;
      r = (r + rmax) / 2;
    }
  }

  printf("%.7f\n", r);
}


Measured memory_bytes: 6836
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  bool result = false;
  if(a+b+c<22)
    result = true;
  if(result)
    cout << "win" << endl;
  else
    cout << "bust" << endl;
}

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

int main() {
	int n;
	cin >> n;
	map<int, int> a;
	rep(i, n) {
		int b;
		cin >> b;
		a[b] = i;
	}

	rep(i, n) {
		if (i == n) cout << a[i] << endl;
		else cout << a[i] << " "; 
	}
	return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    ll A,B,C; cin >>A>>B>>C;

    int ans = 0;
    if (A%2==0 && A==B && B==C) {
        ans = -1;
    } else {
        while (A%2==0 && B%2==0 && C%2==0) {
            int a, b, c;
            a = (B+C)/2;
            b = (C+A)/2;
            c = (A+B)/2;
            A = a;
            B = b;
            C = c;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

string S;

void solve() {
	cin >> S;
	rep(i, 0, sz(S)) {
		if(S[i] == '?') S[i] = 'D';
	}
	cout << S << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

int A[100000],n;

int binarySearch(int key){
  int left = 0,right = n,mid;
  while (left < right){
    mid = (left + right) / 2;
    if (A[mid] == key)return 1;
    else if (key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
}


int main(){
  int i,j,m,num=0,key;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&m);
  for(j=0;j<m;j++){
    scanf("%d",&key);
    if(binarySearch(key))num++;
  }
  printf("%d\n",num);

  return 0;
}
   



Measured memory_bytes: 2116
#include<bits/stdc++.h>
#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()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    array<bool, 10> exists;
    exists.fill(false);
    rep(i, 0, 4)
    {
        int N;
        cin >> N;
        exists[N] = true;
    }
    if (exists[1] && exists[9] && exists[7] && exists[4])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


int n,l,a[N];

int main() {
	scanf("%d%d",&n,&l);
	REP(i,1,n) scanf("%d",a+i);
	REP(i,1,n-1) if (a[i]+a[i+1]>=l) {
		puts("Possible");
		REP(j,1,i-1) printf("%d\n",j);
		PER(j,i+1,n-1) printf("%d\n",j);
		printf("%d\n",i);
		return 0;
	}
	puts("Impossible");
}









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

using namespace std;

int main()
{
  int n;

  cin >> n;

  vector<int> w;
  w.resize(n);

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

  int s1 = 0;
  int s2 = 0;

  for(int i = 0;
      i < n;
      ++i)
    {
      s2 += w[i];
    }

  int ans = 100000;

  for(int i = 0;
      i < n - 1;
      ++i)
    {
      s1 += w[i];
      s2 -= w[i];
      ans = min(ans, abs(s1 - s2));
    }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void exchange(char **x, char **y);

int main(void)
{
	char str[100][101];
	char *p[101];
	int i, j, k = 0;
	int N, L;
	
	scanf("%d%d", &N, &L);
	for(i = 0; i < N; i++) {
		p[i] = str[i];
		scanf("%s", str[i]);
	}
	for(i = 0; i < N; i++) {
		for(j = i + 1; j < N; j++) {
			while(p[i][k] == p[j][k]) {
				k++;
			}
			if(p[i][k] > p[j][k]) {
				exchange(&p[i], &p[j]);
			}
			k = 0;
		}
		printf("%s", p[i]);
		j = 0;
	}
	return 0;
}
void exchange(char **x, char **y)
{
	char *z = *x;
	
	*x = *y;
	*y = z;
}

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

int main(){
    int ans = 0;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); ++i){
        if (s[i] != t[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3916
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll h,w;
ll n;
Vi a;
ll ma[110][110];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>h>>w;
    cin>>n;
    a.resize(n);
    rep(i,n)cin>>a[i];
    rep(i,110)rep(j,110)ma[i][j]=-1;
    ll tmp=0,idx=0;
    rep(i,h){
        if(i%2==0){
            rep(j,w){
                ma[j][i] = idx;
                tmp++;
                if(tmp==a[idx]){
                    tmp = 0;
                    idx++;
                }
                if(idx>=n)break;
            }
        }else{
            for(ll j=w-1;j>=0;j--){
                ma[j][i] = idx;
                tmp++;
                if(tmp==a[idx]){
                    tmp = 0;
                    idx++;
                }
                if(idx>=n)break;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ma[j][i]+1<<" ";
        }
        cout<<""<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    int a,b;
    string s,t;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}


Measured memory_bytes: 3600
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");

   //  String nyu=sc.nextLine();
//int[] num=new int[6];
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu);
//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/



System.out.println(A*B%2==0 ? "No" : "Yes") ;

	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
//ll gcd ( ll a, ll b ) {
//    if ( a % b == 0 ) return b;
//    return gcd(b, a % b);
//}
int main() {
    ll x, y;
    cin >> x >> y;
    if ( x % y == 0 ) {
        cout << -1 << endl;
        return 0;
    }
//    ll gcd_num = gcd(x, y);
//    if ( y == gcd_num ) {
//        cout << -1 << endl;
//        return 0;
//    }
    ll mult_num = 2;
    while ( 1 ) {
        if ( x * mult_num > 1e18 ) {
            cout << -1 << endl;
            return 0;
        }
        if ( ( x * mult_num ) % y != 0 ) break;
        ++mult_num;
    }
    cout << x * mult_num << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[605][605],n,d1,d2,z;
void doit(int x)
{
	int y=0;
	while (x%4==0)x/=4,y++;
	if (x%2==1)
	 {
	 	for (int i=0;i<2*n;i++)
	 	 for (int j=0;j<2*n;j++)
	 	  if (((i>>y)+(j>>y))&1)a[i][j]=1;
	 }
	else
	 {
	 	for (int i=0;i<2*n;i++)
	 	 for (int j=0;j<2*n;j++)
	 	  if ((i>>y)&1)a[i][j]=1;
	 } 
}
int main()
{
	scanf("%d%d%d",&n,&d1,&d2);
	doit(d1);doit(d2);
	for (int i=0;i<2*n;i++)
	 for (int j=0;j<2*n;j++)
	  if (!a[i][j]&&z<n*n)
	   {
	   	printf("%d %d\n",i,j);
	   	z++;
	   }
	return 0;   
}

Measured memory_bytes: 2304
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Main{
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}                                              
		return ans;
	} 
	static long mod=1000000007;
	static long power(long x,long y) 
    { 
        long res = 1; 
        x = x % mod; 
        while (y > 0) { 
            if (y % 2 == 1) 
                res = (res * x) % mod; 
            y = y >> 1;
            x = (x * x) % mod; 
        } 
        return res%mod; 
    } 
    static long modInverse(long n) 
    { 
        return power(n, mod-2); 
    } 
    static int digits(int n)
    {
    	int ans=0;
    	while(n!=0)
    	{
    		ans++;
    		n=n/10;
    	}
    	return ans;
    }
    static int[] dp;
    static int min(int[]h,int ind)
    {
    	if(ind==h.length-1)
    		return 0;
    	if(ind>=h.length)
    		return 1000000000;
    	if(dp[ind]!=-1)
    		return dp[ind];
    	int res=1000000000;
    	for(int i=1;i<=2;i++)
    	{
    		if(ind+i<h.length)
    			res=Math.min(res,Math.abs(h[ind+i]-h[ind])+min(h,ind+i));
    	}
    	dp[ind]=res;
    	return res;
    }
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int n=cin();
        int[]h=split();
        dp=new int[n+1];
        Arrays.fill(dp, -1);
        System.out.println(min(h,0));
    }
}

Measured memory_bytes: 57920
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
    long long N;
    cin >> N;

    int dp[61][3] = {};
    dp[60][0] = 1;

    for(int d=59; d>=0; --d) {
        for(int s=0; s<3; ++s) {
            for(int k=0; k<3; ++k) {
                int tmp = min(2, 2 * s + (int)((N >> d) & 1) - k);
                if(tmp >= 0) dp[d][tmp] = (dp[d][tmp] + dp[d+1][s]) % MOD;
            }
        }
    }

    int res = (dp[0][0] + dp[0][1]) % MOD;
    res = (res + dp[0][2]) % MOD;
    cout << res << endl;
}

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

unsigned long long int gcd(unsigned long long int x,unsigned long long int y){
	return x%y?gcd(y,x%y):y;
}

int main(){
	int n;
	unsigned long long int a=1;
	cin>>n;
	vector<unsigned long long int>t(n);
	for(int i=0;i<n;i++){
		cin>>t[i];
		a*=t[i]/gcd(a>t[i]?a,t[i]:t[i],a);
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 103455

int v[tam];
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,L;
    cin>>n>>L;
    forr(i,0,n)
    {
        cin>>v[i];
    }
    vector<int> sol;
    forr(i,0,n-1)
    {
        if (v[i]+v[i+1]>=L)
        {
            forr(j,0,i)
            sol.pb(j+1);
            for(int j=n-1;j>=i+2;j--)
            sol.pb(j);
            sol.pb(i+1);
            cout<<"Possible\n";
            for(auto num:sol)
                cout<<num<<endl;
            return 0;
        }
    }
    cout<<"Impossible\n";
}
// PLUS ULTRA!!

Measured memory_bytes: 1784
package main

import (
	"fmt"
)

func main() {
	var n, y int
	a, b, c := -1, -1, -1
	fmt.Scan(&n, &y)
	for i := 0; i <= n; i++ {
		for j := 0; i+j <= n; j++ {
			if 10000*i+5000*j+1000*(n-i-j) == y {
				a = i
				b = j
				c = n - i - j
			}
		}
	}
	fmt.Println(a, b, c)
}


Measured memory_bytes: 512
import java.util.*;
public class Main { 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); // osatu
		int y = sc.nextInt(); // goukei
		int yukiti = 0;
		int higuti = 0;
		int noguti = 0;
		
		loop : for(int a = 0; a <= n; a++) {
			for(int b = 0; b <= n - a; b++ ) {
				if(10000* a + 5000*b + 1000*(n-a-b) == y) {
					yukiti = a;
					higuti = b;
					noguti = n - a - b;
					break loop;//ループ抜ける
				}
			}
		}
		if(yukiti == 0 && higuti == 0 && noguti == 0) {
			yukiti = -1;
			higuti = -1;
			noguti = -1;
		}
		System.out.print(yukiti + " " + higuti + " " + noguti);
     }
}

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

int main()
{
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (i % 2 == s[i] - '0') cnt++;
  }
  if (cnt < s.length() - cnt) {
    cout << cnt << endl;
  } else {
    cout << s.length() - cnt << endl;
  }
}


Measured memory_bytes: 512
//ΔAGC035C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n;
int main()
{
	int i,o;
	scanf("%d",&n);
	for(i=1;i<n;i<<=1);
	if(i==n){
		cout<<"No";
		return 0;
	}
	cout<<"Yes"<<endl;
	o=n;
	if(n%2==0)
		n--;
	for(i=2;i<=n;i=i+1)
		cout<<1<<' '<<i<<endl;
	for(i=2;i<=n;i=i+1)
		cout<<o+i<<' '<<(i^1)<<endl;
	cout<<o+2<<' '<<o+1<<endl;
	if(n!=o){
		n=o;
		for(i=1;i<n;i<<=1);
		i>>=1;
		cout<<n<<' '<<i<<endl;
		cout<<o+n<<' '<<(i^1^n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 2304
import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();

      int arr[][]=new int[n][3];
      
      for(int i=0; i<n; i++)
        for(int j=0; j<3; j++)
        	arr[i][j]=sc.nextInt();
      
      
        
      
      int dp[][] =  new int[n][3];
       
      for(int i=0; i<n; i++)
      Arrays.fill(dp[i], Integer.MIN_VALUE);
      
      System.out.println(maxHappiness(arr, 0, -1, dp));
      
    }
  
  public static int maxHappiness(int arr[][], int pos, int prevSelected, int dp[][]){
    
  	if(pos >= arr.length)
      return 0;
    
    if(prevSelected!=-1 && dp[pos][prevSelected] != Integer.MIN_VALUE)
      return dp[pos][prevSelected];
    
    int max = Integer.MIN_VALUE;
    
    for(int i=0;i<3; i++){
       
         if(i != prevSelected){
           
           max = Math.max(max,arr[pos][i] + maxHappiness(arr, pos+1,i,dp ));
         }
    }
    
    if(prevSelected != -1)
       	dp[pos][prevSelected] = max;
    
    return max;
    
  }
}


Measured memory_bytes: 58844
#include <stdio.h>

int main(void){
    int money, num;
    scanf("%d", &money);
    num = money / 1000;
    if(money == num * 1000){
        printf("0\n");
    }
    else{
        printf("%d\n", 1000 * (num+1) - money);
    }
    return 0;
}


Measured memory_bytes: 1728
import java.util.*;
public class Main {
    static final long mod = (long) (1e9 + 7);
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] oks = new boolean[n + 1];
        Arrays.fill(oks, true);
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            oks[a] = false;
        }
        long[] dp = new long[n + 1];
        dp[0] = 1;
        for (int now = 0; now < n; now++) {
            for (int next = now + 1; next <= Math.min(n, now + 2); next++) {
                if (oks[next]) {
                    dp[next] += dp[now];
                    dp[next] %= mod;
                }
            }
        }
        System.out.println(dp[n]);
        sc.close();
    }
}

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

int main(){
  int N,M,ans=0,pe=0;cin >> N >> M;
  vector<bool> A(N,false);
  vector<int> W(N,0);
  for(int i=0;i<M;i++){
    int p;cin >> p;
    p --;
    string S;cin >> S;
    if(S=="AC"){
      A[p] = true;
    }else{
      if(!A[p]){
        W[p] ++;
      }
    }
  }
  for(int p=0;p<N;p++){
    if(A[p]){
      ans ++;
      pe += W[p];
    }
  }
  cout << ans << " " << pe << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
#include <utility>
#include <map>
#include <set>
using namespace std;

int a, b;


int main() {

	cin >> a >> b;

	if (a >= 13) {
		cout << b << endl;
	}
	else if (a >= 6 && a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << '0' << endl;
	}


	return 0;
}

Measured memory_bytes: 764
N=int(input())
ans=0

def answer(N):
    ans=0
    if N<10:
        return N
    ans += 9
    if N<100:
        return ans
    if N<1000:
        return ans + N-99
    ans += 900

    if N<10000:
        return ans
    ans += N-9999
    if N==100000:
        ans -=1
        
    return ans



print(answer(N))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
//#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int32_t main()
{
    IOS;
    string s1,s2;
    cin>>s1;
    cin>>s2;
    int dp[s1.size()+1][s2.size()+1]={};
    memset(dp,0,sizeof(dp));
    string ans="";
    for(int i=0;i<=s1.size();i++)
    {
        for(int j=0;j<=s2.size();j++)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s1[i-1]==s2[j-1])
                {
                    dp[i][j]=1+dp[i-1][j-1];
                }
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int x=s1.size(),y=s2.size();
    while(x>0&&y>0)
    {
        if(s1[x-1]==s2[y-1])
        {
            ans=ans+s1[x-1];
            x--;
            y--;
        }
        else if(dp[x-1][y]>dp[x][y-1])
        {
            x--;
        }
        else
            y--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}


Measured memory_bytes: 35456
#!/usr/bin/env python3
# import bisect

n, k = list(map(int, input().split()))
x = list(map(int, input().split()))

# index = bisect.bisect(list, 0)

# left = index
# right = n - index

# if left != 0:
#     if x[index-1] == 0:
#         k -= 1
#         del(x[index-1])

ans = 10**9
for i in range(0, n-k+1):
    # print(x[i], x[i+k-1])
    if x[i]*x[i+k-1] >= 0:
        ans_tmp = max(abs(x[i]), abs(x[i+k-1]))
    else:
        ans_tmp = abs(x[i]) + abs(x[i+k-1]) + min(abs(x[i]), abs(x[i+k-1]))

    # print(ans_tmp)
    ans = min(ans, ans_tmp)
# print()
print(ans)


Measured memory_bytes: 20044
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] abc = scanner.nextLine().split(" ", 3);
        long a = Long.parseLong(abc[0]);
        long b = Long.parseLong(abc[1]);
        long c = Long.parseLong(abc[2]);

        if (a + b >= c) {
            System.out.println(b + c);
        } else {
            System.out.println(a + b + 1 + b);
        }
    }
}


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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) (x).begin(),(x).end()
#define int ll

#define pt pair<int, int>
#define x first
#define y second

ld dist(pt a, pt b) {
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

bool check(string s) {
	auto t = s;
	reverse(all(t));
	return s == t;
}

void solve() {
	string s;
	cin >> s;
	bool ans = true;
	ans &= check(s);
	int n = s.size();
	string t = "";
	for (int i = 0; i < (n - 1) / 2; i++)
		t += s[i];
	ans &= check(t);
	t = "";
	for (int i = (n + 3) / 2 - 1; i < n; i++)
		t += s[i];
	ans &= check(t);
	if (ans) cout << "Yes";
	else cout << "No";
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout.precision(20);
	int t;
	//cin >> t;
	t = 1;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <utility>
const int d[] = {0,1,2,4,8,-1,-2,-4,-8}, d_[] = {0,1,4,5};
using namespace std;
int main(){
  int N;
  while(cin >> N, N){
    vector< vector<int> > V(N, vector<int>(16));
    for(int i = 0; i < N; ++i)
      for(int j = 0; j < 16; ++j) cin >> V[i][j];
    vector<int> s(16,1);
    bool f = false;
    for(int i = 0; i < 4; ++i){
      if(V[0][5+d_[i]]){
        f = true;
        break;
      }
      s[5+d_[i]] = 0;
    }
    if(f){
      cout << 0 << endl;
      continue;
    }
    set< pair<int, vector<int> > > S;
    S.insert(make_pair(5,s));
    for(int i = 1; i < N; ++i){
      set< pair<int, vector<int> > > S_;
      for(auto itr = S.begin(); itr != S.end(); ++itr){
        int t = (*itr).first;
        vector<int> v = (*itr).second;
        for(int j = 0; j < 16; ++j) ++v[j];
        for(int j = 0; j < 9; ++j){
          int t_ = t + d[j];
          if(t_ < 0 || t_%4 == 3 || t_/4 >= 3 || (t%4 != t_%4 && t/4 != t_/4)) continue;
          vector<int> v_ = v;
          bool f = false;
          for(int k = 0; k < 4; ++k){
            if(V[i][t_+d_[k]]){
              f = true;
              break;
            }
            v_[t_+d_[k]] = 0;
          }
          for(int k = 0; k < 16; ++k)
            if(v_[k] == 7) f = true;
          if(f) continue;
          S_.insert(make_pair(t_,v_));
        }
      }
      S = S_;
    }
    if(!S.empty()) cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}



Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n , A, B;
  cin >> n >> A >> B;
  string s ;
  cin >> s ;
  int dom = 0;
  int fore = 0; 
  for ( int i=0 ; i<n ; i++){
    if (s.at(i) == 'c'){
      cout << "No"<< endl;
      continue ;
    }else if ( s.at(i) == 'a'){
      if (dom+fore<A+B){
      cout <<  "Yes"  << endl;
      dom++ ;
      continue ;
      }else {
        cout << "No"  << endl;
        continue ;
      }
    }else if ( s.at(i) == 'b'){
      if (dom + fore < A+B && fore < B){
      cout << "Yes"  << endl;
        fore++ ;
        continue ;
      }else {
        cout << "No"  << endl;
      continue ;
      }
    }
  }
}

Measured memory_bytes: 3736
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {

	static class C {
		int x, y, d;

		C(int x, int y, int d) {
			this.x = x;
			this.y = y;
			this.d = d;
		}
	}

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

		int h = sc.nextInt();
		int w = sc.nextInt();

		char[][] s = new char[h][];
		boolean[][] wall = new boolean[h][w];
		int count = 0;

		for (int i = 0; i < h; i++) {
			s[i] = sc.next().toCharArray();
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '#') {
					count++;
					wall[i][j] = true;
				}
			}
		}

		Deque<C> dq = new ArrayDeque<>();
		boolean[][] vid = new boolean[h][w];
		vid[0][0] = true;

		dq.addLast(new C(0, 0, 1));
		int ans = 0;

		while (!dq.isEmpty()) {
			C current = dq.pollFirst();
			int x = current.x;
			int y = current.y;
			int d = current.d;

			if ((x == h - 2 && y == w - 1) || (x == h - 1 && y == w - 2)) {
				ans = d + 1;
				break;
			}

			if (x != 0) {
				if (!wall[x - 1][y] && !vid[x - 1][y]) {
					dq.addLast(new C(x - 1, y, d + 1));
					vid[x - 1][y] = true;
				}
			}
			if (x != h - 1) {
				if (!wall[x + 1][y] && !vid[x + 1][y]) {
					dq.addLast(new C(x + 1, y, d + 1));
					vid[x + 1][y] = true;
				}
			}

			if (y != 0) {
				if (!wall[x][y - 1] && !vid[x][y - 1]) {
					dq.addLast(new C(x, y - 1, d + 1));
					vid[x][y - 1] = true;
				}
			}
			if (y != w - 1) {
				if (!wall[x][y + 1] && !vid[x][y + 1]) {
					dq.addLast(new C(x, y + 1, d + 1));
					vid[x][y + 1] = true;
				}
			}
		}

		if (ans == 0) {
			System.out.println(-1);
		} else {
			System.out.println(h * w - ans - count);
		}

	}

}


Measured memory_bytes: 22868
package main

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

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

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

func main() {
	n, k := nextInt(), nextInt()
	h := make([]int, n)

	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}

	sort.Ints(h)

	res := 1<<63 - 1
	for i := 0; i+k-1 < n; i++ {
		t := h[i+k-1] - h[i]
		if t < res {
			res = t
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAX = 10010;

bool p[MAX];

int main()
{
    p[0] = p[1] = 1;
    rep(i,MAX)if(!p[i])for(int j= i*2;j<MAX;j+=i)p[j] = 1;

    int n;
    while(cin >> n && n)
    {
        for(int i = n;i!=0;i--)if(!p[i] && !p[i-2]){ cout << i-2 << " " << i << endl;break;}
    }
    return 0;
}

Measured memory_bytes: 872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int N,A; cin >> N >> A;
  vector<int> x(N);
  rep(i,N) cin >> x[i];

  vector<vector<vector<ll>>> dp(N+1, vector<vector<ll>>(N+1, vector<ll>(2501)));
  dp[0][0][0] = 1;
  rep(i,N) {
    rep(j,N+1) {
      rep(k,2501) {
        if (j == 0) dp[i+1][0][k] = dp[i][0][k];
        else {
          if (k < x[i]) dp[i+1][j][k] = dp[i][j][k];
          else dp[i+1][j][k] = dp[i][j][k] + dp[i][j-1][k-x[i]];
        }
      }
    }
  }
  
  ll ans = 0;
    rep(j,N+1) {
      if (j == 0) continue;
      ans += dp[N][j][A*j];
    }
  cout << ans << endl;
}

Measured memory_bytes: 52224
#include <iostream>

using namespace std;
long double p[200010],sum[200010];
int main(){
	cout.precision(20);
	int i,n,k;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> p[i]; p[i]++;
	}
	sum[0] = 0;
	for(i=1;i<=n;i++){
		sum[i] = sum[i - 1] + p[i - 1];
	}
	long double mx = -1;
	for(i=k;i<=n;i++){
		mx = max(mx,sum[i] - sum[i - k]);
	}
	cout << mx/2 << endl;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int n,k,ans=0,x=1,a;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(a==1)
            x=i+1;
    }
    if(x<=k || x>=n-k+1)
    {
        ans=(n-1)/(k-1);
        if((n-1)%(k-1))
            ans++;
    }
    else
    {
        ans=(x-1)/(k-1);
        ans+=(n-x)/(k-1);
        if(((x-1)%(k-1)) || ((n-x)%(k-1)))
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=998244353;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);
long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main(){
  COMinit();
  int n,m;
  cin >> n >> m;
  vector<int>s(m);
  vector<int>c(m);
  rep(i,m) cin >> s[i] >> c[i];
  if(m==0){
    if(n!=1)cout << pow(10,n-1) << endl;
    else cout << 0 << endl;
    return 0;
  }
  if(n==1){
    for(int i=0;i<10;i++){
      string t=to_string(i);
      bool ok=true;
      rep(j,m){
        if(t[s[j]-1]-'0'!=c[j]){
          ok=false;
          break;
        }
      }
      if(ok){
        cout << i << endl;
        return 0;
      }
    }
  }
  for(int i=pow(10,n-1);i<pow(10,n);i++){
    string t=to_string(i);
    bool ok=true;
    rep(j,m){
      if(t[s[j]-1]-'0'!=c[j]){
        ok=false;
        break;
      }
    }
    if(ok){
      cout << i << endl;
      return 0;
    }
  }
  cout<<-1 << endl;
  return 0;
  
}

Measured memory_bytes: 12160
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long H = stdIn.nextLong();
		long n = 0;
		while(H>0) {
			H /= 2;
			n++;
		}
		System.out.println((long)Math.pow(2, n)-1);
	}
}


Measured memory_bytes: 23764
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    char[] x = in.next().toCharArray();
    int n = x.length;
    for (int i = 0; i < n; i++) {
      char next = i < n - 1 ? x[i + 1] : '?';
      char jump = i < n - 2 ? x[i + 2] : '?';
      if (x[i] == next) {
        out.println((i + 1) + " " + (i + 2));
        return;
      } else if (x[i] == jump) {
        out.println((i + 1) + " " + (i + 3));
        return;
      }
    }
    out.println("-1 -1");
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

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

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


Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main(void){

  int N;  cin >> N;
  string s, t;  cin >> s >> t;

  for(int count = N ; 0 < count ; count--){
    string str1 = s.substr(N - count, count), str2 = t.substr(0, count);
    if(str1 == str2){
      cout << 2 * N - count;
      return 0;
    }
  }

  cout << 2 * N << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int H, W;
		String str = null;
		String[] input = new String[2];
		int i, j;

		while(true){
			str = scan.nextLine();
			input = str.split(" ");

			H = Integer.parseInt(input[0]);
			W = Integer.parseInt(input[1]);

			if(3 <= H && 3 <= W){
				for(i=0; i<H; i++){
					for(j=0; j<W; j++){
						if(j==0 || j==(W-1)){
							System.out.print("#");
						}
						else if(i==0 || i==(H-1)){
							System.out.print("#");
						}
						else{
							System.out.print(".");
						}
					}
					System.out.println();
				}
				System.out.println();
			}
			if (H==0 && W==0){
				break;
			}
		}

	}
}


Measured memory_bytes: 34100
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>
#include <algorithm>
#include<iomanip>
#define INF 1000000000
#define LM 55555
#define LL long long
using namespace::std;


long long  X,Y,x[100],y[100],xm,ym,now, num, N, K, M, ans;
string S, s[100];
bool h,w[10], k[100],con[300];
char cc;


int main() {
	cin >> N>>M>>X>>Y;
	xm = -50000;
	ym = 50000;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
		xm = max(xm, x[i]);
	}
	for (int i = 0; i < M; i++) {
		cin >> y[i];
		ym = min(ym, y[i]);
	}
	for (int i = X + 1; i <= Y; i++) {
		if (xm<i && ym >= i) {
			cout <<"No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;

	return 0;

}

Measured memory_bytes: 256