akhauriyash/Code-Regression huggingface dataset:
x, y = map(int, input().split())

max_i = 0
max_j = 0
min_i = 0
min_j = 0
color = [1, 2, 3]
i = 0
while True :
    if min_i <= x <= max_i and min_j <= y <= max_j :
        ans = color[i]
        break
    i += 1
    if i >= 3 :
        i = 0
    l = max_j+1  - min_j
    max_i += l
    
    if min_i <= x <= max_i and min_j <= y <= max_j :
        ans = color[i]
        break
    i += 1
    if i >= 3 :
        i = 0
    l = max_i+1  - min_i
    max_j += l
    
    if min_i <= x <= max_i and min_j <= y <= max_j :
        ans = color[i]
        break
    i += 1
    if i >= 3 :
        i = 0
    l = max_j+1  - min_j
    min_i -= l
    
    if min_i <= x <= max_i and min_j <= y <= max_j :
        ans = color[i]
        break
    i += 1
    if i >= 3 :
        i = 0
    l = max_i+1  - min_i
    min_j -= l

print(ans)


Measured memory_bytes: 5608
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    int n,m,sum=0,i;
    cin>>n>>m;
    int a[m];
    for(i=0;i<m;i++){
        cin>>a[i];
       sum=a[i]+sum;}
      if(sum<=n)
          cout<<n-sum;
         else if (sum>n)
         cout<<-1;
}


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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

int main(void){
	int n;
	cin >> n;
	v2(adj, n+1, n+1, 1);
	REP(i,1,n+1){
		adj[i][(n/2)*2-i+1]=0;
	}

	vec x, y;
	REP(i,1,n+1){
		REP(j,i+1,n+1){
			if(adj[i][j]){
				x.push_back(i);
				y.push_back(j);
			}
		}
	}

	prt(x.size());
	rep(i,x.size()){
		prt2(x[i], y[i]);
	}
}


Measured memory_bytes: 3708
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
using namespace std;
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (a > b)cout << "0" << endl;
	else if (n == 1) {
		if (a == b) {
			cout << "1" << endl;
		}
		else {
			cout << "0" << endl;
		}
	}
	else if (n == 2)cout << "1" << endl;
	else {
		cout << (n - 2) * (b - a) + 1 << endl;
	}
}


Measured memory_bytes: 256
import itertools as it
import math
from statistics import mean
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
A=[]
for i in list(it.permutations(X,N)):
    B=[]
    for j in range(N-1):
        B.append(math.sqrt((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2))
    A.append(sum(B))
print(mean(A))

Measured memory_bytes: 11276
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."						*/
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define ld double 
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define deb cerr << "Line no." << __LINE__
#define nl '\n'
#define pb push_back
#define all(a) a.begin(),a.end()
#define P pair<ll,ll> 
#define F first
#define S second
const ll p_mod=9999999999999983;
const long double pi = 3.14159265358979323;
const ll N=1e6+9;
const ll mod=1e9+7;
//typedef double f80;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){uniform_int_distribution<int> uid(l, r); return uid(rng); }
ll powerk(ll x, ll y);

ll n;
double dp[303][303][303];
double go(ll a, ll b, ll c)
{
	if(a==0 && b==0 && c==0)return 0.0;
	if(dp[a][b][c]>=0)return dp[a][b][c];
	double res=0.0;
	if(a>0)res+= 1.0*go(a-1,b,c)*a/(a+b+c);
	if(b>0)res+= 1.0*go(a+1,b-1,c)*b/(a+b+c);
	if(c>0)res+= 1.0*go(a,b+1,c-1)*c/(a+b+c);
	res+= 1.0*n/(a+b+c);
	/*
		why n/(a+b+c)?
		it must be (n-(a+b+c))/(a+b+c) = S (let);
		total sum of GP = S,S^2,S^3.........inf
		SUM= S/1-S = (n/(a+b+c)) -1 ;
		so now, to change the state from getting no sushi to getting one shushi we need one operation.
		so add 1;

		ultimately, 
		SUM= n/(a+b+c);

	//*/
	return dp[a][b][c]= res;
}

void solve()
{    
	ll x,a=0,b=0,c=0;
	cin>>n;
	rep(i,1,n)
	{
		cin>>x;
		if(x==1)a++;
		else if(x==2)b++;
		else c++;
	}
	
	memset(dp, -1, sizeof dp);
	cout<<fixed<<setprecision(10)<<go(a,b,c)<<nl;
}


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}
ll powerk(ll x, ll y)
{
  if(y==0)return 1;
  if(y==1)return x%mod;
  if(y&1)
    return ((powerk((x*x)%mod, y/2)%mod)*x)%mod;
  else return powerk((x*x)%mod,y/2)%mod;
}

