akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, t, a, ans;
    cin >> n >> t >> a;
    double d = Inf;
    rep(i, n) {
      int h;
      cin >> h;
      double temp = t - h * 0.006;
      if (abs(temp - a) < d) {
        ans = i + 1;
        d = abs(temp - a);
      }
    }

    cout << ans << '\n';

    return 0;
}


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

try:
    idx = a.index(0)
    print(0)

except ValueError:

    ans = a[0]
    for i in range(1, len(a)):
        ans *= a[i]
        if ans > 10**18:
            print('-1')
            exit()

    print(ans)

Measured memory_bytes: 87896
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int a, b;
  cin >> a >> b;
  if(a <= 9 && b <= 9) cout << a * b << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define re return
#define ull unsigned long long
#define ll long long
#define ld long double
#define mid (l+r+1)/2
#define f first
#define s second
#define oo 1e9
#define pi acos(-1)
#define OO 1e18
#define EPS 1e-11
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define Hossam_Yehia ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int n,h,w,arr[100005],out[105][105],idx(1);
int main(){
    Hossam_Yehia;
    cin >> h >> w;
    cin >> n;
    for(int i=1;i<=n;++i)
        cin >> arr[i];
    int a=0,b=w-1,c=1,d=h-2;
    // a=0,b=1,c=1,d=0;
    while(idx<=n){
        for(int i=a;i<=b;++i){
            //cout<<a<<" "<<i<<endl;
            while(!arr[idx])++idx;
            if(idx>n)break;
            out[a][i]=idx;--arr[idx];
        }
        //cout<<"---------------------\n";
        for(int i=c;i<=d;++i){
            //cout<<i<<" "<<b<<endl;
            while(!arr[idx])++idx;
            if(idx>n)break;
            out[i][b]=idx;--arr[idx];
        }
        //cout<<"---------------------\n";
        for(int i=b;i>=a;--i){
            //cout<<d+1<<" "<<i<<endl;
            while(!arr[idx])++idx;
            if(idx>n)break;
            out[d+1][i]=idx;--arr[idx];
        }
        //cout<<"---------------------\n";
        for(int i=d;i>=c;--i){
            //cout<<i<<" "<<a<<endl;
            while(!arr[idx])++idx;
            if(idx>n)break;
            out[i][a]=idx;--arr[idx];
        }
        //cout<<"---------------------\n";
        //cout<<idx<<endl;
        if(!arr[idx])++idx;
        ++a,--b,++c,--d;
    }
    //cout<<Y<<endl;
    for(int i=0;i<h;++i,cout<<endl)
        for(int j=0;j<w;++j)
            cout<<out[i][j]<<" ";
    re 0;
}

Measured memory_bytes: 384
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  ull a,b,x;
  cin >> a >> b >> x;
  if(a%x !=0){
   cout <<  (b / x + 1) - (a / x + 1) << endl;
  }
  else{
   cout << (b / x + 1 ) - (a / x + 1 ) + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 205;
const int mod = 1e9 + 7;
#define sz(v) ((int)v.size())

lint dp[62][62][2];
lint L;

lint min_ret(int pos, int rem, int mtchd){
	if(pos == 0) return 0;
	if(~dp[pos][rem][mtchd]) return dp[pos][rem][mtchd];
	lint ret = 2e18;
	for(int i=0; i<2; i++){
		if(rem < i) continue;
		if(mtchd && i == 0 && (L >> (pos - 1)) % 2 == 1) continue;
		lint val = min_ret(pos - 1, rem - i, (mtchd && (i == (L >> (pos - 1)) % 2)));
		if(i) val += (1ll << (pos - 1));
		ret = min(ret, val);
	}
	return dp[pos][rem][mtchd] = ret;
}

int min_popcnt(lint l, lint r){ // at most 12000 query
	memset(dp, -1, sizeof(dp));
	L = l;
	for(int i=0; i<60; i++){
		if(min_ret(60, i, 1) <= r) return i;
	}
	return 60;
}

int n;
lint k, a[MAXN];
vector<pair<vector<lint>, lint> > cands;

bool vect_comp(vector<lint> a, vector<lint> b){
	for(int i=1; i<sz(a); i++){
		if(b[i] - b[0] != a[i] - a[0]){
			return a[i] - a[0] < b[i] - b[0];
		}
	}
	return false;
}

int main(){
	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> a[i];
	lint minVal = *min_element(a, a + n);
	for(int i=0; i<=k && i <= 60; i++){
		vector<lint> v;
		for(int j=0; j<n; j++){
			lint modv = a[j] & ((1ll << i) - 1);
			v.push_back(modv);
		}
		v.push_back((1ll << i) - 1);
		sort(v.begin(), v.end());
		v.resize(unique(v.begin(), v.end()) - v.begin());
		lint prv = -1;
		for(int j=0; j<sz(v); j++){
			if(prv + 1 > minVal) break;
			lint range = k - i - min_popcnt(prv + 1, min(minVal, v[j]));
			if(range < 0){
				prv = v[j];
				continue;
			}
			vector<lint> starter;
			for(int k=0; k<n; k++){
				lint val = (a[k] - prv - 1) >> i;
				starter.push_back(val);
				range = min(range, val);
			}
			cands.emplace_back(starter, range);
			prv = v[j];
		}
	}
	sort(cands.begin(), cands.end(), 
	[&](const pair<vector<lint>, lint> &a, const pair<vector<lint>, lint> &b){
		return vect_comp(a.first, b.first);
	});
	lint ret = 0;
	for(int i=0; i<cands.size(); ){
		int e = i;
		while(e < cands.size() && !vect_comp(cands[i].first, cands[e].first)) e++;
		map<lint, int> mp;
		for(int j=i; j<e; j++){
			lint st = cands[j].first[0];
			lint ed = st - cands[j].second;
			mp[ed]++;
			mp[st+1]--;
		}
		lint prv = -1;
		int cnt = 0;
		for(auto &i : mp){
			if(cnt > 0){
				ret += i.first - prv;
				ret %= mod;
			}
			cnt += i.second;
			prv = i.first;
		}
		i = e;
	}
	cout << ret << endl;
}


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

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

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 = " ")
{ if (!v.size()) puts(""); 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; }

