akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight capacity, cost;
  int rev;
};
bool operator < (const Edge &e, const Edge &f) {
  return e.cost != f.cost ? e.cost > f.cost : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void add_edge(Graph &g, int s, int d, Weight cap, Weight cost) {
  g[s].push_back((Edge){s,d,cap,cost,g[d].size()});
  g[d].push_back((Edge){d,s,0,-cost,g[s].size()-1});
}

pair<Weight, Weight> minimumCostFlow3(Graph g, int s, int t) {
  const int n = g.size();
  pair<Weight, Weight> total; // (cost, flow)

  for (int F = INF; F > 0;) { // residual flow
    vector<Weight> d(n, INF); d[s] = 0;
    vector<int> pv(n), pe(n);
    bool update = 1;
    while(update) {
      update = 0;
      REP(i, n) if (d[i] < INF) REP(j, g[i].size()) {
          Edge &e = g[i][j];
          if (e.capacity > 0 && d[e.dst] > d[i] + e.cost) {
            d[e.dst] = d[i] + e.cost;
            pv[e.dst] = i; pe[e.dst] = j;
            update = 1;
          }
        }
    }
    if (d[t] == INF) break;
    Weight f = F;
    for (int u = t; u != s; u = pv[u])
      f = min(f, g[pv[u]][pe[u]].capacity);
    if (!f) break;
    for (int u = t; u != s; u = pv[u]) {
      total.first += f * g[pv[u]][pe[u]].cost;
      g[pv[u]][pe[u]].capacity -= f;
      g[u][g[pv[u]][pe[u]].rev].capacity += f;
    }
    F -= f;
    total.second += f;
  }
  return total;
}

int main() {
  int n;
  while(cin >> n, n) {
    Graph g(367);
    
    REP(i, n) {
      int a, b, w;
      cin >> a >> b >> w;
      add_edge(g, a-1, b, 1, -w);
    }
    REP(i, 366) {
      add_edge(g, i, i+1, 2, 0);
    }
    cout << -minimumCostFlow3(g, 0, 366).first << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
using namespace std;

int main(void) {
	int check_odd = 0, s0_number = 0, s1_number = 0, sw = 0;
	char colors[100000];
	cin >> colors;
	for (int i = 0; i < strlen(colors); i++) {
		if ((colors[i] - '0') == sw % 2) {
			s1_number++;
		}
		else {
			s0_number++;
		}
		sw++;
	}
	cout << min(s0_number, s1_number) << endl;
	return 0;
}

Measured memory_bytes: 384
import sys

def main():
    n, k, s = [int(i) for i in raw_input().strip().split()]
    if k == 0:
        foo = [s + 1 if s < 1000000000 else 999999999] * n
    elif s > (n - k):
        foo = [1] * (n - k) + [s - (n - k)] + [s] * (k - 1)
    else:
        foo = [s] * k + [n] * (n - k)
    foo = [str(i) for i in foo]
    sys.stdout.write('%s\n' % ' '.join(foo))

if __name__ == '__main__':
    main()

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

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (max(a,c) - min(a,c) <= d) cout << "Yes" << endl;
    else if (max(a,b) - min(a,b) <= d && max(b,c) - min(b,c) <= d) cout << "Yes" <<endl;
    else cout << "No" << endl;
        
    
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;
int bit[1000000+1];
int N;

void add(int x,int w){
    for(int i=x;i<=N;i += i&(-i)){
        bit[i]+=w;
    }
}

ll get_sum(int x){
    ll sum=0;
    for(int i=x;i>0;i-=i&(-i)){
        sum+=bit[i];
    }
    return sum;
}



int main() {
    int K;
    cin>>N>>K;
    ll a[N];
    ll sorted[N];
    REP(i,N){
        cin>>a[i];
        if(i>0){a[i]+=a[i-1];}
        a[i]-=K;
        sorted[i]=a[i];
    }
    sort(sorted,sorted+N);
    map<ll,int> toPress;
    //1~Nに圧縮
    REP(i,N){ toPress[sorted[i]]=i+1; }

    ll ans=0;
    REP(i,N){
        if(a[i]>=0){ans++;};
        ans+=get_sum(toPress[a[i]]);
        add(toPress[a[i]],1);
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;
typedef int64_t ll;

pair<int, int> rot0(pair<int, int> xy){
    return xy;
};

pair<int,int> rot90(pair<int, int> xy){
    return {-xy.second, xy.first};
};

pair<int,int> rot180(pair<int, int> xy){
    return {-xy.first, -xy.second};
};
pair<int,int> rot270(pair<int, int> xy){
    return {xy.second, -xy.first};
};

void input(vector<pair<int, int>>& sn){
    int m;
    cin >> m;
    int cx, cy;
    cin >> cx >> cy;
    sn.push_back({0, 0});
    int x, y;
    cin >> x >> y;
    auto rt = rot0;
    if(x - cx != 0){
        if(x - cx < 0) rt = rot180;
    }
    else{
        if(y - cy > 0) rt = rot270;
        else rt = rot90;
    }
    sn.push_back(rt({x-cx, y-cy}));
    for (int i = 2; i < m; ++i) {
        cin >> x >> y;
        sn.push_back(rt({x-cx, y-cy}));
    }
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& x){
    for(auto&& t: x)
        os << t << ' ';
    return os;
}

ostream& operator<<(ostream& os, const pair<int, int>& px){
    return os << '(' << px.first << ", " << px.second << ')';
}

void rev(const vector<pair<int, int>>& sn, vector<pair<int, int>>& rn){
    auto st = sn.back();
    int cx, cy, x, y;
    cx = st.first;
    cy = st.second;
    rn.push_back({0,0});
    st = sn[sn.size()-2];
    x = st.first;
    y = st.second;
    auto rt = rot0;
    if(x - cx != 0){
        if(x - cx < 0) rt = rot180;
    }
    else{
        if(y - cy > 0) rt = rot270;
        else rt = rot90;
    }
    rn.push_back(rt({x-cx, y-cy}));
    for (int i = sn.size() - 3; i >= 0; --i) {
        st = sn[i];
        x = st.first;
        y = st.second;

        rn.push_back(rt({x-cx, y-cy}));
    }
}


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

    int n;
    while(true){
        cin >> n;
        if(n == 0) break;
        vector<int> ans;
        vector<pair<int, int>> sn, snr;
        input(sn);
        rev(sn, snr);
//        cout << "sn :: " << sn << endl;
//        cout << "snr :: " << snr << endl;

        for (int i = 0; i < n; ++i) {
            vector<pair<int, int>> inn;
            input(inn);
//            cout << "inn :: " << inn << endl;
            if(inn.size() == sn.size()){
                bool can = true;
                bool rcan = true;
                for (int j = 0; j < sn.size(); ++j) {
                    if(can && inn[j] != sn[j]){
                        can = false;
                    }
                    if(rcan && inn[j] != snr[j]){
                        rcan = false;
                    }
                    if(!can && !rcan) break;
                }
                if(can || rcan) ans.push_back(i+1);
            }
        }

        for (auto &&a  : ans) {
            cout << a << '\n';
        }
        cout << "+++++" << endl;
    }
}



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

using namespace std;

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


int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s < t) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
implicit none
character(10) :: s
integer :: i,j,k,c,n
read *,s
n = len_trim(s)

if (s(1:1) /= 'A') then
   print '(a)','WA'
   stop
endif

i = scan(s(3:n-1),'C')
if (i == 0) then
   print '(a)','WA'
   stop
endif
i = i + 2
j = scan(s(i+1:n-1),'C')
if (j /= 0) then
   print '(a)','WA'
   stop
endif

do k = 2, i-1
   c = ichar(s(k:k))
   if (c < 97 .or. 122 < c) then
      print '(a)','WA'
      stop
   endif
enddo

do k = i+1, n
   c = ichar(s(k:k))
   if (c < 97 .or. 122 < c) then
      print '(a)','WA'
      stop
   endif
enddo

print '(a)','AC'
stop
end

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int A, B;
  std::cin >> A >> B;
  int now = 1, count = 0;
  while(now < B){
    now += A - 1;
    count++;
  }
  std::cout << count << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int a[21];
int n;


int f(int i, int sum)
{
  if (sum == 0) return 1;
  if (sum < 0) return 0;
  if (i >= n) return 0;
  return f(i + 1, sum) || f(i + 1, sum - a[i]);
}

int main() {
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int m;
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    int input;
    scanf("%d", &input);
    puts(f(0, input) ? "yes" : "no");
  }
  return 0;
}

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

int main(){
  int a,b,c,d;cin >> a >> b >> c >> d;
  if(abs(a-c)<=d)cout << "Yes";//Direct
  else if(abs(a-b)<=d&&abs(b-c)<=d)cout << "Yes";//Indirect
  else cout << "No";
}

Measured memory_bytes: 256
import bisect


class BTreeNode:
    def __init__(self):
        self.key = []
        self.child = []


class BTree:
    def __init__(self):
        self.root = BTreeNode()

    def search_higher(self, key):
        ptr = self.root
        ret = None
        while ptr.child:
            i = bisect.bisect_right(ptr.key, key)
            if i != len(ptr.key):
                ret = ptr.key[i]
            ptr = ptr.child[i]
        i = bisect.bisect_right(ptr.key, key)
        if i != len(ptr.key):
            ret = ptr.key[i]
        return ret

    def search_lower(self, key):
        ptr = self.root
        ret = None
        while ptr.child:
            i = bisect.bisect_left(ptr.key, key)
            if i != 0:
                ret = ptr.key[i - 1]
            ptr = ptr.child[i]
        i = bisect.bisect_left(ptr.key, key)
        if i != 0:
            ret = ptr.key[i - 1]
        return ret

    def insert(self, key):
        def insert_rec(ptr):
            b_size = 512
            if not ptr.child:
                bisect.insort(ptr.key, key)
                if len(ptr.key) == b_size * 2 - 1:
                        ret = BTreeNode()
                        ret.key = ptr.key[:b_size]
                        ptr.key = ptr.key[b_size:]
                        return ret
            else:
                i = bisect.bisect(ptr.key, key)
                temp = insert_rec(ptr.child[i])
                if temp is not None:
                    ptr.key.insert(i, temp.key.pop(-1))
                    ptr.child.insert(i, temp)
                    if len(ptr.child) == b_size * 2:
                        ret = BTreeNode()
                        ret.child = ptr.child[:b_size]
                        ptr.child = ptr.child[b_size:]
                        ret.key = ptr.key[:b_size]
                        ptr.key = ptr.key[b_size:]
                        return ret
            return None
        temp = insert_rec(self.root)
        if temp is not None:
            root = BTreeNode()
            root.key = [temp.key.pop(-1)]
            root.child = [temp, self.root]
            self.root = root

    def dump(self):
        def dump_rec(ptr, dep):
            for _ in range(0, dep):
                print("  ", end="")
            print(ptr.key)
            for c in ptr.child:
                dump_rec(c, dep + 1)
        dump_rec(self.root, 0)
        print("")


def main():
    n = int(input())
    p = list(map(int, input().split()))
    idx = [0] * n
    for i in range(0, n):
        idx[i] = i
    idx.sort(key=lambda i: - p[i])
    t = BTree()
    t.insert(-1)
    t.insert(n)
    ans = 0
    for i in idx:
        nex = t.search_higher(i)
        nexnex = t.search_higher(nex)
        pre = t.search_lower(i)
        prepre = t.search_lower(pre)
        if prepre != None:
            ans += p[i] * (pre - prepre) * (nex - i)
        if nexnex != None:
            ans += p[i] * (i - pre) * (nexnex - nex)
        t.insert(i)
    print(ans)


main()


Measured memory_bytes: 16208
/*
 * atcoder/abc122/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/* Mod */
#define MOD 1000000007
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%MOD+MOD)%MOD){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%MOD+MOD)%MOD; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=MOD) x-=MOD; return *this;}
  mint& operator-=(const mint& a){ if((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=MOD; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
ostream & operator << (ostream & out, mint const & v) {
  out << v.x;
  return out;
}

string S = "ACGT";
int N;
ll dp[101][5][5][5];

int idx(char c) {
  if (c == 'A') return 0;
  if (c == 'C') return 1;
  if (c == 'G') return 2;
  return 3;
}

mint rec(string s = "") {
  int size = s.size();
  ll &cc = dp[size][size >= 3 ? idx(s[size-3]) : 4][size >= 2 ? idx(s[size-2]) : 4][size >= 1 ? idx(s[size-1]) : 4];
  if (~cc) return cc;
  if (size == N) {
    // cout << s << endl;
    return cc = 1;
  }
  mint count = 0;
  loop(i,0,4) {
    if (size < 2) {
      count += rec(s + S[i]);
      continue;
    }

    if (size >= 2) {
      if (s[size-2] == 'A' and s[size-1] == 'G') {
        if (S[i] != 'C') count += rec(s + S[i]);
      }
      else if (s[size-2] == 'A' and s[size-1] == 'C') {
        if (S[i] != 'G') count += rec(s + S[i]);
      }
      else if (s[size-2] == 'G' and s[size-1] == 'A') {
        if (S[i] != 'C') count += rec(s + S[i]);
      }
      else if (size >= 3 and s[size-3] == 'A' and s[size-2] != 'G' and s[size-1] == 'G') {
        if (S[i] != 'C') count += rec(s + S[i]);
      }
      else if (size >= 3 and s[size-3] == 'A' and s[size-2] == 'G' and s[size-1] != 'C') {
        if (S[i] != 'C') count += rec(s + S[i]);
      }
      else count += rec(s + S[i]);
    }
  }
  return cc = count.x;
}

void solve() {
  cin >> N;
  loop(i,0,101) loop(j,0,5) loop(k,0,5) loop(l,0,5) dp[i][j][k][l] = -1;
  cout << rec() << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 384
import sys
N,Y=input().split(' ')
N=int(N)
Y=int(Y)
tmp=Y
x=int(tmp/10000)
tmp-=x*10000
y=int(tmp/5000)
tmp-=y*5000
z=int(tmp/1000)

while True:
  sum=x+y+z
  if(sum==N):break
  elif(N-sum>=4 and y>=1):
    y-=1
    z+=5
  elif(N-sum>=4 and x>=1):
    x-=1
    y+=2
  elif(N-sum<4 and x>=1):
    x-=1
    y+=2
  else:
    print('-1 -1 -1')
    sys.exit()
print(x,y,z)


Measured memory_bytes: 3064
#include <cstdio>
using namespace std;
int a[105];
int main(){
	int n,k,m,t,c=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;++i){
		scanf("%d",&m);
		for(int j=1;j<=m;++j){
			scanf("%d",&t);
			++a[t];
		}
	}
	for(int i=1;i<=n;++i){
		if(a[i]==0)++c;
	}
	printf("%d\n",c);
	return 0; 
}


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

int main() {
  int n;
  cin>>n;
  long long sum = 0;
  for (int i=1; i<=n; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    sum += i;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

int main() {
    unsigned long long n;
    unsigned long long sum2 = 0;
    unsigned long long sum5 = 0;
    
    cin >> n;
    if (n % 2 == 0) {
        {
            unsigned long long s = n;
            while (s > 0) {
                sum2 += s / 2;
                s /= 2;
            }
        }
        {
            unsigned long long s = n;
            while (s > 0) {
                sum5 += s / 10;
                s /= 5;
            }
        }
    }
    
    cout << min(sum2, sum5) << endl;

    return 0;
}


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

int main()
{
	float a, b, c, d, e, f, x, y;

	while (cin >> a >> b >> c >> d >> e >> f) {
		if (a == 0) {
			x = 0;
			y = c / b;
		}else if (b == 0) {
			x = c / a;
			y = 0;
		}else {
			x = (c * e - b * f) / (a * e - b * d);
			if (0 == x) { x = 0; }
			y = (c - a * x) / b;
		}
		cout << fixed << setprecision(3) << x << ' ' << y << endl;
	}
    return 0;
}

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		//入力処理
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());
		int r=Integer.parseInt(st.nextToken());
		int c=Integer.parseInt(st.nextToken());

		//配列の作成・入力
		int[][] ary=new int[r][c];
		for(int j=0;j<r;j++) {
			StringTokenizer sa=new StringTokenizer(br.readLine());
			for(int i=0;i<c;i++) {
				int d=Integer.parseInt(sa.nextToken());
				ary[j][i]=d;
			}
		}

		//出力する配列作成
		int[][] Opary=new int[r+1][c+1];
		int sum=0;
		for(int j=0;j<r+1;j++) {
			for(int i=0;i<c+1;i++) {
				if(i==c && j==r) {
					for(int k=0;k<=r;k++) {
						sum=sum+Opary[k][i];
					}
					Opary[j][i]=sum;
					break;
				}
				if(j==r) {
					for(int k=0;k<=r;k++) {
						sum=sum+Opary[k][i];
					}
					Opary[j][i]=sum;
					sum=0;
					continue;
				}
				if(i==c && j!=r) {
					Opary[j][i]=sum;
					sum=0;
					continue;
				}
				Opary[j][i]=ary[j][i];
				sum=sum+Opary[j][i];
			}
		}

		//配列の出力
		for(int j=0;j<r+1;j++) {
			for(int i=0;i<c+1;i++) {
				System.out.print(Opary[j][i]);
				if(i==c) {
					break;
				}
				System.out.print(" ");
			}
			System.out.println();
		}
	}

}



Measured memory_bytes: 33352
INF = 10 ** 9
N, M = map(int,input().split())
dp = [[INF for i in range(1 << N)] for j in range(M+1)]
dp[0][0] = 0
for i in range(M):
    a, b = map(int,input().split())
    c = list(map(int,input().split()))
    k = 0
    for l in c:
        k += 1 << (l - 1)
    for j in range(1 << N):
        if dp[i][j] != INF:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j])
            dp[i+1][j | k] = min(dp[i+1][j | k], dp[i][j] + a)

