akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

void fprint() { std::cout << '\n'; }
template <class H, class... T> void fprint(H &&head, T &&... args) {
    std::cout << std::fixed << std::setprecision(10) << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}

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

    int N;
    cin >> N;
    vector<int> v(N);
    for (auto &&i : v) {
        cin >> i;
    }

    double sum = 0;
    for (auto &&i : v) {
        sum += 1.0 / i;
    }
    double ans = 1.0 / sum;
    fprint(ans);

    return 0;
}

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

int n, k;
vector<int> g[2005];
int d[2005];
 
void dfs(int u,int p,int dd) {
	d[u] = dd;
	for (int v : g[u]) if (v != p) {
		dfs(v, u, dd + 1);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 2; i <= n; ++i) {
		int u, v; cin >> u >> v;
		g[u].push_back(v), g[v].push_back(u);
	}
	int res = n;
	if (k % 2 == 0) {
		for (int u = 1; u <= n; ++u) {
			dfs(u, u, 0);
			int cnt = 0;
			for (int v = 1; v <= n; ++v) cnt += (d[v] > (k / 2));
			res = min(res, cnt);
		}
	}
	else {
		for (int u = 1; u <= n; ++u) {
			for (int v : g[u]) {
				dfs(u, v, 0);
				dfs(v, u, 0);
				int cnt = 0;
				for (int w = 1; w <= n; ++w) cnt += (d[w] > ((k - 1) / 2));
				res = min(res, cnt);
			}
		}
	}
	cout << res << '\n';
}

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

int N,Y,sum;
int mon[3] = {10000,5000,1000};

