akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
int A, B, C, X, Y, ans;
int Value(int a, int b) {
	if(a < 0 || b < 0 || X - a < 0 || a - b - X + Y > 0) return 0x7fffffff;
	//printf("%d %d %d\n", a, b, 2 * X * C + (A - 2 * C) * a + B * b);
	return 2 * X * C + (A - 2 * C) * a + B * b;
}
int Calc() {
	int min = 0x7fffffff;
	min = std::min(min, Value(0, Y - X));
	min = std::min(min, Value(X - Y, 0));
	min = std::min(min, Value(X, Y));
	min = std::min(min, Value(0, 0));
	min = std::min(min, Value(X, 0));
	//printf("%d\n", min);
	return min;
}
int main() {
	scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
	ans = Calc();
	std::swap(X, Y);
	std::swap(A, B);
	ans = std::min(ans, Calc());
	printf("%d\n", ans);
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	IOS;
	int d,g;
	cin >> d >> g;
	vector<int> p(d),c(d);
	for(int i = 0; i < d; i++) cin >> p[i] >> c[i];
	int ans = INF;
	for(int i = 0; i < (1<<d); i++){
		int num = 0,sum = 0,tmp = i;
		for(int j = 0; j < d; j++){
			if(i&(1<<j)){
				sum += (j+1)*p[j]*100 + c[j];
				num += p[j];
			}
		}
		if(sum >= g) ans = min(ans,num);
		else{
			for(int j = 0; j < d; j++){
				if(!(i&(1<<j)) && sum+(j+1)*p[j]*100 >= g){
					while(sum < g) sum += (j+1)*100,num++;
					ans = min(ans,num);
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    REP(i, N) { cin >> d[i]; }
    sort(ALL(d));
    int left = d[N / 2 - 1];
    int right = d[N / 2];
    cout << right - left << endl;
}

Measured memory_bytes: 640
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#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 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<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	for (auto x: s) {
		ans = (ans + (x - '0')) % 9;
	}
	if (ans == 0) cout << "Yes\n";
	else cout << "No\n";
	return 0; 
}
 


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define fori(i,a,b) for(int i=a,b_=b;i<=b_;++i)
#define ford(i,a,b) for(int i=a,b_=b;i>=b_;--i)
#define forv(i,a) for(auto &i:a)
#define ll long long
#define pb push_back
#define pp pop_back()
#define pii pair<ll,ll>
#define fi first
#define se second
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define getbit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define ___ << "\n"
#define __ << " " <<
#define _ << " "
using namespace std;

const int N=21, mod=1e9+7;
int n,a[N+5][N+5];
ll f[(1<<N)+5];

int main()
{
    cin >> n;
    fori(i,1,n) fori(j,1,n) cin >> a[i][j];

    int tg=(1<<n)-1;
    f[0]=1;
    fori(tt,0,tg)
    {
        int i=__builtin_popcount(tt)+1;
        fori(j,1,n) if(a[i][j]==1 && getbit(tt,j)==0)
        {
            int tt2=onbit(tt,j);
            f[tt2]=(f[tt2]+f[tt])%mod;
        }
    }
    cout << f[tg];
}


Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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;
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}

void solve(void){
    ll n;
    cin >> n;
    
    cout << divisors(n);
}

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

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

#define ll long long int
#define ld long double
#define pb push_back

ll mod = 1000000007;

using namespace std;

int main()
{
	
	 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	 int n,b;
	 cin>>n>>b;
	 if(n < 6)
	 {
	 	cout<<"0\n";
	 }
	 else if(n >= 6 && n <= 12)
	 {
	 	cout<<b/2;
	 }
	 else
	 {
	 	cout<<b<<"\n";
	 }
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine}
object Main {
    def main(args: Array[String]): Unit = {
        val len = readInt
        val list = readLine.split(" ").map(_.toInt).toList
        readInt
        readLine.split(" ").map(_.toInt).foreach { target =>
            if (search(list, target, len)) println("yes") else println("no")
        }
    }
    def search(haystack: List[Int], target: Int, len: Int): Boolean = {
        if (target == 0) return true
        if (len == 0) return false
        else {
            val x = haystack.head
            val xs = haystack.tail
            search(xs, target - x, len - 1) || search(xs, target, len - 1)
        }
    }
}


Measured memory_bytes: 44004
#include <bits/stdc++.h>
using namespace std;
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;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

#include <atcoder/convolution>
#include <atcoder/modint>
using namespace atcoder;

using mint = modint998244353;

int main() {
    int n, m;
    cin >> n >> m;
    vector<mint> a(n), b(m);
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[i] = x;
    }
    for(int i = 0; i < m; i++) {
        int x;
        cin >> x;
        b[i] = x;
    }
    auto c = convolution<mint>(a, b);
    int sz = (int)c.size();
    for(int i = 0; i < sz; i++) {
        cout << c[i].val() << " \n"[i == sz - 1];
    }
}

