akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define reg register
#pragma GCC optimize(3)
#pragma GCC optimize("02")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
class complex{
public:
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline complex & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
int n;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	inc>>n;
	int x;
	while(n--){
		inc>>x;
		if(x%2==0&&!(x%3==0||x%5==0)) return puts("DENIED"),0;
	}
	return puts("APPROVED"),0;
}


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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if(a >= 13) cout << b << endl;
  else if(a >= 6) cout << b/2 << endl;
  else cout << 0 << endl;
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int dy[4]={-1,0,1,0};
int dx[4]={0,1,0,-1};


int H,W;
char si,ti;
int sy,sx;

char t[100][100];
bool inField(int y,int x){
  return (0<=y&&y<H&&0<=x&&x<W);
}
bool isAl(char ch){
  return ('A'<=ch&&ch<='Z');
}

int solve(){
  typedef pair<int,int> P;
  map< P , int > d;
  
  queue< P > Q;
  Q.push( P(sy,sx) );
  d[ P(sy,sx) ]=0;
  while(!Q.empty()){
    P p=Q.front();Q.pop();
    int py=p.first;
    int px=p.second;
    if( t[py][px]==ti )return d[p];
    
    for(int dir=0;dir<4;dir++){
      int ny=py+dy[dir];
      int nx=px+dx[dir];
      bool flag=true;

      
      while( inField(ny,nx) && !isAl(t[ny][nx]) ){
        ny+=dy[dir];
        nx+=dx[dir];
        if(t[ny][nx]=='.')flag=false;
        if(dx[dir]==0 && t[ny][nx]=='-')flag=false;
        if(dy[dir]==0 && t[ny][nx]=='|')flag=false;
      }
      
      if(!flag)continue;
      if( !inField(ny,nx) )continue;
      if( !isAl(t[ny][nx]) )continue;
      if( d.count( P(ny,nx) ) )continue;
      d[ P(ny,nx) ] = d[ P(py,px) ]+1;
      Q.push( P(ny,nx) );
    }
  }
  assert(0);
}

int main(){
  cin>>H>>W>>si>>ti;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>t[i][j];
      if(t[i][j]==si){
        sy=i;
        sx=j;
      }
    }
  }
  cout<<solve()<<endl;
  return 0;
}



Measured memory_bytes: 3124
// abc085_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> D(N);
    REP(i, N) cin >> D[i];
    sort(ALL(D), greater<int>());

    int ans = 1;
    REPN(i, 1, N){
        if (D[i] != D[i-1]){
            ans ++;
        }
    }

    print(ans);

    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mii map<lli,lli>
#define msi map<string,lli>
#define pii pair<lli,lli> 
#define vi vector<lli> 
#define vvi vector< vector<lli> >
#define sz(x) (lli)x.size()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX1 998244353
#define MAX2 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define input(data,n,command) for(lli i=0;i<n;i++){lli tmp;cin>>tmp;data.pb(tmp);command}
#define sort_asc(a) sort(a.begin(),a.end());
//#define sort_desc(a) sort(a.begin(),a.end(),greater<lli>());
#define display(a) for(lli i = 0 ;i<a.size();i++){cout<<a[i]<<" ";} cout<<endl;
#define rep(i,a,b) for(lli i = a;i < b;i++)
#define endl "\n"

//Written By MUDIT BHARDWAJ...
/*--------------------------------------------------------------------*/
//vector<pair<lli,lli>>adj[300010];

lli solve()
{
    //start from here
    lli n;
    cin>>n;
    lli a,w,t,r;
    a = 0;
    w = 0;
    t = 0;
    r = 0;
    rep(i,0,n)
    {
        string s;
        cin>>s;
        if(s[0] == 'A')
        {
            a++;
        }
        else if(s[0] == 'W')
        {
            w++;
        }
        else if(s[0] == 'T')
        {
            t++;
        }
        else
        {
            r++;
        }
    }
    cout<<"AC x "<<a<<endl<<"WA x "<<w<<endl<<"TLE x "<<t<<endl<<"RE x "<<r<<endl;
    return 0;
}