if dp[-1][-1] == INF:
    print(-1)
else:
    print(dp[-1][-1])

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

bool is_prime(ll N)
{
    if (N < 2)
        return false;
    for (ll i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
            return false;
    }
    return true;
}

map<ll, ll> soinsubunkai(ll N)
{
    map<ll, ll> res;
    ll num = N;
    for (ll i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            ll j = N / i;
            if (is_prime(i))
            {
                ll a = 0;
                while (num % i == 0)
                    a++, num /= i;
                res[i] = a;
            }
            if (is_prime(j))
            {
                ll a = 0;
                while (num % j == 0)
                    a++, num /= j;
                res[j] = a;
            }
        }
    }
    return res;
}

void solve(void)
{
    ll n, p;
    cin >> n >> p;
    map<ll, ll> v = soinsubunkai(p);
    if (v.size() == 0)
        cout << p << endl;
    else
    {
        ll ans = 1;
        for (auto i : v)
        {
            while (i.second >= n)
                ans *= i.first, i.second -= n;
        }
        cout << ans << endl;
    }
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

int number = 0;

void selection_sort (vector<int> &a, size_t n) {
	for (int i = 0; i < n; i++) {
		int min_j = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[min_j]) min_j = j;
		}
		if (i != min_j) {
			swap(a[i], a[min_j]);
			number++;
		}
	}
}