int main(void){
    cin >>N>>Y;
    for(int i=0;i<=N;i++){
        for(int j=0;i+j<=N;j++){
            sum = mon[0]*i+mon[1]*j+mon[2]*(N-i-j);
            if(sum == Y){
                cout << i << " " << j << " "<<N-i-j<<endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


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



int main() {
    int n;
    cin >> n;
    
    vector<int> b(n-1);
    rep(i,n-1) {
        cin >> b[i];
    }
    
    int sum = 0;
    vector<int> a(n);
    rep(i,n) {
        if(i == 0)
            a[i] = b.front();
        else if(i == n-1)
            a[i] = b.back();
        else
            a[i] = min(b[i-1],b[i]);
    }
    
    rep(i,n) {
        sum += a[i];
    }
    
    cout << sum << endl;
    
    
    
    
    return 0;
}




Measured memory_bytes: 3600
N = int(input())
A = input()
B = input()
C = input()

ans = 0

for i in range(N):
    if A[i] == B[i]:
        if B[i] == C[i]:
            ans += 0
        else:
            ans += 1
    else:
        if B[i] == C[i]:
            ans += 1
        else:
            if C[i] != A[i]:
                ans += 2
            else:
                ans += 1

print(ans)


Measured memory_bytes: 3060
A, B, C = map(int, input().split())
K = int(input())
ans = 'No'

for a in range(K+1):
    for b in range(K+1):
        for c in range(K+1):
            if a + b + c <= K:
                if B * (2**b) > A * (2**a) and C * (2**c) > B * (2**b):
                    ans = 'Yes'

print(ans)

Measured memory_bytes: 9192
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int w[10000000],h[1500];
int main(){
	int n,m;
	while(true){
	cin>>n>>m;
	if(n==0&&m==0)
		break;
	for(int i=0;i<n;i++)
		cin>>h[i];
	int wcount=0;
	for(int start=0;start<n;start++){
		int count=0;
		for(int len=start;len<n;len++){
			count+=h[len];
			w[wcount]=count;
			wcount++;
		}
	}
	sort(w,w+wcount);
	for(int i=0;i<m;i++)
		cin>>h[i];
	int key,ans=0;
	for(int start=0;start<m;start++){
	int count=0;
	for(int len=start;len<m;len++){
		count+=h[len];
		key=count;
	int left=0,right=wcount;
	int mid;
	while(true){
		if(left>=right)
			break;
		mid=(left+right)/2;
		if(w[mid]==key){
			ans++;
			int q=mid-1;
			while(true){
				if(q<0)
					break;
				if(w[q]==w[mid])
					ans++;
				else
					break;
				q--;
			}
			q=mid+1;
			while(true){
				if(q==wcount)
					break;
				if(w[q]==w[mid])
					ans++;
				else
					break;
				q++;
			}
			break;
		}
		if(key>w[mid])
			left=mid+1;
		if(key<w[mid])
			right=mid;
	}
	}
	}
	cout<<ans<<endl;
	}
	return 0;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	int a,b; cin>>a>>b;
	map<int,int> ct;
	for (int i=0; i<n; i++) {
		int p; cin>>p;
		if(p<=a) ct[0]++;
		else if(p<=b) ct[1]++;
		else ct[2]++;
	}
	cout<<min({ct[0],ct[1],ct[2]})<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////


int main(){
  inl(A,B,C,K);
  out((A - B) * (K % 2 ? -1 : 1));

}

Measured memory_bytes: 256
program Rectangle_Cutting
    implicit none
    real(8):: w,h,x,y
    integer(4):: ans
    read*, w,h,x,y

    if (w/2d0 == x .and. h/2d0 == y) then
        ans = 1
    else
        ans = 0
    end if

    print*, w*h*0.5d0, ans
end program Rectangle_Cutting

Measured memory_bytes: 256
/*Author--Vishwas Agrawal*/
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define pb push_back
#define test \
   int t;    \
   cin >> t; \
   while (t--)
#define fio                          \
   ios_base::sync_with_stdio(false); \
   cin.tie(NULL);                    \
   cout.tie(NULL);
#define mod 1000000007LL
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define inc(i, a, n) for (int i = a; i < n; i++)
#define dec(i, a, n) for (int i = n - 1; i >= a; i--)
int main()
{
 ll n;
 cin>>n;
 ll arr[n];
 inc(i,0,n)cin>>arr[i];
 ll ans=0;
 inc(i,1,n)
 {
    if(arr[i]<arr[i-1])
    {
     ans+=arr[i-1]-arr[i];
     arr[i]=arr[i-1];
    }
 }
 cout<<ans<<endl;

   return 0;
}

Measured memory_bytes: 5192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
   public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            br.readLine();
            String[] split = br.readLine().split(" ");
            int n = split.length;
            double[] prob = new double[n];
            for (int i = 0; i < n; i++) {
               prob[i] = Double.parseDouble(split[i]); 
            }
            double[] dp = new double[n + 1];
            dp[0] = 1.0;
            for (int i = 1; i <= n; i++) {
                for (int j = n; j >= 0; j--) {
                    dp[j] = (j == 0 ? 0 : dp[j - 1])*prob[i - 1] +  dp[j]*(1 - prob[i - 1]);
                }
            }
            double result = 0.0;
            for (int i = (n + 1) / 2 ; i <= n; i++) {
                result += dp[i];
            }
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

int N, M;
vector<int> adjlist[100005];
bool vis[100005], fail;
int c[100005];

void dfs(int x, int col) {
	if (vis[x]) {
		if (col != c[x]) fail = 1;
		return;
	} else vis[x] = 1;
	c[x] = col;
	for (int i = 0; i < adjlist[x].size(); i++) dfs(adjlist[x][i], !col);
		
}
long long l, r, x;

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		adjlist[a].push_back(b);
		adjlist[b].push_back(a);
	}
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		if (vis[i]) continue;
		if (adjlist[i].size() == 0) {
			x++;
			continue;
		}
		fail = 0;
		dfs(i, 0);
		if (fail) l++;
		else r++;
	}
	//printf("%lld %lld %lld\n", ans, l, r);
	ans += l * l;
	ans += l * r * 2ll;
	ans += (r * r) * 2ll;
	ans += 2ll * (long long)N * x - x * x;
	printf("%lld\n", ans);
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())

int main() {
  int n;
  cin>>n;
  
  vector<int> a(n);
  vector<int> s(n);
  rep(i,n){cin>>a[i];
  s[i]=a[i];
          }
  SORTD(s);
  
  int max=s[0];
  
  for(int i=0;i<n;i++){
    if(max==a[i]&&s[0]!=s[1]){
    	cout<<s[1]<<endl;
    }
    
    else{
    	cout<<s[0]<<endl;
    }

  }
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 123;

int a[N], skipped[N];
stack<int> ans;

void solve() {
  int n; scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a+i);
  for (int cnt = 0; cnt < n; ++cnt) {
    int sel = -1;
    for (int i = 1, ind = 1; i <= n; ++i) {
      if (skipped[i]) continue;
      if (a[i] == ind) {
	if (sel == -1 || a[i] > a[sel]) sel = i;
      }
      ++ind;
    }
    if (sel == -1) {
      printf("-1");
      return;
    }
    skipped[sel] = true;
    ans.push(a[sel]);
  }
  while (!ans.empty()) {
    printf("%d\n", ans.top());
    ans.pop();
  }
}

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


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, a[5][1010], dp[5][1010];

int main() {
	cin >> n;
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= 2; i++) {
		for (int j = 1; j <= n; j++) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
		}
	}
	cout << dp[2][n] << endl;
}

