akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: Int -> Int -> Int -> Int -> (Double, Int)
solve !w !h !x !y =
  let isCenter = w == 2 * x && h == 2 * y
  in  (fromIntegral (w * h) / 2, if isCenter then 1 else 0)

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (w, h, x, y) <-
    (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2, vec VU.! 3))
    .   VU.unfoldrN 4 readInt
    <$> B.getLine
  let (d, b) = solve w h x y
  putStrLn $ show d ++ " " ++ show b


Measured memory_bytes: 508
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string s;
	lint n;
	cin>>s>>n;
	rep(i,(100<n?100:n)){
		if(s.at(i)!='1'){
			cout<<s.at(i)<<endl;
			return 0;
		}
	}
	cout<<1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto&& i : a){
        cin >> i;
    }
    sort(begin(a), end(a));
    if(a.back() == 0){
        cout << "Yes\n";
        return 0;
    }else if(n % 3){
        cout << "No\n";
        return 0;
    }
    bool check = true;
    int x1, x2, x3;
    for(int i = 0; i < n / 3; i++){
        if(i == 0){
            if(a[0] != 0 || a[n / 3] != a[n / 3 * 2]){
                check = false;
                break;
            }else{
                x2 = a[n / 3];
            }
        }else if(0 != a[i] || x2 < a[i + n / 3 * 2]){
            check = false;
            break;
        }
    }
    if(check){
        cout << "Yes\n";
        return 0;
    }
    check = true;
    for(int i = 0; i < n / 3; i++){
        if(i == 0){
            if((a[0] ^ a[n / 3]) != a[2 * n / 3]){
                check = false;
                break;
            }else{
                x1 = a[0];
                x2 = a[n / 3];
                x3 = a[n / 3 * 2];
            }
        }else if(x1 != a[i] || x2 != a[i + n / 3] || x3 != a[i + n / 3 * 2]){
            check = false;
            break;
        }
    }
    if(check){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define reps(i,s,n) for(int i=(s); (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
int main(){
  int n,m,c; cin >> n >> m >> c;
  vector<int> b(m); rep(i,m)cin >> b[i]; 
  vector<vector<int>>a(n,vector<int>(m)); rep(i,n)rep(j,m) cin >> a[i][j];
  int tmp=0, ans=0;
  rep(i,n){
   rep(j,m) tmp += a[i][j]*b[j];
   if(tmp > -1*c) ans++; 
   tmp=0; 
  }
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8

N = int(input())
A = list(map(int, input().split()))

max_answer = 0

for i in range(N):
    for j in range(i + 1, N):
        answer = abs(A[i] - A[j])
        if answer > max_answer:
            max_answer = answer

print(max_answer)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
const int MOD = 1000000007;

int main()
{
    int d, g; cin >> d >> g;
    int p[11],c[11];
    rep(i, d) cin >> p[i] >> c[i];

    ll ans = INF;
    rep(i, 1 << d)
    {
        ll tot = 0, cnt = 0;
        rep(j, d)
        {
            if (i >> j & 1)
            {
                tot += p[j] * (j + 1) * 100 + c[j];
                cnt += p[j];
            }
        }
        if (tot >= g) ans = min(ans, cnt);
        else
        {
            for (int j = d-1; j >= 0; --j)
            {
                if (i >> j & 1) continue;
                rep(k, p[j])
                {
                    if (tot >= g) break;
                    tot += 100 * (j + 1);
                    cnt++;
                    //cout << j << endl;
                }
            }
            ans = min(ans, cnt);
            //cout << ans << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
string s;
  cin >>s;
 
    cout << s.at(0)<<s.at(1)<<s.at(2)<<s.at(3)<<s.at(4)<<" "<<s.at(6)<< s.at(7)<<s.at(8)<<s.at(9)<<s.at(10)<<s.at(11)<<s.at(12)<<" "<<s.at(14)<<s.at(15)<<s.at(16)<<s.at(17)<<s.at(18)<< endl;
}

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

int main() {

    string S;
    cin >> S;
    
    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
        cout << "Yes" << endl;
    }
    
    else { cout << "No" << endl;
         }

}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}


bool SQRT(ll a){
    ll d=sqrt(a);
    for(ll i=d-100;i<d+100;i++){
        if(i*i==a){return true;}
    }
    return false;
}

int main(){
    ll n,d;
    cin>>n>>d;
    vector<vector<ll>> A(n,vector<ll>(d));
    cin>>A;
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            ll D=0;
            for(int k=0;k<d;k++){
                D+=(A[j][k]-A[i][k])*(A[j][k]-A[i][k]);
            }
            if(SQRT(D)){ans++;}
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
/*input
3
RRRGGGBBB
*/
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int maxn = 3e5 + 100;
const int mod = 998244353;
int n;
string s;
ll cnt[3]; /// 0 - R, 1 - G, 2 - B
vector<ll>ways[3];/// 0 - RG, 1 - RB, 2 - GB
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	cin >> s;
	ll ans = 1;
	for(char c : s)
	{
		if(c == 'R')
		{
			if(sz(ways[2]) > 0)
			{
				ans = ans * ways[2].back() % mod;
				ans = 1ll * ans * sz(ways[2]) % mod;
				ways[2].pop_back();
			}
			else
			{
				if(cnt[1] > 0)
				{
					ways[0].pb(cnt[1]);
					cnt[1]--;
				}
				else if(cnt[2] > 0)
				{
					ways[1].pb(cnt[2]);
					cnt[2]--;
				}
				else
					cnt[0]++;
			}
		}
		else if(c == 'G')
		{
			if(sz(ways[1]) > 0)
			{
				ans = ans * ways[1].back() % mod;
				ans = 1ll * ans * sz(ways[1]) % mod;
				ways[1].pop_back();
			}
			else
			{
				if(cnt[0] > 0)
				{
					ways[0].pb(cnt[0]);
					cnt[0]--;
				}
				else if(cnt[2] > 0)
				{
					ways[2].pb(cnt[2]);
					cnt[2]--;
				}
				else
					cnt[1]++;
			}
		}
		else if(c == 'B')
		{
			if(sz(ways[0]) > 0)
			{
				ans = ans * ways[0].back() % mod;
				ans = 1ll * ans * sz(ways[0]) % mod;
				ways[0].pop_back();
			}
			else
			{
				if(cnt[0] > 0)
				{
					ways[1].pb(cnt[0]);
					cnt[0]--;
				}
				else if(cnt[1] > 0)
				{
					ways[2].pb(cnt[1]);
					cnt[1]--;
				}
				else
					cnt[2]++;
			}
		}
	}
	for(int i = 1; i <= n; i++)
		ans = 1ll * ans * i % mod;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1680
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<complex>
#include<time.h>
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	ll pos=0;
	REP(i,n) if(a[i]==1) pos=i;
	ll ans=0;
	ll idx=0;
	while(idx<n) {
		if(idx<=pos&&idx+k>pos) {
			ans++;
			idx+=k;
		} else {
			ans++;
			idx+=k-1;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long dp[10][10]={};
long long N;
int top,bottom,num;
long long ans=0;
cin>>N;
for(int i=1;i<=N;++i){
  bottom=i%10;
  num=i;
  while(num>=10){
    num/=10;
  }
  top=num;
  dp[top][bottom]+=1;
}
for(int i=1;i<10;++i){
  for(int j=1;j<10;++j){
    if(i!=j){
      ans+=(dp[i][j]*dp[j][i]);
    }
    else{
      ans+=(dp[i][j]*dp[i][j]);
    }
  }
}
cout<<ans<<"\n";
return 0;
}


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


int main(){
    long long N, M;
    cin >> N >> M;
    vector<pair<long long, long long> > a(M);
    vector<long long> b(200000,0);
    for (int i=0; i<M; ++i) {
        cin >> a.at(i).first >> a.at(i).second;
        if (a[i].first==1) b[a[i].second]++;
    }
    
    for (int i=0; i<M; ++i) {
        if (b[a[i].first]>0 && a[i].second==N) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 4992
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		int n;

		double a;

		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();

		ArrayList<Double> list = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			list.add(sc.nextDouble());
		}

		Collections.sort(list);

		a = list.get(0);

		for (int i = 1; i < n; i++) {
			a = (a + list.get(i)) / 2;
		}

		System.out.println(a);


	}
}


Measured memory_bytes: 24020
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

struct Test{
	int a,b,c,r;
};

vector<Test> tests;

int pro[400];

int main() {
	int a,b,c,n;
	while(cin>>a>>b>>c,a){
		tests.clear();
		int i;
		for(i=0;i<400;i++)pro[i]=2;
		cin>>n;
		for(i=0;i<n;i++){
			Test buf;
			cin>>buf.a>>buf.b>>buf.c>>buf.r;
			buf.a--;buf.b--;buf.c--;
			tests.push_back(buf);
		}
		bool update=true;
		while(update){
			update=false;
			for(i=0;i<n;i++){
				if(pro[tests[i].a]!=2&&pro[tests[i].b]!=2&&pro[tests[i].c]!=2)continue;
				if(tests[i].r==1){
					pro[tests[i].a]=1;
					pro[tests[i].b]=1;
					pro[tests[i].c]=1;
					update=true;
				}else{
					if(pro[tests[i].a]==1&&pro[tests[i].b]==1){pro[tests[i].c]=0;update=true;}
					if(pro[tests[i].a]==1&&pro[tests[i].c]==1){pro[tests[i].b]=0;update=true;}
					if(pro[tests[i].b]==1&&pro[tests[i].c]==1){pro[tests[i].a]=0;update=true;}
				}
			}
		}
		for(i=0;i<a+b+c;i++){
			cout<<pro[i]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

using P = pair<ll, int>;

int main() {
  int N, K;
  while (cin >> N >> K) {
    vec<ll, 2> g(N);
    for (int i = 0; i < N; i++) {
      ll t, d;
      cin >> t >> d;
      --t;
      g[t].push_back(d);
    }
    vector<int> ind;
    for (int t = 0; t < N; t++) {
      if (g[t].empty()) continue;
      sort(g[t].rbegin(), g[t].rend());
      ind.push_back(t);
    }
    sort(ind.begin(), ind.end(), [&](int a, int b) {
      if (g[a][0] != g[b][0]) return g[a][0] > g[b][0];
      return a < b;
    });
    ll res = 0;
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    ll topsum = 0, restsum = 0;
    for (int j = 0; j < ind.size() && j < K;) {
      int k = j;
      while (k < ind.size() && g[ind[k]][0] == g[ind[j]][0]) {
        int t = ind[k];
        for (int i = 1; i < g[t].size(); i++) {
          restsum += g[t][i];
          pq.push(g[t][i]);
        }
        ++k;
      }
      while (j < k) {
        int x = j + 1;
        int y = K - x;
        if (y < 0) break;
        topsum += g[ind[j]][0];
        while (pq.size() > y) {
          restsum -= pq.top();
          pq.pop();
        }
        if (pq.size() == y) {
          res = max(res, topsum + restsum + (ll)x * x);
        }
        ++j;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int l[10], u, v;
	char c;

	while (cin >> l[0] >> c) {
		rep(i, 9) cin >> l[i + 1] >> c;
		cin >> u >> c >> v;

		for (int i = 1; i < 10; ++i) {
			l[i] += l[i - 1];
		}

		double d = (double)l[9] / (u + v) * u;
		for (int i = 0; i < 10; ++i) {
			if (l[i] >= d) {
				cout << i + 1 << endl;
				break;
			}
		}
		//rep(i, 10) cout << l[i] << endl;
		//cout << u << endl;
	 	//cout << v << endl;
	}
}

Measured memory_bytes: 3068
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

def LCM(m,n):
  if m>n:
    m,n=n,m
  for i in range(1,m+1)[::-1]:
    if n%i==0:
      return i
    
N,X=(int(i) for i in input().split(' '))
x=[int(i) for i in input().split(' ')]
x=[X]+x
x=quick_sort(x)
D=abs(x[1]-x[0])
for i in range(N):
  D=LCM(D,abs(x[i+1]-x[i]))
print(D)

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

int main(){
	int n;
	cin >> n;
	vector<int64> a(n), b(n);
	int64 sa = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sa += a[i];
	}
	int64 sb = 0;
	for(int i = 0; i < n; i++){
		cin >> b[i];
		sb += b[i];
	}
	if(sa < sb){
		cout << -1 << endl;
		return 0;
	}
	vector<int64> ps;
	int64 sum = 0;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int tmp = a[i] - b[i];
		if(tmp > 0) ps.push_back(tmp);
		if(tmp < 0) sum += abs(tmp), ans++;
	}
	sort(ps.rbegin(), ps.rend());
	for(auto i : ps){
		if(sum > 0){
			sum -= i;
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2428
MOD = 10**9 + 7
factorials = [1]
for i in range(1, 200000):
    factorials.append((factorials[-1] * i) % MOD)
invs = [pow(x, MOD - 2, MOD) for x in factorials]


def combinations(n, k):
    return (factorials[n] * invs[k] * invs[n - k]) % MOD


def f(x, y):
    return combinations(x + y - 2, x - 1)


h, w, a, b = map(int, input().split())
res = 0
for y in range(1, h - a + 1):
    res += (f(b, y) * f(w - b, h - y + 1)) % MOD
print(res % MOD)

Measured memory_bytes: 19028
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod2 1000000007
#define mod 998244353
#define pi 3.141592653589793
#define all(v) v.begin(),v.end()


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}

int main(){
    int n;
    cin >> n;
    int x=n%10;
    if(x==3){
        cout << "bon" <<endl;
    }
    else if(x==0||x==1||x==6||x==8){
        cout << "pon" <<endl;
    }
    else {
        cout << "hon" <<endl;
    }
    return 0;
}



Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 205;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n,m,r;
long long d[N][N];
int mas[15];
bool used[15];
long long answ = 1ll * inf * inf;

void rec(int v,int vv,long long sum){
    if(v == r){
        answ = min(answ , sum);
        return ;
    }
    for(int i=0;i<r;i++){
        int gag = mas[i];
        if(used[i] == false){
            used[i] = true;
            rec(v + 1 , gag , sum + d[vv][gag]);
            used[i] = false;
        }
    }
}

int main(){
    cin>>n>>m>>r;
    for(int i=0;i<r;i++) scanf("%d",&mas[i]);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i == j)continue;
            d[i][j] = 1ll * inf * inf;
        }
    }
    for(int i=1;i<=m;i++){
        int a,b;
        long long c;
        cin>>a>>b>>c;
        d[a][b] = d[b][a] = c;
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                d[i][j] = min(d[i][j] , d[i][k] + d[k][j]);
            }
        }
    }
    rec(0 , 0 , 0);
    cout<<answ<<endl;
    return 0;
}


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

const int N = 2e5 + 10, mod = 1e9 + 7;

int n, k, dp[N], cnt[N];

int fp(int a, int b) {
    int ret = 1;
    while(b) {
        if(b & 1) ret = 1ll * ret * a % mod;
        b >>= 1;
        a = 1ll * a * a % mod;
    }
    return ret;
}

int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        scanf("%d%d", &n, &k);
        for(int i = 1; i <= k; i++) {
            for(int j = i; j <= k; j += i) cnt[i]++;
        }
        int ans = 0;
        for(int i = k; i >= 1; i--) {
            dp[i] = fp(cnt[i], n);
            for(int j = i + i; j <= k; j += i) dp[i] = (1ll * dp[i] - dp[j]) % mod;
            if(dp[i] < 0) dp[i] += mod;
            ans = (ans + 1ll * dp[i] * i % mod) % mod;
        }
        printf("%d\n", ans);
    }    
    return 0;
}

Measured memory_bytes: 4564
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b;
    cin >> a >> b ;
    a -= b;
    cout << (a < 0 ? 0: a) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] num = new int[n];
			long[] sum = new long[n];
			
			for(int i=0;i<n;i++){
				int a = sc.nextInt();
				long b = sc.nextLong();
				long c = sc.nextLong();
				boolean flag = true;
				for(int j=0;j<i;j++){
					if(num[j]==0)break;
					if(a==num[j]){
						sum[j] += b*c;
						flag = false;
					}
				}
				if(flag==true){
					num[i] = a;
					sum[i] += b*c;
				}
				
			}
			
			boolean na = true;
			for(int i=0;i<n;i++){
				if(sum[i]>=1000000){
					System.out.println(num[i]);
					na = false;
				}
			}
			if(na==true)System.out.println("NA");
			
		}
	}
}

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

