akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include <bits/stdc++.h>

namespace __temp_inbuilt{
	int read(void){
		int res = 0, sign = 1;
		char ch = std::getchar();
		while(!std::isdigit(ch)){
			if(ch == '-')
				sign = -1;
			ch = std::getchar();
		}
		while(std::isdigit(ch))
			res = res * 10 + ch - 48, ch = std::getchar();
		return sign * res;
	}
	
	template<class Tp>
		void write(const Tp &x){
			if(x > 9)
				write(x / 10);
			std::putchar(x % 10 + 48);
	}
}

using __temp_inbuilt::read;

template<class Tp>
	void writeln(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
		std::putchar('\n');
	}

template<class Tp>
	void writesp(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
		std::putchar(' ');
	}

template<class Tp>
	void write(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
	}

typedef long long ll;
typedef unsigned long long ull;
typedef double rl;
typedef long double RL;

const rl PI = 3.1415926535898, E = 2.71828182845904;

namespace contest{
	const int MAXN = 2e5 + 19;
	
	int n, k, a[MAXN];
	
	int check(int v){
		int res = 0;
		for(int i = 1; i <= n; ++i)
			res += (a[i] + v - 1) / v - 1;
		return res;
	}
	
	int main(){
		n = read(), k = read();
		int u = 1;
		for(int i = 1; i <= n; ++i)
			a[i] = read(), u = std::max(u, a[i]);
		int l = 1, r = u;
		while(l < r){
			int mid = (l + r) >> 1;
			if(check(mid) <= k)
				r = mid;
			else
				l = mid + 1;
		}
		writeln(l);
		return 0;
	}
}

int main(){
	contest::main();
	return 0;
}

Measured memory_bytes: 4328
import Control.Applicative
import Control.Monad
import Data.List
import Data.Maybe
import Data.Ord

calc g ps = f 0 0 Nothing ps
  where
    f :: Int -> Int -> Maybe (Int, Int) -> [(Int, Int, Int)] -> Maybe Int
    f get probs Nothing [] = Just probs
    f get probs (Just (maxi, maxp)) []
      | get >= g = Just probs
      | get + (maxi * (maxp - 1)) >= g = let remain = g - get in Just (probs + div (remain + maxi - 1) maxi)
      | otherwise = Nothing
    f get probs maxprob ((i, p, c) : remains) = listToMaybe $ sort $ catMaybes [f get probs (maxprob <|> Just (i, p)) remains, f (get + i * p + c) (probs + p) maxprob remains]

main = do
    [d, g] <- map read . words <$> getLine
    ps <- sortBy (flip compare) . zipWith (\i [p, c] -> (100 * i, p, c)) [1..] <$> replicateM d (map read . words <$> getLine) :: IO [(Int, Int, Int)]
    print $ fromJust $ calc g ps

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

using namespace std;
int main(){
    int N,M,S;cin >> N >> M;S = 0;
    std::vector<int> A(M);
    for (int i=0;i<M;i++) cin >> A[i];
    for (int i=0;i<M;i++) S= S+A[i];
    if(S<=N){
        cout << N-S << endl;
    }else{
        cout << "-1" << endl;
    }
}





Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int H, W;
vv<int> C, A;

int main() {
    cin >> H >> W;
    C = vvec(10, 10, 0);
    A = vvec(H, W, 0);
    rep(i, 10) rep(j, 10) cin >> C[i][j];
    rep(i, H) rep(j, W) cin >> A[i][j];

    for (int k = 0; k < 10; k++)
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++)
                C[i][j] = min(C[i][j], C[i][k] + C[k][j]);

    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            if (A[i][j] != -1) {
                ans += C[A[i][j]][1];
            }
        }
    }
    write(ans);
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    bool f = true;
    while (f && k) {
        k--;
        f = false;
        vector<int> cnt(n+1,0);
        for (int i = 0;i < n;++i) {
            // for (int j = i;j < min(n,i+a[i]+1);++j) cnt[j]++;
            // for (int j = i-1;j >= max(0,i-a[i]);--j) cnt[j]++;
            cnt[max(0,i-a[i])]++;
            cnt[min(n,i+a[i]+1)]--;
        }
        for (int i = 0;i < n;++i) cnt[i+1] += cnt[i];
        for (int i = 0;i < n;++i) a[i] = cnt[i];
        for (int i = 0;i < n;++i) if (a[i] < n) f = true;
    }
    for (int i = 0;i < n;++i) cout << a[i] <<  " \n"[i == n-1];
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n,ma,mb;
int a[45],b[45],c[45];
int dp[45][450][450];

