akhauriyash/Code-Regression huggingface dataset:
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];
int n, m;

void solve()
{
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) 
	{
		cin >> arr[i];
	} 
	sort(arr, arr + n);
	int cnt = 0;
	for(int i = n -1; i >= 0; i--)
	{
		if(k > 0)
		{
			k--;
		}
		else
		{
			cnt += arr[i];
		}
	}
	cout << cnt << endl;
}

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

	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

fact = [1, 1]
for i in range(2, max(N, M) + 1):
    fact.append((i * fact[i - 1]) % MOD)

if abs(N - M) >= 2:
    print(0)
elif abs(N - M) == 0:
    print((fact[N] * fact[M] * 2) % MOD)
else:
    print((fact[N] * fact[M]) % MOD)


Measured memory_bytes: 7060
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long ll;
const int INF = 100000;
string s;
string solve(string s)
{
    int n=s.size();
    int dp[n+1][n+1];
    memset(dp,0,sizeof dp);
    int idx=0;
    int len=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if((s[i-1]==s[j-1])&&(dp[i-1][j-1]<(j-i))){
                dp[i][j]=dp[i-1][j-1]+1;
                if(dp[i][j]>len){
                    len=dp[i][j];
                    idx=max(i,idx);
                }
            }
            else{
                dp[i][j]=0;
            }
        }
    }
    string res="";
    if (len> 0)
        for (int i = idx - len + 1; i <= idx; i++)
            res.push_back(s[i-1]);

    return res;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);


    int n;
    cin>>n;
    cin>>s;
    cout<<solve(s).size()<<endl;
}


Measured memory_bytes: 97920
import java.util.Scanner;

public class Main {
	public static boolean havedigit7(int number) {
		boolean have7 = false;
		while (number > 0 && !have7)
			if (number % 10 == 7)
				have7 = true;
			else
				number /= 10;
		return have7;
	}

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.println(havedigit7(scanner.nextInt()) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 35652
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
#define MAXN 300100
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

int32_t main(){
	int A,P;
	cin>>A>>P;
	int total = 3*A+P;
	cout<<total/2<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );};

string a[80];
int h, w;

int fi(char t, int s, int e) {
  int ans = 0;
  for(int i = s; i <= e; i++) {
    rep(j, w) {
      if(a[i][j] != t) ans++;
    }
  }
  return ans;
}

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

  cin >> h >> w;
  rep(i, h) cin >> a[i];
  int ans = h * w;
  for(int w = 1; w < h; w++) {
    for(int b = 1; b < h; b++) {
      int r = h - w - b;
      if(w < 1 || b < 1 || r < 1) continue;
      int res = 0;
      res += fi('W', 0, w - 1);
      res += fi('B', w, w + b - 1);
      res += fi('R', w + b, w + b + r - 1);
      // cout << w << " " << b << " " << r << "  " << res << endl;
      ans = min(ans, res);
    }
  }
  cout << ans << endl;
  // cout << fi('W', 2, 3) << endl;
  return 0;
}



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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

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

  string s, t;
  cin >> s >> t;
  cout << t.append(s) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  cout << (n % 1000 ? 1000 - n % 1000 : 0) << endl;
}


Measured memory_bytes: 3608
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
  Scanner sc= new Scanner(System.in);
        int a = sc.nextInt();
int b = sc.nextInt();

int d=a/b;
int r=a%b;
double f =(double)a/ (double)b;
System.out.println(d);
System.out.println(r);
System.out.printf("%.8f",f);

	}
}



Measured memory_bytes: 26584
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
		}
	int dp[n][3];
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
		dp[i][1]=max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
		dp[i][2]=max(dp[i-1][0]+arr[i][2],dp[i-1][1]+arr[i][2]);
		}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	
	}


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

