akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
using ld = long double;
using ml = boost::multiprecision::cpp_int;

namespace NyaGadget
{
	/*** DFSライブラリ***/

#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)

	struct DFSnode
	{	// DFS NODE
		ll r = 0;  // root node
		ll s = 0;  // self node
	};

	struct DFS
	{
		using Edge = vector<ll>;
		vector<Edge> graph;

		DFS(ll size) { graph.resize(size); }
		vector<ll>& operator [](int n) { return graph[n]; }

		/**
		@brief 辺を追加する関数
		@note
		 頂点v1とv2を結ぶ辺を追加する。
		**/
		void CreateEdge(ll v1, ll v2)
		{	// 後戻りも出来るようにv1→v2とv2→v1の両方の辺を追加する
			graph[v1].push_back(v2);
			graph[v2].push_back(v1);
		}

		/**
		@brief 実行関数
		@param snode 開始ノード
		@param v 各ノード処理に必要な変数
		@param Update ノード毎の処理を定義した関数
		@note
		 大抵の場合、開始ノードは{0, 0}で良い。
		 Updateの処理で必要な変数はvで渡す。
		 したがって、Updateの第二引数と変数vは同じ型にする必要がある。
		**/
		template <class T> void
		Run(DFSnode snode, T& v, function<void(DFSnode, T&)> Update)
		{
			Update(snode, v);

			each(i, e, graph[snode.s])
			{	// 後戻りしないようにする
				if (e == snode.r)
					continue;

				Run<T>({snode.s, e}, v, Update);
			}
		}
	};

#undef fori
#undef each

}

#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);                                     // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
#define sum(begin, end) accumulate(all(begin, end), 0LL)                      // accumulate 
/********** const value **********/
#define llong_max 9223372036854775807                                         // 9 * 10^18
#define mod 1000000007                                                        // 1e9 + 7
#define pi 3.14159265                                                         // 3.14 ...
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

using namespace NyaGadget;

struct DFSV
{
	vector<ll> ans;
	vector<ll> memo;
};

void DFSF(DFSnode n, DFSV& v)
{
	v.ans[n.s] = v.ans[n.r] + v.memo[n.s];
}

int main(void)
{ 
	ll n, q; cin >> n >> q;

	DFS dfs(n);
	rep(i, 0, n - 1)
	{
		ll a, b; cin >> a >> b;
		dfs.CreateEdge(--a, --b);
	}

	vector<ll> p(q), x(q);
	rep(i, 0, q)
	{
		cin >> p[i] >> x[i];
		p[i]--;
	}

	// 頂点xで加算するべきカウンタの値をメモしておく。
	DFSV v = { vector<ll>(n), vector<ll>(n) };
	rep(i, 0, q)
		v.memo[p[i]] += x[i];
	// DFSを実行する
	dfs.Run<DFSV>({0, 0}, v, DFSF);

	each(i, e, v.ans)
		cout << e << " ";

	return 0;
}


Measured memory_bytes: 35712
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int i = int.Parse(Console.ReadLine());
        if (i == 1)
        {
            Console.WriteLine("Hello World");
            return;
        }
        Console.WriteLine(int.Parse(Console.ReadLine()) + int.Parse(Console.ReadLine()));
    }
}


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

const int mod = 1e9+7;

