akhauriyash/Code-Regression huggingface dataset:
import numpy as np
inputs = open(0).readlines()

def main(inputs):
    h, w, k = map(int, inputs[0].split())
    cake, count, coords = np.zeros((h, w), dtype=np.uint), 0, {}
    for i, s in enumerate(inputs[1:]):
        for j, c in enumerate(s):
            if c == '#':
                count += 1
                cake[i, j] = count
                coords[count] = (j, i)
    empty_rows = {i for i, rows in enumerate(cake) if not np.any(rows)}

    for i in range(1, count+1):
        x, y = coords[i]
        x0, y0 = x-1, y-1
        x1, y1 = x+1, y+1
        while 0 <= x0 and cake[y, x0] == 0:
            cake[y, x0] = i
            x0 -= 1
        x0 += 1
        while x1 < w and cake[y, x1] == 0:
            cake[y, x1] = i
            x1 += 1
        while 0 <= y0 and y0 in empty_rows:
            cake[y0, x0:x1] = i
            y0 -= 1
        while y1 < h and y1 in empty_rows:
            cake[y1, x0:x1] = i
            y1 += 1

    for rows in cake:
        print(*rows)

main(inputs)

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

int main(){
  int n;cin >> n;
  int ans = 0;
  for(int i=1;i<=n;i++){
    string s = to_string(i);
    if(s.length()%2 != 0)ans += 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

mod=1000000007
n,m=mp()
dp=[0]*(n+2)
dp[0]=1
for i in range(m):
    a=int(input())
    dp[a]=-1
for i in range(n):
    if dp[i]==-1:
        continue
    if dp[i+1]>=0:
        dp[i+1]+=dp[i]
        dp[i+1]=dp[i+1]%mod
    if dp[i+2]>=0:
        dp[i+2]+=dp[i]
        dp[i+2]=dp[i+2]%mod
print(dp[-2]%mod)

Measured memory_bytes: 67416
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iterator>
#include <math.h>
#include <algorithm>
using namespace std;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n;
  ll ans=0;
  cin>>n;
  vector<ll>v(n,0);
  ll x=0;
  for(ll i=0;i<n;i++){
    cin>>v[i];
    x=x^v[i];
  }

  if(x!=0){
    ll tmp=0;
    vector<ll>z;
    ll f=0;
    for(ll i=0;i<n;i++){
      tmp=tmp^v[i];
      if(tmp==0&&f==1)z.push_back(0);
      if(tmp==x){
        f=1;
        z.push_back(1);
        tmp=0;
      }
    }
    vector<vector<ll> >p(2,vector<ll>(z.size(),0));
    if(z.size()==1){
      cout<<1<<endl;
      return 0;
    }
    p[0][0]=1;
    p[1][0]=1;
    for(ll i=1;i<(ll)z.size();i++){
      if(z[i]==0){
        p[0][i]=(p[0][i-1]+p[1][i-1])%MOD;
        p[1][i]=p[1][i-1]%MOD;
      }
      else{
        p[0][i]=(p[0][i-1]+p[1][i-1])%MOD;
        p[1][i]=p[0][i-1]%MOD;
      }
    }
    ans=p[1][z.size()-1];
    cout<<ans<<endl;
  }
  else{
    ll tmp=0;
    vector<ll>z;
    for(ll i=0;i<n;i++){
      tmp=tmp^v[i];
      if(tmp==0)z.push_back(0);
    }
    vector<vector<ll> >p(2,vector<ll>(z.size(),0));
    if(z.size()==1){
      ans+=1;
    }
    else if(z.size()==2){
      ans+=3;
    }
    else{
      p[0][0]=1;
      p[1][0]=1;
      for(ll i=1;i<(ll)z.size();i++){
        p[0][i]=(p[0][i-1]+p[1][i-1])%MOD;
        p[1][i]=(p[0][i-1]+p[1][i-1])%MOD;
      }
      ans+=p[1][z.size()-1];
    }

    map<ll,vector<ll>>mp;
    map<ll,ll>mp2;
    set<ll>st;
    tmp=0;
    ll zz=0;
    for(ll i=0;i<n;i++){
      tmp=tmp^v[i];
      if(tmp==0){
        for(auto itr = st.begin(); itr != st.end(); ++itr){
          mp[*itr].push_back(zz+mp2[*itr]);
        }
        st.clear();
        zz++;
      }
      else{
        if(st.count(tmp)){}
        else mp[tmp].push_back(zz+mp2[tmp]);
        mp2[tmp]++;
        st.insert(tmp);
      }
    }
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
      z=(itr->second);
      if(z.size()==1){
        ans=(ans+1)%MOD;
        ans%=MOD;
        continue;
      }
      ll p0=1;
      ll p1=1;
      ll pp0,pp1;
      for(ll i=1;i<(ll)z.size();i++){
        pp0=(p0+(z[i]-z[i-1])*p1%MOD)%MOD;
        pp1=(p0+(z[i]-z[i-1]-1)*p1%MOD)%MOD;
        p0=pp0;
        p1=pp1;
      }
      ans=(ans+p1)%MOD;
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 58220
#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int n, ma, mb;
int a[N], b[N], c[N];
int dp[N][20*N][20*N];

int solve (int i, int aa, int bb)
{
	if (aa >0 && bb >0)
		if (abs((double)aa / (double)bb - (double(ma) / double(mb))) <= 1e-9) {
			return 0;
		}
	if (i >= n) {
		return 1e9;
	}
	int &res = dp[i][aa][bb];
	if (res != -1)
		return res;
	int solve1 = 0, solve2 = 0;
	solve1 = solve(i+1, a[i]+aa, b[i]+bb)+c[i];
	solve2 = solve(i+1, aa, bb);
	return res = min(solve1, solve2);
}

int main ()
{
	cin >> n >> ma >> mb;
	memset(dp, -1, sizeof dp);
	for (int i = 0; i< n ; i ++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	
	int s = solve(0, 0, 0);
	if (s >= 1e9)
		cout << -1 << endl;
	else
		cout << s << endl;
	return 0;
}


Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int a,b,c,d;cin >> a >> b >> c >> d;
    for (int i = 0; i < 1000; i++) {
        c -= b;
        if(c <= 0){
            puts("Yes");
            return 0;
        }
        a -= d;
        if(a <= 0){
            puts("No");
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#define A first
#define B second
using namespace std;
pair<int,int>z[3000];
int n,x,y,ans;
bool IT(int x,int y){
	int left=0,right=n,mid;
	while(true){
		if(left>=right-1)break;
		mid=(left+right)/2;
		if(z[mid].A==x&&z[mid].B==y)return true;
		if(z[mid].A<x||(z[mid].A==x&&z[mid].B<y))left=mid;
		else right=mid;
	}
	return false;
}
int main(){
	while(true){
	cin>>n;
	if(!n)break;
	for(int i=0;i<n;i++)cin>>z[i].A>>z[i].B;
	sort(z,z+n);
	ans=0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			x=z[i].B-z[j].B;
			y=z[i].A-z[j].A;
			if(IT(z[i].A+x,z[i].B-y)&&IT(z[j].A+x,z[j].B-y))ans=max(ans,x*x+y*y);
			if(IT(z[i].A-x,z[i].B+y)&&IT(z[j].A-x,z[j].B+y))ans=max(ans,x*x+y*y);
		}
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    int ans = 0;
    int minv = INF;
    rep(i, n){
        ans += (minv >= v[i]);
        chmin(minv, v[i]);
    }
    cout << ans << endl;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 1e2 + 5;
int mat[MAX][MAX];
int dp[MAX][MAX];

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

	int n;
	cin >> n;

	fori(i, 1, 3) {
		fori(j, 1, n + 1) {
			cin >> mat[i][j];
		}
	}

	fori(i, 1, 3) {
		fori(j, 1, n + 1) {
			dp[i][j] = mat[i][j] + max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	cout << dp[2][n] << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <set>
#include <algorithm>
#include <map>
 
 
using namespace std;
 
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pll, int> para;
const ll inf = 2e18 + 7;
const int maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;
 
int n;
ll k, a[maxN], sum, f[maxN];
set<pll, greater<pll> > s;

bool solve(ll z) {
	ll ile = k;
	REP(i, n) {
		if (a[i] * f[i] > z) {
			ll p = z / f[i];
			ile -= (a[i] - p);
			if (ile < 0) return false;
		}
	}
	return true;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	REP(i, n) cin >> f[i];
	sort(a, a + n, greater<ll>());
	sort(f, f + n);
	int cnt = 0;
	if (sum <= k) cout << 0 << endl;
	else {
		ll l = 0, r = 1e12;
		while (l < r) {
			ll mid = (l + r) / 2;
			if (solve(mid)) {
				r = mid;
			} else {
				l = mid + 1;
			}
		}
		cout << r << endl;
	}
	return 0;
}


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

void main_()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> hs;
    hs.reserve(N);
    copy_n(istream_iterator<ll>(cin), N, back_inserter(hs));

    vector<ll> dp(N, numeric_limits<ll>::max());
    dp[0] = 0;
    for (ll i = 1; i < N; ++i) {
        for (ll j = 1; j <= K; ++j) {
            if (i - j >= 0) {
                auto c = dp[i - j] + abs(hs[i] - hs[i - j]);
                dp[i] = min(dp[i], c);
            }
        }
    }

    cout << dp[N - 1] << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MOD 1000000007
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % MOD;
        y = y >> 1;
        x = (x * x) % MOD;
    }
    return res;
}
int main()
{
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    ll s1,s2,s3;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    s1=a[0];s2=b[0];s3=c[0];
    ll s11=s1,s22=s2,s33=s3;
    for(ll i=1;i<n;i++)
    {
        s1=max(s22+a[i],s33+a[i]);
        s2=max(s11+b[i],s33+b[i]);
        s3=max(s22+c[i],s11+c[i]);
        s11=s1;s22=s2;s33=s3;
    }
    ll answer= max(s1,max(s2,s3));
    cout<<answer<<endl;
}

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

int main() {
  int r, D; cin >> r >> D;
  int x[11]; cin >> x[0];
  
  for (int i = 0; i < 10; ++i) {
    x[i+1] = r*x[i] - D;
    cout << x[i+1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
s = input()

if s != s[::-1]:
  print("No")
  exit()
if s[:(len(s)-1)//2] != s[:(len(s)-1)//2][::-1]:
  print("No")
  exit()
if s[(len(s)+3)//2-1:] != s[(len(s)+3)//2-1:][::-1]:
  print("No")
  exit()
  
print("Yes")

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int x=0;
  for(int i=a; i<b+1; i++){
    if(c%i==0){
      x++;
    }
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int l=n/2,r=n/2+1;
	printf("%d\n",a[r]-a[l]);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
//const int MAX=;

int main(){
	int A,B;
	cin>>A>>B;
	if(B%A==0)cout<<A+B;
	else cout<<B-A;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = []
for _ in range(H):
    C.append(input())

# 遍历所有可能，状态压缩
status = [0] * (H+W)

stat = ['0', '1']
for _ in range(len(status)-1):
    tmp = []
    for j in stat:
        tmp.append(j + '0')
    for j in stat:
        tmp.append(j + '1')
    stat = tmp

# print(stat)

ret = 0
for s in stat:
    count = 0
    row = s[:H]
    hel = s[H:]
    for i in range(H):
        if row[i] == '1':
            continue
        for j in range(W):
            if hel[j] == '1':
                continue
            if C[i][j] == '#':
                count += 1
    if count == K:
        # print('aaaaa')
        ret += 1
print(ret)

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

int main () {
  int x;
  int y;
  int z;
  cin>>x>>y>>z;
  
  if ((x+y+z)>=22) {
    cout<<"bust"<<endl;
  }
  
  else {
    cout<<"win"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	ll ans=n*m-2*n-2*m-4+8;
	if(m==1){
		if(n==1){
			ans=1;
		}else{
			ans=n-2;
		}
	}else{
		if(n==1){
			ans=m-2;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
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)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> p(n);
  
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
    p[a[i]]++;
  }
  
  int64_t sum = 0;
  for(int i = 0; i < n; i++){
    int64_t m = p[i];
    if(m > 1)
      sum += m*(m-1)/2;
  }
  
  for(int i = 0; i < n; i++){
    int64_t m1 = p[a[i]];
    m1 = m1*(m1-1)/2;
    p[a[i]]--;
    int64_t m2 = p[a[i]];
    m2 = m2*(m2-1)/2;
    int64_t s = sum - m1 + m2;
    cout << s << endl;
    p[a[i]]++;
  }
  
  return 0;
  
}

Measured memory_bytes: 4096
n = int(input())

line={}
c=0

for i in range(n):
    string = ''.join(sorted(list(input())))
    # print(string)
    if string in line:
        c+=line[string]
    if string in line:
        line[string]+=1
    else:
        line[string]=1
    # print(line,c)

print(c)

Measured memory_bytes: 65880
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N,L;
string S[101];

int main()
{
  cin >> N >> L;
  for (int i = 0; i < N; ++i) cin >> S[i];
  sort(S,S+N);
  for (int i = 0; i < N; ++i) cout << S[i];
  return 0;
}

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

#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ld long double
#define EPS (1e-9)
#define OO (1ll << 50)
#define mod 1000000007
#define pii pair<int , int>

using namespace std;
const int N = 500005;
int a, b;

int main() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	io;
	cin >> a >> b;
	cout << (2 * b - a) << endl;
	return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int K;
    cin >> K;

    const int LIM = 500;

    if (K <= LIM) {
        cout << K << "\n";
        for (int r = 0; r < K; r++) {
            for (int c = 0; c < K; c++) {
                cout << r + 1 << " ";
            }
            cout << "\n";
        }
    } else {
        int N = LIM;
        cout << N << "\n";
        for (int r = 0; r < N; r++) {
            for (int c = 0; c < N; c++) {
                int d = (r + c) % N;
                if ((r&1) && (d < K - LIM)) {
                    cout << d + 1 + LIM << " ";
                } else {
                    cout << d + 1 << " ";
                }
            }
            cout << "\n";
        }
    }

    return 0;
}



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

int main(){
  ll n,d;
  cin >> n >> d;
  if(n%(d*2+1) == 0){
    cout << n/(d*2+1) << endl;
  }else{
    cout << n/(d*2+1) +1 << endl;
  }
  return 0;
}


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

#define unknown -1

int main(void) {
	int groups[3][7] = {{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}};
	int size[] = {7, 4, 1};
	int i, j, k, num[2];
	char group[] = {unknown, unknown};
	scanf("%d %d", &num[0], &num[1]);
	for (i = 0; i < 2; i++) {
		for (j = 0; j < 3; j++) {
			for (k = 0; k < size[j]; k++)
			if (groups[j][k] == num[i]) {
				group[i] = j;
				break;
			}
		}
	}
	printf("%s\n", group[0] == group[1] ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 128
p=Array.new(10){(0..9).map{0}}
ds=[0,1,2,4]

while input=gets
	x,y,size=input.chomp.split(",").map{|s| s.to_i}
	d=ds[size]
	10.times{|i|
		10.times{|j|
			if (x-i)**2+(y-j)**2<=d
				p[i][j]+=1
			end
		}
	}
end

pf=p.flatten
count=pf.select{|k| k==0}.length
max=pf.max
puts count,max


Measured memory_bytes: 6880
N=int(input())
A=list(map(int,input().split()))
arai=sum(A)
sunuke=0
ans=float('inf')
for i in range(N):
    a=A[i]
    arai-=a
    sunuke+=a
    if i==N-1:continue
    ans=min(ans,abs(arai-sunuke))
print(ans)

Measured memory_bytes: 24936
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        double a = scan.nextInt();
        double b = scan.nextInt();
        double x = scan.nextInt();
        double current = x / a;
        if (current == a * b) {
            System.out.println(0);
            return;
        }
        if (current <= a * b / 2) {
            double height = 2 * current / b;
            double atan2 = 90 - Math.abs(Math.atan2(height, b)) * 180 / Math.PI;
            System.out.printf("%.9f\n", atan2);
            return;
        }
        double height = (2 * current - b * a) / a;
        double atan2 = Math.abs(Math.atan2(b - height, a)) * 180 / Math.PI;
        System.out.printf("%.9f\n", atan2);
    }
}


Measured memory_bytes: 21844
N = gets.to_i
A = gets.chomp.split.map(&:to_i)

# 値が小さいインデックスを入れる
# インデックス+1を出力
tmp=0
B=Array.new(A.length)
A.each_index do |i|
  # キーが(揃った人数-1)、値が出席番号
  B[A[i]-1]=i+1
end

puts B.join(" ")

Measured memory_bytes: 13188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();

			System.out.print(Math.max(Math.min(b, d) - (Math.max(a, c)), 0));
		}
	}
}


Measured memory_bytes: 21972
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,h,m = LI()
    x = 30*h+0.5*m
    y = 6*m
    cos = math.cos(abs(x-y)/180*3.141592653589793238)
    c = a**2+b**2-2*a*b*cos
    print(c**0.5)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 67744
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 55;

int n, a[N], b[N], c[N];
bool mark[N];
vector <int> q;

bool check() {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < N; j++) {
            mark[j] = false;
        }
        mark[a[i]] = true;
        q.push_back(a[i]);
        for (int j = 0; j < q.size(); j++) {
            int now = q[j];
            for (int k = 1; k < N; k++) {
                int tmp = now % k;
                if (c[k] == 1 && !mark[tmp]) {
                    mark[tmp] = true;
                    q.push_back(tmp);
                }
            }
        }
        q.clear();
        if (!mark[b[i]]) {
            return false;
        }
    }
    return true;
}

int main() {

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    for (int i = 0; i < n; i++) {
        scanf("%d", &b[i]);
    }

    for (int i = 0; i < N; i++) {
        c[i] = 1;
    }

    if (!check()) {
        puts("-1");
        exit(0);
    }

    long long res = 0;

    for (int i = N - 1; i >= 0; i--) {
        c[i] = 0;
        if (!check()) {
            c[i] = 1;
            res |= 1LL << i;
        }
    }

    printf("%lld\n", res);

    return 0;

}


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

int main(){
  int k,t;
  cin>>k>>t;
  if(t==1){
    cout<<k-1<<endl;
    return 0;
  }
  int vec[t];
  for(int i=0;i<t;i++){
    cin>>vec[i];
  }
  sort(vec,vec+t);
  if(vec[t-1]<=(k+1)/2){
    cout<<0<<endl;
    return 0;
  }
  int ans=(vec[t-1]-(k+1)/2)*2;
  if(k%2==0){
    ans--;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

ll dp[MAX * 2];
int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	memr(dp, 0);
	int n, k; cin >> n >> k;
	vector<int> v(n);
	rep(i, n) {
		cin >> v[i];
		dp[v[i]]++;
	}
	sort(dp, dp + MAX * 2, greater<ll>());

	ll sum = 0;
	rep2(i, k, MAX * 2){
		sum += dp[i];
	}

	cout << sum << endl;


	return 0;
}


Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int top(int n) {
  int k = 0;
  while (n) {
    k = n % 10;
    n /= 10;
  }
  return k;
}
int main() {
  int N;
  cin >> N;
  LL cnt = 0;
  VEC<VEC<int>> P(10, VEC<int>(10, 0));

  REP(i, 1, N + 1) {
    int h = top(i);
    int t = i % 10;
    // DUMP(i, h, t);
    if (t == 0) continue;
    P[h][t]++;
  }
  REP(i, 0, 10) { DUMP(i, P[i]); }

  REP(h, 1, 10) {
    REP(t, 1, 10) {
      // DUMP(a, h, t, cnt);
      cnt += P[h][t] * P[t][h];
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,arr[4]={0};
  cin >> n;
  while(n--){
    string str;
    cin >> str;
    if(str[0]=='A')
      arr[0]++;
    else if(str[0]=='W')
      arr[1]++;
    else if(str[0]=='T')
      arr[2]++;
    else
      arr[3]++;
  }
  cout << "AC" << " " << "x" << " " << arr[0] << endl;
  cout << "WA" << " " << "x" << " " << arr[1] << endl;
  cout << "TLE" << " " << "x" << " " << arr[2] << endl;
  cout << "RE" << " " << "x" << " " << arr[3] << endl; 
  return 0;
}

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

class Graph {
    vector<vector<int>> adj;
    vector<int> color;

public:
    Graph(int n) : adj(n), color(n, -1) {}

    void connect(int a, int b) {
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    bool dfs(int from = 0, int cur = 0) {
        color[from] = cur;
        for (auto to : adj[from]) {
            if (color[to] == cur) return false;
            if (color[to] == -1 && !dfs(to, 1 - cur)) return false;
        }
        return true;
    }

    vector<int> &getColor() {
        return color;
    }
};

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

    Graph graph(n);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        graph.connect(--a, --b);
    }

    long long ans;
    if (graph.dfs()) {
        int cnt[2] = {0};
        for (auto i : graph.getColor()) cnt[i]++;
        ans = (long long)cnt[0] * cnt[1] - m;
    } else {
        ans = (long long)n * (n - 1) / 2 - m;
    }

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

Measured memory_bytes: 6272
#gets.to_i
#data = gets.split(" ").map{|nn|nn.to_i}
#n = data[]
#m = data[]
#a = data[]
#a = data[]
#c = data[]
#n.times do
#end

data = gets.chomp.chars

cost_first_white = 0
for i in 0..(data.size-1) do
  if i % 2 == 0
    if data[i] == "0"
    else
      cost_first_white += 1
    end
  else
    if data[i] == "1"
    else
      cost_first_white += 1
    end
  end

end
cost_first_black = 0

for i in 0..(data.size-1) do
  if i % 2 == 0
    if data[i] == "1"
      next
    else
      cost_first_black += 1
    end
  else
    if data[i] == "0"
      next
    else
      cost_first_black += 1
    end
  end
end


if cost_first_black < cost_first_white
  puts cost_first_black.to_s
else
  puts cost_first_white.to_s
end

Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    sort(a.begin(), a.end());
    cout << a.at(0) << " " << a.at(1) << " " << a.at(2) << endl;
}


Measured memory_bytes: 3052
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String s = scan.next();
        int c = s.charAt(0);
        os.println((char) (c+1));
    }
}

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

int main() {
    string S; cin >> S;

    int cnt = 0;
    for(int i = 0; i < S.size(); ++i) {
        if(S[i] == 'o') {
            cnt++;
        }
    }

    cout << 700 + 100 * cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(ll i=(ll)(x);i<(ll)(y);++i)
#define For(i,x,y)  for(ll i=(ll)(x);i<=(ll)(y);++i)
#define FOr(i,x,y)  for(ll i=(ll)(x);i>=(ll)(y);--i)
#define pi acos(-1) 
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define E(x)        return writeln(x),0
#define LL			(long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)	printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue		puts("\nGuYueNa________________________________________________________________________________")
#define y1			fafa____
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_; 
#endif 
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,GYN,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
	void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);puts("");}
	void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);puts("");}
	void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);puts("");}
	void writeln(ll x){write(x);putchar('\n');}
}using namespace SHENZHEBEI;
const ll N=100010;
ll a[N],n,pos;
bool cmp(ll a,ll b){return a>b;}
int main(){
	n=read();
	For(i,1,n)a[i]=read();
	sort(a+1,a+n+1,cmp);
	ll cur=0;
	for(;a[pos]>=pos;++pos);--pos;//a[pos]>=pos
	ll ans1=a[pos]-pos+1,ans2;
	For(i,1,n)if (a[i]>=pos)ans2=i;ans2-=pos-1;
	puts((ans1&ans2)&1?"Second":"First");
}
/*
1 1
1 1
一定是1在结尾....

他不一定选2啊。
f[2][1]...
f[1][1]
f[j][k]
小的那个是i,上面还有j剩下。
1.选择上面的
2.枚举下一个。。
选1个,2个,3个。.


*/

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int[][] a = new int[3][n+1];
		for (int i=1; i<=2; i++) {
			for (int j=1; j<=n; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		sc.close();
		int dmax = 0;
		int aup = 0;
		int adown = 0;
		for (int k=1; k<=n; k++) {
			for (int i=1; i<=k; i++) {
					aup += a[1][i];
			}
			for (int i=k; i<=n; i++) {
				adown += a[2][i];
			}
			dmax = Math.max(dmax, aup+adown);
			aup = 0;
			adown = 0;
		}
		System.out.println(dmax);
	}

}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))


int main() {
	ll n;
	cin >> n;
	vector<ll> v(n);
	rep(i,n) cin>>v[i];
	sort(v.begin(),v.end());
	// rep(i,n) cout<<v[i]<<endl;	
	v.erase(unique(v.begin(),v.end()), v.end());
	// どうやた、uniqueの末尾には残骸が残るので消す必要あり
	cout << v.size() << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
  
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
  
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
  
int F()
{
    char ch;
    int x, a;
    while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
    if (ch == '-') ch = getchar(), a = -1;
    else a = 1;
    x = ch - '0';
    while (ch = getchar(), ch >= '0' && ch <= '9')
        x = (x << 1) + (x << 3) + ch - '0';
    return a * x;
}
  
int A, B, C;
  
int main()
{
    giii(A, B, C);
    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) puts("0");
    else printf("%lld\n", min(1LL * A * B, min(1LL * B * C, 1LL * A * C)));
    return 0;
}

Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))
a = [b[0]]
if N == 2:
  print(2*a[0])
