akhauriyash/Code-Regression huggingface dataset:
/*
        FFFFFFFFFFFFFFFFFFFFFF
        F::::::::::::::::::::F
        F::::::::::::::::::::F
        FF::::::FFFFFFFFF::::F
          F:::::F       FFFFFF
          F:::::F
          F::::::FFFFFFFFFF
          F:::::::::::::::F
          F:::::::::::::::F
          F::::::FFFFFFFFFF
          F:::::F
          F:::::F
        FF:::::::FF
        F::::::::FF
        F::::::::FF
        FFFFFFFFFFF
*/
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007 //998244353
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(i,n) for(ll i=0;i<n;i++)
#define nl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define cout1(a) cout<<a<<nl
#define cout2(a,b) cout<<a<<" "<<b<<nl
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<nl
#define cout4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<nl
#define vcout(v,i) cout<<v[i].fi<<" "<<v[i].se<<nl
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define ms(v,n) memset((v),n,sizeof(v));
#define ii pair<ll,ll>
#define mll map<ll,ll>
#define sll set<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define maxi(a,b,c) max(a,max(b,c))
#define maxii(a,b,c,d) max(max(a,b),max(c,d))
#define mini(a,b,c) min(a,min(b,c))
#define md(a,b)  ((a%mod)*(b%mod)+mod)%mod 
#define inf 9e18
#define cases ll T;cin>>T;while(T--)
#define BLOCK 500
//const double PI = 3.141592653589793238460;
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T> T add(T &a, T b){ return (a+=b)%=mod; }
template<typename T> T sub(T &a, T b){ (a-=b); if(a<0) a+=mod; }
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
const int N=1e5+5;

int32_t main()
{
    
	fast
	
	vector<ii> vec;
	int cnt[3]={0,0,0};
	int lim[2]={0,0};
	cin>>lim[0]>>lim[1]>>cnt[0]>>cnt[1]>>cnt[2];
	for(int z=0;z<3;z++)
	{
		for(int j=0;j<cnt[z];j++)
		{
			ll x; cin>>x;
			vec.pb({x,z});
		}
	}
	sort(vec.rbegin(),vec.rend());
	ll ans=0;
	ll apples=lim[0]+lim[1];
	for(int i=0;i<vec.size();i++)
	{
		int ty=vec[i].se;
		if(apples<=0) break;
		if(ty<=1)
		{
			if(lim[ty]<=0) continue;
			lim[ty]--;
			ans+=vec[i].fi;
			apples--;
		}
		else
		{
			apples--;
			ans+=vec[i].fi;
		}
	}
	cout<<ans<<'\n';    

	return 0;
    
}

Measured memory_bytes: 10604
@num = 1
while gets do
  w = $_.to_i
  break if w == 0
  n = gets.to_i
  arr = n.times.map{ gets.split(',').map(&:to_i) }

  dp = Array.new(n+1){ Array.new(w+1) }
  dp[0][0] = 0

  mw, mv = w, 0
  arr.each.with_index do |ai, i|
    (0..w).reject{ |wi| dp[i][wi].nil? }.each do |wi|
      t = dp[i+1][wi] = [dp[i][wi], dp[i+1][wi]||0].max
      mw, mv = wi, t if mv < t || (mv == t && mw >= wi)

      if wi+ai[1] <= w
        t = dp[i+1][wi+ai[1]] = [dp[i][wi]+ai[0], dp[i+1][wi+ai[1]]||0].max
        mw, mv = wi+ai[1], t if mv < t || (mv == t && mw >= wi+ai[1])
      end
    end
  end
  puts "Case #{@num}:", mv, mw
  @num +=1
end

Measured memory_bytes: 14144
#include <iostream>
#include <string.h>

using namespace std;