int main() {
    string mp = "ACGT";
    char c;

    cin >> c;
    for (int i = 0; i < int(mp.size()); i++) {
        if (c != mp[i]) continue;
        cout << mp[int(mp.size()) - i - 1] << endl;
    }

    return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

int n, k, a[202020];

int chk(int x){
    ll cnt = 0;
    for(int i=1; i<=n; i++) cnt += (a[i] - 1) / x;
    return cnt <= k;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> k; for(int i=1; i<=n; i++) cin >> a[i];
    int l = 1, r = 1e9;
    while(l < r){
        int m = l + r >> 1;
        if(chk(m)) r = m;
        else l = m + 1;
    }
    cout << r;
}

Measured memory_bytes: 4484
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <math.h>

int main(void)
{
    double r;
    scanf("%lf", &r);
    printf("%.6lf %.6lf\n", M_PI * r * r, 2.0 * M_PI * r);

    return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define Jrep(j,n) for(int j=0;j<(n);j++)
#define Jreps(j,n) for(int j=1;j<=(n);j++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,dp[100010]={};
    cin>>n;
    int h[100010];
    reps(i,n){
	cin>>h[i];
    }
    dp[2]+=abs(h[1]-h[2]);
    for(int i=3;i<=n;i++){
	dp[i]+=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    }
    cout<<dp[n]<<'\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    string s,t; cin>>s>>t;
    bool ok=false;
    rep(i, s.size()-t.size()+1){
        bool che=true;
        rep(j,t.size()){
            if(s[j+s.size()-t.size()-i]==t[j] || s[j+s.size()-t.size()-i]=='?'){

            }else{
                che=false;
                break;
            }
        }
        if(che){
            rep(j,t.size()){
                s[j+s.size()-t.size()-i]=t[j];
                ok=true;
            }
            break;
        }
    }
    if(ok){
        rep(i, s.size()){
            if(s[i]=='?'){
                s[i]='a';
            }
        }
        cout<<s<<endl;
    }else{
        cout<<"UNRESTORABLE"<<endl;
    }
    return 0;
}

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

const LL MOD = pow(10,9) + 7;

int main(){
    int n;
    cin >> n;
    string s;
    char c;
    LL count1 = 0,count2 = 0;
    for(int i = 0; i < n; ++i){
        cin >> c;
        if(c == '.') count1++;
        s += c;
    }

    if(count1 == n || count1 == 0){
        cout << 0 << endl;
    }else{

    LL ans = MOD;

    for(int i = 0; i < n; ++i){
        ans = min(count1 + count2,ans);
        if(s[i] == '.') count1--;
        if(s[i] == '#') count2++;
        ans = min(count1 + count2,ans);
    }

    cout << ans << endl;

    }


    return 0;
}

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

using namespace std;

#define u64             uint64_t
#define i64             int64_t
#define mod             1000000007
#define inf             1e18
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    /**************************/
     
    int a = 0;
    int w = 0;
    int tl = 0;
    int r = 0;
    int t;
    cin >> t;
    while(t--)
    {
        string s;
        cin >> s;
        if(s == "AC")
        {
            a++;
        }else if(s == "WA")
        {
            w++;
        }else if(s == "TLE")
        {
            tl++;
        }
        else if (s == "RE"){
            r++;
        }   
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << tl << endl;
    cout << "RE x " << r << endl;

    /**************************/
    cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) sort((a).rbegin(),(a).rend());
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n,m;


struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

vector<int> sosuu = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};

int count(int x,int y){
    int ans = 0;
    while(x>=y){
        ans += x/y;
        x /= y;
    }
    return ans;
}

signed main(){
    cin >> n;
    vector<int> a(5);
    REP(i,sosuu.size()){
        int x = count(n,sosuu[i]);
        if(x>=74){
            REP(j,5){
                a[j]++;
            }
        }
        else if(x>=24){
            REP(j,4){
                a[j]++;
            }
        }
        else if(x>=14){
            REP(j,3){
                a[j]++;
            }
        }
        else if(x>=4){
            REP(j,2){
                a[j]++;
            }
        }
        else if(x>=2){
            REP(j,1){
                a[j]++;
            }
        }
    }
    //Debug(a);
    int ans = a[3] * (a[0]-1) + a[1] * (a[1]-1) * (a[0]-2)/2 + a[2] * (a[1]-1) + a[4];
    print(ans);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


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

using namespace std;

typedef long long ll;

int cnt[20][20];
int n;

int main()
{
//    freopen("input", "r", stdin);
    cin.tie(0); cin.sync_with_stdio(false);

    cin >> n;

    int i, j, k, l;
    for(i=1; i<=n; ++i)
    {
        long double x;
        cin >> x;
        ll y = round (x * 1000000000);

        int n2 = 0, n5 = 0;

        while(y%2 == 0)
            y/=2, n2++;

        while(y%5 == 0)
            y/=5, n5++;

        n2 = min(n2, 18);
        n5 = min(n5, 18);
        ++cnt[n2][n5];
    }

    ll ans = 0;

    for(i=0; i<=18; ++i)
        for(j=0; j<=18; ++j)
            for(k=0; k<=18; ++k)
                for(l=0; l<=18; ++l)
                {
                    if(i+k<18 || j+l<18) continue;
                    if(make_pair(i, j) > make_pair(k, l)) ans += (ll) cnt[i][j] * cnt[k][l];
                        else if(make_pair(i, j) == make_pair(k, l)) ans += (ll) cnt[i][j] * (cnt[i][j]-1) / 2;
                }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	int n,c=0,max=0;
  	cin>>n;
  	long int a[n];
  cin>>a[0];
    for(int i=1;i<n;i++)
    {
      cin>>a[i];
      if(a[i]<=a[i-1])
        c++;
      else
        c=0;
    	if(c>max)
    		max=c;
  }
  cout<<max;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int x, max;
    x = 0;
    max = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'I'){
            x++;
            if (max < x) max = x;
        } else {
            x--;
        }
    }
    cout << max << endl;
}

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

