akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
using P = pair<ll,ll>;

vector<vector<ll>> to(200005);
vector<ll> ans;

void dfs( ll p, ll q ){
  for(auto v : to.at(p) ){
    if( v == q ) continue;
    ans.at(v) += ans.at(p);
    dfs(v,p);
  }
}

int main(){
  ll n,q;cin >> n >> q;
  rep(i,n-1){
    ll a,b;cin >> a >> b;
    --a;--b;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }

  ans.resize(n);
  rep(i,q){
    ll p,x;cin >> p >> x;
    --p;
    ans.at(p) += x;
  }

  dfs(0,0);

  rep(i,n){
    cout << ans.at(i);
    if( i != n-1 ) cout << " ";
    else cout << endl;
  }
  return 0;
}


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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

long long dp[3050][3050];
int a[3050];

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    int n, k;
    cin >> n;
    forn(i, n) cin >> a[i];

    for (int i = 0; i < n; i++)
        dp[i][i] = (n % 2 == 1 ? 1 : -1) * a[i];

    forlr(l, 2, n + 1) {
        forn (i, n) {
            int j = i + l - 1;
            if (j >= n)
                continue;

            int who = ((n + l) % 2 == 0 ? 1 : -1);

            if (who == 1)
                dp[i][j] = max(dp[i][j - 1] + a[j], dp[i + 1][j] + a[i]);
            else
                dp[i][j] = min(dp[i][j - 1] - a[j], dp[i + 1][j] - a[i]);
        }
    }
    cout << dp[0][n - 1];

    return 0;
}

Measured memory_bytes: 71936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<string> vs;
const long long INF = 1LL << 58;
const int INT_INF = 1 << 28;
const double PI = acos(-1.0);

int main() {
  int n;
  cin >> n;
  vi s(n);
  rep(i, n) cin >> s[i];
  sort(all(s));
  int q;
  cin >> q;
  int ans = 0;
  rep(i, q) {
    int t;
    cin >> t;
    if (distance(lower_bound(all(s), t), upper_bound(all(s), t)))
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3136
#include<iostream>
#include<cstring>
using namespace std;
int N=998244353;
int a[3005][3005],b[3005],n,s;
int main(){
	cin>>n>>s;
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	int sum=0;
	for(int i=0;i<n;i++){
		memcpy(a[i+1],a[i],sizeof(a[i]));
		a[i+1][b[i]]=(a[i+1][b[i]]+i+1)%N;
		for(int j=0;j<=s-b[i];j++){
			a[i+1][j+b[i]]=(a[i+1][j+b[i]]+a[i][j])%N;		
		}
		sum=(sum+a[i+1][s])%N;
	}
	cout<<sum;
	return 0;
}


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

int main(){
	int i,a,b,c,k,point=0;
	cin>>a>>b>>c>>k;
	for(i=0;i<k;i++){
		if(i<a) point++;
		else if(i<a+b) point=point+0;
		else if(i<a+b+c) point--;
	}
	cout<<point<<endl;
}


Measured memory_bytes: 3620
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [A[i] - B[i] for i in range(N)]

ans = 0
p = 0
q = 0
l = []

for i, c in enumerate(C):
    if c < 0:
        ans += 1
        p += c
    else:
        q += c
        l.append(c)

if p + q < 0:
    print(-1)
    exit()

l.sort()


while p < 0:
    p += l[-1]
    l.pop()
    ans += 1

print(ans)

Measured memory_bytes: 19068
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int a[100001],b[100001];
bool comp(int a,int b)
{
 return a>b;
}
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]+1]++;
        b[a[i]-1]++;
        b[a[i]]++;
    }
    sort(b,b+100001,comp);
    cout<<b[0]<<endl;

}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }


int main() {
    ll n, k; cin >> n >> k;
    ll ans = 1;
    rep(i, n) {
        ans *= k;
        ans %= MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3120
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
#define bit(n, k) ((n) >> (k) & 1)
const int MOD = (int)1e9 + 7;
template<class T> void add(T &a, T b) { (a += (b % MOD + MOD) % MOD) %= MOD; }

int main() {
    int h, w; cin >> h >> w;
    int K; cin >> K; K--;
    vector<vector<int>> num(w, vector<int>(w));
    for (int mask = 0; mask < 1 << (w - 1); mask++) {
        bool ok = true;
        for (int i = 0; i + 1 < w - 1; i++) {
            if (bit(mask, i) && bit(mask, i + 1)) ok = false;
        }
        if (!ok) continue;
        vector<int> p(w);
        iota(p.begin(), p.end(), 0);
        for (int i = 0; i < w - 1; i++) if (bit(mask, i)) swap(p[i], p[i + 1]);
        for (int i = 0; i < w; i++) num[i][p[i]]++;
    }
    vector<vector<long long>> dp(h + 1, vector<long long>(w));
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) for (int k = 0; k < w; k++) {
            add(dp[i + 1][k], dp[i][j] * num[j][k]);
        }
    }
    cout << dp[h][K] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a[4], b[4];
	cin >> a[0] >> a[1] >> a[2] >> a[3];
	cin >> b[0] >> b[1] >> b[2] >> b[3];
	if (a[0] + a[1] + a[2] + a[3] >= b[0] + b[1] + b[2] + b[3])
		cout << a[0] + a[1] + a[2] + a[3] << endl;
	else
		cout << b[0] + b[1] + b[2] + b[3] << endl;
	return 0;
}

