akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal ,RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vpll path;
//***********//
vl bitList(ll n, ll k, ll f) {
	vl bitList(k);
	for (ll i = 0; i < k; i++) {
		bitList[i] = f % n;
		f /= n;
	}
	return bitList;
}
int main() {
	cin >> N;
	string S;
	cin >> S;
	string P = S.substr(0, N);
	string Q = S.substr(N, N);
	reverse(Q.begin(), Q.end());
	map<pair<string,string>, ll>A;
	map<pair<string,string>, ll>B;
	for (i = 0; i < pow(2,N); i++) {
		vl V = bitList(2,N,i);
		string pre = "";
		string pre2 = "";
			for (j = 0; j < N; j++) {
				if (V[j]) pre += P[j];
				else pre2 += P[j];
		}
		A[mp(pre,pre2)]++;
	}
	for (i = 0; i < pow(2, N); i++) {
		vl V = bitList(2, N, i);
		string pre = "";
		string pre2 = "";
		for (j = 0; j < N; j++) {
			if (V[j]) pre += Q[j];
			else pre2 += Q[j];
		}
		B[mp(pre,pre2)]++;
	}
	for (auto x : A) {
		ans += x.second * B[x.first];
	}
	cout << ans;
}

Measured memory_bytes: 108288
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define COUT cout<<fixed<<setprecision(12)
#define CIN getline(cin,s)
ll MOD=1000000007;