int main() {
	size_t n;
	cin >> n;
	vector<int> a(n);
	for (size_t i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	selection_sort(a, n);
	
	for (size_t i = 0; i < n; i++) {
		cout << a[i] << " \n"[i + 1 == n];
	}
	
	cout << number << '\n';
	
	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>

int main(void)
{
	int s[12];
	int c[12];
	
	while (1){
		int n;
		int count;
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (int i = 0; i < n; i++){
			scanf("%d", &s[i]);
		}
		
		count = 0;
		do {
			for (int i = 0; i < n; i++){
				c[i] = 0;
				for (int j = 0; j < n; j++){
					if (s[i] == s[j]){
						c[i]++;
					}
				}
			}
			if (memcmp(s, c, sizeof(int) * n) == 0) break;
			memcpy(s, c, sizeof(s));
			
			count++;
		} while (1);
		
		printf("%d\n", count);
		printf("%d", s[0]);
		for (int i = 1; i < n; i++){
			printf(" %d", s[i]);
		}
		puts("");
	}
	
	return (0);
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A<C && C<B){
    cout << "Yes" << endl;
  }
  else if(B<C && C<A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True
def fact(n):
    arr = [[i,1] for i in range(2,n+1)]
    for i in range(2,n+1):
        for j in range(2,n+1):
            tmp=arr[j-2][0]
            if tmp%i==0 and tmp//i>1:
                while tmp%i==0:
                    arr[i-2][1]+=1
                    tmp //= i
                    arr[j-2][1]=0
    return arr
n=int(input())
x=fact(n)
cnt=1
for i in range(n-1):
    if is_prime(i+2):
        cnt*=x[i][1]+1
        cnt%=1000000007
print(cnt)

Measured memory_bytes: 3064
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

#define MAXN 300
int g[MAXN][MAXN];

const int oo = 100000;

int max_flow(int n, int source, int sink) {
  int tot = 0;
  
  while (true) {
    queue<int> Q;
    vector<int> parent(n+1, -1);
    vector<bool> seen(n+1, false);
    
    Q.push(source);
    seen[source] = true;
    while (!Q.empty()) {
      int u = Q.front(); Q.pop();
      for (int v = 0; v <= n; v++) {
        if (g[u][v] && !seen[v]) {
          seen[v] = true;
          parent[v] = u;
          Q.push(v);
        }
      }
    }
    
    if (!seen[sink]) {
      break;
    }
    
    int cur = sink, cap = oo;
    while (parent[cur] != -1) {
      cap = min(cap, g[parent[cur]][cur]);
      cur = parent[cur];
    }
    
    cur = sink;
    while (parent[cur] != -1) {
      g[parent[cur]][cur] -= cap;
      g[cur][parent[cur]] += cap;
      cur = parent[cur];
    }
    
    tot += cap;
  }
  
  return tot;
}

int main(void) {
  int h, w;
  scanf("%i %i", &h, &w);
  
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      char c; scanf(" %c", &c);
      if (c == 'o') {
        g[i][j+h] = 1;
        g[j+h][i] = 1;
      } else if (c == 'S') {
        g[i][j+h] = oo;
        g[j+h][i] = oo;
        g[0][i] = oo;
      } else if (c == 'T') {
        g[i][j+h] = oo;
        g[j+h][i] = oo;
        g[i][h+w+1] = oo; 
      }
    }
  }
  
  int tot = max_flow(h+w+1, 0, h+w+1);
  printf("%i\n", tot < oo ? tot : -1);
  
  return 0;
}

Measured memory_bytes: 512
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

f b cal mon [] = div cal mon
f b cal mon (x:xs) = if (ncal*mon > cal*nmon) then f b ncal nmon xs else div cal mon
  where
    ncal = cal + x
    nmon = mon + b

main = do
    n <- getInt
    [a,b] <- getInts
    c <- getInt
    ds <- replicateM n getInt
    print $ f b c a $ sortBy (flip compare) ds
    return ()

Measured memory_bytes: 4132
_  = gets.to_s.split.map(&:to_i)
a  = gets.to_s.split.map(&:to_i).sort
bcs = $<.read.split.map(&:to_i).each_slice(2).sort_by{|b,c| c}

ans = 0

b, c = bcs.pop
a.each do |k|
  
  if b.nil?
    ans += k
  elsif k < c
    ans += c
    b -= 1
    b,c = bcs.pop if b == 0
  else
    ans += k
  end
end

puts ans

Measured memory_bytes: 29536
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(void){
    map<string, int> m;
    string s;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        auto f=m.find(s);
        if(f==m.end()){
            m[s]=1;
        }else{
            m[s]++;
        }
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 19100
d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(d)]
lastd = [0] * 26

for i in range(d):
    ans = 0
    tmp = 0
    for j in range(26):
        if tmp < s[i][j] + (i - lastd[j] + 1) * c[j]:
            tmp = s[i][j] + (i - lastd[j] + 1) * c[j]
            ans = j + 1
    print(ans)
        
    

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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    
    if (S == "Y"){
      cout << "Four" << endl;
      break;
    }
    
    if (i == N - 1 && S != "Y"){
      cout << "Three" << endl;
    }
  }
      
  
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
#define N
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
int main()
{
	int i,n;
	scanf("%d",&n);
	printf("%d\n",(n/2)*(n-n/2));
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++) cin >> v[i];
	vector<int> count1(100002);
	vector<int> count2(100002);
	int max1=0, max2=0, max3=0, max4=0, flag1, flag2;
	for(int i=1; i<n; i=i+2) count1[v[i]]++;
	for(int i=0; i<n; i=i+2) count2[v[i]]++;
	for(int i=0; i<100002; i++){
		if(max1 < count1[i]){
			max2 = max1;
			max1 = count1[i];
			flag1 = i;
		}else if(max2 < count1[i]){
			max2 = count1[i];
		}
		if(max3 < count2[i]){
			max4 = max3;
			max3 = count2[i];
			flag2 = i;
		}else if(max4 < count2[i]){
			max4 = count2[i];
		}
	}
	int ans;
	if(flag1==flag2){
		cout << n - max(max1 + max4, max2 + max3) << endl;
	}else{
		cout << n - (max1 + max3) << endl;
	}
	for(int i=0; i<count1.size(); i++){
		if(max1 < count1[i]){
			max1 = count1[i];
		}
	}
	return 0;
}


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

