akhauriyash/Code-Regression huggingface dataset:
class Node
  def initialize(id)
    @id = id
    @neighbors = []
    @visited = false
    @cost = -1
  end

  attr_accessor :id, :neighbors, :visited, :cost
end

def calc(nodes)
  nodes[0].visited = true
  nodes[0].cost = 0
  while (true) do
    visited_nodes = nodes.find_all {|key, value| value.visited == true}.map {|array| array[1]}
    return if visited_nodes.size == nodes.size

    next_node = [-1, -1]
    visited_nodes.each do |v_node|
      v_node.neighbors.each do |neighbor|
        n_id = neighbor[0]
        n_dist = neighbor[1]
        if nodes[n_id].visited == false then
          cand_node = [n_id, v_node.cost + n_dist]
          if next_node[1] < 0 || next_node[1] > cand_node[1] then
            next_node = cand_node
          end
        end
      end
    end

    next_id = next_node[0]
    next_cost = next_node[1]
    nodes[next_id].visited = true
    nodes[next_id].cost = next_cost

    nodes[next_id].neighbors.each do |neighbor|
      n_id = neighbor[0]
      n_dist = neighbor[1]
      if nodes[n_id].visited then
        cand_cost = next_cost + n_dist
        nodes[n_id].cost = cand_cost if nodes[n_id].cost > cand_cost
      end
    end
  end
end


# main
n = gets.chomp.to_i
vertices = {}
n.times do
  inputs = gets.chomp.split.map(&:to_i)
  neighbors = []
  2.step(2+inputs[1]*2-1, 2) do |i|
    neighbors << [inputs[i], inputs[i+1]]
  end
  vertices[inputs[0]] = Node.new(inputs[0])
  vertices[inputs[0]].neighbors = neighbors
end

calc(vertices)
vertices.sort_by {|key, value| key}.each do |id, node|
  puts "#{node.id} #{node.cost}"
end

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

int main(){
    int k=0,s=0;
    int count = 0;

    cin >> k >> s;

    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-i-j < 0 || s-i-j > k){
                continue;
            }else{
                count++;
            }
        }
    }
    cout << count <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
template<typename T>
struct Edge {
    int from, to;
    T cost;
    Edge(int from, int to, T cost) {
        this->from = from;
        this->to = to;
        this->cost = cost;
    }
};
bool operator == (Edge<int> e1, Edge<int> e2) {
    return e1.from == e2.from &&
            e1.to == e2.to &&
            e1.cost == e2.cost;
}
template<typename T>
using Edges = std::vector<Edge<T>>;
template<typename T>
using Graph = std::vector<Edges<T>>;
std::vector<int> bellman_ford(const Graph<int> &g, int s) {
    int sz = g.size();
    const int inf = INT_MAX;
    std::vector<int> dist(sz, inf);
    dist[s] = 0;
    for(int i=0;i<sz-1;++i) {
        for(int j=0;j<sz;++j) {
            if(dist[j] == inf) continue;
            for(int k=0;k<(int)(g[j].size());++k) {
                Edge<int> e = g[j][k];
                dist[e.to] = std::min(dist[e.to], dist[e.from] + e.cost);
            }
        }
    }
    for(int i=0;i<sz;++i) {
        if(dist[i] == inf) continue;
        for(int j=0;j<(int)(g[i].size());++j) {
            Edge<int> e = g[i][j];
            if(dist[e.from] + e.cost < dist[e.to]) return std::vector<int>(1, -1);
        }
    }
    return dist;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m, p; cin >> n >> m >> p;
  Graph<int> g(n);
  for(int i=0;i<m;++i) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    g[a].push_back(Edge<int>(a, b, -(c-p)));
  }
  vll dist(n, INT_MAX);
  dist[0] = 0;
  for(int i=0;i<n-1;++i) {
    for(int j=0;j<n;++j) {
      if(dist[j] == INT_MAX) continue;
      for(int k=0;k<(int)(g[j].size());++k) {
        auto e = g[j][k];
        dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
      }
    }
  }
  map<int, bool> nega;
  for(int i=0;i<n;++i) {
    if(dist[i] == INT_MAX) continue;
    for(int j=0;j<(int)(g[i].size());++j) {
      auto e = g[i][j];
      if(dist[e.to] > dist[e.from] + e.cost) {
        nega[e.from] = true;
        nega[e.to] = true;
      }
    }
  }
  for(int i=0;i<n-1;++i) {
    for(int j=0;j<n;++j) {
      if(dist[j] == INT_MAX || !nega[j]) continue;
      for(int k=0;k<(int)(g[j].size());++k) {
        nega[g[j][k].to] = true;
      }
    }
  }
  if(nega[n-1]) {
    cout << -1 << endl;
  } else {
    cout << max(0ll, -dist[n-1]) << endl;
  }
}