Measured memory_bytes: 256
inputs = input()
num = 0
if inputs == "SUN":
    num = 7
elif inputs == "MON":
    num = 6
elif inputs == "TUE":
    num = 5
elif inputs == "WED":
    num = 4
elif inputs == "THU":
    num = 3
elif inputs == "FRI":
    num = 2
elif inputs == "SAT":
    num = 1

print(num)

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

inline int abs(int n) {
    return (n < 0 ? -n : n);
}

inline int find_best(int number, vector<int> &inserted) {

    auto pos = lower_bound(inserted.begin(), inserted.end(), number/2);

    if (pos == inserted.end()) {
        pos--;
    }

    int closest = *pos;
    //do plus-minus two
    int it = 0;
    for (auto next = pos; it < 2 && next != inserted.end(); next++, it++) {
        closest = (abs(number/2 - closest) > abs(number/2 - *next)) ? *next : closest;
    }

    it = 0;
    for (auto next = pos; it < 2; it++) {
        closest = (abs(number/2 - closest) > abs(number/2 - *next)) ? *next : closest;

        if (next == inserted.begin()) { break; }
        next--;
    }

    return closest;
}

bool criteria(pair<int, int> a, pair<int, int> b) {

    a.second = max(a.second, a.first - a.second);
    b.second = max(b.second, b.first - b.second);

    int diff1 = abs(a.first/2 - a.second);
    int diff2 = abs(b.first/2 - b.second);

    if (a.first == b.first && a.second == b.second) {
        return false;
    }

    if (a.first <= b.first && diff1 > diff2) {
        return true;
    }

    int largest_a = a.first - (a.first - a.second);
    int largest_b = b.first - (b.first - b.second);

    return largest_a < largest_b;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

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

    sort(A, A+n);
    vector<int> inserted;
    inserted.push_back(A[0]);

    vector<pair<int, int> > options;

    for (int i=1; i<n; i++) {
        int number = A[i];
        int best = find_best(number, inserted);

        options.push_back({ number, best });
        inserted.push_back(number);
    }


    sort(options.begin(), options.end(), criteria);

    auto best = *(options.rbegin());
    cout << best.first << " " << best.second << endl;
    return 0;
}


Measured memory_bytes: 2164
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);

    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }

    cout << sum-n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"