int main()
{
    ios
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    lli T=1;
    //cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}
/*-----------------------------------------------------------------------*/

Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100
#define INF 10000000



int Q[N];
int n,a[N][N];
int dt[N];
int head=0,tail=0;

void enqueue(int);
int dequeue();
void bfs(int);



int main(){
  int m,i,j,k,u;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&m);
      m--;
      a[u][m]=1;
    }
  }
  bfs(0);

  return 0;
}



void enqueue(int x){
  Q[tail] = x;
  tail = (tail + 1) % N;
}

int dequeue(){
  int x = Q[head];
  head = (head + 1) % N;
  return x;
}


void bfs(int s){
  int i,v,u;
  enqueue(s);
  
  for(i=0;i<n;i++) dt[i]=INF;
  dt[s]=0;
  while(head != tail){
    u = dequeue();
    for(v=0;v<n;v++){
      if(a[u][v]==0) continue;
      if(dt[v]!=INF) continue;
      dt[v]=dt[u] +1;
      enqueue(v);
    }
  }
  for(i=0;i<n;i++){
    printf("%d ",i+1);
    if(dt[i]==INF) printf("-1");
    else printf("%d",dt[i]);
    printf("\n");
  }


}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 998244353;
Int INF = 1e18;
double EPS = 0.00000001;

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> h(n);
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        cin >> h[i];
        if (h[i] >= k) {
            res++;
        }
    }
    dump(res);
    return 0;
}

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