void solve()
{
	string s;
	cin>>s;
	ll sum=0;
	for(ll i=0;i<s.size();i++)
	{
		sum=sum+s[i]-48;
	}
	if(sum%9==0)
	{
		cout<<"Yes\n";
	}
	else
	cout<<"No\n";
}
int main()
{
	ll t=1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3724
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

double euclid_strong(vector<double> a,vector<double> b){
    double sum=0;
    if(a.size()!=b.size()) return -1;
    for(int i=0;i<a.size();i++){
        sum+=(a[i]-b[i])*(a[i]-b[i]);
    }
    return sqrt(sum);
}

int main(){
    int n,d;
    cin >> n >> d;
    vector<vector<double>> points(n,vector<double>(d));
    REP(i,0,n){
        REP(j,0,d) cin >> points[i][j];
    }
    
    int cnt=0;
    REP(i,0,n){
        REP(j,i+1,n){
            double res=euclid_strong(points[i],points[j]);
            if(ceil(res) == floor(res)) cnt++;
        }
    }
    cout << cnt <<endl;
}

Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
int n;
ll k;
void solve()
{
   cin>>n>>k;k--;
   int i,A[n+1];
   foe(i,1,n)cin>>A[i];
   set<int>s;
   vector<int>pos,ans;
   int p=1;
   while(true)
   {
       p=A[p];
       if(s.count(p))break;
       else pos.pb(p),s.insert(p);
   }
   int j;i=0;
   while(pos[i]!=p)i++;
   fo(j,i,sz(pos))ans.pb(pos[j]);

   ll size=sz(ans);
   if(k>i)
   {
       k=(k-i)%size;
       cout<<ans[k]<<"\n";
   }
   else
   cout<<pos[k]<<"\n";
   
   
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 14928
$s=8e18;
($n,$k)=glob<>;@x=sort{$a-$b}<>;
for$i(0..$n-$k){
	@p=();
	/ /,push@p,$' for@x[$i..$i+$k-2];
	for$j($k-1..$n-$i-1)
	{
		$x[$i+$j]=~$";push@p,$';
		@p=sort{$a-$b}@p;
		$s=$s>($==($p[$_+$k-1]-$p[$_])*($x[$i+$j]-$x[$i]))?$=:$s for 0..@p-$k
	}
}
print$s


Measured memory_bytes: 768
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main(void)
{
    int H, W;
    int h, w;
    
    while (1) {
        scanf("%d%d", &H, &W);
        if (H == 0 && W == 0) break;
        for (h = 0; h < H; h++) {
            for (w = 0; w < W; w++) {
                putchar(((h & 1) ^ (w & 1)) == 0 ? '#' : '.');      }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}



Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n;
  int a[200009];
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n,greater<>());
  mint ans=0;
  if(n==1){
    ans+=a[0];
  }
  else{
    mint t=1;
    for(int i=0;i<n-2;i++){
      t*=2;
    }
    for(int i=0;i<n;i++){
      ans+=t*(i+2)*a[i];
    }
  }
  for(int i=0;i<n;i++){
    ans*=2;
  }

  cout<<ans.x<<endl;

  return(0);
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int w,h,n,x[101],y[101],a[101];
  cin >> w >> h >> n;
  int x1=0,x2=w,y1=0,y2=h;
  rep(i,0,n){
    cin >> x[i] >> y[i] >> a[i];
  }
  rep(i,0,n){
    if(a[i]==1){
      x1 = max(x1,x[i]);
    }else if(a[i]==2){
      x2 = min(x2,x[i]);
    }else if(a[i]==3){
      y1 = max(y1,y[i]);
    }else{
      y2 = min(y2,y[i]);
    }
  }

  cout << max(0,x2-x1) * max(0,y2-y1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pq priority_queue
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define elif else if

using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using pll=pair<ll,ll>;
using pss=pair<string,string>;
using pdd=pair<ld,ld>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-9;

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

ll abs1(ll a){if(a>=0)return a;else return -a;}
ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1)ret*=a;
    a*=a;
    if(a>=p)a%=p;if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}
int digit(ll a,ll b=10){int i=0;while(a!=0){a/=b;i++;}return i;}
ll gcd1(ll a,ll b){
  if(a==0 || b==0)return 0;
  ll n;while(a%b!=0){n=a%b;a=b;b=n;}return b;
}
ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];a[0]=n;b[0]=m;int i=1;
  while(b[i-1]!=0){a[i]=b[i-1];b[i]=a[i-1]%b[i-1];i++;}
  n=i;if(c%a[n-1]!=0)return 0;
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){ll cnt=x;x=y;y=cnt-(a[n-i-1]/b[n-i-1])*y;}
  return x;
}
ll modRev(ll a,ll p=MOD){
  a%=p;ll n=solveLinear(a,p,1);
  n%=p;if(n<0)return n+p;
  return n;
}
ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  ll ret=1;
  for(int i=1;i<=n;i++){ret=ret*i;if(ret>=p)ret%=p;}
  return ret;
}
ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  ll ret=1;
  rep(i,k){ret=ret*(n-i);if(ret>=p)ret%=p;}
  return ret;
}
ll binom(ll n,ll k,ll p=MOD){
  return (perm(n,k,p)*modRev(fact(k,p)))%p;
}
int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}
int main(){
  int i,j,k,cnt=0;
  int a,b,p=80;
  cin>>a>>b;
  a--;b--;
  cout<<p<<" "<<p<<endl;
  char c[p][p];
  rep(i,p/2)rep(j,p)c[i][j]='.';
  rep(i,p/2)rep(j,p)c[i+p/2][j]='#';
  for(i=0;i<p;i+=2){
    for(j=0;j<p;j+=2){
      if(b==0)break;
      c[i][j]='#';
      b--;
    }
  }
  for(i=p-1;i>=0;i-=2){
    for(j=p-1;j>=0;j-=2){
      if(a==0)break;
      c[i][j]='.';
      a--;
    }
  }
  rep(i,p){
    rep(j,p){
      cout<<c[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 13.07.2020 13:57:13
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  int n;
  cin>>n;

  int a[n+2],aa[n+1],sum=0;
  a[0]=0;
  REP(i,n){
    cin>>a[i+1];
    aa[i]=abs(a[i+1]-a[i]);
  }
  a[n+1]=0;
  aa[n]=abs(a[n+1]-a[n]);

  REP(i,n+1)sum+=aa[i];


  FOR(i,1,n){
    int ans=sum;
    ans=ans-aa[i-1]-aa[i]+abs(a[i+1]-a[i-1]);
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

vector<int> adj[N];
int ans[N];
bool vis[N];

void solve(){
    int n; cin>>n;
    int m; cin>>m;
    For(i, 0, m){
        int a, b; cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    queue<int> q;
    q.push(1);
    vis[1]=true;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int v: adj[u]){
            if(!vis[v]){
                vis[v]=true;
                ans[v]=u;
                q.push(v);
            }
        }
    }
    For(i, 2, n+1){
        if(!vis[i]){
            cout<<"No";
            return;
        }
    }
    cout<<"Yes\n";
    For(i, 2, n+1){
        cout<<ans[i]<<"\n";
    }
}

signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 13120
n=int(input())
x_list = list(map(int,input().split()))

min = min(x_list)
max = max(x_list)

sum_min = 1000000000000000000
for target_i in range(1, 101):
    sum_tmp = 0
    for i in range(n):
        sum_tmp += (target_i - x_list[i]) ** 2
    if sum_min >= sum_tmp:
        sum_min = sum_tmp

print(sum_min)

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

void insertionSort(int *a, int n) {
  int v, j;
  for (int i=0; i<n; i++) {
    v = a[i];
    j = i - 1;
    while (0<=j && v<a[j]) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;

    for (int k=0; k<n; k++) {
      cout << a[k];
      if (k < n - 1) cout << " ";
    }
    cout << endl;
  }
}

int main() {
  int N, A[100];
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  insertionSort(A, N);

  return 0;
}

Measured memory_bytes: 3084
A, B, C, K = input().split()
A = int(A)
B = int(B)
C = int(C)
K = int(K)

max = 0

if(K >= A):
    max += A
    K -= A
else:
    max += K

K -= B

if(K > 0):
    max -= K

print(max)


Measured memory_bytes: 9160
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N, K, S; cin >> N >> K >> S;
  rep(i,K) cout << S << endl;
  if (S>2) rep(i,N-K) cout << S/2+1 << endl;
  else rep(i,N-K) cout << S+1 << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}



Measured memory_bytes: 3632
n, m, k = gets.chomp.split.map(&:to_i)
orange = []
n.times{orange << gets.to_i}
cost = [0]
for i in 0..(n-1)
    min = max = orange[i]
    s, min_cost = 1, cost[i] + k
    (i-1).downto(0){|j|
        s += 1
        break if s > m
        min = orange[j] if min > orange[j]
        max = orange[j] if max < orange[j]
        c = cost[j] + s * (max - min) + k
        min_cost = c if min_cost > c
    }
    cost[i+1] = min_cost
end
puts cost[n]


Measured memory_bytes: 8944
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

ll n;
ll a[3000];
ll dp[3000][3000];

ll fun( ll start, ll end)
{
	if(start>end)
		return 0;
	else if(dp[start][end]!=-1)
		return dp[start][end];
	else
	return dp[start][end]=max(a[start]-fun(start+1,end),a[end]-fun(start,end-1));
}
int main()
{ 
fast;
	
	cin>>n;
	for(ll i=0;i<n;i++)
		cin>>a[i];

	memset(dp,-1,sizeof(dp));
	cout<<fun(0,n-1);
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <stdlib.h>

int nakamayukie(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int N, x;
int a[128];

int main(void) {
	int i;
	int notomamiko;
	if (scanf("%d%d", &N, &x) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	qsort(a, N, sizeof(*a), nakamayukie);
	notomamiko = x;
	for (i = 0; i < N; i++) {
		if (notomamiko < a[i]) {
			printf("%d\n", i);
			return 0;
		}
		notomamiko -= a[i];
	}
	printf("%d\n", N - (notomamiko > 0));
	return 0;
}


Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define Mod 924844033
#define MN 2005
int n,k,id[MN<<1],tot;
LL fac[MN],f[MN<<1][MN][2];
int main(){
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for(int i=1;i<=n;++i)fac[i]=(LL)fac[i-1]*i%Mod;
	for(int i=1;i<=k;++i){
		for(int j=i;j<=n;j+=k)
			id[++tot]=j;
		for(int j=i;j<=n;j+=k)
			id[++tot]=j;
	}
	f[1][0][0]=1;
	for(int i=2;i<=(n<<1);++i)
		for(int j=0;j<=i/2;++j){
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%Mod;
			if(j&&id[i]-id[i-1]==k)
				f[i][j][1]=f[i-1][j-1][0];
		}
	LL ans=fac[n];
	for(int i=1;i<=n;++i)
		ans=(ans+((i&1)?-1ll:1ll)*(LL)(f[n<<1][i][0]+f[n<<1][i][1])*(LL)fac[n-i]%Mod+Mod)%Mod;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 123904
import math
def com(x, y):
    k = math.factorial(x)
    s = math.factorial(y)
    l = math.factorial(x - y)
    return k // (s * l)
n = int(input())
a = list(map(int, input().split()))
a.sort()
max = a[-1]
target = max / 2
min = a[0]
for i in range(n - 1):
    if abs(a[i] - target) < abs(min - target):
        min = a[i]
print("{} {}".format(max, min))


Measured memory_bytes: 14436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085A
{
	class Program
	{
		static void Main(string[] args)
		{
			string s;

			s = Console.ReadLine();

			char[] cs = s.ToCharArray();

			cs[3] = '8';

			Console.WriteLine(cs);

			Console.ReadKey();
		}
	}
}


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

int main(){
  string S;
  cin >> S;
  int ans;
  if(S == "SAT") ans = 1;
  else if(S == "FRI") ans = 2;
  else if(S == "THU") ans = 3;
  else if(S == "WED") ans = 4;
  else if(S == "TUE") ans = 5;
  else if(S == "MON") ans = 6;
  else ans = 7;
  cout << ans << endl;
}


Measured memory_bytes: 768
x, y, a, b, c = map(int,input().split())
p_p = list(map(int,input().split()))
q_q = list(map(int,input().split()))
r_r = list(map(int,input().split()))
p_p.sort(reverse=True)
q_q.sort(reverse=True)
r_r.sort(reverse=True)

oisisa = sum(p_p[:x])+sum(q_q[:y])
apple = p_p[:x] + q_q[:y]
apple.sort()
seen = 0
for i in range(min(x+y,c)):
    if r_r[i] > apple[seen]:
        oisisa = oisisa + r_r[i] - apple[seen]
        seen += 1
    else:
        break


print(oisisa)

Measured memory_bytes: 23328
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

int const MAX_N = 256 * 1024;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	string st;
	cin >> st;
	int n = (int)st.length();

	long long CNT = 0;
	long long ans = 0;
	for (int i = n - 1; i >= 0; i--)
		if (st[i] == 'W') CNT++;
		else {
			ans += CNT;
		}
	cout << ans;
	return 0;
}

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

bool all_0 = true, all_1 = true;
long n, k, m;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> m;
		m &= 1;
		if (m == 1) {
			all_0 = false;
		} else {
			all_1 = false;
		}
	}
	if (k == 1) {
		if (all_0) {
			cout << 0;
		} else {
			cout << (1ull << n - 1);
		}
	} else {
		if (all_0) {
			cout << (1ull << n);
		} else {
			cout << (1ull << n - 1);
		}
	}
}

Measured memory_bytes: 256
S = input()

if S == "SUN":
    print("7")
elif S == "MON":
    print("6")
elif S == "TUE":
    print("5")
elif S == "WED":
    print("4")
elif S == "THU":
    print("3")
elif S == "FRI":
    print("2")
elif S == "SAT":
    print("1")    


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <math.h>

using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;

  for (int i = 0; i < 1010; ++i)
  {
    int x = i * 0.08;
    int y = i * 0.1;
    if (x == A && y == B)
    {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

  string s;
  cin >> s;
  int d = 0;
  int pd = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '?')
      s[i] = 'D';
  }

  cout << s << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

template<class T>
inline bool chmin(T &a, T b) { if(a > b) {a = b; return true;} return false; }
template <class T>
inline bool chmax(T &a, T b) { if(a < b) {a = b; return true;} return false; }
const int INF = 1LL << 60;

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];

	bool res = true;
	for(int i = 0; i < n; i++) {
		if(a[i] % 2 == 0) {
			if(a[i] % 3 == 0 || a[i] % 5 == 0) {
			} else {
				res = false;
			}
		}
	}

	if(res) cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;
int main()
{
    vector<int> n(3);
    REP(i, 3)
    {
        cin >> n.at(i);
    }
    sort(n.begin(), n.end());
    if (n.at(0) == 5 && n.at(1) == 5 && n.at(2) == 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3608
#include<stdio.h>

int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+'){
            printf("%d\n",a+b);
        }else if(op=='-'){
            printf("%d\n",a-b);
        }else if(op=='*'){
            printf("%d\n",a*b);
        }else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?'){
            break;
        }
    }
}


Measured memory_bytes: 2712
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;

class Main{
  public static void main(String[] args) throws IOException
  {
    LinkedList<Long> list = new LinkedList<Long>();
    FastScanner fs = new FastScanner();
    int n = fs.nextInt();
    for(int i=0;i<n;i++){
      if(i%2==0) list.addLast(fs.nextLong());
      else list.addFirst(fs.nextLong());
    }
    if(n %2 == 1){
      List<Long> lis = list;
      Collections.reverse(lis);
      list.forEach(num ->{ System.out.print(num+" ");});
    }else
    list.forEach(num ->{ System.out.print(num+" ");});
    System.out.println();
  }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 62056
n = int(input())
dic = {}

for i in range(n):
    si = list(input())
    si.sort()
    str_si = ""
    for j in range(10):
        str_si += si[j]
    if str_si not in dic:
        dic[str_si] = 1
    else:
        dic[str_si] += 1

tot = 0
for j in dic.values():
    k = j-1
    tot += (k*(k+1)//2)

print(tot)

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define allof(v) (v).begin(), (v).end()


int main(void)
{
	string s;
	cin >> s;
	cout << (s[0] == s[2] ? "Yes" : "No") << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int mc[12]={0,31,59,90,120,151,181,212,243,273,304,334};

long long dat(int y,int m,int d) {
	long long an;
	an=y*365+mc[m-1]+d+y/4-y/100+y/400;
	if (((y % 4==0 && y % 100!=0) || y % 400==0) && m<3) an--; 
	return an;
}

int main() {
    int y1,m1,d1,y2,m2,d2;
	long long d;
	while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
		if (y1<0 || m1<0 || d1<0 || y2<0 || m2<0 || d2<0) break;
		d=dat(y2,m2,d2)-dat(y1,m1,d1);
		cout << d << endl;
	}
    return 0;
}

Measured memory_bytes: 1156
import numpy as np

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]

I = [[0 for i in range(26)] for j in range(D)]

for d in range(D):
    for t in range(26):
        I[d][t] = (c[t] * (D-(d+1))) + s[d][t]

for line in I:
    print(line.index(max(line))+1)

Measured memory_bytes: 27680
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  int A, P;
  std::cin >> A >> P;
  int n = A * 3 + P;
  std::cout << n / 2 << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


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

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

  if(S=="SUN") {
    cout << 7 << endl;
  } else if(S=="MON") {
    cout << 6 << endl;
  } else if(S=="TUE") {
    cout << 5 << endl;
  } else if(S=="WED") {
    cout << 4 << endl;
  } else if(S=="THU") {
    cout << 3 << endl;
  } else if(S=="FRI") {
    cout << 2 << endl;
  } else if(S=="SAT") {
    cout << 1 << endl;
  }

  return 0;
}


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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int d[11][6];
bool check[11][6];
int H;

void write() {
    rep(i, H) {
        rep(j, 5) cout << d[i][j] << " ";
        cout << endl;
    }
    cout << endl;
}
void fall() {
    rep(i, H) rep(j, 5) if (check[i][j]) d[i][j] = 0;
    repr(i, H) {
        rep(j, 5) {
            if (d[i][j] == 0) {
                bool update = true;
                while (update && d[i][j] == 0) {
                    update = false;
                    for (int k = i - 1; k >= 0; --k) {
                        d[k + 1][j] = d[k][j];
                        if(d[k][j] > 0) update = true;
                    }
                    d[0][j] = 0;
                }
            }
        }
    }
    // write();
}
int erase() {
    rep(i, 11) rep(j, 6) check[i][j] = 0;
    rep(i, H) {
        rep(j, 3) {
            if (d[i][j] > 0 && d[i][j] == d[i][j + 1] && d[i][j] == d[i][j + 2]) {
                check[i][j] = check[i][j + 1] = check[i][j + 2] = true;
            }
        }
    }
    int ret = 0;
    rep(i, H) rep(j, 5) if (check[i][j]) ret += d[i][j];
    fall();
    return ret;
}

int main() {
    while (cin >> H) {
        if (H == 0) break;
        rep(i, H) {
            rep(j, 5) cin >> d[i][j];
        }
        int s = 0;
        while (1) {
            int t = erase();

            if (t == 0) break;
            s += t;
        }
        cout << s << endl;
    }
    return 0;
}


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

using namespace std;

#define rep(i,n) for(long i=0;i<=n;i++)

int main(){
 long n,c;
  cin >> n >> c;
  
  long s[n],t[n],cc[n];
  rep(i,n-1) cin >> s[i] >> t[i] >> cc[i];
  
  long channel[200002]={0},used[200002]={0};
  
  rep(i,c){
   rep(j,n-1) {
     if(cc[j]==i) {
       channel[2*s[j]-1]++;
       channel[2*t[j]]--;
     }
     }
    rep(j,200000) channel[j+1]+=channel[j];
    rep(j,200000) if(channel[j]>0) used[j]++;
    rep(j,200001) channel[j]=0;
  }
  
 long res=0;
 rep(i,200001){
  res=max(res,used[i]);
 }
  
  cout << res << endl;  
  
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}



int main() {
	int n, m; cin >> n >> m;
	str a, b;
	for (int i = 0; i < n; i++) {
		a.push_back(m+'0');
	}
	for (int i = 0; i < m; i++) {
		b.push_back(n + '0');
	}
	if (a > b)cout << b << endl;
	else cout << a << endl;



	return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
*arr, = map(int, input().split())


cnt = Counter(arr)

ans = 0

total = 0

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


for v in arr:
    print(total - cnt.get(v, 1) + 1)





Measured memory_bytes: 94356
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;
 
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);
 
int n;
ll k; 
 
struct mat {
	ll a[50][50];
	
	mat operator *(mat other) {
		mat umn;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				umn.a[i][j] = 0;
			}
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int l = 0; l < n; l++) {
					umn.a[i][j] += a[i][l] * other.a[l][j];
					umn.a[i][j] %= MOD;
				}
			}
		}
		
		return umn;
	}
	
};
 
