akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Diagnostics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        if (calc2()) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }

    bool calc2()
    {

        int N = cin.nextInt();
        int[] A = cin.ArrayInt(N);

        int minHeight = 1;
        foreach (var i in A)
        {
            if (i < minHeight) return false;
            minHeight = Math.Max(minHeight, i - 1);
        }
        return true;
    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}




Measured memory_bytes: 28892
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s[ohara];
ll n, cnt, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;
ll ac, wa;
U_MAP out, out2;

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

  cin >> n >> m;
  rep(i, m) cin >> a[i] >> s[i];
  rep(i, m) {
    if (out[a[i]]) continue;
    if (s[i] == "AC") {
      out[a[i]] = 1;
      ac++;
    }
  }
  rep(i, m) {
    if (!out[a[i]]) continue;
    if (out2[a[i]]) continue;
    if (s[i] == "AC") {
      out2[a[i]] = 1;
    } else {
      wa++;
    }
  }
  cout << ac << " " << wa << "\n";
  return 0;
}


Measured memory_bytes: 23460
#include<bits/stdc++.h>
#define Pii pair<int,int>
#define se second
#define fi first
#define mp make_pair
#define pb push_back
#define maxn 400
using namespace std;
bool vis[maxn];
int n,m,seg[maxn][maxn],pos,cur[maxn];
int num[maxn],ans=0;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++) scanf("%d",&seg[i][j]);
	for(int i=1;i<=n;i++) cur[i]=1,num[seg[i][1]]++;
	for(int i=1;i<=m;i++){
		if(num[i]>ans){
			ans=num[i];
			pos=i;
		}
	}
	int tot=m;
	while(tot){
		memset(num,0,sizeof(num));
		for(int i = 1; i <= n; ++ i){
			while(vis[seg[i][cur[i]]]) ++ cur[i];
			++ num[seg[i][cur[i]]];
		}
		int tem=0;
		for(int i = 1; i <= m; ++ i)
			if(num[i] >tem) tem = num[i];
		ans=min(ans,tem);
		for(int i = 1; i <= m; ++ i)
			if(num[i] == tem) vis[i] = true, -- tot;
	} 
	cout<<ans;
	return 0;
}

Measured memory_bytes: 768
import sys
readline = sys.stdin.readline

N = int(readline())
S = [readline().strip() for i in range(N)]

D = []
L, R = [], []
for s in S:
    l, r = 0, 0
    for c in s:
        if c == ')':
            if l > 0:
                l -= 1
            else:
                r += 1
        else:
            l += 1
    if l == 0 and r == 0:
        pass
    elif l == 0:
        R.append(r)
    elif r == 0:
        L.append(l)
    else:
        D.append((l, r))

L = sum(L)
R = sum(R)

inc = []
dec = []
for l, r in D:
    if l > r:
        inc.append((l, r))
    else:
        dec.append((l, r))

inc.sort(key=lambda x:x[1])
dec.sort(key=lambda x:-x[1])

D = inc + dec

for i, (l,r) in enumerate(D):
    L -= r
    if L < 0:
        print('No')
        exit(0)
    L += l

if L == R:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 66716
#include <stdio.h>

int main(void)
{
	int n,x,cnt=0,sum;
	int i,j,k;
	
	while(1){
		scanf("%d %d",&n,&x);
		if(n==0 && x==0) break;
		
		for(i=1 ; i<=n ; i++){
			for(j=i+1 ; j<=n ; j++){
				for(k=j+1 ; k<=n; k++){
					if(i+j+k==x) cnt++;
				}
			}
		}
		
		printf("%d\n",cnt);
		cnt=0;
	}
		
	return 0;
}


Measured memory_bytes: 2068
#include <stdio.h>