Measured memory_bytes: 512
n = gets.to_i
  nums = gets.split.map(&:to_i)
  app = true
  nums.each do |num|
    if num%2 == 0
      if num%3 != 0 && num%5 != 0
        app = false
      end
    end
  end
  if app
    puts "APPROVED"
  else
    puts "DENIED"
  end

Measured memory_bytes: 1788
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
long long p[5001]={0};
int main(){
while(1){
memset(p,0,sizeof(p));
long long n,i,j,t,a;
cin>>n;
if(n==0)break;
for(i=1;i<=n;i++){
cin>>a;
p[i]=p[i-1]+a;
}
t=-999999999;
for(i=1;i<=n;i++){
	for(j=0;j<i;j++){
t=max(t,p[i]-p[j]);
}
}
cout<<t<<endl;
}
return 0;
}

Measured memory_bytes: 3012
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
int MAX_N = 100005;
int n, M;
priority_queue<int> q;
void input() {
    RI(n, M);
    REP(i, n) {
    	int a; RI(a);
    	q.push(a);
    }
}

void solve() {
	while(M > 0) {
		int t = q.top(); q.pop();
		q.push(t/2);
		M--;
	}
	LL ans = 0;
	while(!q.empty()) {
		ans = ans + q.top();
		q.pop();
	}
	printf("%lld\n", ans);
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}


Measured memory_bytes: 892
import math
 
def kock(n, x1, y1, x2, y2):
    if n == 0:
        return
 
    angle = math.radians(60)
 
    sx = (2*x1 + x2)/3
    sy = (2*y1 + y2)/3
    tx = (2*x2 + x1)/3
    ty = (2*y2 + y1)/3
    ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
    uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy
 
    kock(n-1, x1, y1, sx, sy)
    print sx, sy
    kock(n-1, sx, sy, ux, uy)
    print ux, uy
    kock(n-1, ux, uy, tx, ty)
    print tx, ty
    kock(n-1, tx, ty, x2, y2)
 
n = input()
 
p1x = 0.
p1y = 0.
p2x = 100.
p2y = 0.
 