elif N > 2:
  for i in range(N-2):
    a.append(min(b[i], b[i+1]))
  a.append(b[N-2])
  print(sum(a))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  map<int,int>mp;
  vector<int>X(N);
  vector<int>ans(N*N,-1);
  REP(i,N){
    cin>>X[i];
    X[i]--;
    mp[X[i]]=i;
    ans[X[i]]=i+1;
  }
  sort(ALL(X));
  int left=0;
  REP(i,N){
    int x=X[i];
    int j=mp[x];
    // 左からj個詰める。
    REP(k,j){
      while(true){
        if(ans[left]==-1){
          ans[left]=j+1;
          left++;
          break;
        }else{
          left++;
        }
      }
    }
  }
  sort(rALL(X));
  int right=N*N-1;
  REP(i,N){
    int x=X[i];
    int j=mp[x];
    // 右からN-j-1個詰める。
    REP(k,N-j-1){
      while(true){
        if(ans[right]==-1){
          ans[right]=j+1;
          right--;
          break;
        }else{
          right--;
        }
      }
    }
  }

  // 条件を満たすか確認
  bool flag=true;
  REP(i,N){
    int x=X[i];
    int j=mp[x];
    // x番目のj+1までにj+1がj個有ることを確認
    if(count(ans.begin(), ans.begin()+x, j+1)!=j)flag=false;
  }
  if(flag){
    cout<<"Yes"<<endl;
    REP(i,N*N-1){
      cout<<ans[i]<<" ";
    }
    cout<<ans[N*N-1]<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


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

int main() {
	char d='A'-'a';
	string a,b;cin>>a>>b;
	if(a.size()==b.size()) {
		if(a>b) cout<<"GREATER"<<endl;
		else if(a==b) cout<<"EQUAL"<<endl;
		else cout<<"LESS"<<endl;
	} else {
		if(a.size()>b.size()) cout<<"GREATER"<<endl;
		else cout<<"LESS"<<endl;
	}
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int a[M], b[M];
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
  }

  int c[N];
  for (int i = 0; i < N; i++) c[i] = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (a[j] == i+1 || b[j] == i+1) c[i]++;
    }
  }

  for (int i = 0; i < N; i++) {
    cout << c[i] << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
using namespace std;

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

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

	cout << "\n";
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {

    ll n,m;
    cn n>>m;
    if(n<10 && m<10)ct n*m;
    else ct -1;
    






    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}
int main(){
    ll n;cin>>n;
    vi a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    vvi dp(1<<n,vi(n,inf));
    rep(j,n)dp[1<<j][j]=0;
    rep(i,1<<n){
        rep(j,n){
            if(dp[i][j]==inf)continue;
            rep(nx,n){
                if(i>>nx&1)continue;
                int bx;
                int s=0;
                rep(k,n)if(i>>k&1)s++;
                if((s+j)%2)bx=a[j];
                else bx=b[j];
                int cx;
                if((s+nx)%2)cx=b[nx];
                else cx=a[nx];
                int ni=i+(1<<nx);
                if(bx>cx)continue;
                ll mi=dp[i][j];
                REP(k,nx+1,n)if(i>>k&1)mi++;
                chmin(dp[ni][nx],mi);
            }
        }
    }
    ll ans=inf;
    rep(j,n)chmin(ans,dp[(1<<n)-1][j]);
    if(ans!=inf)out(ans);
    else out(-1);
}

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

const long long MOD = 1e9 + 7;


int main(void){
    long long n, k; cin >> n >> k;
    vector<long long> v;
    for(long long i = 1; i * i <= n; i++){
        if(i * i == n){
            v.push_back(i);
            break;
        }
       v.push_back(i);
       v.push_back(n / i);
    }
    sort(v.begin(),v.end());

    long long N = v.size();
    long long vv[N];
    long long L = 0;
    for(int i = 0; i < N; i++){
        vv[i] = v[i] - L;
        L = v[i];
    }

    long long dp[k + 1][N];
    long long a[N + 1];
    for (int i = 0; i < k + 1; i++) for (int j = 0; j < N; j++) dp[i][j] = 0;
    for (int i = 1; i <= k; i++) {
        if (i == 1) a[0] = 1;
        else a[0] = 0;
        for (int j = 0; j < N; j++) {
            a[j + 1] = a[j] + dp[i-1][j];
            a[j + 1] %= MOD;
        }
        for(int j = 0; j < N; j++){
            dp[i][j] = a[N - j] * vv[j];
            dp[i][j] %= MOD;
        }
    }
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += dp[k][i];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 51704
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vip a(n);
		vs b(n);
		for(int i=0;i<n;i++){
			cin>>b[i];
			int c[9];
			for(int j=0;j<9;j++) cin>>c[j];
			a[i].first=i;
			a[i].second={c[6]*c[7]*c[8]-c[0],c[1]+c[2]+c[3]+(c[4]+c[5])*c[8]};
		}
		sort(a.begin(),a.end(),[&](pip p,pip q){
			P s=p.second,t=q.second;
			int tmp=s.first*t.second-s.second*t.first;
			if(tmp) return tmp>0;
			return b[p.first]<b[q.first];
		});
		for(int i=0;i<n;i++) cout<<b[a[i].first]<<endl;
		cout<<'#'<<endl;
	}
}


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