vector<lint> Fib{0, 1, 1};
lint fib(int k) {
  if (k < 0) return 0;
  if (k == 0) return 0;
  if (k < 3) return 1;
  if (Fib.size() <= k + 1) {
    Fib.push_back(fib(k - 1) + fib(k - 2) /* % mod */);
  }

  return Fib[k];
}

signed main() {
  cout << fib(in() + 1) << endl;
}

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

void put(int k, int N, string &S, vector<int> &a){
	if(a[k] >= 0){
		return;
	}
	if(k == 0){
		if(S[0] == '<'){
			a[k] = 0;
		}
		else{
			put(k + 1, N, S, a);
			a[k] = a[k + 1] + 1;
		}
	}
	else if(k == N - 1){
		if(S[N - 2] == '>'){
			a[k] = 0;
		}
		else{
			put(k - 1, N, S, a);
			a[k] = a[k - 1] + 1;
		}
	}
	else{
		int now = -1;
		if(S[k - 1] == '<'){
			put(k - 1, N, S, a);
			now = max(now, a[k - 1]);
		}
		if(S[k] == '>'){
			put(k + 1, N, S, a);
			now = max(now, a[k + 1]);
		}
		a[k] = now + 1;
	}
}

signed main(){
	int N, i;
	string S;
	cin >> S;
	N = S.size() + 1;
	vector<int> a(N, -1);
	for(i = 0; i < N; i++){
		put(i, N, S, a);
	}
	int ans = 0;
	for(i = 0; i < N; i++){
//		printf("a[%lld] = %lld\n", i, a[i]);
		ans += a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int N[4];
  bool flag[4];
  for(int i=0; i<4; i++){
    cin >> N[i];
    if(N[i]==1) flag[0]=true;
    if(N[i]==9) flag[1]=true;
    if(N[i]==7) flag[2]=true;
    if(N[i]==4) flag[3]=true;
  }
  for(int i=0; i<4; i++){
    if(!flag[i]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    long long int N, M, K, A, B, C;
    cin >> N >> M >> K;
    cin >> A >> B >> C;
    long long int T;
    cin >> T;
    vector<long long int> v;
    priority_queue<P> que;
    for(int i = 0; i < M; i++){
        long long int S;
        cin >> S;
        v.push_back(S);
    }
    long long int lim[3100];
    for(int i = 0; i < M - 1; i++){
        long long int t = (v[i] - 1) * B;
        if(t > T){
            lim[i] = v[i] - 1;
            continue;
        }
        long long int num = (T - t) / A;
        num = min(num, v[i + 1] - v[i] - 1);
        lim[i] = v[i] + num;
    }
    if((N - 1) * B <= T){
        lim[M - 1] = v[M - 1];
    }else{
        lim[M - 1] = v[M - 1] - 1;
    }
    long long int t, num;
    for(int loop = 0; loop < K - M; loop++){
        long long int max_num = 0, pos = -1;
        for(int i = 0; i < M - 1; i++){
            t = (v[i] - 1) * B + (lim[i] - v[i] + 1) * C;
            if(T - t < 0){
                continue;
            }
            num = (T - t) / A + 1;
            num = min(num, v[i + 1] - lim[i] - 1);
            if(max_num < num){
                max_num = num;
                pos = i;
            }
        }
        if(pos == -1){
            break;
        }
        t = (v[pos] - 1) * B + (lim[pos] - v[pos] + 1) * C;
        num = (T - t) / A + 1;
        num = min(num, v[pos + 1] - lim[pos] - 1);
        lim[pos] += num;
        
    }
    long long int ans = 0;
    for(int i = 0; i < M; i++){
        ans += lim[i] - v[i] + 1;
    }
    cout << ans - 1 << endl;

    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <iomanip>
#include <fstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
const int MAXN = 20;

int N;
ll arr[MAXN];
ll ans;
vector <int> v;

ll cval[MAXN];
bool use[MAXN];
int lloc[MAXN], rloc[MAXN];

void gogo (int m)
{
    int nleft = N - m;
    if (nleft == 2)
    {
        ans = min (ans, cval[0] + cval[N-1]);
        return;
    }
    int nlast = N - 1;
    if (m) nlast = v.back();

    int cloc = 0;
    for (int i = 1; i <= min (nlast, nleft - 2); i++)
    {
        cloc = rloc[cloc];
        v.push_back (i);
        int cleft = lloc[cloc], cright = rloc[cloc];
        use[cloc] = true;
        cval[cleft] += cval[cloc];
        cval[cright] += cval[cloc];
        rloc[cleft] = cright;
        lloc[cright] = cleft;
        gogo(m + 1);
        rloc[cleft] = cloc;
        lloc[cright] = cloc;
        cval[cright] -= cval[cloc];
        cval[cleft] -= cval[cloc];
        use[cloc] = false;
        v.pop_back();
    }
}

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

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> arr[i];
        cval[i] = arr[i];
        use[i] = false;
        lloc[i] = i - 1;
        rloc[i] = i + 1;
    }

    ans = 1e18;
    if (N == 2)
    {
        cout << arr[0] + arr[1] << "\n";
        return 0;
    }

    gogo(0);

    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int xs[5];
	for (int i = 0; i < 5; ++i) {
		cin >> xs[i];
	}
	for (int i = 0; i < 5; ++i) {
		if (xs[i] == 0) {
			cout << i+1 << endl;
			break;
		}
	}
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define req(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define qer(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

ll S[2001];
int main(){
    int n;cin>>n;S[0]=1;
    req(i,1,n){
        ll num=(i<3)?0:S[i-3];
        S[i]=(S[i-1]+num)%mod;if(i==n)cout<<num;
    }
    return 0;
}

Measured memory_bytes: 3644
import numpy as np

N = int(input())
A = np.array(input().split(),np.int64)
MOD = 10 ** 9 + 7

ans = 0
for i in range(60):
    c = np.count_nonzero((A>>i)&1)
    ans += (2 ** i) * c * (N - c)

print(ans%MOD)

Measured memory_bytes: 62776
import java.util.Scanner;

public class Main {
	
	public static void main (String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int cnt = 1;
		
		while (true) {
			if (n == 1 || n == 2 || n == 4) {
				System.out.println(cnt + 3);
				return;
			}
			if (n % 2 == 0) n /= 2;
			else n = n * 3 + 1;
			cnt++;
		}
	}
	
}


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

int main(){
    long long a,b,k;
    bool flag=0;
cin >>a >>b >>k;
if(a==b and a+b==k){//オーバーフロー対策
        a=b=0;
}
if(a+b<k){
    a=b=0;
     flag=1;
}
if(flag!=1 and k-a>=1){//k>=a;
    b=b-(k-a);
    a=0;
}
else if(flag!=1){
    a=a-k;
}

        cout <<a <<" " <<b <<endl;
return 0;
}

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

const int MAX_N = 7;

int p, q, a, n;
int tmp[MAX_N];
int size = 0;
int product = 1;

inline pair<int, int> add(int n1, int d1, int n2, int d2) {
	int deno = d1 / __gcd(d1, d2) * d2;
	int nume = deno / d1 * n1 + deno / d2 * n2;
	const int g = __gcd(nume, deno);
	return make_pair(nume / g, deno / g);
}

inline int dfs(int nume, int deno) {
	if(nume == p && deno == q)
		return 1;

	if(size == n || nume * q > deno * p)
		return 0;

	int res = 0;
	for(int i = (size ? tmp[size - 1] : 1); product * i <= a; ++i) {
		const pair<int, int> check = add(nume, deno, n - size, i);
		if(check.first * q < check.second * p)
			break;

		product *= i;
		tmp[size++] = i;
		const pair<int, int> result = add(nume, deno, 1, i);
		res += dfs(result.first, result.second);
		product /= i;
		--size;
	}

	return res;
}

int main() {
	while(scanf("%d %d %d %d", &p, &q, &a, &n), p) {
		const int g = __gcd(p, q);
		p /= g;
		q /= g;
		printf("%d\n", dfs(0, 1));
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1032
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
# mod = 998244353
# mod = 10 ** 9 + 9
mod = 10 ** 9 + 7
PI = Math::PI
dx = [ 1,  0, -1,  0,  1,  1, -1, -1]
dy = [ 0,  1,  0, -1,  1, -1,  1, -1]
eight = [0, 1, 1, 0, -1, -1, 1, -1, 0]
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end
def gi;             gets.to_i                                  end
def gf;             gets.to_f                                  end
def gs;             gets.chomp                                 end
def gmi(n=nil); n.nil? ? gets.split.map(&:to_i) : n.times.map{ gets.to_i } end
def gmf(n=nil); n.nil? ? gets.split.map(&:to_f) : n.times.map{ gets.to_f } end
def gms(n=nil); n.nil? ? gets.split : n.times.map{ gets.chomp } end
def ga2(h);        h.times.map{ gets.split.map(&:to_i) }      end
def gm(h);        h.times.map{ gets.chomp }      end
def yn(f); puts f ? "Yes" : "No" end
def YN(f); puts f ? "YES" : "NO" end
def yes(f=nil); f.nil? ? (puts "Yes"; exit) : (puts f ? "Yes" : "No") end
def no(f=nil); f.nil? ? (puts "No"; exit) : (puts f ? "Yes" : "No") end
def yay(f=nil); f.nil? ? (puts "Yay!"; exit) : (puts f ? "Yay!" : ":(") end

n,m = gmi
a = gmi.sort.reverse
s = a.inject(:+)
yn( a[m-1] >= (1.0  * s ) / (4.0 * m)  )

Measured memory_bytes: 1788
from collections import deque

n, m = map(int, input().split())
l = [[] for i in range(n)]
union = []
vis = [-1]*n
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    l[a].append(b)
    l[b].append(a)

q = deque()

for i in range(n):
    temp = []
    q.append(i)
    while q:
        a = q.popleft()
        if vis[a] == -1:
            vis[a] = 0
            temp.append(a)
            for j in l[a]:
                q.append(j)
    if len(temp) > 0:
        union.append(temp)


for i in union:
    ans = max(ans, len(i))

print(ans)

Measured memory_bytes: 51872
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long
#define Size(v) (int)v.size()

using namespace std;
// using namespace __gnu_pbds;

const ll INF = 1e18;	

void solve() {
	int n;
	cin >> n;	

	vector<ll> a(n + 1);

	ll ans = 1;

	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}

	for (int i = 1; i <= n; ++i) {
		if (a[i] == 0) {
			cout << 0;
			return;
		}
	}

	for (int i = 1; i <= n; ++i) {
		if (ans <= INF / a[i]) ans *= a[i];
		else {
			cout << -1;
			return;
		}
	}

	cout << ans;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	while (t--) 
		solve();
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];
    ll sum=accumulate(a.begin(),a.end(),0LL);
    ll rest=sum;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            rest=min(b[i],rest);
        }
    }
    cout<<sum-rest<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
#include <cassert>

using namespace std;
typedef long long ll;

const int SIZE = 2001;

int l2[SIZE], r2[SIZE], num[SIZE];
int lrsize = 0;

int dfs(char *l, char *r){
  if(l >= r) return -1;
  char *w = l;
  int counter = 0;
  
  while(*w != '[' || counter){
    if(w==r) assert(false);
    if(*w == '(') counter++;
    if(*w == ')') counter--;
    w++;
  }

  *w = '\0';
  char *p = w;
  while(*p != ']') p++;
  *p = '\0';
  p++;

  int t = lrsize++;

  num[t] = atoi(w+1);
  l2[t] = dfs(l+1, w-1);
  r2[t] = dfs(p+1, r-1);

  return t;
}

string dfs2(int now1, int now2){
  string L, R;
  
  if(l2[now1] != -1 && l2[now2] != -1){
    L = dfs2(l2[now1], l2[now2]);
  }else{
    L = "";
  }

  if(r2[now1] != -1 && r2[now2] != -1){
    R = dfs2(r2[now1], r2[now2]);
  }else{
    R = "";
  }

  return "(" + L + ")[" + to_string(num[now1] + num[now2]) + "](" + R + ")";

}


int main(){
  char a[SIZE], b[SIZE];
  scanf("%s%s", a, b);
  
  int root1 = dfs(a, a + strlen(a));
  int root2 = dfs(b, b + strlen(b));
  
  cout << dfs2(root1, root2) << endl;

  return 0;  
}



Measured memory_bytes: 3364
#include <iostream>
#include <map>
#include <climits>
using namespace std;

const int maxi = 1 << 30;

int main(){
  map<int,int> M;
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    int tmp;
    cin >> tmp;
    M[tmp]++;
  }
  
  int ans = 0;
  for(int sum = maxi;sum >=2 ;sum /= 2){
    auto itr = M.begin();
    for(;itr != M.end();itr++){
      int cur = (*itr).first;
      if (cur >= sum || (*itr).second == 0)continue;
      long long tar = sum - cur;
      if (M[tar] != 0){
	if (tar == cur){
	  ans += M[tar]/2;
	  M[cur] = 0;
	} else {
	  ans += min(M[tar], M[cur]);
	  int tmp =  min(M[cur], M[tar]);
	  M[tar] -= tmp;
	  M[cur] -= tmp;
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31104
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    string s;
    cin >> s;
    char c = s[0];
    int cnt = 0;
    REP(i, s.size()) {
        if(s[i] != c) {
            c = s[i];
            cnt++;
        }
    }
    int ans = max(ans, cnt);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1020
n , k = map(int,input().split())
p = list(map(int,input().split()))
P = []
ans = sum(p[0:k])+k
P.append(ans)
for i in range(1,n-k+1):
  ans =  ans - p[i-1] + p[i+k-1]
  P.append(ans)
  
print(max(P)/2)


Measured memory_bytes: 24812
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;


int main(){
	int n;
	while(cin>>n,n){
		map<string,int> m;
		string mxc,c;
		bool flag=false;
		int mx=0,sec=0,ansi;
		REP(i,1,n+1){
			cin>>c;
			m[c]++;
			if(!flag){
				if(mx<m[c]){
					mx=m[c];
					mxc=c;
				}else{
					sec=max(sec,m[c]);
				}
				if(mx==sec){
					mxc="TIE";
				}else if(mx>sec+n-i){
					ansi=i;
					flag=true;
				}
			}
		}
		cout<<mxc;
		if(mxc!="TIE"){
			cout<<" "<<ansi;
		}
		p("");
	}
	return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct pnt{
    double x,y;
    pnt operator+(pnt key){
	pnt res; res.x=x+key.x,res.y=y+key.y;
	return res;
    }
    pnt operator-(pnt key){
	pnt res; res.x=x-key.x,res.y=y-key.y;
	return res;
    }
    pnt operator*(double key){
	pnt res; res.x=x*key,res.y=y*key;
	return res;
    }
    pnt operator/(double key){
	pnt res; res.x=x/key,res.y=y/key;
	return res;
    }
    double abs(){
	return sqrt(x*x+y*y);
    }
};
double dot(pnt a,pnt b){
    return a.x*b.x+a.y*b.y;
}
struct line{
    pnt a,b;
};
pnt projection(line p,pnt q){
    pnt base=p.b-p.a;
    pnt hypo=q-p.a;
    pnt res=p.a+base*dot(hypo,base)/base.abs()/base.abs();
    return res;
}
int main(){
    line p;
    cin>>p.a.x>>p.a.y>>p.b.x>>p.b.y;
    ll n;cin>>n;
    while(n--){
	pnt q;
	cin>>q.x>>q.y;
	pnt res=projection(p,q);
	cout<<fixed<<setprecision(9)<<res.x<<" ";
	cout<<fixed<<setprecision(9)<<res.y<<endl;
    }
    return 0;
}



Measured memory_bytes: 3280
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int X;
    scanf("%d", &X);
    if(X >= 2000){
        printf("1");
    } else {
        bool bCanPay = false;
        for(int i = 0; i < 20; i++){
            for(int j = 0; j < 20; j++){
                for(int k = 0; k < 20; k++){
                    for(int l = 0; l < 20; l++){
                        for(int m = 0; m < 20; m++){
                            for(int n = 0; n < 20; n++){
                                if(100 * i + 101 * j + 102 * k + 103 * l + 104 * m + 105 * n == X){
                                    bCanPay = true;
                                }
                            }
                        }
                    }
                }
            }
        }
        if(bCanPay){
            printf("1");
        } else {
            printf("0");
        }
    }
  
    
    return 0;
}


Measured memory_bytes: 3160
AC = 0
WA = 0
TLE = 0
RE = 0
 
N = int(input())
for i in range(N):
  l = input()
  if l == "AC":
    AC += 1
  elif l == "WA":
    WA += 1
  elif l == "TLE":
    TLE += 1
  else:
    RE += 1
print("AC x " + str(AC)) 
print("WA x " + str(WA))
print("TLE x " + str(TLE)) 
print("RE x " + str(RE))

Measured memory_bytes: 69964
import java.util.Scanner;

public class Main {

	static int W,H,n,ans;
	static int[] id;
	static int[][] field,memo;
	static int[][] ansfield;
	static int[][][] kukaku;
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		for(;;){
			W=cin.nextInt();
			H=cin.nextInt();
			n=cin.nextInt();
			if(W+H+n==0)break;
			ans=0;
			memo = new int[n][2];
			
			field= new int[H][W];
			ansfield= new int[H][W];
			kukaku=new int[n][101][2];
			id=new int[n];
			for(int i=0;i<n;i++){
				memo[i][0]=cin.nextInt();
				id[i]=memo[i][0];
				memo[i][1]=cin.nextInt();
				int cnt=0;
				for(int j=1;j<=memo[i][1];j++){
					if(memo[i][1]%j==0){
						kukaku[i][cnt][0]=j;
						kukaku[i][cnt][1]=memo[i][1]/j;
						cnt++;
					}
					kukaku[i][100][0]=cnt;
				}
			}
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					field[i][j]=cin.nextInt();
				}
			}
			bt(0);
			if(ans==0||ans>1){
				System.out.println("NA");
			}
			else{
				outputans();
			}
			
			
			
		}
	}
	static void bt(int step){
		if(step==n){
			if(ans==0){
				for(int i=0;i<H;i++){
					for(int j=0;j<W;j++){
						ansfield[i][j]=field[i][j];
					}
				}
			}
			ans++;
			return;
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(field[i][j]==id[step]){
					fit(i,j,step);
				}
			}
		}
	}
	static void fit(int x,int y,int step){
		for(int i=0;i<kukaku[step][100][0];i++){
			for(int k=x-kukaku[step][i][0]+1;k<=x;k++){
				if(k<0||k>=H)continue;
				for(int h=y-kukaku[step][i][1]+1;h<=y;h++){
					if(h<0||h>=W)continue;
					
					boolean f = true;
					//テ・ツァツ凝ァツつケテ」ツ?渓,h
					for(int a=k;a<k+kukaku[step][i][0];a++){
						for(int b=h;b<h+kukaku[step][i][1];b++){
							if(a<0||a>=H||b<0||b>=W){
								f=false;
								break;
							}
							
							
							// (k,h)-(a,b)テ」ツつ段d[step]テ」ツ?ァテ・ツ。ツ療」ツつ?
							if(field[a][b]!=0&&field[a][b]!=id[step]){
//								System.out.println(a+" "+b+" "+id[step]);
								f=false;
								break;
							}
							
						}
					}
//					output(); 
//					System.out.println(kukaku[step][i][0]+" "+kukaku[step][i][1]);
//					System.out.println(k+" "+h);
//					System.out.println();
					if(!f)continue;
					// テ・ツ。ツ療」ツつ?
					for(int a=k;a<k+kukaku[step][i][0];a++){
						for(int b=h;b<h+kukaku[step][i][1];b++){
							field[a][b]=id[step];
						}
					}
					bt(step+1);
					// テヲツ按サテ」ツ??
					for(int a=k;a<k+kukaku[step][i][0];a++){
						for(int b=h;b<h+kukaku[step][i][1];b++){
							field[a][b]=0;
						}
					}
					field[x][y]=id[step];
					
					
					
				}
			}
		}
		
		
		
		
	}
	static void output(){
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				System.out.print(field[i][j]+" ");
			}
			System.out.println();
		}
	}
	static void outputans(){
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				
				if(j==W-1){
					System.out.print(ansfield[i][j]);	
				}
				else{
					System.out.print(ansfield[i][j]+" ");	
				}
			}
			System.out.println();
		}
	}
}

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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int> > s(M);
    for (int i = 0; i < M; ++i) {
        int k; cin >> k;
        for (int j = 0; j < k; ++j) {
            int a; cin >> a; --a;
            s[i].push_back(a);
        }
    }
    vector<int> p(M);
    for (int i = 0; i < M; ++i) cin >> p[i];

    long long res = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        bool ok = true;
        for (int i = 0; i < M; ++i) {
            int con = 0;
            for (auto v : s[i]) {
                // onになっているスイッチの数を数える
                if (bit & (1<<v)) ++con;
            }
            // スイッチの数を2で割った個数が不一致の場合
            if (con % 2 != p[i]) ok = false;
        }
        // 不一致が一つもなかった場合にのみ　カウントする
        if (ok) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 3604