int main(){
  int k, n; cin >> k >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = a[n-1] - a[0];
  rep(i, n){
    if(i == 0) continue;
    ans = min(ans, k-(a[i]-a[i-1]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin >> str;
    int n = str.length();
    int minx = 1000;
    for(int i=0; i < n-2; i++){
       string tmp = str.substr(i,3);
       int tmp2 = stoi(tmp);
       int tmp3 = abs(753-tmp2);
       minx = min(minx,tmp3);
    }
    cout << minx << endl;
}

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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int k, t;

	cin >> k >> t;
	vector<int> a(t);
	REPU(i, 0, t) cin >> a[i];
	sort(ALL(a));
	int x = 2 * a[t - 1] - k - 1;
	amax(x, 0);
	cout << x << endl;

	return 0;
}


Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll a,b,c,d;
            cin>>a>>b>>c>>d;
            while(true)
            {
                c=c-b;
                if(c<=0)
                {
                    cout<<"Yes"<<endl;
                    return 0;
                }
                a=a-d;
                if(a<=0)
                {
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        return 0;
    }


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

int n, m;
Vi va;
vector<pii> vm;
priority_queue<int, Vi, greater<int>> que;

void init()
{
	cin >> n >> m;
	va.resize(n);
	REP(i, n) cin >> va[i];
	vm.reserve(m);
	REP(i, m)
	{
		int b, c; cin >> b >> c;
		vm.emplace_back(pii(c, b));
	}
	sort(ALL(vm), greater<pii>());
}


int main()
{
	init();

	int i = 0;
	while (que.size() < n && i < m)
	{
		REP(_i, vm[i].second)
			que.push(vm[i].first);
		++i;
	}

	REP(i, n)
		que.push(va[i]);

	while (que.size() > n)
		que.pop();
	
	ll ans = 0;
	REP(i, n)
	{
		ans += (ll)que.top();
		que.pop();
	}

	cout << ans << endl;
	
}


Measured memory_bytes: 2552
n, x = map(int, input().split())
a = list(map(int, input().split() ))
a.sort()
s = 0
cnt = 0
for i in a:
    s += i
    if s > x:
        print(cnt)
        exit()
    if s==x:
        print(cnt+1)
        exit()
    cnt+=1
if s == x:
    print(cnt)
else:
    print(cnt-1)

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

int main()
{
    ll D, T, S;
    cin >> D >> T >> S;
    ll tmp = T * S;

    if (tmp >= D) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
	



}


Measured memory_bytes: 3632
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
  int N, K = 0;
  cin >> N >> K;

  unordered_set<int> members;

  for (int i = 0; i < N; i++) {
    members.insert(i + 1);
  }

  int member = 0;
  int d = 0;

  for (int i = 0; i < K; i++) {
    if (members.size() == 0) {
      break;
    }
    cin >> d;
    for (int j = 0; j < d; j++) {
      if (members.size() == 0) {
        break;
      }

      cin >> member;
      members.erase(member);
    }
  }

  cout << members.size() << endl;

  return 0;
}


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

int main() {
  int H,N;
  cin >> H>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int ans=0;
  int C=0;
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  for(int i=0;i<N;i++){
    ans+=A[i];
    if(ans>=H){
      C++;
      break;
    }
    else{
      C*=0;
    }
  }
  if(C>0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
    int A[4];
    cin>>A[0]>>A[1]>>A[2]>>A[3];
    sort(A,A+4);
    if(A[0]==1&&A[1]==4&&A[2]==7&&A[3]==9) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin >> s;
  int len = s.size();
  int cc = 0;
  for(int i = 0; 2*i < len; i++){
    if(s[i] != s[len-i-1])cc++;
  }
  cout << cc << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> h(n); for (auto&& e : h) cin >> e;
  V<> dp(n);
  for (int i = n - 2; i >= 0; --i) if (h[i] >= h[i + 1]) {
    dp[i] = 1 + dp[i + 1];
  }
  cout << *max_element(begin(dp), end(dp)) << '\n';
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;

int main(void){
    int  n;
    cin>>n;
    vector<ll>a(n),b(n),s1(n+1),s2(n+1);
    for(int i=0;i<n;i++){
        cin>>a[i];
        s1[i+1]=s1[i]+a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        s2[i+1]=s2[i]+b[i];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll tmp = s1[i+1];
        tmp+=s2[n]-s2[i];
        ans = max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' && ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 5005, mod = 1e9 + 7;
struct Edges { int x, y, z; } G[MAXN];
int fa[MAXN], a[MAXN], vis[MAXN];
struct Edge { int to, next, dis; } e[MAXN * 2];
int head[MAXN], tot;
int f[MAXN], dis[MAXN], dep[MAXN];

inline void addedge(int from, int to, int dis) {
  e[++tot] = (Edge){to, head[from], dis};
  head[from] = tot;
  e[++tot] = (Edge){from, head[to], dis};
  head[to] = tot;
}

inline bool cmp(Edges x, Edges y) { return x.z < y.z; }

int Find(int x) { return fa[x] == x ? x : fa[x] = Find(fa[x]); }
inline LL qpow(LL a, LL k) {
  LL re = 1;
  for (; k; k >>= 1, a = a * a % mod)
    if (k & 1) re = re * a % mod;
  return re; 
}

void Dfs(int now, int fa) {
  dep[now] = dep[fa] + 1;
  f[now] = fa;
  for (RI i = head[now]; i; i = e[i].next)
    if (e[i].to != fa)
      dis[e[i].to] = e[i].dis, Dfs(e[i].to, now);
}

inline int Get(int x, int y) {
  int re = 0;
  while (x != y)
    if (dep[x] > dep[y]) re = max(re, dis[x]), x = f[x];
    else re = max(re, dis[y]), y = f[y];
  return re;
}

signed main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m; read(n), read(m);
  int x; read(x);
  for (RI i = 1; i <= m; ++i)
    read(G[i].x), read(G[i].y), read(G[i].z);
  sort(G + 1, G + 1 + m, cmp);
  for (RI i = 1; i <= n; ++i) fa[i] = i;
  int sum = 0;
  for (RI i = 1; i <= m; ++i) {
    int fx = Find(G[i].x), fy = Find(G[i].y);
    if (fx == fy) continue;
    else fa[fx] = fy, sum += G[i].z, vis[i] = 1, addedge(G[i].x, G[i].y, G[i].z);
  }
  LL ans = 0;
  if (sum == x) ans += (qpow(2, n - 1) - 2) * qpow(2, m - n + 1) % mod;
  Dfs(1, 0);
  int cnt = 0;
  for (RI i = 1; i <= m; ++i)
    if (!vis[i])
      a[++cnt] = G[i].z - Get(G[i].x, G[i].y);
  sort(a + 1, a + 1 + cnt);
  for (RI i = 1; i <= cnt; ++i)
    if (a[i] + sum == x) (ans += qpow(2, cnt - i + 1) % mod) %= mod;
  printf("%lld\n", ans);
            
  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 512
N = int(input())
H = list(map(int, input().split()))

ans = "Yes"
height = H[-1]
for i in range(2,N+1):
    if H[N-i] >= height+2:
        ans = "No"
        break
    elif H[N-i] >= height:
        continue
    else:
        height = H[N-i]

print(ans)

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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	string s; cin >> s;
	int S = stoi(s);
	int a = S/100, b = S%100;
	if(1 <= b && b <= 12){
		if(1 <= a && a <= 12) cout << "AMBIGUOUS" << endl;
		else cout << "YYMM" << endl;
	} 
	else{
		if(a == 0 || a >= 13) cout << "NA";
		else cout << "MMYY" << endl;
	}
} 

Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n, A,B,C = i_map()

    l = [i_input() for i in range(n)]

    def dfs(cur, a,b,c):
        if cur==n:
            return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a,b,c) > 0 else INF
        ret0 = dfs(cur+1, a,b,c)
        ret1 = dfs(cur+1, a+l[cur],b,c) + 10
        ret2 = dfs(cur+1, a,b+l[cur],c) + 10
        ret3 = dfs(cur+1, a,b,c+l[cur]) + 10
        return min(ret0, ret1,ret2, ret3)
    print(dfs(0,0,0,0))


if __name__=="__main__":
    main()


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

using namespace std;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    vector<int> ans;
    int maxx = max(X, Y), minn = min(X, Y);
    ans.push_back(A * X + B * Y);
    ans.push_back(C * minn * 2 + A * (X - minn) + B * (Y - minn));
    ans.push_back(C * maxx * 2);
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 256
s=input()
k=int(input())
m=[ord("z")+1]*3
for i in range(len(s)):
    if ord(s[i])<m[0]:
      m=[ord(s[i]),m[0],m[1]]
    elif m[0]<ord(s[i])<m[1]:
      m=[m[0],ord(s[i]),m[1]]
    elif m[1]<ord(s[i])<m[2]:
      m=[m[0],m[1],ord(s[i])]

a=[]
for l2 in m:
  l=chr(l2)
  s2=s
  while l in s2:
    for i in range(5):
      a.append(s2[s2.find(l):min(s2.find(l)+i+1,len(s2))])
    s2=s2[s2.find(l)+1:]
print(sorted(set(a))[k-1])
               
    
    

Measured memory_bytes: 10408
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(true){
 int ans=0;
 String r=sc.next();
   if(r.equals("0"))break;
for(int i=0;i<r.length();i++){
    ans+=Character.getNumericValue(r.charAt(i));
}
 
 
 System.out.println(ans);
}
}
}


Measured memory_bytes: 26320
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
*/
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),


signed main(){
    FASTER;
    int n;cin>>n;
    vi v(n);cin>>v;
    int cnt=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                set<int> st;
                st.insert(v[i]);
                st.insert(v[j]);
                st.insert(v[k]);
                if(st.size()<3)continue;
                vi la(all(st));
                cnt+=(la[2]<la[1]+la[0]);
            }
        }
    }
    cout<<cnt;
}






Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int main(){
	float area;
  int w, h, x, y;
  cin >> w >> h >> x >> y;
  area = (float)w * h / 2;
  if(x * 2 == w && y * 2 == h){
  	cout << area << ' ' << 1;
  }else{
  	cout << area << ' ' << 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

const int N=5009;
ll dp[N][N], f[N];
int sz[N];
vector<int> lk[N];

void dfs(int x, int fr){
    sz[x]=1;
    dp[x][1]=1;
    for(auto y:lk[x]) if(y!=fr){
        dfs(y,x);
        int sz0=sz[x];
        sz[x]+=sz[y];
        ll sum=0;
        rep1(i,sz[y])(sum+=dp[y][i]*f[i])%=MOD;
        for(int i=sz[x];i>=1;i--){
            ll ans=-dp[x][i]*sum%MOD;
            for(int j=max(1,i-sz0);j<=min(i,sz[y]);j++)(ans+=dp[x][i-j]*dp[y][j])%=MOD;
            dp[x][i]=ans;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    rep(i,n-1){
        int x, y; cin>>x>>y;
        lk[x].push_back(y); lk[y].push_back(x);
    }
    f[0]=1;
    for(int i=2;i<=n;i++) f[i]=f[i-2]*(i-1)%MOD;
    dfs(1,0);
    ll ans=0;
    rep1(i,n) (ans+=dp[1][i]*f[i])%=MOD;
    cout1((ans+MOD)%MOD);
}

Measured memory_bytes: 195072
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
 
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  if(sum == 1){
    cout << 10 << endl;
  }
  else{
  cout << sum << endl;
  }
}


Measured memory_bytes: 3612
from collections import Counter

n = int(input()) 
times = 0

def make_divisors(n):
    divisors = [n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors
    
times = len(make_divisors(n - 1))
a = make_divisors(n)

for i in a:
    tmp = n // i
    if tmp == 1:
        times += 1 
        continue
    while tmp % i == 0:
        tmp = tmp // i
    if tmp % i == 1:
        times += 1 
    
print(times if n != 2 else 1)

Measured memory_bytes: 3692
#include <stdio.h>

int main (void){
	int A,B;
	
	scanf("%d %d",&A,&B);
	
	A = (A == 1) ? 14: A;
	B = (B == 1) ? 14: B;
	
	if(A==B) printf("Draw");
	else if(A>B) printf("Alice");
	else printf("Bob");
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <cstdlib>
#define mp make_pair
#define pb push_back
#define mem(i,a) memset(i,a,sizeof(i))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const ll INF=10000000000;
const int DMAX=600000+5;
const int MOD=6000000;
template<class T> inline void read(T &x){
    x=0; 
    T f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-'){
            f=-1;
        }
        ch=getchar();
    }
    while(ch<='9' && ch>='0'){
        x=x*10+(ch-'0');
        ch=getchar();
    }
    x*=f;
}
ll len[DMAX];
ll n,x;
ll full[DMAX];
ll solve(ll now,ll q){
	if(now==0){
		return 1;
	}
	if(q==1){
		return 0;
	}
	if(q>1 && q<len[now-1]+1){
		return solve(now-1,q-1);
	}
	if(q==len[now-1]+1){
		return full[now-1];
	}
	if(q==len[now-1]+2){
		return full[now-1]+1;
	}
	if(q>=len[now-1]+3 && q<len[now-1]*2+2){
		return full[now-1]+solve(now-1,q-1-len[now-1]-1)+1;
	}
	if(q>=len[now-1]*2+2){
		return full[now-1]*2+1;
	}
}
int main(){
	read(n),read(x);
	len[0]=1;
	full[0]=1;
	for(int i=1;i<=n;i++){
		len[i]=len[i-1]*2+3;
		full[i]=full[i-1]*2+1;
	}
	ll ans=solve(n,x);
	cout<<ans<<endl;
	return 0;
}

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


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

    int D;
    cin >> D;
    if(D==25){
        cout << "Christmas" << endl;
    }
    if(D==24){
        cout << "Christmas Eve" << endl;
    }
    if(D==23){
        cout << "Christmas Eve Eve" << endl;
    }
    if(D==22){
        cout << "Christmas Eve Eve Eve" << 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) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;


int main(){
  ll X;
  cin >> X;
  ll a = 100;
  ll cnt = 0;
  while(a < X){
    a = ll(a*(double)1.01);
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    bool ok = true;
    for (auto x : a)
    {
        if (x % 2 != 0)
        {
            continue;
        }
        if (x % 3 == 0 || x % 5 == 0)
        {
            continue;
        }
        ok = false;
        break;
    }

    string ans = ok ? "APPROVED" : "DENIED";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <stdlib.h>
#include <limits.h>
#include <string>
#include <iostream>

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l=0, N, h[100], x[100], y[100], H;
	cin >> N;
	for (i; i < N; i++)cin >> x[i] >> y[i] >> h[i];

	for (l = 0; l<N; l++) {

		for (i = 0; i <= 100; i++) {
			for (j = 0; j <= 100; j++) {
				H = h[l] + abs(x[l] - i) + abs(y[l] - j);
				for (k = 1; k < N; k++) {
					if (max(H - abs(x[k] - i) - abs(y[k] - j), (long long)0) != h[k])
						break;
				}
				if (k == N) {
					cout << i << " " << j << " " << H << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}

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

const ll mod = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    ll t[n], a[n];
    for (int i = 0; i < n; i++) cin >> t[i];
    for (int i = 0; i < n; i++) cin >> a[i];
    ll ht[n], ah[n];
    ll t_max = -1, a_max = -1;
    for (int i = 0; i < n; i++) {
        if (t_max < t[i]) {
            t_max = t[i];
            ht[i] = t[i];
        } else if (t[i] <= t_max) {
            ht[i] = -1;
        }
        if (a_max < a[n - i - 1]) {
            a_max = a[n - i - 1];
            ah[n - i - 1] = a[n - i - 1];
        } else if (a[n - i - 1] <= a_max) {
            ah[n - i - 1] = -1;
        }
    }
    ll ans = 1;
    for (int i = 0; i < n; i++) {
        if (ht[i] != -1 && ah[i] == -1) {
            if (ht[i] > a[i]) ans = 0;
        } else if (ht[i] != -1 && ah[i] != -1) {
            if (t[i] < ah[i] || a[i] < ht[i]) ans = 0;
        } else if (ht[i] == -1 && ah[i] == -1) {
            ans *= min(t[i], a[i]);
            ans %= mod;
        } else if (ht[i] == -1 && ah[i] != -1) {
            if (t[i] < ah[i]) ans = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int q1,b,c1,c2,q2;
	while(cin>>q1>>b>>c1>>c2>>q2&&q1!=0){
		// Ü¸ïÃ{÷ðAé¾¯¤
		int aizu=min(b/c1,q2);
		if(aizu==0){
			cout<<"NA"<<endl;
			continue;
		}
		int left = b-aizu*c1;
		// ÉÊÌ{÷ðãÀÜÅ¤
		int usu=left/c2;
		left-=usu*c2;
		// »ÝÌóÔÅðð½µÄ¢é©
		if(aizu+usu>=q1){
			cout<<aizu<<" "<<usu<<endl;
		}
		// ½µÄ¢È©Á½êAaizu÷ðèAusu÷ð+
		else{
			bool f=false;
			for(int i = aizu-1; i >= 1; i--){
				aizu=i;
				left+=c1;
				int tmp=left/c2;
				left-=tmp*c2;
				usu+=tmp;
				if(aizu+usu>=q1){
					f=true;
					cout<<aizu<<" "<<usu<<endl;
					break;
				}
			}
			if(!f){
				cout<<"NA"<<endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
vector<bool> vst(5);
void dfs(int v, vector<int> g[])
{
    if (!vst[v])
        cout << v << " ";
    vst[v] = true;
    // cout << "set " << v << " = true\n";
    for (auto i : g[v])
    {

        if (!vst[i])
        {
            // cout << "v=" << v << " i=" << i << endl;
            dfs(i, g);
        }
    }
}
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> g[n + 1];
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    //DFS練習
    // dfs(1, g);
    //////////
    //解此題用BFS
    vector<bool> visit(n + 1);
    vector<int> paraent(n + 1);
    queue<int> q;
    q.push(1);
    visit[1] = 1;
    while (!q.empty())
    {
        int cur = q.front();
        q.pop();
        for (auto x : g[cur])
        {
            if (!visit[x])
            {
                visit[x] = 1;
                q.push(x);
                paraent[x] = cur;
            }
        }
    }
    cout << "Yes\n";
    for (int i = 2; i <= n; i++)
        cout << paraent[i] << endl;
}

Measured memory_bytes: 10200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long x = lcm(A, B);
        System.out.println(A*B/x);
    }

    public static long lcm(long a, long b) {
        if (a < b) {
            return lcm(b, a);
        } else if (a == b) {
            return 1;
        } else if (a%b==0) {
            return b;
        }
        return lcm(b, a%b);
    }
}


Measured memory_bytes: 24916
import collections

n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if n == 1:print(0)
else:
    c = collections.Counter(prime_factorize(n))
    kouho = []
    soinnsuu = list(c.keys())
    sisuu = list(c.values())
    '''for i in range(len(soinnsuu)):
        for j in range(1,sisuu[i] + 1):
            kouho.append(soinnsuu[i]**j)
    kouho = list(set(kouho))
    kouho.sort()
    ans = 0
    while n != 1:
        for i in range(len(kouho)):
            if n%kouho[i] == 0 and kouho[i] != -1:
                n //= kouho[i]
                kouho[i] = -1
                ans += 1
                break
    '''
    ans = 0
    for i in sisuu:
        for j in range(1,100):
            if i >= j:
                ans += 1
                i -= j
            else:break
    print(ans)


Measured memory_bytes: 9468
#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 <iomanip> // double
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> check(4,vector<int>(13,1));
  rep(i,n) {
      pair<string,int> scan;
      cin >> scan.first >> scan.second;
      int a,b;
      if(scan.first == "S") a = 0;
      else if(scan.first == "H") a = 1;
      else if(scan.first == "C") a = 2;
      else a = 3;
      b = scan.second;
      b--;
      check[a][b] = 0;
  }
  vector<string> soot(4);
  soot = {"S","H","C","D"};
  rep(i,4) {
      rep(j,13) {
          if(check[i][j]) cout << soot[i] << " " << j + 1 << "\n";
      }
  }
}


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

int main() {
  int p;
  std::vector<int> vec;

  for(int i = 0; i<3; i++){
    std::cin >> p;
    vec.push_back(p);
  }

  std::cout << vec[2] << " " << vec[0] << " " << vec[1] << std::endl; 

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    t: usize,
    ab: [(usize, i32); n],
  }
  let mut ab = ab;
  ab.sort();
  let mut dp = vec![vec![0; t]; n];
  let mut ans = 0;
  for (i, &(a, b)) in ab.iter().take(n-1).enumerate() {
    let mut current = 0;
    for j in 0 .. t {
      dp[i+1][j] = match j.checked_sub(a) {
        None => dp[i][j],
        Some(v) => cmp::max(dp[i][j], dp[i][v] + b),
      };
      current = cmp::max(current, dp[i+1][j]);
    }
    ans = cmp::max(ans, current + ab[i+1].1);
  }

  puts!("{}\n", ans);
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

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

const int INF = 1e9;

int main(){
    ll n;
    string c;
    cin >> n >> c;
    ll red = 0;
    REP(i,n){
        if(c[i]=='R') red++;
    }
    ll ans = 0;
    REP(i,red){
        if(c[i]=='W') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int> > G(n);
    vector<int> in(n);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        in[y]++;
    }

    queue<int> que;
    rep(i, n) {
        if (in[i] == 0) {
            que.push(i);
        }
    }

    vector<int> dp(n);
    while (!que.empty()) {
        int u = que.front();
        que.pop();
        rep(i, sz(G[u])) {
            dp[G[u][i]] = max(dp[G[u][i]], dp[u]+1);
            in[G[u][i]]--;
            if (in[G[u][i]] == 0) {
                que.push(G[u][i]);
            }
        }
    }

    int ans = 0;
    rep(i, n) {
        ans = max(ans, dp[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6528
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
string _10jp(int x,int p){
	string st;char c;
	int i;
	while(x!=0){
		c=x%p+'0';
		st=c+st;
		x/=p;
	}
	return st;
}
int main()
{
	int n,p;
	cin>>n>>p;
	cout<<_10jp(n,p).size()<<endl;
}
///*165/7==23 4
  //23/7==3   2
  //3/7==0    3

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}

class AAbcOfABC {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    string S;
    cin >> S;
    sort(ALL(S));
    if (S == "abc") {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
};


signed main() {
  AAbcOfABC solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int [] nums = new int[3];
        for (int i = 0; i < 3; i++) {
            nums[i] = cin.nextInt();
        }
        int k = cin.nextInt();
        Arrays.sort(nums);
        nums[2] = nums [2] << k;
        System.out.println(nums[0] + nums[1] + nums[2]);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    priority_queue<int>q;
    int n,a[200000];
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        q.push(a[i]);
    }
    for(;;)
    {
        int a1,a2;
        a1=q.top();
        q.pop();
        a2=q.top();
        q.pop();
        if(a1==1||a2==0)
        {
            q.push(a1);
            break;
        }
        a1=__gcd(a1,a2)%a1;
        q.push(a1);
        if(a2)
            q.push(a2);
        if(q.size()==1)
            break;
    }
    printf("%d\n",q.top());
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	long long Ans = 0, MIN = 1000000001;
	int Minus = 0;
	for (int i = 0; i < N; i++) {
		long long A;
		cin >> A;
		Minus += (A < 0);
		long long Abs = A > 0 ? A : -A;
		Ans += Abs;
		MIN = min(MIN, Abs);
	}
	if (Minus % 2 == 0) cout << Ans << endl;
	else cout << Ans - 2 * MIN << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N, a0, b1, c2;
  cin >> N;
  vector<vector<int64_t>> dp(N, vector<int64_t>(3, 0));
 
  cin >> a0 >> b1 >> c2;
  dp.at(0).at(0)=a0;
  dp.at(0).at(1)=b1;
  dp.at(0).at(2)=c2;
  
    for (int i=1; i<N; i++) {
      cin >> a0 >> b1 >> c2;
        for (int j=0; j<3; j++) {
          if (j==0) {
            dp.at(i).at(j)=a0 + max(dp.at(i-1).at(1), dp.at(i-1).at(2));
          }
          if (j==1) {
            dp.at(i).at(j)=b1 + max(dp.at(i-1).at(0), dp.at(i-1).at(2));
          }
          if (j==2) {
            dp.at(i).at(j)=c2 + max(dp.at(i-1).at(0), dp.at(i-1).at(1));
          }
        }
    }
  cout << max(dp.at(N-1).at(0), max(dp.at(N-1).at(1), dp.at(N-1).at(2))) << endl;
}

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

int main(){
  string s;
  int n=s.size(),b=0;
  cin>>n>>s;
  if(n%2!=0){
    cout<<"No"<<endl;
  }
  else if(s.substr(0,n/2)==s.substr(n/2,n/2)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
     


Measured memory_bytes: 256