akhauriyash/Code-Regression huggingface dataset:
n=int(input())
arr=[]
for i in range(n):
    a,b = map(int, input().split())
    arr.append([a,b,i])
arr=sorted(arr, key=lambda x: x[0], reverse=True)
arr=sorted(arr, key=lambda x: x[1])
#print(arr)

task=0
ti=0
flag=0
for i in arr:
    task+=i[0]
    ti=i[1]
    #print(task,ti)
    if task > ti:
        flag=1
        break

if flag==1:
    print("No")
else:
    print("Yes")

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
char S[202020];
ll dp[202020];
ll i,j,ans;
int main(){
    scanf("%s", S);
    dp[1] = 1;
    dp[2] = -1e9;
    dp[3] = 2;
    for (i = 1; S[i];i++){
        ll a = dp[i] + 1;
        if(S[i-1]!=S[i]){
            dp[i+1] = max(dp[i+1], a);
        }
        a++;
        dp[i + 3] = max(dp[i + 3], a);
    }
    dp[i + 1]--;
    printf("%lld", max(dp[i],dp[i + 1]));
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
	int n,m,tmp,max;
	while(1){
		cin >> n >> m;
		
		if(n == 0 && m == 0)break;
		
		vector<int> s(n),v(n*(n-1)/2);
		
		for(int i=0;i<n;i++){
			cin >> s[i];
		}
		
		tmp = 0;
		max = -1;
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				v[tmp] = s[i]+s[j];
				tmp++;
			}
		}
		
		for(int i=0;i<tmp;i++){
			if(v[i] > max && m >= v[i] ) max = v[i];
		}
		
		if(max < 0)cout << "NONE" << endl;
		else cout << max << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 6040
import itertools
H, W = map(int, input().split())
A = []
for _ in range(H):
    a = list(input())
    if a.count("#") != 0:
        A.append(a)

H = len(A)
if H == 1:
    A = list(itertools.chain.from_iterable(A))
    cnt = []
    for ans in A:
        if ans == "#":
            cnt.append(ans)
    print("".join(cnt))
else:
    L = []
    for w in range(W):
        l = []
        for h in range(H):
            if A[h][w] == "#":
                l = []
                break
            l.append(w)
        if len(l) != 0:
            L.append(l[0])

    dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
    for ans in A:
        ans = dellist(ans, L)
        print("".join(ans))

Measured memory_bytes: 9236
#include <stdio.h>

int main(void)
{
 int count=0,v,i,j,N,A[100],flag=1;

 scanf("%d",&N);

 for(i=0;i<N;i++){
  scanf("%d",&A[i]);
 }

 i=0;

 while(flag){
  flag=0;
  for(j=N-1;j>i;j--){
   if(A[j]<A[j-1]){
     v=A[j];
     A[j]=A[j-1];
     A[j-1]=v;
     flag=1;
     count++;
   }
  }
  i++;
 }
 for(i=0;i<N-1;i++){
  printf("%d ",A[i]);
 }
 printf("%d\n",A[N-1]);
 printf("%d\n",count);

 return 0;
}
  
     

Measured memory_bytes: 1800
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;

const int mod = 1e9+7;

void add_self(int&a,int b)
{
  a+=b;
  if(a>=mod)
  {
    a-=mod;
  }
}


int main() 
{


int N;
cin>>N;
string s;
cin>>s;
vector<vector<int>>dp(N+1,vector<int>(N+1));
vector<vector<int>> prefix(N+1,vector<int>(N+1));
// dp[i][j] represents number of ways to fill prefix of size i
// with numbers 1 to i. And the last number filled is j.

dp[1][1] =1;
// if i=1; number of ways to fill it is 1 as 1 can only be filled.

// Now we have to calculte the ways for increasing lengths


for(int i=2;i<=N;i++)
{
  

  for(int j=1;j<i;j++)
  {
    prefix[i-1][j] = (prefix[i-1][j-1]+dp[i-1][j])%mod;

  }

  for(int j=1;j<=i;j++)
  {
    int fill_value = j;
    int L,R;
    //Did'nt understand the logic completely
    if(s[i-2]=='<')
    {
      L = 1;
      R = j-1;
    }
    else
    {
      L = j;
      R = i-1;
    }
    if(L<=R)
    add_self(dp[i][j],(prefix[i-1][R]-prefix[i-1][L-1]+mod)%mod);
    // for(int k=L;k<=R;k++)
    // {
    //   add_self(dp[i][j],dp[i-1][k]);
    // }
    //O(n^3 algorithm) 
    //This understood but am not confident
    // for(int k=1;k<i;k++)
    // {
    //   int true_value = k;
    //   if(k>=j)
    //   {
    //     true_value++;
    //   }

    //   if((true_value<j) != (s[i-2]=='<'))
    //   {
    //     continue;
    //   }

    //   add_self(dp[i][j],dp[i-1][k]);

    // }
  }

}
int ans =0;

for(auto c:dp[N])
{
  add_self(ans,c);
}
cout<<ans<<endl;

}