int main(){
	cin>>n>>ma>>mb;
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];
		
	for(int i=0;i<45;i++){
		for(int j=0;j<450;j++){
			for(int k=0;k<450;k++){
				dp[i][j][k]=1000000;
			}
		}
	}
	
	dp[0][0][0]=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<450;j++){
			for(int k=0;k<450;k++){
				if(dp[i][j][k]==1000000)continue;
				dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
				dp[i+1][j+a[i]][k+b[i]]=min(dp[i][j][k]+c[i],dp[i][j+a[i]][k+b[i]]);
			}
		}
	}
	int ans=1000000;
	for(int i=1;i*ma<450&&i*mb<450;i++){
		ans=min(ans,dp[n][i*ma][i*mb]);
		//cout<<dp[n][i*ma][i*mb]<<endl;
	}
	if(ans==1000000)
		ans=-1;
	cout<<ans<<endl;
	return 0;
}
	

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main()
{

    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> x(n), v(n);

    rep(i, 0, n)
    {
        cin >> x[i];
    }
    sort(all(x));
    int ans = 0;
    reps(mid, n - 1, -1)
    {
        reps(low, mid - 1, -1)
        {
            auto itr = lower_bound(all(x), x[mid] + x[low]);
            int sa = distance(itr, x.end()); //social distance
            ans += (n - 1 - mid) - sa;
        }
    }

    cout << ans << '\n';
    return 0;
}

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

#define n_fish first
#define number second

using namespace std;

typedef pair<int, int> PAIR;

struct CompEntrants{
  bool operator()(const PAIR &entrant1, const PAIR &entrant2) const
  {
    if(entrant1.n_fish == entrant2.n_fish)
      return entrant1.number < entrant2.number;
    return entrant1.n_fish > entrant2.n_fish;
  }
};

int main()
{
  int n_entrants;
  vector<PAIR> entrants;
  PAIR entrant;

  cin >> n_entrants;
  for(int i = 0; i < n_entrants; ++i){
    cin >> entrant.number >> entrant.n_fish;
    entrants.push_back(entrant);
  }
  sort(entrants.begin(), entrants.end(), CompEntrants());

  cout << entrants.front().number << " " << entrants.front().n_fish << endl;

  return 0;
}

Measured memory_bytes: 1204
s=list(input())
n = len(s)

c=0
k=0
while c==0:
    if k ==n:
        c = 1
    else:
        
        if k + 7 <= n-1 and s[k]=='d' and s[k+1] == 'r' and s[k+2] == 'e' and s[k+3] == 'a' and s[k+4] == 'm' and s[k+5] == 'e' and s[k+6] == 'r' and s[k+7] == 'a':
            k += 5
        elif k + 6 <= n-1 and s[k]=='d' and s[k+1] == 'r' and s[k+2] == 'e' and s[k+3] == 'a' and s[k+4] == 'm' and s[k+5] == 'e' and s[k+6] == 'r':
            k += 7
        elif k + 4 <= n-1 and s[k]=='d' and s[k+1] == 'r' and s[k+2] == 'e' and s[k+3] == 'a' and s[k+4] == 'm':
            k += 5
        elif k+6 <= n-1 and s[k] == 'e' and s[k+1] == 'r' and s[k+2] == 'a' and s[k+3] == 's' and s[k+4] == 'e' and  s[k+5] == 'r' and s[k+6] == 'a':
            k+= 5
        elif k+5 <= n-1 and s[k] == 'e' and s[k+1] == 'r' and s[k+2] == 'a' and s[k+3] == 's' and s[k+4] == 'e' and  s[k+5] == 'r':
            k += 6
        elif k+4 <= n-1 and s[k] == 'e' and s[k+1] == 'r' and s[k+2] == 'a' and s[k+3] == 's' and s[k+4] == 'e':
            k += 5
        else:
            c = 1