// Xorawar

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

int ketanowa (int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  if ((N % ketanowa(N)) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 3648
n, x = map(int, input().split())

while not(n == 0 and x == 0):
    res = 0
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            for k in range(j + 1, n + 1):
                if i + j + k == x:
                    res += 1
    print(res)
    n, x = map(int, input().split())



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

using namespace std;

long long s, a, b;

int main() {
	cin >> s, a = 1e9;
	b = ceil(1.0 * s / a);
	cout << 0 << ' ' << 0 << ' '
		 << a << ' ' << 1 << ' '
		 << (s % a == 0 ? 0 : a - s % a) << ' ' << b << endl;
	return 0;
}

Measured memory_bytes: 256
while 0<n=gets.to_i
h={};(1..n).map{a,b,c=gets.split.map &:to_i;h[a]||=0;h[a]+=b*c};h=h.reject{|a,x|x<1e6}.map{|a,x|a};h[0]||h.push("NA");puts h;end

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

using namespace std;

using ll = long long;

struct UnionFind {
    std::vector<int> data;

    explicit UnionFind() {}
    explicit UnionFind(int size) : data(size, -1) {}

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) std::swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -data[root(x)]; }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
};

// Choose(n, 2)
inline ll Comb2(const ll n) { return n * (n - 1) / 2; }

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

    ll n, m;
    cin >> n >> m;

    vector<pair<int, int>> edges(m);
    for (int i = 0; i < m; ++i) {
        cin >> edges[i].first >> edges[i].second;
        --edges[i].first;
        --edges[i].second;
    }
    reverse(edges.begin(), edges.end());

    UnionFind uf(n);
    vector<ll> ans; ans.reserve(n);
    ll num = Comb2(n);
    for (const auto &e : edges) {
        ans.push_back(num);
        if (uf.find(e.first, e.second)) continue;
        ll s1 = uf.size(e.first), s2 = uf.size(e.second);
        num += Comb2(s1) + Comb2(s2) - Comb2(s1 + s2);
        uf.unite(e.first, e.second);
    }

    reverse(ans.begin(), ans.end());
    for (ll x : ans) cout << x << '\n';

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	int ans = 0;
	for( int i = n; i >= 1; --i ){
		int a = i;
		int cnt = 0;
		while( a%2 == 0 ){
			a /= 2;
			++cnt;
		}
		ans = max(ans, cnt);
	}
	cout << (1<<ans) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;