Measured memory_bytes: 70784
from itertools import accumulate
def main():
  N = int(input())
  A = [int(_) for _ in input().split()]
  B = list(accumulate(A))
  s = B[-1]
  B = [abs(2 * b - s) for b in B]
  print(min(B[:-1]))
  return

if __name__ == '__main__':
  main()

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

int main(){
    int a, b;
    cin>>a>>b;
    if(a%b==0){
        cout<<"0"<<endl;
    }
    else{
        cout<<"1"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);

int main() {
    cin>>N>>K;
    ll res = 0;
    rep(i,N){
        cin>>A>>B;
        res += (A * A + B * B <= K * K);
    }
    cout<<res<<endl;
}


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

typedef long long ll;

int a[3];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] + a[1];
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++){
    cin >> d.at(i);
  }
  
  int ans = 0;
  for(int i = 0; i < N - 1; i++){
    for(int j = i + 1; j < N; j++){
      ans += d.at(i) * d.at(j);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		int a,b,sum=0;
		a = stdIn.nextInt();
		b = stdIn.nextInt();
		
		int A = Math.max(a,b);
		int B = Math.min(a,b);
		
		sum = Math.max(2*A-1,A+B);
		
		System.out.println(sum);
	}
}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;



typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
    
    
    
//defines
typedef long long ll;
typedef long double ld;
ll a,b,c,n,m,k,t=1;

