akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n, k;
    cin >> n >> k;
    cout << n - k + 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
vector<pii>g[123456];
ll dist[123445];
void dfs(int s){
    for(auto x: g[s]){
        if(dist[x.first] == -1){
            dist[x.first] = dist[s] + x.second;
            dfs(x.first);
        }
    }
}
int main(){
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        g[a].emplace_back(b,c);
        g[b].emplace_back(a,c);
    }
    memset(dist,-1,sizeof(dist));
    show(n);
    dist[0] = 0;
    dfs(0);
    rep(i,n){
        show(dist[i]);
        cout << dist[i] % 2 << endl;
    }
}

Measured memory_bytes: 8704
#define f(I)(p[I]+h[I]*(h[I]-2*h[i]))
long C,h[2<<17],p[2<<17],X,a;
P[2<<17];
s,t,x,y;
main(i){
	for(scanf("%*d%ld%d",&C,h);~scanf("%d",&a);P[++t]=i-1){
		for(h[i]=a;X=f(P[s]),s<t&&X>=f(P[s+1]);s++);
		for(p[i++]=X+=a*a+C;s<t&&(h[y=P[t]]-h[x=P[t-1]])*(f(y)-f(i-1))>(a-h[y])*(f(x)-f(y));t--);
	}
	printf("%ld",X);
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
#define vcin(a)                          \
    for (int i = 0; i < (a).size(); i++) \
        cin >> (a)[i];

int main()
{
    int N, K;
    cin >> N >> K;
    vll a(N), s(N+1);
    rep(i, N)
    {
        cin >> a[i];
    }
    partial_sum(a.begin(),a.end(), s.begin()+1);
    unordered_map<ll, int> sums;
    vll sumsInt;
    for (size_t i = 0; i < N+1; i++)
    {
        for (size_t j = i + 1; j < N+1; j++)
        {
            sums[(s[j] - s[i])]++;
            sumsInt.push_back(s[j]-s[i]);
        }
//        sums[s[i]]++;
//        sumsInt.push_back(s[i]);
    }
//    sumsInt.push_back(s.back());
//    sums[(s.back())]++;
    sort(all(sumsInt));
    bitset<60> ans = 0;
    for (int digit = 60; digit >= 0; digit--)
    {
        int cnt = 0;
        for (auto &&i : sums)
        {
            if ((i.first & (1LL<<digit)))
                cnt += i.second;
        }
        if (cnt >= K)
        {
            for (auto &&i : sums)
            {
                if (!(i.first & (1LL<<digit)))
                {
                    i.second=0;
                }
            }

            ans[digit] = 1;
        }
    }
    cout << ans.to_ullong() << endl;
    return 0;
}


Measured memory_bytes: 26924
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b;
  cin >> a >> b;
  pr(max(0LL,a-b*2));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

typedef long long int ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vl;

#define F first
#define S second
#define endl '\n'
#define LEN(x) int((x).size())
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(a, b) for(int a = 0; (a) < (b); (a)++)
#define debug(x) cerr << #x << " = " << x << '\n'

int main() {
	ios_base::sync_with_stdio(0), cin.tie(NULL);
	
	string s;
	cin >> s;
	
	if(s == "SSS") {
		cout << 0 << endl;
	} else if(s == "RSS" or s == "SRS" or s == "SSR" or s == "RSR") {
		cout << 1 << endl;
	} else if(s == "RRR"){
		cout << 3 << endl;
	} else {
		cout << 2 << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(void){
 vector<int> wa(3);
  for(int i=0;i<3;i++){
    cin>>wa.at(i);
  }
  sort(wa.begin(),wa.end());
  if((wa.at(0)==5&&wa.at(1)==5)&&wa.at(2)==7)
    cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b, k, cnt=0, i=1, q[1000];

    scanf("%d%d%d", &a, &b, &k);

    for(i=1;i<=100;i++){
        if(a%i==0 && b%i==0){
            q[cnt]=i;
            cnt++;
        }
    }
        

    
    printf("%d\n", q[cnt-k]);
    return 0;
}

    


Measured memory_bytes: 128
import itertools

RANK_NUM = 13
n = int(input())
data = [input() for _ in range(n)]
data_list = [i.split() for i in data]
data_tuple = [(i[0], i[1]) for i in data_list]

card_all = itertools.product(['S', 'H', 'C', 'D'], [str(i) for i in range(1, RANK_NUM + 1)])
lost_card = [card for card in card_all if not card in data_tuple]
for output in lost_card:
    print(' '.join(output))


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

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

int main()
{
    ll n;
    cin >> n;
    ll max = 1000000000000000000;
    ll ans = 1;
    vector<ll> v(n);
    rep(i, n) {
        cin >> v[i];
        if (v[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    rep(i, n) {
        ll tmp;
        tmp = ans * v[i];
        ll x = tmp / ans;
        if (v[i] != x) {
            cout << -1 << endl;
            return 0;
        }
        ans *= v[i];
        if (ans > max) {
            cout << -1 << endl;
            return 0;
        }
    }
    if (ans > max) {
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll x = il();

  ll ans = 1;
  if (x <= 599) ans = 8;
  else if (x <= 799) ans = 7;
  else if (x <= 999) ans = 6;
  else if (x <= 1199) ans = 5;
  else if (x <= 1399) ans = 4;
  else if (x <= 1599) ans = 3;
  else if (x <= 1799) ans = 2;

cout << ans << endl;


  
}

Measured memory_bytes: 3688
import math


def combi(a, b):
    ans = math.factorial(a) / (math.factorial(a - b) * math.factorial(b))
    return ans


N, P = map(int, input().split())
A = list(map(int, input().split()))

even = 0
odd = 0

for i in range(N):
    if A[i] % 2 == 0:
        even += 1
    else:
        odd += 1

even_n = 0
for i in range(0, even + 1):
    even_n += combi(even, i)
odd_n = 0
if P == 1:
    for i in range(1, odd + 1, 2):
        odd_n += combi(odd, i)
else:
    for i in range(0, odd + 1, 2):
        odd_n += combi(odd, i)

print(int(even_n * odd_n))


Measured memory_bytes: 3064
#include <algorithm>
#include <functional>
#include <numeric>
#include <iterator>
#include <iostream>
#include <vector>

int main()
{
    int N, M;
    std::vector<int> A;

    std::cin >> N >> M;
    A.reserve(N);
    std::copy_n(std::istream_iterator<int>{std::cin}, N, std::back_inserter(A));

    int sum_A = std::accumulate(A.cbegin(), A.cend(), 0);

    auto mth_iter = A.begin() + M - 1;
    std::nth_element(A.begin(), mth_iter, A.end(),
        std::greater<int>{});

    if (*mth_iter * 4 * M < sum_A) {
        std::cout << "No" << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, m, s, t = map(int,input().split())
C = [list(map(int,input().split())) for i in range(m)]
 
s -= 1
t -= 1
 
# O((V + E)log(V))
# Cは [[スタート頂点, ゴール頂点, 重み], ...] のリスト
 
# M = [[] for i in range(n)]
# for i in range(len(C)):
#     M[C[i][0]-1].append([C[i][1]-1, C[i][2]])  # 無向グラフなら両方追加
#     M[C[i][1]-1].append([C[i][0]-1, C[i][2]])  # 無向グラフなら両方追加
 
# N = [[] for i in range(n)]
# for i in range(len(C)):
#     N[C[i][0]-1].append([C[i][1]-1, C[i][3]])  # 無向グラフなら両方追加
#     N[C[i][1]-1].append([C[i][0]-1, C[i][3]])  # 無向グラフなら両方追加
 
M = [[] for i in range(n)]
for i in range(len(C)):
    M[C[i][0]-1].append([C[i][1]-1, C[i][2], C[i][3]])  # 無向グラフなら両方追加
    M[C[i][1]-1].append([C[i][0]-1, C[i][2], C[i][3]])  # 無向グラフなら両方追加
 
import heapq

def dijkstra(a, in_connect_list, v, money_kind): 
    out_shortest_list = [10**15 for i in range(v)]
    out_shortest_list[a] = 0
    searching_list = [a]
    
    while searching_list != []:
        new_search_list = []
        for i in searching_list:
            for j in in_connect_list[i]:
                c = j[0]
                p = j[money_kind] 
                if out_shortest_list[c] > p + out_shortest_list[i]:
                    out_shortest_list[c] = p + out_shortest_list[i]
                    new_search_list.append(c)
        searching_list = list(set(new_search_list))  # 元コードから変更
    return out_shortest_list
 
# Ds, _ = dijkstra(s, M)
# Dt, _ = dijkstra(t, N)
 
Ds = dijkstra(s, M, n, 1)
Dt = dijkstra(t, M, n, 2)
 
ANS = [0] * n
 
# print(Ds,Dt)
 
ans = 10**16
for i in range(n-1, -1, -1):
    ans = min(ans, Ds[i] + Dt[i])
    ANS[i] = ans
 
for i in range(n):
    print(10**15 - ANS[i])

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

int main()
{
long long int i,j,a[3],temp;
for(i=0;i<3;i++)
{
    cin>>a[i];
}

for(j=0;j<3;j++)
 for(i=0;i<2;i++)
{
    if(a[i]>a[i+1])
    {
        temp=a[i];
        a[i]=a[i+1];
        a[i+1]=temp;
    }

}

cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;

}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  vector<int> a(N), b(N), c(N);
  for (int i = 0; i < N; i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<vector<int>> dp(401, vector<int>(401, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++){
    for (int j = 400; j >= a[i]; j--){
      for (int k = 400; k >= b[i]; k--){
        dp[j][k] = min(dp[j][k], dp[j - a[i]][k - b[i]] + c[i]);
      }
    }
  }
  int ans = INF;
  for (int i = 1; i <= 400; i++){
    if (Ma * i <= 400 && Mb * i <= 400){
      ans = min(ans, dp[Ma * i][Mb * i]);
    }
  }
  if (ans == INF){
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 896
#include<stdio.h>

int main(void)
{
        int d = 0;
        int i = 0;
        int f = 0;
        int j = 1;


        while(scanf("%d", &d) != EOF)
        {
                for( i = 0 ; i < 600; i += d)
                {
                        f = f + (( (600 - (j*d)) * (600 - (j*d)) ) * d);
                        j++;
                }
                printf("%d\n",f);
                f = 0;
                j = 1;
        }

        return 0;
}

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

char s[110];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	int ans=0;
	for(int i=0;i<n/2;i++)if(s[i]!=s[n-1-i])ans++;
	printf("%d",ans);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i;
  int j;
  int change;
  int num = 0;
  int count = 0;
  int flag = 1;
  int *data;

scanf("%d",&num);
data = (int *)malloc(sizeof(int)*num);

for(j = 0;j < num;j++){
  scanf("%d",&data[j]);
}

  while(flag){
    flag = 0;

for(i = num - 1;i > 0;i--){
  if(data[i] < data[i - 1]){
    change = data[i];
    data[i] = data[i - 1];
    data[i - 1] = change;
    flag = 1;
    count++;
  }
  }
}

for(i = 0;i < num-1;i++){
  printf("%d ",data[i]);
}
printf("%d",data[num - 1]);
printf("\n");
printf("%d",count);
printf("\n");
return 0;
}



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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, max_h=0, c=0;
  cin >> n;
  vecll h(n);
  bool up=false;
  forll(i, 0, n){
	cin >> h[i];
	max_h = max(max_h, h[i]);
  }
  forll(i, 0, max_h){
	up = false;
	forll(j, 0, n){
	  if(up==true && h[j] <= i)
		up = false;
	  else if (up == false && h[j]>i){
		up = true;
		c++;
	  }
	}
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a<b)
    {
        if(b<c)
        {
            cout << "Yes" << endl;
            return 0;
        }
        else
        {
            cout << "No" << endl;
            return 0;
        }
    }
    else
    {
        cout << "No" << endl;
        return 0;
    }

}



Measured memory_bytes: 3112
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	if(n == 1 && b != a)cout << 0 << endl;
	else if(b < a)cout << 0 << endl;
	else{
		
		cout << b*(n-1) + a - (b + a*(n-1)) + 1  << endl;
	}
  return 0;
}


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

using namespace std;

using ll_t = long long;

void process(ll_t n) {
  string s;
  while(n) {
    ll_t d = (n - 1)%26;
    s.insert(s.begin(), 'a' + d);
    n = (n - 1)/26;
  }
  cout << s << "\n";
}

int main() {
  ll_t n;
  cin >> n;
  
  process(n);
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;cin>>N;
    int A[2][N];
    int sum=0;
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            cin>>A[i][j];
            if(i==0){
                sum+=A[i][j];
            }
        }
    }
    sum-=A[0][0];
    int ans=A[0][0]+A[1][N-1];
    int M=sum;
    for(int i=N-1;i>=1;i--){
        sum-=A[0][i];
        sum+=A[1][i-1];
        M=max(M,sum);
    }
    ans+=M;
    cout<<ans<<endl;
    return 0;
}


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

signed main() {
  uint64_t n;
  cin >> n;
  cout << n*n*n << endl;
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  string S; cin>>S;
  S = "%" + S;
  int ans = 0;
  REP(i,N) {
    if(S[i] != S[i+1]) ans++;

  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int main()
{
    double t;
    int a,b,sum=0,c=1;
    cin>>a>>b>>t;
    t+=0.5;
    while(t-a>0){
        t-=a;
        sum+=b;
    }
    cout<<sum;
    return 0;
}


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

int main(){
    int N;cin>>N;
    int p[N],a[N];
    for(int i=0;i<N;i++){
        cin>>p[i];
        a[i]=p[i];
    }

    sort(p,p+N);
    int count=0;
    for(int i=0;i<N;i++){
        if(a[i]!=p[i])count++;
    }


    if(count==2||count==0)cout<<"YES";
    else cout<<"NO";

}

Measured memory_bytes: 3636
import sys
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[sys.maxsize]*n
dp[0]=0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            dp[j]=min(dp[j], dp[i]+ abs(l[i]-l[j]))


print(dp[-1])
    
    


Measured memory_bytes: 52448
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
ll res[10];

int main(int argc, char const* argv[])
{
  ll h, w;
  int n;
  cin >> h >> w >> n;
  vector<ll> a, b;
  set<Pll> st;
  for(int i = 0; i < n; i++){
    ll x, y;
    cin >> x >> y;
    x--; y--;
    a.pb(x);
    b.pb(y);
    st.insert(mk(x, y));
  }
  for(int i = 0; i < n; i++){
    for(ll j = a[i] - 2; j <= a[i]; j++){
      for(ll k = b[i] - 2; k <= b[i]; k++){
        if(j < 0 || j + 2 >= h || k < 0 || k + 2 >= w)continue;
        int tmp = 0;
        for(ll l = j; l < j + 3; l++){
          for(ll m = k; m < k + 3; m++){
            if(st.find(mk(l, m)) != st.end())tmp++;
          }
        }
        res[tmp]++;
      }
    }
  }
  ll all = (h - 2) * (w - 2);
  for(int i = 1; i < 10; i++){
    res[i] = res[i] / i;
    all -= res[i];
  }
  cout << all << endl;
  for(int i = 1; i < 10; i++){
    cout << res[i] << endl;
  }
	return 0;
}


Measured memory_bytes: 10088
#include <bits/stdc++.h>
using namespace std;
int N, M, K, ans, qpt, pt, pt2;
string s, temp, w;
string we[500000], ww[500000];
void search()
{
	if(s[s.size() - 1] == '*')
	{
		pt = lower_bound(ww, ww + N, temp) - ww;
		temp.push_back('z' + 1);
		pt2 = lower_bound(ww, ww + N, temp) - ww;
		ans += pt2 - pt;
		temp.erase(temp.end() - 1);
	}			
	else if(s[0] == '*')
	{
		reverse(temp.begin(), temp.end());
		pt = lower_bound(we, we + N, temp) - we;
		temp.push_back('z' + 1);
		pt2 = lower_bound(we, we + N, temp) - we;
		ans += pt2 - pt;
		temp.erase(temp.end() - 1);
		reverse(temp.begin(), temp.end());
	}
	else
	{
		pt = lower_bound(ww, ww + N, temp) - ww;
		if(ww[pt] == temp)
			ans++;
	}
}
int main()
{
	cin >> N >> M;
	for(int i = 0; i < N; i++)
	{
		cin >> w;
		ww[i] = w;
		reverse(w.begin(), w.end());
		we[i] = w;
	}
	sort(ww, ww + N);
	sort(we, we + N);
	for(int i = 0; i < M; i++)
	{
		cin >> s;
		qpt = -1;
		ans = 0;
		temp.clear();
		for(int j = 0; j < s.size(); j++)
		{
			if(s[j] != '*')
				temp.push_back(s[j]);
			if(s[j] == '?')
				qpt = temp.size() - 1;
		}
		if(qpt >= 0)
		{
			for(char j = 'a'; j <= 'z'; j++)
			{
				temp[qpt] = j;
				search();
			}
		}
		else
		{
			search();
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 18704
#include<iostream>
#include<algorithm>
using namespace std;
int bubbleSort(int a[], int n){
    bool flg=true;
    int c=0;
    while(flg){
        flg=false;
        for(int j=n-1;j>=1;j--){
            if(a[j]<a[j-1]){
                swap(a[j], a[j-1]);
                c++;
                flg=true;
            }
        }
    }
    return c;
}
int main(){
    int N;
    int A[110];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int cnt=bubbleSort(A, N);
    for(int i=0;i<N;i++){
        cout<<A[i];
        if(i<N-1){
            cout<<' ';
        }else{
            cout<<endl;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    vector<int> a(n);
    int ans = Inf;
    rep (i, n) {
      cin >> a[i];
    }
    FOR (i, -100, 101) {
      int sum = 0;
      rep (j, n) {
        sum += (i - a[j]) * (i - a[j]);
      }
      ans = min(ans, sum);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 896
/*C - Average Length*/

#include <bits/stdc++.h>

using namespace std;

int factorial(int n);

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

	double dist = 0.0;
	int fact;
	int tam;
	int aux;
	
	cin >> tam;
	
	vector < pair <double, double > > puntos(tam);
	vector <int> path(tam);

	for (int i = 0; i < tam; ++i)
		cin >> puntos[i].first >> puntos[i].second;
	
	fact = factorial(tam);
	
	for (int i = 0; i < tam; ++i){
		path[i] = i;
	}
	
	double x1, x2, y1, y2;
	int pos;

	for (int j = 0; j < fact ; ++j)
	{
		for (int i = 0; i < tam - 1; ++i)
		{
			pos = path[i];
			x1 = puntos[pos].first;
			y1 = puntos[pos].second;		
			
			pos = path[i + 1];
			x2 = puntos[pos].first;
			y2 = puntos[pos].second;

			dist += sqrt((x1 - x2)* (x1 - x2) + (y1 - y2) * (y1 - y2));
		}

		next_permutation(path.begin(), path.end());
	}

	dist /= fact;

	cout << fixed << setprecision(10) << dist;

	return 0;
}

int factorial(int n){

	if(n == 1){
		return 1;
	}
	else{
		return factorial(n - 1) * n;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	int f = 0, s = 0;
	for(int i = 0; i < 3; i++){
		cin >> a[i];
		if(a[i] == 5){
			f++;
			}
		else if(a[i] == 7){
			s++;
			}
		}

		if(f == 2 && s == 1){
			cout << "YES";
			}
		else{
			cout << "NO";
			}
		}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18;

int a[1000001], b[1000001], c[1000001];
int d[1000001];
signed main(){
	int n, m;
	scanf("%lld%lld", &n, &m);
	fill(d, d+1000001, INF);
	for(int i = 0;i < m;i++){
		scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
		c[i] = -c[i];
	}
	
	d[1] = 0;
	int f = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			if(d[a[j]] == INF)continue;
			if(d[b[j]] > d[a[j]]+c[j]){
				d[b[j]] = d[a[j]]+c[j];
				if(i == n-1 && b[j] == n)f = 1;
			}
		}
	}
	
	if(f)printf("inf\n");
	else printf("%lld\n", -d[n]);
	return 0;
}


Measured memory_bytes: 12544
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int V = sc.nextInt();
    int B = sc.nextInt();
    int W = sc.nextInt();
    int T = sc.nextInt();
    int a=B-A;
    if(a<=0){a=a*-1;}
    if((long)(V-W)*T >= a || a == 0) {
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}


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

using namespace std;
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
long long a,b;
long long f(long long a,long long b)
{
	if (a%2&&b%2) if ((b-a)/2%2) return a^1;else return a;
	if (a%2==0&&b%2) if ((b-a+1)/2%2) return 1;else return 0;
	if (a%2&&b%2==0) if ((b-a-1)/2%2) return a^b^1;else return a^b;
	if ((b-a)/2%2) return b^1;else return b;
}
int main()
{
	cin>>a>>b;
	cout<<f(a,b)<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
abc = [list(map(int, input().split())) for i in range(n)]
dp = [[0]*3 for i in range(n+1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if (j == k):
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])
result = max(dp[n][0], dp[n][1], dp[n][2])
print(result)

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

using namespace std;
using ll = long long;

const long long INF = 1LL << 60;
const int NMAX = 100000;
int main() {
    #ifdef MYLOCAL
        ifstream in("input.txt");
        cin.rdbuf(in.rdbuf());
    #endif

    int n; cin >> n;
    int a[n][3] = {};
    int dp[n + 1][3] = {};
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }


    int res = 0;
    for (int j = 0; j < 3; ++j) {
        res = max(res, dp[n][j]);
    }
    cout << res << endl;
}

Measured memory_bytes: 2560
using System;

namespace Atcoder0121_2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            double a = double.Parse(input[0] + input[1]);
            int ai = (int)a;
            double heiho = Math.Sqrt(a);
            int heihoi = (int)heiho;
            if (ai == heihoi * heihoi){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  if(a[0] == b[2] && b[0] == a[2] && a[1] == b[1]) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define LB lower_bound
#define UP upper_bound
#define INF 999999999999
const double PI = acos(-1.0);
int N;
ll M,H;
ll h[100001];
ll mx[100001];
ll ans;
ll u,v;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> N >> M;
    rep2(i,1,N){
        cin >> h[i];
        mx[i] = 0;
    }

    rep1(i,0,M){
        cin >> u >> v;
        mx[u] = max(mx[u],h[v]);
        mx[v] = max(mx[v],h[u]);
    }

    rep2(i,1,N)
        if(mx[i] < h[i]) ans++;
    cout << ans;
    return 0;     
}

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

int main(){
  int x;
  cin >> x;
  int wari500,wari5;
  wari500 = x / 500;
  int amari500 = x % 500;
  wari5 = amari500 / 5;
  
  cout << wari500 * 1000 + wari5 * 5 << endl;
}

Measured memory_bytes: 256
//In the name of ALLAH
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
using namespace std;

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

const long long maxn = 2e5 + 5;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

int a, n, b;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> a >> b;
	if(abs(a - b) % 2 == 0)
		return cout << "Alice" << endl, 0;
	cout << "Borys" << endl;	
	return 0;
}


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

int main(){
    string s;
    string A;
    cin >>s;

    size_t size = s.length();
    A=s[0];

    for(int i=1;i<size;++i){
        if(i%2==0) A=A+s[i];
    }
    cout <<A<<endl;
    return 0;
}

Measured memory_bytes: 3776
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y =  sc.nextInt();
        int sum;
        int A;

        //int val = X;
        //int valLen = String.valueOf( val ).length();

        sum = (X-1) % (Y-1);
        A = (X-1) / (Y-1);
        if(sum > 0){
            A++;
        }

        System.out.println(A);


    }
}


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

int main() {
	vector<int> a,b;
	int n,k;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> k;
		a.push_back(k);
		b.push_back(k);
	}
	sort(b.begin(),b.end());
	if(a==b) {cout << "YES\n";return 0;}
	for(int i=0;i<n;i++) {
		for(int j=i+1;j<n;j++) {
			swap(a[i],a[j]);
			if(a==b) {cout << "YES\n"; return 0;}
			else swap(a[i],a[j]);
		}
	}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
#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 INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)
int main() {
	int n; cin >> n;
	vector<ll> a(n); rep(i, n) cin >> a[i];
	ll ans = 0;
	rep(i, 60) {
		ll x = 0;
		rep(j, n) if (a[j]>>i & 1) x++;
		ll temp = x * (n-x) % MOD;
		rep(j, i) temp = temp * 2 % MOD;
		ans += temp;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>

using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PI;


void solve()
{
	int N;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	int sum = 0;
	for (int i = 0; i < N - 1; ++i)
	{
		sum += L[i];
	}
	if (L[N - 1] < sum)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int u = 0; u <= c; u++) {
				if ((500 * i + 100 * j + 50 * u) == x) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <functional>

const int INF = 1001001000;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

typedef pair<int,int> P;

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

int main(){

  int a,b,c,d;

  cin >> a >> b >> c >> d;

  if( a+b > c+d){
    cout << "Left" << endl;
  }else if( a+b == c+ d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
  return 0;


}


Measured memory_bytes: 256
def solve():
  H, W, K = map(int, input().split())
  CC = [[0 for _ in range(W)]  for _ in range(H)]
  for i in range(H):
    for j,s in enumerate(input()):
      if s =='#':
        CC[i][j] = 1
  jkn = 0
  for i in range(2**H):
    for j in range(2**W):
      cnt = 0
      hh = format(i,'b')
      ww = format(j,'b')
      for k in range(len(hh)):
        if hh[len(hh)-k-1]=='1':
          for l in range(len(ww)):
            if ww[len(ww)-l-1]=='1':
              if CC[k][l]==1:
                cnt+=1
      if cnt==K:
        jkn += 1
  print(jkn)
solve()

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)


int main()
{
	string s;
	cin>>s;
	int y=0,m=0,d=0;
	int c=10;
	ffor(i,0,4)
	{
        y=y*c+s[i]-48;
        //c=c*10;
	}
	c=10;
	ffor(i,5,7)
	{
		m=m*c+s[i]-48;
        //c=c*10;
	}
	c=10;
	ffor(i,8,10)
	{
		d=d*c+s[i]-48;
        //c=c*10;
	}
    //cout<<y<<" "<<m<<" "<<d<<endl;
	if(y<2019)
	{
		cout<<"Heisei";
		return 0;
	}
	else if(y>2019)
	{
		cout<<"TBD";
		return 0;
	}
	else
	{
		if(m<4)
	{
		cout<<"Heisei";
		return 0;
	}
	else if(m>4)
	{
		cout<<"TBD";
		return 0;
	}
	else
	{
		if(d<=30)
		{
			cout<<"Heisei";
			return 0;
		}
		if(d>30)
		{
			cout<<"TBD";
			return 0;
		}

	}
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, x := ReadInt(), ReadInt()
	a := ReadInts(N)

	ans := 0
	if a[0] > x {
		ans += a[0] - x
		a[0] = x
	}
	for i := 0; i < N-1; i++ {
		if a[i]+a[i+1] > x {
			c := a[i+1] - (x - a[i])
			ans += c
			a[i+1] = x - a[i]
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int length = int.Parse(Console.ReadLine());

            List<int> numbers = new List<int>();

            for(int i = 0; i < length; i++)
            {
                numbers.Add(int.Parse(Console.ReadLine()));
            }

            int max = 0;
            int secondMax = 0;
            int maxCount = 0;

            for(int i = 0; i < length; i++)
            {
                if (numbers[i] > max)
                {
                    max = numbers[i];
                    maxCount = 0;
                }

                if(numbers[i] == max)
                {
                    maxCount++;
                }
            }

            for(int i = 0; i < length; i++)
            {
                if (numbers[i] == max)
                {
                    continue;
                }

                if(numbers[i] > secondMax)
                {
                    secondMax = numbers[i];
                }
            }

            if(maxCount == 1)
            {
                for(int i = 0; i < length; i++)
                {
                    if(numbers[i] == max)
                    {
                        Console.WriteLine(secondMax);
                    }
                    else
                    {
                        Console.WriteLine(max);
                    }
                }
            }
            else
            {
                for (int i = 0; i < length; i++)
                {
                    Console.WriteLine(max);
                }
            }
        }
    }
}


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

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

	std::vector<std::vector<bool>> isConnected(n);

	for(int i=0; i<n; i++)
		isConnected[i].resize(n, true);

	for(int i=0; i<n; i++)
		isConnected[i][i]= false;

	int maxIdx= n- (n%2);

	for(int i=0; i<maxIdx; i++)
		isConnected[i][maxIdx-i-1]= false;

	int numEdge=0;

	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			if(isConnected[i][j])
				numEdge++;

	numEdge= numEdge/2;


	std::cout<<numEdge<<std::endl;

	for(int i=0; i<n; i++)
		for(int j=i; j<n; j++)
			if(isConnected[i][j])
				std::cout<<i+1<<" "<<j+1<<std::endl;


	return 0;
}

Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;
use std::cmp::Reverse;

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


    let mut odds = HashMap::new();
    let mut evens = HashMap::new();

    for (i, v) in vv.into_iter().enumerate() {
        if i % 2 == 1 {
            *odds.entry(v).or_insert(0) += 1;
        } else {
            *evens.entry(v).or_insert(0) += 1;
        }
    }

    let mut odds = odds.into_iter().collect::<Vec<_>>();
    odds.sort_by_key(|&(_, val)| Reverse(val));
    let mut evens = evens.into_iter().collect::<Vec<_>>();
    evens.sort_by_key(|&(_, val)| Reverse(val));

    let (o_key, o_val) = odds[0];
    let (e_key, e_val) = evens[0];

    let ans = if o_key != e_key {
        n - o_val - e_val
    } else {
        match (odds.iter().nth(1), evens.iter().nth(1)) {
            (Some(&(_, o2_val)), Some(&(_, e2_val))) => {
                n - std::cmp::max(o_val+e2_val,o2_val+e_val)
            },
            (Some(&(_, o2_val)), None) => {
                n - o2_val - e_val
            },
            (None, Some(&(_, e2_val))) => {
                n - o_val - e2_val
            },
            (None, None) => {
                n - std::cmp::max(o_val, e_val)
            },
        }

    };

    println!("{}", ans);
}


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


#define ll long long
#define IM INT_MAX
#define LM LLONG_MAX
#define m_p make_pair
#define MOD 1000000007
#define dbg(x) cerr << #x << " = " << x << "\n"


/*
ID: vlad.io1
TASK: 
LANG: C++
*/


bool comp(int a, int b) {
	return a > b;
}


template<typename T>
T gcd(T a, T b) {
	while (a != 0 && b != 0) {
		if (a > b) {
			a %= b;
		} else {
			b %= a;
		}
	}
	return (a > b ? a : b);
}


void solve() {
	int n;
	cin >> n;
	
	int a[2000000] = {0};

	for(int x = 1; x*x <= n; x++) {
		for(int y = 1; y*y <= n; y++) {
			for(int z = 1; z*z <= n; z++) {
				int c = x*x + y*y + z*z + x*y + x*z + y*z;
				a[c]++;
			}
		}
	}

	for(int i = 1; i <= n; i++) cout << a[i] << '\n';
}


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

	//freopen("output.txt", "w", stdout);
	//freopen("input.txt", "r", stdin);

	int t=1;
	//cin >> t;

	while(t--)
		solve();
}


























Measured memory_bytes: 11464
import java.util.Scanner;

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

    if(a == b && a == c) {
    	System.out.println("Yes");
    }else {
    	System.out.println("No");
    }

  }
}

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

int64_t euclid_gcd(int64_t A, int64_t B) {
  while (1) {
    if (A > B && B != 0)  A = A % B;
    if (B > A && A != 0)  B = B % A;
    if (A == B || A == 0 || B == 0)  break;
  }
  return max(A,B);
}

int main() {
  ll k,ans=0;
  cin >> k;
  for(int i=1;i<k+1;i++){
    for(int j=1;j<k+1;j++){
      for(int m=1;m<k+1;m++){
        ans += euclid_gcd(i,euclid_gcd(j,m));
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
    long long n, m, ans = 0;
    cin >> n >> m;
    vector<long long> x(n), y(n), z(n);
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    for(int i = 0; i <= 7; i++){
        vector<long long> p(n, 0);
        int a = 0, b = 0, c = 0;
        if(i & (1 << 2)) a = 1; else a = -1;
        if(i & (1 << 1)) b = 1; else b = -1;
        if(i & (1 << 0)) c = 1; else c = -1;
        for(int j = 0; j < n; j++){
            p[j] = a * x[j] + b * y[j] + c * z[j];
        }
        sort(p.begin(), p.end(), greater<long long>());
        long long sum = 0;
        for(int k = 0; k < m;  k++){
            sum += p[k];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 764
#include<iostream>

using namespace std;

int main(){
  int H,W;

  while(cin >> H >> W){
    if(H==0&&W==0){
      break;}
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
	cout <<"#";
	  }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152