#a
from decimal import Decimal
def comp_index(x, p, maxim):
    low = 0
    high = maxim

    while low + 1 < high:
        mid = (low + high) // 2
        guess = x // p ** mid == x / p ** mid
        if guess:
            low = mid
        else:
            high = mid
    return low
n = int(input())
ansans = 0
max2 = 44
max5 = 19
a = [[0] * (2*max5+1) for _ in range(2*max2+1)]
a_ac = [[0] * (2*max5+1) for _ in range(2*max2+1)]
for _ in range(n):
    aratio = Decimal(input()).as_integer_ratio()
    a2 = -comp_index(aratio[1], 2, max2)
    if a2 == 0:
        a2 = comp_index(aratio[0], 2, max2)
    a5 = -comp_index(aratio[1], 5, max5)
    if a5 == 0:
        a5 = comp_index(aratio[0], 5, max5)
    a[a2][a5] += 1
    a_ac[a2][a5] += 1
    if a2 >= 0 and a5 >= 0:
        ansans -= 1
for i in range(max2, -max2-1, -1):
    for j in range(max5-1, -max5-1, -1):
        a_ac[i][j] += a_ac[i][j+1]
for j in range(max5, -max5-1, -1):
    for i in range(max2-1, -max2-1, -1):
        a_ac[i][j] += a_ac[i+1][j]