void solve()
{
    cin>>n;
    m=(n/1000);
    m++;
    if(n%1000==0)cout<<0;
    else cout<<(1000*m)-n;
   
 cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    int a, b;
    cin >> n >> a >> b;
    int x = 0, y = 0, z = 0;
    for (int i = 0; i < n; ++i)
    {
        int w;
        cin >> w;
        if (w <= a)
            ++x;
        if (w >= a + 1 && w <= b)
            ++y;
        if (w >= b + 1)
            ++z;
    }
    cout << min(x, min(y, z));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INF (1ll<<60)

typedef long long ll;

int main(void) {
	ll maxer, miner, sum;
	int i, n, a;
	
	scanf("%d", &n);
	
	sum = 0;
	maxer = -INF;
	miner = INF;
	
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		sum += a;
		maxer = maxer > a ? maxer : a;
		miner = miner < a ? miner : a;
	}
	
	printf("%lld %lld %lld\n", miner, maxer, sum);
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main() {
  long long int a, b, c, k;
  cin >> a >> b >> c >> k;

  if(a>=k){
    cout << k << endl; 
  }else if(a < k && a + b >= k){
    cout << (k-b) << endl; 
  }else{
    cout << a - 1*(k-a-b) << endl; 
  }

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n;
    cin >> n;
    vi l(n),r(n);
    rep(i,n)cin >> l[i] >> r[i];
    sort(all(l));
    sort(all(r));
    reverse(all(l));
    int ans = 0, t = 0;
    rep(i,n){
        ans = max(ans,max(t+l[i],t-r[i]));
        ans = max(ans, t+l[i]-r[i]);
        t += l[i]-r[i];
    }
    cout << ans*2 << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<char>> S( H, vector<char>( W ) );
    REP( i, H )
    {
        REP( j, W )
        {
            cin >> S[ i ][ j ];
        }
    }
    vector<vector<int>> T( H + 1, vector<int>( W + 1 ) );
    for( int i = 0; i < H; ++i )
    {
        for( int j = 0; j < W; ++j )
        {
            int cnt{};
            
            // # はそのまま
            if( S[ i ][ j ] == '#' )
            {
                T[ i ][ j ] = 114514;
                continue;
            }
            
            //斜め左上
            if( i != 0 && j != 0 )
            {
                if( S[ i - 1 ][ j - 1 ] == '#' )
                {
                    cnt++;
                }
            }
            //上
            if( i != 0 )
            {
                if( S[ i - 1 ][ j ] == '#' )
                {
                    cnt++;
                }
            }
            //斜め右上
            if( i != 0 && j != W - 1 )
            {
                if( S[ i - 1 ][ j + 1 ] == '#' )
                {
                    cnt++;
                }
            }
            //左
            if( j != 0 )
            {
                if( S[ i ][ j - 1 ] == '#' )
                {
                    cnt++;
                }
            }
            //右
            if( j != W - 1 )
            {
                if( S[ i ][ j + 1 ] == '#' )
                {
                    cnt++;
                }
            }
            //下
            if( i != H - 1 )
            {
                if( S[ i + 1 ][ j ] == '#' )
                {
                    cnt++;
                }
            }
            //斜め左下
            if( i != H - 1 && j != 0 )
            {
                if( S[ i + 1 ][ j - 1 ] == '#' )
                {
                    cnt++;
                }
            }
            //斜め右下
            if( i != H - 1 && j != W - 1 )
            {
                if( S[ i + 1 ][ j + 1 ] == '#' )
                {
                    cnt++;
                }
            }
            T[ i ][ j ] = cnt;
        }
    }
    REP( i, H )
    {
        REP( j, W )
        {
            cout << ( T[ i ][ j ] == 114514 ? "#" : to_string( T[ i ][ j ] ) );
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static final int MOD = (int)1e9+7; 
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      int t = Integer.parseInt(sc.next());
      int[] a = new int[n];
      int[] b = new int[n];
      long[] x = new long[n];
      for(int i=0; i<n; i++){
        a[i] = Integer.parseInt(sc.next());
        b[i] = Integer.parseInt(sc.next());
        x[i] = ((long)a[i]<<32)|b[i];
      }
      Arrays.sort(x);
      int[] dp = new int[6060];
      for(int i=0; i<n; i++){ 
          int tb = (int)x[i];
          int ta = (int)(x[i]>>32);
          //System.out.println(ta);
          for(int j=t-1; j>=0; j--){
              dp[j+ta] = Math.max(dp[j+ta],dp[j]+tb);
          }
      }
      int ans = 0;
      for(int i=0; i<dp.length; i++){
          //System.out.println(dp[i]);
          ans = Math.max(dp[i], ans);
      }
      System.out.println(ans);
    }
}


Measured memory_bytes: 27820
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

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

int main(){
    int n, m;
    priority_queue<P, vector<P>, greater<P>> que;
    cin >> n >> m;
    for(int i = 0; i < n; ++i){
        int a, b;
        cin >> a >> b;
        que.push(P(a, b));
    }
    
    ll res = 0;
    priority_queue<int> cd;
    for(int i = 1; i <= m; ++i){
        while(!que.empty()){
            P p = que.top();
            if(p.first <= i){
                que.pop();
                cd.push(p.second);
            }
            else{
                break;
            }
        }
        
        if(!cd.empty()){
            res += cd.top();
            cd.pop();
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 1908
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
if sum(A)<sum(B):
    print(-1)
else:
    D=[]
    d=0
    a=0
    for i in range(len(A)):
        c=A[i]-B[i]
        D.append(c)
        if c<0:
            a+=1
            d-=c
    D.sort()
    j=1
    while d>0:
        if d>D[-j]:
            a+=1
            d-=D[-j]
            j+=1
        else:
            a+=1
            break
    print(a)

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

double th = M_PI * 60.0 / 180.0;

struct Point{
    double x, y;
};

void Koch(int n, Point p1, Point p2){
    if(n == 0) return;
    Point s, t, u;
    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    Koch(n-1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y);
    Koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    Koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    Koch(n-1, t, p2);   
}

int main(){
    int n;
    cin >> n;
    Point p1, p2;
    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;
    printf("%.8f %.8f\n", p1.x, p1.y);
    Koch(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);
    return 0;
}


Measured memory_bytes: 3360
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define RFOR(i,a,b) for (ll i = (a) ; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int n;
	ll ans = 1000, st = 0;
	cin >> n;
	VL a(n);
	rep(i, n) cin >> a[i];


	FOR(i, 0, n-1){
		if(a[i] < a[i+1]){
			st += ans/a[i];
			ans -= (ans/a[i]) * a[i];
		}else if(a[i] > a[i+1]){
			ans += st * a[i];
			st = 0;
		}
	}

	ans += st * a[n-1];
	st = 0;



	cout << ans << endl;
}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#define N 505
using namespace std;

int n, m, Q, st, en, ans, s[N][N];
int main()
{
	int i, j, l, r;
	cin >> n >> m >>Q;
	while (m--) {
		scanf ("%d %d", &l, &r);
		s[l][r]++;
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			s[i][j] += s[i][j - 1];
		}
	}
	while(Q--) {
		scanf ("%d %d", &st, &en);
		ans = 0;
		for (i = st; i <= en; i++) {
			ans += s[i][en];
		}
		printf("%d\n", ans);
	}
    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>

using namespace std;
using ll = long long;

int main(){ 
        int x,y;
        cin >> x  >> y;
        cout << (double) x/y;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi vector<int>
#define vb vector<bool>
#define lli long long int
#define vvi vector<vector<int>>
#define loop(n) for (int i = 0; i < n; i++)
using namespace std;

auto SpeedUp = []() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

lli kanpsack(vi& weg, vi& val, int idx, int w, vector<vector<lli>>& dp)
{
    if (idx==weg.size() || w==0)
        return dp[idx][w] = 0;
    if (dp[idx][w]!=-1)
        return dp[idx][w];
    lli ans = -1e9;
    if (w-weg[idx]>=0)
        ans = max(ans, kanpsack(weg, val, idx+1, w-weg[idx], dp)+val[idx]);
    ans = max(ans, kanpsack(weg, val, idx+1, w, dp));
    return dp[idx][w] = ans;
}

lli solve()
{
    int n, w;
    cin>>n>>w;
    vi weg(n, 0), val(n, 0);
    loop(n) {
        cin>>weg[i];
        cin>>val[i];
    }
    vector<vector<lli>> dp(n+1, vector<lli>(w+1, -1));
    return kanpsack(weg, val, 0, w, dp);

}

int main()
{
    cout<<solve()<<'\n';
    return 0;
}

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

using ll = long long;
using K = long double;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())
#define ALL(a) (a).begin(), (a).end()

const int N = 55;

int n, a[N], b[N];

int used[N];

int rec(int v, int a, int b) {
	if (a == b) return true;
	if (!v) return false;
	if (rec(v-1, a, b)) return true;
	if (used[v] && v <= a) return rec(v-1, a%v, b);
	return false;
}

int go(int a, int b) {
	return rec(50, a, b);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	REP(i, n) cin >> a[i];
	REP(i, n) cin >> b[i];
	REP(i, 50) used[i+1] = 1;
	
	REP(i, n) if (!go(a[i], b[i])) {
		cout << -1 << '\n';
		return 0;
	}
	
	for (int i = 50; i >= 0; --i) {
		used[i] = 0;
		bool ok = 1;
		REP(i, n) if (!go(a[i], b[i])) {
			ok = 0;
			break;
		}
		used[i] = !ok;
	}
	
	ll result = 0;
	REP(i, 51) if (used[i]) result |= 1LL << i;
	
	cout << result << '\n';
	
	return 0;
}


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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

string s;
int flag = 0;

int main()
{
    cin >> s;
    while(true) {
        if(s.size()==0) {
            P("YES");
            break;
        }
        if(s.size()<5||flag==1) {
            P("NO");
            break;
        }
        if(s.substr(s.size()-5)=="dream"||s.substr(s.size()-5)=="erase") {
            s = s.substr(0,s.size()-5);
            flag = 0;
        }
        else if(s.substr(s.size()-6)=="eraser") {
            s = s.substr(0,s.size()-6);
            flag = 0;
        }
        else if(s.substr(s.size()-7)=="dreamer") {
            s = s.substr(0,s.size()-7);
            flag = 0;
        }
        else
            flag = 1;
    }

    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

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 dp[101][101];
void solve()
{
	int h, w;
	cin >> h >> w;
	rep(i, 101) rep(j, 101) dp[i][j] = 1e9;
	vector<vector<char>> grid(h, vector<char>(w));
	rep(i, h) rep(j, w) cin >> grid[i][j];
	//cout<<"a"<<endl;
	if (grid[0][0] == '#')
	{
		dp[0][0] = 1;
	}
	else
	{
		dp[0][0] = 0;
	}
	rep(i, h) rep(j, w)
	{
		int nx[2] = {i + 1, i};
		int ny[2] = {j, j + 1};
		rep(k, 2)
		{
			if (nx[k] < h && ny[k] < w)
			{
				if (grid[nx[k]][ny[k]] == '#')
				{
					if (grid[i][j] == '#')
					{
						chmin(dp[nx[k]][ny[k]], dp[i][j]);
					}
					else
					{
						chmin(dp[nx[k]][ny[k]], dp[i][j] + 1);
					}
				}
				else
				{
					chmin(dp[nx[k]][ny[k]], dp[i][j]);
				}
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 384
//    ? WHY YOU OPEN THIS ?    //
 
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
#define PAIR    pair<int,int>
#define Vector  vector<int>
#define MAP     map<int,int>
#define pb      push_back
#define mk      make_pair
#define MOD     1e9+7 
#define all(a)  begin(a),end(a)
#define F       first
#define S       second
 
#define FOR(i, a, b)     for(int i = a; i < b; i++)
#define ROF(i, a, b)     for(int i = a; i>= b; i--)
#define check(c)       cout<<#c<<" : "<<c<<endl;
#define check2(a, b)    cout<<#a<<" : "<<a<<" | "<<#b<<" : "<<b<<endl;
#define check3(a, b, c)  cout<<#a<<" : "<<a<<" | "<<#b<<" : "<<b<<" | "<<#c<<" : "<<c<<endl;
#define SWIFT          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void testCase(){
    // int n; cin >> n;
    // int a[n]; FOR(i, 0, n) cin >> a[i];

	double x, d; int k; cin >> x >> k >> d;
	int ans, mn = min(k, (int)ceil(abs(x) / d));
	k -= mn;
	if(k == 0){
		ans = abs(abs(x) - mn * d);
	} else{
		if(k & 1){
			ans = abs((ceil(abs(x) / d) - 1) * d - abs(x));
		} else{
			ans = abs(ceil(abs(x) / d) * d - abs(x));
		}
	}
	cout << ans << endl;
}
 
signed main(){
    SWIFT;
    
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    int t = 1;
    // int t; cin >> t;
    while(t--){
        testCase();
    }
    return 0;
}

Measured memory_bytes: 3824
#include<iostream>
#include<cmath>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 40
using namespace std;
 
typedef long long ll;
 
ll coef[MAX];
 
int main()
{
  coef[0] = 0;
  coef[1] = 1;
  coef[2] = 4;
  REP(i,3,40)coef[i] = coef[i-1]*3+1;
 
  int n;
  while(cin >> n)
    {
      ll total = 0;
      ll ans = n;
      rep(i,(int)floor(n/2))
    {
      total += 2*coef[i];
    }
      total *= 2;
      if(n%2 != 0)total += 2*coef[(int)ceil(n/2)];
 
      cout << ans + total << endl;
    }
  return 0;
}

Measured memory_bytes: 1160
S = input()
Q = int(input())

left = ""
right = ""
cnt = 0

for i in range(Q):
    q = input()
    if q == "1":
        cnt += 1
    elif (cnt%2 == 0 and q[2] == "1") or (cnt%2 == 1 and q[2] == "2"):
        left += q[4]
    else:
        right += q[4]

if cnt%2 == 0:
    ans = left[::-1] + S + right
else:
    ans = right[::-1] + S[::-1] + left

print(ans)

Measured memory_bytes: 4468
#include <stdio.h>

int main(void)
{
  char input[3];
  int ret = 0, i;

  scanf("%s", input);
  for(i = 0;i < 3;i++)
    if (input[i] == '1')
      ret += 1;
  printf("%d\n", ret);
  return (0);
}

Measured memory_bytes: 1708
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	string s, t; CI s >> t;
	REP(i, s.length()) {
		if (s == t) {
			CO "Yes" EN;
			return 0;
		}
		s=s[s.length() - 1] + s;
		s.pop_back();
	}
	if (s == t) {
		CO "Yes" EN;
		return 0;
	}
	CO "No" EN;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  int N;
  ll Z, W;
  cin >> N >> Z >> W;
  VL as(N);
  FOR(a,as) {
    cin >> a;
  }
  if(N == 1) {
    cout << llabs(as[0] - W) << endl;
  } else {
    cout << max(llabs(as[N-2]-as[N-1]), llabs(as[N-1]-W)) << endl;
  }

  return 0;
}


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

int main() {
    int N; 
    cin >> N;
    vector<int> v(N+2);
    ll sum = 0;
    v[0] = v[N+1] = 0;
    for (int i = 1; i <= N+1; i++)
    {
        cin >> v[i];
        sum += abs(v[i]-v[i-1]);
    }
    
    for (int i = 1; i <= N; i++)
    {
        ll ans = sum - abs(v[i]-v[i-1]) - abs(v[i+1]-v[i]) + abs(v[i+1]-v[i-1]); 
        cout << ans << '\n';
    }
        
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b + c + max(a, max(b, c)) * 9) << endl;
	return 0;
}
 

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

using namespace std;

void merge(pair<int,int> &a, pair<int,int> b){
	vector<int> p;
	p.push_back(a.first);
	p.push_back(a.second);
	p.push_back(b.first);
	p.push_back(b.second);
	sort(p.begin(),p.end(),greater<int>());	
	a={p[0],p[1]};
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n; cin >> n;
	vector<int> a(1<<n);
	vector<pair<int,int>> f(1<<n);
	for(int i=0;i<(1<<n);i++){
		cin >> a[i];
	}
	
	for(int i=0;i<(1<<n);i++){
		f[i]={a[i],-1};
	}
	for(int i = 0;i < n; ++i) for(int mask = 0; mask < (1<<n); ++mask){
		if(mask & (1<<i))
			merge(f[mask],f[mask^(1<<i)]);
	}
	
	vector<int> ans(1<<n,0);
	for(int i=1;i<(1<<n);i++){
		ans[i]=max(ans[i-1],f[i].first+f[i].second);
		cout << ans[i] << endl;
	}
	
	return 0;
}

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

int main() {
    int n;
    cin >> n;

    int a, odd = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        odd += a % 2;
    }
    if (odd % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 100000;
string s, t;
int n, m;
int a[MaxN + 5], b[MaxN + 5];

int main()
{
	cin >> s;
	n = s.length();
	for (int i = 0; i < n; i++) a[i + 1] = a[i] + s[i] - 'A';
	cin >> t;
	m = t.length();
	for (int i = 0; i < m; i++) b[i + 1] = b[i] + t[i] - 'A';
	int Q;
	scanf("%d", &Q);
	for (int i = 1; i <= Q; i++) {
		int ls, rs, lt, rt;
		scanf("%d%d%d%d", &ls, &rs, &lt, &rt);
		int ps = (rs - ls + 1 + a[rs] - a[ls - 1]) % 3;
		int pt = (rt - lt + 1 + b[rt] - b[lt - 1]) % 3;
		if (ps == pt) printf("YES\n"); else printf("NO\n");
	}
	return 0;
}

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

int main()
{
    string s, t;
    cin >> s>>t;
    int cnt = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3844
// atcoder/abc156/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }
template<typename P, typename Q> inline pair<Q, P> reverse(pair<P, Q> p) { return make_pair(p.second, p.first); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli n, k;
  while (cin >> n >> k) {
    int cnt = 0;
    while (n) {
      n /= k;
      ++cnt;
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Linq.Expressions;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            if (22 <= Sarray().Sum())
                WriteLine("bust");
            else
                WriteLine("win");
        }
        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28180
// Problem : A - ∴ (Therefore)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_a
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor2)

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define REP(i,n) for (ll i = 0; i < n; i++)
#define REPR(i,n) for(ll i = n-1; i >= 0; i--)
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define FORR(i,a,b) for(ll i = a-1; i>= b; i--)
#define ff first
#define ss second
#define MAXN (ll)1000002
#define MODN (ll)1000000007
#define mp make_pair
#define pb push_back
#define LN(x) (ll)x.length()
#define SZ(x) (ll)x.size()
#define bg(x) (x.begin())
#define rbg(x) (x.rbegin())
#define ENDL cout<<endl
ll n,t=1,tmp;
int main() {
    cin>>n;
	n=n%10;
	
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout<<"hon";
	if(n == 0 || n == 1 || n == 6 || n == 8) cout<<"pon";
	if(n == 3) cout<<"bon";
}

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
  int N;
  int val[100002];
  int i,max=0;
  scanf("%d",&N);
  int a[N];
  for(i=0;i<100002;i++){
    val[i]=0;
  }
  int j;
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    for(j=0;j<3;j++){
      val[a[i]+j]+=1;
      if(max<val[a[i]+j]) max=val[a[i]+j];
    }
  }
  printf("%d\n",max);
  return 0;
}
  


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fo(i,start,end) for(int i=start;start<end?i<end:i>end;start<end?i+=1:i-=1)
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vop vector<pll>
#define vov vector<vector<ll>>
using namespace std;

const long long mod1=1e9+7;
const long long mod2=1e18;
const ll mod3=9e18;

long long power(ll  x, ll n){if(n==0)return 1;ll temp=power(x,n/2);if(n%2==0)return temp*temp;else return x*temp*temp;}
ll MAX(ll a,ll b){return a>b?a:b;}
ll MAX(ll a,ll b,ll c){return max(max(a,b),c);}
ll MIN(ll x,ll  y){return x+y-max(x,y);}
ll MIN(ll x,ll y,ll z){return min(min(x,y),z);}
void swap(int* a, int* b){int t = *a;*a = *b;*b = t;}
bool f(ll x,ll y){return x>y;}
const ld pi=3.14159265358;





int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll r;
    cin>>r;
    cout<<fixed<<setprecision(3)<<2*pi*r;



    return 0;
}

Measured memory_bytes: 3800
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
#include <utility>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

#define MOD 1000000007

template<int mod>
struct ModInt{
	int x;
	ModInt():x(0){}
	ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}
	ModInt &operator^=(long long p){
		ModInt res = 1;
		for (; p; p >>= 1) {
			if (p & 1) res *= *this;
			*this *= *this;
		}
		return *this = res;
	}
	ModInt operator-()const{return ModInt(-x);}
	ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
	ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
	ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
	ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
	ModInt operator^(long long p)const{return ModInt(*this)^=p;}
	bool operator==(const ModInt &p)const{return x==p.x;}
	bool operator!=(const ModInt &p)const{return x!=p.x;}
	explicit operator int() const { return x; }						   // added by QCFium
	ModInt operator=(const int p) {x = p; return ModInt(*this);} // added by QCFium
	ModInt inverse()const{
		int a=x,b=mod,u=1,v=0,t;
		while(b>0){
			t=a/b;
			a-=t*b;
			std::swap(a,b);
			u-=t*v;
			std::swap(u,v);
		}
		return ModInt(u);
	}
};
typedef ModInt<MOD> mint;


int main() {
	int n = ri();
	int k = ri();
	if (k == n * n) {
		puts("0");
		return 0;
	}
	mint dp[n * n][n]; // k, left pulled
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		mint next[n * n][n];
		for (int j = 0; j < n * n; j++) for (int k = 0; k < n; k++) {
			if (dp[j][k] == 0) continue;
			int right = n - i - k;
			if (right < 0) continue;
			// pull from right
			if (right) {
				next[j][k + 1] += dp[j][k]; // push to right
				if (k) next[j][k] += dp[j][k] * k; // push to left
			}
			// pull from left
			if (k) {
				next[j][k] += dp[j][k] * k; // push to right
				if (k) next[j][k - 1] += dp[j][k] * k * k; // push to left
			}
			// stay
			next[j][k] += dp[j][k];
		}
		for (auto &i : dp) for (auto &j : i) j = 0;
		for (int j = 0; j < n * n; j++) for (int k = 0; k < n; k++)
			if (next[j][k] != 0) dp[j + k + k][k] += next[j][k];
	}
	printf("%d\n", dp[k][0].x);
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

vvl G = vv(200000, 0, 0, ll);
set<vll> num;
ll o=0, p = 0;
ll x, y;
void check_x(ll now){
  for(int i=0;i<G[now].size();i++){
    if(num.find(vll{now, G[now][i]})!=num.end()||G[now][i]==y) continue;
    if(G[now][i]==x) o++;
    num.insert(vll{now, G[now][i]});num.insert(vll{G[now][i], now});
    check_x(G[now][i]);
  }
}
void check_y(ll now){
  for(int i=0;i<G[now].size();i++){
    if(num.find(vll{now, G[now][i]})!=num.end()||G[now][i]==x) continue;
    if(G[now][i]==y) p++;
    num.insert(vll{now, G[now][i]});num.insert(vll{G[now][i], now});
    check_y(G[now][i]);
  }
}
int main(int argc, char const *argv[]) {
  ll n, m, a, b;std::cin >> n >> m;
  for(int i=0;i<m;i++){
    std::cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll s = 0, f = 0;
  for(int i=0;i<200000;i++) {
    if(G[i].size()%2!=0){
      std::cout << "No" << '\n';
      return 0;
    }
    if(G[i].size()>=6) s++;
    if(G[i].size()>=4) f++;
  }
  if(s||f>=3) std::cout << "Yes" << '\n';
  else if(f==2){
    x=-1, y=-1;
    for(int i=0;i<200000;i++) if(G[i].size()==4) (x==-1?x:y) = i;
    check_x(x);
    check_y(y);
    //std::cout << o << " " << p << '\n';
    if(o>0&&p>0) std::cout << "Yes" << '\n';
    else std::cout << "No" << '\n';
  }
  else std::cout << "No" << '\n';
  return 0;
}


Measured memory_bytes: 32256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    cout<<s2<<s1;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define FIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fore(x,a,b) for(int x=a,qwe=b; x<qwe; x++)
using namespace std;
typedef long long ll;

const int MXW = 31, MXS=3000, INF = -1e6;
int A,B,C,D,E=1,F;
pair<int,int> dp[MXW][MXS];
bool solved[MXW][MXS];

void op(pair<int,int> &p, pair<int,int>q){
  if(p.first == 0) p = q;
  else if(q.first != -INF){
    if(p.second * 100 * (100*q.first+q.second)<q.second * 100 *(100*p.first+p.second))
      p = q;
  } else if(p.first == -INF)
    p = q;
}

pair<int,int> solve(int i, int j){
  if(i * 100 + j > F)return {-INF,-INF};
  if(solved[i][j])return dp[i][j];
  solved[i][j]=1;
  bool is_ans=j/E+(j%E!=0)<=i;
  dp[i][j]={0,0};
  if(is_ans)op(dp[i][j],{i,j});
  op(dp[i][j],solve(i+A,j));
  op(dp[i][j],solve(i+B,j));
  op(dp[i][j],solve(i,j+C));
  op(dp[i][j],solve(i,j+D));
  return dp[i][j];
}

int main(){
  cin >> A >> B >> C >> D >> E >> F;
  pair<int,int> ans=solve(0,0);
  cout << ans.first*100+ans.second << " " << ans.second << "\n";
}


Measured memory_bytes: 640
N = gets.to_i
ABs= readlines.map{|l| l.split.map(&:to_i)}

G = Hash[(ABs + ABs.map{|a, b| [b, a]}).group_by(&:first).map{|k, v| [k, v.map(&:last)]}]
b, w, h = G[1], G[N], {1 => :b, N => :w}
until b.empty? && w.empty?
  b = b.reject{|i| h.key?(i)}.each{|i| h[i] = :b}.flat_map{|i| G[i]}.uniq
  w = w.reject{|i| h.key?(i)}.each{|i| h[i] = :w}.flat_map{|i| G[i]}.uniq
end
puts h.values.count(:b) > N/2 ? 'Fennec' : 'Snuke'

Measured memory_bytes: 65756
a, b, c, x, y = map(int,input().split())

count = a * x + b * y

if x >= y:
	for i in range(x+1):
		if i > y:
			tmp = a * (x-i) + c * (i*2)
		else:
			tmp = a * (x-i) + b * (y-i) + c * (i*2)
		count = min(count, tmp)
else:
	for j in range(y+1):
		if j > x:
			tmp = b * (y-j) + c * (j*2)
		else:
			tmp = a * (x-j) + b * (y-j) + c * (j*2)
		count = min(count,tmp)

print(count)




		
	
	
	

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

std::vector<long long> z_algorithm(std::string& s) {
	long long n = s.size();
	std::vector<long long> ret(n);
	ret[0] = n;
	long long cnt = 0;
	for (long long i = 1; i < n; i++) {
		for (long long j = i + cnt; j < n; j++) {
			if (s[j] != s[j - i]) {
				cnt = j - i;
				break;
			}
			if (j == n - 1) cnt = n - i;
		}
		ret[i] = cnt;
		if (cnt == 0) continue;
		for (long long j = i + 1; j < n; j++) {
			if (j - i + ret[j - i] < cnt) {
				ret[j] = ret[j - i];
				if (j == n - 1) return ret;
			}
			else {
				cnt -= j - i;
				i = j - 1;
				break;
			}
		}
	}
	return ret;
}

int main() {
	long long n;
	std::string s;
	std::cin >> n >> s;
	long long ans = 0;
	for (long long i = 0; i < n; i++) {
		std::string t = s.substr(i);
		std::vector<long long> v = z_algorithm(t);
		long long subans = 0;
		for (long long j = 0; j < v.size(); j++) {
			subans = std::max(subans, std::min(v[j], j));
		}
		ans = std::max(ans, subans);
	}
	std::cout << ans << std::endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<vector<int>> vec(2, vector<int>(N));
  for(int i=0; i<2; i++){
    for(int j=0; j<N; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  int ans = 0;
  int ans_tmp = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<=i; j++){
      ans_tmp += vec.at(0).at(j);
    }
    for(int k=i; k<N; k++){
      ans_tmp += vec.at(1).at(k);
    }
    if(ans_tmp > ans){
      ans = ans_tmp;
    }
    ans_tmp = 0;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
s = int(input())
ser = [s]
i = 0

while True:
    if ser[i] % 2 == 0:
        temp = ser[i]/2
    else:
        temp = 3 * ser[i] + 1
    
    if temp in ser:
        print(i+2)
        break
    else:
        ser.append(temp)
    
    i += 1

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if(s[2]=='7'||s[1]=='7'||s[0]=='7') cout << "Yes" << "\n";
    else                                cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<tuple<ll, ll, ll> > arr(N);
  ll x, y, h;
  for(int i=0;i<N;++i) {
    cin>>x>>y>>h;
    arr[i] = mt(h, x, y);
  }
  sort(arr.begin(), arr.end(), greater<tuple<ll, ll, ll> >());
  ll Cx, Cy, H;
  ll tmpH;
  bool can=false;
  ll zero = 0;
  for(int i=0;i<=100;++i) {
    if(can) break;
    for(int j=0;j<=100;++j) {
      tmpH = get<0>(arr[0])+abs(get<1>(arr[0])-i)+abs(get<2>(arr[0])-j);
      can = true;
      for(int k=1;k<N;++k) {
        if(max(tmpH-abs(get<1>(arr[k])-i)-abs(get<2>(arr[k])-j), zero)!=get<0>(arr[k])) can = false;
      }
      if(can) {
        Cx = i;
        Cy = j;
        H = tmpH;
        break;
      }
    }
  }
  cout<<Cx<<" "<<Cy<<" "<<H<<endl;
}



Measured memory_bytes: 3604