int main() {
	int  N;
	cin >> N;
	if (N < 1200) {
		cout << "ABC" << endl;
	} else if (N < 2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
}

Measured memory_bytes: 256
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.05.26 20:48:33
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 100000000;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

int main() {
    int n, k;
    int v[55];
    scanf("%d%d", &n, &k);
    rep(i, n) scanf("%d", &v[i]);

    int ret = 0;

    // iは取り出す回数
    rep(i, k + 1) {
        // pは戻す回数
        int p = k - i;
        if (i > n) {
            break;
        }
        // lは左端から取る個数
        rep(l, i + 1) {
            // rは右端から取る個数
            int r = i - l;
            vector<int> neg, pog;
            neg = {};
            pog = {};
            rep(j, l) {
                if (v[j] < 0) {
                    neg.pb(v[j]);
                } else {
                    pog.pb(v[j]);
                }
            }
            rep(j, r) {
                if (v[n - 1 - j] < 0) {
                    neg.pb(v[n - 1 - j]);
                } else {
                    pog.pb(v[n - 1 - j]);
                }
            }
            sor(neg);
            rev(neg);
            rep(j, p) {
                if (neg.empty()) {
                    break;
                }
                neg.pop_back();
            }
            int sum = 0;
            rep(j, neg.size()) {
                sum += neg[j];
            }
            rep(j, pog.size()) {
                sum += pog[j];
            }
            ret = max(ret, sum);
        }
    }

    printf("%d\n", ret);

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
	int X, A, B;

	cin >> X >> A >> B;

	if (A >= B )
		cout << "delicious" << endl;
	else  
	{
		if (A <= B,B - A < X+1 )
		{
			cout << "safe" << endl;
		}
		else
		{
			cout << "dangerous" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int ans=3;
  if(a==b && b==c) ans=1;
  else if(a==b || b==c || c==a) ans=2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  while(1){
    int n,w,h,x,y,max=0,m[1000][1000]={};
    cin>>n;
    if(n==0)break;
    cin>>w>>h;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      m[x][y]++;
    }
    cin>>x>>y;
    for(int i=1;i<=w-x+1;i++){
      for(int j=1;j<=h-y+1;j++){
	int cnt=0;
	for(int k=i;k<i+x;k++){
	  for(int l=j;l<j+y;l++){
	    if(m[k][l]==1)cnt++;
	  }
	}
	if(max<cnt)max=cnt;
      }
    }
    cout<<max<<endl;
  }
  return 0;
}

Measured memory_bytes: 6892
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x3f
#define MAX_INF_VAL 0x3f3f3f3f
#define MAX_INF_VAL_LL 0x3f3f3f3f3f3f3f3f
#define pi 3.141592653589
#define eps 1e-6
//#define p 2173412051LL
//#define sz 2

using namespace std;

int main() {
	ll n, m;
	ll ans = 0;
	scanf( "%lld", &n );
	if( n & 1 ) {
		printf( "0" );
		return 0;
	}
	n >>= 1;
	m = 5;
	while( n >= m ) {
		ans += n / m;
		m *= 5;
	}
	printf( "%lld", ans );
	return 0;
}

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

bool compare_by_b(pair<long,long> a,pair<long,long> b){
	if(a.second != b.second){
		return a.second < b.second;
	}
	else{
		return a.first < b.first;
	}
}

int main(){
	int N;
	cin>>N;
	vector<pair<long,long> > arr;
	pair<long,long>p;
	long A,B;
	for(int i=0;i<N;++i){
		cin>>A>>B;
		p.first = A;
		p.second = B;
		arr.push_back(p);
	}
	sort(arr.begin(),arr.end(),compare_by_b);
	long T=0;
	bool ok = true;
	for(int i=0;i<N;++i){
		//cout<<arr[i].first<<" "<<arr[i].second<<endl;
		if(T+arr[i].first <= arr[i].second){
			T += arr[i].first;
		}
		else{
			ok = false;
			break;
		}
	}
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 6128
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

vector<int> e[1001];
int q[1001];int ninq[1001];int flag[1001];

bool check(int n,int len,int st)
{
    vector<int> circle;
    int last=st;
    while (len+1)
    {
        int tmp=q[len];--len;
        for(int ed=0;ed<e[tmp].size();++ed)
        if(e[tmp][ed]==last){
            last=tmp;circle.push_back(last);continue;
        }
    }

    //for (int i=0;i<circle.size();++i) printf("%d ",circle[i]);printf("!!!\n");

    int num=0;
    for (int i=0;i<=n;++i) flag[i]=0;
    for (int i=0;i<circle.size();++i) flag[circle[i]]=1;
    for (int i=0;i<circle.size();++i)
    {
        for (int ed=0;ed<e[circle[i]].size();++ed)
            if (flag[e[circle[i]][ed]])
                ++num;
    }
    if (num==circle.size()){
        printf("%d\n",circle.size());
         for (int i=0;i<circle.size();++i) printf("%d\n",circle[i]);
        return true;
    }
    return false;


}


int main()
{
    int n,m;scanf("%d%d",&n,&m);
    for (int i=0;i<m;++i)
    {
        int a,b;scanf("%d%d",&a,&b);
        e[a].push_back(b);
    }
    for (int i=1;i<=n;++i)
    {
        int ll=0,rr=1;q[0]=i;
        for (int ii=1;ii<=n;++ii) ninq[ii]=1;
        ninq[i]=0;
        while (ll<rr)
        {
            int tmp=q[ll];++ll;
            for (int edge=0;edge<e[tmp].size();++edge)
            {
                //printf("##%d %d\n",tmp,e[tmp][edge]);
                if (ninq[e[tmp][edge]] ){
                    q[rr]=e[tmp][edge];++rr;ninq[e[tmp][edge]]=0;
                    continue;
                }
                if (e[tmp][edge]==i){
                    if( check(n,ll-1,i) ) return 0;
                }
            }
        }
    }
    printf("-1\n");

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;

int main(){
    iosetup;
    ll H; cin >> H;
    ll cnt = 0, k = 0;
    while(H > 0){
        cnt += 1LL << k;
        H /= 2;
        k++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include <algorithm>
using std::min;
#define INF 200000000
#define MAXN 20007
int mmagic[MAXN];
int main(void)
{
    int N,i,H,a,b;
    scanf("%d%d",&H,&N);
    for(i=0;i<MAXN;i++)
    {
        mmagic[i]=INF;
    }

    for(i = 0 ;i<N;i++)
    {
        scanf("%d%d",&a,&b);
        mmagic[a]=min(mmagic[a],b);
    }
    for(i=1;i<=MAXN;i++)
    {
        for(int j=1;j<i;j++)
        {
            mmagic[i] = min(mmagic[i],mmagic[i-j]+mmagic[j]);
        }
    }
    int minVal = INF;
    for(i=H;i<MAXN;i++)
    {
        minVal = min(minVal,mmagic[i]);
    }
    printf("%d\n",minVal);

    return 0;
}

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

#define INF 100000000




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

    int ans = INF;
    rep(i,s.length()-2){
        int temp = 0;
        temp = (s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0';
        ans = min(ans, abs(temp-753));
    }

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


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

int main(){
  long long N;
  cin >> N;
  long long a[5];
  for(int i =0; i<5;++i){
    cin >> a[i];
  }
  long long  mina = 1e+15;
  for(int i = 0 ; i < 5; ++i){
    if(mina > a[i]) mina = a[i];
  }
  long long  ans = N / mina;
  if (N % mina == 0) ans += 4;
  else ans += 5;
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
#include <climits>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_T _DEF(T,in,){return in<T>(gcu());}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

int p(int n, int a, int b) {
	return (n + a - 1) / a * b;
}

int main() {
	int n {in()}, a {in()}, b {in()}, c {in()}, d {in()};
	outl(min(p(n, a, b), p(n, c, d)));
}


Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;
const ll mod = 1000000007;

int main()
{
  int n,k; cin>>n>>k;
  string s; cin>>s;

  int cnt = 0;
  for (int i=1; i<n; i++) {
    if (s[i-1] != s[i]) cnt++;
  }
  int t = max(0, cnt-k*2);
  cout << n-t-1 << endl;

  return 0;
}


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

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

int main()
{
    using vi = vector<int>;
    using vvi = vector<vi>;
    using vvvi = vector<vvi>;

    int A, B, C, X;
    cin >> A >> B >> C >> X;
    int count = 0;
    rep(i, A + 1)
    {
        rep(j, B + 1)
        {
            rep(k, C + 1)
            {
                if (i * 500 + j * 100 + k * 50 == X)
                {
                    count++;
                    break;
                }
            }
        }
    }

    cout << count << endl;
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;


int main() {
    int n;
    scanf("%d", &n);
    vector<int> A(n);
    rp(i, 0, n) {
        scanf("%d", &A.at(i));
        A.at(i) -= i+1;
    }
    sort(A.begin(), A.end());
    int m;
    ll ans = 0;
    ll b;
    if (n%2 == 0) {
        m = n/2;
        b = (A.at(m) + A.at(m-1)) / 2;
        b = int(b);
    } else {
        m = (n-1) / 2;
        b = A.at(m);
        b = int(b);
    }
    rp(i, 0, n) {
            ans += abs(A.at(i) - b);
    }
    printf("%lld", ans);
} 

Measured memory_bytes: 1152
package main

import (
	"fmt"
)

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)
	for i := a; i <= b && i < a+k; i++ {
		fmt.Println(i)
	}
	for i := b - k + 1; i <= b; i++ {
		if a+k <= i {
			fmt.Println(i)
		}
	}
}


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

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

#define MOD 1000000007

using namespace std;

int main(){
	int a;
	string s;
	
	cin >> a >> s;
	
	if(a>=3200)	cout << s << endl;
	else		cout << "red" << endl;
	
	return 0;
}

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

int main() {
	int k;
	cin >> k;
	int n;
	cin >> n;
	vector<int>a(n);
	for(int i = 0;i < n;i++){
		cin >> a.at(i);
	}
	vector<int>b(n);
	for(int i = 0;i < n;i++){
		if (i < n - 1)
			b.at(i) = a.at(i + 1) - a.at(i);
		else b.at(i) = k - a.at(i) + a.at(0);
	}
	int max = 0;
	for (int i = 0;i < n;i++) {
		if (max < b.at(i)) max = b.at(i);
	}
	for (int i = 0;i < n;i++) {
		if (b.at(i) == max) {
			cout << k - b.at(i) << endl;
			break;
		}
	}
}

Measured memory_bytes: 1792
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
    
n , k = map(int,input().split())
a = list(map(int,input().split()))
fl = ""

if k > max(a):
    fl = "IMPOSSIBLE"

else:
    g = a[0]
    for i in range(n-1):
        g = gcd( g , a[i+1] )
        
    if k % g == 0:
        fl = "POSSIBLE"
    else:
        fl = "IMPOSSIBLE"
        
print(fl)

Measured memory_bytes: 62704
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>

#define rep(i,N) for(int (i)=0;(i)<(N);(i)++)
#define MOD 1000000007

using namespace std;

int pow_mod(int a, int b, int p) {
	if (b == 0)return 1;
	else if (b % 2 == 0)return (pow_mod(a*a, b / 2, p) % p);
	else return (pow_mod(a, b - 1, p)*a%p);
}

int factorial_mod(int a, int p) {
	if (!a)return 1;
	else return a * factorial_mod(a - 1, p) % p;
}

int sum_digit(int N) {
	int ans = 0;
	for (; N != 0;) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

int H, W;
string a[110];
bool h[110] = { 0 }, w[110] = { 0 };

int main(){
	scanf("%d %d", &H, &W);
	rep(i, H)cin >> a[i];
	rep(i, H) {
		rep(j, W)if (a[i][j] == '#') {
			h[i] = true;
			w[j] = true;
		}
	}
	int w_max = 0;
	rep(i, W)if (w[i])w_max = max(w_max, i);
	rep(i, H) {
		if (h[i]) {
			rep(j, W) {
				if (w[j]) {
					cout << a[i][j];
					if (j == w_max)cout << "\n";
				}
			}
		}
	}
	return 0;
}

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


void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
    
    vis[node] = true; 

   
    for (int i = 0; i < adj[node].size(); i++) { 

       
        if (!vis[adj[node][i]]) 
            dfs(adj[node][i], adj, dp, vis); 

       
        dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
    } 
} 


void addEdge(vector<int> adj[], int u, int v) 
{ 
    adj[u].push_back(v); 
} 


int findLongestPath(vector<int> adj[], int n) 
{ 
   
    int dp[n + 1]; 
    memset(dp, 0, sizeof dp); 
    bool vis[n + 1]; 
    memset(vis, false, sizeof vis); 

    
    for (int i = 1; i <= n; i++) { 
        if (!vis[i]) 
            dfs(i, adj, dp, vis); 
    } 

    int ans = 0; 

    for (int i = 1; i <= n; i++) { 
        ans = max(ans, dp[i]); 
    } 
    return ans; 
} 

// Driver Code 
int main() 
{ 
    int n ,m;
    cin>>n>>m; 
    vector<int> adj[n + 1]; 

    for(long long int i=0;i<m;i++)
     {   long long int x,y;
         cin>>x>>y;
         addEdge(adj, x, y); 
         
     }

    cout << findLongestPath(adj, n); 
    return 0; 
} 


Measured memory_bytes: 9600
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    public void run() {
 
        for(int i=1;;i++){
            int val=sc.nextInt();
            if(val==0){
                break;
            }
            ln("Case "+i +": "+val);
        }
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


Measured memory_bytes: 42724
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>


using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> G;


void turn(G &g){
  for(int i = 1; i < g.size(); i++){
    int a = -g[i].second;
    int b = g[i].first;
    g[i].first = a;
    g[i].second = b;
  }
}

bool same(const G &g1, const G &g2){
  int n = g1.size();
  if(g2.size() != n) return false;
  int i;
  bool c1 = true, c2 = true;
  rep(i,n)
    if(g1[i].first - g2[i].first != g1[0].first - g2[0].first ||
      g1[i].second - g2[i].second != g1[0].second - g2[0].second)
      c1 = false;

//if(c1) cout<<"c1"<<endl;

  G v(n);
  rep(i,n)
    v[i] = g2[n-1-i];

    rep(i,n)
      if(g1[i].first - v[i].first != g1[0].first - v[0].first ||
        g1[i].second - v[i].second != g1[0].second - v[0].second)
        c2 = false;

//if(c2) cout<<"c2"<<endl;

  return c1 || c2;
}

int main(void) {
  int i,j;
  int n;
  while(cin>>n,n){

    vector<G> v(n+1);

    rep(i,n+1){
      int m;
      cin >> m;
      rep(j,m){
        int x,y;
        cin>>x>>y;
        v[i].push_back(pii(x,y));
      }
      loop(j,1,v[i].size()){
        v[i][j].first -= v[i][0].first;
        v[i][j].second -= v[i][0].second;
      }
      v[i][0].first = 0;
      v[i][0].second = 0;
    }
/*
cout << endl;
rep(i,n+1){
  rep(j,v[i].size())
  cout << v[i][j].first << " " << v[i][j].second << endl;
  cout << endl;
}
*/

    loop(i,1,n+1){
      bool c = false;
      rep(j,4){
        if(same(v[0],v[i])) c = true;
        turn(v[i]);
/*
        cout << "! " << i << " " << j << endl;
        int k;
        rep(k,v[i].size())
          cout << v[i][k].first << " " << v[i][k].second << endl;
        cout << endl;
*/
      }
      if(c) cout << i << endl;
    }

  cout << "+++++" << endl;
  }
}



Measured memory_bytes: 3108
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
using namespace std;

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

int main() {
	//差の最大公約数。
	long N, X; cin >> N >> X;
	long x[1000000]; for (int i = 1; i <= N; i++) cin >> x[i];
	long res = abs(X - x[1]);

	for (int i = 1; i + 1 <= N; i++) res = gcd(res, abs(x[i] - x[i + 1]));

	cout << res << endl;
}

Measured memory_bytes: 2944
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC125B
int main(void) {
  int n, k, i, cou=0, tmp;
  scanf("%d", &n);
  int vc[n];
  for(i=0; i<n; i++)
    scanf("%d", &vc[i]);
  for(i=0; i<n; i++){
    scanf("%d", &tmp);
    vc[i]-=tmp;
  }
  for(i=0; i<n; i++)
    if(vc[i]>0) cou+=vc[i];
  printf("%d", cou);
}

Measured memory_bytes: 128
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;

#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      FAST()              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const ll MOD = 998244353;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];

/*-----*/
int main()
{
	FAST();

       ll test=1;
       //cin>>test;
       while(test--){
           ll n,k,i,ans=0;
           string s;
           cin>>n>>k;
           ll ar[n+5];
           for(i=0;i<n;i++)
            cin>>ar[i];
           sort(ar,ar+n);
           for(i=0;i<k;i++)
            ans+=ar[i];
           cout<<ans<<endl;

        }
	loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
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;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - '0';}
char myitoc(int N) {return '0' + N;}

struct edge
{
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};

signed main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<edge>> G(N);
  for (int i = 0; i < M; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G.at(a).push_back(edge(b, -c));
  }

  vector<int> d(N, INF);
  d.at(0) = 0;
  for (int i = 0; i < 2 * N; i++)
  {
    for (int v = 0; v < N; v++)
    {
      for (int k = 0; k < G.at(v).size(); k++)
      {
        edge e = G.at(v).at(k);
        if (d.at(v) != INF && chmin(d.at(e.to), d.at(v) + e.cost))
        {
          if (i >= N - 1)
          {
            d.at(e.to) = -INF;
          }
        }
      }
    }
  }

  if (-d.at(N - 1) >= INF)
    cout << "inf" << endl;
  else
    cout << -d.at(N - 1) << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    long long a,b,c,d,x,y,z,w;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    x = a*c;
    y = a*d;
    z = b*c;
    w = b*d;
    if(x < y) x = y;
    if(x < z) x = z;
    if(x < w) x = w;

    printf("%lld",x);

    return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>

int a[3];

int main(void) {
	int n;
	int i;
	int x;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a[0],&a[1],&a[2]);
		swap();
		
		x=a[0]*a[0]+a[1]*a[1];
		if(x==a[2]*a[2]){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	
	return 0;
}

void swap(){
	int i,j;
	int temp;
	
	for(i=0;i<2;i++){
		for(j=i+1;j<3;j++){
			if(a[i]>a[j]){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
	}
}

Measured memory_bytes: 580
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (void){
        int len;
        int c=0;
        char S[10];
        scanf("%s",S);
        len=strlen(S);
        if (S[0]=='A'&&S[1]>=97&&S[1]<=122&&S[len-1]>=97&&S[len-1]<=122) {
          for (int i = 2; i <= len-2; i++) {
            if (S[i]=='C') {
              c++;
            }else if (!(S[i]>=97&&S[i]<=122)) {
              printf("WA\n");
              return 0;
            }
          }
          if (c==1) {
            printf("AC\n");
          }else{
          printf("WA\n");
          }
        }else{
            printf("WA\n");
        }
        return 0;
}


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

const int N=1e3+5;
int n,m,A[N],sum;

signed main() {
	cin>>n>>m;
	for(register int i=1;i<=n;i++)
		cin>>A[i],sum+=A[i];
	sort(A+1,A+1+n,greater<int>());
	for(register int i=1;i<=m;i++)
		if(A[i]*4*m<sum) return cout<<"No"<<endl,0;
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,r) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define lower(a,x) lower_bound(all(a), x) - a.begin();
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x);
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x);
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end());
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

string as = "AKIHABARA";

void dfs(ll now, string ss) {
  if (ss.length() == 9) {
	if (ss == as) ok = true;
	return;
  }
  dfs(now, ss + 'A');
  if (now < n) dfs(now + 1, ss + s[now]);
}

int main(void) {
  cin >> s;
  n = s.length();
  if (n > 9) {
	cout << "NO" << endl;
	return 0;
  }

  ok = false;
  dfs(0, "");
  if (ok) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

S_len = len(S)
T_len = len(T)

ans = T_len

for i in range(S_len - T_len + 1):

    diff = 0

    for j in range(T_len):

        if T[j] != S[i+j]:

            diff += 1

    ans = min(ans, diff)

print(ans)

Measured memory_bytes: 9016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder();
		while(true){
			String data[] = reader.readLine().split(" ");
			int a= Integer.parseInt(data[0]);
			int b= Integer.parseInt(data[1]);
			
			if(a==0 && b==0)
				break;
			
			for(int y=0,i=0; y<a; y++){
				for(int x=0; x<b; x++){
					builder.append( i++ %2 == 0 ? "#" : ".");
				}
				builder.append("\n");
				if(b%2==0)i++;
			}
			builder.append("\n");
		
		}
		System.out.print(builder);
	}
}

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

const int MN = 200010;

int H, W, N;
set<int> st[MN];

int main() {
    scanf("%d %d %d", &H, &W, &N);

    for(int i = 0; i < N; i++) {
        int x, y; scanf("%d %d", &x, &y);
        x--; y--;

        st[y].insert(x);
    }
    for(int i = 0; i < W; i++) st[i].insert(H);

    int x = 0, y = 0, t = 1, ans = *st[0].upper_bound(0);
    while(1) {
        if(t) {
            int t = *st[y].upper_bound(x);
            if(x + 1 == t) break;
            x++;
        }
        else {
            if(y < W - 1) {
                int t = *st[y + 1].lower_bound(x);
                if(t != x) {
                    y++;
                    ans = min(ans, *st[y].upper_bound(x));
                }
            }
        }
        t ^= 1;
    }
    printf("%d", ans);
}


Measured memory_bytes: 28416
#include <iostream>
using namespace std;
int main (void) {
    int N;
    int x;

    cin >> N >> x;

    if (x == 1 || x == 2 * N - 1 || (N == 2 && x != 2)) {
        cout << "No" << endl;
    } else if (N == 2) {
        cout << "Yes" << endl;
        cout << 1 << endl;
        cout << 2 << endl;
        cout << 3 << endl;
    } else {
        cout << "Yes" << endl;
        int a[2 * N - 1] = {0};
        if (x == 2) {
            a[N - 2] = x + 1;
            a[N - 1] = x;
            a[N] = x - 1;
            a[N + 1] = x + 2;
            for (int i = 0, n = 1; i < 2 * N - 1; i++) {
                if (n == x - 1) {
                    n = x + 3;
                }
                if (N - 2 <= i && i <= N + 1) {
                    continue;
                }
                a[i] = n++;
            }
        } else {
            a[N - 2] = x - 1;
            a[N - 1] = x;
            a[N] = x + 1;
            a[N + 1] = x - 2;
            for (int i = 0, n = 1; i < 2 * N - 1; i++) {
                if (n == x - 2) {
                    n = x + 2;
                }
                if (N - 2 <= i && i <= N + 1) {
                    continue;
                }
                a[i] = n++;
            }
        }
        for (int i = 0; i < 2 * N - 1; i++) {
            cout << a[i] << endl;
        }
    }

    return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;

    vector<long long> H(N + 1, 0);
    set<long long> HH;
    HH.insert(0);
    for (int i = 1; i <= N; i++)
    {
        cin >> H[i];
        HH.insert(H[i]);
    }
    map<long long, long long> to_value;
    map<long long, long long> to_idx;
    long long idx = 0;
    for (long long hh : HH)
    {
        to_value[idx] = hh;
        to_idx[hh] = idx;
        idx++;
    }

    // i-th index
    // j-th height
    // k-th change
    const long long init = 1e18;
    vector<vector<vector<long long>>> dp(N + 1, vector<vector<long long>>(N + 1, vector<long long>(K + 1, init)));
    dp[0][0][0] = 0;
    queue<pair<long long, long long>> q;
    q.push({0, 0});
    for (int i = 1; i <= N; i++)
    {
        set<pair<long long, long long>> tmp;
        while (!q.empty())
        {
            long long h = q.front().first;
            long long change = q.front().second;
            long long score = dp[i - 1][h][change];
            q.pop();
            if (to_value[h] > H[i])
            {
                dp[i][to_idx[H[i]]][change] = min(dp[i][to_idx[H[i]]][change], score);
                tmp.insert({to_idx[H[i]], change});
                if (change < K)
                {
                    dp[i][h][change + 1] = min(dp[i][h][change + 1], score);
                    tmp.insert({h, change + 1});
                }
            }
            if (to_value[h] == H[i])
            {
                dp[i][to_idx[H[i]]][change] = min(dp[i][to_idx[H[i]]][change], score);
                tmp.insert({to_idx[H[i]], change});
            }
            if (to_value[h] < H[i])
            {
                dp[i][to_idx[H[i]]][change] = min(dp[i][to_idx[H[i]]][change], score + (H[i] - to_value[h]));
                tmp.insert({to_idx[H[i]], change});
                if (change < K)
                {
                    dp[i][h][change + 1] = min(dp[i][h][change + 1], score);
                    tmp.insert({h, change + 1});
                }
            }
        }
        for (pair<long long, long long> p : tmp)
        {
            q.push(p);
        }
    }
    long long ans = init;
    while (!q.empty())
    {
        if (q.front().second <= K)
        {
            ans = min(ans, dp[N][q.front().first][q.front().second]);
        }
        q.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 219776
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

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

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

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func attackCount(hp, at int) int {
	count := math.Ceil(float64(hp) / float64(at))
	return int(count)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	hpTakahashi := nextInt()
	atTakahashi := nextInt()
	hpAoki := nextInt()
	atAoki := nextInt()

	//相手を倒すまでの攻撃回数
	countTakahashi := attackCount(hpAoki, atTakahashi)
	countAoki := attackCount(hpTakahashi, atAoki)

	if countTakahashi <= countAoki {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1756
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <stack>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

using namespace std;

constexpr int INF = 1000000000;/* 1e+9a */
constexpr int MODULO = 1000000007;

typedef int64_t ll;

constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << (n % k == 0 ? "0\n" : "1\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	if(a[0]==b[2] && a[2]==b[0] && a[1]==b[1]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())

A =list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(A)
for _ in range(M):
    temp = heapq.heappop(A) * (-1)
    heapq.heappush(A, (-1)*(temp // 2))


print(-sum(A))



Measured memory_bytes: 14252