bool check(string s){

  return true;
}
bool solve(){  
  string s;cin>>s;
  ll ans=0;
  ll cp=0;
  ll n=s.size();
  rep(i,n){
    cp+=(s[i]=='p');
  }
  ll maxP=n/2;
  cout<<maxP-cp<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 512
n = int(input()) #int
s = input() # str

chars = list(s)

alpha2num = lambda c: ord(c) - ord('A') + 1
num = []
for i in range (0,len(chars)):
  if alpha2num(chars[i])+n >26:
    num.append(alpha2num(chars[i])-26+n)
  else:
    num.append(alpha2num(chars[i])+n)

num2alpha = lambda c: chr(c+64)
alp = []
for i in range (0,len(num)):
  alp.append(num2alpha(num[i]))

print((''.join(map(str,alp))))

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

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    int h[25];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int ans = 1;
    for(int i = 1; i < n; i++){
        int ch = 1;
        for(int j = 0; j < i; j++){
            if(h[j] <= h[i])continue;
            else{
                ch = 0;
                break;
            }
        }
        if(ch == 1){
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define N 101
#define WARU 10000

int n;
int yotei[N];
int memo[N][4][4];

//	x日目, r日連続でk種を食べた
int getWay(int x, int r, int k)
{
	int ret = 0;
	int i;
	
	if (memo[x][r][k] != -1){
		return (memo[x][r][k]);
	}
	
	if (x == n){
		return (1);
	}
	
	if (yotei[x] != 0){
		int nissu = (k == yotei[x] ? r + 1 : 1);
		if (nissu < 3){
			ret += (getWay(x + 1, nissu, yotei[x]) % WARU);
		}
	}
	else {
		for (i = 1; i <= 3; i++){
			int nissu = (k == i ? r + 1 : 1);
			
			if (nissu < 3){
				ret += (getWay(x + 1, nissu, i) % WARU);
			}
		}
	}
	
	return (memo[x][r][k] = (ret % WARU));
}

int main(void)
{
	int i;
	int k;
	
	memset(yotei, 0, sizeof(yotei));
	memset(memo, -1, sizeof(memo));
	scanf("%d%d", &n, &k);
	for (i = 0; i < k; i++){
		int when, what;
		scanf("%d %d", &when, &what);
		yotei[when - 1] = what;
	}
	
	printf("%d\n", getWay(0,0,0));
	
	return (0);
}

Measured memory_bytes: 604
from sys import stdin

N, M = map(int, stdin.readline().split())
arr = []
for i in range(N):
  arr.append(list(map(int, stdin.readline().split())))

arr.sort(key=lambda a: a[0])
ans = 0
index = 0
bought = 0
while True:
    p, q = arr[index]
    q = min(q, M - bought)

    ans += p * q
    bought += q

    if bought == M:
        break

    index += 1

print(ans)

Measured memory_bytes: 28948
function Main(input) {
  input = input.split(" ");
  var w = parseInt(input[0]);
  var a = parseInt(input[1]);
  var b = parseInt(input[2]);
  var s;
  if(a>b){
    var c = a;
    a=b;
    b=c;
  }
    if(a+w>=b){
      s=0;
      
    }else{
      s=b-(a+w);
    }

  console.log('%s', s);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] h = new int[n];
		long ans = 0;

		for (int i = 0; i < n; i++)
			h[i] = scan.nextInt();

		Arrays.sort(h);

		for (int i = 0; i < n - k; i++)
			ans += h[i];

		System.out.println(ans);

		scan.close();
	}
}

Measured memory_bytes: 64880
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a>> b>>c;
    if((a==b &&c!=b &&c!=a) || (c==b &&a!=b &&a!=c) || (a==c && b!=c &&b!=a))
      cout <<  2;
    else if (a==b &&a==c &&c==b )
        cout << 1 ;
    else if(a!=b && a!=c &&b!=c)
        cout << 3 ;


    return 0;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 998244353;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	int N, K;
	cin >> N >> K;
	vector<bool> use(10, true);
	for (int i = 0; i < K; i++) {
		int tmp;
		cin >> tmp;
		use[tmp] = false;
	}

	while (true) {
		bool flag = true;
		auto str = to_string(N);
		for (int i = 0; i < str.size(); i++) {
			int M = atoi(str.substr(i, 1).c_str());
			if (!use[M]) {
				N++;
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << N << endl;
			return 0;
		}
	}

	return 0;
}


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

using ll = long long;

int main(){
  ll N;cin >> N;
  for(ll i=1;i<=N;i++){
    ll sum = i*(i+1)/2;
    if(N<=sum){
      for(int j=1;j<=i;j++){
        if(j+N!=sum){
          cout << j << endl;
        }
      }
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
   int n;
   cin>>n;
   vector<int> v(n);
   rep(i,n)cin >> v[i];
   vector<int> x,y;
   rep(i,n)
   {
      if(i&1)x.push_back(v[i]);
      else y.push_back(v[i]);
   }
   sort(ALL(x));
   sort(ALL(y));
   vector<pair<int,int>> xx,yy;

   int l=1;
   rep(i,x.size()-1)
   {
      if(x[i]!=x[i+1])
      {
         xx.push_back(make_pair(l,x[i]));
         l=1;
      }
      else
      {
         l++;
      }
   }
   xx.push_back(make_pair(l,x.back()));
   l=1;
   
   rep(i,y.size()-1)
   {
      if(y[i]!=y[i+1])
      {
         yy.push_back(make_pair(l,y[i]));
         l=1;
      }
      else
      {
         l++;
      }
   }
   yy.push_back(make_pair(l,y.back()));
   l=1;
   sort(ALL(xx),greater<pair<int,int>>());
   sort(ALL(yy),greater<pair<int,int>>());
   if(xx[0].second==yy[0].second)
   {
      if(xx.size()==1&&yy.size()==1)
      {
         cout<<n/2<<endl;
         return 0;
      }
      else if(xx.size()==1)
      {
         cout<<n-xx[0].first-yy[1].first<<endl;;
      }
      else if(yy.size()==1)
      {
         cout<<n-yy[0].first-xx[1].first<<endl;;
      }
      else
      {
         int ans1 , ans2;
         ans1 = n-xx[0].first-yy[1].first;
         ans2 = n-yy[0].first-xx[1].first;
         cout<<min(ans1,ans2)<<endl;
      }
   }
   else
   {
      cout<<n-xx[0].first-yy[0].first<<endl;
   }
   
   return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 100001

bool ans=1;

vector<pll> v[N];
lli a[N];
bool vis[N];

void dfs(lli q,lli val)
{
    vis[q] = 1;
    a[q] = val;

    for(auto x:v[q])
    {
        if(!vis[x.ff])
        {
            dfs(x.ff , val+x.ss);
        }
    }
}

void solve()
{
    lli n,m;
    cin>>n>>m;

    loopl(i,1,n+1) a[i] = -1;


    while(m--)
    {
        lli x,y,r;
        cin>>x>>y>>r;

        v[x].pb({y,r});
        v[y].pb({x,-1*r});
    }

    loopl(i,1,n+1)
    {
        if(!vis[i])
            dfs(i,0);
    }

    // loopl(i,1,n+1) cout<<a[i]<<" ";
    // cout<<endl;

    loopl(i,1,n+1)
    {
        for(auto x:v[i])
        {
            if(a[i]+x.ss != a[x.ff])
            {
                cout<<"No";
                return ;
            }
        }
    }

    cout<<"Yes";
}   

int main()
{
////////////////////////////////////////////   
    fastio;
////////////////////////////////////////////
    
    lli t;
    t=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 19976
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n){
        cin >> a[i];
    }
    int max1=-1, max2=-1;
    REP(i, n){
        if(a[i] > max1){
            max2 = max1;
            max1 = a[i];
        }
        else if(a[i] > max2){
            max2 = a[i];
        }
    }
    REP(i, n){
        if(a[i] != max1)
            cout << max1 << endl;
        else
            cout << max2 << endl;
    }

    return 0;
}

Measured memory_bytes: 2432
// template version 1.11
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<int> s(n);
  rep(i, n) {
    cin>>s[i];
  }

  int res = 0;
  rep(k, 1, n-1){
    int i = 0;
    int j = n-1;
    int ans = 0;
    set<int> S;
    while(i + k < n and j - k >=0){
      if (S.find(i) == S.end()){ S.insert(i); }
      else break;
      if (S.find(j) == S.end()){ S.insert(j); }
      else break;

      assert(i!=j);
      assert(0<=i&&i<=n-1 && 0<=j&&j<=n-1);
      ans += s[i]+s[j];
      chmax(res, ans);
      assert(res>=ans);
      assert(res>=0);
      i += k;
      j -= k;
    }
  }
  cout << res << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int n;
int a[200010];
vector<int>ans;
int nw[200010];
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=n;i>0;i--){
		int nnw=0;
		for(int j=i*2;j<=n;j+=i){
			nnw=nnw+nw[j];
			nnw%=2;
		}
		nw[i]=a[i]^nnw;
		if(nw[i]==1){
			ans.push_back(i);
		}
	}
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<' ';
	}
    return 0; 
}