for i in range(-max2, max2+1):
    for j in range(-max5, max5+1):
        ansans += a[i][j] * a_ac[-i][-j]
#for i in range(-max2, max2+1):print(''.join(str(a[i][j]) for j in range(-max5+1, max5+1)))
#print()
#for i in range(-max2, max2+1):print(''.join(str(a_ac[i][j]) for j in range(-max5+1, max5+1)))
print(ansans//2)

Measured memory_bytes: 207708
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	string s;
	cin >> s;
	int len = s.size();
	int cnt = 0;
	for (int i = 0; i < len / 2; i++) {
		if (s[i] != s[len - i - 1])cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a, b;
	scanf("%d %d", &a, &b);

	int max = a + b; 
	if( a - b > max ){
		max = a - b;
    }if( a * b > max ){
		max = a * b;
	}
    printf("%d", max);
	return 0;
}

Measured memory_bytes: 128
input_s = str(input())
ary = input_s.split(" ")
ary.sort()
task = 0
tmp1 = 0
tmp2 = 0
for i in ary:
    if tmp1 == 0:
        tmp1 = int(i)
    else:
        tmp2 = int(i)
        if tmp1 < tmp2:
            task += tmp2 - tmp1
        else:
            task += tmp1 - tmp2
        tmp1 = tmp2
print(task)


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

using namespace std;

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())

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

  vector<int> a;

  for (int i = 0; i < n; ++i) {
    int m;
    cin >> m;
    a.push_back(m);
  }

  vector<int> sorted;
  copy(a,sorted);
  sort(sorted);
  int max = sorted[n - 1];
  int smax = sorted[n - 2];

  for (int i = 0; i < n; ++i) {
    int pre = a[i];

    if (pre == max) {
      cout << smax << endl;
    } else {
      cout << max << endl;
    }
  }
}