int main()
{
    long long a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if(a<b)
    {
        a=a+v*(t);
    b=b+w*(t);
    if(a>=b)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    }
    else if(b<a)
    {
        b=b-w*t;
        a=a-v*t;
        if(a<=b)
          cout<<"YES"<<endl;
        else
         cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

pub fn main() {
    let n: i32 = read();
    let mut v: Vec<i32> = read_vec();
    v.reverse();
    for (i, e) in v.iter().enumerate() {
        print!("{}", e);
        if i != v.len() - 1 {
            print!(" ");
        }
    }
    println!();
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a;
	b=a%10;
	a=a/10;
	c=a%10;
	a=a/10;
	if(a==7||b==7||c==7)
	{
		cout<<"Yes";
		return 0;
	}
	else
	{
		cout<<"No";
		return 0;
	} 
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r=nxt();
    cout<<r*r<<endl;

    return 0;   
}


 
 


Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll sx, sy, tx, ty;

int main() {
    fast_io; cout_precision;
    cin >> sx >> sy >> tx >> ty;
    tx -= sx; ty -= sy;
    cout << string(tx, 'R') << string(ty + 1, 'U') << string(tx + 1, 'L') << string(ty + 1, 'D') << 'R';
    cout << string(ty, 'U') << string(tx + 1, 'R') << string(ty + 1, 'D') << string(tx + 1, 'L') << 'U';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    string a, b; cin >> a >> b;
    int n = a.size(); int m = b.size();
    if(n > m) cout << "GREATER";
    else if(n < m) cout << "LESS";
    else {
        if(a==b) cout << "EQUAL";
        rep(i, n) {
            if(a[i]-'0' < b[i]-'0') {
                cout << "LESS";
                return 0;
            }
            else if(a[i]-'0' > b[i]-'0') {
                cout << "GREATER";
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>

int main() {
    int a,b; std::cin >> a >> b;
    int l1 = (int)ceil(a * 12.5);
    int r1 = (a + 1) * 12.5;
    if(r1 == (int)r1) r1 = (int)r1 - 1;
    else r1 = (int)floor(r1);
    int l2 = (int)ceil(b * 10.0);
    int r2 = (b + 1) * 10.0;
    if(r2 == (int)r2) r2 = (int)r2 - 1;
    else r2 = (int)floor(r2);
    //std::printf("l1 = %d l2 = %d\n",l1,l2);
    //std::printf("r1 = %d r2 = %d\n",r1,r2);
    int l = std::max(l1,l2);
    int r = std::min(r1,r2);
    if(l > r) std::puts("-1");
    else std::printf("%d\n",l);
    return 0;
}

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

#define infi            5e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
// inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle
    //freopen("in.txt", "r", stdin);//#endif
    
    ll n=rr,m=rr;
    ll nn=2*n, ans=0;

    if(nn>m){
        ans = m/2;
    }else{
        ans = n;
        m-=nn;
        ans += (m/4);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
typedef long long ll;
//#define p 1000000007

ll modpow(ll a,ll b,ll c)
{
  ll re=1;
  while(b>=1){
    if(b&1) re=re*a%c;
    a=a*a%c;
    b=b>>1;
  }

  return re;
}
void main(void)
{
  ll N,K,ans=0;
  ll p=1000000007;
  scanf("%lld %lld",&N,&K);
  ll T[K+1];
  for(ll i=K;i>=1;i--){
    T[i]=modpow((K/i),N,p);
    for(ll j=2;j<=(K/i);j++){
      T[i]-=T[i*j];
    }
  }

  for(ll i=i;i<=K;i++){
    ans+=(i*T[i])%p;
  }
  
  printf("%lld",ans%p);

}

Measured memory_bytes: 2500
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int n;
int a[N], b[N];
map<pair<int, int>, int> m;

pair<int, int> get(int i)
{
	int x = a[i], y = b[i];
	if(x == 0 && y == 0)
		return {x, y};
	int g = __gcd(x, y);
	x /= g;
	y /= g;
	if(y < 0)
		x *= -1, y *= -1;
	if(x == 0)
		y = 1;
	if(y == 0)
		x = 1;
	return {x, y};
}

pair<int, int> opp(pair<int, int> p)
{
	int x = p.second, y = p.first;
	x *= -1;
	if(y < 0)
		x *= -1, y *= -1;
	if(x == 0)
		y = 1;
	if(y == 0)
		x = 1;
	return {x, y};
}

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i];
		m[get(i)]++;
	}
	int ans = 1;
	map<pair<int, int>, int> vis;
	for(auto &it:m)
	{
		if(vis[it.first])
			continue;
		pair<int, int> x = {0, 0};
		if(it.first == x)
			continue;
		pair<int, int> p = opp(it.first);
		if(m.count(p))
		{
			vis[p] = 1;
			int x = it.second, y = m[p];
			ans *= (pow(2LL, x, MOD) + pow(2LL, y, MOD) - 1);
			ans %= MOD;
		}
		else
		{
			ans *= pow(2LL, it.second, MOD);
			ans %= MOD;
		}
	}
	ans -= 1;
	ans += m[{0, 0}];
	ans += MOD;
	ans %= MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 31692
n,p = map(int, input().split())

a = list(map(int, input().split()))

odd = 0
even = 0
for x in a:
    if x % 2 == 0:
        even += 1
    else:
        odd += 1
ans = 0
if odd == 0:
    if p == 1:
        ans = 0
    else:
        ans = 2**n    
else:
    ans = 2**(n-1)

print(ans)

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

#define ll long long int
#define llu unsigned long long int
#define f(n) for(ll i=0;i<n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define mod 1000000007

using namespace std;

int main()
{
	//#ifdef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	std::ios_base::sync_with_stdio(false);

	ll a,b,m;
	cin>>a>>b>>m;
	ll x[a+1],y[b+1],z[m+1],minr=10000000,minm=100000000;
	f(a)
	{
		cin>>x[i];
		minr=min(x[i],minr);
	}
	f(b)
	{
		cin>>y[i];
		minm=min(y[i],minm);
	}
	ll minn=100000000;
	f(m)
	{
		ll q,w,e;
		cin>>q>>w>>e;
		ll s=0;
		s=x[q-1]+y[w-1]-e;
		if(minn>s)
		{
			minn=s;
		}
	}

	cout<<min(minn,minm+minr);
	return 0;
}

Measured memory_bytes: 1792
use whiteread::parse_line;

fn main() {
    let (a, b): (i32, i32) = parse_line().unwrap();
    let mut i: i32 = 1;
    let mut same: bool = false;
    while i <= 1000 {
        let aa: i32 = ((i as f32) * 0.08) as i32;
        let bb: i32 = ((i as f32) * 0.1) as i32;

        if aa == a && bb == b {
            println!("{:?}", i);
            same = true;
            break;
        }

        if aa > a || bb > b{
            break;
        }

        i = i + 1;
    }

    if !same {
        println!("-1");
    }
}


Measured memory_bytes: 2160
/// a.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < ll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    ll n,m;
    fi>>n>>m;
    ll cnt = m / 3;
    ll ans = 0;
    auto f = [&](auto a,auto b)
    {
        return min(a,b / 2);
    };
    ans += min(n,m / 2);
    m -= 2 * ans;
    ans += m / 4;
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


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


int main() {
	int n, m,ans=0;
	cin >> n >> m;
	if (n <=1);
	else ans = n * (n - 1) / 2;
	if (m <= 1);
	else ans += m * (m - 1) / 2;
	cout << ans;
}

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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    int r;
    cin >> r;
    cout << setprecision(7) << fixed << (dl)2*3.14159265358979323*r << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

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

int main(void){

	int max,num;
	cin>>max>>num;

	int count=0;
	for(int i=0;i<=max;i++){
		for(int j=0;j<=max;j++){
			if(0<=(num-(i+j))&&(num-(i+j))<=max){
			        count++;
			}
		}
	}

	cout<<count<<endl;

}



Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
public class Input
{
    string[] stock = new string[0];
    int index = 0;
    void CheckStock()
    {
        if (index == stock.Length)
        {
            stock = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            index = 0;
        }
    }
    public string Next()
    {
        CheckStock();
        return stock[index++];
    }
    public char NextChar()
    {
        CheckStock();
        char val = stock[index][0];
        if (stock[index].Length == 1)
        {
            ++index;
        }
        else
        {
            stock[index] = stock[index].Remove(0, 1);
        }
        return val;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
}
class MainClass
{
    static int[,] mv = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

    void Calc()
    {
        Input inp = new Input();
        decimal n, k, ans = 0;
        n = inp.NextInt();
        k = inp.NextInt();
        for(decimal i = 1, j; i <= n; ++i)
        {
            j = 1;
            for (; i * j < k; j *= 2) {}
            ans += 1m / n / j;
        }
        Console.WriteLine(ans);
    }
    static void Main()
    {
        new MainClass().Calc();
    }
}

Measured memory_bytes: 11220
#include <stdio.h>
 
int main(void){
	int a, b;

	scanf("%d %d", &a, &b);
	if(a == b){
		printf("a == b\n");
	}else if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}

	return 0;
}

Measured memory_bytes: 1804
#include<stdio.h>
#include<math.h>
int main()
{
	int k,h;
	double x=0,y=0,mk=0;
	do{
		scanf("%d,%d",&h,&k);
		x+=sin(mk*1.0/180*atan(1.0) * 4.0)*h;
		y+=cos(mk*1.0/180*atan(1.0) * 4.0)*h;
		mk+=k;
	}while(h!=0||k!=0);
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

Measured memory_bytes: 2872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl



int32_t main()
{
    fast;
    int n;cin>>n;
    int *arr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    arr[0]-=1;
    for(int i=1;i<n;i++)
    {
        if(arr[i]<arr[i-1])
        {
            cout<<"No";
            return 0;
        }
        if(arr[i]==arr[i-1])
            continue;
        arr[i]-=1;
    }
    cout<<"Yes";
}

Measured memory_bytes: 1024
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str1,str2;
    cin>>n>>a;
    vector<ll> v(n+1);
    rep(i,n)   cin >> v[i];
    rep(i,n+1){
        if(sum<=a)f++;
        sum+=v[i];
    }
    cout<<f<<endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.chomp.split(' ').map{|i| i.to_i }

len = h.length
(len - 1).times{|i|
  j = len - i - 1
  if h[j - 1] > h[j]
    h[j - 1] -= 1
    if h[j - 1] > h[j]
      puts 'No'
      exit
    end
  end
}
puts 'Yes'


Measured memory_bytes: 9604