const int INF = 1001001001;
//const ll INF = 1000000000000000000;

ll a, b, v, w, t;

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

	string ans;
	int a = 'a';
	while (n > 0) {
		n--;
		ll q = n / 26;
		int r = n % 26;
		ans.push_back(static_cast<char>(r + a));
		n = q;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>

int main(){
    int N, s,t;
    scanf("%d", &N);
    int a[N];
    int b[N];
    int min_b;
    for (s = 0; s < N; s++)
    {
        scanf("%d", &a[s]);
        if(a[s]%2==0){
            for (t = 0; a[s] % 2 == 0;t++){
                a[s] = a[s] / 2;
        }
        }else{
            t = 0;
        }
        b[s] = t;
    }
    min_b = b[0];
    for (s = 0; s < N;s++){
        if(min_b > b[s]){
            min_b = b[s];
        }
    }
    printf("%d", min_b);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
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;

int main() {
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int z = min(X,Y);
  X -= z; Y -= z;
  int ans = 0;
  
  if (A+B >= 2*C) ans += z*2*C;
  else ans += z*(A+B);
  if (A >= 2*C) ans += X*2*C;
  else ans += X*A;
  if (B >= 2*C) ans += Y*2*C;
  else ans += Y*B;
  
  cout << ans << endl;
}
  

Measured memory_bytes: 3556