Measured memory_bytes: 3316
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iomanip>
using namespace std;

bool isPalindrome(string s) {
	bool answer = true;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] != s[s.size() - 1 - i]) {
			answer = false;
			return answer;
		}
		
	}
	return answer;
}


int main() {
	bool answer = true;
	string s;
	cin >> s;
	if (!isPalindrome(s)) { cout << "No" << endl; return 0; }
	string second = s.substr(0, ((s.size() - 1) / 2));
	//cout << "Second: " << second << endl;
	if (!isPalindrome(second)) { cout << "No" << endl; return 0; }
	int third = (s.size() + 3) / 2;
	third--;
	string the = s.substr(third, s.size() - third);
	//cout << third << endl;
	//cout << "Third: " << the << endl;
	if (!isPalindrome(the)) { cout << "No" << endl; return 0; }

	cout << "Yes" << endl;

	
}





Measured memory_bytes: 256
/////////////////////////////////////////
 ///        author: matcha1024         ///
/////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int h, w; cin>> h >> w;
    int si, sj; cin>> si >> sj;
    int ti, tj; cin>> ti >> tj;
    si--; sj--; ti--; tj--;
    vector<string> s(h);
    forin(s);
    const int INF=1e+9;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pair<int, int>> q;
    dist[si][sj]=0;
    q.emplace_back(si, sj);
    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        int d = dist[i][j];
        rep(v, 4){
            int ni = i + di[v], nj = j + dj[v];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni, nj);
        }
        for(int ei = -2; ei <= 2; ei++){
            for(int ej = -2; ej <= 2; ej++){
                int ni = i+ei, nj=j+ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') continue;
                if(dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if(ans == INF) ans = -1;
    cout<< ans << endl;
}


Measured memory_bytes: 9424
H, W = map(int, input().split())
a = [list(map(lambda x: int(x) % 2, input().split())) for _ in range(H)]

route = []
for i in range(H):
    if i%2==0:
        order = range(W)
    else:
        order = reversed(range(W))
    for j in order:
        route.append([i, j])

man = []
move = False
for i, (y, x) in enumerate(route):
    if move:
        man.append(route[i-1]+route[i])
        if a[y][x] ==1:
            move = False
    elif a[y][x] == 1:
        move = True
print(len(man))
for elem in man:
    print(' '.join(list(map(lambda x: str(x+1), elem))))


Measured memory_bytes: 51568
N = int(input())
ans = ['a']
for i in range(N-1):
  tmpans = []
  for a in ans:
    mx = 0
    for s in a:
      mx = max(ord(s),mx)
    for c in range(ord('a'),mx+2):
      tmpans.append(''.join(list(a)+[chr(c)]))
  ans = tmpans[:]
for a in sorted(ans):
  print(a)

Measured memory_bytes: 62300
n = int(input())
ans = 1
dummy1,dummy2 = divmod(n,2)
for i in range(1,dummy1+1):
  ans *= i
  ans *= n+1-i
  ans = ans % (10**9+7)
if dummy2 == 1:
  ans = ((dummy1+1)*ans % (10**9+7))
print(ans)





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

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

  if (S == "hi") {
    cout << "Yes";
  } 
  else if (S == "hihi") {
    cout << "Yes";
  }
  else if (S == "hihihi") {
    cout << "Yes";
  }
  else if (S == "hihihihi") {
    cout << "Yes";
  }  
  else if (S == "hihihihihi") {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
  cout << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<ll, ll> mp;
    ll ans = 0;
    rep(i,n){
        cin >> a[i];
        mp[a[i]]++;
        ans += a[i];
    }
    int q;
    cin >> q;
    rep(i,q){
        int b,c;
        cin >> b >> c;
        mp[c] += mp[b];
        ans += mp[b] * (c-b);
        mp[b] = 0;
        dunk(ans);
    }

    return 0;
}

Measured memory_bytes: 9472
#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 <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int A,B,C;
  cin >> A >> B >> C;
  int K;
  cin >> K;
  int cnt = 0;
  while(A >= B){
    B *= 2;
    cnt++;
  }
  while(B >= C){
    C *= 2;
    cnt++;
  }
  if(cnt <= K){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3648
N = int(input())
A = list(map(int, input().split()))
# M = max(A)+1
M = 10**6+1
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] != 0:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 121876
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int a,b,c;
    cin >> a >> b >> c;
    //処理
    //出力
    if((10*b+c)%4==0) cout << "YES" << ENT;
    else cout << "NO" << ENT;
    return 0;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#define int long long
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	map<int, int>c;
	for (int d = 0; d < b; d++) {
		int e;
		cin >> e; e--;
		cin >> c[e];
	}
	int dp[100][3][2]{};
	if (c[0])dp[0][c[0]-1][0] = 1;
	else dp[0][0][0] = dp[0][1][0] = dp[0][2][0] = 1;
	for (int f = 1; f < a; f++) {
		dp[f][0][0] = dp[f - 1][1][0] + dp[f - 1][1][1] + dp[f - 1][2][0] + dp[f - 1][2][1];
		dp[f][1][0] = dp[f - 1][0][0] + dp[f - 1][0][1] + dp[f - 1][2][0] + dp[f - 1][2][1];
		dp[f][2][0] = dp[f - 1][0][0] + dp[f - 1][0][1] + dp[f - 1][1][0] + dp[f - 1][1][1];
		dp[f][0][1] = dp[f - 1][0][0];
		dp[f][1][1] = dp[f - 1][1][0];
		dp[f][2][1] = dp[f - 1][2][0];
		switch (c[f]) {
		case 1:dp[f][1][0] = dp[f][1][1] = dp[f][2][0] = dp[f][2][1] = 0; break;
		case 2:dp[f][0][0] = dp[f][0][1] = dp[f][2][0] = dp[f][2][1] = 0; break;
		case 3:dp[f][0][0] = dp[f][0][1] = dp[f][1][0] = dp[f][1][1] = 0; break;
		}
		for (int x = 0; x < 3; x++) {
			for (int y = 0; y < 2; y++) {
				dp[f][x][y] %= 10000;
			}
		}
	}
	int s = 0;
	for (int x = 0; x < 3; x++) {
		for (int y = 0; y < 2; y++) {
			s += dp[a-1][x][y];
		}
	}
	cout << s%10000 << endl;
}

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

enum Direction{SOUTH,EAST};

int main()
{
  int H,W,N;
  while(cin>>H>>W>>N,H|W|N){
    vector< vector<int> >v(H,vector<int>(W));
    vector< vector<int> >dp(H,vector<int>(W,0));
    for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>v[i][j];
    dp[0][0]=N-1;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(i-1>=0){
	  if(dp[i-1][j]&1){
	    if(v[i-1][j]==SOUTH)dp[i][j]+=(dp[i-1][j]+1)/2;
	    else dp[i][j]+=(dp[i-1][j]-1)/2;
	  }else{
	    dp[i][j]+=dp[i-1][j]/2;
	  }
	}
	if(j-1>=0){
	  if(dp[i][j-1]&1){
	    if(v[i][j-1]==EAST)dp[i][j]+=(dp[i][j-1]+1)/2;
	    else dp[i][j]+=(dp[i][j-1]-1)/2;
	  }else{
	    dp[i][j]+=dp[i][j-1]/2;
	  }
	}
      }
    }
    int y,x;
    int ny,nx;
    int dy[2]={1,0};
    int dx[2]={0,1};
    y=x=ny=nx=0;
    while(x<W && y<H){
      v[y][x]+=dp[y][x];
      v[y][x]&=1;
      ny+=dy[ v[y][x] ];
      nx+=dx[ v[y][x] ];
      y=ny;
      x=nx;
    }
    cout<<y+1<<" "<<x+1<<endl;
  }
}

