akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

// #include <stack>
// #include <queue>
// #include <deque>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

// #include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

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

    vi v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};

    int k; cin>>k; --k;
    cout<<v[k]<<el;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	map<string, int> ans;
	in(int, N);
	loop(i, N) {
		in(string, s);
		++ans[s];
	}
	in(int, M);
	loop(i, M) {
		in(string, s);
		--ans[s];
	}
	out(max(0, 
		max_element(ans.begin(), ans.end(), [](auto a, auto b) {
		return a.second < b.second;
	})->second));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3009;
int n,t,a[N],b[N],dp[N][N];
int main(){
  cin>>n>>t;
  for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
  for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)if(a[i]<a[j])swap(a[i],a[j]),swap(b[i],b[j]);
  int ans=0;
  for(int i=1;i<=n;i++)
    for(int j=t-1;j>=0;j--){
      int tmp=0;
      if(j+a[i]<t)tmp=dp[i-1][j+a[i]];
      dp[i][j]=max(dp[i-1][j],b[i]+tmp);
      ans=max(ans,dp[i][j]);
    }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 35584
<?php
$word = explode(' ', trim(fgets(STDIN)));
$first = strtoupper(substr($word[0], 0, 1));
$second = strtoupper(substr($word[1], 0, 1));
$third = strtoupper(substr($word[2], 0, 1));
echo $first.$second.$third;
?>

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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,K;
vi A;
vl sum = {0};
Tree<pl> T;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> K; A.resize(N);
    F0R(i,N) {
        cin >> A[i];
        A[i] -= K;
        sum.pb(sum.back()+A[i]);
    }
    ll ans = 0;
    F0R(i,sz(sum)) {
        // cout << "HI " << sum[i] << "\n";
        ans += T.order_of_key({sum[i],MOD});
        T.insert({sum[i],i});
        // cout << "OH " << ans << "\n";
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 15088
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b)
{
   if (a%b == 0) return(b);
   else return(gcd(b,a%b));
}

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}
//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}

long double f(long double a,long double b,long double x){
    long double ans;
    if(a*a*b/2.0 <= x) ans=atan(2*(a*a*b-x)/(a*a*a));
    else ans=PI/2 - atan(2*x/(a*b*b));
    
    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long double a,b,x;
    cin>>a>>b>>x;
    cout<<fixed<<f(a,b,x)*180.0/PI<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
    double a,b,x;
    cin>>a>>b>>x;

    double v = a*a*b;
    double ans;

    if(x >= v / 2.0){
        ans = atan( 2.0*(a*a*b-x) / (a*a*a) );
    }
    else{
        ans = atan( (a*b*b) / (2.0*x) );
    }

    ans = ans * 180.0 /M_PI;

    printf("%.10f\n", ans);
}

Measured memory_bytes: 384
// A - Two Abbreviations

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll get_gcd(ll x, ll y) {
	if (y > 0) return get_gcd(y, x % y);
	else return x;
}

ll get_lcm(ll x, ll y) {
	return x / get_gcd(x, y) * y;
}

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

	string S, T;
	cin >> S;
	cin >> T;

	ll L = get_lcm(N, M);

	ll ans;

	if (N > M) {
		swap(S, T);
		swap(N, M);
	}

	ll s = L / N;
	ll t = L / M;
	bool ok = true;
	for (int i=0; i<N; i++) {
		if ((i * s) % t != 0) continue;

		if (S[i] != T[(i * s) / t]) {
			ok = false;
		}
	}

	if (ok) ans = L;
	else ans = -1;

	cout << ans << endl;

	return 0;
}

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


int main() {
	string s;
	int count;
	count = 0;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') count = count + 1;
	}
	cout << count;
	

	return 0;
}



Measured memory_bytes: 256
//105
#include<iostream>
#include<string>
#include<algorithm>
//#include<math>
#include<vector>