print p1x, p1y
kock(n, p1x, p1y, p2x, p2y)
print p2x, p2y

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error_old(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
#ifdef DEBUG
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {it++;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); }
#else
#define error(args...)
#endif
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){
    int n;
    cin >> n;
    vi arr(n);
    rep(i, n){
        cin >> arr[i];
    }
    vi prefSum(n + 1, 0);
    rep(i, n){
        prefSum[i + 1] = prefSum[i] + arr[i];
    }

    vector<vi> dp(n, vi(n, __LONG_LONG_MAX__));
    repA(len, 1, n){
        repA(l, 0, n - len){
            int r = l + len - 1;
            if(l == r){
                dp[l][r]= 0;
            }else{
                repA(k, l, r - 1){
                    dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + prefSum[r + 1] - prefSum[l]); 
                }
            }

        }
    }
    cout << dp[0][n - 1] << endl;
}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 1536
import java.util.*;
import java.io.*;
import java.lang.*;

 class Main{

    static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    static StringBuilder sb = new StringBuilder("");
    static StringTokenizer stk = new StringTokenizer("");
    static Map<Integer,ArrayList<Integer>> adjList = new HashMap<>();
    static int[] dp ;
    static int N = 0;
    static int M = 0;
    static int maxValue = 0;

    public static  void main(String args[]){
        try{
            stk = new StringTokenizer(bf.readLine());
             N = Integer.parseInt(stk.nextToken());
             M = Integer.parseInt(stk.nextToken());
             dp =  new int[N+1];

            for(int i=0;i<M;i++){
                stk = new StringTokenizer(bf.readLine());
                int from = Integer.parseInt(stk.nextToken());
                int to = Integer.parseInt(stk.nextToken());

                if(adjList.containsKey(from)){
                    adjList.get(from).add(to);
                }else{
                    ArrayList<Integer> al = new ArrayList<>();
                    al.add(to);
                    adjList.put(from,al);
                }
            }

            for(int i=0;i<=N;i++)
                dp[i] = -1;

            solver();

        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public static void solver(){
        
        for(int i=1;i<=N;i++){
            if(dp[i] == -1)
                maxValue = Math.max(maxValue , dfs(i));
            else
                maxValue = Math.max(maxValue,dp[i]);
        }

        // for(int i=1;i<=N;i++){
        //     System.out.print(dp[i]+"  ");
        // }

        System.out.println(maxValue);
    }


    public static int dfs(int src ){

        if(adjList.get(src) == null || adjList.get(src).size() == 0){
            return 0;
        }

        //check where things are starting 
       
        for(int i=0;i < adjList.get(src).size();i++){
            
            if(dp[adjList.get(src).get(i)] > -1)
                dp[src] = Math.max(dp[src], 1+ dp[adjList.get(src).get(i)]) ;
            else
                dp[src] =  Math.max(dp[src],1 + dfs(adjList.get(src).get(i))); //maxlength

        }

        return dp[src];   

    }

}

Measured memory_bytes: 64040
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
  long long int N;
  long long int tmp=0,fx=0;
  scanf("%d",&N);
  tmp=N;
  while(tmp>0){
    fx+=(tmp%10);
    tmp/=10;
  }
  if (N%fx==0) {
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define ed endl
using namespace std;
int main()
{
	int i;
	string a;
	cin >> a;
	fo(i, 0, 3) cout << a[i];
	cout << " " ;
	fo(i, 4, a.length() - 1) cout << a[i];
	cout << ed;
	return 0;
}

Measured memory_bytes: 256
/*
Author: CNYALI_LK
LANG: C++
PROG: D.cpp
*/
#include<bits/stdc++.h>
#define up(a,b,c) for (int a(b),a##end(c);a<=a##end;++a)
#define down(a,c,b) for (int a(b),a##end(c);a>=a##end;--a)
#define uup(a,c,b) for (int a(b),a##end(c);a<=a##end;++a)
#define udown(a,b,c) for (int a(b),a##end(c);a>=a##end;--a)
#define endl '\n'
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>void chkmin(T &a,T b){a=a<b?a:b;}
template<class T>void chkmax(T &a,T b){a=a>b?a:b;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
char a[2048],b[2048];
int ok[2048],l[2048],r[2048],sx[2048],sl[2048],sr[2048];
int cmp(int a,int b){return sl[a]<sl[b];}
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	scanf("%s%s",a,b);
	int n=strlen(a),ans=0x3f3f3f3f,ts;	
	for(int i=0;i<n;++i)if(b[i]-'0'){
		ok[i]=1;
	}
	int s=0;
	while(!ok[s]&&s<n)++s;
	if(s==n){
		int as=0x3f3f3f3f,S;
		for(int i=0;i<n;++i){
			S=1;
			for(int j=0;j<n;++j){
				if(a[j]!=b[(i+j)%n]){
					S=0;
					break;
				}
			}
			if(S){
				chkmin(as,mmin(i,n-i));
			}
		}
		printf("%d\n",as==0x3f3f3f3f?-1:as);
		return 0;
	}

	for(int i=0;i<n;++i){
		if(b[(i+s)%n]-'0')l[(i+s)%n]=0;
		else l[(i+s)%n]=l[(i+s+n-1)%n]+1;
	}
	for(int i=n;i>0;--i){
		if(b[(s+i+n)%n]-'0')r[(s+i+n)%n]=0;
		else r[(s+i+n)%n]=r[(s+i+n+1)%n]+1;
	}
	int tt,rgt,t;
	for(int i=0;i<n;++i){
		ts=0;
		tt=0x3f3f3f3f;
		rgt=0;
		t=0;
		for(int j=0;j<n;++j){
			if(a[j]!=b[(j-i+n)%n]&&r[(j-i+n)%n]>i){
				sr[++t]=r[(j-i+n)%n]-i;
				sl[t]=l[(j-i+n)%n];
				sx[t]=t;
			}
			if(a[j]!=b[(j-i+n)%n])++ts;
		}
		sx[t+1]=0;
		sort(sx+1,sx+t+1,cmp);
		for(int j=t+1;j>=1;--j){
			chkmax(rgt,sr[sx[j]]);
			chkmin(tt,rgt+sl[sx[j-1]]);
		}
		if(t){	
			chkmin(ans,ts+i+tt*2);
		}
		else chkmin(ans,ts+i);
	}

	for(int i=0;i<n;++i){
		ts=0;
		t=0;
		tt=0x3f3f3f3f;rgt=0;
		for(int j=0;j<n;++j){
			if(a[j]!=b[(i+j)%n]&&l[(j+i)%n]>i){
				sl[++t]=l[(j+i)%n]-i;
				sx[t]=t;
				sr[t]=r[(j+i)%n];
			}
			if(a[j]!=b[(i+j)%n])++ts;
		}
		sx[t+1]=0;
		sort(sx+1,sx+t+1,cmp);
		for(int j=t+1;j>=1;--j){
			chkmax(rgt,sr[sx[j]]);
			chkmin(tt,rgt+sl[sx[j-1]]);
		}
		if(t){
			chkmin(ans,ts+i+tt*2);
		}
		else chkmin(ans,ts+i);
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
  vector<int> d;
  int x;
  for( int i=0; i<10; i++ ){
    cin >> x;
    d.push_back( x );
  }
  sort( d.begin(), d.end(), greater<int>() );
  for( int i=0; i<3; i++ ) cout << d[i] << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  ll N;
  scanf("%lld", &N);
  ll a[N];
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &a[i]);
  }

  sort(a,a+N);

  ll b[N];
  b[0] = a[0];
  FOR(i,1,N-1){
    b[i] = b[i-1] + a[i];
  }

  ll ans = 1;

  FORD(i,N-1,1){
    // cout << a[i] << " " << b[i-1] << endl;
    if(a[i]<=b[i-1]*2){
      ++ans;
    }
    else{
      cout << ans << endl;
      return 0;
    }
  }

  cout << ans << endl;
  return 0;

}



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



int main(void) {
  ll x;
  cin >> x;

  vector<ll> a(1001009, 0);
  a[1] = 1;
  for (ll i = 2; i <= 1001001; i++) {
    a[i] = a[i - 1] + i;
  }

  for (ll i = 1; i <= 1001000; i++) {
    if (a[i] == x) {
      cout << i << endl;
      return 0;
    }
    if (a[i] > x) {
      cout << i << endl;
      return 0;
    }
  }


  return 0;
}


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

int main() {

  int N;
  cin >> N;

  long result = 1;

  int mod = 1000000007;

  for (int i = 1; i <= N; i++) {
    result = (result * i) % mod;
  }

  cout << result << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
	string s;
	cin >> s;
	if (s.size() == 1) {
		cout << 0 << endl;
		return 0;
	}
	int ss = s.size();
	vector<pair<char, int>> ext;
	rep(i, ss) {
		if (s[i] != 'x')	ext.emplace_back(s[i], i);
	}
	if (ext.size() == 0) {
		cout << 0 << endl;
		return 0;
	}
	string b = "", e = "";
	rep(i, ext.size() / 2) {
		b += ext[i].first;
		e += ext[ext.size() - 1 - i].first;
	}
	if (b != e) {
		cout << -1 << endl;
		return 0;
	}
	int left, right;
	if (ext.size() % 2 == 1) {
		left = right = ext[ext.size() / 2].second;
	}
	else {
		left = ext[ext.size() / 2].second;
		right = ext[ext.size() / 2 - 1].second;
	}
	vector<int> bn(1, 0), en(1, 0);
	rep(i, left) {
		if (s[i] != 'x')	bn.push_back(0);
		else bn.back()++;
	}
	for (int i = ss - 1; i > right; --i) {
		if (s[i] != 'x')	en.push_back(0);
		else en.back()++;
	}
	int ans = 0;
	rep(i, bn.size()) {
		ans += abs(bn[i] - en[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4872
n = int(input())
a = [int(i) for i in input().split()]
if sum(a)%(n*(n+1)//2) != 0: print("NO")
else:
	x,flag,num = sum(a)//(n*(n+1)//2),True,0
	for i in range(n):
		if (a[i]-a[i-1]-x)%n!=0:
			flag = False
			break
		else: num+=abs((a[i]-a[i-1]-x)//n)
	if flag and num==x: print("YES")
	else: print("NO")

Measured memory_bytes: 14620
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	aa, bb := "", ""
	for i := 0; i < b; i++ {
		aa += strconv.Itoa(a)
	}
	for i := 0; i < a; i++ {
		bb += strconv.Itoa(b)
	}

	if aa < bb {
		fmt.Println(aa)
	} else {
		fmt.Println(bb)
	}
}


Measured memory_bytes: 512
s=input()

a=''
b=''
for i in range(2):
    a=a+s[i]
for j in range(2,4):
    b=b+s[j]    
a=int(a)
b=int(b)

if 1<=a<=12:
    if 1<=b<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=b<=12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int maxn=2e3+50;
typedef long long ll;
ll f[maxn];
int main()
{
    int n;
    cin>>n;
    memset(f,0,sizeof f);
    f[3]=1;
    for(int i=4;i<=n;++i) f[i]=(f[i-1]+f[i-3])%mod;
    cout<<f[n]%mod<<endl;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
A = list(map(int,input().split()))

A.insert(0,0)
A.append(0)
_A = []

for i in range(1,N+1):
  _A.append(abs(A[i] - A[i-1]))
_A.append(abs(0-A[N]))
S = sum(_A)


for i in range(0,N):
  allS = S
  allS -= (_A[i]+_A[i+1]-abs(A[i+2]-A[i]))
  print(allS)

Measured memory_bytes: 20544
// SPDX-License-Identifier: X11
// 2020-08-02

#include <stdio.h>

int main() {
  long K;
  scanf("%ld", &K);

  if (K % 2 == 0 || K % 5 == 0) {
    printf("-1\n");
    return 0;
  }

  long n = 7;
  long k = 1;

  while((n %= K) != 0) {
    n *= 10;
    n += 7;
    k++;
  }

  printf("%lu\n", k);
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn], sign[maxn];
long long mem[maxn][3];
int n;

long long dp(int cur, int nest) {
  if(cur == n) {
    return 0;
  }
  if(mem[cur][nest] != -1) return mem[cur][nest];
  int val = (nest & 1) ? -1 : 1;
  val *= sign[cur] * a[cur]; 
  long long ans = dp(cur + 1, nest) + val;
  if(nest > 0) ans = max(ans, dp(cur + 1, nest - 1) + val);
  if(sign[cur] == -1 && nest < 2) {
    ans = max(ans, dp(cur + 1, nest + 1) + val);
  }
  return mem[cur][nest] = ans;
}

int main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  sign[0] = 1;
  cin >> a[0];
  for(int i = 1; i < n; i++) {
    char c;
    cin >> c >> a[i];
    sign[i] = (c == '-') ? -1 : 1;
  }
  memset(mem, -1, sizeof mem);
  cout << dp(0, 0) << endl;
  return 0;
}


Measured memory_bytes: 11136
# Python3 code to Maximize volume of 
# cuboid with given sum of sides 

# Return the maximum volume. 
def maxvolume( s ): 

	# finding length 
	length = s / 3 
	s -= length 
	# finding breadth 
	breadth = s / 2
	# finding height 
	height = s - breadth 
	
	return length * breadth * height
	
# Driven Program 
s = int(input())
jj=maxvolume(s)
print ('%.15f'%jj) 

# This code is contributed by "Sharad_Bhardwaj". 


Measured memory_bytes: 2940
#include <bits/stdc++.h>	
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
 
// random_device rd; mt19937 g(rd());
 
using namespace std;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}
 
const int mod = (int)1e9 + 7;
const int N = (int)1e5 + 123;
const ld eps = 1e-10;
 
int n;
ld x[N], y[N];
char d[N];
 
ld f(ld k)
{
	ld xmax = -1e9, xmin = 1e9;
	ld ymax = -1e9, ymin = 1e9;
	for(int i = 1; i <= n; i++)
	{
		ld curx = x[i], cury = y[i];
		if(d[i] == 'U') cury += k;
		if(d[i] == 'D') cury -= k;
		if(d[i] == 'R') curx += k;
		if(d[i] == 'L') curx -= k;
		xmax = max(xmax, curx);
		xmin = min(xmin, curx);
		ymax = max(ymax, cury);
		ymin = min(ymin, cury);
	}
	xmax -= xmin;
	ymax -= ymin;
	xmax *= ymax;
	return (ld)xmax;
}
 
int main ()
{                                  	
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	cin >> n;  
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> d[i];
	ld l = 0.0, r = 1e11;
	for(int i = 1; i <= 700; i++)
	{
		ld m1 = l + (r - l) / 3;
		ld m2 = r - (r - l) / 3;
		if(f(m1) > f(m2)) l = m1;
		else r = m2;
	}
	cout << fixed << min(f(r), f(l));
}  

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
int a[100005];
int main()
{
	int a1,a0,af,k;
	sc(a1);sc(a0);sc(af);sc(k);
	if(a1+a0>=k)pf("%d\n",min(a1,k));
	else pf("%d\n",a1-(k-a1-a0));
}


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

int main(void){
    char s[15],t[15];
    scanf("%s",s);
    strncpy(t,s,4);
    t[4]=' ';
    strncpy(t+5,s+4,8);
    printf("%s\n",t);
	return 0 ;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


 
int main() {
    int n;
    cin >> n;
    deque<int> d;
    int ans = 0;
    rep(i, n) {
        int g;
        scanf("%d", &g);
        auto itr = lower_bound(d.begin(), d.end(), g);
        if(d.begin() == itr) {
            d.push_front(g);
        } else {
            *(itr-1) = g;
        }
        
    }

    cout << d.size() << endl;
}

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

int main(){
  string ans = "";
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      char c;
      cin >> c;
      if(i == j) ans += c;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if(N / 10 % 111 == 0 || (N - N / 1000 * 1000) % 111 == 0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 3608
TB = [0,1,2,3,5,7,8,9]
def to_8(v)
  return [] if v == 0
  to_8(v / 8) + [v % 8]
end
def solve(n)
  to_8(n).map {|v| TB[v]}.join
end
loop do
  n = gets.to_i
  break if n == 0
  puts solve(n)
end

Measured memory_bytes: 8940
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
 
int main(){
while(1){
int a;
cin>>a;
if(a==0) break;
int dp[33];
dp[0]=1;
dp[1]=1;
dp[2]=2;
if(a<3){
 cout<<1<<endl;
continue;
}
else{
for(int j=3;j<=a;j++){
dp[j]=dp[j-1]+dp[j-2]+dp[j-3];
}
if(dp[a]%10==0) dp[a]/=10;
else dp[a]=(dp[a]+10)/10;
if(dp[a]%365==0) dp[a]/=365;
else dp[a]=(dp[a]+365)/365;
cout<<dp[a]<<endl;
}
}
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main() {
    //変数の宣言
    double a, b, c;//入力
    double S, L, h;//出力
    
    //入力
    scanf("%lf %lf %lf", &a, &b, &c);
    
    //処理
    //面積
    S = 0.5 * a * b * sin(c * M_PI / 180);
    L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(c * M_PI / 180));
    h = b * sin(c * M_PI / 180);
    
    //出力
    printf("%f\n%f\n%f\n", S, L, h);
    
    
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=998244353;
const ll ms=1e6+5;
const ll inf=1e17;

vector<pair<int,int>> va;
vector<pair<int,int>> vb;
vector<pair<int,pair<int,int>>> vv;
int par[ms];
int sz[ms];


int findpar(int i)
{
    if(i==par[i])return i;
    return par[i]=findpar(par[i]);
}

bool unionn(int a,int b)
{
    a=findpar(a);
    b=findpar(b);
    if(a!=b)
    {
        if(sz[b]>sz[a])swap(a,b);
        sz[a]+=sz[b];
        par[a]=b;
        return 1;
    }
    return 0;
}


int main()
{
    idfc;

    int n;
    cin>>n;
    int a,b;
    int i;


    for(i=1;i<=n;i++)
    {
        cin>>a>>b;
        va.pb({a,i});
        vb.pb({b,i});
        par[i]=i;
        sz[i]=1;
    }
    sort(va.begin(),va.end());
    sort(vb.begin(),vb.end());

    for(i=1;i<n;i++)
    {
        vv.pb({va[i].first-va[i-1].first,{va[i].second,va[i-1].second}});
        vv.pb({vb[i].first-vb[i-1].first,{vb[i].second,vb[i-1].second}});
    }
    sort(vv.begin(),vv.end());

    ll ans=0;
    int w;

    for(i=0;i<vv.size();i++)
    {
        w=vv[i].first;
        a=vv[i].second.first;
        b=vv[i].second.second;
        if(unionn(a,b))
        {
            ans+=w;
        }
    }
    cout<<ans;



    return 0;
}

Measured memory_bytes: 9364
N=int(input())
H=list(map(int,input().split()))
a=0
alist=[]
if N==1:
  print(0)
  exit()
for i in range(N-1):
  if H[i]>=H[i+1]:
    if i!=N-2:
      a+=1
    else:
      a+=1
      alist.append(a)
  elif H[i]<H[i+1]:
    alist.append(a)
    a=0
print(max(alist))



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

using ll = long long;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)
#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

int N, i;

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

  cin>>N>>i;

  cout<<(N-i+1)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int s = a+b ;
    if(s<(a-b))
    {
        s=a-b;
    }
    if(s<(a*b))
    {
        s=a*b;
    }
    printf("%d",s);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
int main() {
	int h1,h2,m1,m2,s1,s2;
	for(int i=0;i<3;i++) {
		scanf("%d %d %d %d %d %d",&h1,&m1,&s1,&h2,&m2,&s2);
		int tm1=h1*3600+m1*60+s1;
		int tm2=h2*3600+m2*60+s2;
		int tm3=tm2-tm1;
		printf("%d %d %d\n",tm3/3600,tm3/60%60,tm3%60);
	}
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
bool mycmp(int a,int b)
{
    return a>b;
}
int main()
{
	int i,x,y,xc=0,yc=0,k=0;
	char a[8001];
	int lenx,leny;
	int b[8001],c[8001],d[8001]={0};
	scanf("%s",a);
	scanf("%d%d",&x,&y);
	//x=abs(x);
	//y=abs(y);
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]=='F')
		    d[k]++;
		else
			k++;
	}
	lenx=leny=0;
	for(i=1;i<=k;i++)
	{
		//printf("%d\n",d[i]);
		if(i%2==0)
			b[lenx++]=d[i];
		else
			c[leny++]=d[i];
	}
	sort(b,b+lenx,mycmp);
	sort(c,c+leny,mycmp);
	xc=d[0];
	for(i=0;i<lenx;i++)
	{
		if(xc>=x)
			xc-=b[i];
		else
			xc+=b[i];
	}
	for(i=0;i<leny;i++)
	{
		if(yc>=y)
			yc-=c[i];
		else
		yc+=c[i];
	}
	//printf("%d %d",xc,yc);
	if(xc==x&&yc==y)
		printf("Yes");
	else
		printf("No");
	return 0;
} 

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N, K;
int a[1111];
vec<int> cand;

int func(int mask) {
   int cnt = 0;

   for (int i = 0; i < cand.size(); i++) {
      if ((cand[i] & mask) == mask) {
         cnt++;
      }
   }

   return cnt;
}

signed main() {
   cin >> N >> K;
   rep (i, N) {
      cin >> a[i];
   }

   for (int i = 0; i < N; i++) {
      int sum = 0;
      for (int j = i; j < N; j++) {
         sum += a[j];
         cand.push_back(sum);
      }
   }

   int mask = 0;
   for (int i = 40; i >= 0; i--) {
      if (func(mask | (1LL << i)) >= K) {
         mask |= (1LL << i);
      }
   }
   cout << mask << endl;

   return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  string s;
  cin >> s;

  ll ans = INF;

  rep(i, s.size() - 2) {
    auto sub = s.substr(i, 3);
    auto n = std::atoll(sub.c_str());
    chmin(ans, abs(n - 753));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
 
using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  vecint isp(200000, 1);

  isp[0]=isp[1]=0;
  for(int i:irange(2,1000)) {
    if (isp[i]) {
      for(int j=i*i; j<200000; j+=i) {
        isp[j] = 0;
      }
    }
  }
  vecint nxt(200000, -1);
  for(int i=199998; i>=0; --i) {
    if (isp[i]) nxt[i] = i;
    else nxt[i] = nxt[i+1];
  }
  int x;
  cin>>x;
  cout<<nxt[x]<<endl;
  return 0;
}


Measured memory_bytes: 1792
#!/home/minamo/.pyenv/versions/3.6.1/bin/python
# vim: ft=python
# coding: utf-8

def registerDictionaryFromTheNumberOf(counts):
    dictionary = {}
    for i in range(counts):
        key, value = input().split(" ")
        dictionary[key] = value
    return dictionary

def readCharacterBeforeConversionAsManyAs(counts):
    readString = ""
    for i in range(counts):
        readString += input().rstrip()
    return readString

def convertCharactersByThe(dictionary, target):
    converted = ""
    for index in range(len(list(target))):
        if target[index] in dictionary:
            converted += dictionary[target[index]]
        else:
            converted += target[index]
    return converted

while True:
    dictionaryCounts = int(input())
    if dictionaryCounts == 0:
        break
    dictionary = registerDictionaryFromTheNumberOf(dictionaryCounts)
    original = readCharacterBeforeConversionAsManyAs(int(input()))
    converted = convertCharactersByThe(dictionary, original)
    print(converted)

Measured memory_bytes: 8536
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        h: usize, n: usize,
        abv: [(usize, usize); n]
    };

    let inf = 1_usize << 30;
    let max_damage = 10.pow(4);
    let mut dp = vec![inf; h + max_damage + 10];
    dp[0] = 0;
    for i in 0..n {
        let (a, b) = abv[i];
        for j in a..h + max_damage {
            dp[j] = std::cmp::min(dp[j], dp[j - a] + b);
        }
    }
    let mut res = std::usize::MAX;
    for i in h..h + max_damage {
        res = res.min(dp[i]);
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2320
#include<stdio.h>

int main(void)
{
        int n,i,a[100],max,min;

        scanf("%d",&n);

        for(i=0;i<n;i++)
                scanf("%d",&a[i]);

        max = a[0];
        min = a[0];

        for(i=1;i<n;i++){
                if(max<a[i])
                        max = a[i];
                if(min>a[i])
                        min = a[i];
        }

        printf("%d\n",max-min);
        return 0;
}


Measured memory_bytes: 128
n,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n-1):
  if a[i]>x:
    print(ans)
    exit()
  else:
    x-=a[i]
    ans+=1
if x==a[n-1]:
  print(n)
else:
  print(ans)

Measured memory_bytes: 9024
/* in the name of Anton */

/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 1LL<<61;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    vii b;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;n++;
    a.clear();a.reserve(n);
    // dbg(INF/1e17,4*INF)
    fo(i,n)
    {
        cin>>in;
        // in=0;
        a.pb(in);
    }

    if(n==1&&a[0]==1)
    {
        cout<<1<<endl;
        return 0;
    }

    // a.back()=1;
    if(a[0])
    {
        cout<<-1<<endl;
        return 0;
    }

    b.pb({1,1});
    l=r=1;
    repA(i,1,n-1)
    {
        l-=a[i];
        r=2*r-a[i];
        l=max(0LL,l);
        if(r>=INF)
            r=INF;
        if(r<0)
        {
            cout<<-1<<endl;
            return 0;
        }
        b.pb({l,r});
    }

    dbg(b)
    lli ans=0;
    cnt=0;
    repD(i,n-1,0)
    {
        cnt=min(cnt,b[i].Y);
        cnt+=a[i];
        dbg(i,cnt)
        ans+=cnt;
    }
    cout<<ans<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 6168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> cR(N+1),cG(N+1),cB(N+1);
    for(int i=0;i<N;i++){
        if(S[i]=='R'){
            cR[i+1]=cR[i]+1;
            cG[i+1]=cG[i];
            cB[i+1]=cB[i];
        }
        if(S[i]=='G'){
            cR[i+1]=cR[i];
            cG[i+1]=cG[i]+1;
            cB[i+1]=cB[i];
        }
        if(S[i]=='B'){
            cR[i+1]=cR[i];
            cG[i+1]=cG[i];
            cB[i+1]=cB[i]+1;
        } 
    }
    ll ans = 0;
    for(int j=1;j<N-1;j++){
        if(S[j]=='R'){
            ans+=cG[j]*(cB[N]-cB[j+1]);
            ans+=cB[j]*(cG[N]-cG[j+1]);
            for(int l=1;(j-l>=0&&j+l<N);l++){
                if(S[j-l]=='G'&&S[j+l]=='B'){
                    ans--;
                }else if(S[j-l]=='B'&&S[j+l]=='G'){
                    ans--;
                }
            }
        }
        if(S[j]=='G'){
            ans+=cR[j]*(cB[N]-cB[j+1]);
            ans+=cB[j]*(cR[N]-cR[j+1]);
            for(int l=1;(j-l>=0&&j+l<N);l++){
                if(S[j-l]=='R'&&S[j+l]=='B'){
                    ans--;
                }else if(S[j-l]=='B'&&S[j+l]=='R'){
                    ans--;
                }
            }
        }
        if(S[j]=='B'){
            ans+=cR[j]*(cG[N]-cG[j+1]);
            ans+=cG[j]*(cR[N]-cR[j+1]);
            for(int l=1;(j-l>=0&&j+l<N);l++){
                if(S[j-l]=='R'&&S[j+l]=='G'){
                    ans--;
                }else if(S[j-l]=='G'&&S[j+l]=='R'){
                    ans--;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
 
int main(){
 
	int a, b, c, d, aux;
	
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if (a > c){
		aux = a;
		a = c;
		c = aux;
		aux = b;
		b = d;
		d = aux;
	}
	if (c > b)
		printf("0\n");
	else
		if (d > b)
			printf("%d\n", b-c);
		else
			printf("%d\n", d-c);
 
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
typedef long long ll;
using namespace std;
int main()
{
	string S; cin >> S;
  	int count = 0;
  	for (int i = 0; i < S.size(); i++){
    	if (S[i] == 'x'){
        	count++;
        }
    }
  	if (count >= 8) {
    	cout << "NO" << endl;
    } else {
    	cout << "YES" << endl;
    }
}


Measured memory_bytes: 256
import java.util.*

fun main(arg: Array<String>) {
    val k = readLine()!!.toInt()
    val edge = LinkedList<Pair<Int, Int>>()
    val score = Array<Int?>(k) { null }
    edge.add(Pair(1, 1))
    while (edge.isNotEmpty()) {
        val pair = edge.poll()
        val next1 = (pair.second * 10) % k
        val next2 = (pair.second + 1) % k
        score[pair.second] = pair.first
        if (pair.second == 0) break
        if (score[next1] == null) edge.push(Pair(pair.first, next1))
        if (score[next2] == null) edge.add(Pair(pair.first + 1, next2))
    }
    println(score[0])
}


Measured memory_bytes: 48556
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    int N,R; cin >> N >> R;//コンテスト参加回数がN 表示レーティングが R
    int ans=R;
    if (N<=10) ans+=100*(10-N);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

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

cs = [0] * (n+1)
for i in range(n):
    cs[i+1] = cs[i] + a[i]


ans = 0
cnt = Counter(cs)
for k, v in cnt.items():
    if v > 1:
        ans += v * (v-1) // 2

print(ans)


Measured memory_bytes: 41672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VD = vector<double>;
using VVD = vector<vector<double>>;

int main(){
  int n;
  cin >> n;
  VI x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];
  
  VVD d(n,VD(n,0));
  rep(i,n){
    rep(j,i){
      double z = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
      d[i][j] = z;
      d[j][i] = z;
    }
  }
  
  VI v(n);
  rep(i,n) v[i] = i;
  double sum=0;
  
  do {
    rep(i,n-1){
      int now=v[i], next=v[i+1];
      sum += d[now][next];
    }
  }while(next_permutation(v.begin(), v.end()));
  
  int fact=1;
  rep(i,n) fact *= (i+1);
  
  cout << setprecision(12) << (sum/(double)fact) << endl;
  
  return 0;
}

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

using namespace std;

int main(){
  int H, W;
  int a[500][500];
  vector< tuple<int, int, int, int> > route;
  
  cin >> H >> W;
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W;j++){
      cin >> a[i][j];
    }
  } 
  
  for(int i = 0;i < H;i++){
    for(int j = 0;j < W - 1;j++){
      if(a[i][j] % 2){
        route.push_back(make_tuple(i, j, i, j + 1));
        a[i][j + 1]++;
      }
    }
  }
  for(int i = 0;i < H - 1;i++){
    if(a[i][W - 1] % 2){
      route.push_back(make_tuple(i, W - 1, i + 1, W - 1));
      a[i + 1][W - 1]++;
    }
  }
  
  cout << route.size() << endl;
  for(int i = 0;i < route.size();i++){
    int x, y, v, w;
    tie(y, x, w, v) = route[i];
    cout << ++y << ' ' << ++x << ' ' << ++w << ' ' << ++v << endl;
  }
  
  return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int a[N], b[N];
    rep(i, N){
        cin >> a[i] >> b[i];
    }
    int c[M], d[M];
    rep(i, M){
        cin >> c[i] >> d[i];
    }

    rep(i, N){
        int MIN = 2002002002;
        int num = 0;
        rep(j, M){
            int dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(MIN > dist){
                MIN = dist;
                num = j+1;
            }
        }
        printf("%d\n", num);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s;
    cin >> s;
    bool a = false;
    bool b = false;
    rep(i,3) {
        if (s[i] == 'A') a = true;
        if (s[i] == 'B') b = true;
    }
    if (a && b) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256