int main(){
  
  
  int i,j,tmp,k,l,m,n,count=0;
  int data[100];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  
  for(k=0;k<n-1;k++){
    for(l=n-1;l>k;l--){
      if(data[l-1]>data[l]){
	tmp = data[l];
	data[l] = data[l-1];
	data[l-1] = tmp;
	count = count + 1;
      }
    }
  }

  for(i=0;i<n;i++){
    if(i>0)printf(" ");
    printf("%d",data[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i;i<(int)n;i++)

using namespace std;

int main(){
  int A,B,M;
  cin>>A>>B>>M;
  vector <int> vec1(A);
  vector <int> vec2(B);
  REP(i,A) {cin>>vec1[i];}
  REP(i,B) {cin>>vec2[i];}
  int minA=*min_element(vec1.begin(),vec1.end());
  int minB=*min_element(vec2.begin(),vec2.end());
  int ans=minA+minB;
  REP(i,M){
    int x,y,c;
    cin>>x>>y>>c;
    x--;y--;
    ans=min(ans,vec1[x]+vec2[y]-c);
  }
  cout<<ans<<endl;
  return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=3010;
int n,T,a[maxn],b[maxn];
int dp[maxn][maxn],ans;
int dp2[maxn][maxn],mx[maxn][maxn];
void update(int &x,int y) { x=max(x,y); }
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(T); T--;
	for (int i=1;i<=n;i++) read(a[i]),read(b[i]);
	for (int i=1;i<=n;i++) {
		for (int j=0;j<=T;j++) update(dp[i][j],dp[i-1][j]);
		for (int j=0;j+a[i]<=T;j++)
			update(dp[i][j+a[i]],dp[i-1][j]+b[i]);
	}
	for (int i=n;i>=1;i--) {
		for (int j=0;j<=T;j++) update(dp2[i][j],dp2[i+1][j]);
		for (int j=0;j+a[i]<=T;j++)
			update(dp2[i][j+a[i]],dp2[i+1][j]+b[i]);
	}
	for (int i=1;i<=n;i++) {
		mx[i][0]=dp2[i][0];
		for (int j=1;j<=T;j++) mx[i][j]=max(mx[i][j-1],dp2[i][j]);
	}
	for (int i=1;i<=n;i++) {
		for (int j=0;j<=T;j++)
			update(ans,dp[i-1][j]+mx[i+1][T-j]+b[i]);
	}
	printf("%d\n",ans);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 106368
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define pr pair<int,int>
#define endl "\n"
#define MOD 1000000007 // 10^9 + 7
#define sz(x) (int)(x).size()
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define all(c) (c).begin(), (c).end()

#define FOR(i,b) for (int i = 0; i < (b); i++)
#define FORR(i,a,b) for (int i = a; i < (b); i++)
#define FORB(i,b) for (int i = (b); i >= (0); i--)
#define FORRB(i,a,b) for (int i = (a);i>= (b); i--)
const ll INF = 1e18l + 5;
using namespace std;

int n,w,weg[110],value[110];
ll total_value;

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

	//freopen("addin.txt","r",stdin);
	//freopen("addout.txt","w",stdout);
	cin >> n >> w;
	for(int i = 1;i <= n;i++){
		cin >> weg[i] >> value[i];
		total_value += value[i];
	}
	vi dp(total_value+1,INF);
	dp[0] = 0;
	for(int item = 1 ;item <= n;item++){
		for(int value_already = total_value-value[item];value_already >= 0 ;value_already--){
			dp[value_already+value[item]] = min(dp[value_already+value[item]],dp[value_already]+weg[item]);
		}
	}
	int res = 0;
	for(int i = 0;i<= total_value;i++){
		if(dp[i] <= w) res = max(i,res);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  long int x;
  int i, j, k, n, y;
  int s[100] = {0}, t[100] = {0}, min;

  scanf("%ld", &x);

  n = 0;
  for (i = 0; x!=0; i++) {
    s[i] = x % 10;
    x = x / 10;
    n++;
  }

  for (i = 0; i < n; i++) {
    t[i] = s[n-i-1];
  }

  min = 99999;
  for (i = 0; i < n-2; i++) {
    y = 753 - (100*t[i] + 10*t[i+1] + t[i+2]);
    if (y < 0) {
      y = -y;
    }
    if (min > y) {
      min = y;
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;

const int INF = 1 << 30;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

class State
{
public:
  int x, y, cost;
  bool water;

  State(int _x, int _y, int _cost, bool _water)
    :x(_x), y(_y), cost(_cost), water(_water) {}

  bool operator < (const State& st) const
  {
    return this->cost > st.cost;
  }
};

int main()
{
  int n, m;
  while (cin >> n >> m) {
    if ((n|m) == 0)
      break;

    int sx, sy;
    vector<string> castle(m);
    for (int i = 0; i < m; ++i) {
      cin >> castle[i];
      castle[i].insert(castle[i].begin(), '.');
      castle[i].insert(castle[i].end(), '.');

      if (castle[i].find_first_of("&") != string::npos) {
	sx = castle[i].find_first_of("&");
	sy = i;
	castle[sy][sx] = '.';
      }
    }
    castle.insert(castle.begin(), string(n+2, '.'));
    castle.push_back(string(n+2, '.'));
    ++sy;

    priority_queue<State> que;
    que.push(State(sx, sy, 0, false));
    vector<vector<int> > dp(m+2, vector<int>(n+2, INF));
    while (!que.empty()) {
      const State st = que.top();
      que.pop();

      if (st.x == 0 || st.x == n+1 || st.y == 0 || st.y == m+1) {
	cout << st.cost << endl;
	break;
      }

      if (dp[st.y][st.x] < st.cost)
	continue;
      dp[st.y][st.x] = st.cost;

      for (int d = 0; d < 4; ++d) {
	int x = st.x + dx[d];
	int y = st.y + dy[d];
	if (x < 0 || n+2 <= x || y < 0 || m+2 <= y)
	  continue;

	if (st.water) {
	  if (castle[y][x] == '#' && dp[y][x] > st.cost) {
	    dp[y][x] = st.cost;
	    que.push(State(x, y, st.cost, true));
	  }

	  if (castle[y][x] == '.' && dp[y][x] > st.cost+1) {
	    dp[y][x] = st.cost+1;
	    que.push(State(x, y, st.cost+1, false));
	  }
	} else {
	  if (castle[y][x] == '#' && dp[y][x] > st.cost) {
	    dp[y][x] = st.cost;
	    que.push(State(x, y, st.cost, true));
	  }

	  if (castle[y][x] == '.' && dp[y][x] > st.cost) {
	    dp[y][x] == st.cost;
	    que.push(State(x, y, st.cost, false));
	  }
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1e9 + 7;
//ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	//t %= mod;
	if (n % 2 == 1)t *= a;
	return t /*% mod*/;
}

//const int INF = 1001001001;
const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll, ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}


int main() {
	string n;
	cin >> n;
	int res = 0;
	for (int i = 0; i < n.size(); i++) {
		int x = n[i] - '0';
		res += x;
		res %= 9;
	}
	if (res == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define endl '\n'
using namespace std;
const int N=2e5+100;
ll seg[N*4][2];
ll lazy=0;
void upd(ll nod,ll b,ll l,ll r,ll id,ll val){
    if (r-l==1){
        seg[nod][b]=min(seg[nod][b],val);
        return;
    }
    ll mid=(r+l)/2;
    if (mid>id) upd(nod*2,b,l,mid,id,val);
    else upd(nod*2+1,b,mid,r,id,val);
    seg[nod][b]=min(seg[nod*2][b],seg[nod*2+1][b]);
    return ;
}
ll get(ll nod,ll b,ll l,ll r,ll L,ll R){
    if (l>=R || L>=r) return (ll)1e15;
    if (l>=L && r<=R) return seg[nod][b];
    ll mid=(r+l)/2;
    return min (get(nod*2,b,l,mid,L,R),get(nod*2+1,b,mid,r,L,R));
}
ll n,a[N],x,y,q;
int32_t main(){
    cin >> n >> q >> x >> y;
    for (int i=1;i<=q;i++){
        cin >> a[i];
    }
    memset(seg,31,sizeof seg);
    a[0]=x;
    upd(1,0,1,N,y,-y);
    upd(1,1,1,N,y,y);
    for (int i=1;i<=q;i++){
        ll z=min(get(1,0,1,N,1,a[i])+a[i],get(1,1,1,N,a[i],N)-a[i]);
        ll t=abs(a[i]-a[i-1]);
     //   cout << z << " " << lazy << endl;
        z+=lazy;
        lazy+=t;
        z-=lazy;
        upd(1,0,1,N,a[i-1],z-a[i-1]);
        upd(1,1,1,N,a[i-1],z+a[i-1]);
    }
    ll ans=(ll)1e15;
    for (int i=1;i<=n;i++){
        ll z=get(1,0,1,N,i,i+1);
        z+=i;
        ll t=get(1,1,1,N,i,i+1);
        t-=i;
        ans=min(ans,min(z,t));
    }
    cout << ans+lazy << endl;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            List<int> hList=new List<int>();

            string s="";

            for (int i = 0; i <= 9; i++)
            {
               s = Console.ReadLine();

               hList.Add(Convert.ToInt32(s));
            }

            hList.Sort();

            for (int i = hList.Count-1; i > hList.Count-(3+1); i--)
            {
                Console.WriteLine(hList[i].ToString());
            }

            Console.ReadLine(); 
        }
    }

}

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

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

    int n,x;
    ll ans = 0;
    cin>>n>>x;
    int ara[n];
    for(int i = 0; i < n; i++) cin>>ara[i];

    if(ara[0] > x){
        ans += ara[0]-x;
        ara[0] = x;
    }

    for(int i = 1; i <n; i++){
        int pre_sum = ara[i] + ara[i-1];
        int temp = max(0,pre_sum-x);
        ara[i] -= temp;
        ans += temp;
    }

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


Measured memory_bytes: 4008
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long a,b;
int main(){
	cin>>a>>b;
	if(a%2!=b%2)
	{
		cout<<"IMPOSSIBLE";
		return 0;
	}
	cout<<(a+b)/2;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    ll k;
    cin>>n>>k;
    vector<ll>pos, neg;
    for(int i=0; i<n; ++i) {
        ll a;
        cin>>a;
        if(a >= 0)
            pos.pb(a);
        else
            neg.pb(-a);
    }
    sort(pos.begin(), pos.end());
    sort(neg.begin(), neg.end());

    ll l = -1e18, r = 1e18;
    // ll l = 10, r = 12;
    ll m;
    while(l < r) {
        m = l + (r - l) / 2;
        // cout<<l<<", "<<r<<" : "<<m<<" ";
        ll fx = 0;
        if(m >= 0) {
            ll lp = 0, rp = pos.size()-1;
            while(lp < rp) {
                if(pos[lp] * pos[rp] <= m) {
                    fx += rp - lp;
                    ++lp;
                }
                else {
                    --rp;
                }
            }
            lp = 0;
            rp = neg.size()-1;
            while(lp < rp) {
                if(neg[lp] * neg[rp] <= m) {
                    fx += rp - lp;
                    ++lp;
                }
                else {
                    --rp;
                }
            }
            fx += pos.size() * neg.size();
        }
        else
        {
            ll lp = pos.size()-1, rp = 0;
            while(lp >= 0 && rp < neg.size()) {
                if(-pos[lp] * neg[rp] <= m) {
                    fx += neg.size() - rp;
                    --lp;
                }
                else {
                    ++rp;
                }
            }
        }
        
        if(fx >= k) {
            r = m;
        }
        else {
            l = m + 1;
        }
        // cout<<fx<<endl;
    }
    // cout<<k<<endl;
    cout<<(l+r)/2<<endl;
}

Measured memory_bytes: 2548
// ABC052
// A - Two Rectangles
#include<bits/stdc++.h>

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a*b > c*d) cout << a*b << endl;
    else cout << c*d << endl;
    return 0;
}


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

int main() {
  
  int n, m;
  cin >> n >> m;
  
  vector<int> vec(n);
  for (int i=0; i<n; i++) cin >> vec.at(i);
  
  double s=0;
  for (int i=0; i<n; i++) s+=vec.at(i);
  s/=(4*m);
  
  for (int i=0; i<n; i++) {
    if (vec.at(i)<s) vec.at(i)=0;
    else vec.at(i)=1;
  }
  
  int ss=0;
  for (int i=0; i<n; i++) ss+=vec.at(i);
  
  if (ss<m) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (a, b, c) = input!(u64, u64, u64);
    let (k, ) = input!(u32);

    for i in 0..=k {
        if a < b * 2u64.pow(i) && b * 2u64.pow(i) < c * 2u64.pow(k - i) {
            println!("Yes");
            std::process::exit(0);
        }
    }

    println!("No");
}

fn main() {
    solve();
}


Measured memory_bytes: 2096
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;

vi prime;
bool table[1000005] = {false};

void seive(){
    for(int i=2;i<1000005;i++){
        if(!table[i]){
            // cout<<i<<" --> ";
            table[i] = true;
            prime.pb(i);
            for(int j=i*i;j<1000005;j+=i){
                table[j] = true;
                //cout<<'t';
            }
        }
    }
}
 
signed main()
{
    tezz
    
    seive();
    int a, b;
    cin>>a>>b;

    set<int> s;
    s.insert(1);

    for(int x:prime){
        if(x<=a && x<=b && a%x == 0 && b%x == 0){
            s.insert(x);

            while(a%x==0) a/=x;
            while(b%x==0) b/=x;
            // cout<<x<<" --> "<<endl;
            // cout<<a<<' '<<b<<endl;
        }
    }

    if(a>1 && b>1 && ((s.size() == 1) || (a==b))) s.insert(0);
    // cout<<endl;

    // for(int x:s) cout<<x<<' ';
    //     cout<<endl;

    cout<<s.size();
} 

Measured memory_bytes: 2424
#include<stdio.h>
int main(){
  int G[101][101];
  int i,j,n,u,k,v;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      G[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",G[i][j]);
      if(j<n-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
ll dp[3010][3010];
ll mod = 998244353;
ll a[1000000 + 10];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n, k;
	cin >> n >> k;
	dp[0][0] = 1;
	rep(i, 1, n + 1) cin >> a[i];
	rep(i, 1, n + 1){
		rep(j, 0, 3001){
			if(j >= a[i]) dp[i][j] = (dp[i - 1][j] * 2 + dp[i - 1][j - a[i]]) % mod ;
			else dp[i][j] = (dp[i - 1][j] * 2) % mod;
		}
	}
	ll ans = 0;
	cout << dp[n][k];
	return 0;
}

Measured memory_bytes: 74164
def main():
    s = input()
    K = int(input())
    sk = []
    for i in range(len(s)):
        for j in range(1, K + 1):
            ss = s[i:i + j]
            if ss not in sk:
                sk.append(ss)
    print(sorted(sk)[K - 1])


main()


Measured memory_bytes: 4084
import heapq

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

C = [(-b, i) for i, b in enumerate(B) if b > A[i]]
heapq.heapify(C)

count = 0
while C:
    c, i = heapq.heappop(C)
    c *= -1
    if A[i] == c:
        continue
    if i == N-1:
        x = B[N-2] + B[0]
    else:
        x = B[i-1] + B[i+1]
    if c <= x or c < A[i] or c-A[i] < x:
        count = -1
        break
    temp = (c-A[i]) // x
    c -= temp * x
    count += temp
    B[i] = c
    if c > A[i]:
        heapq.heappush(C, (-c, i))
print(count)

Measured memory_bytes: 125916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

bool judge(ll x) {
  return (x==1||x==9||x==7||x==4);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b,c,d;cin>>a>>b>>c>>d;
  bool isok=true;
  isok=judge(a);
  if(isok&&a!=b) isok=judge(b);else isok=false;
  if(isok&&a!=c&&b!=c) isok=judge(c);else isok=false;
  if(isok&&a!=d&&b!=d&&c!=d) isok=judge(d);else isok=false;
  print(isok?"YES":"NO");
  return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var a = ab[0];
        var b = ab[1];

        Console.WriteLine((a & b & 1) == 1 ? "Yes" : "No");
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

int main() {
    string str;
    cin >> str;
    str[3] = '8';
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())

ans=0
if x*y>0:
    if x<=y:
        ans=abs(y-x)
    else:
        ans=2+abs(y-x)
elif x*y<0:
    ans=1+abs(y+x)
else:
    if x<=y:
        ans=abs(y-x)
    else:
        ans=1+abs(y-x)
print(ans)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  string s;
  cin >> s;
  
  ll cnt=0, max_cnt=0;
  rep(i, s.size()) {
    if(s[i] == 'R') {cnt++; chmax(max_cnt, cnt);}
    if(s[i] == 'S') cnt=0;
  }
  cout << max_cnt << newl;
  return 0;
}

Measured memory_bytes: 3632
# your code goes here
#dice4
def r(D,s):
    if s==0:
        t=D[0]
        D[0]=D[1]
        D[1]=D[5]
        D[5]=D[4]
        D[4]=t
    elif s==2:
        t=D[0]
        D[0]=D[4]
        D[4]=D[5]
        D[5]=D[1]
        D[1]=t        
    elif s==3:
        t=D[0]
        D[0]=D[3]
        D[3]=D[5]
        D[5]=D[2]
        D[2]=t        
    elif s==1:
        t=D[0]
        D[0]=D[2]
        D[2]=D[5]
        D[5]=D[3]
        D[3]=t
    elif s==4:
        D=r(r(D,1),1)
    return D
def ch(C,D):
    k=0
    while k<6 and C[k]==D[k]:
        k+=1
    if k==6:
        return 1
    else:
        return 0
def d3(C,D):
    nd=0
    if ch(C,D)==1:
        nd=1
    i=0
    while i<4 and nd==0:
        D=r(D,i)
        j=i+1
        j%=4
        k=0
        if ch(C,D)==1:
            nd=1
 #   if i==0:
    #    print(D)
        while k<3 and nd==0:
            D=r(D,j)
            if ch(C,D)==1:
                nd=1
            k+=1
  #      if i==0:
        #    print(D)
        D=r(D,j)
 #   if i==0:
   #     print(D)
        m=i+2
        m%=4
 #   if i==0:
    #    print(m)    
        D=r(D,m)
 #   if i==0:
 #       print(D)
        i+=1
    i=0
    while nd==0 and i<4:
        D=r(D,0)
        D=r(D,1)
        D=r(D,0)
        if ch(C,D)==1:
            nd=1
        D=r(r(D,0),0)
        if ch(C,D)==1:
            nd=1
        i+=1
    if nd==1:
        return 1
    else:
        return 0
n=int(input())
Dl=[[int(i) for i in input().split()] for i in range(n)]
i1=0
ne=1
while i1<n-1 and ne==1:
    i2=i1+1
    while i2<n and ne==1:
        if d3(Dl[i1],Dl[i2])==1:
            ne=0
        i2+=1
    i1+=1
if ne==0:
    print("No")
else:
    print("Yes")

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long b[n + 1];
  b[0] = 0;
  for (int i = 0; i < n; i++) b[i + 1] = b[i] + a[i];
  int res = 1;
  for (int i = n - 1; i > 0; i--) {
    if (2 * b[i] >= a[i]) res++;
    else break;
  }
  cout << res << "\n";
  return 0;
}

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

int main()
{
    int n;
    std::cin >> n;
    std::vector<long long> a(n),b(n);
    for(int i = 0; i < n; i++)std::cin >> a[i];
    for(int i = 0; i < n; i++)std::cin >> b[i];

    std::vector<long long> plus;
    long long sum = 0;
    int num = 0;
    for(int i = 0; i < n; i++){
        long long dif = a[i] - b[i];
        if(dif < 0)sum -= dif, num++;
        else plus.push_back(dif);
    } 

    if(num == 0)std::cout << 0 << std::endl;
    else{
        int res = num;
        sort(plus.begin(),plus.end(),std::greater<long long>());

        long long p = 0;
        for(int i = 0; i < (int)plus.size(); i++){
            p += plus[i];
            ++res;
            if(p >= sum)break;
        }
        if(p >= sum)std::cout << res << std::endl;
        else std::cout << -1 << std::endl;
    }
}

Measured memory_bytes: 2936
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static long MOD = 1000000007;

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

        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt() - 1;
        }

        int count = 0;
        for(int i = 0; i < n - 1; i++) {
            if(p[i] == i) {
                int temp = p[i];
                p[i] = p[i + 1];
                p[i + 1] = temp;
                count++;
            }
        }

        if(n - 1 == p[n - 1]) {
            count++;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 51460
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

double n;
double dp[305][305][305];
int flag[305][305][305];
double f(int c1, int c2, int c3){
  if ( flag[c1][c2][c3] == 1 ){
    return dp[c1][c2][c3];
  }
  flag[c1][c2][c3] = 1;
  
  double ans = 1;
  if ( c1 > 0 ) ans += f(c1 - 1, c2, c3) * c1 / n;
  if ( c2 > 0 ) ans += f(c1 + 1, c2 - 1, c3) * c2 / n;
  if ( c3 > 0 ) ans += f(c1, c2 + 1, c3 - 1) * c3 / n;
  return dp[c1][c2][c3] = (ans / ((c1+c2+c3) / n));

}

double c[3];
int main() {
  cin >> n;
  rep(i,n){
    int a;
    cin >> a;
    ++c[a-1];
  }
  dp[0][0][0] = 0;
  flag[0][0][0] = 1;
  
  printf("%.10f\n",f(c[0], c[1], c[2]));
}


Measured memory_bytes: 329984
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.Map;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DCaracalVsMonster solver = new DCaracalVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class DCaracalVsMonster {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            long h = nl();
            TreeMap<Long, Long> tmap = new TreeMap<>();
            tmap.put(h, 1l);
            long ans = 0;
            while (tmap.size() > 0) {
                if (tmap.lastKey() == 1) {
                    ans += tmap.get(tmap.lastKey());
                    break;
                }
                long x = tmap.get(tmap.lastKey());
                long which = tmap.lastKey();
                tmap.put(which / 2, tmap.getOrDefault(which / 2, 0l) + 2 * x);
                ans += x;
                tmap.remove(which);
            }
            pn(ans);
        }

        long nl() {
            return in.nextLong();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 23380
S = input()
n = len(S)-1
ans = 0
for i in range(2**n):
    i = bin(i)[2:]
    i = '0'*(n-len(i))+i
    s = ''
    for j in range(n):
        if i[j]=='1':
            s = s+S[j]+'+'
        else:
            s = s+S[j]
    s = s+S[-1]
    s = s.split('+')
    for x in s:
        ans += int(x)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>
#include <cassert>

using ll = long long;
using ull = unsigned long long;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;

constexpr ll NOT_SPECIFIED_VALUE_MIN = INT64_MIN;
constexpr ll NOT_SPECIFIED_VALUE_MAX = INT64_MAX;


int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	ll tmpMax = 0;
	for (ll i = 0; i < n; i++) {
		ll tmp;
		cin >> tmp;
		if (i == 0) {
			tmpMax = tmp;
			continue;
		}
		ans += max(tmpMax - tmp, 0LL);
		if (tmpMax < tmp) {
			tmpMax = tmp;
		}

	}
	cout << ans << endl;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h> 
#define int long long
#define quickie ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int i=a; i<b; i++)
#define rep1(i, a, b) for(int i=a; i<=b; i++)
#define repp(i, a, b) for(int i=b-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define db double
#define mi map<int, int>
#define mc map<char, int>
#define ms map<string, int>
#define vi vector<int>
#define qi queue<int>
#define MI(x) power(x, mod-2)
#define test int t; cin >> t;
//#define mod 1000000007LL
#define mod 998244353 
using namespace std;
int power(int x, int y) ;
int gcd(int a, int b) ;

signed main() {
    quickie
    int n, b, c, d ;
    cin >> n >> b ;
    int a[n] ;
    rep(i,0 , n) cin >> a[i] ;
    int sum = 0, cnt = 0  ;
    rep(i, 0, n) {
        sum += a[i] ;
        if(sum > b) 
            break ;
        else cnt++ ;
    }
    cout << cnt+1 << "\n" ;
}

int power(int x, int y) {
    int res = 1; x %= mod;
    while (y > 0) {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res%mod;
}
 
int gcd(int a,int b){
    if(a==0) return b;
    return gcd(b%a,a);
}

Measured memory_bytes: 256
n = gets.to_i
v = gets.split.map(&:to_i)

even = Hash.new(0)
odd = Hash.new(0)
(0...n).step(2){|x| even[v[x]] += 1}
(1...n).step(2){|x| odd[v[x]] += 1}

e1, e2 = even.keys.sort_by{|x| even[x]}.reverse[0..1]
o1, o2 = odd.keys.sort_by{|x| odd[x]}.reverse[0..1]

answers = []
[e1, e2].product([o1, o2]) do |e, o|
  next if e == o
  answers << (n / 2 - even[e]) + (n / 2 - odd[o])
end

puts answers.min

Measured memory_bytes: 17272
num_nm=list(map(int,input().split()))
A=[[0 for iA in range(num_nm[0])]for jA in range(num_nm[1])]
b=[0 for ib in range(num_nm[1])]
for i in range(num_nm[0]):
	num_A=list(map(int,input().split()))
	for j in range(num_nm[1]):
		A[j][i]=num_A[j]
for k in range(num_nm[1]):
	num_b=int(input())
	b[k]=num_b
for l in range(num_nm[0]):
	ans_1=0
	for m in range(num_nm[1]):
		ans_1=ans_1+A[m][l]*b[m]
	print(ans_1)


Measured memory_bytes: 5956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

static const int N=30;
static const int W=10010;
int dp[N+1];

int main(){
    int n;
    while(cin>>n,n!=0){
     dp[0]=dp[1]=1;
     dp[2]=2;
     for(int i=3;i<=n;i++){
         dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
        }
    
      cout<<dp[n]/10/365+1<<endl;
    }
  return 0;
}



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

// #define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) iter(v) {pr(*it)} nl
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 1000000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

bool is_prime[MAXN];
void sieve(int maxn, vector<int> & primes)
{
    memset(is_prime, true, sizeof(is_prime));
    for (int i=2; i<=maxn; i++){
        if (is_prime[i]){
            for (int mult=2; i*mult<=maxn; mult++){
                is_prime[i*mult] = false;
            }
        }
    }
    for (int i=2; i<=maxn; i++){
        if (is_prime[i]) primes.push_back(i);
    }
    is_prime[0] = is_prime[1] = false;
}

int32_t main()
{
    #ifdef DEBUG
    //freopen("A.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    ll n,P;
    cin >> n >> P;
    if (n == 1)
        cout<<P<<endl;
    else {
        vector<int> primes;
        sieve(1000000,primes);
        
        ll ans = 1;
        for (ll p : primes) {
            int cnt = 0;
            while (P%p == 0) {
                cnt++;
                P /= p;
            }
            for (int i=0; i<cnt/n; i++)
                ans *= p;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2424
until (given = $<.gets.split.map(&:to_i)) == [0, 0]
  n, m = given
  bridges = m.times.map {$<.gets.split.map(&:to_i)}.sort_by(&:last)
  city = Array.new(n, false)
  city[0] = true
  appearance = 1
  total_cost = 0
  
  while appearance < n
    bridges.each_index do |i|
      a, b, cost = bridges[i]
      if city[a] or city[b]
        if !city[a]
          city[a] = true
          appearance += 1
          total_cost += cost
        elsif !city[b]
          city[b] = true
          appearance += 1
          total_cost += cost
        end
        bridges.delete_at(i)
        break
      end
    end
  end
  
  puts total_cost
end


Measured memory_bytes: 6896
from collections import deque
import sys

n = int(sys.stdin.readline())
q = deque()

for i in range(n):
    command = sys.stdin.readline()[:-1]
    if command[0] == 'i':
        q.appendleft(command[7:])
    elif command[6] == ' ':
        try:
            q.remove(command[7:])
        except Exception as e:
            pass
    elif command[6] == 'F':
        q.popleft()
    else:
        q.pop()

print(' '.join(q))

Measured memory_bytes: 71924
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }


bool f[10][10] = {};

int N, M;
int dfs(int mask, int cur, int cnt) {
	dump(mask, cur, cnt);
	if (cnt == N&&mask == pow(2, N) - 1)return 1;
	int ret = 0;
	for (int i = 0; i < N; i++) {
		if (mask&(1 << i))continue;
		if (!f[cur][i])continue;
		int d = dfs(mask | (1 << i), i, cnt + 1);
		if (d == 0)continue;
		ret += d;
	}
	dump(mask, cur, cnt, ret);
	return ret;
}

signed main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		a--, b--;
		f[a][b] = f[b][a] = true;
	}
	cout << dfs(1, 0, 1) << endl;
	return 0;
}

Measured memory_bytes: 384
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 n; 
vector<int> a;

void solve() {
	cin >> n;
    a.resize(n + 1);
    rep(i, n + 1) {
        cin >> a[i];
    }
    if(n == 0) {
        int ans = -1;
        if(a[0] == 0) ans = 0;
        if(a[0] == 1) ans = 1;
        cout << ans << endl;
        return;
    }
    vector<int> ma(n + 1, 0);
    ma[0] = 1;
    if(a[0] > 1) {
        cout << -1 << endl;
        return;
    }
    int now = ma[0] - a[0];
    for(int i = 1; i <= n; ++ i) {
        ma[i] = now * 2;
        if(a[i] > ma[i]) {
            cout << -1 << endl;
            return;
        }
        now = ma[i] - a[i];
        if(now > INF) {
            now /= 2;
        }
        //cerr << ma[i] << " ";
    }
    //cerr << endl;
    int ans = 0;
    int tmp = 0;
    for(int i = n; i >= 0; -- i) {
        tmp += a[i];
        if(tmp > ma[i]) tmp = ma[i];
        ans += tmp;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
signed main() {
 int a[100];
 int x=0;
  for(int i = 0; i < 5; i++){  
     cin >> a[i];
      x = x + a[i];} 
       cout << 15-x << endl;
 
}


Measured memory_bytes: 3508
function gcd(a,b)
    if b~=0 then
        return gcd(b,a%b)
    else
        return a
    end
end

n,x=io.read("*n","*n")
d=0
for i=1,n do
    y=math.abs(x-io.read("*n"))
    if y>0 then
        if d==0 then
            d=y
        else
            d=gcd(y,d)
        end
    end
end
print(d)

Measured memory_bytes: 760
#include<bits/stdc++.h>
#define lowbit(i) ((i)&(-(i)))
#define lson(i) ((i)<<1)
#define rson(i) ((i)<<1|1)
#define fi first
#define se second
#define MP(x,y) make_pair((x),(y))
using namespace std;

typedef long long ll;typedef unsigned long long ul;
typedef pair<int,int> pii;typedef pair<ll,ll> pll;
typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef queue<int> qii;typedef queue<pii> qpi;

const int inf=0x3f3f3f3f;
const int maxn=100007;

int n,m;

int main()
{
// 	freopen("","r",stdin);
// 	freopen("","w",stdout);
	scanf("%d%d",&n,&m);
	n<=8&&m<=8?puts("Yay!"):puts(":(");
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  int count =0;
  for(int i=1;i<=n;i++){
   int a;
   cin >> a;
   if(i%2==1 && a%2==1) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3620