if k == n:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 4212
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        
        if(n%k==0){
            System.out.print("0");
        }else{
            System.out.print("1");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main()
{
	int N, A, B, C, D;
	string S;
	cin >> N>> A >> B >> C >> D;
	cin >> S;

	int flag = 0;	//到達可能フラグ


	for (int i = A; i < (C-1); i++)	//2連続で岩があったらflagを１に
	{
		if (S[i] == '#' && S[i + 1] == '#')	flag = 1;
	}

	for (int i = B; i < (D - 1); i++)	//ふぬけ君についても見る
	{
		if (S[i] == '#' && S[i + 1] == '#')	flag = 1;
	}

	int flag2 = 0;	//追い越せるか？

	if (D < C)	//Aによる追い越しが発生するとき
	{
		flag2 = 1;
		for (int i = (B - 2); i <= (D - 2); i++)
		{
			if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.')
			{
				flag2 = 0;	//３連続空きがあれば追い越せる
			}
		}
	}

	if (flag == 0 && flag2 == 0)
	{
		cout << "Yes";
	}
	if (flag == 1 || flag2 == 1)
	{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int N, M, i;
    double A[200];
    double sum = 0;
    int count = 0;

    cin >> N >> M;
  
    for(i = 0; i < N ; i++){
        cin >> A[i];
        sum += A[i];
    }
    
    for(i = 0; i < N; i++){
        if (A[i] >= (sum /(4 * M))){
        count += 1;
        }else{
          count += 0;
        }
    }

    if(count >= M){
        cout <<"Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  int n;
  cin >> n;
  int m = n%10;
  if(m==2 || m==4 || m==5 || m==7 || m==9) cout << "hon" << endl;
  else if(m==3) cout << "bon" << endl;
  else cout << "pon" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define db(x){if(cond)cerr<<__LINE__<<" "<<#x<<" " <<x<<endl;}
#define rep(i,b)for(auto i=(0);i<(b);++i)
#define fo(i,a,b)for(auto i=(a);i<=(b);++i)
#define ford(i,a,b)for(auto i=(a);i>=(b);--i)
#define all(x) (x).begin(),(x).end()
#define vv vector
#define pb push_back
template<typename X>void MA(X&a,X b){a=max(a,b);}template<typename X>void MI(X&a,X b){a=min(a,b);}
template<typename X>void clr(X&x,int a){memset(x,a,sizeof(a));};typedef long long ll;typedef long double ld;
typedef array<int,2>i2;typedef vv<int>vi;int cond=0,multi=0,gcj=0;

struct solver_t;solver_t *solver;
struct solver_t{

  bool prime(int x){
    for(int y=2;y*y<=x;y++)if(x%y==0)return 0;

    return x>=2;
  }

  void solve(){
    int Q;cin>>Q;
    vi allP;
    fo(i,1,(int)1e5+11){
      if(prime(i)&&prime((i+1)/2))allP.pb(i);
    }
    rep(i,Q){
      int a,b;cin>>a>>b;
      int p1=lower_bound(all(allP),b+1) - lower_bound(all(allP),a);
      cout<<p1<<"\n";

    }
  }
};

void gen(){}
void brute(){}
int main(int argc,char** argv){
  fo(i,1,argc-1)if(argv[i]==string("q"))cond=1<<30;
  fo(i,1,argc-1)if(argv[i]==string("gen")){gen();exit(0);}
  fo(i,1,argc-1)if(argv[i]==string("brute")){brute();exit(0);}
  ios::sync_with_stdio(false),cin.tie(0);
  cout.setf(ios::fixed),cout.precision(10);int t;if(multi||gcj)cin>>t;else t=1;
  fo(i,1,t){if(cond)cerr<<__LINE__<<" "<<i<<endl;if(gcj)cout<<"Case #"<<i<<": ";
    solver = new solver_t();
    solver->solve();
  }return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"


int main(){
    int n;
    cin >> n;
    ll ans = 0;
    int min1 = INF,max1 = -INF;
    REP(i,n){
        int t;
        cin >> t;
        if(min1>t)min1 = t;
        if(max1<t)max1 = t;
        ans += t;
    }
    printf("%d %d %ld\n",min1,max1,ans);
    return 0;
}


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

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

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> p(n),c(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    rep(i,n){
        cin>>c[i];
    }
    ll ans=-inf;
    rep(st,n){
        ll roop=0,num=0;
        for(ll v=p[st];;v=p[v]){
            roop+=c[v];
            num++;
            if(v==st) break;
        }
        ll cost=0,ret=k;
        if(roop>0){
            if(ret>=num){
                cost=roop*(ret/num-1);
                ret%=num;
                ret+=num;
            }
        }else{
            ret=num+1;
        }
        ll v=st;
        while(ret--){
            cost+=c[p[v]];
            v=p[v];
            chmax(ans,cost);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3728
#include <stdio.h>
#define Max 100
#define Maxi 2147483647
#define W  0
#define X  1
#define Z  2

int n,m[Max][Max];
int prim(){
  int i,u,minv;
  int d[Max],p[Max],c[Max];

  for(i=0;i<n;i++){
    d[i] = Maxi;
    p[i] = -1;
    c[i] = W;
  }

  d[0] = 0;
  while(1){
    minv = Maxi;
    u = -1;
    for(i = 0;i < n; i++){
      if(minv > d[i] && c[i] != Z){
        u = i;
        minv = d[i];
      }
    }
    if( u == -1) break;
    c[u] = Z;
    for(i = 0;i<n;i++){
      if(c[i]!= Z && m[u][i]!= Maxi){
        if(d[i] > m[u][i]){
          d[i] = m[u][i];
          p[i] = u;
          c[i] = X;
        }
      }
    }
  }
  int sum = 0;
  for(i = 0; i < n; i++){
    if(p[i]!= -1){
      sum += m[i][p[i]];
    }
  }
  return sum;
}

int main(){

  scanf("%d",&n);
  int i,j,e;
  for(i = 0;i<n;i++){
    for(j = 0;j<n;j++){
      scanf("%d",&e);
      if(e == -1){
        m[i][j] = Maxi;
      }
      else m[i][j] = e;
    }
  }
  printf("%d\n", prim());
  return 0;

}

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int main() {
	int n;
	int a[112345];
	cin >> n;
	REP(i, n) scanf("%d", a + i);
	
	int c2 = 0, c4 = 0, ot = 0;
	REP(i, n) {
		if (a[i] % 4 == 0) c4++;
		else if (a[i] % 2 == 0) c2++;
		else ot++;
	}
	
	if (c4 >= ot || (c2 == 0 && c4 + 1 >= ot)) puts("Yes");
	else puts("No");
	
	return 0;
}

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

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

    int res = 0;
    rep(i, N) res += a[i];
    res -= N;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long m[2][2019] = {};
	int cur = 0, nxt;
	long long ans = 0;
	char c;
	int dig;
	while (cin >> c) {
		if (c == 'i')break;
		dig = c - '0';
		nxt = cur ^ 1;
		for (int i = 0; i < 2019; i++) {
			m[nxt][i] = 0;
		}
		m[cur][0] += 1;
		for (int i = 0; i < 2019; i++) {
			m[nxt][(i*10+dig)%2019] += m[cur][i];
		}
		cur = nxt;
		ans += m[cur][0];
	}
	cout << ans;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int tap = 1;
	    int ans = 0;
	    while(tap < B){
	    	tap--;
	    	tap += A;
	    	ans++;
	    }
	    System.out.println(ans);

		stdIn.close();
	}
}


Measured memory_bytes: 35648
#include<iostream>
#include<queue>
using namespace std;
struct node
{
	long long v,nxt,data;
	bool can;
};
node edge[1000001];
bool cn;
long long fa[1000001],FA[1000001],x,y,n,m,head[1000001],len,depth[1000001],d[1000001],D[1000001],RD[1000001],minnD[1000001];
void add(int x,int y,int z)
{
	edge[++len].v=y;
	edge[len].data=z;
	edge[len].nxt=head[x];
	head[x]=len;
	return;
}
void bfs(int x)
{
	int top;
	depth[x]=1;
	queue<int>q;
	q.push(x);
	while (!q.empty())
	{
		top=q.front();
		q.pop();
		for (int i=head[top];i>0;i=edge[i].nxt)
			if (!depth[edge[i].v]&&edge[i].can)
			{
				depth[edge[i].v]=depth[top]+1;
				FA[i]=top;
				fa[edge[i].v]=i;
				q.push(edge[i].v);
			}
	}
	return;
}
int main()
{
	len=1;
	cin>>n>>m;
	for (int i=1;i<=n;++i)
		cin>>D[i];
	for (int i=1;i<=m;++i)
	{
		cin>>x>>y;
		add(x,y,i);
		add(y,x,i);
	}
	for (int i=1;i<=n;++i)
	{
		minnD[i]=1e9;
		for (int j=head[i];j>0;j=edge[j].nxt)
			minnD[i]=min(minnD[i],D[edge[j].v]);
		cn=0;
		for (int j=head[i];j>0;j=edge[j].nxt)
			{
				if (cn==0&&minnD[i]==D[edge[j].v])
				{
					cn=1;
					edge[j].can=1;
					edge[j^1].can=1;
				}
			}
	}
	for (int i=1;i<=n;++i)
		if (!depth[i]) 
			bfs(i); 
	for (int i=1;i<=n;++i)
	{
		RD[i]=1e9;
		if (D[i]<D[FA[fa[i]]])
			d[edge[fa[i]].data]=D[FA[fa[i]]];
		else
			d[edge[fa[i]].data]=D[i];
	}
	for (int i=1;i<=n;++i)
		for (int j=head[i];j>0;j=edge[j].nxt)
			if (d[edge[j].data]!=0)
				RD[i]=min(RD[i],d[edge[j].data]);
	for (int i=1;i<=n;++i)
		if (RD[i]!=D[i])
		{
			cout<<-1<<endl;
			return 0;
		}
	for (int i=1;i<=n;++i)
		{
			if (depth[i]%2==0)
				cout<<'B';
			else
				cout<<'W'; 
		}
	cout<<endl;
	for (int i=1;i<=m;++i)
		{
			if (d[i]==0)
				cout<<1000000000<<endl;
			else
				cout<<d[i]<<endl;
		}
	return 0; 
}

Measured memory_bytes: 44160
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w =sc.nextInt();
		char[][] map=new char[h+2][w+2];
		for(int i=1; i<=h; i++){
			String s=sc.next();
			for(int j=1; j<=w; j++){
				map[i][j]=s.charAt(j-1);
			}
		}
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				if(map[i][j]=='#'){
					if(map[i-1][j]!='#' && map[i+1][j]!='#' && map[i][j-1]!='#' && map[i][j+1]!='#'){
						System.out.println("No");
						return;
					}
				}
			}
		}
		System.out.println("Yes");
	}
}



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

int main(){
    int64_t N, A, B, i, j, beat = 0;

    cin >> N;
    vector<int> city(N+1);
    vector<int> hero(N);
    for(i = 0; i < N+1; i++){
        cin >> A;
        city[i] = A;
    }
    for(i = 0; i < N; i++){
        cin >> B;
        hero[i] = B;
    }
    for(i = 0; i < N; i++){
        if(city[i] > hero[i]){
            beat += hero[i];
            hero[i] = 0;
        }else{
            beat += city[i];
            hero[i] -= city[i];
        }
        if(city[i+1] > hero[i]){
            beat += hero[i];
            city[i+1] -= hero[i];
        }else{
            beat += city[i+1];
            city[i+1] = 0;
        }
    }
    cout << beat << endl;
}

Measured memory_bytes: 1024
<?php  
$loop = trim(fgets(STDIN)); 
$nums_input = trim(fgets(STDIN));

$nums = explode(" ", $nums_input);
$result = 1;
$max_num = 1000000000000000000;

for ($i = 0;$i < $loop;$i++) {
  if ($nums[$i] == 0) {
    $result = 0;
    break;
  }
}

if ($result !== 0) {
  for ($i = 0;$i < $loop;$i++) {
    $result = $result * $nums[$i];
    if ($result > $max_num) {
      $result = -1;
      break;
    }
  }
}

print $result;





Measured memory_bytes: 25464
#%%
s = input()
l = ['KIHBR', 'AKIHBR', 'KIHABR', 'KIHBAR', 'KIHBRA', 'AKIHABR', 'AKIHBAR', 'AKIHBRA', 'KIHABAR', 'KIHABRA', 'KIHBARA', 'AKIHABAR', 'AKIHBARA', 'KIHABARA', 'AKIHABARA']
if s in l:
    print('YES')
else:
    print('NO')

#%%


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int A[210][210];
int d[10][10];
int main()
{
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> d[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A[i][j] != -1)ans += d[A[i][j]][1];
		}
	}
	cout << ans << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s; cin >> s;
    int q; cin >> q;
    bool st = false;
    vector<char> vec[2];
    while(q--) {
        int t; cin >> t;
        if(t == 1) {
            st =! st;
        } else {
            int f; cin >> f;
            char c; cin >> c;
            --f;
            vec[f^st].push_back(c);
        }
    }
    string ans;
    for(int i=vec[0].size()-1; ~i; --i) ans += vec[0][i];
    ans += s;
    for(char c : vec[1]) ans += c;
    if(st) reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}

Measured memory_bytes: 1448
def main():
    while True:
        n,m = map(int,input().split())
        if not n and not m:
            return
        aa = list(map(int,input().split()))
        ans = 0
        for i in range(n):
            for j in range(n):
                if i == j:
                    continue
                tmp = aa[i] + aa[j]
                if tmp <= m:
                    ans = max(ans, tmp)
        if ans == 0:
            print("NONE")
        else:
            print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 5632
function Main(input){
    /** 入力値の作成 */
    const arr = input.trim().split('\n');
    const N = Number(arr.shift());
    let Ai = arr.shift().split(' ').map(Number);
    const Q = Number(arr.shift());
    let BiCi = [];
    for(let i=0; i<arr.length; i++){
        BiCi.push(arr[i].trim().split(' ').map(Number));
    }
    /** ここから本処理 */
    let box = new Array(100001).fill(0);
    for(let i=0; i<Ai.length; i++){
        box[Ai[i]]++;
    }
    let sum = Ai.reduce((a,b) => a+b);
    for(let i=0; i<BiCi.length; i++){
        sum +=  (BiCi[i][1] - BiCi[i][0]) * box[BiCi[i][0]];
        box[BiCi[i][1]] += box[BiCi[i][0]];
        box[BiCi[i][0]] = 0;
        console.log(sum);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 86092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 21;
int n;
bool a[N][N];
ll DP[1<<N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n)FOR(j, 0, n) cin >> a[i][j];
  DP[0] = 1;
  FOR(i, 1, bit(n)){
    int c = pcnt(i)-1;
    FOR(j, 0, n) if((i&bit(j)) && a[j][c]) DP[i] += DP[i^bit(j)];
    DP[i] %= MOD;
  }
  cout << DP[bit(n)-1] << endl;
}

Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
typedef long long ll;
typedef long double ld;
using namespace std;

ll d[5010], sum[5010];

int main() {
	int k, q;
	cin >> k >> q;
	for(int i=0; i<k; ++i) cin >> d[i];
	for(int i=0; i<q; ++i){
		ll n, x, m;
		cin >> n >> x >> m;
		sum[0]=0;
		for(int j=0; j<k; ++j){
			sum[j+1]=sum[j]+(d[j]%m==0 ? m : d[j]%m);
		}
		ll oval=x+sum[k]*((n-1)/k)+sum[(n-1)%k];
		cout << n-1-(oval/m-x/m) << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int n,k,cnt=0;
    cin >> n >> k;
    /*for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
            if ((i+j)%k==0)
    {
        for (int ii=1;ii<=n;ii++)
        {
            if ((i+ii)%k==0&&(j+ii)%k==0)
            {
                cout << "("<<i<<","<<j<<","<<ii<<")"<<endl;
                cnt++;
            }
        }
    }
    cout << cnt<<endl;*/
    int t=(n/k),t2=(n+k/2)/k;
    if (k&1)
    {
        cout << 1LL*t*t*t<<endl;
    }else
    {
        cout << 1LL*t*t*t+1LL*t2*t2*t2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
vector<int> E[200001];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;



int main() {
    int N; cin >> N;
    set<int> retu;
    bool ok = true;
    int count = 0;
    int ans = 0;
    while (ok) {
        retu.insert(N);
        count++;
        if (retu.size() != count) {
            cout << count << endl;
            return 0;
        }
        if (N % 2 == 0) N /= 2;
        else N = N * 3 + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)

    val n, a, b = sc.nextInt()
    val MOD = 1000000007L

    // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#4-%E7%B4%AF%E4%B9%97-an
    def modpow(a: Long, n: Long, mod: Long): Long = {
      var res = 1L
      var aTmp = a
      var nTmp = n
      while (nTmp > 0) {
        if (nTmp % 2 != 0) {
          res = res * aTmp % mod
        }
        aTmp = aTmp * aTmp % mod
        nTmp = nTmp / 2
      }

      res
    }

    def modcomb(n: Long, a: Int, mod: Long): Long = {
      var x = 1L
      var y = 1L
      for (i <- 0 until a) {
        x = x * (n - i)
        x %= mod
        y = y * (i + 1)
        y %= mod
      }
      x * modpow(y, mod - 2, mod) % mod
    }


    val total = modpow(2L, n.toLong, MOD) - 1
    val combA = modcomb(n, a, MOD)
    val combB = modcomb(n, b, MOD)
    val ans = (total - combA - combB) % MOD

    if(ans >= 0) println(ans)
    else println(ans + MOD)

  }

}


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

int h, w, k, m = 0, t;
char c[7][7];

int main()
{
	cin >> h >> w >> k;

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> c[i][j];

	for (int u = 0; u < (1 << (h + w)); u++) {
		t = 0;
		for (int i = 0; i < h; i++) {
			if (u & (1 << i)) {
				for (int j = 0; j < w; j++) {
					if (u & (1 << (h + j))) {
						if (c[i][j] == '#')
							t++;
					}
				}
			}
		}

		if (t == k)
			m++;
	}

	cout << m << endl;
}


Measured memory_bytes: 3604
import sys
H, W, M = map(int, sys.stdin.readline().split())
hlst = {}
wlst = {}
hwlst = []

for i in range(M):
    h, w = sys.stdin.readline().split()
    if h in hlst:
        hlst[h] += 1
    else:
        hlst[h] = 1

    if w in wlst:
        wlst[w] += 1
    else:
        wlst[w] = 1

    hwlst.append([h, w])

h = max(hlst.values())
w = max(wlst.values())
hmax = [i for i in hlst if hlst[i] == h]
wmax = [i for i in wlst if wlst[i] == w]
num = len(hmax)*len(wmax)
ans = h + w -1


for i in hwlst:
    if hlst[i[0]] == h and wlst[i[1]] == w:
        num -= 1

if num == 0:
    print(h+w-1)
else:
    print(h+w)

Measured memory_bytes: 98384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
vector<pair<ll,ll> > p;
int main(){
  long double a, b, c;
  cin >> a >> b >> c;
  ll aa = sqrt(a);
  ll bb = sqrt(b);
  ll cc = sqrt(c);
  long double ax = sqrtl(a);
  long double bx = sqrtl(b);
  long double cx = sqrtl(c);
  if(cc != cx) cc+=2;
  if(a+b+2*sqrtl(a*b)<c){
    cout <<"Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = DateTime.Parse(Console.ReadLine());
            DateTime crit = new DateTime(2019,4,30);

            if(S <= crit)
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }

        }
    }

}


Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 102;

int n;
int a[N];

void solv()
{
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
        if (i % 2 == 1 && a[i] % 2 == 1)
            ++ans;
    }
    printf("%d\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 3828
package main

import "fmt"

func main() {
	var s string
	ans := make([]int, 0)
	for {
		var v int
		fmt.Scan(&s)
		if s == "0" {
			break
		}
		for i := 0; i < len(s); i++ {
			v += int(s[i] - '0')
		}
		ans = append(ans, v)
	}
	for i := range ans {
		fmt.Println(ans[i])
	}
}



Measured memory_bytes: 1124
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 1e14;
const int INF2 = 1e9;

int main() {
  int N, M, L;
  cin >> N >> M >> L;

  vector<vector<ll>> dp(N, vector<ll>(N, INF));
  rep(i, M) {
    int A, B, C;
    cin >> A >> B >> C;
    A--; B--;

    dp.at(A).at(B) = C;
    dp.at(B).at(A) = C;
  }
  rep(i, N) dp.at(i).at(i) = 0;

  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        dp.at(i).at(j) = min(dp.at(i).at(j), dp.at(i).at(k) + dp.at(k).at(j));
      }
    }
  }

  vector<vector<int>> fuel(N, vector<int>(N, INF2));
  rep(i, N) {
    rep(j, N) {
      if (dp.at(i).at(j) <= L) fuel.at(i).at(j) = 1;;
    }
  }
  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        fuel.at(i).at(j) = min(fuel.at(i).at(j), fuel.at(i).at(k) + fuel.at(k).at(j));
      }
    }
  }

  int Q;
  cin >> Q;

  rep(i, Q) {
    int s, t;
    cin >> s >> t;
    s--; t--;

    if (fuel.at(s).at(t) == INF2) {
      cout << -1 << endl;
    } else {
      cout << fuel.at(s).at(t) - 1 << endl; // 最初の補給は除く
    }
  }

  return 0;
}

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