Measured memory_bytes: 19040
#include<bits/stdc++.h>
#define ll long long int


using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    ll i;ll s=0;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    	s=s^a[i];
	}
	for(i=0;i<n;i++)
	{
		ll b=s^a[i];
		cout<<b<<endl;
	}
	
  return 0;
}

Measured memory_bytes: 5184
package main

import (
	"fmt"
)

func main() {
	var a, b, s int
	fmt.Scan(&a, &b)
	s = b - a
	n := 0
	arr := make([]int, 1000)
	for i := 1; i <= 999; i++ {
		n += i
		arr[i] = n
	}
	for i := 0; i < len(arr)-1; i++ {
		if arr[i+1]-arr[i] == s {
			fmt.Println(arr[i] - a)
			return
		}
	}
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#')
                continue;
            int num = 0;
            for (int k = -1; k <= 1; ++k) {
                for (int l = -1; l <= 1; ++l) {
                    int y = i + k;
                    int x = j + l;
                    if (y < 0 || x < 0 || y >= h || x >= w)
                        continue;
                    if (k == 0 && l == 0)
                        continue;
                    if (s[i+k][j+l] == '#')
                        num++;
                }
            }
            s[i][j] = '0' + num;
        }
    }
    for (int i = 0; i < h; ++i) {
        cout << s[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<algorithm>

#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

const int inf=1<<29;
int adj[100][100],memo[100][11];
bool visited[100][11];

int main(){
	for(int c,n,m,src,dst;scanf("%d%d%d%d%d",&c,&n,&m,&src,&dst),c;){
		src--,dst--;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)	adj[i][j]=(i==j?0:inf);
		for(int i=0;i<n;i++)for(int j=0;j<=c;j++)	memo[i][j]=inf,visited[i][j]=false;
		for(int i=0;i<m;i++){
			int a,b,fee;	scanf("%d%d%d",&a,&b,&fee);
			a--,b--;
			adj[a][b]=adj[b][a]=fee;
		}

		memo[src][0]=0;
		priority_queue< pair<int,pii> > pq;	pq.push(mp(0,mp(src,0)));
		while(!pq.empty()){
			pair<int,pii> a=pq.top();	pq.pop();
			int fee=-a.first;
			int u=a.second.first;
			int tic=a.second.second;
			if(u==dst)	break;

			if(visited[u][tic])	continue;
			visited[u][tic]=true;

			for(int v=0;v<n;v++){
				if(!visited[v][tic] && fee+adj[u][v]<memo[v][tic]){
					memo[v][tic]=fee+adj[u][v];
					pq.push(mp(-memo[v][tic],mp(v,tic)));
				}
				if(tic<c && !visited[v][tic+1] && fee+adj[u][v]/2<memo[v][tic+1]){
					memo[v][tic+1]=fee+adj[u][v]/2;
					pq.push(mp(-memo[v][tic+1],mp(v,tic+1)));
				}
			}
		}

		int feemin=inf;
		for(int i=0;i<=c;i++)	feemin=min(feemin,memo[dst][i]);
		printf("%d\n",feemin);
	}

	return 0;
}

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

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

using namespace std;

struct state{
	int a,b,c;
	state(int a,int b,int c):a(a),b(b),c(c){}
	bool operator< (const state& x)const{ return make_tuple(a,b,c)< make_tuple(x.a,x.b,x.c); }
	bool operator==(const state& x)const{ return make_tuple(a,b,c)==make_tuple(x.a,x.b,x.c); }
};

int main(){
	int n,a0,b0,c0; cin>>n>>a0>>b0>>c0;
	vector<string> s(n);
	rep(i,n) cin>>s[i];

	vector<vector<state>> S(n+1);
	S[n].emplace_back(0,0,0);
	for(int i=n-1;i>=0;i--){
		vector<state> tmp;

		rep(j,S[i+1].size()){
			int a=S[i+1][j].a,b=S[i+1][j].b,c=S[i+1][j].c;
			if(s[i]=="AB"){
				tmp.emplace_back(a+1,max(b-1,0),c);
				tmp.emplace_back(max(a-1,0),b+1,c);
			}
			else if(s[i]=="BC"){
				tmp.emplace_back(a,b+1,max(c-1,0));
				tmp.emplace_back(a,max(b-1,0),c+1);
			}
			else{
				tmp.emplace_back(a+1,b,max(c-1,0));
				tmp.emplace_back(max(a-1,0),b,c+1);
			}
		}

		sort(tmp.begin(),tmp.end());
		tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());

		rep(j,tmp.size()){
			bool ok=true;
			rep(k,tmp.size()) if(j!=k && tmp[k].a<=tmp[j].a && tmp[k].b<=tmp[j].b && tmp[k].c<=tmp[j].c) ok=false;
			if(ok) S[i].emplace_back(tmp[j]);
		}
	}

	auto check=[&](int a,int b,int c,int i){
		rep(j,S[i].size()){
			if(a>=S[i][j].a && b>=S[i][j].b && c>=S[i][j].c) return true;
		}
		return false;
	};

	if(!check(a0,b0,c0,0)) return puts("No"),0;

	puts("Yes");
	rep(i,n){
		if(s[i]=="AB"){
			a0++; b0--;
			if(check(a0,b0,c0,i+1)){ puts("A"); continue; }
			a0--; b0++;
			b0++; a0--;
			if(check(a0,b0,c0,i+1)){ puts("B"); continue; }
			b0--; a0++;
		}
		else if(s[i]=="BC"){
			b0++; c0--;
			if(check(a0,b0,c0,i+1)){ puts("B"); continue; }
			b0--; c0++;
			c0++; b0--;
			if(check(a0,b0,c0,i+1)){ puts("C"); continue; }
			c0--; b0++;
		}
		else{
			a0++; c0--;
			if(check(a0,b0,c0,i+1)){ puts("A"); continue; }
			a0--; c0++;
			c0++; a0--;
			if(check(a0,b0,c0,i+1)){ puts("C"); continue; }
			c0--; a0++;
		}
	}

	return 0;
}


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