void solve()
{
	
	int n;
	cin >> n;
    for(int i = 0; i < n; ++i)
	{
        int gx, gy, p;
        bool stage[16][16][16][16];
        memset(stage,-1,sizeof(stage));
        cin >> gx >> gy >> p;
        for(int j = 0; j < p; ++j)
		{
            int x1,y1,x2,y2;
			cin >> x1 >> y1 >> x2 >> y2;
            stage[x1][y1][x2][y2] = false;
            stage[x2][y2][x1][y1] = false;
        }
        int dp[17][17];
        memset(dp, 0, sizeof(dp));
        dp[0][0] = 1;
        dp[1][1] = 1;
        for(int y = 0; y <= gy; ++y)
		{
            for(int x = 0; x <= gx; ++x)
			{
                if(x == 0 && y == 0) continue;
                if(x > 0 && stage[x - 1][y][x][y])
				{
                    dp[y + 1][x + 1] += dp[y + 1][x];
                }
                if(y > 0 && stage[x][y - 1][x][y])
				{
                    dp[y + 1][x + 1] += dp[y][x + 1];
                }
            }
        }
		if(dp[gy + 1][gx + 1] == 0)
		{
			cout << "Miserable Hokusai!" << endl;
        }
        else
		{
			cout << dp[gy + 1][gx + 1] << endl;
        }
    }
}

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

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

