akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 2e5 + 5;
struct Edge {
	int from, to, cost;
	bool operator<(const Edge &rhs) const {
		return cost < rhs.cost;
	}
} e[N];
int n, m, k, c[N], newID[N], maxCost[N];
struct DSU {
	int n, p[N], sz[N];
	void init(int _n) {
		n = _n;
		fw (i, 0, n) p[i] = i, sz[i] = 1;
	}
	int getp(int u) {
		return u == p[u] ? u : p[u] = getp(p[u]);
	}
	bool joint(int u, int v) {
		u = getp(u), v = getp(v);
		if (u == v) return 0;
		if (sz[u] < sz[v]) swap(u, v);
		sz[u] += sz[v];
		p[v] = u;
		return 1;
	}
} groups, spanningTree;
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//Treat uncolored vertexes as vertexes in new graph, then connect an edge cost 0 to its color.
	cin >> n >> m >> k;
	fw (i, 0, n) cin >> c[i], c[i]--;
	int ptr = k;
	memset(newID, -1, sizeof newID);
	fw (i, 0, n) {
		if (c[i] == -1) newID[i] = ptr++;
		else newID[i] = c[i];
	}
	fw (i, 0, m) {
		cin >> e[i].from >> e[i].to >> e[i].cost;
		e[i].from--, e[i].to--;
	}
	sort(e, e + m);
	groups.init(ptr);
	fw (i, 0, m) groups.joint(newID[e[i].from], newID[e[i].to]);
	int cntGroups = 0, cntUnknown = ptr - k;
	fw (i, 0, ptr) if (groups.getp(i) == i) cntGroups++;
//	fw (i, 0, n) cout << newID[i] << "\n";
	if (cntUnknown < cntGroups - 1) {
		cout << "-1";
		return 0;
	}
	//Each "unknown" vertex can be connected to a "known" vertex with cost 0.
	int ans = 0;
	spanningTree.init(ptr);
	int cntEdges = 0;
	fw (i, 0, m) {
		if (cntEdges == k - 1) break;
		if (spanningTree.joint(newID[e[i].from], newID[e[i].to])) {
			ans += e[i].cost;
			cntEdges++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int X;
  cin>>X;

  int ans=1;
  reps(i,2,100){
    int num=i*i;
    if(num>X) break;
    reps(j,1,12){
      if(num*i>X) break;
      num*=i;
    }
    maxi(ans,num);
  }
  cout<< ans<<"\n";
}

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


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;

ll bit[200010];
ll n;

vector<P> vec;

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return pow_mod(x, mod - 2);
}

ll fu(ll x, ll y)
{
	if (y == 0) return x;
	return fu(y, x % y);
}