int f ( int x ) {
  return x*(x+1) / 2;
}

int main() {
  int a, b;
  cin >> a >> b;
  for ( int x = 1; x < 1000; ++x ) {
    if ( f(x)-a == f(x+1)-b ) {
      cout << f(x)-a << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int a[3], ans=10000000, b[3];
    cin>>a[0]>>a[1]>>a[2];
    b[0]=abs(a[1]-a[0]);
    b[1]=abs(a[2]-a[0]);
    b[2]=abs(a[2]-a[1]);
    sort(b, b+3);
    cout<<b[0]+b[1]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
template <class T> int size(const T &x) { return x.size(); }
const int INF = 2147483647;
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)

int main() {
    int a,b;
    cin >> a >> b;
    int zs = 0,
        ns = 0;
    if (a <= 0 && 0 <= b)
        zs++;
    if (a <= 0) {
        ns = -a;
        if (b < 0) {
            ns -= -b - 1;
        }
    }
    if (zs >0 ) {
        cout << "Zero" << endl;
    } else if (ns % 2 == 0) {
        cout << "Positive" << endl;
    } else {
        cout << "Negative" << endl;
    }
    return 0;
}



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


#define ll long long
#define fr(m) for(int i=0; i<m; i++)
#define frj(m) for(int j=0; j<m; j++)
#define frr(n) for(int i=n; i>=0; i--)
#define pb push_back
#define orr ||
#define nl \n
#define sci(n) scanf("%lld ", &n)
#define pri(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

bool compare(ll a, ll b){
    return(a>b);
}

int main()
{

    ll n, k;
    cin>>n>>k;
    ll arr[10];
    fr(10) arr[i]=1;
    fr(k){
        int number;
        cin>>number;
        arr[number]=0;
    }
//    fr(10) cout<<arr[i]<<" ";
    ll num=n,j=0,flag,ans=num;
    while(1){

//       cout<<num<<endl;
       flag=1;
       while(num){
            if(arr[num%10]==0){
                flag=0;
                break;
            }
            num/=10;
       }
        if(flag){cout<<ans<<endl; break;}
        num=n+j;
        ans=num;
        j++;
    }
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $cnt, $limit);
$lifes = array_map('intval', explode(' ', trim(fgets(STDIN))));
rsort($lifes);
for ($i=0; $i < $limit; $i++) { 
    unset($lifes[$i]);
}
echo array_sum($lifes);

Measured memory_bytes: 31348
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define cast static_cast
#define vi vector<int>
#define v vector
#define p pair
#define push_back pb
#define mkae_pair mk
typedef long long int ll;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	vi a(n);
	ll ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(all(a));
	ans+=a[n-1];
	int h=2;
	for(int i=n-2;i>=0;i--){
		if(h<n){
			ans+=a[i];
			h++;
		}
		if(h<n){
			ans+=a[i];
			h++;
		}
		if(h>=n){
			break;
		}
	}
	cout<<ans<<"\n";
}	

int main(){
	boost_io;
	solve();
	return 0;
}


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

char field[51][51];
using namespace std;
int main(){
  int h, w;
  cin >> h >> w;
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      cin >> field[i][j];
    }
  }
  
  
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      if(field[i][j] == '#'){
        cout << "#";
        continue;
      }
      
      int count=0;
      for(int dh=-1; dh<=1; dh++){
        for(int dw=-1; dw<=1; dw++){
          if(i+dh >= 0 && i+dh <h && j+dw>=0 && j+dw<w && !(dh==0&&dw==0) && field[i+dh][j+dw] == '#'){
            count++;
          }
        }
      }
      cout << count;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????? I