typedef pair<int, int> pii;

bool isok(vector<int>& v) {
    for(int i = 1; i < v.size(); i++) {
        if(v[i] <= v[i-1]) return false;
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vector<pii> a, ans;
    for(int i = 0; i < N; i++) {
        int aa;
        cin >> aa;
        a.push_back(pii(aa, i+1));
    }   

    sort(a.begin(), a.end());
    if(a[0].first < 0) {
        pii p = abs(a[0].first) > abs(a[N-1].first) ? a[0] : a[N-1];
        for(int i = 0; i < N; i++) {
            ans.push_back(pii(p.second, i+1));
            a[i].first += p.first;
        }
    }

    if(a[N-1].first > 0) {
        for(int i = 1; i < N; i++) {
            ans.push_back(pii(i, i+1));
        }
    } else {
        for(int i = N - 1; i > 0; i--) {
            ans.push_back(pii(i+1, i));
        }        
    }

    cout << ans.size() << endl;
    for(auto e: ans) cout << e.first << " " << e.second << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
      
    static char[] k = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
      
  
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String p = sc.next();
          
        boolean ans = false;
          
        IN:for(int i = 0; i < s.length(); i++) {
            for(int j = 0; j < p.length(); j++) {
                if(s.charAt((i + j) % s.length()) != p.charAt(j)) {
                    continue IN;
                }
            }
            ans = true;
            break;
        }
          
        System.out.println((ans)?"Yes":"No");
          
        sc.close();
    }
}