using namespace std;
int main(){
    string S;
    cin >> S;  

    bool flag = false;

    if(S[0] == S[1]){
        flag = true;
    }if(S[1] == S[2]){
        flag = true;
    }if(S[2] == S[3]){
        flag = true;
    }

    if(flag){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }



}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAX_N 1000000

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (1) {
		ll h, w; cin >> h >> w;
		if (h == 0 && w == 0) break;
		rep(i, h) {
			rep(j, w) {
				if (i == 0 || j == 0 || i == h - 1 || j == w - 1)	cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;}
  Mint operator-(Mint a) const{return Mint(v)-=a;}
  Mint operator*(Mint a) const{return Mint(v)*=a;}
  Mint operator/(Mint a) const{return Mint(v)/=a;}

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
const int MAX = 3030;
using M = Mint<int, 998244353>;
M dp[MAX][MAX]={};
int used[MAX][MAX]={};

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

  int a,b,c,d;
  cin>>a>>b>>c>>d;
  dp[a][b]=1;

  for(int i=a;i<c;i++){
    M sum{0};
    for(int j=b;j<=d;j++){
      dp[i+1][j]+=dp[i][j]*M(j);
      sum*=M(i);
      dp[i+1][j]+=sum;
      sum+=dp[i][j];
    }
  }

  M ans{0};
  for(int j=b;j<=d;j++)
    ans+=dp[c][j]*M(c).pow(d-j);
  cout<<ans<<newl;
  return 0;
}


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

int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int x=a*100+b*10+c;
    if (x%4)
    {
        printf("NO\n");
    }
    else
    {
        printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int x, a, b;
    cin >> x >> a >> b;
    if (b - a <= 0) {
        cout << "delicious" << endl;
    } else {
        if (b - a <= x) {
            cout << "safe" << endl;
        } else {
            cout << "dangerous" << endl;
        }
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= b; --i)
#define range(i, a, b, c) for (int i = a;             \
                               c > 0 ? i < b : i > b; \
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << endl
#else
const bool test = false;
#define dump(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while (getline(ss, buffer, sep))
    {
        v.push_back(buffer);
    }
    return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
    return accumulate(begin, end, 0ll);
}
 
void solve();
 
class Solver {
public:
  int N, K;
  int l[MAX];
  
  void solve() {
	cin >> N >> K;
	rep(i, N) cin >> l[i];
	sort(l, l+N);
	cout << accumulate(l+(N-K), l+N, 0LL) << endl;
  }
};
 
signed main()
{
    cout << fixed << setprecision(20);
    auto ptr = new Solver();
    ptr->solve();
    delete ptr;
	// while (true) {
	//   auto ptr = new Solver();
	//   ptr->solve();
	//   delete ptr;
    // }
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <cassert>

std::set<int> edges[100005];
int deg[100005];

std::queue<int> leaves;

void remove(int v){
  for(int w:edges[v]){
    edges[w].erase(v);
    if(edges[w].size()==1){
      leaves.push(w);
    }
  }
}

int main(){
  int N;
  scanf("%d",&N);
  for(int i=0;i<N-1;i++){
    int U,V;
    scanf("%d %d",&U,&V);
    U--,V--;
    edges[U].insert(V);
    edges[V].insert(U);
  }
  for(int i=0;i<N;i++){
    if(edges[i].size()==0){
      printf("First\n");
      return 0;
    }
    if(edges[i].size()==1){
      leaves.push(i);
    }
  }
  while(!leaves.empty()){
    int node=leaves.front();
    leaves.pop();
    if(edges[node].empty()){
      printf("First\n");
      return 0;
    }
    int v=*edges[node].begin();
    if(edges[v].size()!=1) remove(*edges[node].begin());
  }
  printf("Second\n");
  return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin>>n;
  vll a(n);
  REP(i,n)cin>>a[i];
  
  ll cnt=0;
  REP1(i,n){
    if(a[i]==a[i-1]){
      cnt++;
      i++;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int M = 101;
const int INF = 19191919;

// ?????¬???????????°???i?¨?????????£??????????¶?????????????j???????????????????¶???????????????????max
int maxcal[M][M];

// ?????????????????????i?????????????????????????????????max
const int H = 10001;
int maxh[H]={};

// i??\???????????????????????????j???????????????????????????max
int dp[M][M];


int main()
{
    int S,T,U,N,O,D;
    cin >>S >>T >>U >>N >>O >>D;

    vector<int> e(T),c(T),h(N),a(N);
    rep(i,T) cin >>e[i] >>c[i];
    rep(i,N) cin >>h[i] >>a[i];

    fill(maxcal[0],maxcal[M],-INF);
    maxcal[0][0] = 0;
    rep(i,T)for(int j=M-2; j>=0; --j)rep(k,M)
    {
        int cost = k+e[i];
        if(cost<M) maxcal[j+1][cost] = max(maxcal[j+1][cost], maxcal[j][k]+c[i]);
    }

    rep(i,N)rep(j,H)
    {
        int nj = j+a[i];
        if(nj<H) maxh[nj] = max(maxh[nj], maxh[j]+h[i]);
    }
    for(int i=1; i<H; ++i) maxh[i] = max(maxh[i],maxh[i-1]);

    fill(dp[0],dp[M],-INF);
    dp[0][S] = 0;
    // i??\???,??????j
    rep(i,D)rep(j,S+1)
    {
        // ?????????k?¶???????????????¬???????????°??????
        rep(k,j+1)
        {
            int cal = maxcal[U][k];
            if(cal<0) continue;
            dp[i+1][min(j-k+O,S)] = max(dp[i+1][min(j-k+O,S)], dp[i][j]+maxh[cal]);
        }
    }

    int ans = -1;
    rep(i,M) ans = max(ans,dp[D][i]);
    cout << ans << endl;
    return 0;
}

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

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


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
using namespace std;
#define LARGE 1000000007

int main() {
    int A, B, K; cin >> A >> B >> K;
	int count = 0;
	int num = min(A, B);
	while(true){
		if(A%num == 0 && B%num == 0){
			count++;
		}
		if(count == K) break;
		num--;
	}
	cout << num << endl;
}

Measured memory_bytes: 256
def getsum(BITTree, i): 
    s = 0
    i += 1
    while i > 0: 
        s += BITTree[i] 
        i -= i & (-i) 
    return s 
  
def updatebit(BITTree , n , i ,v): 
    i += 1
    while i <= n: 
        BITTree[i] += v 
        i += i & (-i) 

def construct(arr, n): 
    BITTree = [0]*(n+1) 
    for i in range(n): 
        updatebit(BITTree, n, i, arr[i]) 
    return BITTree

def main():
    n, q = map(int, input().split())
    a = list(map(int, input().split()))
    BITTree = construct(a, len(a))
    for _ in range(q):
        i, j, k = map(int, input().split())
        if i:
            print(getsum(BITTree, k - 1) - getsum(BITTree, j - 1))
        else:
            updatebit(BITTree, len(a), j, k)
    # freq = [2, 1, 1, 3, 2, 3, 4, 5, 6, 7, 8, 9] 
    # BITTree = construct(freq,len(freq)) 
    # print("Sum of elements in arr[0..5] is " + str(getsum(BITTree,5))) 
    # freq[3] += 6
    # updatebit(BITTree, len(freq), 3, 6) 
    # print("Sum of elements in arr[0..5]"+
    #                     " after update is " + str(getsum(BITTree,5))) 

if __name__ == "__main__":
    main()

Measured memory_bytes: 65168
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pi pair<int, int>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define deb(x) cout << #x << ":" << x << endl;
/* freopen("input.txt", "r", stdin); */
/* freopen("output.txt", "w", stdout); */
const ll inf = 1e17 + 7, MOD = 1e7 + 9;


int main() {
	fastio();
	int r;
	cin >> r;
	double ans = 2 * r * 3.14159265358979323846;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

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;
}

struct UnionFind {
  vector<ll> d;
  ll connection_count;
  UnionFind(ll n = 0) : d(n, -1) {
    connection_count = n;
  }
  ll find(ll x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    connection_count--;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(ll x, ll y) {
    return find(x) == find(y);
  }
  ll size(ll x) {
    return -d[find(x)];
  }
};

signed main() {
  init();
  ll N, M;
  cin >> N >> M;

  UnionFind uf(M);
  mll m;

  rep(i, N) {
    ll k;
    cin >> k;
    ll before_l = INF;
    rep(i, k) {
      ll l;
      cin >> l;
      l--;
      if (before_l != INF) uf.unite(l, before_l);
      m[l]++;
      before_l = l;
    }
  }

  bool ok = true;
  for (auto mm : m)
    if (uf.size(mm.first) != (ll)m.size()) ok = false;
  if (ok) YN;

  return 0;
}

Measured memory_bytes: 7800
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	int ans = 700;
	cin >> S;
	rep(i, 3) if (S[i] == 'o') ans += 100;
	cout << ans << endl;

	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main test = new Main();
		test.run();
	}
	
	void run(){
		final BufferedReader  in = new BufferedReader(new InputStreamReader(System.in));
		
		do {
			int[] indata = null;
			try{
				indata = changeData(in.readLine());
			}catch(IOException e){
			}
			
			if(!checkData(indata))break;
		}while(true);		
	}
	
	int[] changeData(String data){
		String[] elem = data.split(" ");
		int[] datas = new int[elem.length];
		for (int i = 0; i < elem.length; i++){
			datas[i] = Integer.parseInt(elem[i]);
		}
		return datas;
	}
	boolean checkData(int[] data){
		if (data[0]==0 && data[1]==0) return false;
		System.out.println(countData(data[0],data[1]));
		return true;
	}
	
	int countData(int a, int b){
		int count=0;
		for(int i=1; i<=a; i++)
			for(int j=i+1; j<=a; j++)
				for(int k=j+1; k<=a; k++)
					if (i+j+k == b)count ++;
		return count;
	}
}

Measured memory_bytes: 24432
#include<bits/stdc++.h>
using namespace std;
int n,ans=1e9;
int calc(int x){
	if (x==0)return x;
	return calc(x/10)+x%10;
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<n;i++)ans=min(ans,calc(i)+calc(n-i));
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define endl "\n"
const long long mod=1e9+7;
const double pi=acos(-1);
const long long inf=1000000000000000005LL;

int n,k,arr[100100];
ll dp[110][100010];
bool hah[110][100010];
/*ll hitung(ll x,ll y){
	if(x==n)
		if(y==0)
			return 1;
		else
			return 0;
	if(hah[x][y])
		return dp[x][y];
	for(int i=0;i<=arr[x];i++)
		if(y>=i){
			dp[x][y]=dp[x][y]+hitung(x+1,y-i);
			dp[x][y]=dp[x][y]%mod;
		}
	hah[x][y]=true;
	return dp[x][y];
}*/

int main(){
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>arr[i];
	for(int i=0;i<n;i++)
		dp[i][0]=1;
	for(int i=n-1;i>=0;i--){
		for(int j=1;j<=k;j++){
			if(i==n-1){
				if(j<=arr[i]){
					dp[i][j]=dp[i][j-1]+1;
				}else{
					dp[i][j]=dp[i][j-1];
				}
			}else{
				int h=j,l=max(0,j-arr[i]);
				dp[i][j]=dp[i][j-1]+((l==0)?dp[i+1][h]:dp[i+1][h]-dp[i+1][l-1]+mod);
				dp[i][j]=dp[i][j]%mod;
			}
		}
	}
	cout<<(dp[0][k]-dp[0][k-1]+mod)%mod<<endl;
}


Measured memory_bytes: 80128
MAIN : {
	my $n = <STDIN>;
	chomp $n;
	my $s1 = <STDIN>;
	chomp $s1;
	my @list = split(" ", $s1);
	
	@list = sort {$a <=> $b} @list;

	while (1) {
		if (scalar(@list) == 1) {
			last;
		}
		my $min = -1;
		for ($i = 1; $i < scalar(@list); $i++) {
			my $mod = $list[$i] % $list[0];
			if ($mod == 0) {
			}
			else {
				if ($min == -1) {
					$min = $mod;
				}
				elsif ($mod < $min) {
					$min = $mod;
				}
			}
		}
		
		if ($min == -1) {
			print STDOUT $list[0], "\n";
			exit 0;
		}
		
		unshift @list, $min;
	}
	
	print join (",", @list), "\n";
}





__END__

Measured memory_bytes: 18876
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <cstring> // memset
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#define ALL(x) (x).begin(), (x).end()
#define INF 1e9
#define LOG(x) cout << #x << " = " << (x) << endl
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    
    return 0;
}
 

Measured memory_bytes: 256
N = int(input())
if (400 <= N < 600):
    print(8)
elif (600 <= N < 800):
    print(7) 
elif (800 <= N < 1000):
    print(6) 
elif (1000 <= N < 1200):
    print(5) 
elif (1200 <= N < 1400):
    print(4) 
elif (1400 <= N < 1600):
    print(3) 
elif (1600 <= N < 1800):
    print(2) 
elif (1800 <= N < 2000):
    print(1) 


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    SPEED
    int N; cin >> N;
    vector<int> V(N+1),W(N+1);
    for(int i = 1; i <= N; ++i) cin >> V[i] >> W[i];

    //O(Q)
    int nl = 1<<10,nr=1<<8,L_max=100001;
    vector<int> msb(nl,0);
    for(int i = 1; i < nl; ++i) msb[i]=31-__builtin_clz(i);
    vector<int> bit_w_dp(nl,0);
    vector<int> bit_v_dp(nl,0);
    vector<vector<int>> dp(nl,vector<int>(L_max,0));

    //前計算
    for(int n = 1; n < min(nl,N+1); ++n) {
        int k = 2*n;
        vector<int> l;
        while(k/=2) l.push_back(k);
        int sz=l.size();
        //bit全探索
        for(int i = 1; i < (1<<sz); ++i) {
            bit_w_dp[i]=bit_w_dp[i^(1<<msb[i])]+W[l[msb[i]]];
            bit_v_dp[i]=bit_v_dp[i^(1<<msb[i])]+V[l[msb[i]]];
            if(bit_w_dp[i]<=L_max) chmax(dp[n][bit_w_dp[i]],bit_v_dp[i]);
        }
        //累積max
        for(int i = 1; i < L_max; ++i) {
            chmax(dp[n][i],dp[n][i-1]);
        }
    }

    int Q; cin >> Q;
    string ans_str="";

    //クエリ
    while(Q--) {
        int p,L; cin >> p >> L;
        vector<int> r;
        int k = 2*p,l=0;
        while(k/=2) {
            if(k<nl) chmax(l,k);
            else r.push_back(k);
        }
        int sz = r.size(),ans=dp[l][L];
        //bit全探索
        for(int i = 1; i < (1<<sz); ++i) {
            bit_w_dp[i]=bit_w_dp[i^(1<<msb[i])]+W[r[msb[i]]];
            bit_v_dp[i]=bit_v_dp[i^(1<<msb[i])]+V[r[msb[i]]];
            if(bit_w_dp[i]<=L) chmax(ans,dp[l][L - bit_w_dp[i]]+bit_v_dp[i]);
        }
        ans_str += to_string(ans)+"\n";
    }
    cout << ans_str;

    return 0;
}


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010
const int N = 1e5;

struct DSU {
    int connected;
    int par[N], sz[N];

    DSU() {}

    DSU(int n) {
        for (int i = 1; i <= n; i++) {
            par[i] = i;
            sz[i] = 1;
        }
        connected = n;
    }

    int getPar(int k) {
        while (k != par[k]) {
            par[k] = par[par[k]];
            k = par[k];
        }
        return k;
    }

    int getSize(int k) {
        return sz[getPar(k)];
    }

    void unite(int u, int v) {
        int par1 = getPar(u), par2 = getPar(v);

        if (par1 == par2)
            return;

        connected--;

        if (sz[par1] > sz[par2])
            swap(par1, par2);

        sz[par2] += sz[par1];
        sz[par1] = 0;
        par[par1] = par[par2];
    }
};

vector<int> g[maxn], g2[maxn];
int visited[maxn];
deque<int> order;
vector<int> component;

void dfs(int u) {
    visited[u] = true;
    for (auto x : g[u]) {
        if (!visited[x]) {
            dfs(x);
        }
    }
    order.push_front(u);
}


void dfs1(int u) {
    component.push_back(u);
    visited[u] = true;
    for (auto x : g2[u]) {
        if (!visited[x]) {
            dfs1(x);
        }
    }
}

void solve() {
    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;

        g[a].push_back(b);
        g2[b].push_back(a);
    }
    for (int i = 0; i < n; i++)
        if (!visited[i])
            dfs(i);
    memset(visited, 0, sizeof visited);
    DSU d(n + 1);

    for (auto x : order)
        if (!visited[x]) {
            dfs1(x);
            for (auto p : component)
                d.unite(p, x);
            component.clear();
        }
    int q;
    cin >> q;

    for (int j = 0; j < q; ++j) {
        int a, b;
        cin >> a >> b;  

        if (d.getPar(a) == d.getPar(b))
            cout << 1 << endl;
        else
            cout << 0 << endl;
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 10084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;

class Program
{
	static void Main() => new Program().Solve();

	void Solve()
	{
		var xn = ReadLongArray();
		var x = xn[0];
		var n = xn[1];

		var p = new HashSet<long>();

		if (n == 0) {
			Console.ReadLine();
		} else {
			foreach (var a in ReadLongArray()) {
				p.Add(a);
			}
		}

		for (var i = 0; ; i++) {
			if (!p.Contains(x - i)) {
				Console.WriteLine(x - i);
				return;
			} else if (!p.Contains(x + i)) {
				Console.WriteLine(x + i);
				return;
			}
		}
	}

	#region Console.Read 関係
	long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
	long ReadLong() => long.Parse(Console.ReadLine());
	#endregion
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

int a[114514];

signed main() {
	int n, k, q;
	cin >> n >> k >> q;
	rep(i, q) {
		int x;
		cin >> x;
		a[x - 1]++;
	}
	rep(i, n) {
		if (k - (q - a[i]) <= 0) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 1408
n = gets.to_i
t = 0;
h = 0;

n.times do
  tt, hh = gets.split(" ").map(&:to_s)
  if tt == hh
    t += 1
    h += 1
  elsif tt > hh
    t += 3
  else
    h += 3
  end
end
puts "#{t} #{h}"



Measured memory_bytes: 6860
a_can = (1..26).select{|i| 26.gcd(i) == 1}
cl = ('a'..'z').to_a

gets.to_i.times do
  s = gets.chomp
  hints = s.split(' ').select{|st| st.length==4}

  @alph = a_can.find do |a|
    @beta = (0..26).find do |b|
      %w(this that).any?{|h|
        hints.include?(h.chars.map{|i| cl[(a*cl.index(i)+b)%26]}.join)
      }
    end
  end

  map = (0..25).map{|i| (@alph*i+@beta)%26}
  puts s.chars.map{|i| cl.include?(i) ? cl[map.index(cl.index(i))] : i }.join
end

Measured memory_bytes: 6144
import math

def make_divisors(n):
    #https://qiita.com/LorseKudos/items/9eb560494862c8b4eb56
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

a,b,k = map(int,input().split())
tmp = math.gcd(a,b)
ans = make_divisors(tmp)
print(ans[-k])

Measured memory_bytes: 9132
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n = int(input())
ok = False
cont = 0
for i in xrange(n):
    a,b = (int(x) for x in input().split())
    if a == b:
        cont += 1
        if cont == 3:
            ok = True
    else:
        cont = 0
if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 85948
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(x) (x).begin (),(x).end()
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define si set<ll>
#define rep(i,a,b) for(unsigned ll i=a;i<b;i++)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MOD 1000000007LL
#define pi 3.14159265358
ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}
bool isPrime(int num){
    bool flag=true;
    for(int i = 2; i*i <= num ; i++) {
       if(num % i == 0) {
          flag = false;
          break;
       }
    }
    return flag;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

void solve()
{
   ll n,m,sum=0; cin>>n>>m;
   rep(i,0,m)
   {
       ll a; cin>>a;
       sum+= a;
   }
   ll res = n-sum;
   if(res>=0) cout<<res;
   else cout<<-1;
}

int main()
{
    SPEED;
    ll t = 1;

  // cin>>t;

    while(t--) solve();

   return 0;
}


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

int main(void)
{
	string str;
	char c;

	getline(cin,str);
	for (int i=0; i<str.size(); i++){
		c = str.at(i);
		if ('A'<=c && c<='Z') c += 'a'-'A';
		else if ('a'<=c && c<='z') c -= 'a'-'A';
		str.at(i)=c;
	}
	cout << str <<endl;
	return 0;
}

Measured memory_bytes: 1176
#include <stdio.h>
#define NOT_FOUND -1
#define MAX 100000

int binarySearch(int[],int);

int n;

int main(){
    int q,count = 0;
    int S[MAX],T[MAX];

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

    scanf("%d",&q);
    for(int i = 0;i < q;i++)scanf("%d",&T[i]);

    for(int i = 0;i < q;i++)if(binarySearch(S,T[i]) >= 0)count++;

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

    return 0;
}

int binarySearch(int A[n],int key){
    int left = 0,mid,right = n;

    while(left < right){
        mid = (left + right) / 2;
        if(A[mid] == key)return mid;
        else if(key < A[mid])right = mid;
        else left = mid + 1;
    }

    return NOT_FOUND;
}


Measured memory_bytes: 2320
ac t ts sp = ts + (last sp) - (t!!(head sp - 1))

main=do
 getLine
 t<-map read.words<$>getLine
 let ts = sum t
 getLine
 spl<-map (map read.words).lines<$>getContents
 mapM_ print$map (ac t ts) spl  

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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  string A, B;
  cin >> A >> B;
  if(A.size() > B.size()){
    cout << "GREATER" << endl;
    return 0;
  }else if(A.size() < B.size()){
    cout << "LESS" << endl;
    return 0;
  }else{
    for(int i = 0; i < A.size(); i++){
      if(int(A[i]) > int(B[i])){
        cout << "GREATER" << endl;
        return 0;
      }else if(int(A[i] < B[i])){
        cout << "LESS" << endl;
        return 0;
      }
    }
  }
  cout << "EQUAL" << endl;
}



Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long>A(N), B(N), C(N);
    for (int i = 0; i < N; i++)cin >> A[i];
    for (int i = 0; i < N; i++)cin >> B[i];
    for (int i = 0; i < N; i++)cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        auto itrA = lower_bound(A.begin(), A.end(), B[i]);
        long long a = itrA - A.begin();
        auto itrC = upper_bound(C.begin(), C.end(), B[i]);
        long long c = N - (itrC - C.begin());
        ans += a*c;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string S;
	cin >> S;
	vector<int> sum(n);
	int cnt_migi = 0;
	int cnt_hidari = 0;
	rep(i, n) {
		if (S[i] == 'E') cnt_migi++;
	}

	int ans = 1000000007;
	rep(i, n) {
		if (S[i] == 'E') cnt_migi--;
		ans = min(ans, cnt_migi + cnt_hidari);
		if (S[i] == 'W') cnt_hidari++;
	}

	dunk(ans);

	return 0;
}

Measured memory_bytes: 1812
'use strict'

function main(s) {
  s = s.split('\n').slice(0, -1);

  const N = Number(s[0].split(' ')[0]);
  const K = Number(s[0].split(' ')[1]);
  const bars = s[1].split(' ').map(n => Number(n));
  bars.sort((a, b) => a - b);

  const ans = bars.slice(N - K).reduce((a, b) => a + b);
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
vector<int>adj[maxn];
bool visited[maxn];
int dp[maxn];

void dfs(int i){
    visited[i]=true;
    for(auto it:adj[i]){
        if(!visited[it]){
            dfs(it);
        }

            if(dp[i]<dp[it]+1){
                dp[i]=dp[it]+1;
            }

    }}
void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);

    }
    for(int i=1;i<=n;i++){
        if(!visited[i]){
            dfs(i);
        }
    }
    int maxx=0;
    for(int i=1;i<=n;i++){
        if(dp[i]>maxx){
            maxx=dp[i];
        }
    }
    cout<<maxx<<endl;
}

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

    solve();
    return 0;
    }


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

int main() {
	// your code goes here
    long long int n, a,b;
    cin>>n>>a>>b;
    long long int i=0;
    if((b-a)%2 == 0 ){
        
        cout<<(b-a)/2<<endl;
    }
    else{
        if((a-1) <= (n-b)){
            i = (a-1)+1+(((b-1)-a)/2);
        }
        else{
           i = (n-b) + 1 + ((b-(a+1))/2);
        }
        
        cout<<i<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;
using Graph = vector<vector<int>>;


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; }

int myAbs(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

/*vector<bool> seen;
void dfs(const Graph& G, int v, int count) {
    seen[v] = true;
    count = 0;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        if (count > 2) continue;
        count++;
        cout << count << ":" << next_v << endl;
        dfs(G, next_v, count);
    }
}*/

const int INF = 100000000;
const int MOD = 1000000007;
typedef pair<int, int> P;
long long a[100010][3];
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) cin >> a[i][j];
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {//jのループはi日目の前日
            for (int k = 0; k < 3; k++) {//kのループはi日目当日
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < 3; i++) chmax(ans, dp[N][i]);
    cout << ans << endl;
}


Measured memory_bytes: 4992
<?php

while (true) {
    
    fscanf(STDIN, "%d %d", $height, $width);
    
    if ($height == 0 && $width == 0){
        break;
    }
    
    $rectangle = new Rectangle($height, $width);
    $rectangles[] = $rectangle->drawCheck();
}

echo implode(PHP_EOL, $rectangles),PHP_EOL;

class Rectangle {
    
    private $height;
    private $width;
    
    public function __construct($height, $width){
        $this->height = $height;
        $this->width = $width;
    }
    
    public function draw(){
        $rectangle = [];
        for($i = 0; $i < $this->height; $i++){
            $rectangle[] = str_repeat("#", $this->width);
        }
        return implode(PHP_EOL, $rectangle).PHP_EOL;
    }
    
    public function drawCheck(){
        $rectangle = [];
        for($i = 0; $i < $this->height; $i++){
            if($i == 0 || $i == $this->height -1 || $this->width <= 2){
                $rectangle[] = str_repeat("#", $this->width);
            }else{
                $rectangle[] = "#".str_repeat(".", $this->width - 2)."#";
            }
        }
        return implode(PHP_EOL, $rectangle).PHP_EOL;
    }
    
}

Measured memory_bytes: 15160