mat poc;
 
int main () {
 
	cin >> n >> k;
	mat rj;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> poc.a[i][j];
			rj.a[i][j] = 1;
		}
	}
	
	for (int i = 0; i <= 60; i++) {
		if ((k&(1LL << i)) > 0) {
			rj = rj * poc;
		}
		poc = poc * poc;
	}
	
	int sol = 0;
	for (int i = 0; i < 1; i++) {
		for (int j = 0; j < n; j++) {
			sol += rj.a[i][j];
			sol %= MOD;
		}
	}
	
	cout << sol;
	
	return 0;
}

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

using namespace std;

void print(char c, int n){
	for(int i = 0; i < n; ++i) cout << c;
}

int main(){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int x = abs(sx - tx), y = abs(sy - ty);
	print('U', y);
	print('R', x);
	print('D', y);
	print('L', x + 1);
	print('U', y + 1);
	print('R', x + 1);
	print('D', 1);
	print('R', 1);
	print('D', y + 1);
	print('L', x + 1);
	print('U', 1);
	cout << endl;
}

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

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;--i)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);

//DEBUG
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
	int n,h;
	cin >> n>> h;
	pair <int,int> x[200000];
	REP(i, n) {
		cin >> x[i].first >> x[i].second;
		x[n+i].first = x[i].second; x[n+i].second = -i;
	}
	sort(x,x+2*n); 
	int t = 0;
	int po = 2 * n - 1;
	while(h>0){
		if (x[po].second <= 0) {
			h -= x[po].first;
			po--;
			t++;
		}
		else {
			t += h / x[po].first;
			if(h%x[po].first) t++;
			break;
		}
	}
	cout << t << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;