Measured memory_bytes: 3064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N-1];
		int[] b = new int[N-1];
		int[] acopy = new int[N-1];
		int[] bcopy = new int[N-1];
		int[] c = new int[N];
		int[][] edge = new int[N][2];
		int[] num = new int[N];
		long ans = 0;
		for(int i = 0; i < N-1; i++) {
			a[i] = sc.nextInt()-1;
			b[i] = sc.nextInt()-1;
			acopy[i] = a[i];
			bcopy[i] = b[i];
			edge[a[i]][1]++;
			edge[b[i]][1]++;
		}
		for(int i = 0; i < N; i++)
			edge[i][0] = i;
		Arrays.sort(edge, (x,y) -> x[1] - y[1]);
		for(int i = 0; i < N; i++)
			c[i] = sc.nextInt();
		Arrays.sort(c);
		List<Integer> sorted = new ArrayList<>();
		sorted.add(edge[N-1][0]);
		for(int i = 0; i < N; i++) {
			int key = sorted.get(i);
			for(int j = 0; j < N-1; j++) {
				if(acopy[j] == key) {
					sorted.add(b[j]);
					acopy[j] = -1;
					bcopy[j] = -1;
				}
				if(bcopy[j] == key) {
					sorted.add(a[j]);
					acopy[j] = -1;
					bcopy[j] = -1;
				}
			}
			if(sorted.size() >= N)
				break;
		}
		for(int i = N-1; i >= 0; i--)
			num[sorted.get(N-1-i)] = c[i];
		for(int i = 0; i < N-1; i++)
			ans += Math.min(num[a[i]], num[b[i]]);
		System.out.println(ans);
		for(int i = 0; i < N; i++)
			System.out.println(num[i]);
	}

}


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

