akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>

using namespace std;

#define n 4
#define n2 16
#define LIM 100

static const int dx[4]={0, -1, 0, 1};
static const int dy[4]={1, 0, -1, 0};
static const char dir[4]={'r', 'u', 'l', 'd'};
int MDT[n2][n2];

struct puz {int f[n2], space, MD; };

puz state;
int limit;
int path[LIM];

int getAllMD(puz pz){
  int sum=0;
  for(int i=0 ; i<n2 ; i++){
    if(pz.f[i]==n2)continue;
    sum+=MDT[i][pz.f[i]-1];
  }
  return sum;
}

bool isSolved(){
  for(int i ; i<n2 ; i++)if(state.f[i]!=i+1)return false;
  return true;
}

bool dfs(int depth, int prev){
  if(state.MD==0)return true;
  if(depth+state.MD>limit)return false;
  int sx=state.space/n;
  int sy=state.space%n;
  puz tmp;
  for(int r=0 ; r<4 ; r++){
    int tx=sx+dx[r];
    int ty=sy+dy[r];
    if(tx<0 || ty<0 || tx>=n || ty>=n)continue;
    if(max(prev, r)-min(prev, r)==2)continue;
    tmp=state;
    state.MD-=MDT[tx*n+ty][state.f[tx*n+ty]-1];
    state.MD+=MDT[sx*n+sy][state.f[tx*n+ty]-1];
    swap(state.f[tx*n+ty], state.f[sx*n+sy]);
    state.space=tx*n+ty;
    if(dfs(depth+1,r)){path[depth]=r; return true; }
    state=tmp;
  }
  return false;
}

string indep(puz in){
  in.MD=getAllMD(in);
  for(limit=in.MD ; limit<=LIM ; limit++){
    state=in;
    if(dfs(0, -100)){
      string ans="";
      for(int i=0 ; i<limit ; i++)ans+=dir[path[i]];
      return ans;
    }
  }
  return "unsolvabe";
}

int main(){
  for(int i=0 ; i<n2 ; i++)
    for(int j=0 ; j<n2 ; j++)
      MDT[i][j]=abs(i/n-j/n)+abs(i%n-j%n);
  puz in;
  for(int i=0 ; i<n2 ; i++){
    cin>>in.f[i];
    if(in.f[i]==0){
      in.f[i]=n2;
      in.space=i;
    }
  }
  string ans=indep(in);
  cout<<ans.size()<<endl;
  return 0;
}



Measured memory_bytes: 3196
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N;
	int x;
	cin >> x;
	if (x == 1 || x == 2 * N - 1) {
		cout << "No" << endl;
		return 0;
	}
	if (N == 2) {

		cout << "Yes" << endl;
		cout << 1 << endl
			 << 2 << endl
			 << 3 << endl;
		return 0;
	}
	vector< bool > used(2 * N, false);
	used[x] = true;
	vector< int > M(4);
	M[1] = x;
	if (x == 2) {
		M[2] = 1;
		M[0] = 3;
		M[3] = 4;
		used[1] = used[3] = used[4] = true;
	} else {
		M[2] = x + 1;
		M[0] = 1;
		M[3] = 2;
		used[x + 1] = used[1] = used[2] = true;
	}
	cout << "Yes" << endl;
	int k = 1;
	rep(i, N - 2) {
		while (used[k])
			k++;
		cout << k++ << endl;
	}
	rep(i, 4) {
		cout << M[i] << endl;
	}
	rep(i, N - 3) {
		while (used[k])
			k++;
		cout << k++ << endl;
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

string s,sum;
cin >> s;
for(int i = 0; i < s.size();i += 2) sum += s.at(i);
cout << sum << endl;

//////////////////////////////////////////////////////
return 0;}

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

#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, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main() {

  int X, Y;
  int n, m;
  cin >> X >> Y;

  if((X+Y)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  

  
  n = (2*Y-X)/3;
  m = (2*X-Y)/3;

  COMinit();

  cout << COM(n+m,n) << endl;
     
}






Measured memory_bytes: 123148
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  