?¬?????±??????????????????????????????????????????¢??????????????\??¬????????§????????????????????°????????????????????????????????????
   +--+
 ???|???|
+--+--+--+--+
|???|???|???|???|
+--+--+--+--+
 ???|???|
   +--+

"""

class Dice:
    T = 0
    S = 1
    E = 2
    W = 3
    N = 4
    B = 5

    """ ????????????????????? """
    def __init__(self): # ?????????????????????
        self.side = [1, 2, 3, 4, 5, 6]
        self.top = 0

    def setDice(self, arr):  # ??¢??????????????????
        self.side = arr[0:6]

    def Turn(self, dir): # ?????????????????¢??????
        s = self.side

        if dir == "N":     # ????????¢??????
            #    Top 0     South 1   East 2    West 3    North 4   Bottom 5
            t = [s[Dice.S],s[Dice.B],s[Dice.E],s[Dice.W],s[Dice.T],s[Dice.N]]
        elif dir == "S": # ????????¢??????
            t = [s[Dice.N],s[Dice.T],s[Dice.E],s[Dice.W],s[Dice.B],s[Dice.S]]
        elif dir == "E": # ??±?????¢??????
            t = [s[Dice.W],s[Dice.S],s[Dice.T],s[Dice.B],s[Dice.N],s[Dice.E]]
        elif dir == "W": # ?\??????¢??????
            t = [s[Dice.E],s[Dice.S],s[Dice.B],s[Dice.T],s[Dice.N],s[Dice.W]]
        elif dir == "L": # ???????????¢
            t = [s[Dice.T],s[Dice.W],s[Dice.S],s[Dice.N],s[Dice.E],s[Dice.B]]
        elif dir == "R": # ???????????¢
            t = [s[Dice.T],s[Dice.E],s[Dice.N],s[Dice.S],s[Dice.W],s[Dice.B]]

        self.side = t
#        print("{0} T0:{1} S1:{2} W2:{3} E3:{4} N4:{5} B5:{6} ".format(dir, self.side[0],self.side[1], self.side[2],self.side[3], self.side[4],self.side[5]))

    def Search(self, tval, sval, dir): # ?????¢??¨?????¢???????????????????????????????????¢???????????????
    
        if self.side[Dice.E] == tval:
            self.Turn("W")
        elif self.side[Dice.W] == tval:
            self.Turn("E")
        elif self.side[Dice.N] == tval:
            self.Turn("S")
        elif self.side[Dice.S] == tval:
            self.Turn("N")
        elif self.side[Dice.B] == tval:
            self.Turn("N")
            self.Turn("N")

        for i in range(3): # ?????¢?????????????????????????????§????????????
            if self.side[Dice.S] == sval:
                break
            self.Turn("L")
            
        return self.side[dir]

dnum = list(map(int,input().strip().split()))
d = Dice()
d.setDice(dnum)
cnum = int(input().strip())
for c in range(cnum):
    cmd = list(map(int,input().strip().split()))
    val = d.Search(cmd[0], cmd[1], Dice.E)
    print(val)

Measured memory_bytes: 7896
#include<stdio.h>
int main()
{
    long long int n,k,p,m;
    scanf("%lld %lld",&n,&k);
    m=n%k;
    p=k/2;
    if(m>p)
        m=k-m;
    printf("%lld\n",m);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> blue(n);
  for(int i=0; i<n; i++) cin >> blue[i];
  
  int m;
  cin >> m;
  vector<string> red(m);
  for(int i=0; i<m; i++) cin >> red[i];
  
  map<string, int> mp;
  for (string x : blue) mp[x]++;
  for (string x : red) mp[x]--;

  int a=0, ans=0;
  for (auto p : mp) {
    a = p.second;
    if (a > ans) ans = a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3648
<?php

fscanf(STDIN, '%s', $S);

$ss = str_split($S);
$ans = 0;

for ($i=0; $i < 4; $i++) {
    if ($ss[$i] === '+') {
        $ans ++;
    } else {
        $ans --;
    }
}

echo $ans;

echo PHP_EOL;


Measured memory_bytes: 16080
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <iomanip>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
int main() {
	string s;
	cin >> s;
	int hoge = s.length();
	for (int i = 0;i < hoge-1;++i) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
		if (i + 2 < hoge) {
			if (s[i] == s[i + 2]) {
				cout << i + 1 << " " << i + 3 << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1" << endl;
}

Measured memory_bytes: 512
<?php
fscanf(STDIN, '%d %d', $n, $m);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$lcm = $a[0];
for ($i = 0; $i < $n; ++$i) {
    $lcm = lcm($lcm, $a[$i]);
    if ($lcm / $a[$i] % 2 === 0) {
        echo (0) . PHP_EOL;
        exit;
    }
}
$ans = floor((2 * $m + $lcm) / (2 * $lcm));
echo $ans . PHP_EOL;

// 最大公約数
function gcd($m, $n)
{
    if (!$n) return $m;
    return gcd($n, $m % $n);
}

// 最小公倍数（2つ）
function lcm($m, $n)
{
    return $m * $n / gcd($m, $n);
}

Measured memory_bytes: 16884
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
  int a[3],b=1;
  cin >> a[0] >> a[1] >> a[2];
  sort (a,a+3);
  if (a[0]!=a[1]) b++;
  if (a[1]!=a[2]) b++;
  cout << b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int a, b, c;
	a = 0;
	b = 0;
	c = 0;

	for (int i = 0; i < 3; i++) {
		if (s.at(i) == 'a') a++;
		if (s.at(i) == 'b') b++;
		if (s.at(i) == 'c') c++;
	}

	if (a && b && c) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


int main() {
	string s; cin >> s;
	string ans = "keyence";
	if (s == ans) {
		cout << "YES" << endl;
		return 0;
	}
	int n = s.size();
	for (int i = 0; i < n; i++) {
		for (int j = 0; i + j < n; j++) {
			string t = s.substr(0, i) + s.substr(i + j + 1, n - i - j-1);
			//cout << t << endl;
			if (ans == t) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
k,n=map(int,input().split())
a=list(map(int,input().split()))
b=[]
b.append(k-a[n-1]+a[0])
for i in range(0,n-1):
  b_i=a[i+1]-a[i]
  b.append(b_i)

s=sum(b)
b.append(k-a[n-1]+a[0])
c =[]
for j in range(0,n):
  h=s-max(b[j+1],b[j])
  c.append(h)
print(min(c))

Measured memory_bytes: 26444
#include <cstdio>
#include <algorithm>

int main(void)
{
    int a[3],b[3];
    int k;

    //freopen("x.in","r",stdin);

    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    k = 0;
    std::sort(a,a + 3);
    while((a[0] & 1) + (a[1] & 1) + (a[2] & 1) == 0)
    {
        b[0] = (a[0] + a[1]) >> 1;
        b[1] = (a[0] + a[2]) >> 1;
        b[2] = (a[1] + a[2]) >> 1;
        if(a[0] == b[0] && a[1] == b[1] && a[2] == b[2])
            return puts("-1"),0;
        a[0] = b[0],a[1] = b[1],a[2] = b[2];
        ++k;
    }
    printf("%d\n",k);

    return 0;
}

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

#define int long long int
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back

signed main() {
    int n;
    cin >> n;
    vi a(n);
    int mn = INT_MAX, cnt = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        mn = min(mn, a[i]);
        if(a[i] == mn) {
            cnt++;
        }
    }
    cout << cnt;
}


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


def solve(S: int, W: int):
    print("unsafe" if S <= W else "safe")


    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <stdio.h>

int main()
{
  int i, n, b, f, r, v;
  int people[5][4][11] = {0, 0, 0, 0, 0};

  scanf("%d", &n);

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

  for( b = 1 ; b <= 4 ; b++ )
  {
    for( f = 1 ; f <= 3 ; f++ )
    {
      for( r = 1 ; r < 10 ; r++ )
        printf(" %d", people[b][f][r]);
      printf(" %d\n", people[b][f][10]);
    }
    if( b == 4 )
      break;
    printf("####################\n");
  }
}



Measured memory_bytes: 2140
n,D = map(int,input().split())
X  =[]
for _ in range(n):
    x = list(map(int,input().split()))
    X.append(x)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        val = 0
        for d in range(D):
            val += (X[i][d]-X[j][d])**2
        val = val**0.5
        if val.is_integer():
            ans += 1
print(ans)
        


Measured memory_bytes: 62556
#include <bits/stdc++.h>
using namespace std;
long long f[100010][30],a[100010];
int main()
{
    long long n;
    cin >> n;
    for(long long i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    long long l;
    cin >> l;
    for(long long i=1;i<=n;i++)
    {
        long long k=upper_bound(a+1,a+1+n,a[i]+l)-a;
        k=k-1;
        if(a[i]+l>=a[n])
            f[i][0]=n;
        else
            f[i][0]=k;
    }
    for(long long j=1;j<=20;j++)
    {
        for(long long i=1;i<=n;i++)
        {
            f[i][j]=f[f[i][j-1]][j-1];
        }
    }
    long long q;
    cin >> q;
    while(q--)
    {
        long long u,v;
        cin >> u >> v;
        if(u>v)
            swap(u,v);
        long long ans=0;
        for(long long i=20;i>=0;i--)
        {
            if(f[u][i]<v)
            {
                ans+=(1<<i);
                u=f[u][i];
            }
        }
        cout << ans + 1 << "\n";
    }
}


Measured memory_bytes: 25088
//		HYSO SERIOUS? WHY SO SERIOUS                            RIOUS? WHY SO SERIOUS? WHYSO SERIO
//		 ERIOUS? WHY SO SERIOUS ? WHY                          WHY SO SERIOUS? WHY SOSERIOUSWHYS
//		       OSERIOUS? WHY SO SERIOU         SERIOUS        ERIOUS? WHY SO SERIOUS? WHYS
//		          WHY SO SERIOUS? WHY SOSERIOUS? WHYSOSERIOUS? WHY SO SERIOUS?WHY SO SE
//		           ERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SOSERIO
//		           WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WH
//		            SERIOUS?WHYSO SERIOUS? WHY SO SERIOUS? WHY SO SERIOUS? WHYSO SE
//		              ?WHYSOSERIOUS?WHY SO SERIOUS? WHY SO SERIOUS?WHYSO SERIOUS?
//		                           OSERIOUS? WHY SO SERIOUS?WHYSOSER
//		                                 HYSOSERIOUS?WHYSOSERI
//		                                     SOSERIOUS?W
//		                                         SER
//		                                          W


#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define read(a) long long int a; cin>>a;
#define readstr(s) string s; cin>>s;
#define readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define v(pi) vector<ll>pi
#define vp(pi) vector<pair<ll,ll>>pi
#define fast ios_base::sync_with_stdio(false);cin.tie(0);
#define pb(p) push_back(p)
#define mp make_pair
#include <cmath>
#include <map>
#define mi(lol) map<ll,ll>lol

int main() {
	fast;
//#ifndef ONLINE_JUDGE
  //freopen("input.txt","r",stdin);
  //freopen("output.txt","w",stdout);
//#endif
  read(a)
  read(b)
  if(a==b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
	return 0;
}


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

class Program
{
    public static void Main()
    {
        while (true)
        {
            long[] earn = new long[4000];
            List<int> input_order = new List<int>();
            bool[] exists = new bool[4000];
            int n = int.Parse(Console.ReadLine());
            if (n == 0)
            {
                break;
            }
            for (int i = 0; i < n; ++i)
            {
                string[] args = Console.ReadLine().Split();
                int e = int.Parse(args[0]);
                long p = long.Parse(args[1]), q = long.Parse(args[2]);
                earn[e - 1] += p * q;
                if (!exists[e - 1])
                {
                    input_order.Add(e);
                    exists[e - 1] = true;
                }
            }
            int cnt = 0;
            foreach (var e in input_order)
            {
                if (earn[e - 1] >= 1000000)
                {
                    Console.WriteLine(e);
                    ++cnt;
                }
            }
            if (cnt == 0)
            {
                Console.WriteLine("NA");
            }
        }
        return;
    }
}


Measured memory_bytes: 13772
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());
        String[] ss = new String[n];
        for (int i = 0; i < n; i++) {
            ss[i] = in.nextLine();
        }
        String ans = ss[0];
        for (String s : ss) {
            ans = same(ans, s);
        }
        char[] ch = ans.toCharArray();
        Arrays.sort(ch);
        System.out.println(new String(ch));
    }

    public static String same(String s1, String s2) {
        String ans = "";
        for (int i = 0; i < 26; i++) {
            int c1 = 0, c2 = 0;
            for (char c : s1.toCharArray()) {
                if (c == 'a' + i)
                    c1++;
            }
            for (char c : s2.toCharArray()) {
                if (c == 'a' + i)
                    c2++;
            }
            for (int j = 0; j < Math.min(c1, c2); j++) {
                ans += (char) ('a' + i);
            }
        }
        return ans;
    }
}


Measured memory_bytes: 25940
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
int main(void){
    int count=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]!=s[i+1])count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 512
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int c;
		int t;
		int m = 9999;
		int an = 0;
		for(int i = 1; i <= N; i++){
			c = sc.nextInt();
			t = sc.nextInt();
			if(t <= T && c < m){
				an = c;
				m = c;
			}
		}
		if(an == 0){
			System.out.print("TLE");
		}else{
			System.out.print(an);
		}
	}
}


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

int main() {
  string s;
  cin >> s;
  int ans = 100000;
  for (int i = 0; i + 2 < s.size(); i++) {
    int res = 0;
    for (int j = i; j < i + 3; j++) {
      res = res * 10 + (s[j] - '0');
    }
    ans = min(ans, abs(res - 753));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = [0] * (n)
for x in range(1, n):
    if x * x > n:
        break
    for y in range(1, n):
        if x * x + y * y + x * y > n:
            break
        for z in range(1, n):
            key = x * x + y * y + z * z + x * y + y * z + z * x
            if key > n:
                break
            ans[key - 1] += 1
for i in range(n):
    print(ans[i])

Measured memory_bytes: 9060
#include <atcoder/all>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n, m;
char field[99][99];

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

    cin >> n >> m;
    rep(i, n) cin >> field[i];

    atcoder::mcf_graph<int, ll> G(n * m + 2);
    const int S = n * m, T = n * m + 1;

    ll ans = 0;

    ll INF = 1 << 30, cnt = 0;

    rep(i, n) rep(j, m) {
        if(field[i][j] == 'o') {
            G.add_edge(S, i * m + j, 1, 0);
            ans -= i + j;
            cnt++;
        }
        if(field[i][j] != '#') {
            G.add_edge(i * m + j, T, 1, INF - (i + j));
            if(i + 1 < n && field[i + 1][j] != '#')
                G.add_edge(i * m + j, (i + 1) * m + j, 100, 0);
            if(j + 1 < m && field[i][j + 1] != '#')
                G.add_edge(i * m + j, i * m + j + 1, 100, 0);
        }
    }

    ans += cnt * INF - G.flow(S, T).second;

    cout << ans << endl;

    return 0;
}

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

int main()
{
    long long a, b, k, i;
    cin>>a>>b>>k;

    if(a>k){
        a = a - k;
    }
    else if(a<=k){
        k = k - a;
        a = 0;
        b = b - k;

    }

    if(a<0)
        cout<<"0 "<<b;
    else if(b<0)
        cout<<a<<" 0";
    else
        cout<<a<<" "<<b;


}


Measured memory_bytes: 256
#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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K, S;
int MA = 1000000000;
int ans[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K >> S;

	if (S == MA) {
		rep(i, 0, K) ans[i] = MA;
		rep(i, K, N) ans[i] = 1;
	}
	else {
		rep(i, 0, K) ans[i] = S;
		rep(i, K, N) ans[i] = MA;
	}

	rep(i, 0, N) {
		if(i) printf(" ");
		printf("%d", ans[i]);
	}
	printf("\n");
}







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

#define pb         push_back

const int INF = 100000000;

int main(void) {
	while(1){
		int n, p;
		cin >> n >> p;
		if(n == 0 && p == 0) break;

		vector<int> stone(n, 0);
		int bawl = p;
		int win = -1;
		while(1){
			for(int i=0; i<n; i++){
				if(bawl > 0){
					bawl--;
					stone[i]++;
					if(bawl == 0 && stone[i] == p) win = i;
				}else{
					bawl = stone[i];
					stone[i] = 0;
				}
			}
			if(win != -1) break;
		}
		cout << win << endl;
	}
	
	return 0;
}

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

int N;
int ans=0;
void dfs(vector<int> &A,vector<int> &B,int now){
  if(now==N){
    for(int i=0;i<N;i++){
      if(B.at(i)%2==0){
        ans++;
        return;
      }
    }
    return;
  }

  for(int i=-1;i<=1;i++){
    B.at(now)=A.at(now)+i;
    dfs(A,B,now+1);
  }
}

int main(){
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);

  vector<int> B(N);
  dfs(A,B,0);
  cout << ans << endl;

  return 0;
}

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

int main() {
  //nが夏休みの日数　iが宿題の個数
  int n,i=0;
  cin>>n>>i;
  vector<int> kosuu(i);
  for (int j = 0; j < i; j++) {
    cin >> kosuu.at(j);
  }
  int m=0;
   //cout<<m<<endl;
  for (int j = 0; j < i; j++) {
    m+=kosuu.at(j);
  }
 // cout<<kosuu.at(0)<<endl;
  //cout<<kosuu.at(1)<<endl;
 // cout<<m<<endl;
   if(n-m<0){
    cout<<-1<<endl;
   }
   else{
   cout<<n-m<<endl;
   }
}
  


Measured memory_bytes: 3652
#[test]
fn test_solve() {
   assert_eq!(solve("3 3\n1 2 1\n2 3 1\n1 3 2\n"), "Yes\n");
   assert_eq!(solve("3 3\n1 2 1\n2 3 1\n1 3 5\n"), "No\n");
   assert_eq!(solve("4 3\n2 1 1\n2 3 5\n3 4 2\n"), "Yes\n");
   assert_eq!(solve("10 3\n8 7 100\n7 9 100\n9 8 100\n"), "No\n");
   assert_eq!(solve("100 0\n"), "Yes\n");
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut frm = vec![Vec::new(); n];
    for _ in 0..m {
        let l: usize = sc.read();
        let r: usize = sc.read();
        let d: isize = sc.read();
        frm[l-1].push((r-1, d));
        frm[r-1].push((l-1, -d));
    }

    let mut x = vec![None; n];
    for v in 0..n {
        if x[v].is_none() {
            x[v] = Some(0);
            if !dfs(v, &mut x, &frm) {
                return "No\n".to_string();
            };
        }
    }

    "Yes\n".to_string()
}
fn dfs(v: usize, x: &mut Vec<Option<isize>>, frm: &Vec<Vec<(usize, isize)>>) -> bool {
    let xv = x[v].unwrap();
    for &(w, d) in &frm[v] {
        if let Some(xw) = x[w] {
            if xv + d != xw {
                return false;
            }
        } else {
            x[w] = Some(xv + d);
            if !dfs(w, x, frm) {
                return false;
            }
        }
    }
    true
}

fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

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

using ld = long double;
using point = std::complex<ld>;
using polygon = std::vector<point>;

constexpr ld eps = 1e-10;
const ld pi = std::acos(-1.0);

struct circle {
    circle() : p(point(0, 0)), r(0) {}
    circle(point p_, long double r_) : p(p_), r(r_) {}
    point p;
    long double r;
};

std::vector<point> is_cc(circle const& c1, circle const& c2) {
    std::vector<point> res;
    ld d = std::abs(c1.p - c2.p);
    ld rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
    ld dfr = c1.r * c1.r - rc * rc;
    if(std::abs(dfr) < eps) {
        dfr = 0.0;
    } else if(dfr < 0.0) {
        return res;
    }

    ld rs = std::sqrt(dfr);
    point diff = (c2.p - c1.p) / d;
    res.push_back(c1.p + diff * point(rc, rs));
    if(dfr != 0.0) {
        res.push_back(c1.p + diff * point(rc, -rs));
    }
    return res;
}


int main() {
    int n;
    while(cin >> n, n) {
        vector<circle> cs;
        for(int i = 0; i < n; ++i) {
            double x, y;
            scanf("%lf,%lf", &x, &y);
            cs.emplace_back(point(x, y), 1);
        }

        int ans = 1;
        for(int i = 0; i < n; ++i) {
            for(int j = i + 1; j < n; ++j) {
                for(auto&& p : is_cc(cs[i], cs[j])) {
                    int cnt = 0;
                    for(auto const& c : cs) {
                        cnt += abs(p - c.p) <= 1;
                    }
                    ans = max(cnt, ans);
                }
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3308
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

signed main() {
	int n, t;
	scanf("%d %d", &n, &t);
	ll sum = (ll)n*t;
	scanf("%*d");
	int bef = 0;
	REP(i, n-1) {
		int a;
		scnaf("%d", &a);
		if ((a-bef) < t) {
			sum -= (ll)t - (a-bef);
		}
		bef = a;
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;

bool isprime(int x){
    for(int i = 2;i * i <= x;i++){
        if(x % i == 0)
            return false;
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    for(int i = n;i< 1e9;i++){
        if(isprime(i)){
            cout << i <<endl;
            break;
        }
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 256