int main(void)
{
	ll a, b;
	cin >> a >> b;
	ll ans = 0;
	ll c = fu(a, b);

	for (int i = 2; i <= sqrt(c); i++)
	{
		if (c % i != 0) continue;
		ans++;
		while (c % i == 0)
		{
			c /= i;
		}
	}

	if (c != 1) ans++;

	cout << ans + 1 << endl;

	int www;
	cin >> www;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector <string> c(h);
  REP(i, h) {
	cin >> c[i];
  }
  int ans = 0;
  REP(s, 1 << h) {
	REP(t, 1 << w) {
	  int cnt = 0;
	  REP(i, h) {
		REP(j, w) {
		  if (c[i][j] == '#' && !(s & (1 << i)) && !(t & (1 << j))) {
			  cnt++;
			}
		}
	  }
	  if (cnt == k) {
		  ans++;
		}
	}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
import heapq
#listから複数index削除するやつ
dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]

[N,M]=[int(x) for x in input().split()]
work=[[int(x) for x in input().split()] for _ in range(N)]

work.sort() #日付の短い順にsortしておく　これいる？いる！！！！
tank=[] #候補を入れる
res=0 #回答
j=0

for i in range(M+1): #日付を後ろから見ていく
  while j<=N-1 and work[j][0]<=i: #forじゃないのはheapqに入れた分はずっと候補なのでもうみなくていいため
    heapq.heappush(tank,-work[j][1])
    j+=1
  #print("tank1:",tank)
  
  if len(tank)==0: #候補がなければ次の日へ
    #print("continue.")
    continue

  else: #候補があればもっとも良いのを回答に足す
    res -= heapq.heappop(tank)
    #print("res=",res)
    
  #print("tank2:",tank)
    
print(res)

Measured memory_bytes: 74328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AIZUJudge {
    class Program {
        static void Main(string[] args) {
            new Program().solve();
       }

        void solve() {
            for (int i = 0; i < 9; i++) {
                string input = Console.ReadLine();
                string[] sinput = input.Split();
                string[] result = calcResult(sinput);
                Console.WriteLine(result[0]+" "+result[1]+" "+result[2]);
            }
        }

        string[] calcResult(string[] data) {
            string[] result = new string[3];
            result[0] = data[0];
            result[1] = sumFromString(data[1],data[2]).ToString();
            result[2] = calcIncome(data[1], data[2]).ToString(); 
            return result;
        }

        int sumFromString(string a, string b) {
            return int.Parse(a) + int.Parse(b);
        }

        int calcIncome(string a,string b) {
            return int.Parse(a) * 200 + int.Parse(b) * 300;
        }
    }
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}

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

ll a,b,c,d;

ll f(ll n){
	return n-n/c-n/d+n/lcm(c,d);
}

int main(){
	cin>>a>>b>>c>>d;
	cout<<f(b)-f(a-1)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int max(int a,int b){ return (a<b)?b:a;}
void MRoy(){
    int a,b;
    scanf("%d%d",&a,&b);
    int Ans = a+b;
    Ans = max(Ans, a-b);
    Ans = max(Ans,a*b);
    printf("%d\n",Ans);
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;


int main(){
    int N, K;
    long long x[100000];
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    long long ans = (long long)1e14;

    // [begin, begin + K)
    for(int begin = 0; begin + K <= N; begin++){
        long long tmp1 = 0, tmp2 = 0;
        tmp1 += abs(x[begin]) + abs(x[begin] - x[begin + K - 1]);
        tmp2 += abs(x[begin + K - 1]) + abs(x[begin] - x[begin + K - 1]);
        long long tmp = min(tmp1, tmp2);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  int curr = h[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    if (h[i] > curr) {
      --h[i];
      if (h[i] > curr) {
        out("No");
        return 0;
      }
    }
    curr = min(curr, h[i]);
  }
  out("Yes");
}


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

const int MOD = 1000000007;

int main(){
    int N; cin >> N;
    vector<int> C(N);
    rep(i, N) cin >> C[i];
    vector<int> dp(N+1);
    map<int, int> d;
    dp[0] = 1;
    rep(i, N) {
        dp[i+1] = dp[i];
        if (i > 0 && C[i-1] == C[i]){
            continue;
        }
        if(d[C[i]] > 0){
            dp[i+1] += dp[d[C[i]]];
        }
        d[C[i]] = i+1;
        dp[i+1] %= MOD;
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 13980
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MAX 1000001
#define abs(y) ((y>0) ? (y) : (-(y)))

//int solve(int data[],int size);
typedef long long int int64;

int main()
{
    int64 x,k,d;
    int i,j;
    int a=7;
	scanf("%lld %lld %lld",&x,&k,&d);

	//遠い場合は近づく

	if(x<0)x= x * (-1);

	if(x>0)
    {
	    if(x/d<=k)//間に合う
        {
	        int64 cand1 = x%d;
	        int64 cand2 = abs(((x%d)-d));
	        if((k-(x/d))%2==0)printf("%lld",cand1);
	        else printf("%lld",cand2);
        }
	    else//間に合わない
        {
	        printf("%lld",x-(k*d));
        }
    }
	else if(x==0)
    {
	    if(k%2==0)printf("0");
	    else printf("%lld",abs(d));

    }
	//printf("%d",i);
}


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

typedef long long ll;
ll helper(vector <vector <ll>>&dp,vector <ll >&v,int i,int j)
{
    ll start,end;
    if(i>j)
        return 0;
    if(i==j)
        return v[i];
    if(i+1==j)
        return max(v[i],v[i+1]);
    if(dp[i][j]==-1)
    {
        start=v[i]+min(helper(dp,v,i+2,j),helper(dp,v,i+1,j-1));
        end=v[j]+min(helper(dp,v,i+1,j-1),helper(dp,v,i,j-2));
        dp[i][j]=max(start,end);
    }
    return dp[i][j];


}
void solve()
{
    int i,n;
    cin>>n;
    vector <ll> v(n);
    ll X,Y,sum=0;
    for(i=0;i<n;i++)
    {
        cin>>v[i];
        sum+=v[i];
    }
   // cout<<sum<<"\n";
    vector <vector <ll>>dp(n,vector <ll>(n,-1));
    X=helper(dp,v,0,n-1);
    Y=sum-X;
    cout<<X-Y<<"\n";
}
int main()
{
	solve();
	return 0;
}


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

void solve(std::vector<long long> x)
{
    for (int i = 0; i < 5; i++)
    {
        if (x[i] == 0)
        {
            cout << i + 1 << endl;
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::vector<long long> x(5);
    for (int i = 0; i < 5; i++)
    {
        scanf("%lld", &x[i]);
    }
    solve(std::move(x));
    return 0;
}


Measured memory_bytes: 3668
S = list(input())
N = len(S)

ans = 0
flag = 0
ABCflag = 0

i = 0
while i < N-2:

    if S[i]+S[i+1]+S[i+2] == 'ABC':
        if flag:
            ans += flag
        ans += 1
        S[i+2] = 'A'
        i += 1

    elif S[i] == 'A':
        flag += 1

    else:
        flag = 0

    i += 1
print(ans)


Measured memory_bytes: 4840
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
using namespace std;
int a[1001];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        if(n==0)
            return 0;
            int p=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            p=p+a[i];
        }
        double m=p*1.0/n;
        double t=0;
        for(int i=1;i<=n;i++)
        {
            t=t+(a[i]-m)*(a[i]-m)/n;
        }
        double t2=sqrt(t);
        printf("%.8lf\n",t2);
    }
}

Measured memory_bytes: 3176
S = list(input())
S_dict = {}

for idx, s in enumerate(S):
    if s not in S_dict:
        S_dict[s] = [idx]
    else:
        S_dict[s].append(idx)
T = list(input())
T_dict = {}
for idx, t in enumerate(T):
    if t not in T_dict:
        T_dict[t] = [idx]
    else:
        T_dict[t].append(idx)
# print(list(S_dict.values()))
# print(list(T_dict.values()))

for s in list(S_dict.values()):
    if s in list(T_dict.values()):
        continue
    else:
        print("No")
        exit()
print("Yes")

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

using namespace std;
using ll = long long;

int main() {
    int N, X;
    cin >> N;
    int M = 0;
    cin >> M >> X;
    vector<int> A(M,0);
    for(int i = 0; i < M; i++) {
    cin >> A.at(i);
    }
    sort(A.begin(),A.end());
    for(int i = 0; i < M; i++) {
        if(A.at(i) > X) {
            cout << min(i, M - i) << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
using namespace std;
using ll=long long;

int main(int argc, char const *argv[]) {
  ll q,h,s,d,n,a,b;
  cin>>q>>h>>s>>d;
  cin>>n;
  a=min({8*q,4*h,2*s,d});
  b=min({4*q,2*h,s});
  if(n%2==1){
    cout<<(n/2)*a+b<<endl;
  }else{
    cout<<(n/2)*a<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define retrun return
#define cpnst const
int CT[444][444],DEG[444],SZ[444],Lm=401;
class UFS
{
	int Fa[1111];
	public:
	void init(){for(register int i=1;i<=1000;i++)Fa[i]=i;}
	int rt(int x){return Fa[x]^x?Fa[x]=rt(Fa[x]):x;}
	bool merge(int x,int y){return x=rt(x),y=rt(y),Fa[x]=y,x^y;}
}U;
void rd()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(c)a=-c;if(d)b=d;else b=-b;
	U.merge(a+201,b+201),CT[a+201][b+201]++,
	DEG[a+201]++,DEG[b+201]--,SZ[a+201]++,SZ[b+201]++;
}
int UNB[11111];
void cover(int x)
{UNB[U.rt(x)]=1;}
int main()
{
	register int i;
	int n;
	scanf("%d%*d",&n),U.init();
	for(i=1;i<=n;i++)rd();
	for(i=-200;i<=200;i++)
	{
		if(i<0&&DEG[i+201]>0)return puts("NO"),0;
		if(i>0&&DEG[i+201]<0)return puts("NO"),0;
	}for(i=1;i<=Lm;i++)
		if(DEG[i])cover(i);
	for(i=1;i<=Lm;i++)
		if(SZ[i])
			if(!UNB[U.rt(i)])return puts("NO"),0;
	puts("YES");
}
/*
Just go for it.
*/

Measured memory_bytes: 2364
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
// #define INF 9e+18

/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

#define int long long

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    int ans = 0;
    rep(i, N) {
        if (p[i] == i + 1) {
            ans++;
            i++;
        }
    }
    cout << ans << nn;
    return 0;
}


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

int main() {
  int n,k;long long ans = 0;
  cin >> n >> k;
  vector<long long>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  for(int i = 0;i < n-k;i++){
    ans += data.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MAX 1000005;
using namespace std;
int main(){

    int a, b, c, d; cin >> a >> b >> c >> d;

    if( a+b > c+d ){
        cout << "Left\n";
    }else{
        if( a+b < c+d ){
            cout << "Right\n";
        }else{
            cout << "Balanced\n";
        }
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <map>

using namespace std;

typedef long long i64;

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

    vector<int> a(n);
    int i;
    map<int, int> m;
    for (i=0; i<n; i++) {
        scanf("%d", &a[i]);
        m[a[i]] = i+1;
    }
    sort(a.begin(), a.end());

    i64 res=0;
    for (i=0; i<n; i++) {
        if ((m[a[i]]^(i+1))&1) {
            res++;
        }
    }

    cout << res/2 << endl;
    return 0;
}


Measured memory_bytes: 5376
<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
$c = trim(fgets(STDIN));
$x = trim(fgets(STDIN));
$cnt = 0;
for ($i = 0; $i <= $a; $i++) {
    for ($j = 0; $j <= $b; $j++) {
        for ($k = 0; $k <= $c; $k++) {
            if (500 * $i + 100 * $j + 50 * $k == $x) {
                $cnt++;
            }
        }
    }
}
echo $cnt;

Measured memory_bytes: 4728
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    H = list(map(int, input().split()))

    res = 0
    i = 0
    while sum(H) != 0:
        if H[i] != 0:
            while i < n and H[i] != 0:
                H[i] -= 1
                i += 1
            res += 1
            i = 0
        else:
            i += 1

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    var s = Enumerable.Repeat(0, n).Select(x => Console.ReadLine()).ToArray();
    var set = new HashSet<string>();
    var t = s[0][0];
    bool f = true;
    foreach (var w in s) {
      if (w[0] != t) {
        f = false;
        break;
      }
      if (set.Contains(w)) {
        f = false;
        break;
      }
      t = w[w.Length - 1];
      set.Add(w);
    }
    Console.WriteLine(f ? "Yes" : "No");
  }
}

Measured memory_bytes: 13408
#include<iostream>
#include<set>

int sum_comb(std::set<int> c, int n, int s) {
	int sum = 0;
	if (n == 0) {
		if (s == 0) return 1;
		else return 0;
	}

	for (int i = c.size() == 0 ? 9 : (*(c.begin())) - 1; i >= 0; --i) {
		if (i <= s) {
			c.insert(i);
			sum += sum_comb(c, n - 1, s - i);
		}
	}
	return sum;
}

int main() {
	int n, s;
	while (std::cin >> n >> s) {
		if (n == 0 && s == 0) break;
		std::set<int> c;
		std::cout << sum_comb(c, n, s) << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<cstdio>
using namespace std;
int f[15][10005];
int n,m;
int anss=0,ans=0;
void dfs(int q){
	if(q>n){
		//if(ans>anss)anss=ans;
		return ;
	}
	ans=0;
	for(int j=1;j<=m;j++){
		int count=0;
		for(int i=1;i<=n;i++){
			if(f[i][j]==0)count++;
		}//cout<<"count "<<count<<endl;
		if(count>n/2)ans+=count;
		else ans+=n-count;
	}
	//cout<<"ans "<<ans<<endl;
	if(ans>anss)anss=ans;//cout<<anss<<endl;
	dfs(q+1);
	//ans=0;
	for(int j=1;j<=m;j++){
		f[q][j]=(f[q][j]+1)%2;
	}

	dfs(q+1);
	for(int j=1;j<=m;j++){
		f[q][j]=(f[q][j]+1)%2;
	}
}
int main(){
	while(scanf("%d%d",&n,&m)&&!(n==0)){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				scanf("%d",&f[i][j]);
			}
		}
		dfs(1);
		cout<<anss<<endl;
	}
	return 0;
}

Measured memory_bytes: 3536
S = input()
S_list = list(S)

while len(S_list) >= 5 :
    a = len(S_list)
    if S_list[0:5] == ['e', 'r', 'a', 's', 'e']:
        if a >= 6 :
            if S_list[5] == 'r' :
                del S_list[0:6]
            else:
                del S_list[0:5]
        else:
            del S_list[0:5]
    elif S_list[0:5] == ['d', 'r', 'e', 'a', 'm']:
        if a >= 8 :
            if S_list[5:8] == ['e', 'r', 'a'] :
                del S_list[0:5]
            elif S_list[5:7] == ['e', 'r'] :
                del S_list[0:7]
            else :
                del S_list[0:5]
        elif a >= 7 :
            if S_list[5:7] == ['e', 'r'] :
                del S_list[0:7]
            else:
                del S_list[0:5]
        else :
            del S_list[0:5]
    else:
        print('NO')
        break


if len(S_list) == 0:
    print('YES')
elif 0<len(S_list)<5:
    print('NO')

Measured memory_bytes: 4084
def bisect(a, x, lo=0, hi=None):
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if x < a[mid]: hi = mid
        else: lo = mid+1
    return lo

while True:
    n = int(input())
    if n==0: break

    dealt = [0]*(2*n)
    thand = []
    hhand = []

    for i in range(n):
        dealt[int(input())-1] = 1
    for i in range(2*n):
        if dealt[i]:
            thand.append(i)
        else:
            hhand.append(i)

    thand.sort()
    hhand.sort()
    tarosturn = 1
    ba = -1

    while True:
        if len(thand) == 0:
            print(len(hhand))
            print(0)
            break
        elif len(hhand) == 0:
            print(0)
            print(len(thand))
            break

        if tarosturn:
            taro = bisect(thand,ba)
            if taro != len(thand):
                ba = thand.pop(taro)
            else:
                ba = -1
            tarosturn = 0
        else:
            hanako = bisect(hhand,ba)
            if hanako != len(hhand):
                ba = hhand.pop(hanako)
            else:
                ba = -1
            tarosturn = 1

Measured memory_bytes: 7732
#include <bits/stdc++.h>
using namespace std;
int a[1000];
int div(int n)
{
    int cou=0,i;
    for(i=1;i<=n;i++)
    {
        if(n%i==0)
        {
            cou++;
        }
    }
    
    if(cou==8)
        return 0;
    else
        return 1;
}
int main()
{
    int i,n;
    a[0]=0;
    for(i=1;i<=201;i++)
    {
        if(i%2==1 && div(i)==0)
            a[i]=a[i-1]+1;
        else
            a[i]=a[i-1];
    }
    cin>>n;
    cout<<a[n]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
signed main() {
	string s;
	cin >> s;
	if (s[0] == '9' || s[1] == '9') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;

}

Measured memory_bytes: 256
/*
AizuOnline A0060
Card Game
*/
#include <stdio.h>
#define min(a,b) ((a)<(b))?(a):(b)

main()
{
  int c1,c2,c3;
  int nokori;
  int used;


  
while(EOF != scanf("%d %d %d",&c1,&c2,&c3))
  {
    nokori = 20 -c1-c2;
    nokori = min(10,nokori); 
    
    used=0;
    if(nokori >= c1)
      used ++;
    if(nokori >= c2)
      used ++;
    if(nokori >= c3)
      used ++;

    /*printf("ZAN %d\n",nokori-used);*/
    if(nokori-used <4)
      printf("NO\n");
    else
      printf("YES\n");
  }
return(0);
}

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

namespace ABC051A___Haiku
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            string output = input.Replace(",", " ");

            Console.WriteLine(output);

        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
int main(void){
    
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b){
        if(b<c)printf("Yes\n");
        else printf("No\n");
    }
    else printf("No\n");

    return 0;
}



Measured memory_bytes: 2056
s = input()
target = 'keyence'
l = len(s)
for i in range(l - 6): #消す文字数 
    #print(i)
    for j in range(l - i + 1): #消し始めの位置
        a = s[:j] + s[j+i:]
        #print(i, j, a)
        if a == target:
            print('YES')
            exit()
print('NO')


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

using namespace std;

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

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

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

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

	int n; string s; cin >> n >> s;
	int e(0);
	REPU(i, 0, n) {
		if (s[i] == 'E') e++;
	}
	int ans = n, ce = 0;
	REPU(i, 0, n) {
		if (s[i] == 'E') {
			amin(ans, i - ce + e - ce - 1);
			ce++;
		}
		else amin(ans, i - ce + e - ce);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    ll num=0,d=1;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	if(abs(num)<=abs(a[i])){
    		num=a[i];
    		d=i+1;
    	}
    }
    cout <<2*n-1<<endl;
    if(num>0){
    	for(int i=1;i<=n;i++){
    		cout << d<<" "<<i<<endl;
    	}
    	for(int i=2;i<=n;i++){
    		cout << i-1<<" "<<i<<endl;
    	}

    }else{
    	for(int i=1;i<=n;i++){
    		cout << d<<" "<<i<<endl;
    	}
    	for(int i=n;i>1;i--){
    		cout << i<<" "<<i-1<<endl;
    	}
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, tmp;
    
    while(1){
        scanf("%d %d", &a, &b);
        int count=0;
        if(a==0 && b==0) break;
        if(a<b){
            tmp=b;
            b=a;
            a=tmp;
        }
    
        while(1) {
            a=a%b;
            tmp=b;
            b=a;
            a=tmp;
            count++;
            if(b==0) break;
        }   
    
        printf("%d %d\n", a, count);
    }
    
    return 0;
    
}


Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(int i=a; i<n; i++)
#define loop(i,a,n)	for(int i=a; i>=n; i--)

int main() 
{		
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	long long int a;
	cin>>a;
	double b=a;
	cout<<fixed<<setprecision(15)<<(b*b*b)/27;
	
	return 0;	
}

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

int main() {
    int a, b;

    cin >> a >> b;

    if (a > b) {
        cout << "a > b";
    } else if (a < b) {
        cout << "a < b";
    } else {
        cout << "a == b";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3088
#include<iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
using namespace std;

int main()
{
	std::string str;

	cin >> str;

	for (int i = 0; i < str.size(); i++) {
		if(i%2 == 0)
			std::cout << str[i];
	}

	std::cout  << '\n';

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,a[N],x;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		x^=a[i];
	}
	for(int i=1;i<=n;i++)
		printf("%d ",a[i]^x);
	return 0;
}

Measured memory_bytes: 4496
H, W, K = map(int, input().split())
s = ["" for i in range(H)]
for i in range(H):
    s[i] = str(input())

ans = [[0 for i in range(W)] for j in range(H+1)]
x = 1
for i in range(1, H+1):
    for j in range(W):
        if s[i-1][j] == "#":
            ans[i][j] = x
            x += 1
#print(*ans)
x = 1
for i in range(1, H+1):
    if sum(ans[i]) == 0:
        for j in range(W):
            ans[i][j] = ans[i-1][j]
    else:
        for j in range(W):
            if ans[i][j] == 0:
                ans[i][j] = x
            else:
                x = ans[i][j]
        x += 1
#print(*ans)
for i in range(1, H+1):
    if sum(ans[i]) == 0:
        for j in range(W):
            ans[i][j] = ans[i-1][j]
#print(*ans)
for i in reversed(range(1,H)):
    if sum(ans[i]) == 0:
        for j in range(W):
            ans[i][j] = ans[i+1][j]
for i in range(1, H+1):
    print(*ans[i])



Measured memory_bytes: 7580
//InTheNameOfGod
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
const int maxn = 1;
int n;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    if(n==3)
    {
        cout <<200<<' '<<7<<' '<<3;
        return 0;
    }
    cout<<3<<' ' <<9<<' ';
    n-=2;
    int x=1;
    while(n&&2*x<=30000)
    {
        if(x%3==1&&n==1)
        {
            cout<<(x+2)*2<<' ';
            n--;
            break;
        }
        if(x*2==30000&&n%2==0)
        {
            break;
        }
        cout<<2*x<<' ';
        x++;
        n--;
    }
    x=5;
    while(n&&3*x<=30000)
    {
        cout<<3*x<<' ';
        x+=2;
        n--;
    }
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <bitset>
#include <vector>
using namespace std;
vector<long long> primes;
bitset<1000001> bs;
void sieve() {
	bs.set();
	bs[0] = bs[1] = 0;
	for (long long i = 2; i <= 1000000; ++i) {
		if (bs[i]) {
			primes.push_back(i);
			for (long long j = i * i; j <= 1000000; j += i) bs[j] = 0;
		}
	}
}
int main() {
	sieve();
	long long N, ans = 0;
	scanf("%lld", &N);
	for (long long i: primes) {
		int cnt = 1;
		while (N % i == 0) {
			for (int j = 0; j < cnt; ++j) {
				if (N % i != 0) break;
				if (j == cnt - 1) ++ans;
				N /= i;
			}
			++cnt;
		}
	}
	if (N != 1) ++ans;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 3684
def main():
    n = int(input())
    b = list(map(int, input().split()))
    f = True
    ans = []
    while len(b) > 0:
        sf = True
        for i in reversed(range(len(b))):
            if b[i] == i+1:
                b.pop(i)
                ans.append(i+1)
                sf = False
                break
        if sf:
            f = False
            break
    if f:
        for v in reversed(ans):
            print(v)
    else:
        print("-1")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#define MAX_N 3005

using namespace std;
typedef long long ll;

const ll mod = 1000000007;


ll mpow(ll x,ll n){
    ll ret = 1;
    while(n>0){
        if((n&1)==1){
            ret *= x;
            ret %= mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret%mod;
}

ll inv(ll x){
    return mpow(x,mod-2);
}




int main(){
    int N,Q;
    ll A[MAX_N];
    ll dp[2][MAX_N][MAX_N];
    cin>>N>>Q;
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    ll _2q = mpow(2,Q);
    ll inv2 = inv(2);
    for(int i = 0;i < N;i++){
        for(int j = 0;j < N;j++){
            if(A[i]>A[j]){dp[0][i][j]=dp[1][i][j]=1;}
            else{dp[0][i][j]=dp[1][i][j]=0;}
        }
    }
    for(int qqq = 0;qqq < Q;qqq++){
        int x,y;cin>>x>>y;
        x--,y--;
        for(int i = 0;i < N;i++){
            if(i!=x&&i!=y){
                dp[1][x][i]=(dp[0][x][i]*inv2+dp[0][y][i]*inv2)%mod;
                dp[1][i][x]=(dp[0][i][x]*inv2+dp[0][i][y]*inv2)%mod;
                dp[1][y][i]=(dp[0][y][i]*inv2+dp[0][x][i]*inv2)%mod;
                dp[1][i][y]=(dp[0][i][y]*inv2+dp[0][i][x]*inv2)%mod;
            }
        }
        dp[1][x][y]=dp[1][y][x]=(dp[0][x][y]*inv2+dp[0][y][x]*inv2)%mod;
        for(int i = 0;i < N;i++){
            dp[0][i][x]=dp[1][i][x];
            dp[0][i][y]=dp[1][i][y];
            dp[0][x][i]=dp[1][x][i];
            dp[0][y][i]=dp[1][y][i];
        }
        
    }
    ll ans = 0;

    for(int i = 0;i < N;i++){
        for(int j = i+1;j < N;j++){
            ans += dp[0][i][j];
            ans %= mod;
//            cout<<(_2q*dp[0][i][j])%mod<<" ";
        }
//        cout<<endl;
    }
    cout<<(ans*_2q)%mod<<endl;

}


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

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

    vector<int> a(N + 1);
    vector<int> b(N + 1, -1);
    int M = 0;

    rep(i, N) {
        cin >> a[i + 1];
    }

    for(int i = N; i >= 1; i--) {
        IFD cout << "i: " << i << endl;
        int c = 0;
        for(int j = N / i; j >= 1; j--) {
            int v = j * i;
            IFD cout << v << endl;
            if(i == v) {
                /*
                if(a[v] != (a[v] + c) % 2) {
                    cout << "-1" << endl;
                    return;
                }*/
                b[v] = (a[v] + c) % 2;
                if(b[v] == 1) {
                    M++;
                }
            } else {
                c = (c + b[v]) % 2;
            }
        }
    }
    IFD cout << endl;

    IFD {
        rep(i, N) {
            cout << b[i + 1] << " ";
        }
        cout << endl << endl;
    }

    cout << M << endl;
    rep(i, N) {
        if(b[i + 1] == 1) {
            cout << i + 1 << " ";
        }
    }
    if(M != 0) {
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    int n;
    cin>>n;
    bool dp[110];
    rep(i,110) dp[i]=false;
    dp[0]=true;
    rep(i,100){
        if(i+4<=100) dp[i+4]=dp[i+4] || dp[i];
        if(i+7<=100) dp[i+7]=dp[i+7] || dp[i];
    }
    //rep(i,101) cout<<i<<" "<<dp[i]<<endl;
    if(dp[n]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

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

	string key = "keyence";
	string input; 
	cin >> input;
	if(input == key) {
		puts("YES");
		return 0;
	}
	int len = input.size();
	for(int i = 0; i < len; i++) {
		for(int j = i; j < len; j++) {
			string tmporaryString; 
			for(int k = 0; k < len; k++) {
				if(i <= k && k <= j)
					continue;
				tmporaryString.push_back(input[k]);	
			}
			cerr << tmporaryString << endl;
			if(tmporaryString == key) {
				puts("YES");
				return 0;
			}
		}
	}
	puts("NO");
    return 0;
}
	

Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    ABC = list(map(int, input().split()))
    A = ABC[0]
    B = ABC[1]
    C = ABC[2]
    
    ans = C - (A -B)
    if ans < 0:
      print(0)
    else:
      print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
from collections import deque
n,q=map(int,raw_input().split())
l=deque([raw_input().split()for _ in range(n)])
t=0
while len(l):
 a,b=l.popleft()
 b=int(b)
 if q<b: t+=q;l.append([a,b-q])
 else:   t+=b;print a,t

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

int main()
{
    int n,m;
    cin >> n >> m;
    int a[n][m] = {};
    
    for(int i=0; i<n; i++){
        int k;
        cin >> k;
        while(k--){
            int l;
            cin >> l;
            a[i][l-1]++;
        }
    }
    
    int c = 0;
    for(int j=0; j<m; j++){
        int t = 0;
        for(int i=0; i<n; i++){
            if(a[i][j] == 1) t++;
        }
        if(t == n) c++;
        
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string S;
    cin >> S;
    const int N = S.size();
    vector<int> s(N + 1, 0);
    vector<ll> p(N + 1, 1LL);
    for (int i = N - 1; i >= 0; i--) { s[i] = s[i + 1] + S[i] - '0', p[i] = p[i + 1] * (S[i] - '0' + 1); }
    const int Sum = s[0];
    const ll Prod = p[0];
    vector<map<ll, ll>> dp(9 * N + 1);
    dp[0][1] = 1;
    ll prev = 0;
    for (int i = N - 1; i >= 0; i--) {
        const int d = S[i] - '0';
        for (int j = 0; j < d; j++) {
            if (p[i] % (j + 1) != 0) { continue; }
            const int S = s[i] - j;
            const ll P = p[i] / (j + 1);
            prev += (dp[S].find(P) == dp[S].end() ? 0LL : dp[S][P]);
        }
        vector<map<ll, ll>> tmp(9 * N + 1);
        for (int j = 0; j <= 9 * N; j++) {
            for (const auto& e : dp[j]) {
                for (int k = 0; k < 10; k++) { tmp[j + k][e.first * (k + 1)] += e.second; }
            }
        }
        dp = tmp;
    }
    ll ans = 0;
    for (int i = 0; i < Sum; i++) {
        for (const auto& e : dp[i]) { ans += e.second; }
    }
    for (const auto& e : dp[Sum]) { ans += (e.first < Prod ? e.second : 0LL); }
    cout << ans + prev << endl;
    return 0;
}



Measured memory_bytes: 27704
N,K = map(int, input().split())
binom = [[ 1 if j==0 else 0 for j in range(K+1)] for i in range(N+1) ]

for i in range(1,N+1):
    for j in range(1,K+1):
        binom[i][j] = binom[i-1][j-1] + binom[i-1][j]
for i in range(1,K+1):
    print(binom[K-1][i-1] * binom[N-K+1][i] % (10**9 + 7))

Measured memory_bytes: 480608
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

const int M = 6;

int main() {
  std::ios_base::sync_with_stdio(false);

  std::string S;
  cin >> S;

  int N = S.size();

  vector<vector<int>> f(N + 1, vector<int>(M + 1, -1));
  f[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= M; ++j) {
      if (f[i][j] != -1) {
        for (int k = 1; k <= M && i + k <= N; ++k) {
          if (j != k ||
              !std::equal(S.begin() + i - j, S.begin() + i, S.begin() + i)) {
            f[i + k][k] = max(f[i + k][k], f[i][j] + 1);
          }
        }
      }
    }
  }

  int ret = *max_element(f[N].begin(), f[N].end());
  cout << ret << '\n';
  return 0;
}


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

int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> x(n);
  rep(i,n){
    cin>>x[i];
  }
  ll ans=LLONG_MAX;
  rep(i,n-k+1){
    ll left=x[i], right=x[i+k-1];
    ll now_ans=0;
    if(left<0 && right>0){
      now_ans=min(abs(left)*2+right,abs(right)*2+abs(left));
    }else{
      now_ans=max(abs(left),abs(right));
    }
    ans=min(ans,now_ans);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4044
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
vector<int> g[110000];
vector<int> g2[110000];
char in[4];
int v1[110000];
int v2[110000];
int A[110000];
int B[110000];
int C[110000];
int main(){
	int T;scanf("%d",&T);
	while(T--){
		int a,b;scanf("%d%d",&a,&b);
		int c,d;scanf("%d%d",&c,&d);
		for(int i=0;i<a+1;i++)g[i].clear();
		for(int i=0;i<a+1;i++)g2[i].clear();
		for(int i=0;i<b;i++){
			int p,q;scanf("%d%d%s",&p,&q,in);
			if(in[0]=='N'){
				g[p].push_back(q);
				g[q].push_back(p);
			}else{
				g2[p].push_back(q);
				g2[q].push_back(p);
			}
		}
		for(int i=0;i<a+1;i++)v1[i]=v2[i]=0;
		queue<int>Q;
		Q.push(0);
		v1[0]=1;
		while(Q.size()){
			int at=Q.front();Q.pop();
			for(int i=0;i<g2[at].size();i++)if(!v1[g2[at][i]]){
				v1[g2[at][i]]=1;
				Q.push(g2[at][i]);
			}
		}
		v2[d]=1;
		Q.push(d);
		while(Q.size()){
			int at=Q.front();Q.pop();
			for(int i=0;i<g2[at].size();i++)if(!v2[g2[at][i]]){
				v2[g2[at][i]]=1;
				Q.push(g2[at][i]);
			}
		}
		if(v1[d]){
			printf("0\n");continue;
		}
		for(int i=0;i<a+1;i++)A[i]=B[i]=C[i]=99999999;
		A[c]=0;
		Q.push(c);
		while(Q.size()){
			int at=Q.front();Q.pop();
			for(int i=0;i<g[at].size();i++){
				if(A[g[at][i]]>9999999){
					A[g[at][i]]=A[at]+1;
					Q.push(g[at][i]);
				}
			}
		}
		for(int i=0;i<a+1;i++)if(v1[i]){
			Q.push(i);
			B[i]=0;
		}
		while(Q.size()){
			int at=Q.front();Q.pop();
			for(int i=0;i<g[at].size();i++){
				if(B[g[at][i]]>9999999){
					B[g[at][i]]=B[at]+1;
					Q.push(g[at][i]);
				}
			}
		}
		for(int i=0;i<a+1;i++)if(v2[i]){
			Q.push(i);
			C[i]=0;
		}
		while(Q.size()){
			int at=Q.front();Q.pop();
			for(int i=0;i<g[at].size();i++){
				if(C[g[at][i]]>9999999){
					C[g[at][i]]=C[at]+1;
					Q.push(g[at][i]);
				}
			}
		}
		int ret=999999999;
		for(int i=0;i<a+1;i++)ret=min(ret,A[i]+B[i]+C[i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 13312
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int check(vector<int> a, vector<int> b) {
    int dist = 0;
    for(int i = 0; i < a.size(); i++) {
        dist += (a[i] - b[i]) * (a[i] - b[i]);
    }
    for(int i = 0; i < 1000; i++) {
        if(i * i == dist)
            return 1;
    }
    return 0;
}

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    int cnt = 0;
    rep(i, N) rep(j, D) cin >> X[i][j];
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            cnt += check(X[i], X[j]);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
N,C=map(int,input().split())
cha=[[0 for i in range(10**5+1)] for j in range(C)]
for i in range(N):
  s,t,c=map(int,input().split())
  cha[c-1][s-1:t]=[1]*(t-s+1)
channels=0
for i in range(10**5+1):
  chans=0
  for c in range(C):
    chans+=cha[c-1][i]
  channels=max(channels,chans)
print(channels)

Measured memory_bytes: 26672
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int a = int.Parse(Console.ReadLine());
		if ( a == 3 || a == 5 || a == 7){
		Console.WriteLine("YES");
        }
      else{
      Console.WriteLine("NO");
      }
	}
}

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

int n;
int v[101];

int num(int m){
    int ret=0;
    for(int i=2; i<=n; i++){
        if(v[i]>=m) ret++;
    }

    return ret;
}

int main(void){
    cin >> n;
    
    for(int i=2; i<=n; i++){
        int cur=i;
        for(int j=2; j<=i; j++){
            while(cur%j==0){
                v[j]++;
                cur/=j;
            }
        }
    }

    cout << num(74)+num(24)*(num(2)-1)+num(14)*(num(4)-1)+((num(4)*(num(4)-1))/2)*(num(2)-2) << endl;
}

Measured memory_bytes: 256