int dfs(char **map,int **check,int i,int j,int h){
	check[i][j]=1;
	if(map[i][j+1]==map[i][j] && check[i][j+1]==0){
		dfs(map,check,i,j+1,h);
	}
	if(i+1<h && map[i+1][j]==map[i][j] && check[i+1][j]==0){
		dfs(map,check,i+1,j,h);
	}
	if(j!=0 && map[i][j-1]==map[i][j] && check[i][j-1]==0){
		dfs(map,check,i,j-1,h);
	}
	if(i-1>=0 && map[i-1][j]==map[i][j] && check[i-1][j]==0){
		dfs(map,check,i-1,j,h);
	}

	return 1;
}

int main(){
	char** map;
	int** check;
	int i,j,k,l,count,sx,sy;

while(1){
	count=0;
	scanf("%d %d",&sx,&sy);
	if(sx==0)break;

	map=malloc(sizeof(char *)*sx);
	for(i=0;i<sx;i++){
		map[i]=malloc(sizeof(char)*(sy+1));
	}
	check=malloc(sizeof(int *)*sx);
	for(i=0;i<sx;i++){
		check[i]=malloc(sizeof(int)*(sy+1));
	}
	for(i=0;i<sx;i++){
		for(j=0;j<=sy;j++){
			check[i][j]=0;
		}
	}

	scanf("%c",&map[0][0]);
	for(i=0;i<sx;i++){
		for(j=0;j<=sy;j++){
			scanf("%c",&map[i][j]);
		}
	}

	for(i=0;i<sx;i++){
		for(j=0;j<sy;j++){
			if(check[i][j]==0)count+=dfs(map,check,i,j,sx);
//			for(k=0;k<sx;k++){
//				for(l=0;l<sy;l++)printf("%d",check[k][l]);
//				printf("\n");
//			}
		}
	}

	printf("%d\n",count);
	for(i=0;i<sx;i++){
		free(map[i]);
	}
	free(map);
}
	return 0;
}

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