int in[100010];
int a[100010];
int vis[100010],line[100010],cycc[100010];
vector<vector<int> > cyc;
bool oncyc[100010];
long long int dp[100010];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],in[a[i]]++;
	for(int i=1;i<=n;i++)
		if(!in[i]){
			int u=i;vis[i]=i;while(!vis[a[u]])	u=a[u],vis[u]=i;
			if(vis[a[u]]==i){
				cyc.push_back({});
				cyc.back().push_back(u);
				for(int j=u;a[j]!=u;j=a[j])
					cyc.back().push_back(a[j]);
				for(auto it:cyc.back())
					oncyc[it]=true;
			}
			else if(!oncyc[a[u]]||line[a[u]]){
				cout<<0<<endl;
				return 0;
			}
			int cnt=0;
			for(int j=i;j!=a[u];j=a[j])	cnt++;
			line[a[u]]=cnt;
		}
	for(int i=1;i<=n;i++)
		if(!vis[i]){
			int cnt=0;
			for(int j=i;!vis[j];j=a[j])	cnt++,vis[j]=i;
			cycc[cnt]++;
		}
	long long int ans=1;
	for(int i=1;i<=n;i++){
		int cnt=cycc[i];
		dp[0]=1;
		dp[1]=1;
		if(i>1&&(i&1))
			dp[1]++;
		for(int j=2;j<=cnt;j++)
			dp[j]=(dp[j-1]*dp[1]+dp[j-2]*(j-1)*i)%mod;
		ans=ans*dp[cnt]%mod;
	}
	for(auto it:cyc){
		reverse(it.begin(),it.end());
		int sz=it.size();
		int last=sz;
		for(int i=0;i<sz;i++,last++)
			if(line[it[i]])	break;
		for(int i=sz-1;i>=0;i--)
			if(line[it[i]]){
				int l1=line[it[i]],l2=last-i;
				if(l1>l2)
					ans=0;
				else if(l1<l2)
					ans=ans*2%mod;
				last=i;
			}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

int main()
{

  ll N, K;
  cin >> N >> K;
  ll h[N];
  rep(i, N) cin >> h[i];

  sort(h + 0, h + N);

  ll ans = 1000000007;
  rep(i, N - K + 1)
  {
    ans = min(ans, abs(h[i] - h[i + K - 1]));
  }
  cout << ans;
}

Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, m, x[10000], y[10000], p[10000];
int root(int x){
	if(p[x] == x) return x;
	return p[x] = root(p[x]);
}
inline double d(int dx, int dy){
	return sqrt(dx * dx + dy * dy);
}

int main(){
	scanf("%d%d", &n, &m);
	rep(i, n) scanf("%d%d", x + i, y + i), p[i] = i;
	vector<pair<double, pi> > es;
	double ans = 0;
	
	rep(i, m){
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		double t = d(x[a] - x[b], y[a] - y[b]); 
		es.pb(mp(t, mp(a, b)));
		ans += t;
	}
	sort(all(es));
	for(int i = es.size() - 1; i >= 0; i--){
		int a = root(es[i].second.first), b = root(es[i].second.second);
		if(a == b) continue;
		p[a] = b;
		ans -= es[i].first;
	}
	printf("%.9f\n", ans);
	
	return 0;
}

Measured memory_bytes: 1896
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 1;
	bool flag1 = false;
	bool flag2 = false;
	rep(i, n - 1) {
		if (a[i] > a[i + 1]) {
			if (flag2 == false) {
				flag2 = true;
			}
			if (flag1) {
				ans++;
				flag1 = false;
				flag2 = false;
			}
		}
		else if (a[i] < a[i + 1]) {
			if (flag1 == false) {
				flag1 = true;
			}
			if (flag2) {
				ans++;
				flag1 = false;
				flag2 = false;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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


int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  ll sum = 0;
  rep(i,m){
    cin>>a.at(i);
    sum+=a.at(i);

  }
  if(n<sum){
    cout<<-1<<endl;

  }
  else{
    cout<<n-sum<<endl;
  }
  return 0;

}


Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }
 
int main() {
  std::cout << std::fixed << std::setprecision(10);
  ull n;
  cin >> n;

  vector<ull> a;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    a.push(tmp);
  }

  double r = 0.0;
  each(i, n) {
    r += (double)(1 / (double)a[i]);
  }

  cout << (double)(1/r) << endl;
 
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  for(;;){
    int n;
    cin >> n;
    if(n==0) break;
    vector<int> r(n),c(n);
    for(int i=0; i<n; i++){
      cin >> r[i];
    }
    for(int i=0; i<n; i++){
      cin >> c[i];
    }
    sort(r.begin(),r.end());
    sort(c.rbegin(),c.rend());
    bool bOK = true;
    for(int i=0; i<n; i++){
      int count = 0;
      for(int j=0; j<n; j++){
        if(r[j] > 0){
          count++;
          r[j]--;
        }
      }
      if(c[i] != count){
        bOK = false;
        break;
      }
    }
    if(bOK) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>

int main(void)
{
    int A,B,N;
    scanf("%d%d%d",&N,&A,&B);
    if(N==1)
    {
        if(A==B)
            printf("1\n");
        else
            printf("0\n");
    }
    else 
    {
        if(A>B)
            printf("0\n");
        else
            printf("%lld\n",(long long )(B-A)*(N-2)+1);
    }
    return 0;
}
    

Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll mul(ll a, ll b) {
	return (a * b) % MOD;
}

ll pw(ll a, ll p) {
	ll res = 1;
	while (p > 0) {
		if (p & 1) {
			res = mul(res, a);
		}
		a = mul(a, a);
		p /= 2;
	}
	return res;
}

ll inv(ll x) {
	return pw(x, MOD - 2);
}


int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	string s;
	cin >> s;
	ll k = s.size() + n;
	vector<ll> p25(k + 1, 1), p26(k + 1, 1);
	for (int i = 1; i < k + 1; i++) {
		p25[i] = mul(p25[i - 1], 25);
		p26[i] = mul(p26[i - 1], 26);
	}
	vector<ll> fact(k + 1, 1);
	for (int i = 1; i < k + 1; i++) {
		fact[i] = mul(fact[i - 1], i);
	}
	ll ans = 0;
	for (int i = s.size(); i <= k; i++) {
		ll c = mul(inv(fact[i - s.size()]), mul(fact[i - 1], inv(fact[s.size() - 1])));
		ans = (ans + mul(c, mul(p25[i - s.size()], p26[k - i]))) % MOD;
	}
	cout << ans;
}

Measured memory_bytes: 51296
#include<bits/stdc++.h>
using namespace std;
#define maxn 420000
#define rg register
#define ll long long
inline ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0')
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=getchar();
	}
	return x*f;
} 
ll S;
int main()
{
	S=read();
	ll b,a,x=sqrt(S);
	if(x*x!=S) x++; 
	S=x*x-S;
	a=sqrt(S);
	for(;a>0;--a)
	{
		if(S%a==0)
		{
			b=S/a;
			break;
		}
	}
	cout<<0<<" "<<0<<" "<<x<<" "<<a<<" "<<b<<" "<<x;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll,ll>
#define pint pair<int,int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define MAX 100005
#define endl '\n'
#define mp make_pair
#define INF INT_MAX
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define ps(x,y) fixed<<setprecision(y)<<x
#define setbits(x) __builtin_popcountll(x)            //counts no of ones in binary representation
#define w(t)     int t; cin>>t; while(t--)
#define pi 3.141592653589793238
#define sortt(v)  sort(v.begin(),v.end())
#define lb(v,x) std::lower_bound(v.begin(),v.end(),x)
#define ub(v,x) std::upper_bound(v.begin(),v.end(),x)

using namespace std;

int main(){
	ll n;
	cin>>n;
	ll a[n];
	forn(i,n)	cin>>a[i];
	ll ans=0;
	ll maxi=a[0];
	for(int i=1;i<n;i++){
		if(a[i]>=maxi)	maxi=a[i];
		else{
			ans+=(maxi-a[i]);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define M 100010

// k=a1+a2+...an>nan+1
int main(){
    IOS;
 	
 	ll C[51][51];
 	rep(i,0,51)C[0][i]=0,C[i][0]=1;
 	rep(i,1,51)rep(j,1,51)C[i][j]=C[i-1][j]+C[i-1][j-1];
 	ll n;cin>>n;
 	ll a,b;cin>>a>>b;
 	vll v;
 	map<ll,ll>mp;
 	rep(i,0,n){ll x;cin>>x;v.pb(x);mp[x]++;}
 	sort(all(v)); reverse(all(v));
 	ll sum=0,cnt=a,way=0,j=a,mn=v[a-1],c=0;
 	rep(i,0,a){
 		sum+=v[i];
 		if(mn==v[i])c++;
 	}
 	ld x=sum/(ld)cnt;
 	if(c==a){
 		rep(i,a,mp[mn]+1)if(i<=b)way+=C[mp[mn]][i];
 	}
 	else way=C[mp[mn]][c];
 	cout<<setprecision(10)<<x<<"\n"<<way;
     
     
     
     
     return 0;
}


Measured memory_bytes: 3792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var paper = new Dictionary<int, int>();

            for (int i = 0; i < n; i++)
            {
                var tmp = IO.RInt - 1;
                if (!paper.ContainsKey(tmp))
                {
                    paper[tmp] = 1;
                }
                else
                {
                    paper[tmp]++;
                }
            }
            WriteLine(paper.Values.Where(x => x % 2 == 1).Count());
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

Measured memory_bytes: 21340
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int H, N;
	cin >> H >> N;
	vector<int> A(N);
	REP(i, N) scanf("%d", &A[i]);
	
	ll sum = accumulate(ALL(A), 0ll);
	puts([&] {
		return H <= sum;
	}() ? "Yes": "No");
	
	return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    ll a;
    long double b;
    cin >> a >> b;
    cout << fixed << setprecision(20) << (ll)floor(a*b) << endl;
    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	long long int a;
  cin>>a;
  
  int sum = 0;
  
  int p = a/500;
  sum = p * 1000;
  
  int k = a - 500*p;
  
  int q = k / 5;
  sum = sum + (q * 5);
  
  if(sum > 0)
  {
  	cout<<sum;
  }
  else
  {
  	cout<<0;
  }
  //cout<<sum;
  
  return 0;
}

Measured memory_bytes: 256
/*
	Name: n1kh1
	Date: 01/02/20 11:51
*/

#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
typedef long long int ll;
int main(){

//	#ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
//    #endif
//    ios::sync_with_stdio(false);
//    cin.tie(nullptr);
//    cout.precision(10);
//    cout << fixed;

		int q;
		cin>>q;
		int dp[q+1][3];
		dp[0][0]=0,dp[0][1]=0;dp[0][2]=0;
		int a,b,c;
		for(int i=1;i<=q;i++){
			cin>>a>>b>>c;
			int p=a+max(dp[i-1][1],dp[i-1][2]);
			int q=b+max(dp[i-1][0],dp[i-1][2]);
			int r=c+max(dp[i-1][0],dp[i-1][1]);
			dp[i][0]=p;
			dp[i][1]=q;
			dp[i][2]=r;
			
		}
		cout<<max(dp[q][0],max(dp[q][2],dp[q][1]));


}


Measured memory_bytes: 1408
n, k, q = map(int, input().split())
scores = [0 for i in range(n+1)]
for i in range(q):
  scores[int(input())] += 1
  
for i in range(1, n+1):
  if q - scores[i] >= k:
    print('No')
  else:
    print('Yes')

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll n;
    cin >> n;
    ll m=  0, a=0,r=0,c=0,h=0;
    map<char,ll> ma;
    for(ll i = 0;i<n; i++)
    {

        string ss;
        cin >> ss;
        ma[ss[0]]++;
    }
    m = ma['M'], a=  ma['A'],r=ma['R'],c=ma['C'],h=ma['H'];
    vector<ll> v;
    v.pb(m), v.pb(a), v.pb(r), v.pb(c), v.pb(h);
    ll ans = 0;

    for(ll i = 0; i < v.size(); i++)
    {

        for(ll j = i+1; j < v.size(); j++)
        {

            for(ll k = j+1; k < v.size(); k++)
            {

                ans += v[i]*v[j]*v[k];
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
n = int(input())
s = input()

cnt = 0
for i in range(n - 2):
    num = 1
    if s[i] != "A":
        num = 0
    if s[i + 1] != "B":
        num = 0
    if s[i + 2] != "C":
        num = 0    
    cnt += num

print(cnt)

Measured memory_bytes: 3060
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it before "scanf" and other c input!

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    double  r;
    scanf("%lf",&r);
    printf("%.20f\n",2 * pi * r);
    return 0;
}

Measured memory_bytes: 3232
#include<iostream>

typedef unsigned long long ULL;
using namespace std;

int main(){
    int N,D;
    int ans;
    cin >> N >> D;
    D = D * 2 + 1;
    if( N % D == 0){
        ans = N / D;
    }else{
        ans = N / D + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>

// ハッシュ計算で使う素数
constexpr int prime[] = {2,  3,  5,  7,  11, 13,  17,  19, 23, 29,
                         31, 37, 41, 43, 47, 53,  59,  61, 67, 71,
                         73, 79, 83, 89, 97, 101, 103, 107};

constexpr size_t alphabet = 26;
constexpr size_t str_len = 10;

inline int64_t hash(char *str, int start, int end) {
  int64_t result = 1;

  // アルファベット1文字ごとに素数を割り当てて掛け算結果をハッシュ値にする
  // オーバーフローしない限りは完全ハッシュ
  for (size_t i = start; i < end; ++i) {
    result *= prime[str[i] - 'a'];
  }

  return result;
}

int main() {
  int n;
  scanf("%d", &n);

  // 最大入力数*1行の文字数(改行込み)
  char input[100000 * 11 + 5];

  // 文字列の一括入力
  fread(input, sizeof(char), sizeof(char) * 11 * n, stdin);

  std::unordered_map<int64_t, int64_t> map;
  int64_t count = 0;
  for (int i = 0; i < n; ++i) {
    auto key = hash(input, i * 11 + 1, i * 11 + 10 + 1);

    if (map.count(key) == 0) {
      map[key] = 0;
    } else {
      auto &val = map[key];
      count += (++val);
    }
  }
  printf("%ld\n", count);

  return 0;
}

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

typedef vector<int> vi;
typedef vector<vi> vvi;
const int INF = 2000000;
vvi t;
int n,k;

int solve(int x, int y = -1) {
    vi dis(n, INF); dis[x] = 0;
    queue<int> q; q.push(x);
    int maxd = k/2;
    if(y != -1) {
        dis[y] = 0; q.push(y);
        maxd = (k-1)/2;
    }
    int ans = 0;
    while(!q.empty()) {
        int v = q.front(); q.pop();
        if(dis[v] > maxd)
            ans++;
        for(auto u : t[v]) {
            if(dis[u] == INF) {
                dis[u] = dis[v] + 1;
                q.push(u);
            }
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    while(cin >> n >> k) {
        t = vvi(n);
        for(int i = 0; i < n-1; i++) {
            int x,y; cin >> x >> y; x--; y--;
            t[x].push_back(y);
            t[y].push_back(x);
        }
        int ans = n;
        for(int v = 0; v < n; v++) {
            ans = min(ans, solve(v));
            for(auto u : t[v]) {
                ans = min(ans, solve(v,u));
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 384
n = gets.to_i
t,x,y = 0,0,0
ans = "Yes"

n.times do
    ti,xi,yi = gets.chomp.split(" ").map(&:to_i);
    if (ti - t) < (xi - x).abs + (yi - y).abs
        ans = "No"
    elsif !((ti - t) % 2 == ((xi - x).abs + (yi - y).abs) % 2)
        ans = "No"
    end
    t,x,y = ti,xi,yi
end

puts ans

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var N = S.Length / 2;

            var first = S.Substring(0, N);
            var last = S.Substring(N+1 , N);
            if(first==last&&first== string.Join("", last.Reverse()))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string a, b;
    cin >> a >> b;
    a += b;
    int x = stoi(a);
    rep(i, 400){
        if(i * i == x){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  for (int i = 1; i <= 9; ++i)
    for (int j = 1; j <= 9; ++j)
      if (i * j == n) {
        std::cout << "Yes" << std::endl;
        return 0;
      }
  std::cout << "No" << std::endl;
}


Measured memory_bytes: 3164
import math
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    M = math.floor(math.log2(max(A)))
    count = 0
    for _ in range(M):
        success = True
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] /= 2
            else:
                success = False
                break
        if success == False:
            break
        count += 1
    print(count)
main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    //    std::ios_base::sync_with_stdio(false);
    //    cin.tie(NULL);
    int n; cin >> n;
    vector<pii>v(5);
    int id = 1;
    for(auto & e : v){
        cin >> e.first;
        e.second = id++;
    }
    sort(all(v));
    int mini = v.front().first;
    if(mini >= n) cout << 5 << endl;
    else {
        cout << (n - mini) / mini + ((n - mini) % mini ? 1: 0) + 5 << endl;
    }
}




Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long x = sc.nextLong();
    long y = Long.parseLong(sc.next().replace(".",""));    
    BigDecimal big = new BigDecimal(x).multiply(new BigDecimal(y).divide(new BigDecimal("100")));
    String res = big.toString();
    if(res.contains(".")){
   		res = res.substring(0, res.indexOf("."));
    }
    System.out.println(res);
  }
 
}

Measured memory_bytes: 36148
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

void findDivisors(ll n) 
{ 
    ll sum = 0;
    vector<ll> div(n + 1);
  
    for (int i = 1; i <= n; i++) { 
  
        for (int j = 1; j * i <= n; j++) 
            div[i * j]++; 
    } 
  
    for (int i = 1; i <= n; i++) 
        sum += i * div[i];
    print(sum);
}

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    findDivisors(n);



}




Measured memory_bytes: 81332
main = do
  li <- getLine
  let [a,b] = words li
  let ans = compute a b
  print ans

compute :: String -> String -> Integer
compute a b = a1 * (b1 * 100 + b2) `div` 100
  where
    a1 = read a
    b1 = read $ take 1 b
    b2 = read $ drop 2 b


Measured memory_bytes: 3956
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;
int n,a,b,c,d,sol;
string s;
int main()
{
    cin>>a>>b>>c>>d;
    int res = max(a,c);
    int res1 = min(b,d);
    cout<<max(0,res1-res)<<endl;
    return 0;
}


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

int main() {
	int a, b, c;
	double x;
	
	cin >> a;
	cin >> b;
	x = (a + b) / 2.0;	//7 + 4 = 11 -> x = 5.5 -> 6.0
	c = x;
	
	if (x - c >= 0.5) {
		c++;
	}
	
	cout << c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, A;
  cin >> N >> A;
  int ans = N * N - A;
  cout << ans << endl;
  return 0;
}

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

#define F(I,J,N) for(int I=J;I<N;I++)

int main(){
	priority_queue<int> q;
	int n,a,b,c;
	cin>>n;
	F(i,0,n){
		cin>>a>>b>>c;
		q.push(a);q.push(b);q.push(c);
		a=q.top();q.pop();b=q.top();q.pop();c=q.top();q.pop();
		bool f=false;
		if(a*a==(b*b+c*c)) f=true;
		if(f) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
ss = input().strip()
ts = input().strip()

mapping = {}
for s, t in zip(ss, ts):
  if mapping.get(s, t) != t:
    print("No")
    quit(0)
  mapping[s] = t
if len(mapping.values()) == len(set(mapping.values())):
  print("Yes")
else:
  print("No")

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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<char> frame(W+2, '#');
  
  for (int i = 0; i < W+2; i++) {
    cout << frame.at(i);
  }
  
  cout << endl;
  
  for (int i = 0; i < H; i++) {
   vector<char> a(W+2, '#');
    
    for (int j = 1; j < W+1; j++) {
      cin >> a.at(j);
    }
    
    for (int j =0; j < W+2; j++) {
      cout << a.at(j);
    }
    
    cout << endl;  
    
  }
  
  for (int i = 0; i < W+2; i++) {
    cout << frame.at(i);
  }
  
  cout << endl;
  
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}



int main()
{
	int n;
	cin>>n;
	vector<int> d(n+1,0);
	repi(i,1,n+1)cin>>d[i];
	rep(i,n+1)d[i]=min(d[i],(24-d[i])%24);

	sort(all(d));
	vector<int> used(24,0);
	used[0]=1;

	int parity=-1;
	repi(i,1,n+1){
		if(parity<0)used[d[i]]++;
		else used[(24-d[i])%24]++;
		parity*=-1;
	}

	int ans=24;
	int prev=0;
	repi(i,1,24){
		if(used[i]>1){
			ans=0;
			break;
		}
		if(used[i]==1){
			ans=min(ans,i-prev);
			prev=i;
		}
	}

	if(prev==0||used[0]>1)ans=0;

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
// jebote stupidast
int main() {
    long long n, k;
    cin >> n >> k;
    long long sum = 0;
    map<long long, long long> mp;
    for(long long i = 0; i < n; ++i){
        long long a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    for(auto x:mp){
        sum += x.second;
        if(sum >= k){
            cout << x.first;
            return 0;
        }
    }
	return 0;
 
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;


int main(){
int n;cin>>n;vector<int>v(n);
for(int i=0;i<n;i++){
int a;cin>>a;
v[i]=a;
}
int count =0,max=0;
for(int i=0;i<n;i++){
    if(v[i]>=max){
        max=v[i];
        count ++;
    }
}
cout<<count;

}

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

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 2e5 + 10;
pii V[N];

int n, x, y;

int main(){
    while(~scanf("%d", &n)){
        for(int i=0; i<n; i++){
            scanf("%d %d", &x, &y);
            V[i] = mp(y, x);
        }
        sort(V, V+n);
        LL sum = 0;
        bool flag = 1;

        for(int i=0; i<n; i++){
            sum += V[i].second;
            if(sum > V[i].first){
                flag = 0;
                break;
            }
        }
        puts(flag ? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
 
int main(int argc, const char * argv[]) {
    int a1=0,a2=0,a3=0,a4=0,dice[101][7],i=0,a=0,z=0,j=0,k=0,b=0;
    scanf("%d",&a);
    for(i=1;i<=a;i++){
        for(j=1;j<=6;j++){
            scanf("%d",&dice[i][j]);
        }
    }
    for(i=1;i<=a;i++){
        for(j=i+1;j<=a;j++){
            for(k=0;k<10000;k++){
                z = rand()%4;
                if(z==0){
                    a1=dice[i][1];
                    a2=dice[i][3];
                    a3=dice[i][4];
                    a4=dice[i][6];
                    dice[i][1]=a3;
                    dice[i][3]=a1;
                    dice[i][4]=a4;
                    dice[i][6]=a2;
                }else if(z==1){
                    a1=dice[i][1];
                    a2=dice[i][2];
                    a3=dice[i][5];
                    a4=dice[i][6];
                    dice[i][1]=a2;
                    dice[i][2]=a4;
                    dice[i][5]=a1;
                    dice[i][6]=a3;
                }else if(z==2){
                    a1=dice[i][1];
                    a2=dice[i][2];
                    a3=dice[i][5];
                    a4=dice[i][6];
                    dice[i][1]=a3;
                    dice[i][2]=a1;
                    dice[i][5]=a4;
                    dice[i][6]=a2;
                }else if(z==3){
                    a1=dice[i][1];
                    a2=dice[i][3];
                    a3=dice[i][4];
                    a4=dice[i][6];
                    dice[i][1]=a2;
                    dice[i][3]=a4;
                    dice[i][4]=a1;
                    dice[i][6]=a3;
                }
                for(b = 1;b <= 6;b++)
                    if(dice[i][b] != dice[j][b])
                        break;
                if(b == 7){
                    printf("No\n");
                    return 0;
                }
//                for(aaa = 1;aaa<=6;aaa++){
//                    if(dice[i][aaa] != dice[j][aaa]){
//                        break;
//                    }else{
//                    }
//                    if(aaa==7){
//                        printf("No\n");
//                        return 0;
//
//                    }
//                }
            }
        }
 
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 2696
import java.io.*;
import java.math.BigInteger;
import java.util.*;


public class  Main{
	static int inf=(int)2e9;
	static long[][]memo;
	static int[]v;
	static int[]ws;
	static long dp(int i,int val) {
		if(i>=v.length) {
			if(val==0)return 0;
			return inf;
		}
		if(val==0)return 0;
		if(val<0)return inf;
		if(memo[i][val]!=-1)return memo[i][val];
		
		return memo[i][val]=Math.min(dp(i+1,val-v[i])+ws[i],dp(i+1,val));
	}
    public static void main(String[] args) throws Exception{
    	MScanner sc = new MScanner(System.in);
        //MScanner sc = new MScanner("reduce.in");
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt();int w=sc.nextInt();
        v=new int[n];ws=new int[n];
        memo=new long[n][100001];
        for(int i=0;i<n;i++) {
        	ws[i]=sc.nextInt();v[i]=sc.nextInt();
        }
        
        for(long[]a:memo)Arrays.fill(a,-1);
        int ans=-1;
        for(int i=1;i<100001;i++) {
        	dp(0,i);
        }
       // System.out.println(memo[0][17]);
        for(int i=0;i<n;i++) {
        	for(int j=0;j<100001;j++) {
        		if(memo[i][j]!=-1) {
        			if(memo[i][j]<=w) {
        				ans=Math.max(ans,j);
        			}
        		}
        	}
        }
        pw.println(ans);
        pw.flush();
    }
    
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 126036
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,lint> pl;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int v[50],c[50];
int main()
{
	int n,out=0;
	cin>>n;rep(i,n) cin>>v[i];rep(i,n) cin>>c[i];
	rep(i,n) out+=max(0,v[i]-c[i]);
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
typedef  unsigned long long ULL;
ULL getn(ULL start,ULL end, ULL num);
ULL LCM(ULL a, ULL b);
ULL GCD(ULL a, ULL b);
int main(){
    ULL A,B,C,D;
    ULL nU,nC,nD,nLCM;
    
    cin >> A >> B >> C >> D;
    
    nU = getn(A,B,1);
    nC = getn(A,B,C);
    nD = getn(A,B,D);
    nLCM = getn(A,B,LCM(C,D));
    cout << nU - ( nC + nD - nLCM) << endl;;
}
ULL getn(ULL start,ULL end, ULL num){
    ULL nstart;
    ULL nend = end / num;
    if( start > 0){
        nstart = ( start - 1) / num;
    }else{
        nstart = 0;
    }
    
    return nend - nstart;
}
ULL LCM(ULL a, ULL b){
    ULL gcd = GCD(a,b);
    return ( a * b) / gcd;
}
ULL GCD(ULL a, ULL b){
    ULL temp;
    if( a < b){
        temp = a;
        a = b;
        b = temp;
    }
    while( a % b != 0){
        temp = a % b;
        a = b;
        b = temp;
    }
    
    return b;
}


Measured memory_bytes: 888
#include <stdio.h>

int main()
{
	int i, count;
	char s[101];

	scanf("%s", s);

	for (i = 0, count = 0; s[i] != '\0'; i++) {
		count++;
	}

	printf("%c%d%c\n", s[0], count - 2, s[i - 1]);
	
	return 0;
}


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

int main() {
  int N, ans=0; cin >> N;
  int A1[N+1], A2[N+1];
  cin >> A1[0];
  for (int i = 1; i<N; i++) {cin >> A1[i]; A1[i]+= A1[i-1];}
  A1[N] = A1[N-1];
  A2[0]= 0;
  cin >> A2[1];
  for (int i = 2; i<N+1; i++) {cin >> A2[i]; A2[i]+= A2[i-1];}
  for (int i = 0; i<N; i++) ans = max(ans, A1[i]+A2[N]-A2[i]);
  cout << ans << "\n";
}

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

int32_t main(){
    int n;cin>>n;
    string s;cin>>s;
    int x=0,ans=0;
    for(int i=0;i<s.length();i++){
        if (s[i]=='I')x++;
        if (s[i]=='D')x--;
        ans = max(ans,x);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3544
#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>
#include<bits/stdc++.h>

using namespace std;

/**templates**/
#define ll long long
#define LL long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sd(x) scanf("%lf",&x)
#define ss(x) scanf("%s",x)
#define pi acos(-1.0)
#define pb push_back
#define inf 1LL<<62

ll arr[100005];
int main()
{
    ll tst,a,b,m,n,res=0,ans=0;
    sl(n);
    sl(ans);
    ///ll mini=inf;
    ll maxi=0;
    for(ll i=0;i<n;i++)
    {
        sl(a);
        sl(arr[i]);
        maxi=max(maxi,a);
        ///mini=min(min,arr[i]);
    }
    ll one=inf;
    ll two=0;
    ll three=0;
    one=ceil((double)ans/maxi);
    sort(arr,arr+n);
    reverse(arr,arr+n);
    for(ll i=0;i<n;i++)
    {
        res+=arr[i];
        two++;
        if(res>=ans)
            break;
    }
    if(res<ans)
        two=inf;
    res=0;
    bool flag=0;
    for(ll i=0;i<n;i++)
    {
        if(arr[i]>maxi)
        {
            res+=arr[i];
            three++;
            if(res>=ans)
            {
                flag=1;
                break;
            }
        }
        else
            break;
    }
    if(!flag){
        res=ans-res;
        three+=ceil((double)res/maxi);
    }
    ///cout<<one<<" "<<two<<" "<<three<<endl;
    one=min(one,two);
    one=min(one,three);

    printf("%lld\n",one);



    return 0;
}


Measured memory_bytes: 1024