int main() {
	int n, r;
	cin >> n >> r;
	if (n < 10) {
		r = r+(100 * (10 - n));
	}
	cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    string ans="No";
    
    rep(i,k+1){
        if(a>=b){
            b=b*2;
            continue;
        }else if(b>=c){
            c=c*2;
            continue;
        }else{
            ans="Yes";
            break;
        }
        
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

char arr[300000];

void solve() {

    scanf("%s", arr);
    int len = strlen(arr);
    int ans = 1;
    bool jump = false;
    for(int i = 1 ; i < len ; i++) {
        ans++;
        if(!jump) {
            if(arr[i] == arr[i-1]) {
                if(i == len-1) ans--;
                else i++;
                jump = true;
            }
        } else jump = false;
    }
    printf("%d\n", ans);
}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){return (int)s.size();}
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    vvc<int> a(n,vi(3));
    vvc<ll> dp(n,vc<ll>(3,-INF));
    rep(i,n){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    
    rng(i,1,n){
        chmax(dp[i][0], max(dp[i-1][1],dp[i-1][2])+a[i][0]);
        chmax(dp[i][1], max(dp[i-1][0],dp[i-1][2])+a[i][1]);
        chmax(dp[i][2], max(dp[i-1][0],dp[i-1][1])+a[i][2]);
    }
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> s(m), c(m);
    rep(i,m) cin >> s[i] >> c[i];
    int ans = -1;
    if(n==1&&m==0){
        ans = 0;
        cout << ans << endl;
        return 0;
    }else if(n==1&&c[0]==0){
        ans = 0;
        cout << ans << endl;
        return 0;
    }
    for(int i=pow(10,(n-1)); i<pow(10,n); ++i){
        bool ok=true;
        vector<int> x(n);
        int y=i;
        rep(j,n){
            x[j]=y%10;
            y/=10;
        }
        rep(j,m){
            if(x[n-s[j]]!=c[j]){
                ok=false;
                break;
            }
        }
        if(ok){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long  long
#define INF 0x3f3f3f3f
#define pll pair<long long , long long>
const int MAX=1e6+9;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int prime[MAX];
int main() 
{
   int n;
   cin>>n;
   cout<<(!n);


}


Measured memory_bytes: 27032
#include <cstdio>
#include <algorithm>
const int N = 101;
int a[N][N];
int r[N * N]; // r[x] = row of element x
int p[N][N]; // p[x][y] = row of element y in column x

int next(int row)
{
	int col = 0;
	while (a[row][col] != -1)
		++col;
	return col;
}

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
		{
			int x; scanf("%d", &x);
			r[x - 1] = i;
			a[i][j] = -1;
		}
	
	for (int i = 0; i < n * m; ++i)
	{
		int row = r[i];
		int col1 = i % m;
		int col2 = next(row);
		int val = i / m;
		if (col1 == col2)
		{
			a[row][col1] = val;
			p[col1][val] = row;
		} 
		else 
			while (val != -1)
			{
				p[col1][val] = row;
				std::swap(val, a[row][col1]);
				a[row][col2] = val;
				if (val != -1)
					std::swap(row, p[col2][val]);
			}
	}
	
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
		{
			int val = a[i][j] * m;
			for (int k = 0; k < m; ++k)
				if (r[val + k] == i)
				{
					a[i][j] = val + k;
					r[val + k] = -1;
					break;
				}
		}
	
	for (int i = 0; i < n; ++i, puts(""))
		for (int j = 0; j < m; ++j)
			printf("%d ", a[i][j] + 1);
	
	for (int i = 0; i < m; ++i)
		for (int j = 1; j < n; ++j)
			for (int k = 0; k < n - j; ++k)
				if (a[k][i] > a[k + 1][i])
					std::swap(a[k][i], a[k + 1][i]);
	
	for (int i = 0; i < n; ++i, puts(""))
		for (int j = 0; j < m; ++j)
			printf("%d ", a[i][j] + 1);
}


Measured memory_bytes: 384
n = int(input())
l = list(map(int, input().split()))

s = sorted(l)

ret = []
for i in range(len(l)):
    if l[i] != s[i]:
        if len(ret) >= 2:
            print("NO")
            exit(0)

        ret.append(i)

le = len(ret)
if le == 0 or  le == 2:
    print("YES")
    exit(0)

print("NO")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
#define N 200010
using namespace std;
int n,a[N],b[N],x[N],y[N]; ll ans;
int main(){
	scanf("%d",&n);
	rep (i,1,n) scanf("%d",&a[i]);
	rep (i,1,n) scanf("%d",&b[i]);
	rep (i,0,28){
		int All=(1<<i)-1,ca=0,cb=0; ll tmp=0;
		rep (j,1,n){
			x[j]=a[j]&All; ca+=a[j]>>i&1;
			y[j]=b[j]&All; cb+=b[j]>>i&1;
		}
		tmp+=(ll)ca*(n-cb)+(ll)cb*(n-ca);//非进位
		sort(x+1,x+1+n); sort(y+1,y+1+n);
		int l=0,r=n+1;
		while (++l<=n){//进位
			while (r>1 && y[r-1]+x[l]>All) r--;
			tmp+=n-r+1;
		}
		ans+=(tmp&1)<<i;//重复计算不影响奇偶性
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#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, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    int a, b;
    a = (s[0] - '0') * 10 + (s[1] - '0');
    b = (s[2] - '0') * 10 + (s[3] - '0');

    //01~12

    string ans;
    if(1 <= a && a <= 12)
    {
        if(1 <= b && b <= 12)
        {
            ans = "AMBIGUOUS";
        }
        else
        {
            ans = "MMYY";
        }
    }
    else
    {
        if(1 <= b && b <= 12)
        {
            ans = "YYMM";
        }
        else
        {
            ans = "NA";
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline char nchar() {
	static const int bufl=1<<20;
	static char buf[bufl],*a=NULL,*b=NULL;
	return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++;
}
inline int read() {
	int x=0,f=1;
	char c=nchar();
	for (;!isdigit(c);c=nchar()) if (c=='-') f=-1;
	for (;isdigit(c);c=nchar()) x=x*10+c-'0';
	return x*f;
}
inline char oth(char c) {
	return 'A'+'B'-c;
}
int d;
inline int up(int x,int y) {
	return (x+y-1)/y;
}
int get_d(int A,int B) {
	if (A<B) swap(A,B);
	int ret=(A+B)/(B+1);
	while (ret>1 && up(A,ret-1)-1<=B) --ret;
	return ret;
}
void d_is_one(int A,int B,int l,int r) {
	if (B>A) {
		char c=l&1?'B':'A';
		for (int i=l;i<=r;++i,c=oth(c)) putchar(c);
	} else {
		char c=l&1?'A':'B';
		for (int i=l;i<=r;++i,c=oth(c)) putchar(c);
	}
	puts("");
}
void work(int A,int B,int l,int r,int sh=0) {
	if (l>r || A+B==0) return;
	assert(l<=r && r<=A+B);
	int x=A-up(B,d)+1;
	if (sh || x<=0) {
		int k=x<=0?(B-1)%d+1:1;
		for (;l<=k && l<=r;++l) putchar('B');
		return work(A,B-k,l-k,r-k);
	} else {
		int sh=min(x,d);
		for (;l<=sh && l<=r;++l) putchar('A');
		return work(A-sh,B,l-sh,r-sh,1);
	}
}
void deal(int A,int B,int l,int r) {
	if (l>r) return;
	int x=A-up(B,d)+1;
	if (!B) {
		for (int i=l;i<=r;++i) putchar('A');
		return;
	}
	if (x<=0) {
		int k=B-d*A;
		assert(k>0);
		for (;l<=k && l<=r;++l) putchar('B');
		return deal(A,B-k,l-k,r-k);
	}
	if (x>=d) {
		int cnt=(1ll*d*(A+1-d)-B)/(1ll*d*d-1)+1;
		int h=min((l-1)/(d+1),cnt),len=(d+1)*h;
		if (h) return deal(A-d*h,B-h,l-len,r-len);
		for (;l<=d && l<=r;++l) putchar('A');
		for (;l<=d+1 && l<=r;++l) putchar('B');
		return deal(A-d,B-1,l-(d+1),r-(d+1));
	}
	if (B%d || A*d!=B) {
		int b=(B-1)%d+1;
		for (;l<=x && l<=r;++l) putchar('A');
		for (;l<=x+b && l<=r;++l) putchar('B');
		return deal(A-x,B-b,l-(x+b),r-(x+b));
	} else {
		assert(A*d==B);
		int cnt=(l-1)/(1+d),len=cnt*(d+1);
		if (cnt) return deal(A-cnt,B-d*cnt,l-len,r-len);
		for (;l<=1 && l<=r;++l) putchar('A');
		for (;l<=1+d && l<=r;++l) putchar('B');
		return deal(A-1,B-d,l-(d+1),r-(d+1));
	}
}
void work() {
	int A=read(),B=read();
	int l=read(),r=read();
	d=get_d(A,B);
	if (d==1) return d_is_one(A,B,l,r);
	deal(A,B,l,r);
	puts("");
}
int main() {
	for (int T=read();T--;) work();
	return 0;
}


Measured memory_bytes: 384
module kkk
  sub main ()
    dim s as string
    dim alp as string
    dim ans as string
    
    s = Console.ReadLine()
    
    alp = "abcdefghijklmnopqrstuvwxyz"
    
    ans = Right(Left(alp, InStr(alp, s) + 1), 1)
    
    Console.WriteLine(ans)
  end sub
end module
    

Measured memory_bytes: 13408
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size())cout<<"GREATER"<<endl;
	if(a.size()<b.size())cout<<"LESS"<<endl;
	if(a.size()==b.size()){
		if(a>b)cout<<"GREATER"<<endl;
		if(a<b)cout<<"LESS"<<endl;
		if(a==b)cout<<"EQUAL"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
//给定三个整数A，B，C。
//如果整数C大于等于A且小于等于B，输出“Yes",否则输出”No".
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    if(c>=a&&c<=b)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef unsigned int uint32_t;
typedef int int32_t;
typedef long long int64_t;
#define NUM_CONTESTS (26)
#define MAX_DAY (365)


int main()
{
    int32_t D;
    int32_t c[NUM_CONTESTS];
    int32_t s[MAX_DAY][NUM_CONTESTS];
    int32_t t[MAX_DAY];
    int32_t score;
    
    // Read data
    scanf("%d", &D);
    for(int i =0; i<NUM_CONTESTS;i++){
        scanf("%d", &c[i]);
    }
    for(int i=0; i<D;i++){
        for(int j=0;j<NUM_CONTESTS;j++){
            scanf("%d", &s[i][j]);
        }
    }
    for(int i=0; i<D; i++){
        scanf("%d", t+i);
    }

    // Calc satisfaction score
    int M, d, q;
    scanf("%d", &M);
    for(int j=0; j<M;j++){
        scanf("%d %d", &d, &q);
        t[d-1] = q;

        score = 0;
        int last[NUM_CONTESTS]={0};
        for(int i=0; i<D;i++){
            int num = t[i]-1;
            score += s[i][num];
            last[num] = i+1;
            for(int j=0; j<NUM_CONTESTS; j++){
                score -= c[j]*(i+1-last[j]);
            }
        }
        printf("%d\n",score);
    }
    

    
    return 0;
}

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

int n, m;

int main() {
  cin >> n >> m;
  vector<int> L(m);
  vector<int> R(m);
  rep (i, m) {
    cin >> L.at(i) >> R.at(i);
  }
  int ansL = 1;
  int ansR = n;
  rep (i, m) {
    ansL = max(ansL, L.at(i));
    ansR = min(ansR, R.at(i));
  }
  if (ansL <= ansR) {
    cout << ansR - ansL + 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int main(void) {
	string s;
	getline(cin, s);

	transform(s.begin(), s.end(), s.begin(), ::toupper);

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 1180
n = int(input())
S = [str(input()) for _ in range(n)]

a = 0
b = 0
ab = 0
ans = 0
for s in S:
    ans += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        ab += 1
    elif s[0] == 'B':
        b += 1
    elif s[-1] == 'A':
        a += 1
    else:
        pass
if ab:
    ans += ab-1
if ab:
    if a:
        ans += 1
        a -= 1
    if b:
        ans += 1
        b -= 1
ans += min(a, b)
print(ans)


Measured memory_bytes: 44248
/*
    /\ In The Name Of ALLAH /\
    Author : Jawahiir Nabhan
*/
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 3736
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 15
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353

n, m = LI()
a = n + 3 * m
fac = [1] * (a + 1)
inv = [1] * (a + 1)
for j in range(1, a + 1):
    fac[j] = fac[j-1] * j % mod

inv[a] = pow(fac[a], mod-2, mod)
for j in range(a-1, -1, -1):
    inv[j] = inv[j+1] * (j+1) % mod

def comb(x, y):
    if y > x or x < 0 or y < 0:
        return 0
    return fac[x] * inv[x - y] * inv[y] % mod

ans = 0
for i in range(min(m + 1, n + 1)):
    if (m - i) % 2:
        continue
    ans += comb(n, i) * comb((m * 3 - i) // 2 + n - 1, n - 1)
    ans %= mod

print((ans - n * comb(m - 1 + n - 1, n - 1)) % mod)

Measured memory_bytes: 81116
# include <iostream>
# include <algorithm>

using namespace std;

int main() {
  int N, a[300000];
  cin >> N;
  
  for (int i = 0; i < 3 * N; i++) cin >> a[i];
  sort(a, a + 3 * N);
  
  // int型だと桁あふれ？する
  long ans = 0;
  // 最大値2つと最小値1つの組み合わせのとき、最大となるはず
  for (int i = N; i < 3 * N; i+=2) ans += a[i];
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
    int N, K;
    cin >> N >> K;
    
    double p[N];
    double expect[N];
    for(int i = 0; i <N; i++) cin >> p[i];
    for(int i = 0; i < N; i++){
        double tmp = 0.0;
        for(int j = 0; j < p[i]; j++){
            tmp += (j+1) / p[i];
        }
        expect[i] = tmp;
    }
    double ans = 0;
    double comsum[N+1];
    comsum[0] = 0.0;
    for(int i = 0; i< N; i++){
        comsum[i+1] = comsum[i] + expect[i];
    }
    
    
    for(int i = K; i <= N; i++){
        double tmp2 = comsum[i] - comsum[i-K];
        ans = max(ans, tmp2);
    }
    
    printf("%.10f", ans);
}



Measured memory_bytes: 5504
#include<iostream>
#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>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a,d;cin>>a;
  deque <ll>b;
  rep(i,a){
    cin>>d;
    if(i%2==1)b.push_front(d);
    else b.push_back(d);
  }
  if(a%2==1)reverse(b.begin(),b.end());
  rep(i,a)cout<<b[i]<<" ";
}

Measured memory_bytes: 27264
#include<stdio.h>

#define MAX 10000
#define INF 1000000001
#define NIL -1
#define BLACK 1

typedef struct{
  int k;
  int v[MAX];
  int c[MAX];
}node;


int d[MAX],pi[MAX],color[MAX];
node A[MAX];

void initializeSS(int,int);
void dijkstra(int,int);


int main(){
  int i,j,n,u,sum;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&A[u].k);
    for(j=0;j<A[u].k;j++) scanf("%d%d",&A[u].v[j],&A[u].c[j]);
  }

  dijkstra(n,0);

  sum=0;
  
  for(i=0;i<n;i++) printf("%d %d\n",i,d[i]);
  
  return 0;
}

void initializeSS(int n,int s){
  int v;

  for(v=0;v<n;v++){
    d[v]=INF;
    pi[v]=NIL;
  }
  d[s]=0;
}

void dijkstra(int n,int s){
  int i,u,v,mincost;
  
  initializeSS(n,s);

  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }

    if(mincost==INF) break;

    color[u]=BLACK;

    for(i=0;i<A[u].k;i++){
      v=A[u].v[i];
      if(color[v]!=BLACK && d[u]+A[u].c[i]<d[v]){
	pi[v]=u;
	d[v]=d[u]+A[u].c[i];
      }
    }
  }
}



Measured memory_bytes: 83520
from operator import itemgetter

n,m=map(int,input().split())
l=sorted([list(map(int,input().split())) for i in range(m)],key=itemgetter(1))
x,cnt=l[0][1],1
for i in l:
    a=i[0]
    b=i[1]
    if a>=x:
        cnt+=1
        x=b
print(cnt)

Measured memory_bytes: 29920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD=1e9+7;
const long long INF = 1LL<<60;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0;i<n;i++){
        cin >> a.at(i);
    }

    map<ll,ll> mp_all;
    for(ll i = 0;i<n;i++){
        mp_all[a.at(i)]++;
    }

    ll count_all = 0;
    for(auto itr = mp_all.begin();itr!=mp_all.end();itr++){
        count_all+= (itr->second)*(itr->second-1)/2;
    }

    map<ll,ll> mp_answers;
    for(auto itr = mp_all.begin();itr!=mp_all.end();itr++){
        ll number = itr->first, count = itr-> second;
        ll count_without_number = count_all - count*(count-1)/2 + (count-1)*(count-2)/2;
        mp_answers[number] = count_without_number;
    }

    for(ll i = 0;i<n;i++){
        cout << mp_answers[a.at(i)] << endl;
    }
}

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

int main() {
int x,a,b,c,d;
cin>>x;
a=x/1000;
x%=1000;
b=x/100;
x%=100;
c=x/10;
d=x%10;
for(int i=0;i<(1<<3);i++){
    int s=a+b+c+d;
    string t="+++";
    if((1&i>>0)==1)s-=b*2,t[0]='-';
    if((1&i>>1)==1)s-=c*2,t[1]='-';
    if((1&i>>2)==1)s-=d*2,t[2]='-';
    if(s==7){
        cout<<a<<t[0]<<b<<t[1]<<c<<t[2]<<d<<"="<<s<<endl;
return 0;
    }
}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int main() {
  int n,K; cin >> n >> K;
  vector<int> x(n),y(n);
  rep(i,n) cin >> x[i] >> y[i];
  
  ll ans = 1LL << 62;
  
  rep(i,n)rep(j,n)rep(k,n)rep(l,n){
    int cnt = 0;
    if(x[i] < x[j] && y[k] < y[l]){
      rep(m,n){
        if(x[i] <= x[m] && x[j] >= x[m] && y[k] <= y[m] && y[l] >= y[m]) cnt++;
      }
    }
    if(cnt >= K) chmin(ans, (ll)(x[j]-x[i])*(ll)(y[l]-y[k]));
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

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

	int A1, A2, A3, A4;
	int B1, B2, B3, B4;
	while (cin >> A1 >> A2 >> A3 >> A4) {
		int hit = 0, blow = 0;
		vector<int>A(4);
		vector<int>B(4);

		A[0] = A1; A[1] = A2; A[2] = A3; A[3] = A4;
		REP(i, 4) cin >> B[i];

		REP(i, 4) {
			REP(j, 4) {
				if (A[i] == B[j]) {
					if (i == j) {
						hit++;
					} else {
						blow++;
					}
				}
			}
		}
		cout << hit << " " << blow << "\n";
	}
	return 0;
}

Measured memory_bytes: 3104
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();
    let mut ans = 0;
    for (i, c) in s.into_iter().enumerate() {
        if c != t[i] {
            ans += 1;
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 3972
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int p(int A,int B){
  if(!B)return 1;
  if(B%2)return p(A,B-1)*A%mod;
  int C=p(A,B/2);
  return C*C%mod;
}
signed main(){
  int N;
  string S;
  cin>>N>>S;
  int A[5100][5100]{};
  A[0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=N;j++){
      A[i+1][max(j-1,0LL)]=(A[i+1][max(j-1,0LL)]+A[i][j])%mod;
      A[i+1][j+1]=(A[i+1][j+1]+A[i][j]*2)%mod;
    }
  }
  cout<<A[N][S.size()]*p(p(2,S.size()),mod-2)%mod<<endl;
}

Measured memory_bytes: 206820
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    char[] chars = s.toCharArray();

    if (chars[2] == chars[3] && chars[4] == chars[5]) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[4]={0};
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="AC")
            a[0]++;
        else if(s=="WA")
            a[1]++;
        else if(s=="TLE")
            a[2]++;
        else
            a[3]++;
    }
    printf("AC x %d\n",a[0]);
    printf("WA x %d\n",a[1]);
    printf("TLE x %d\n",a[2]);
    printf("RE x %d\n",a[3]);
    return 0;
}

Measured memory_bytes: 3724
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		int A[][][] = new int[4][3][10];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
        for(int i=0;i<N;i++){
            String[] array = br.readLine().split(" ");
            int b = Integer.parseInt(array[0])-1;
            int f = Integer.parseInt(array[1])-1;
            int r = Integer.parseInt(array[2])-1;
            int v = Integer.parseInt(array[3]);
            A[b][f][r]+=v;
        }
        for(int i=0;i<4;i++){
        	for(int j=0;j<3;j++){
        		for(int k=0;k<10;k++){
        			System.out.print(" "+A[i][j][k]);
        		}
        		System.out.println("");
        	}
        	if(i<3) System.out.println("####################");
        }
	}
}

Measured memory_bytes: 19328
#include <iostream>
using namespace std;
int main(){
    long long k, a, b;
    cin >> k >> a >> b;
    if( a < b - 2 ){
        long long biscuit = a;
        k -= a - 1;
        biscuit += (k/2) * (b-a) + k%2;
        cout << biscuit << endl;
    } else {
        cout << k + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
A,B,Q = map(int,(input().split()))
si = [-(10**10)]+[int(input()) for _ in range(A)]+[2*(10**10)]
ti = [-(10**10)]+[int(input()) for _ in range(B)]+[2*(10**10)]
xi = [(i,int(input())) for i in range(Q)]
A +=2
B +=2

#xを小さい順に考える
xi.sort(key = lambda x:x[1])
ans = [0]*Q
x = xi[0][1]
for i_sr,sr in enumerate(si):
    if sr>x:
        sl = si[i_sr-1]
        break
for i_tr,tr in enumerate(ti):
    if tr>x:
        tl = ti[i_tr-1]
        break
for i,x in xi:
    while sr < x:
        sl = sr
        i_sr += 1
        sr = si[i_sr]
    while tr < x:
        tl = tr
        i_tr += 1
        tr = ti[i_tr]
    dsl = x-sl
    dsr = sr-x
    dtl = x-tl
    dtr = tr-x
    ans[i] = min(max(dsr,dtr),max(dsl,dtl),dsl+dtr+min(dsl,dtr),dsr+dtl+min(dsr,dtl))
for out in ans:
    print(out)

Measured memory_bytes: 29828
let cnt = ref 0

let merge a l m r =
  let ni = m - l in
  let ai = Array.make (ni + 1) max_int in
  for i = 0 to ni - 1 do
    ai.(i) <- a.(l + i)
  done;
  let aj = Array.make (r - m + 1) max_int in
  for i = 0 to r - m - 1 do
    aj.(i) <- a.(m + i)
  done;
  let i = ref 0 in
  let j = ref 0 in
  for k = l to r - 1 do
    if ai.(!i) <= aj.(!j) then begin
      a.(k) <- ai.(!i);
      incr i;
    end else begin
      a.(k) <- aj.(!j);
      cnt := !cnt + (ni - !i);
      incr j;
    end
  done

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 11472
from operator import add
b2q = {"00":"0","01":"1","10":"2","11":"3"}
while True:
    n = input()
    if n == -1:
        break
    s = format(n,"b")
    if len(s) % 2 == 1:
        s = "0" + s
    print "".join(map(b2q.get,map(add,s[::2],s[1::2])))

Measured memory_bytes: 4356
#include <iostream>
#include <string>
#include <vector>
#define INF 100000000
using namespace std;
int main(void){
    int N;
    int W[110];
    
    cin >> N;
    for(int i=0;i<N;i++) cin >> W[i]; 
    
    int S1,S2;
    int dist_now = 1000;
    
    for(int T=1;T<N;T++){
        int S1 = 0,S2 = 0;
        for(int i=0;i<T;i++) {
            S1 += W[i];
          //  cout << S1 << " " << W[i] << " " << T << endl;
        }
        for(int j=T;j<N;j++) {
            S2 += W[j];
          //  cout << S2 << " " << W[j] << " " << T << endl;
        }
        int dist = abs(S1-S2);
        if(dist<dist_now) dist_now = dist;
    }

    cout << dist_now;

    return 0;
    
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 333;

int H, W, D;

pair< int, int > d[MAX_N * MAX_N];
int memo[MAX_N * MAX_N];

ll dfs(int x)
{
  if (memo[x] > -1) return memo[x];
  if (x<D) return 0ll;
  
  ll res = 0ll;
  res += abs(d[x].first - d[x-D].first);
  res += abs(d[x].second - d[x-D].second);
  
  res += dfs(x-D);

  return memo[x] = res;
}

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

  memset(memo, -1, sizeof(memo));
  
  cin >> H >> W >> D;
  REP(hi, H) {
    REP(wi, W) {
      CIN(a); a--;
      d[a] = make_pair(hi, wi);
    }
  }

  ll ans = 0ll;
  CIN(Q);
  REP(i, Q) {
    CIN(l, r);
    l--; r--;
    ans = dfs(r) - dfs(l);
    cout << ans << endl;
  }

  return 0;
}



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

using i64 = long long;

const int N = 2048, MOD = 924844033;


i64 dp[N][N], knap[2][N], factorial[N];
bool f[N];

vector<int> chain_lens;
int n, k;


static void fix(i64 &x) {
	if (x >= MOD)
		x-= MOD;
	if (x < 0)
		x+= MOD; }

static void init_dp() {
	dp[0][0] = dp[1][0] = 1;

	for (int len = 2; len < N; ++len)
	for (int viol = 0; viol <= len / 2; ++viol) {
		dp[len][viol]+= dp[len - 1][viol];
		if (viol > 0)
			dp[len][viol]+= dp[len - 2][viol - 1];
		fix(dp[len][viol]); } }

int main() {
#ifdef HOME
	freopen("agc5d.in", "r", stdin);
	freopen("agc5d.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	i64 ant;
	int mx_dist;

	init_dp();

	cin >> n >> k;
	for (int l, t, i = 1; i <= n; ++i) if (!f[i]) {
		l = 1 + (i - k > 0);
		t = i;
		while (true) { // God forgive me
			f[t] = true;
			if (t + k <= n)
				l+= 1;
			if (t + 2 * k <= n) {
				l+= 1;
				t+= 2 * k; }
			else
				break; }

		chain_lens.push_back(l); }

	knap[0][0] = 1;
	mx_dist = 0;

	for (auto l: chain_lens) { // K steps (for each chain)
		for (int p = mx_dist; p >= 0; --p) // N (knapsack ptr)
			for (int step = 0; step <= l / 2; ++step) if(dp[l][step]) { // N / K (violation count)
				mx_dist = max(mx_dist, step + p);
				knap[1][p + step]+= knap[0][p] * dp[l][step] % MOD;
				fix(knap[1][p + step]); }

		swap(knap[0], knap[1]);
		memset(knap[1], 0x00, sizeof knap[1]); }

	factorial[0] = 1;
	for (int i = 1; i < N; ++i)
		factorial[i] = factorial[i - 1] * i % MOD;

	for (int i = 0; i <= n; ++i)
		knap[0][i] = knap[0][i] * factorial[n - i] % MOD;

	ant = 0;
	for (int i = 0; i <= n; i+= 2) {
		ant+= knap[0][i] - knap[0][i + 1];
		fix(ant);
		fix(ant); }

	cout << ant << endl;

	return 0; }



Measured memory_bytes: 31616
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
    char a[101];
	char b[101];
	f(i, 101){
		a[i] = 0;
		b[i] = 0;
	}
	int n, m;
	int x, y;
	int ans = 0;
	scanf("%d", &n);
	x = 0;
	y = 0;
	f(i,n){
		scanf("%s", a);
		scanf("%s", b);
		m = strcmp(a, b);
		if (m > 0)x += 3;
		else if (m < 0)y += 3;
		else {
			x++;
			y++;
		}
	}
	printf("%d %d\n", x, y);
	return 0;
}

Measured memory_bytes: 2804
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Node W[] = new Node[n];
		int s=Integer.MAX_VALUE, cost=0;
		for(int i=0; i<n; i++){
			W[i] = new Node();
			W[i].value = sc.nextInt();
			W[i].place = -1;
			if(s > W[i].value) s = W[i].value;
		}

		for(int j=0; j<n; j++){
			int min=Integer.MAX_VALUE, place=-1;
			for(int i=0; i<n; i++){
				if(W[i].place != -1) continue;
				if(min > W[i].value){
					min = W[i].value;
					place = i;
				}
			}
			W[place].place = j;
		}

		for(int i=0; i<n; i++){
			int j=W[i].place;
			if(j != -1 && j != i){
				int cnt=1, min, sum;
				min = sum = W[i].value;
				while(j != i){
					int next = W[j].place;
					if(min > W[j].value) min = W[j].value;
					sum += W[j].value;
					cnt++;
					W[j].place = -1;
					j = next;
				}
				cost += sum+(cnt-2)*min<sum+min+(cnt+1)*s?
				        sum+(cnt-2)*min:
				        sum+min+(cnt+1)*s;
			}
		}

		System.out.println(cost);
	}
}
class Node{
	int value;
	int place;
}

Measured memory_bytes: 21200
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l;
	string p,q;
	cin>>p>>q;
	l=q.length();
	p+=q[l-1];
	if(p==q)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  long long int a,b,i;
  string s;
  cin>>a>>s;
  
  b=(s[0]-'0')*100+(s[2]-'0')*10+s[3]-'0';
  a=a*b/100;
  cout<<a<<endl;
  
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

ll modmultiply(ll a,ll b,ll c) {
  ll x = 0,y = a%c; 
  while(b > 0) {
    if(b%2 == 1) x = (x+y)%c; 
    y = (y*2)%c;
    b /= 2; 
  }
  return x%c;
}

ll modpow(ll x, ll y, ll mod) {
  ll ret = 1;// ret = x^y%mod;
  while(y) {
    if(y&1)
      //ret = (ret*x)%mod;
      ret = modmultiply(ret, x, mod);
    //x = (x*x)%mod;
    x = modmultiply(x, x, mod);
    y >>= 1;
  }
  return ret;
}

int N,K;

const ll mod = 1000000007LL;

vector<int> getDiv(int n){
  vector<int> res;
  for(int i=1;i*i<=n;i++)
    if(n%i == 0)
	{
	  res.push_back(i);
	  if(i*i != n) 
	    res.push_back(n/i);
	}
  return res;
}


typedef pair<ll,ll> ii;
map<ii,ll> mp;
ll bf_ans = 0;
map<ll,ll> cnt;
void dfs(int cur,ll g,deque<ll> &deq) {
  if( cur >= N ) {
    //cout << "g = " << g << endl;
    cout << "gcd(";
    rep(i,(int)deq.size()) {
      if( i ) cout << ", ";
      cout << deq[i];
    }
    cout << ") = " << g << endl;
    ++cnt[g];
    bf_ans += g;
    bf_ans %= mod;
    return;
  }
  REP(i,1,K+1) {
    deq.pb(i);
    dfs(cur+1,__gcd(g,(ll)i),deq);
    deq.pop_back();
  }
}

ll bf() {
  REP(i,1,K+1) {
    deque<ll> deq;
    deq.pb(i);
    dfs(1,i,deq);
  }
  return bf_ans;
}




ll dp[100010];

void solve() {
  //cout << bf() << endl;
  ll ans = 0;
  for(ll i = K; i >= 1; --i) {
    ll v = K / i;
    dp[i] = modpow(v,N,mod);
    for(ll j=i*2;j<=K;j=j+i) {
      dp[i] -= dp[j];
      while( dp[i] < 0 ) ( dp[i] += mod ) %= mod;
      dp[i] %= mod;
    }
    ( ans += (ll)( i * dp[i] ) ) %= mod ;
  }
  cout << ans << endl;
}

int main() {
  cin >> N >> K;
  solve();
  return 0;
}


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

int main() {
  ll N; cin >> N;
  using p = pair<ll, ll>;
  vector<p> a[2];

  for (ll i = 0; i < N; i++) {
    string s; cin >> s;
    ll mn = 0;
    ll cur = 0;

    for (char c : s) {
      cur += (c == '(' ? 1 : -1);
      mn = min(mn, cur);
    }

    if (cur >= 0) {
      a[0].push_back(make_pair(mn, cur));
    } else {
      a[1].push_back(make_pair(mn, cur));
    }
  }

  sort(a[0].begin(), a[0].end(), [](auto &x, auto &y) {
    return x.first > y.first;
  });
  sort(a[1].begin(), a[1].end(), [](auto &x, auto &y) {
    return x.second - x.first > y.second - y.first;
  });

  ll cur = 0;
  for (ll i = 0; i < 2; i++) {
    for (auto &pr : a[i]) {
      ll c = pr.second, m = pr.first;

      if (cur + m < 0) {
        cout << "No" << endl;
        return 0;
      }
      cur += c;
    }
  }

  if (cur == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 19040
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



ll power(ll x,ll k){
  ll ret=1;
  while(k>0){
    if(k&1) (ret*=x) %= M;
    (x*=x) %= M;
    k >>= 1;
  }
  return ret;
}

struct Combinations {
  static int num;
  vi fact,factr,inv;

  Combinations(int num) {

    fact.assign(num+1,0);
    factr.assign(num+1,0);
    inv.assign(num+1,0);
    inv[1]=fact[0]=factr[0]=1;
    FOR(i,2,num+1) inv[i]=inv[M%i]*(M-M/i)%M;
    FOR(i,1,num+1) fact[i]=fact[i-1]*i%M,factr[i]=factr[i-1]*inv[i]%M;
  }


  int comb(int n,int c){
    if(c<0||c>n) return 0;
    return factr[c]*fact[n]%M*factr[n-c]%M;
  }

  int per(int n,int c){
    if(c<0||c>n) return 0;
    return fact[n]*factr[n-c]%M;
  }

  int hcomb(int n,int c){
    if(n==0&&c==0) return 1;
    return comb(n+c-1,c);
  }

};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,k;
  cin>>n>>k;
  cout<<power(k,n)<<endl;

}


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

inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}

const int N=2005;
const int mo=1e9+7;

int ans;

signed main()
{
	int n=read();
	int m=read();
	for ( int i=m;i<=n+1;i++ ) 
	{
		int x=i-1;
		x=(1+x)*x/2;
		x=(x+mo)%mo;
		int tot=0;
		int y=n-i+1;
//		cout<<y<<endl;
		int all=(y+n)*(n-y+1)/2;
		all=all%mo;
		ans=(ans+all-x+1)%mo;
	}
	cout<<(ans+mo)%mo<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
ll a;
int s[1000];
int t=0;
ll pow_2(int n)
{
    ll ans=1;
    for (int i=0; i<n; ++i)
        ans*=-2;
    return ans;
}
ll abss(ll a)
{
    if (a>0) return a;
    return -a;
}
int main()
{
    cin>>a;
    if (a==0) 
    {
        cout<<0<<endl;
        return 0;
    }
    ll i=0;
    ll bit;
    while (a!=0)
    {
        bit = (((1<<i)&abss(a))>0);
        s[t++]=bit;
        if (bit==1)
            a-=pow_2(i);
        i+=1;
    }
    for (int i=t-1; i>=0; --i)
        cout<<s[i];
    cout<<endl;
    return 0;
}

        



Measured memory_bytes: 256