Measured memory_bytes: 26200
n=int(input())
sen = n // 1000
hyaku = (n - sen * 1000) // 100
juu = (n - sen * 1000 -  hyaku * 100) // 10
iti = n - sen * 1000 -  hyaku * 100 - juu * 10

if sen == hyaku or hyaku == juu or juu == iti:
    print('Bad')
else:
    print('Good')

Measured memory_bytes: 38256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

ll  a[100005];

int main(int argc, char* argv[])
{
    char str[5]={0};
    scanf("%s", str); 

    long a[2]={-1,1};

    long i,j,k;
    for(i=0; i<2; i++) {
        for(j=0; j<2; j++) {
            for(k=0; k<2; k++) {
                long val =(long)(str[0]-'0')+(long)(str[1]-'0')*a[i]+(long)(str[2]-'0')*a[j]+(long)(str[3]-'0')*a[k];
                if(val==7){
                    printf("%c", str[0]);
                    if(i==0) printf("-"); else printf("+");
                    printf("%c", str[1]);
                    if(j==0) printf("-"); else printf("+");
                    printf("%c", str[2]);
                    if(k==0) printf("-"); else printf("+");
                    printf("%c=7\n", str[3]);
                    return 0;
                }
            }
        }
    }
      
 
    return 0;
}


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