#define ll long long

int main()
{
	double a;	cin >> a; 

	double l = a/3.0;
    a -= l;   
    double b = a / 2; 
  	double h = a - b; 
  	
  	cout << fixed << setprecision(10) << l*b*h << "\n";

    // return length * breadth * height; 
}

Measured memory_bytes: 256
def MAP(): return map(int,input().split())

n,q = MAP()
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i]+(1 if s[i:i+2]=="AC" else 0)
for i in range(q):
    l,r = MAP()
    print(t[r-1]-t[l-1])

Measured memory_bytes: 52312
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string S;
  cin >> S;
  vector<int> vec(26, 0);
  REP(i, 4) {
    vec[S[i] - 'A']++;
  }
  REP(i, vec.size()) {
    if (vec[i] && vec[i] != 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

void solve()
{
	int a, b;
	cin >> a >> b;
	cout << ((a+b == 15) ? "+" : (a*b == 15) ? "*" : "x") << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  bool[string] di;

  foreach (_; n.iota) {
    auto rd = readln.chomp.splitter(' ');
    auto cmd = rd.front; rd.popFront;
    auto str = rd.front;
    switch (cmd) {
    case "insert":
      di[str] = true;
      break;
    case "find":
      writeln(str in di ? "yes" : "no");
      break;
    default:
      assert(0);
    }
  }
}

Measured memory_bytes: 38000
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int n;
	cin >> n;
	int parity=n%2;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]%2 == parity){
			cout << "0\n";
			return 0;
		}
	}
	if(n==1){
		cout << (a[0]==0) << "\n";
	}else{
		sort(a,a+n);
		int prev=a[0],num=1,ans=1;
		for(int i=1;i<n;i++){
			if(prev==a[i]) num++;
			else{
				if(prev!=0 && num==2){
					//printf("%d %d\n",prev,a[i]);
					ans*=2;
					ans%=MOD;
				}
				else if(prev==0 && num==1){}
				else{
					cout << "0\n";
					return 0;
				}
				num=1;
			}
			prev=a[i];
		}
		if(num==2) {
			ans*=2;
			ans%=MOD;
		}else{
			ans=0;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int S;
	cin >> S;
	int S1 = S / 100;
	int S2 = S % 100;
	if (S1>=13 || S1==0)
	{
		if (S2<=12 && S2!=0)
		{
			cout << "YYMM" << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
	else
	{
		if (S2 >= 13 || S2==0)
		{
			cout << "MMYY" << endl;
		}
		else
		{
			cout << "AMBIGUOUS" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

ans = 0

for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            t = [L[i], L[j], L[k]]
            t.sort()
            if len(set(t)) == 3 and (t[0] + t[1]) > t[2]:
                ans += 1

print(ans)


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

int main() {
	string s;
	cin >> s;
	for (int i = (s.size() - 1) / 2; i >= 0; i--) {
		if (s.substr(0, i) == s.substr(i, i)) {
			cout << i * 2 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int count = 0;
  int r_max = N / R;
  int g_max = N / G;
  for (int i = 0; i <= r_max; i++) {
    for (int j = 0; j <= g_max; j++) {
      if (N - i * R - j * G < 0) {
        break;
      }
      bool flag = (N - i * R - j * G) % B == 0;
      if (flag) {
        count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_130
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }
        static void Main(string[] args)
        {
            var XA = Sarray();
            if (XA[0] < XA[1]) WriteLine(0);
            else WriteLine(10);
        }
    }
}

Measured memory_bytes: 13268
import javax.sound.midi.Soundbank;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

import static java.lang.Math.*;

public class Main {
    final static int MAX = 10000 + 5;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt();
        int n = in.nextInt();
        //void cp(int c,int w){for(int i=c; i<=v; i++)f[i]=max(f[i],f[i-c]+w);}
        int[] f = new int[MAX * 2];
        int[] a = new int[MAX * 2];
        int[] b = new int[MAX * 2];
        int maa = 0;
        int mib = MAX;
        for (int k = 0; k < n; k++) {
            a[k] = in.nextInt();
            b[k] = in.nextInt();
            maa = max(a[k], maa);
            mib = min(b[k], mib);
        }
        int ans = 100000000;
        for (int i = 1; i <= h + maa; i++) {
            f[i] = ans;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < n; j++) {
                f[i + a[j]] = min(f[i + a[j]], f[i] + b[j]);
            }
        }
        for (int i = h; i <= h + maa; i++) {
            ans = min(ans, f[i]);
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 27516
import heapq
N,M=[int(thing) for thing in input().split(" ")]
A_list=[int(thing)*(-1) for thing in input().split(" ")]
heapq.heapify(A_list)
for aaaaa in range(M):
    thing =heapq.heappop(A_list)/2
    heapq.heappush(A_list,thing)
print(int(sum([thing*-1//1 for thing in A_list])))


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

using namespace std;

int main(){
	int H, W, h, w;
	while(cin >> H >> W >> h >> w){
		vector<vector<int>> mtx(H, vector<int>(W, 0));
		if(h==1 && w==1){
			cout << "No" << endl;
			continue;
		}
		long long sum = 0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i%h == h-1 && j%w == w-1){
					mtx[i][j] = -1000000000;
				} else if(i%h == 0 && j%w == 0){
					mtx[i][j] = 999999999 - (h*w-2);
				} else {
					mtx[i][j] = 1;
				}
				sum += mtx[i][j];
			}
		}
		if(sum > 0){
			cout << "Yes" << endl;
			for(int i=0;i<H;i++){
				cout << mtx[i][0];
				for(int j=1;j<W;j++) cout << " " << mtx[i][j];
				cout << endl;
			}
		} else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 3968
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int A; cin >> A;
  int B; cin >> B;
  if (A <= 8 && B <= 8) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
//using static System.Console;
//using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {

            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var C = cin.ReadInt;
            var X = cin.ReadInt;
            var ans = 0;
            for (int i = 0; i <= A; ++i)
                for (int j = 0; j <= B; ++j)
                    for (int k = 0; k <= C; ++k)
                        if (500 * i + 100 * j + 50 * k == X)
                            ans++;
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13268
number = input()
a = number.split()

D=int(a[0])
N=int(a[1])

if N == 100:
    if D==0:
        print(N+1)
    elif D==1:
        answer = 100*N
        print(answer+100)
    elif D==2:
        answer = 10000*N
        print(answer+10000)

else:
    if D==0:
        print(N)
    elif D==1:
        answer = 100*N
        print(answer)
    elif D==2:
        answer = 10000*N
        print(answer)

Measured memory_bytes: 3064
w,h,n = map(int,input().split())
l = {1:0, 2:w, 3:0, 4:h}
for _ in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        l[a] = max(l[a], x) 
    elif a == 2:
        l[a] = min(l[a], x) 
    elif a == 3:
        l[a] = max(l[a], y) 
    elif a == 4:
        l[a] = min(l[a], y)
        
if l[2]-l[1] <=0 or l[4]-l[3]<=0:
    print(0)
else : print((l[2]-l[1])*(l[4]-l[3]))

Measured memory_bytes: 3064