Measured memory_bytes: 0
h,w = list(map(int, input().split()))
ans = 10**10
if h%3 == 0 or w%3 == 0:
    print(0)
    exit()
    
for H in range(1, h + 1):
    a = H * w
    b = (h - H) * (w // 2)
    c = (h - H) * (w - w // 2)
    ans = min(ans, max(a,b,c) - min(a,b,c))

for W in range(1, w + 1):
    a = W * h
    b = (w - W) * (h // 2)
    c = (w - W) * (h - h // 2)
    ans = min(ans, max(a,b,c) - min(a,b,c))

if h > 3:
    ans = min(ans, w*((h+2)//3) - w*(h//3))

if w > 3:
    ans = min(ans, h*((w+2)//3) - h*(w//3))
    
print(ans)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll a,b;
    cin>>a>>b;
    if((b-a)%2==0){
        cout<<a+(b-a)/2;
    }else{
        cout<<"IMPOSSIBLE";
    }
    
}


Measured memory_bytes: 256
n,k=io.read("*n","*n","*l")
a={}
for i=1,n do
    x=io.read("*n")
    if not a[x] then
        a[x]=1
    else
        a[x]=a[x]+1
    end
end

b={}
for _,j in pairs(a) do
    table.insert(b,j)
end
table.sort(b)

ball=0
if #b-k>0 then
    for i=1,#b-k do
        ball=ball+b[i]
    end
end
print(ball)

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

//.define
//#define FILE_IN_OUT
#define RET(_x)                       return std::cout << (_x), 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define nfirst(_obj, _n)              (_obj).begin(), (_obj).begin() + (_n)
#define fori(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator < (_end); ++_iterator)
#define forr(_iterator, _begin, _end) for (int _iterator = (_begin); _iterator >= (_end); --_iterator)
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define div_ceil(_dividend, _divider) ((_dividend) - 1LL + (_divider)) / (_divider)
#define sz(_obj)                      static_cast<int>((_obj).size())
template<typename Tp>
inline void outarr(Tp _array, const std::size_t _N, const char* _delim = " ") {
    Tp end = _array + _N;
    for (Tp current = _array; current != end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = std::int64_t;
using pii = std::pair<int, int>;
constexpr int INF = INT_MAX;
constexpr int MOD = 1e9 + 7;

//.data
pii points[55];
int x[55];
int y[55];

inline bool bw(int a, int l, int r) {
    return l <= a && a <= r;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream сin  ("input.txt",  std::ios::in);
    std::ofstream сout ("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, k;
    cin >> n >> k;

    loop(n) {
        cin >> x[i] >> y[i];
        points[i] = {x[i], y[i]};
    }

    sort(x, x + n);
    sort(y, y + n);

    ll ans = LLONG_MAX;
    fori(xl, 0, n) {
        fori(xr, xl + 1, n) {
            fori(yd, 0, n) {
                fori(yu, yd + 1, n) {
                    int x1 = x[xl];
                    int x2 = x[xr];
                    int y1 = y[yd];
                    int y2 = y[yu];
                    int cnt = 0;
                    fori(i, 0, n) {
                        int xi = points[i].first;
                        int yi = points[i].second;
                        if (bw(xi, x1, x2) && bw(yi, y1, y2)) {
                            ++cnt;
                        }
                    }
                    if (cnt >= k) {
                        ans = min(ans, (ll)(x2 - x1) * (y2 - y1));
                    }
                }
            }
        }
    }

    cout << ans;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

using namespace std;

int main(){
	
	int angka1,angka2,angka3;
	scanf ("%d %d %d",&angka1,&angka2,&angka3);
	int hasil = (angka1*100) + (angka2*10) + angka3;
	if (hasil%4==0){
		printf ("YES\n");
	}
	else{
		printf ("NO\n");
	}
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;


int gcd(int a, int b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

int main() {
	int n, x;
	cin >> n >> x;
	vector<int>city(n);

	rep(i, n) {
		int t; cin >> t;
		city[i] = t - x;
	}
	
	int res = city[0];
	
	rep(i, n) {
		res = gcd(res, city[i]);
	}

	cout << abs(res) << endl;

	return 0;
}

Measured memory_bytes: 640
import math
#def main(S, b):
if __name__ == '__main__':
    #a, b, c, k = map(int, input().split())
    k = int(input())
    n = input()
    #print(n[-1])
    if (len(n) <= k):
        print(n)
    else:
        print(n[:k] + "...")

    # if (s == t[:(len(s))] and len(t) == len(s) + 1):

    #     print("Yes")
    # else:
    #     print("No")
    # s = sum(a)


Measured memory_bytes: 9156
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll int,ll int>
#define PI 2*acos(0)
//#define mx 1000000
#define INF LONG_LONG_MAX
using namespace std;
const ll int p=998244353;
//vector<ll > prime;
//bool mark[mx];
ll int mod(ll int a,ll int b)
{
    ll int m=a%b;
    if(m<0) m=(b<0)?(m-b):(m+b);
    return m;
}
ll maxpow(ll n)
{
    return (n & (~(n-1)));
}
bool isPrime(ll n)
{
    if(n<2) return false;
    if(n==2) return true;
    if(n%2==0) return false;
    for(ll i=3;i*i<=n;i+=2){
        if(n%i==0) return false;
    }
    return true;
}
/*void init()
{
    mark[1]=1;
    int i,j,limit=sqrt(mx*1.0)+2;
    prime.push_back(2);
    for(i=4;i<mx;i+=2) mark[i]=1;
    mark[2]=0;
    for(i=3;i<mx;i+=2){
        if(!mark[i]){
            prime.push_back(i);
            if(i<=limit){
                for(j=i*i;j<mx;j+=2*i){
                    mark[j]=1;
                }
            }
        }
    }
}*/
/*
ll maxdiv(ll n)
{
    ll i,ans=1;
    for(i=0;i<prime.size();i++){
        if(n%prime[i]==0){
            ans=n/prime[i];break;
            //return ans;
        }
    }
    return ans;
}*/
ll lcm(ll a,ll b)
{
    ll ans=a*b;
    return (ans/__gcd(a,b));
}
// ax+by and a>b
ll gcd(ll a,ll b,ll &x,ll &y)
{
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll d=gcd(b,mod(a,b),x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
ll abso(ll a)
{
    if(a>=0) return a;
    return -a;
}
ll div_count(ll n)
{
    bool flag[n+1];
    memset(flag,1,sizeof(flag));
    for(int p=2;p*p<n;p++){
        if(flag[p]){
            for(int i=p*2;i<n;i+=p) flag[i]=false;
        }
    }
    ll total=1;
    for(int p=2;p<=n;p++){
        if(flag[p]){
            int cnt=0;
            while(n%p==0){
                n/=p;
                cnt++;
            }
            total*=(cnt+1);
        }
    }
    return total;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll i,j,n,x,m,first,a,cx,ans=0;
    cin>>n>>x>>m;
    cx=x;
    ll cnt[m+5]={};
    for(i=0;i<n;i++){
        if(cnt[x] || !x) break;
        cnt[x]=i;
        ans+=x;
        x=(x*x)%m;
    }
    if( !x || i>=n){
        cout<<ans;
        return 0;
    }
    first=0;
    for(a=0;a<cnt[x];a++){
        first+=cx;
        cx=(cx*cx)%m;
    }
    ans-=first;
    i-=cnt[x];
    n-=cnt[x];
    ans=ans*(n/i);
    for(j=0;j<n%i;j++){
        ans+=cx;
        cx=(cx*cx)%m;
    }
    cout<<ans+first;
    return 0;
}
//1028C


Measured memory_bytes: 4392
#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

typedef struct { int parent; int left, right; } TREE;
TREE tree[30];

void preorder(int node)
{
	printf(" %d", node);
	if (tree[node].left  >= 0) preorder(tree[node].left);
	if (tree[node].right >= 0) preorder(tree[node].right);
}

void inorder(int node)
{
	if (tree[node].left  >= 0) inorder(tree[node].left);
	printf(" %d", node);
	if (tree[node].right >= 0) inorder(tree[node].right);
}

void postorder(int node)
{
	if (tree[node].left  >= 0) postorder(tree[node].left);
	if (tree[node].right >= 0) postorder(tree[node].right);
	printf(" %d", node);
}

int main()
{
	int n, i, id;
	int root, left, right;

	n = in();
	for (i = 0; i < n; i++) {
		id = in();
		tree[id].left  = left =  in();
		tree[id].right = right = in();
		if (tree[id].left  >= 0) tree[left ].parent = id+1;
		if (tree[id].right >= 0) tree[right].parent = id+1;
	}
	for (root = 0; root < n; root++) {
		if (tree[root].parent == 0) break;
	}

	puts("Preorder");
	preorder(root); putchar('\n');
	puts("Inorder");
	inorder(root); putchar('\n');
	puts("Postorder");
	postorder(root); putchar('\n');
	return 0;
}


Measured memory_bytes: 2084
N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]+[10**6]
A=[0]*(N+2)
A[0:2]=[0,1]
j=0
for i in range(N):
    if i+1 != a[j]:
        A[i+2]=(A[i]+A[i+1])%(10**9+7)
    else:
        j+=1
print(A[N+1])

Measured memory_bytes: 7848
#include<stdio.h>
int main(){
    int n;
    char s[10000];
    scanf("%d %s",&n,s);
    for(int i=0;s[i]!='\0';i++){
        s[i]+=n;
        if(s[i]>90){
            s[i]-=26;
        }
    }
    printf("%s\n",s);
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll inf = 2e9+7;
const int MAX_N = 5e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[MAX_N],fac[MAX_N];

template <class T = int> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%inf;}a=a*a%inf;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<MAX_N;i++){fac[i]=fac[i-1]*i%inf;}for(int i=0;i<MAX_N;i++){inv[i]=POW(fac[i],inf-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%inf)*inv[n-r]%inf;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

class UnionFind {
public:
	int par[MAX_N];
	int rank[MAX_N];
	ll sima[MAX_N];

	void init(int n);
	int find(int x);
	void unite(int x,int y);
	bool same(int x,int y);
};

void UnionFind::init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rank[i] = 0;
		sima[i] = 1;
	}
}

int UnionFind::find(int x) {
	if (par[x] == x) return x;
	else return par[x] = find(par[x]);
}

void UnionFind::unite(int x,int y) {
	x = find(x);
	y = find(y);
	if (rank[x] < rank[y]) par[x] = y;
	else {
		par[y] = x;
		if (rank[x] == rank[y]) rank[x]++;
	}
	if (x != y) sima[par[x]] = sima[x] + sima[y];
}

bool UnionFind::same(int x,int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

typedef struct 
{
	int from,to;
} edge;

UnionFind uf;

int main() {
	ll n = in(),m = in();
	edge E[m];
	REP (i,m) {
		E[i].from = in()-1;
		E[i].to = in()-1;
	}
	uf.init(n);
	ll ans = n * (n-1) / 2;
	ll Ans[m];
	Ans[m-1] = ans;
	for (int i = m-1;i > 0;i--) {
		int from,to;
		Ans[i-1] = Ans[i];
		// if (uf.sima[uf.find(E[i].from)] == 1) {
			from = E[i].from;
			to = E[i].to;
		// } else if (uf.sima[uf.find(E[i].to)] == 1) {
		// } else {
		// }
		if (uf.find(from) != uf.find(to)) {
			Ans[i-1]-=uf.sima[uf.find(to)]*uf.sima[uf.find(from)];
			uf.unite(from,to);
		}
	}
	REP (i,m) {
		cout << Ans[i] << endl;
	}
}

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

using namespace std;
int main() {
	int n;
	string s,ans;

	cin >> n>>s;
	if (n % 2 != 0) {
		cout << "No";
		return 0;
	}
	for (int i = 0; i < n / 2; i++) {
		//cout << s.at(i) << " " << s.at(i + (n / 2));
		if (s.at(i) != s.at(i + (n/2))) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

	return 0;
}

Measured memory_bytes: 3128
#include <iostream>

using namespace std;

int main() {
    int A,B,C;
    cin>>A>>B>>C;
    if (A==B && A!=C){
        cout<<"Yes"<<endl;
    }
    else if (B==C && B!=A ){
        cout<<"Yes"<<endl;
    }
    else if ( C==A && C!=B){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Control.Monad.ST
import Control.Monad.State
import Control.Monad.Primitive
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Data.Maybe
import Data.Bits
import Data.Ord
import Data.Ratio
import Data.Int
import Data.Char
import qualified Data.IntMap as IM
import qualified Data.ByteString.Char8 as BS
import qualified Data.Set as Set
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector.Generic as VG
import qualified Data.Vector.Generic.Mutable as VGM
import qualified Data.Sequence as Sq
import Data.Tuple
import Data.Function
import Text.Printf
import Debug.Trace
import Numeric

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)

listToTuple2 [a,b] = (a,b)
listToTuple3 [a,b,c] = (a,b,c)
listToTuple4 [a,b,c,d] = (a,b,c,d)
listToTuple5 [a,b,c,d,e] = (a,b,c,d,e)

readIntBS = fst . fromJust . BS.readInt

for = flip map

infixr 1 ?
(?) :: Bool -> (a,a) -> a
(?) b t = (if b then fst else snd) t

main :: IO ()
main = do
  
  [n,x] <- map read . words <$> getLine :: IO [Int64]
  xs <- map (abs . (+ (-x)) . fromIntegral . readIntBS) . BS.words <$> BS.getLine :: IO [Int64]

  
  print $ foldl1 gcd xs


Measured memory_bytes: 35196
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <utility>
#define left(p) (p<<1)
#define right(p) (p<<1|1)
using namespace std;
using ll = long long;
const int N = 2e5 + 5;
const ll mod = 998244353;
ll tree[N << 2];
ll mark[N << 2];
void build(const vector<ll> &a, int l, int r, int p) {
  if (l == r) {
    tree[p] = a[l];
  } else {
    int mid = (l + r) >> 1;
    build(a, l, mid, left(p));
    build(a, mid+1, r, right(p));
    tree[p] = (tree[left(p)] + tree[right(p)]) % mod;
  }
}

inline void push_down(int p, int len) {
  mark[left(p)] = (mark[left(p)] + mark[p]) % mod;
  mark[right(p)] = (mark[right(p)] +  mark[p]) % mod;
  tree[left(p)] = (tree[left(p)] + mark[p] * (len - len/2)) % mod;
  tree[right(p)] = (tree[right(p)] + mark[p] * (len/2)) % mod;
  mark[p] = 0;
}

void update(int l, int r, ll d, int p, int cl, int cr) {
  if (cl > r || cr < l)
    return;
  if (cl >= l && cr <= r) {
    tree[p] = (tree[p] +  (cr - cl + 1) * d) % mod;
    if (cr > cl) {
      mark[p] = (mark[p] + d) % mod;
    }
  } else {
    int mid = (cl + cr) >> 1;
    push_down(p, cr - cl + 1);
    update(l, r, d, left(p), cl, mid);
    update(l, r, d, right(p), mid + 1, cr);
    tree[p] = tree[left(p)] + tree[right(p)];
  }
}

ll query(int l, int r, int p, int cl, int cr) {
  if (cl > r || cr < l) return 0;
  if (cl >= l && cr <= r) return tree[p];

  int mid = (cl + cr) >> 1;
  push_down(p, cr - cl + 1);
  return (query(l, r, left(p), cl, mid) + query(l, r, right(p), mid + 1, cr)) % mod;
}

template <typename T>
void print_vec(const vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; ++i) {
    if (i > 0) cout << ' ';
    cout << v[i];
  }
  cout << '\n';
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> l(k), r(k);
  for (ll i = 0; i < k; ++i) {
    cin >> l[i] >> r[i];
  }
  vector<ll> dp(n + 1, 0ll);
  dp[1] = 1;
  build(dp, 1, n, 1);
  for (int i = 1; i <= n; ++i) {
    ll v = query(i, i, 1, 1, n);
    for (int j = 0; j < k; ++j) {
      update(i + l[j], i + r[j], v, 1, 1, n);
    }
  }
  cout << query(n, n, 1, 1, n) << '\n';

  return 0;
}


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

typedef complex<double> Point;

double cross(Point a, Point b){
    return (conj(a)*b).imag();
}

int main(){
    Point V[3], P;
    while(true){
        double x, y;
        for(int i=0; i<3; i++){
            if(!(cin >> x >> y))
                return 0;
            V[i] = {x, y};
        }
        cin >> x >> y;
        P = {x, y};
        
        int sum = 0;
        for(int i=0; i<3; i++){
            sum += cross(V[(i+1)%3]-V[i], (P-V[i])) > 0;
        }
        cout << (sum==0 || sum==3? "YES": "NO") << endl;
    }
    return 0;
}



Measured memory_bytes: 3204
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a, b;
    cin >> a >> b;
    cout << max(max(a+b,a-b),a*b);

    return 0;
}


Measured memory_bytes: 256
#include <numeric>
#include <stack>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <string>
#include <bitset>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <tuple>
#include <sstream>

using namespace std;

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<int, int>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

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

    int n;
    while (cin >> n) {
        vector<iip> a(n);
        forn(i, n) {
            cin >> a[i].first;
            a[i].second = i + 1;
        }

        sort(a.begin(), a.end());
        fore(ai, a) {
            cout << ai.second << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, k;
  char d;
  string s, u, x;
  in2(s, k);
  vector<string> t;
  rep(i, s.size()){
    u = s[i];
    b = 0;
    rep(j, t.size()){
      if(u == t[j])
        b++;
    }
    if(b == 0)
      t.pb(u);
  }
  rep(i, s.size() - 1){
    u = s[i];
    x = s[i + 1];
    u = u + x;
    b = 0;
    rep(j, t.size()){
      if(u == t[j])
        b++;
    }
    if(b == 0)
      t.pb(u);
  }
  rep(i, s.size() - 2){
    u = s[i];
    x = s[i + 1];
    u = u + x;
    x = s[i + 2];
    u = u + x;
    b = 0;
    rep(j, t.size()){
      if(u == t[j])
        b++;
    }
    if(b == 0)
      t.pb(u);
  }
  rep(i, s.size() - 3){
    u = s[i];
    x = s[i + 1];
    u = u + x;
    x = s[i + 2];
    u = u + x;
    x = s[i + 3];
    u = u + x;
    b = 0;
    rep(j, t.size()){
      if(u == t[j])
        b++;
    }
    if(b == 0)
      t.pb(u);
  }
  rep(i, s.size() - 4){
    u = s[i];
    x = s[i + 1];
    u = u + x;
    x = s[i + 2];
    u = u + x;
    x = s[i + 3];
    u = u + x;
    x = s[i + 4];
    u = u + x;
    b = 0;
    rep(j, t.size()){
      if(u == t[j])
        b++;
    }
    if(b == 0)
      t.pb(u);
  }
  sort(all(t));
  out(t[k - 1]);
  memi;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
using Num = long long;

Num gcd(Num m,Num n){
	if(n == 0)return m;
	return gcd(n,m%n);
}
Num lcm(Num m,Num n){
	return m / gcd(m,n) * n;
}
int main(){
	int n;
	Num ans = 1;
	cin >> n;
	for(int i=0;i<n;i++){
		Num t;
		cin >> t;
		ans = lcm(ans,t);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF : usize = 1000000007;

#[fastout]
fn main() {
  input! {
    n: usize,
  };

  let mut res = 0;
  for i in 1..=n {
    res += n / i * i * (n / i + 1) / 2;
  }
  
  println!("{}", res);
}

Measured memory_bytes: 2192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define rep(i, n) for (i = 0; i < n; i++)
using namespace std;
 
signed main() {
	int n, y;
	cin >> n >> y;
	
	for (int a = 0; a <= y / 10000; a++) {
		for (int b = 0; b <= y / 5000; b++) {
			int rem = y - a * 10000 - b * 5000;
			if (rem < 0) continue;
			int c = rem / 1000;
			if (a + b + c == n) {
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
		}
	}
	
	cout << "-1 -1 -1" << endl;
	return 0;
}

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


public class Test
{	
    public static void Main()
	{
	    int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

	    
	    if(n[0] > n[2]) Console.WriteLine("NO");
	    else if (n[0]+n[1] < n[2] )Console.WriteLine("NO");
	    else Console.WriteLine("YES");
	    
	} 
}

Measured memory_bytes: 13268
import sys
readline = sys.stdin.readline

N = readline().strip()
K = int(readline())

MM = [9, 81, 9 ** 3]

def comb(n, k):
    a = 1
    for i in range(k):
        a *= n - i
    
    for i in range(k):
        a = a // (i + 1)
    
    return a

def xxx(N, K):
    L = len(N)
    if L <= K - 1:
        return 0
    
    if K == 0:
        return 1
    
    a = comb(L - 1, K) * MM[K - 1]

    b = int(N[0]) - 1
    a += b * comb(L - 1, K - 1) * MM[K - 2] if K >= 2 else b
    
    _i = L
    for i in range(1, L):
        if N[i] != '0':
            _i = i
            break

    if _i < L:
        a += xxx(N[_i:], K - 1)
    elif K == 1:
        a += 1
    return a

print(xxx(N, K))

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

using namespace std;
int p[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int a[11];
string dp[12345];
string strMax(const string&a,const string&b)
{
    if (a.size()==b.size())
    {
        if (a>b)
            return a;
        else 
            return b;
    }else
    {
        if (a.size()>b.size())
            return a;
        else 
            return b;
    } 
}
int main()
{
    int n,m;
    cin >> n >> m;
    for (int i=1;i<=m;i++)
    {
        cin >> a[i];
    }
    fill(dp,dp+n,string(""));
    dp[0]="p";
    for (int i=0;i<=n;i++)
    {
        for (int j=1;j<=m;j++)
        {
            dp[i+p[a[j]]]=strMax(dp[i]+char(a[j]+48),dp[i+p[a[j]]]);
        }
        //cout <<i<<" "<< dp[i] << endl;
    }
    dp[n].erase(dp[n].begin());
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 43776
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int cnt = 0;
	for(int i = 0; i < n - 2; ++i) {
		if(s[i] != 'A') continue;
		if(s[i + 1] != 'B') continue;
		if(s[i + 2] != 'C') continue;
		cnt++;
	}
	cout << cnt << '\n';
	return 0;
}

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

int main() {
	std::string s;
	int k;

	std::cin >> s >> k;
	for (size_t i = 0; i < s.size() && k > 0; ++i) {
		if (s[i] != 'a' && k >= 'z' - s[i] + 1) {
			k -= 'z' - s[i] + 1;
			s[i] = 'a';
		}

		if (i == s.size() - 1)
			s[i] = 'a' + (s[i] - 'a' + k) % ('z' - 'a' + 1);
	}

	std::cout << s << std::endl;
}

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

int main()
{
    int N;
    double v,g=9.8,t;
    while(cin >> v){
        t=v/g;
        for(N=1 ;; N++){
            if(N*5-5 > 1.0/2.0*g*t*t){
                break;
            }
        }
        cout << N << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char str[210];
int v[210];
int main(){
	int T;scanf("%d",&T);
	while(T--){
		int n;
		scanf("%d%s",&n,str);
		int a=strlen(str);
		int ret=0;
		for(int i=0;i<=a;i++){
			int B=0;int G=0;
			for(int j=0;j<a;j++){
				v[j]=0;
				if(str[j]=='B')B++;
				else G++;
			}
			int at=0;
			int t=0;
			int sz=a;
			while(B&&G){
				int c=n%sz;
				if(i==t){c++;}
				if(c==0)c+=sz;
				while(1){
					if(!v[at]){c--;if(c==0)break;}
					at=(at+1)%a;
				}
				v[at]=1;
				if(str[at]=='B')B--;
				else G--;
				sz--;
				t++;
			}
			ret=max(ret,B);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1028
N = int(input())
F = []
for _ in range(N):
    F.append(int(''.join(input().split()), 2))
P = []
for _ in range(N):
    P.append(list(map(int, input().split())))

ans = -10000000000
for i in range(1, 2 ** 10):
    sum = 0
    for j, f in enumerate(F):
        cover = i & f
        cnt = 0
        while cover != 0:
            if cover % 2 == 1:
                cnt += 1
            cover //= 2
        sum += P[j][cnt]
    ans = max(sum, ans)

print(ans)


Measured memory_bytes: 42732
#include<stdio.h>
#define MAX 501

int main(void)
{
  int n,c[MAX],s[MAX],f[MAX],i,j,ans=0,r;
  scanf("%d",&n);
  for(i=0;i<n-1;i++)
    {
      scanf("%d %d %d",&c[i],&s[i],&f[i]);
    }
  for(i=0;i<n-1;i++)
    {
      ans = 0;
      for(j=i;j<n-1;j++)
	{
	  if(ans <= s[j])
	    {
	      ans = s[j] + c[j];
	    }
	  else
	    {
	      if((r = (ans % f[j])) != 0)
		{
		  ans = ans + c[j] + f[j] -r;
		}
	      else
		{
		  ans += c[j];
		}
	    }
	}
      printf("%d\n",ans);
    }
  printf("0\n");
  return 0;
}


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

namespace B_Uneven_Numbers
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int counter = 0;
            for(int i = 1; i <= N; i++)
            {
                if (i.ToString().Length % 2 != 0)
                {
                    counter++;
                }
            }
            Console.Write(counter);
        }
    }
}


Measured memory_bytes: 15188
#include <string.h>
#include <stdio.h>

int main()
{   
    char s[101];
    long long k;
    scanf("%s %lld",s,&k);
    int l=strlen(s);
    if(l==1){
        printf("%lld",k/2);
        return 0;
    }
    int inner=0,cnt=0,uni=0;
    for(int i=0;i<l;i++){
        if(s[i]==s[i+1]){
            cnt++;
        }else if(cnt){
            inner+=(cnt+1)/2;
            if(cnt==l-1)uni=1;
            cnt=0;
        }
    }
    if(uni==1){
        printf("%lld",l*k/2);
        return 0;
    }
    int head=1,tail=1,chk=0;
    long long ans=inner*k;
    if(s[0]==s[l-1]){
        chk=2;
        if(s[0]==s[1]){
            int i=0;
            while(s[i]==s[i+1]){
                head++;
                i++;
            }
        }
        if(s[l-1]==s[l-2]){
            int i=0;
            while(s[l-(1+i)]==s[l-(2+i)]){
                tail++;
                i++;
            }
        }
    }
        
    if(chk==2&&head%2==1&&tail%2==1)ans+=(k-1);
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 200005;

#define getchar getchar_unlocked
#define putchar putchar_unlocked

inline int in() {
    int n = 0; short c;
    while ((c = getchar()) >= '0') n = n * 10 + c - '0';
    return n;
}

vector<int> vec[MAX_N];
int id[MAX_N];

int main()
{
    int n = in(), K = in(), T = in();
    rep(i,T){
        int l = in(),r = in();
        id[i] = in();
        vec[l-1].pb(T+i);
        vec[r].pb(i);
    }
    set<P> st = {P(-1,INF), P(T,INF)};
    int ans = 0, cnt = 0, sm = 0;
    rep(i,n){
        each(val,vec[i]){
            if(val >= T){
                cnt++;
                val -= T;
                auto it = st.lower_bound(P(val,INF));
                int nx = it->se;
                --it;
                int prv = it->se;
                if(nx-prv==1) sm--;
                if(nx == id[val]+1) sm++;
                if(prv == id[val]-1) sm++;
                st.insert(P(val,id[val]));
            }else{
                cnt--;
                auto it = st.lower_bound(P(val,INF));
                int nx = it->se;
                --it, --it;
                int prv = it->se;
                ++it, st.erase(it);
                if(nx-id[val]==1) sm--;
                if(id[val]-prv==1) sm--;
                if(nx-prv==1) sm++;
            }
        }
        if(cnt == K && sm == K-1) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 20624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
	int A,B,C,X;
	scanf("%d %d %d %d",&A,&B,&C,&X);
	int count = 0;
	int money = 0;
	if(500*A + 100*B +  50*C < X){
		printf("%d\n",count);
		return 0;
	}

	for(int i=0; i<=A; i++){
		money += 500*i;
		for(int j=0; j<=B; j++){
			money += 100*j;
			for(int k=0; k<=C; k++){
				money += 50*k;
				if(money == X){
					count++;
				}
				money -= 50*k;
			}
		money -= 100*j;
		}
	money -= 500*i;
	}
	printf("%d\n",count);
	
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    string ans = "YES";
    rep(i, n - 1) {
        if(a[i] == a[i + 1]) ans = "NO";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,
        bs:[i64;n-1]
    }

    let mut ass = vec![0i64;n];
    ass[0] = bs[0];
    for i in 1..n-1{
        ass[i] = min(bs[i-1], bs[i]);
    }
    ass[n-1] = bs[n-2];
    let ans = ass.iter().sum::<i64>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
L,R = map(int,input().split())

min = 2019
if R-L >= 2019:
    print(0)
    exit()
else:
    for i in range(L,R):
        for j in range(1,R-i+1):
            if min > (i * (i+j) % 2019):
                min = (i * (i+j) % 2019)
print(min)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string S;
	getline(cin,S);
		if(S.at(0)=='R'&&S.at(1)=='R'&&S.at(2)=='R')
		cout<<"3";
		else if((S.at(0)=='R'&&S.at(1)=='R')||(S.at(1)=='R'&&S.at(2)=='R'))
		cout<<"2";
		else if(S.at(0)=='R'||S.at(1)=='R'||S.at(2)=='R')
		cout<<"1";
		else
		cout<<"0";
return 0;
}

Measured memory_bytes: 3552
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

vll score(v2ll& s, vll& c, vll t, int D) {
    ll ans = 0;
    vll vans(D + 1);
    vint last(27, 0);
    REP(d, 1, D + 1) {
        ans += s[d][t[d - 1]];
        last[t[d - 1]] = d;
        REP(i, 1, 27)
            ans -= c[i] * (ll(d) - ll(last[i]));
        vans[d] = ans;
    }
    return vans;
    
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int D;
    cin >> D;
    vll c(27);
    rep(i, 26) cin >> c[i + 1];

    v2ll s(D + 1, vll(27));
    rep(i, D) {
        rep(j, 26) cin >> s[i + 1][j + 1];
    }

    vll t(D);
    rep(i, D) cin >> t[i];
    auto ans = score(s, c, t, D);
    rep(i, D)
        cout << ans[i + 1] << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    long long  ans=0;
    int len=s.size()-1;
    long a,b;
    for(int i=0; i<(1<<(len)); ++i){
        a=0;
        b=s[0]-'0';
        for(int j=0; j<len; ++j){
            if ((i>>j)%2 ==0) b=b*10+s[j+1]-'0';
            else{
                a+=b;
                b=s[j+1]-'0';
            }
        }
        ans+=a+b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import fractions

a, b, c, d = list(map(int, input().split()))

c_n = (b // c) - ((a - 1) // c)
d_n = (b // d) - ((a - 1) // d)

lcm = (c * d) // fractions.gcd(c, d)
lcm_n = (b // lcm) - ((a - 1) // lcm)

ans = (b - a + 1) - (c_n + d_n - lcm_n)
print(ans)


Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  ll x;
  cin >> x;
  ll a = 100;
  FOR(i,0,10000000){
    a = a+a/100;
    if(a>=x){
      cout << i + 1 << endl;
      return 0;
    }
  }



}


Measured memory_bytes: 3592