signed main(){
  int n,k;
  cin>>n>>k;
  vector<bool> D(10,true);
  rep(i,k){
    int d;
    cin>>d;
    D[d]=false;
  }
  
  for(int i=n;;i++){
    string t=to_string(i);
    bool flag=true;
    rep(j,t.size()){
      if(D[t[j]-'0']==false){
        flag=false;
        break;
      }
    }
    if(flag){
      cout<<i<<endl;
      return 0;
    }
  }


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int x,y;
    int kame,n=0;

    scanf("%d %d",&x,&y);

    for(kame=0;kame<=x;kame++){
        if(kame*4+(x-kame)*2==y){
            printf("Yes");
            n++;
            break;
        }
    }

    if(n==0) printf("No");

    return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f

int main()
{
    int m,n,a[110];
    scanf("%d%d",&n,&m);
    double sum=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    sum=sum*0.1/(4*m*0.1);
    ll cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>=sum)
            cnt++;
    }
    if(cnt>=m)
        printf("Yes\n");
    else
        printf("No\n");
}



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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll mod = 1;
    ll n;
    cin >> n;
    if (n == 0) {
        cout << 0 << endl;
        return 0;
    }
    string ans = "";
    while (n != 0) {
        ll nxt = mod * (-2);
        ll hoge = (n % nxt != 0);
        ans += to_string(hoge);
        n -= hoge * mod;
        mod = nxt;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}