int cnt, k;
P E[2][100];
int dfs(string&s, int&i) {
	int l = -1, r = -1;
	int a = cnt++;
	i++; if (s[i] == '(')l = dfs(s, i), i++;
	i++; if (s[i] == '(')r = dfs(s, i), i++;
	E[k][a].first = l; E[k][a].second = r;
	return a;
}
string calc1(int u, int v) {
	string l, r;
	if ((u != -1 && E[0][u].first != -1) || (v != -1 && E[1][v].first != -1))
		l = calc1(u == -1 ? -1 : E[0][u].first, v == -1 ? -1 : E[1][v].first);
	if ((u != -1 && E[0][u].second != -1) || (v != -1 && E[1][v].second != -1))
		r = calc1(u == -1 ? -1 : E[0][u].second, v == -1 ? -1 : E[1][v].second);
	return "(" + l + "," + r + ")";
}
string calc2(int u, int v) {
	string l, r;
	if (E[0][u].first != -1 && E[1][v].first != -1)l = calc2(E[0][u].first, E[1][v].first);
	if (E[0][u].second != -1 && E[1][v].second != -1)r = calc2(E[0][u].second, E[1][v].second);
	return "(" + l + "," + r + ")";
}
int main() {
	string a, b, c;
	while (cin >> a >> b >> c) {
		int i = cnt = k = 0; dfs(b, i);
		i = cnt = 0; k = 1; dfs(c, i);
		if (a == "u")cout << calc1(0, 0) << endl;
		else cout << calc2(0, 0) << endl;
	}
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  vector<ll> h(n);
  rep(i,n) cin>>h[i];
  ll ans=0;
  ll cnt=0;
  rep(i,n-1){
    if(h[i]>=h[i+1]) cnt++;
    else{
      ans=max(ans,cnt);
      cnt=0;
    }
    if(i==n-2) ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		string S = GetString();
		int N = S.Length;
		for(int i = 0; i < N; i++)
		{
			for(int j = i; j < N; j++)
			{
				string T = S.Substring(0, i + 1) + S.Substring(j, N - j);
				if(T.Equals("keyence"))
				{
					Console.WriteLine("YES");
					return;
				}
			}
		}
		Console.WriteLine("NO");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;


int main() {
	int T;
	cin >> T;
	for (int test = 0; test < T; test++) {
		int N;
		cin >> N;
		vector<LL>A(N);
		string S;
		for (int i = 0; i < N; i++) {
			cin >> A[i];
		}
		cin >> S;
		set<LL, greater<LL>>K;
		LL ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			if (S[i] == '0') {
				if (K.count(A[i])) {

				}
				else {
					K.insert(A[i]);
					set<LL, greater<LL>>::iterator itr = K.begin();
					while (next(itr) != K.end()) {
						auto ntr = next(itr);
						LL tmp = 1LL << 61;
						while ((tmp & *itr) == 0) {
							if (tmp == 1) {
								tmp = 0;
								break;
							}
							tmp >>= 1;
						}
						if (*ntr & tmp) {
							LL iv = *itr;
							LL nv = *ntr;
							K.erase(nv);
							K.insert(nv ^ iv);
							itr = K.lower_bound(iv);
							ntr = next(itr);
						}
						else {
							itr = ntr;
							ntr = next(ntr);
						}
					}
					if (K.count(0))K.erase(0);
				}

			}
			else {
				LL kas = A[i];
				LL tmp = 1LL << 61;
				for (auto elm : K) {
					while ((tmp & elm) == 0) {
						tmp >>= 1;
						if (tmp == 0)break;
					}
					if (kas & tmp) {
						kas ^= elm;
					}
				}
				if (kas) {
					ans = max(ans, 1LL);
					break;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int bubbleSort(int (&A)[100],int N){
	int j, tmp, cnt = 0, flag = 1;
	while(flag){
		flag = 0;
		for(j=N-1;j>=1;j--){
			if(A[j] < A[j-1]){
				tmp = A[j];
				A[j] = A[j-1];
				A[j-1] =tmp;
				cnt++;
				flag = 1;
			}
		}
	}
	return cnt;
}

int main(){
	int n, cnt, a[100], i;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	cnt = bubbleSort(a, n);
	cout << a[0];
	for(i=1;i<n;i++){
		cout << " " << a[i];
	}
	cout << endl << cnt << endl;
	return 0;
}

Measured memory_bytes: 1164