int main(){

  string s;
  int n;

  while(cin>>s){
    for(int i=0; i<(int)s.size(); i++){
      if(s[i]!='@')cout << s[i];
      else{
	i++;
	n = s[i]-'0';
	i++;
	for(int j=0; j<n; j++)cout<<s[i];
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  int N; cin >>N;

  int ans=pow(10,9);
  rep(i,0,N) {
    int A; cin >>A;
    int temp=0;
    while (A%2==0) {
      A/=2;
      temp++;
    }
    chmin(ans,temp);
  }

  cout <<ans <<'\n';
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/integer/common_factor_ct.hpp>
using namespace std;

int main(int argc, const char * argv[]) {
    int N, X; cin >> N >> X;
    vector<int> x(N);
    
    for (int i = 0; i < N; i++) {
        int inp; cin >> inp;
        x[i] = inp;
    }
    
    if (N == 1) {
        cout << abs(x[0] - X) << endl;
        return 0;
    }
    
    int gcdResult = boost::integer::gcd(abs(X - x[0]), abs(X - x[1]));
    for (int i = 2; i < N; i++) {
        gcdResult = boost::integer::gcd(gcdResult, abs(X - x[i]));
    }
    
    cout << gcdResult << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int x,a[100000],n,my[100003],mymax,ans;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[n];
		if(a[n]==0){
			my[100002]++;
			my[0]++;
			my[1]++;
		}
		else {
		my[a[n]]++;
		my[a[n]-1]++;
		my[a[n]+1]++;
		}
	}
	for(int i=0;i<=100001;i++){
		if(ans<my[i]) {
			mymax=i;
			ans=my[i];
		}	
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll n, m, q;
    cin >> n >> m >> q;

    vll a(q), b(q), c(q), d(q);
    REP(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    
    ll res = 0, na = n + m - 2;
    REP(bi, 1LL << na) {
        vll v(n, 1);
        ll id = 1;
        REP(i, na) {
            if ((bi >> i) & 1) {
                v[id]++;
                if (v[id] == m) {
                    for (int x = id; x < n; x++) v[x] = m;
                    break;
                }
            }
            else {
                v[id + 1] = v[id];
                id++;
                if (id == n) break;
            }
        }
        ll mem = 0;
        REP(i, q) {
            if (v[b[i]] - v[a[i]] == c[i]) mem += d[i];
        }
        chmax(res, mem);
    }
    cout << res << endl;
    return 0;
}

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

long long n,a[100005],sd[100005];
unordered_multiset<long long> s;

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

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
    }

    sd[0]=1;
    for(int i=1;i<100005;i++)
        sd[i]=(sd[i-1]*2)%1000000007;
    if(n%2==0)
    {
        for(int i=1;i<n;i+=2)
            if(s.count(i)!=2)
            {
                cout<<0<<endl;
                return 0;
            }
        cout<<sd[n/2]<<endl;
        return 0;
    }
    else
    {
        if(s.count(0)!=1)
        {
            cout<<0<<endl;
            return 0;
        }
        for(int i=2;i<n;i+=2)
            if(s.count(i)!=2)
            {
                cout<<0<<endl;
                return 0;
            }
        cout<<sd[n/2]<<endl;
        return 0;
    }
}


Measured memory_bytes: 8804
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<string> A(N);
  cin>>A;

  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  Int ans = A.size();
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9536
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy";
    else if (s == "Cloudy") cout << "Rainy";
    else cout << "Sunny";



}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R;
    cin >> R;
    cout << 3 * R * R << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int items[3300][3300];
int dp[3001][3001][4];
const int INF = 1e18;
int h,w;
int dfs(int x,int y,int num){
	//x,yにいて、x行目でnumこ使った
	if((x == 0 && y == -1)||(x == -1 && y == 0)){
		if(num>=0)return 0;
		return -INF;
	}
	if(x < 0 || y < 0 || x > h-1|| y > w-1 || num < 0)return -INF;
	if(dp[x][y][num] != -1)return dp[x][y][num];
	int ret = -INF;
	//何も使わず上から
	if(num == 0){
		rep(i,4)ret = max(ret,dfs(x-1,y,i));
	}
	
	//何も使わず左から
	ret = max(ret,dfs(x,y-1,num));
	//使って上から
	if(items[x][y] && num == 1){
		rep(i,4)ret = max(ret,dfs(x-1,y,i)+ items[x][y]);
	}
	//使って左から
	if(items[x][y])ret = max(ret,dfs(x,y-1,num-1) + items[x][y]);
	return dp[x][y][num] = ret;
	
}
signed main(){
	int k;cin >> h >>w >> k;
	rep(i,3001)rep(j,3001)rep(k,4)dp[i][j][k] = -1;
	rep(i,k){
		int a,b,c;cin >> a >> b >> c;
		a--;b--;
		items[a][b] = c;
	}
	int ret = 0;
	rep(i,4){
		// trace(ret);
		ret = max(ret,dfs(h-1,w-1,i));
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 362744
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n,k = mi()
    r,s,p = mi()
    tmp = list(input())
    t = [0]
    t+=tmp

    ans = 0

    for i in range(1,n+1):
        if t[max(0,i-k)] == t[i]:
            t[i] = 0
            continue
        if t[i] == 'r':
            ans+=p
        elif t[i] == 'p':
            ans+=s
        else:
            ans+=r

    print(ans)



    


    
main()


Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N, L;

	cin >> N >> L;
	int sum = 0, mn = L;
	int a;

	for (int i = 0; i < N; i++)
	{
		a = L + i;
		sum += a;
		if (abs(a) < abs(mn))
			mn = a;
	}
	sum -= mn;
	cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n;
    cin >> n;

    ll ans = 0;
    for(ll i = 1; i <= n; i+=2){
        ll count = 0;
        for(ll j = 1; j <= i; j++){
            if(i % j == 0){
                count++;
            }
        }
        if(count == 8) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define int ll

using namespace std;

const ll N = 3e5+100;
ll MOD = 1e9+7;

long long  modPow(long long a, long long x, long long p) {
    //calculates a^x mod p in logarithmic time.
    long long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

ll modInverse(long long a, long long p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}
ll modBinomial(long long n, long long k, long long p) {
// calculates C(n,k) mod p (assuming p is prime).

   ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}

signed main()
{

    ll n;
    cin>>n;ll a,b;cin>>a>>b;
    ll ans = modPow(2LL,n,MOD);ans--;
    ans%=MOD;
    ans -= modBinomial(n,a,MOD);
    if(ans < 0) ans += MOD;
    
    ans -= modBinomial(n,b,MOD);
    if(ans < 0) ans += MOD;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
MOD = 10**9+7
n = int(input())
dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
dp[0][0] = 1
for i in range(1, n+1):
	s = input()
	for j in range(n+1):
		if s == "U":
			if j > 0:
				dp[i][j] += dp[i-1][j-1]
			dp[i][j] += j * dp[i-1][j]
		elif s == "-":
			dp[i][j] += dp[i-1][j]
		else:
			if j < n:
				dp[i][j] += (j+1) * (j+1) * dp[i-1][j+1]
			dp[i][j] += j * dp[i-1][j]
		dp[i][j] %= MOD
print(dp[n][0])


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

using namespace std;

int A[20][20];

int main(){
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B;
    int sub;
    for(int i = 0; i < M; i++){
        cin >> sub;
        B.push_back(sub);
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    
    int cnt = 0;
    for(int i = 0; i < N; i++){
        int sum = 0;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        
        sum += C;
        if(sum > 0)     cnt++;
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 998244353

class ModTools:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        inverse = [1] * MAX
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, -1, -1):
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせの数 """

        if n < r: return 0
        r = min(r, n-r)
        numerator = self.fact[n]
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

N, M, K = MAP()

mt = ModTools(N, MOD)
ans = 0
for k in range(K+1):
    ans += M * pow(M-1, N-k-1, MOD) * mt.nCr(N-1, k)
    ans %= MOD
print(ans)


Measured memory_bytes: 77424
#include<stdio.h>
 
main(){
 
 
int a,b;
 
 
double c;
 
 
scanf("%d %d",&a,&b);
 
 
c=(double)a/b;
 
 
printf("%d %d %f\n",a/b,a%b,c);
 
 
return 0;
 
 
}

Measured memory_bytes: 636
INF = 5000
$h = 0
$w = 0

def bfs(bord,a)
	walks = [[1,0],[-1,0],[0,1],[0,-1]]
	step = bord[a[0]][a[1]]
	newpos = []
	walks.each{|ws|
		newpos[0] = a[0] + ws[0]
		newpos[1] = a[1] + ws[1]
		if newpos[0].between?(0,$h-1) and newpos[1].between?(0,$w-1) then
			if bord[newpos[0]][newpos[1]] > (step+1) then
				bord[newpos[0]][newpos[1]] = step + 1
				bfs(bord,newpos)
			end
		end
	}
end

loop{
	str = gets.split.map(&:to_i)
    if str.size != 2
        next
    end
    $h,$w = str[0],str[1]

	if ($h == 0 and $w == 0) then
		exit
	end
	a = [0,0]
	b = [0,0]
	bord = Array.new($h).map{Array.new($w,0)}

	$h.times{|y|	
		bord[y] = gets.chomp.split(//).map.with_index{|c,i|
			case c
			when "A" then
				a[0] = y
				a[1] = i
				0
			when "B" then
				b[0] = y
				b[1] = i
				INF
			when "." then
				INF
			else
				-1
			end
		}
	}
	bfs(bord,a)
	pat = gets.chomp
	bstep = 0
	flag = 0
	loop{
		pat.each_char{|ch|
			bstep += 1
			case ch
			when "2" then
				b[0] += b[0] < $h-1 ? 1:0
			when "4" then
				b[1] -= b[1] > 0 ? 1:0
			when "6" then
				b[1] += b[1] < $w-1 ? 1:0
			when "8" then
				b[0] -= b[0] > 0 ? 1:0
			when "5" then
			end
			if bord[b[0]][b[1]] != -1 and bstep >= bord[b[0]][b[1]] then
				print("#{bstep} #{b[0].to_s} #{b[1]}\n")
				flag = 1
				break
			end
		}
		if flag == 1 then
			break;
		end
		if bstep >= 500 then
			print "impossible\n"
			break
		end
	}
}

Measured memory_bytes: 6492
n, q = map(int, input().split())
s = input()
ac = [0] * (n+1)
for i in range(n):
  if s[i:i+2] == "AC":
    ac[i+1] = ac[i] + 1
  else:
    ac[i+1] = ac[i]
for j in range(q):
  l,r = map(int, input().split())
  print(ac[r-1]-ac[l-1])
  

Measured memory_bytes: 6188
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)


//    Edges := 重み付き辺の集合
//    WeightedGraph := 重み付きグラフ
//    UnWeightedGraph := 重み無しグラフ
//    Matrix := 距離行列
template< typename T >
struct edge {
  ll src, to;
  T cost;

  edge(ll to, T cost) : src(-1), to(to), cost(cost) {}

  edge(ll src, ll to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator ll() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< ll > >;
template< typename T >
using Matrix = vector< vector< T > >;


//計算量 ElogV


struct UnionFind {
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(ll x, ll y) {
    return root(x) == root(y);
  }
  int root(ll x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(ll x) {
    return -data[root(x)];
  }
};


template< typename T >
T kruskal(Edges< T > &edges, ll V)
{
  sort(begin(edges), end(edges), [](const edge< T > &a, const edge< T > &b)
  {
    return (a.cost < b.cost);
  });
  UnionFind tree(V);
  T ret = 0;
  for(auto &e : edges) {
    if(tree.unionSet(e.src, e.to)) ret += e.cost;
  }
  return (ret);
}


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

    ll v,e;
    cin>>v>>e;
    Edges<ll> edges;
    FOR(i,0,e){
      ll in1,in2,w;
      cin>>in1>>in2>>w;
      edges.push_back(edge<ll>(in1,in2,w));
    }
    cout<<kruskal<ll>(edges,v)<<endl;

}



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

typedef long long lint;

lint Plus[200010],ans=0;
int Xor[200010],n,a[200010];

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<n;i++){
		Xor[i+1]=Xor[i]^a[i];
		Plus[i+1]=Plus[i]+a[i];
	}
	int end=0;
	for(int start=0;start<n;start++){
		while(end<n){
			lint sum1=Xor[end+1]^Xor[start];
			int sum2=Plus[end+1]-Plus[start];
			if(sum1==sum2) end++;
			else break;
		}
		ans+=end-start;
	}
	printf("%lld",ans);
	return 0;
}

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

char s[105];

int main() {
	scanf("%s", s + 1);
	for (int i = 1; i <= strlen(s + 1); ++i) {
		if (i % 2 == 0 && s[i] == 'R') { puts("No"); return 0; }
		if (i % 2 == 1 && s[i] == 'L') { puts("No"); return 0; }
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <tuple>
#include <vector>
#include <unordered_set>

using lli=long long int;
std::vector<lli> prime_arr;
std::unordered_set<lli> prime_set;

void make_prime_arr(){
  const lli pmax = 100009;
  std::vector<lli> sieve(pmax+1, 1); 
  for(lli i = 2; i <= pmax; i++){
    if(sieve[i] == 0) continue;
    prime_arr.push_back(i);
    prime_set.insert(i);
    lli n = i*i;
    while(n <= pmax){
      sieve[n] = 0;
      n += i;
    }
  }
}

int main(){
  int Q;
  std::cin >> Q;

  make_prime_arr();
  std::vector<lli> l_arr;
  for(auto&& p: prime_arr){
    if((p&1)==1 && prime_set.count((p+1)/2) != 0) l_arr.push_back(p);
  }

  for(int i = 0; i < Q; i++){
    int l,r;
    std::cin >> l >> r;
    int ans = std::distance(std::lower_bound(l_arr.begin(), l_arr.end(), l), std::lower_bound(l_arr.begin(), l_arr.end(), r+1));
    std::cout << ans << "\n";
  }

  return 0;
}



Measured memory_bytes: 1536
#include <stdio.h>

typedef struct {
	int connected;
	int distance[100];
}onesiseki;

int main(void) {
	onesiseki siseki[100];
	int sisekinum;
	int i,j;
	int roadnum;
	int a,b,dist;
	int distancesum;
	int minsiseki,minsisekito,mindist;
	while(1) {
		scanf("%d",&sisekinum);
		if(sisekinum==0)break;
		for(i=0;i<sisekinum;i++) {
			siseki[i].connected=0;
			for(j=0;j<sisekinum;j++)siseki[i].distance[j]=-1;
		}
		scanf("%d",&roadnum);
		for(i=0;i<roadnum;i++) {
			scanf("%d,%d,%d",&a,&b,&dist);
			siseki[a].distance[b]=dist;
			siseki[b].distance[a]=dist;
		}
		siseki[0].connected=1;
		distancesum=0;
		while(1) {
			minsiseki=minsisekito=mindist=-1;
			for(i=0;i<sisekinum;i++) {
				if(siseki[i].connected) {
					for(j=0;j<sisekinum;j++) {
						if(siseki[j].connected==0 && siseki[i].distance[j]>0) {
							if(mindist<0 || siseki[i].distance[j]<mindist) {
								mindist=siseki[i].distance[j];
								minsiseki=i;
								minsisekito=j;
							}
						}
					}
				}
			}
			if(minsiseki==-1)break;
			distancesum+=mindist-100;
			siseki[minsisekito].connected=1;
		}
		printf("%d\n",distancesum/100);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e5 + 10;
vector<int> g[maxn];
int ans[maxn];
int32_t main(){
    int n;
    cin >> n;
    vector<pii> v;
    for (int i = 1;i <= n;i++){
        int a;
        cin >> a;
        v.pb({a,i});
    }
    for (int i = 1;i < n;i++){
        int a,b;
        cin >> a >> b;
        g[a].pb(b);g[b].pb(a);
    }
    sort(v.begin(),v.end());
    vector<vector<int> > c;
    int l = -1;
    for (int i = 0;i < n;i++){
        if (v[i].F != l){
            vector<int> d;
            c.push_back(d);
            c.back().pb(v[i].S);
            l = v[i].F;
        }else {
            c.back().pb(v[i].S);
        }
    }
    int cnt = 0;
    for (auto v1 : c){
        cnt++;
        for (int vert : v1){
        //    cout << vert << ' ' << cnt << endl;
            for (int v : g[vert]){
            //    cout << v << ' ' << vert << ' ' << ans[v] << endl;
                if (ans[v] == -1) ans[vert] = 1;
            }
        }
        for (int vert : v1){
            if (ans[vert] == 0) ans[vert] = -1;
        }
    }
    for (int i = 1;i <= n;i++){
        if (ans[i] == 1) cout << i << ' ';
    }
    cout << endl;
}


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

int main(){
	int N, i, s[4];
	cin >> N;
	for(i=0; i<4; i++){
		s[i]= N-  (N/10)*10;
		N = (N-s[i])/10;
	}
	
	if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3]))	cout << "Yes" << endl;
	else	cout << "No" << endl;
	
	
	return 0;
}


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

int main() {
  int A,B,C,D;
  1 <= A,B,C,D <= 10;
  cin >> A >> B >> C >> D;
  if (A+B > C+D) {
    cout << "Left" << endl;
  } else if (A+B == C+D) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}


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

using namespace std;

int main()
{
  	string S;
  	cin >> S;
  	if(S.front() != 'A'){
      	cout << "WA" << endl;
      	return 0;
    }
  	int Cpos = S.find('C');
  	if(Cpos < 2 || S.size() - 2 < Cpos){
      	cout << "WA" << endl;
      	return 0;
    }
  	for(int i = 1; i < S.size(); ++i){
      	char ch = S[i];
      	if('A' <= ch && ch <= 'Z'){
        	if(i != Cpos){
      			cout << "WA" << endl;
      			return 0;
            }
        }
    }
  	cout << "AC" << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll a,b;
  cin >> a >> b;

  if(a<=0 && 0<=b) {
  cout << "Zero" << endl;
  }
  
  else if(0<a) {
  cout << "Positive" << endl;
  }
  
  else {
    cout << ((b-a)%2==0?"Negative":"Positive") << endl;
  }
  
}

Measured memory_bytes: 256
/**
 *   created: 28 April 2019  23:46:46
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
// #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

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

int main()
{
	optimizeIO();
	int tc=1;
	// cin>>tc;
	for(int tt=0;tt<tc;tt++){
		int v[5];
		rep(i,0,5)
			cin>>v[i];
		int mini = 10,ind=-1;
		rep(i,0,5){
			if(v[i]%10>=1){
				if(v[i]%10<mini){
					mini = v[i]%10;
					ind = i;
				}
			}
		}
		int res=0;
		rep(i,0,5){
			if(i==ind){
				res += 10*(v[i]/10) + v[i]%10;
			}
			else{
				res += 10*(v[i]/10);
				if(v[i]%10!=0)
					res += 10;
			}
		}
		cout<<res;
	}
	return 0;
}




Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        string S = RString();
        int N = S.Length;
        var list = new List<int>();
        int now = 0;
        while (now < N)
        {
            int cnt = 0;
            while (now < N && S[now] == 'B') { cnt++;now++; }
            if(cnt>0)list.Add(cnt);
            cnt = 0;
            while (now < N && S[now] == 'W') { cnt++;now++; }
            if(cnt>0)list.Add(cnt);
        }
        WriteLine(list.Count-1);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 27264
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    sf(a, b);
    if (a <= b * 2) puts("0");
    else cout << a - b * 2 << endl;

    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

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

int main(){
  using ll= long long int;
  ll N,X;
  cin >> N >> X;

  ll ans= 0;
  ll prev,tmp;
  cin >> prev;
  ans+= max(0LL, prev-X);
  prev= min(prev, X);
  for(int i=1; i<N; i++){
    cin >> tmp;
    ans+= max(0LL, prev+ tmp- X);
    prev= min(tmp, X- prev);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int a[(int)1e5+5];
int main ()
{
    int n;
    cin>>n;
    int num;
    for(int i=0;i<n;i++)
    {
        cin>>num;
        a[(num)]++;
    }
    int sum=0;
    int ans=0;
    for(int i=0;i<1e5+2;i++)
    {
        sum+=a[i];
        if(sum==n/2)
            ans++;
        else if(sum>n/2)
            break;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
    int ansu = 0, ansd = 1;
    for (int ai = 0; ai <= f / (100 * a); ai++) {
        for (int bi = 0; bi <= (f - 100 * a * ai) / (100 * b); bi++) {
            for (int ci = 0; ci <= (f - 100*a*ai - 100*b*bi) / c; ci++) {
                for (int di = 0; di <= (f - 100*a*ai - 100*b*bi - c*ci) / d; di++) {
                    if ((ai * a + bi * b) * e < c * ci + d * di) break;
                    int tmpu = c * ci + d * di, tmpd = 100 * a * ai + 100 * b * bi + c * ci + d * di;
                    if (ansu * tmpd < ansd * tmpu) {
                        // cout << tmpu << ' ' << tmpd << '\n';
                        ansu = tmpu, ansd = tmpd;
                    }
                }
            }
        }
    }

    if (ansu == 0) ansd = 100 * min(a, b);
    cout << ansd << ' ' << ansu << '\n';
    return 0;
}


Measured memory_bytes: 256
mod = 10**9+7
n = int(input())
s = input()

# 使っていない個数,ans
from collections import deque
a = deque()
a.append((0,1))
ans = 0
for i,c in enumerate(list(s)):
    if i == 2*n-1:
        for q,w in a:
            ans += w
            ans %= mod
        break
    b = deque()
    while a:
        q,w = a.pop()
        #print(i, q,w)
        # 全部使ってしまっている→今のやつを使うしかない
        if c=="W":
            # 使う
            if q%2==0:
                if q == 0:continue
                w *= q
                w %= mod
                q -= 1
                b.append((q,w))
            else:
                if 2*n-i <= q:continue
                q += 1
                b.append((q,w))
        else:
            if q%2==0:
                if 2*n-i <= q:continue
                q += 1
                b.append((q,w))
            else:
                if q==0:continue
                w *= q
                w %= mod
                q -= 1
                b.append((q,w))
    a = b
a = 1
for i in range(1, n+1):
    a *= i
    a %= mod
ans = ans*a % mod
print(ans)


Measured memory_bytes: 61748
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

tmp=[]
for i in range(x):
    for j in range(y):
        tmp.append(a[i]+b[j])
tmp.sort()
tmp2=[]
for i in range(min(k,x*y)):
    for j in range(z):
        tmp2.append(tmp[-1-i]+c[j])
tmp2.sort()

for i in range(k):
    print(tmp2[-1-i])

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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod(ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit(ll b, ll i) { return b & (1 << i); }
inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
// struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int n, d;
    cin >> n >> d;
    
    int ans = 0;
    rep(i,n){
        int x, y;
        cin >> x >> y;
        if(x*x + y*y <= d*d){
            ans++;
        }
    }
    
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

void solve(ll A, ll B, ll K) {
    if (A-K < 0) {
        ll minus = A-K;
        A = 0;
        B += minus;
        if (B < 0)
            B = 0;
    }
    else
        A -= K;

    cout << A << " " << B;
}

int main() {
    ll A,B,K;
    cin >> A >> B >> K;
    solve(A,B,K);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>


int main (){



int S, S1, S2;


scanf("%d", &S);

S1=S/100;
S2=S%100;

if(S1==0 || S2==0){
if(S1>=1 && S1<=12){
printf("MMYY\n");
}else if(S2>=1 && S2<=12){
printf("YYMM\n");
}else{
printf("NA\n");
}
return 0;
}
if(S1>=1 && 
S1<=12){

if(S2>=1 && S2<=12){
printf("AMBIGUOUS\n");
}else if (S2>=13){
printf("MMYY\n");
}
}

else if(S1>=13){

if(S2>=1 && S2<=12){
printf("YYMM\n");
}else if (S2>=13){
printf("NA\n");
}
}



return 0;

}

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

using namespace std;

int main()
{
    int x, uresisa;
    cin >> x;
    uresisa = int(x / 500) * 1000;
    x %= 500;
    uresisa += int(x / 5) * 5;

    cout << uresisa << endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main() {
    val pw = PrintWriter(System.out)

    val k = readInputLine().toLong()

    var ans = 0L

    for (a in LongRange(1L, k)) {
        for (b in LongRange(1L, k)) {
            for (c in LongRange(1L, k)) {
                ans += gcd(gcd(a, b), c)
            }
        }
    }

    pw.println(ans)

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}

tailrec fun gcd(a: Long, b: Long): Long =
    when {
        b > a -> gcd(b, a)
        b == 0L -> a
        else -> gcd(b, a % b)
    }


Measured memory_bytes: 35220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int H = int.Parse(Console.ReadLine());

            Console.WriteLine((A + B) * H / 2);
        }
    }
}

Measured memory_bytes: 11092
a, b, c = map(int, input().split())
d = (a % 2) + (b % 2) + (c % 2)
m = max(a, b, c)
s = a + b + c
ans1 = (3 * m - s) // 2
ans2 = (3 * (m + 1) - s) // 2
if d == 0 or d == 3:
    ans = ans1
elif d == 1:
    if m % 2 == 1:
        ans = ans1
    else:
        ans = ans2
else:
    if m % 2 == 0:
        ans = ans1
    else:
        ans = ans2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
const ll MAX=100050;
const ll modn=1e9+7;
using namespace std;

void slove(){
    int a;
    cin>>a;
    if(a>=30)
        cout<<"Yes\n";
    else cout<<"No\n";
}

int main() {
    int _;
    //scanf("%d",&_);
    _=1;
    while(_--) {
        slove();
    }
    return 0;
}

Measured memory_bytes: 3628
t=0
N,T=map(int,input().split())
nt=[int(i) for i in input().split()]
ans=0
for i in range(N):
    if nt[i]>t:
        ans+=T
    else:
        ans+=(T-(t-nt[i]))
    t=nt[i]+T
print(ans)


Measured memory_bytes: 25196