int solve(){
 	int n;cin>>n;
 	int ans=hell;
 	auto func=[&](int x){
 		int s=0;
 		while(x){
 			s+=x%10;
 			x/=10;
 		}
 		return s;
 	};
 	rep(i,1,n)mins(ans,func(i)+func(n-i));
 	cout<<ans<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 1000000
using namespace std;

int main(){
    int n;
    int fib[50];
    cin>>n;
    fib[0]=1;
    fib[1]=1;
    rep(i,2,n+1){
        fib[i]=fib[i-1]+fib[i-2];
    }
    cout<<fib[n]<<endl;
    return 0;
}

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

int count(int n, int x){
  int cnt = 0;
  for(int i = 1;i <=n-2;i++){
    for(int j = i+1;j <=n-1;j++){
      for(int k = j+1;k <=n;k++){
        if(i + j + k == x )cnt++;
      }
    }
  }
  return cnt;
}        
int main(){
  int n, x;;
  while(true){
    cin >> n >> x;
    if(n == 0 && x == 0)break;
    cout << count(n,x) << endl;
  }
}


Measured memory_bytes: 3100
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; ++i)
int main() {
    map<ll, int> a;
    ll n; cin >> n;
    rep(i, n) {
        ll t; cin >> t; //a.first
        a[t]++; //a.second
    }
    ll ans = 0;
    for (auto itr = a.begin(); itr != a.end(); ++itr) {
        if (itr->second % 2 != 0) { //奇数なら書かれてる
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using namespace std;

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

    vector < pair<long long, long long> > AB(N);

    for(int i = 0; i < N; i++){
        int A, B;
        cin >> A >> B;
        AB[i] = make_pair(A, B);
    }

    sort(AB.begin(), AB.end());

    long long money = 0;
    int rest = M;

    for(int i = 0; i < N; i++){
        if (rest - AB[i].second <= 0) {
            money += rest * AB[i].first;
            break;
        }else{
            money += AB[i].first * AB[i].second;
            rest -= AB[i].second;
        }
    }
    
    cout << money << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
#define N 100005
struct edge
{
	int to,next;
}e[N*2];
int n,m,tot,head[N];
int a[N],b[N],id[N],fa[N];
long long qd[N],S[N];
bool cmp(int x,int y)
{
	return a[x]<a[y];
}
void add(int x,int y)
{
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
int get(int x)
{
	return fa[x]==x?x:fa[x]=get(fa[x]);
}
int vis[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
		a[i]=max(a[i]-b[i],0);
	}
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	for(int i=1;i<=n;i++)	id[i]=i,fa[i]=i,qd[i]=a[i],S[i]=b[i]; 
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		int x=id[i];
		vis[x]=1;
		for(int j=head[x];j;j=e[j].next)
			if(vis[e[j].to])
			{
				int X=get(x),Y=get(e[j].to);
				if(X==Y) continue;
				fa[Y]=X;S[X]+=S[Y];
				qd[X]=min(qd[X],qd[Y]+max(0ll,a[x]-S[Y]-qd[Y]));
			}
	}
	int x=get(1);
	printf("%lld",qd[x]+S[x]);
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略
 
int main(){
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  for(int i = a; i <= b; i++){
    if(i % k == 0){
      cnt++;
    }
  }
  if(cnt == 0){
    cout << "NG";
  }else{
  	cout << "OK";
  }
}

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

using namespace std;

int main() {
	int x;
	cin >> x;
	
	if (360 % x == 0) cout << 360 / x << '\n';
	else {
		for (int i = 720; i <= 10000000000; i += 360) {
			if (i % x == 0) {
				cout << i / x << '\n';
				return 0;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3632
N,Y=map(int,input().split())
Y/=1000
for i in range(0,N+1):
    for j in range(0,N-i+1):
        if(10*i+5*j+N-i-j==Y):
            print(str(i)+" "+str(j)+" "+str(N-i-j))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,n;
  cin>>h>>n;
  int a[n];
  int s=0;
  int i;
  for(i=0;i<n;i++)
  {
   cin>>a[i];
    s+=a[i];
  }
  if(s>=h)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 640