int main()
{
    // get a integer
    int a,b,k,d,i;
    cin >> k;

    cin >> a >> b;
    d=0;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)d=1;
    }
    if(d==1)cout << "OK" ;
    else cout << "NG" ;
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector <char> v;
vector<int> num;

int main(){
  char s;

  for (int i = 0; i < 9; i ++ ){
    cin >> s;
    if(i == 0||i == 4||i==8){
      v.push_back(s);
    }
  }
  for (int i= 0;i<3;i++){
    cout << v[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10000000)


N,Q=list(map(int, input().split() ))

data={i+1:0 for i in range(N)}

# for i in range(N-1):
#     a,b=list(map(int, input().split() ))
#     hoge[a].baby_list.append(b)

relate = [list(map(int, input().split() )) for i in range(N-1)]
relate.sort(key=lambda x :x[0])
    
for i in range(Q):
    root, value = list(map(int, input().split() ))
    data[root]+=value

for a,b in relate:
    data[b]+=data[a]

print(" ".join(list(map(str,list(data.values())))))

Measured memory_bytes: 96504
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<map>

#define Rep(i,x,y) for (int i=x,_Lim=y;i<=_Lim;i++)
#define Dep(i,x,y) for (int i=x,_Lim=y;i>=_Lim;i--)

#define mk(a,b) make_pair(a,b)

using namespace std;

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

int Stv[1<<8];

inline int read(){
	int f=1,res=0,ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;ch=getchar();
	}
	while (ch>='0' && ch<='9') res=res*10+ch-48,ch=getchar();
	return f*res;
}
int n,m;
int main(){
	n=read();m=read();
	if(n>m) swap(n,m);
	if(n==1){
		cout<<(m==1?1:m-2)<<endl;
	}else{
		cout<<1ll*(n-2)*(m-2)<<endl;
	}
}

Measured memory_bytes: 256
class ConversionTable
  def initialize
    @data = {}
  end

  def set_data src_char, dest_char
    @data[src_char] = dest_char
  end

  def conversion char
    if @data[char].nil?
      return char
    end

    @data[char]
  end
end

def make_conversion_table data_num
  conversion_table = ConversionTable.new

  data_num.times do
    src_char,dest_char = gets.chomp.split(' ')
    conversion_table.set_data(src_char, dest_char)
  end

  conversion_table
end

def answer_string conversion_table, str_length
  answer_str = ''

  str_length.times do
    input_char = gets.chomp
    answer_str << conversion_table.conversion(input_char)
  end

  answer_str
end

answers = []

loop do
  data_num = gets.chomp.to_i
  break if data_num == 0
  table = make_conversion_table(data_num)

  str_length = gets.chomp.to_i
  answers << answer_string(table, str_length)
end

answers.each do |str|
  puts str
end

Measured memory_bytes: 6224
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int h1, m1, h2, m2, k;
  std::cin >> h1 >> m1 >> h2 >> m2 >> k;
  int t1 = h1 * 60 + m1;
  int t2 = h2 * 60 + m2;
  std::cout << (t2 - t1 - k) << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n;
vector<int> a,b;
bool gao(){
	if(n==2)return true;
	sort(a.begin(),a.end(),greater<int>());
	if(a[0]!=a[1])return false;
	if(a[n-1]!=(a[0]+1)/2)
		return false;
	b.assign(n+1,0);
	for(int i=0;i<a.size();i++)
		b[a[i]]++;
	if((a[0]%2==0)and b[a[n-1]]!=1)
		return false;
	if(a[0]&1 and b[a[n-1]]!=2)
		return false;
	for(int i=a[n-1]+(a[0]%2==0);i<=a[0];i++)
		if(b[i]<2)return false;
	return true;
}
int main(){
	n=read();
	a.resize(n);
	for(int i=0;i<n;i++)
		a[i]=read();
	if(gao())puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
use std::io::{self, Read};

fn main() {
    let mut input = "".to_owned();
    io::stdin().read_to_string(&mut input).unwrap();
    let mut input = input.split_whitespace();
    macro_rules! read {
        ([$tt:tt]) => (read!([$tt; read!(usize)]));
        ([$tt:tt; $n:expr]) => ((0..$n).map(|_| read!($tt)).collect::<Vec<_>>());
        (($($tt:tt),+)) => (($(read!($tt)),*));
        ($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap());
    }

    let (n, m, c) = read!((usize, usize, i32));
    let (b, a) = read!(([i32; m], [[i32; m]; n]));

    let ans = a
        .into_iter()
        .filter(|a| a.iter().zip(&b).map(|(a, b)| a * b).sum::<i32>() + c > 0)
        .count();
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int ans = 0;
        for (int i = 0; i < S.length()/2; i++) {
            int a = S.charAt(i);
            int b = S.charAt(S.length()-1-i);
            if (a != b) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

class Team{
public:
	char name;
	int win;
	int lost;
	int number;

	bool operator>( const Team& lhs ) const{
		if( win > lhs.win ){
			return true;
		}else if( win < lhs.win ){
			return false;
		} else if( win == lhs.win ){
			if( lost > lhs.lost ){
				return false;
			} else if( lost < lhs.lost ) {
				return true;
			}
		}
		if( number < lhs.number ){
			return true;
		} else {
			return false;
		}
	}

	bool operator<( const Team& lhs ) const{
		if( win < lhs.win ){
			return true;
		}else if( win > lhs.win ){
			return false;
		} else if( win == lhs.win ){
			if( lost < lhs.lost ){
				return false;
			} else if( lost > lhs.lost ) {
				return true;
			}
		}
		if( number > lhs.number ){
			return true;
		} else {
			return false;
		}
	}
};

int main(void)
{
	Team team[11];
	int n;
	int input_data[11];
	char input_name;

	while( cin >> n && n != 0 ){
		for( int i = 0;i < 11;i++ ){
			team[i].win = team[i].lost = team[i].name = team[i].number = 0;
		}

		for( int i = 0;i < n;i++ ){
			cin >> input_name;
			for( int j = 0;j < n - 1;j++ ){
				cin >> input_data[j];
				if( input_data[j] == 0 ) team[i].win++;
				else if( input_data[j] == 1 ) team[i].lost++;
			}

			team[i].name = input_name;
			team[i].number = i;
			
		}

		stable_sort( team, team + n, greater<Team>() );

		for( int i = 0;i < n;i++ ) cout << team[i].name << endl;


	}
	
	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int h, w; cin >> h >> w;
  char c = 'A';
  string s[w][h];
  int ansx, ansy;
  for(int y = 0; y < h; y++) {
    for(int x = 0; x < w; x++) {
      cin >> s[x][y];
      if(s[x][y] == "snuke") {
        ansx = x;
        ansy = y+1;
      }
    }
  }
  printf("%c%d\n", c+ansx, ansy);

  return 0;
}

Measured memory_bytes: 256
// _/\\\\____________/\\\\______/\\\\\\\\\______/\\\________/\\\___/\\\\\\\\/\\____/\\\\\\\\\\_|
//  _\/\\\\\\________/\\\\\\____/\\\\\\\\\\\\\___\/\\\________/\\\__\/\\\____\/\\\__\////\\\///__|
//   _\/\\\//\\\____/\\\//\\\___/\\\/////////\\\__\/\\\________/\\\__\/\\\____\/\\\\____\/\\\_____|
//    _\/\\\\///\\\/\\\/_\/\\\__\/\\\_______\/\\\__\/\\\\\\\\\\\\\\\__\/\\\____\/\\\\____\/\\\_____|
//     _\/\\\__\///\\\/___\/\\\__\/\\\\\\\\\\\\\\\__\/\\\/////////\\\__\/\\\____\/\\\\____\/\\\_____|
//      _\/\\\____\///_____\/\\\__\/\\\/////////\\\__\/\\\_______\/\\\__\/\\\____\/\\\_____\/\\\_____|
//       _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\___/\\\\______\/\\\_____|
//        _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\\\\/\\_____/\\\\\\\\\\__|
//         _\///______________\///___\///________\///___\///________\///___\/////////_____\//////////___|
#include<bits/stdc++.h>
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< long long > vl;
typedef vector< pair <int,int> > vpi;
#define hurry ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define setp setprecision
#define pop pop_back()
#define pb push_back
#define mp make_pair
#define beg begin()
#define sc second
#define sz size()
#define fr first
#define endl '\n'
//=======================================================================================================================
//global
int dp[3003][3002];
pair <int,int> par[3008][3009];
vc v;
//=======================================================================================================================
//functions
void lcs (str s,str t)
{
    for(int i=1;i<=s.sz;i++)
    {
        for(int j=1;j<=t.sz;j++)
        {
            if(s[i - 1]==t[j - 1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
                par[i][j].fr=i-1;
                par[i][j].sc=j-1;
            }
            else
            {
                if(dp[i-1][j]>=dp[i][j-1])
                {
                    dp[i][j]=dp[i-1][j];
                    par[i][j].fr=i-1;
                    par[i][j].sc=j;
                }
                else
                {
                    dp[i][j]=dp[i][j-1];
                    par[i][j].fr=i;
                    par[i][j].sc=j-1;
                }
            }
        }
    }
}
//=======================================================================================================================
int main()
{
    str s,t;
    cin>>s>>t;
    lcs(s,t);
    int n=s.sz;
    int m=t.sz;
    while(n>0 and m>0)
    {
        if(par[n][m].fr==n-1 and par[n][m].sc==m-1)
            v.pb(s[n - 1]);
        pair<int, int> tmp = par[n][m];
        n=tmp.fr;
        m=tmp.sc;
    }
    for(int i=v.sz-1;i>=0;i--)
    {
        cout<<v[i];
    }
}
//========================================================================================================================
//4
//1 4 2 3
//4 1 2 3
//1 2 4 3


Measured memory_bytes: 106112
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


std::vector<long long> a;


void dfs(int i, long long j)
{
  if (i == 0) {
    a.push_back(j);
  }
  else {
    for (int k = std::max<int>(j % 10 - 1, 0); k <= std::min<int>(j % 10 + 1, 9); k ++)
      dfs(i - 1, j * 10 + k);
  }
}


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int K;

  std::cin >> K;

  for (int i = 0; i < 10; i ++)
    for (int j = 1; j <= 9; j ++)
      dfs(i, j);

  std::cout << a[K - 1] << std::endl;
  
  return 0;
}


Measured memory_bytes: 3444
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc= new Scanner(System.in);
        String text = sc.nextLine();
        text+=text;
        String pat = sc.nextLine();
         if (text.contains(pat)) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

int main() {
    int K;
    string S;
    cin >> K >> S;
    if(S.size() <= K) {
        cout << S << endl;
    }
    else {
        cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}


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


using namespace std;


int N,M;

vector<int> A;


int main()
{

	cin >> N;
	cin >> M;

	A = vector<int>(N);

	int sum = 0;
	for (int i = 0;i<N; i++) {
		cin >> A[i];

		sum += A[i];
	}

	int b = (sum - 1) / (4 * M);
	
	int m = 0;

	for (int i = 0; i < N && m < M; i++) {

		if (A[i] > b) {
			m++;
		}
	}
	

	cout << (m>=M ? "Yes" : "No" ) << endl;
	return 0;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int h,w;cin >>h>>w;
    vector<string>s(h);
    for (int i = 0; i < h; ++i) {
        cin >>s[i];
    }
    string k(w+2,'#');
    cout <<k<<endl;
    for (int i = 0; i < h; ++i) {
        cout <<'#'<<s[i]<<'#'<<endl;
    }
    cout <<k<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>

using namespace std;

int main(){
    string word,str;
    int count=0;
    cin >> word;
  
    for(int i=0,l=word.size();i<l;i++)
        if('A'<=word[i] && word[i]<='Z'){
            word[i]+=('a'-'A');
        }
    while(cin >> str){
        if(str=="END_OF_TEXT"){
            break;
        }
        
        for(int i=0,l=str.size();i<l;i++){
            if('A'<=str[i] && str[i]<='Z'){
                str[i]+=('a'-'A');
            }
        }
            
        if(word==str){
            count++;  
        } 
    }
  
    cout << count << endl;
    return 0;

}


Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;
int ans;
long long N;
bool check753(long long n) {
	int th = false;
	int fi = false;
	int se = false;
	while (n != 0) {
		if (3 == n%10) {
			th = true;
		}
		if (5 == n%10) {
			fi = true;
		}
		if (7 == n%10) {
			se = true;
		}
		n /= 10;
	}
	if (th && fi && se) {
		return true;
	}
	return false;
}
void dfs(long long v) {
	if (N < v) {
		return;
	}
	if (check753(v)) {
		ans++;
	}
	dfs(10 * v + 7); 
	dfs(10 * v + 5); 
	dfs(10 * v + 3);
}

int main() {
	cin >> N;
	ans = 0;
	dfs(0);
	cout << ans <<  endl;
	return 0;
}

Measured memory_bytes: 3636
INPUT = list(map(int, input().split()))

N = INPUT.pop(3)
INPUT.sort()

res = 0
for i in range(N//INPUT[2]+1):
    remainder_1 = N-INPUT[2]*i
    for j in range(remainder_1//INPUT[1]+1):
        remainder_2 = remainder_1-INPUT[1]*j
        if remainder_2%INPUT[0] == 0:
            res += 1

print(res)

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

int main(){
	int n;
	cin >> n;
	vector<tuple<string, int, int>> a;

	for(int i = 1; i <= n; i++){
		string s;
		int p;
		cin >> s >> p;
		p *= -1;
		a.emplace_back(tie(s,p,i));
	}

	sort(a.begin(), a.end());

	for(int i = 0; i < n; i++){
		string s;
		int p, id;
		tie(s, p, id) = a.at(i);
		cout << id << endl;
	}

	return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    if(s.size()!=t.size()){
        cout<<"No"<<endl;
        return 0;
    }
    vector<int> v[30];
    for(int i=0;i<s.size();i++){
        v[s[i]-'a'].push_back(i);
    }
    for(int i=0;i<'z'-'a';i++){
        if(v[i].size()==0)continue;
        for(int j=i+1;j<='z'-'a';j++){
            if(v[j].size()==0)continue;
            if(t[v[i][0]]==t[v[j][0]]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    for(int i=0;i<='z'-'a';i++){
        if(v[i].size()==0)continue;
        char c=t[v[i][0]];
        for(int j=1;j<v[i].size();j++){
            if(c!=t[v[i][j]]){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 1800
def char(n, h):
    tbl = ['#', '.']

    if h % 2 == 1:
        tbl = ['.', '#']

    if n % 2 == 0:
        return tbl[0]
    else:
        return tbl[1]


while True:
    h, w = map(int, input().split())

    if h == 0 and w == 0:
        break

    for i in range(h):
        print(''.join([char(n, i) for n in range(w)]))

    print()

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

int main(){
    int h,w;
    cin>>h>>w;
    int a[h][w];
    int coin=0;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        cin>>a[i][j];
    }
    int n=0;
    vector<pair<int,int>> b,af;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        if(a[i][j]%2){
            if(i==h-1 && j==w-1) break;
            n++;
            b.push_back(make_pair(i,j));
            a[i][j]--;
            if(j==w-1){
                a[i+1][j]++;
                af.push_back(make_pair(i+1,j));
            }
            else {
                a[i][j+1]++;
                af.push_back(make_pair(i,j+1));
            }
        }
    }

    cout<<n<<endl;
    for(int i=0;i<n;i++){
        cout<<b[i].first+1<<" "<<b[i].second+1<<" "<<af[i].first+1<<" "<<af[i].second+1<<endl;
    }





}

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

using namespace std;
#define sc(x) scanf("%lld", &x);
#define pr(x) printf("%lld\n", x);
typedef long long ll;
typedef pair<ll, ll> P;

ll n;

int main()
{
    cin>>n;
    if(n%2 == 0) cout<<n<<"\n";
    else cout<<n*2<<"\n";
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

import itertools

li = [i for i in range(1,n+1)]
li2 = list(itertools.permutations(li))

cnt = 0
for i in li2:
    cnt +=1
    if i == p:
        a = cnt
    if i == q:
        b = cnt

print(abs(a-b))

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

int N, Q;
ll A[112345], sum[112345], ans[112345];
int X[112345];

int main() {
	cin >> N >> Q;
	REP(i, N) scanf("%lld", A + i);
	REP(i, Q) scanf("%d", X + i);
	
	sum[0] = A[0];
	sum[1] = A[1];
	FOR(i, 2, N) sum[i] = A[i] + sum[i - 2];
	
	vector<pii> v;
	REP(i, Q) v.push_back(pii(X[i], i));
	sort(ALL(v));
	
	int x = (N + 1) / 2;
	ll cur = 0;
	REP(i, x) cur += A[N - i - 1];
	
	for (pii query : v) {
		int q = query.fi;
		
		int idx = lower_bound(A, A + N, q) - A; // 初めに青木くんが取るカード
		if (idx > 0 && abs(A[idx] - q) >= abs(A[idx - 1] - q)) idx--;
		
		while (x > 0) {
			bool ok = true;
			int l = max(N - 2 * x, 0); // [l, r) : Aoki
			int r = N - x; // [r, N) : Takahashi
			
			if (l > idx || r <= idx) ok = false;
			
			if (2 * x - 1 == N) {
				if (abs(A[l] - q) > abs(A[r] - q)) ok = false;
			}
			else {
				if (abs(A[l + 1] - q) > abs(A[r] - q)) ok = false;
				if (l > 1 && abs(A[l - 1] - q) <= abs(A[r - 1] - q)) ok = false;
			}
			if (ok) break;
			
			cur -= A[N - x];
			x--;
		}
		if (2 * x - 1 == N) ans[query.se] = cur;
		else ans[query.se] = cur + sum[N - 2 * x - 1];
	}
	
	REP(i, Q) printf("%lld\n", ans[i]);
	
	return 0;
}


Measured memory_bytes: 5364
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll n,m;
ll temp[10000],*dp=temp+3000;
ll a[99];
int main(){
	scanf("%lld%lld",&n,&m);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n)a[i]-=m;
	dp[0]=1;
	rep(i,0,n){
		if(a[i]<=0)rep(j,-2800,2800)dp[j+a[i]]+=dp[j];
		else for(ll j=2800;j>-280;j--)dp[j+a[i]]+=dp[j];
	}
	printf("%lld\n",dp[0]-1);
}

Measured memory_bytes: 256
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define INF			100000000000
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

ll n;
ll a[N],b[N],c[N];
ll dp[N][3];


ll solve(ll pos, ll act){
	// cerr<<pos<<" "<<act<<endl;
	if(dp[pos][act]!=-1)return dp[pos][act];
	ll ans=-INF;
	if(pos==0){
		ans=0;
	}
	else{
		rep(i,0,3){
			if(i==act)continue;
			ans=max(ans,solve(pos-1,i));
		}
	}
	if(act==0)ans+=a[pos];
	if(act==1)ans+=b[pos];
	if(act==2)ans+=c[pos];
	return dp[pos][act]=ans;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	rep(i,0,N)rep(j,0,3)dp[i][j]=-1;
	while(TESTS--)
	{
		cin>>n;
		rep(i,0,n){
			cin>>a[i]>>b[i]>>c[i];
		}
		cout<<max(solve(n-1,0),max(solve(n-1,1),solve(n-1,2)))<<endl;

	}
	return 0;
}

Measured memory_bytes: 12968
#include<stdio.h>
#include<string.h>
#define STRINGLENGTH 1001
int main (void){
    int a,b,q;
    char sentence[STRINGLENGTH];
    char str[STRINGLENGTH];
    scanf("%s",str);
    scanf("%d",&q);

    for (int i = 0; i < q; i++)
    {
        char order[8]={0};
        scanf("%s",order);
        if(strstr(order,"replace") != NULL ){
            scanf("%d %d %s",&a,&b,sentence);
            for (int i = a, j=0; i <=b ; i++,j++){
                str[i] = sentence[j];
            }   
        }
        if(strstr(order,"print") != NULL ){
            scanf("%d %d",&a,&b);
            for (int i = a; i <= b; i++){
                printf("%c",str[i]);
            }
            printf("\n");
        }
        if(strstr(order,"reverse") != NULL ){
            scanf("%d %d",&a,&b);
            char hoge;
            for (int i = a,j = 0; j <=(b-a)/2 ; i++,j++){
                hoge = str[i];
                str[i] = str [b-j];
                str [b-j] = hoge;
            }
        }        

    }
    return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
vector<LL> make_divisors(LL n){vector<LL> divisors;for(int i = 1; i <= sqrt(n); i++) {if(n%i == 0){divisors.push_back(i);if(i != n/i){divisors.push_back(n / i);}}}return divisors;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

int main(void){
    int A,B;
    cin >> A >> B;

    cout << max(0, A - 2 * B) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] f = new int[9];
		for(int i=0; i<N; i++) {
			int temp = sc.nextInt();
			if(temp<400) {
				f[0]++;
			} else if(temp < 800) {
				f[1]++;
			} else if(temp < 1200) {
				f[2]++;
			} else if(temp < 1600) {
				f[3]++;
			} else if(temp < 2000) {
				f[4]++;
			} else if(temp < 2400) {
				f[5]++;
			} else if(temp < 2800) {
				f[6]++;
			} else if(temp < 3200) {
				f[7]++;
			} else {
				f[8]++;
			}
		}
		sc.close();
		int mincolor = 0;
		for(int i=0; i<8; i++) {
			if(f[i]!=0) mincolor++;
		}
		if(mincolor !=0) {
			System.out.println(mincolor + " " + (mincolor+f[8]));			
		} else {
			System.out.println((mincolor+1) + " " + (mincolor+f[8]));
		}

	}

}


Measured memory_bytes: 21840
import java.util.*;

public class Main{

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        int[][] a = new int[2][N];
        int[][] c = new int[2][M];
        for(int i = 0; i < N; i++){
            a[0][i] = sc.nextInt();
            a[1][i] = sc.nextInt();
        }
        for(int i = 0; i < M; i++){
            c[0][i] = sc.nextInt();
            c[1][i] = sc.nextInt();
        }
        sc.close();

        for(int i = 0; i < N; i++){
            int min = Math.abs(a[0][i] - c[0][0]) + Math.abs(a[1][i] - c[1][0]);
            int index = 0;
            for(int j = 1; j < M; j++){
                if(min > Math.abs(a[0][i] - c[0][j]) + Math.abs(a[1][i] - c[1][j])){
                    min = Math.abs(a[0][i] - c[0][j]) + Math.abs(a[1][i] - c[1][j]);
                    index = j;
                }
            }
            System.out.println(index+1);
        }
    }
}

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

using namespace std;

using ll = long long;

//1-indexであることに注意
template <typename T>
struct BIT {
    int n;
    vector<T> data;

    BIT(int n) : n(n), data(n + 1, 0) {}

    T sum(int i) {
        T s = 0;
        while (i > 0) {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, T x) {
        while (i <= n) {
            data[i] += x;
            i += i & -i;
        }
    }
};

ll solve(int x, vector<int>& a) {
    int n = a.size();
    vector<int> b(n + 1, 0);
    for (int i = 0; i < n; i++) {
        b[i + 1] = (a[i] >= x ? 1 : -1);
        b[i + 1] += b[i];
        b[i] += n;
    }
    b[n] += n;

    BIT<ll> bt(2 * n + 1);
    bt.add(b[0], 1);
    ll res = 0;
    for (int i = 1; i <= n; i++) {
        res += bt.sum(b[i]);
        bt.add(b[i], 1);
    }
    return res;
}

//引数unzipには圧縮前のvectorを入れる
int compress(vector<int>& unzip, map<int, int>& zip) {
    sort(unzip.begin(), unzip.end());
    unzip.erase(unique(unzip.begin(), unzip.end()), unzip.end());
    for (int i = 0; i < unzip.size(); i++) {
        zip[unzip[i]] = i;
    }
    return unzip.size();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll lim = ((ll)(n + 1) * n / 2 + 1) / 2;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
   
    vector<int> a2(a);
    map<int, int> dummy;

    int ok = 0, ng = compress(a2, dummy);
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        if (solve(a2[mid], a) >= lim) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << a2[ok] << endl;
    return 0;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
double m=(double)n;
if(n%2==0){
    cout<<(m/2)/m<<endl;
}
else{
    cout<<((m+1)/2)/n<<endl;
}
}


Measured memory_bytes: 256