int main() {
	int A, B, C, D; cin >> A >> B >> C >> D;
	if(A+B==C+D) cout << "Balanced" << endl;
	else if(A+B>C+D) cout << "Left" << endl;
	else cout << "Right" << endl;
	return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc088/tasks/abc088_a
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a;
	cin>>n>>a;
	n=n%500;
	if(n<=a){
		cout<<"Yes"<<endl;
	}
	if(n>a){
		cout<<"No"<<endl;
	}
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        int sum = 0;
        for(int j = 0; j < K; j++) {
            sum += arr[N - 1 - j];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;

vector<ll> to[2510];
vector<ll> rto[2510];
bool from1[2510];
bool toN[2510];
bool ok[2510];

void dfs(ll v) {
  if (from1[v]) return;
  from1[v] = true;
  for (ll u : to[v]) {
    dfs(u);
  }
}

void rdfs(ll v) {
  if (toN[v]) return;
  toN[v] = true;
  for (ll u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  ll n, m, p;
  cin >> n >> m >> p;
  vector<tuple<ll, ll, ll>> edges;
  REP(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    c -= p;
    c = -c;
    edges.emplace_back(a, b, c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n - 1);
  REP(i, n) ok[i] = from1[i] && toN[i];

  vector<ll> d(n, INF);
  d[0] = 0;
  bool upd = true;
  ll step = 0;
  while (upd) {
    upd = false;
    REP(i, m) {
      ll a, b, c;
      tie(a, b, c) = edges[i];
      if (!ok[a] || !ok[b]) continue;
      ll newD = d[a] + c;
      if (newD < d[b]) {
        upd = true;
        d[b] = newD;
      }
    }
    step++;
    if (step > n) {
      cout << -1;
      return 0;
    }
  }
  ll ans = -d[n - 1];
  ans = max(ans, 0LL);
  cout << ans;
  return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 10005

using namespace std;

int main()
{
    ll a,b,c;

    scanf("%lld %lld %lld",&a,&b,&c);

    if(c>=a&&c<=b)
        printf("Yes\n");

    else
        printf("No\n");

    return (0);
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,ans=0;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            for(ll k=j+1;k<n;k++)
            {
                if(a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
                {
                    if(a[i]+a[j]>a[k]&&a[j]+a[k]>a[i]&&a[k]+a[i]>a[j])
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main(){
  int num[3];
  cin >> num[0] >> num[1] >> num[2];
  if(num[0] + num[1] == num[2] || num[1] + num[2] == num[0] || num[2] + num[0] == num[1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if (k>(a+b))
    {
    	k=k-(a+b);
    	cout<<a-k<<endl;
	}
	else
	{
		if (k>a)
		{
			cout<<a<<endl;
		}
		else
		{
			cout<<k<<endl;
		}
	}
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,D;
  cin>>N>>D;
  long long count=0;
  for(int i=0;i<N;i++){
  	long long x,y;
    cin>>x>>y;
    if(sqrt(x*x + y*y)<=D){
    count++;
    }
  }
  cout<<count;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

ll calulate_nCK(ll r, ll c)
{
    ll i;
    int max_number = r+c+2;
    int MOD = 1e9+7;
    
    vector<ll> fac(max_number+1,1);
    vector<ll> inv(max_number+1,1);
    vector<ll> finv(max_number+1,1);
    vector<ll> nCk(max_number+1,1);
    for(i = 2;i <= max_number;++i){
        inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
    }
    for(i = 1;i <= max_number;++i){
        fac.at(i) = fac.at(i-1)*i%MOD;
        finv.at(i) = finv.at(i-1)*inv.at(i)%MOD;
    }
    for(i = 1;i <= max_number;++i){
        nCk.at(i) = fac.at(max_number)*finv.at(i)%MOD*finv.at(max_number-i)%MOD;
    }
    return nCk.at(r+1) - 1;
}

int main()
{
    ll i,j;
    ll r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ll MOD = 1e9+7;
    ll ans = calulate_nCK(r2, c2)  + (MOD- calulate_nCK(r2, c1-1))  + (MOD- calulate_nCK(r1-1, c2)) + calulate_nCK(r1-1, c1-1);
    cout << ans%MOD << endl;
    return 0;
}

Measured memory_bytes: 62764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n;

void solve(){
    cin >> n;
    cout << (n + 1) / 2 << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

namespace CSharpScript
{
	class Program
	{
		static void Main(string[] args)
		{
			// Test("test");
			var n = int.Parse(Console.ReadLine());
			var input = Console.ReadLine().Split().ToArray();
			var a = input[0];
			var b = input[1];

			var ans = "";
			var acounter = 0;
			var bCounter = 0;
			for (var i = 0; i < a.Length + b.Length; i++)
			{
				if (i % 2 == 0)
				{
					ans += a[acounter++];
				}
				else
				{
					ans += b[bCounter++];
				}
			}
			System.Console.WriteLine(ans);
		}

		public static long Gcd(long m, long n)
		{
			long temp;
			while (m % n != 0)
			{
				temp = n;
				n = m % n;
				m = temp;
			}
			return n;
		}
	}
}

Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x;
    cin>>n>>x;
    VL L(n);
    REP(i,n)cin>>L[i];
    LL d = 0;
    int ans = 1;
    REP(i,n){
        if(d + L[i] <= x)ans++;
        d += L[i];
    }
    PUTS(ans);
}

Measured memory_bytes: 256
import sys
s=0
p=[list(map(float,e.split(',')))for e in sys.stdin]
x,y=p[0]
for i in range(len(p)-2):a,b=p[i+1];c,d=p[i+2];s+=(a-x)*(d-y)-(b-y)*(c-x)
print(abs(s)/2)


Measured memory_bytes: 5592
BIG_NUM = 10**18
is_even = lambda x: x%2==0
def two_count(x):
    if x == 0:
        return BIG_NUM
    c = 0
    while x and x%2 == 0:
        x //= 2
        c += 1
    return c
    
A, B, C = map(int, input().split(" "))

if all(map(is_even, [A, B, C])):
    a2, b2, c2 = (B+C)//2, (C+A)//2, (A+B)//2    
    n = min(map(two_count, [A-a2, B-b2, C-c2]))
    if n == BIG_NUM:
        print(-1)
    else:
        print(n+1)
else:
    print(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))

#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
const int MOD = 1'000'000'007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int n, m, k;
//=======================

int  count_digits(int n) 
{ 
    string num = to_string(n); 
    return num.size() ;
} 
void solve() {

long long int n,x,sum=0;
string s;
cin>>s;
n=s.length();
fo(x,n){
    sum+=(s[x]-'0');
}
if(s[0]=='0'&&n==1){cout<<"Yes";return;}
if(sum%9==0){cout<<"Yes";}
else{cout<<"No";}

}

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

    return 0;
}

Measured memory_bytes: 50588
N = int(input())
r = []

for i in range(1, N+1):
    name, point = (x for x in input().split())
    r.append([name, int(point), i])
    r.sort(key=lambda x: x[1], reverse=True)
    r.sort(key=lambda x: x[0])

for i in range(N):
    print(r[i][2])

Measured memory_bytes: 3060
import math
a,b=map(int,input().split())
a_down=math.ceil(a/0.08)
a_up=math.ceil((a+1)/0.08)
b_down=math.ceil(b/0.1)
b_up=math.ceil((b+1)/0.1)

for i in range(a_down,a_up):
  if i >= b_down and i < b_up:
    answer=i
    break
  else:
    answer=-1
print(answer)

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

#pragma GCC diagnostic warning "-Wconversion"

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, n) for(int i = n; i >= 0; i--)
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a, b) a = min(a, b)
#define imax(a, b) a = max(a, b)

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

using ll = long long;

ll check(ll H, ll W)
{
        ll res = maxval(ll);

        ll x = W / 2;
        ll y = W / 2 + W % 2;

        forb(i, H - 1)
        {
                ll a = i * W;

                ll b = (H - i) * x;
                ll c = (H - i) * y;
                imin(res, max({abs(a - c), abs(a - b), abs(b - c)}));

                ll j = (H - i) / 2;
                ll k = (H - i) / 2 + (H - i) % 2;
                b = j * W;
                c = k * W;
                imin(res, max({abs(a - c), abs(a - b), abs(b - c)}));
        }
        return res;
}

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

        ll H, W;
        cin >> H >> W;

        cout << min(check(H, W), check(W, H)) << endl;
}


Measured memory_bytes: 256
n, m, x = list(map(int, input().split()))
a = list(map(int, input().split()))

cost = {}

for i in a:
    cost[i] = True

left = right = 0

for i in reversed(range(0, x)):
    left += (1 if i in cost else 0)

for i in range(x, n + 1):
    right += (1 if i in cost else 0)

print(min(left, right))


Measured memory_bytes: 3060
while True:
	k=map(int,raw_input().split(" "))
	if k[0]==k[1]==0:
		break
	ct=0
	a=0
	b=0
	c=0	
	max=k[0]
	sum=k[1]
	a=max+1
	
	while True:
		a-=1
		b=a-1
		c=sum-a-b
		if not a>b>c:
			print ct
			break
		while a>b>c:
			if a>b>c>0:
				ct+=1
			b-=1
			c+=1
			

Measured memory_bytes: 6348
// template {{{
#![allow(clippy::many_single_char_names)]

#[allow(dead_code)]
mod ngtio {
    use ::std::collections::VecDeque;

    pub struct Buffer {
        buf: VecDeque<String>,
    }

    impl Buffer {
        pub fn new() -> Self {
            Self {
                buf: VecDeque::new(),
            }
        }

        fn load(&mut self) {
            while self.buf.is_empty() {
                let mut s = String::new();
                let length = ::std::io::stdin().read_line(&mut s).unwrap();
                if length == 0 {
                    break;
                }
                self.buf.extend(s.split_whitespace().map(|s| s.to_owned()));
            }
        }

        pub fn string(&mut self) -> String {
            self.load();
            self.buf
                .pop_front()
                .unwrap_or_else(|| panic!("入力が終了したのですが。"))
        }

        pub fn string_char_vec(&mut self) -> Vec<char> {
            let s = self.string();
            s.chars().collect::<Vec<_>>()
        }

        pub fn string_char_vec_trusted_len(&mut self, len: usize) -> Vec<char> {
            let s = self.string();
            let s = s.chars().collect::<Vec<_>>();
            assert_eq!(s.len(), len, "あら、思ったのと長さ違いますね……");
            s
        }

        pub fn char(&mut self) -> char {
            let string = self.string();
            let mut chars = string.chars();
            let res = chars.next().unwrap();
            assert!(
                chars.next().is_none(),
                "char で受け取りたいのも山々なのですが、さては 2 文字以上ありますね？"
            );
            res
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T
        where
            <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
        {
            self.string()
                .parse::<T>()
                .expect("Failed to parse the input.")
        }

        pub fn read_vec<T: ::std::str::FromStr>(&mut self, len: usize) -> Vec<T>
        where
            <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
        {
            (0..len).map(|_| self.read::<T>()).collect()
        }
    }

    macro_rules! define_primitive_reader {
        ($($ty:tt,)*) => {
            impl Buffer {
                $(
#[inline]
                    pub fn $ty(&mut self) -> $ty {
                        self.read::<$ty>()
                    }
                )*
            }
        }
    }

    define_primitive_reader! {
        u8, u16, u32, u64, usize,
        i8, i16, i32, i64, isize,
    }

    impl Default for Buffer {
        fn default() -> Self {
            Self::new()
        }
    }
}

#[allow(unused_imports)]
use std::{collections, iter, mem, ops};
// }}}

fn main() {
    let mut buf = ngtio::Buffer::new();
    let x = buf.u8();
    println!("{}", 1 - x);
}


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

int main(void){
    ll n,d;
    cin>>n>>d;
    ll x,y;
    int count = 0;
    rep(i,n){
        cin>>x>>y;
        if(x*x+y*y<=d*d)count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int sz=22;
const ll MOD=1e9+7;
ll dp[sz][(1<<22)]; // represents total ways to pair men with women when men from
 // i to N are present to match with j subset of women. Subset is represented using
 // bitmasking where every bit in integer j represnts whether women is present(1) or
 // not(1) 
 
// Dp with Bistmasking
ll solve(vector<vector<int>>& compat,int i,int womenSubset,int men){
    if(i==men+1){
        if(womenSubset==0)
            return 1;
        else
            return 0;
    }
    if(dp[i][womenSubset]!=-1)
        return dp[i][womenSubset];
    ll ans=0;
    for(int women=0;women<men;women++){
        bool available=(((1<<women)&womenSubset)==0)?0:1;
        if(available and compat[i][women+1]){
            ans=ans+solve(compat,i+1,womenSubset^(1<<women),men)%MOD;
        }
    }
    return dp[i][womenSubset]=ans;
}   

int main() {
	memset(dp,-1,sizeof(dp));
    ll n=0;cin>>n;
    vector<vector<int>> compat(n+1,vector<int>(n+1,0));
    for(int i=1;i<=n;++i)
        for(int j=1;j<=n;++j)
            cin>>compat[i][j];
    ll ans=solve(compat,1,(1<<n)-1,n)%MOD;
    cout<<ans<<'\n';
    return 0;
}


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

a=[]
a_sort=[]
for i in range(n):
    tmp=int(input())
    a.append(tmp)
    a_sort.append(tmp)
a_sort.sort(reverse=True)

for i in range(n):
    if a_sort[0]==a[i]:print(a_sort[1])
    else:print(a_sort[0])

Measured memory_bytes: 102316
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>

#define FOR(i, n) for (int i = 0; i < n; i++)
#define FORN(i, a, b) for (int i = a; i < b; i++)
#define OUT(s) cout << s << endl;
#define IN(a) cin >> a;
#define PACK(a, n) \
  for (int i = 0; i < n; i++) cin >> a[i];
#define PACK1(a, n) \
  for (int i = 1; i < n; i++) cin >> a[i];
#define LIST(a, n) \
  for (int i = 0; i < n; i++) cout << "[" << i << "] " << a[i] << endl;

using namespace std;

int A, B;

int main() {
  IN(A >> B);
  int count = 0;
  FORN(i, A, B + 1) {
    string numstr = to_string(i);
    bool sym = true;
    FOR(i, numstr.size() / 2) {
      if (numstr[i] != numstr[numstr.size() - 1 - i]) {
        sym = false;
      }
    }
    if (sym) count++;
  }
  OUT(count);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll n; cin >> n;
  ll m = 1ll<<n;
  V s(m);
  rep(i, m) cin >> s[i];
  sort(all(s));

  V S;
  S.push_back(s[m-1]);
  s[m-1] = -1;

  rep(i, n) {
    V S2 = S;
    sort(all(S2));
    int j = m-1;
    while (!S2.empty() && j >= 0) {
      if (s[j] < 0) {
        --j;
        continue;
      }
      if (S2.back() > s[j]) {
        S.push_back(s[j]);
        s[j] = -1;
        S2.pop_back();
      }
      --j;
    }
    if (!S2.empty()) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 2932
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<cctype>
#include<climits>
#include<bitset>
#include<stack>

using namespace std;

typedef long long ll;

const int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
int W, H, fld[10][10];
int P, sx, sy;
map<pair<pair<int, int>, int>, int> memo;

inline int CountBit(int s)
{
	int res = 0;
	for (int i = 0; i < P; i++) res += (s >> i) & 1;
	return res;
}

inline bool IsInside(int x, int y)
{
	return 0 <= x && x < W && 0 <= y && y < H;
}

inline bool CanDown(int x, int y, int s, int noBits)
{
	if (x == sx && y == sy && noBits == P) return true;
	if (fld[y][x] == -1) return false;
	return ((s >> fld[y][x]) & 1) == 0;
}

int DFS(int x, int y, int s)
{
	int cnt = CountBit(s);
	if (x == sx && y == sy && cnt == P) return 1;
	pair<pair<int, int>, int> state = make_pair(make_pair(x, y), s);
	if (cnt < 16)
	{
		map<pair<pair<int, int>, int>, int>::iterator itr = memo.find(state);
		if (itr != memo.end()) return itr->second;
	}
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i], ny = y + dy[i];
		while (IsInside(nx, ny) && !CanDown(nx, ny, s, cnt))
			nx += dx[i], ny += dy[i];
		if (!IsInside(nx, ny)) continue;
		sum += DFS(nx, ny, s | (1 << fld[ny][nx]));
	}
	if (cnt < 16) memo[state] = sum;
	return sum;
}

signed main()
{
	while (cin >> W >> H, W || H)
	{
		memo.clear();
		P = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> fld[i][j];
				if (fld[i][j] == 0) fld[i][j] = -1;
				else if (fld[i][j] == 1) fld[i][j] = P++;
				else sx = j, sy = i, fld[i][j] = -1;
			}
		}
		printf("%d\n", DFS(sx, sy, 0));
	}
	return 0;
}

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





int main(){

  int64_t k;
  cin>>k;
  
  queue<int64_t> data;
  
  for (int i=1;i<=9;i++){
    data.push(i);
  }
  
  
  for (int64_t i=0;i<k-1;i++){
    int64_t tmp=data.front();
    data.pop();

    int64_t a=tmp%10;
    if (a!=0 and a!=9){
      data.push(tmp*10+a-1);
      data.push(tmp*10+a);
      data.push(tmp*10+a+1);
    }
    
    else if (a==0){
      data.push(tmp*10);
      data.push(tmp*10+1);
    }
    
    else {
      data.push(tmp*10+a-1);
      data.push(tmp*10+a);
    }
  }
  
  int64_t answer=data.front();
 
  cout<<answer<<endl;
      
      
    
  
  
  

  
  
  
}

Measured memory_bytes: 1792
from decimal import Decimal, ROUND_HALF_UP
n = int(input())
P = list(map(int,input().split()))
a = sum(P) / len(P)
r =  Decimal(a).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
ans = 0
for i in range(n):
    ans += (P[i] - r) ** 2

print(ans)

Measured memory_bytes: 5076
from functools import reduce
from math import floor, ceil

# 入力
K = int(input())
A = list(map(int, input().split()))

# ラウンドKから1まで順に、子どもたちの人数として考えられる最小の値と最大の値を求める
R = reduce(
    lambda acc, a:
        acc if acc[0] > acc[1] else
        (
            a * ceil(acc[0] / a),
            a * (floor(acc[1] / a) + 1) - 1
        ),
    reversed(A),
    (2, 2)
)
ans = (
    -1 if R[0] > R[1] else
    ' '.join(map(str, R))
)

# 出力
print(ans)


Measured memory_bytes: 14648