Measured memory_bytes: 8760
"use strict";

function main(input) {
  input = input.trim().split("");

  for (let i = 0; i < input.length; i++) {
    if (input[i] == "?") {
      input[i] = "D";
      // if (input[i + 1] == "D" || input[i + 1] == "?") {
      //   input[i] = "P";
      // }
    }
  }

  console.log(input.join(""));
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> d(n);
    REP(i, n) cin >> d[i];
    sort(ALL(d));

    cout << d[n/2] - d[n/2-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

#define mod 1000000007
using namespace std;

long long dp[5010][5010];
int main(){
	int i,j,n;
	string s;
	cin >> n >> s;
	dp[0][0] = 1;
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			if(j==0){
				dp[i+1][j] += dp[i][j];
				dp[i+1][j+1] += dp[i][j];
			}else{
				dp[i+1][j-1] += 2*dp[i][j];
				dp[i+1][j+1] += dp[i][j];
			}
			dp[i+1][j-1] %= mod;
			dp[i][j] %= mod;
			dp[i+1][j+1] %= mod;
		}
	}
	
	cout << dp[n][s.size()] << endl;
}


Measured memory_bytes: 196096
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
#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) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define INF (ll)1000000007
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; }
 
int main(void){
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];
    SORT(a);
 
    int l=-1, r=N, n=(l+r)/2;
 
    while(r-l > 1){
        int dp[N][K+1];
        REP(i,N)REP(j,K+1) dp[i][j] = 0;
        REP(i,N) dp[i][0] = 1;
        int k=1;
        REP(i,N){
            if(i == n) continue;
            FOR(j,1,K+1){
                if(j-a[i] >= 0) chmax(dp[k][j], dp[k-1][j-a[i]]);
                chmax(dp[k][j], dp[k-1][j]);
            }
            k++;
        }
        bool flag = false;
        for(ll i=max((ll)0, (ll)K-a[n]); i<K; i++) if(dp[N-1][i]){flag = true; break;}
        if(flag) r = n;
        else l = n;
        n = (l+r)/2;
    }
 
    cout << l+1 << endl;
    
    return 0;
}

Measured memory_bytes: 98048
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,a[3]={"Sunny","Cloudy","Rainy"};
  cin>>s;
  for(int i=0;i<3;i++)
  {
     if(a[i]==s)
     {
       cout<<a[(i+1)%3];
       break;
     }
  }
}

Measured memory_bytes: 256