akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x)
{
    S[++top] = x;
}

int pop()
{
    top--;
    return S[top+1];
}

int main()
{
    int a, b;
    top = 0;
    char s[100];

    while( scanf("%s", s) != EOF)
    {
        if ( s[0] == '+')
        {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if( s[0] == '-')
        {
            b = pop();
            a = pop();
            push(a - b);
        }
        else if ( s[0] == '*')
        {
            a = pop();
            b = pop();
            push(a*b);
        }
        else
        {
            push(atoi(s));
        }
    }

    printf("%d\n", pop());

    return 0;
}


Measured memory_bytes: 2080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int array[] = new int[n];

		for(int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}

		int q = sc.nextInt();

		for(int i = 0; i < q; i++) {
			int key = sc.nextInt();

			if(array[n-1] < key) {
				System.out.print(n + " ");
				System.out.println(n);
			}
			else {
				BinarySearch4 bi4 = new BinarySearch4();
				bi4.binarySearch3(array, key);

				if(array[n-1] == key) System.out.println(n);
				else {
					//upperbound
					bi4.binarySearch4(array, key);
				}
			}
		}
	}
}

class BinarySearch4 {
	int center;

	public void binarySearch3(int[] array, int key) {
		int pLeft = 0;
		int pRight = array.length - 1;
		int temp = -1;

		do {
			center = (pLeft + pRight) / 2;
			if(center == temp) break;

			if (array[center] >= key) {  //key以上の数がarray[center]より前にある可能性がある
				pRight = center;
			} else {
				pLeft = center + 1;  //ここはok
			}
			temp = center;
		} while (pLeft <= pRight);

		System.out.print(center + " ");
	}

	public void binarySearch4(int[] array, int key) {
		int pLeft = center;
		int pRight = array.length - 1;
		int temp = -1;

		do {
			center = (pLeft + pRight) / 2;
			if(center == temp) break;

			if (array[center] > key) {
				pRight = center;
			} else {
				pLeft = center + 1;  //ここはok
			}
			temp = center;
		} while (pLeft <= pRight);

		System.out.println(center);
	}
}


Measured memory_bytes: 115644
#include <stdio.h>
#include <string.h>
#include "math.h"


int main(int argc, char *argv[]){

  int i;
  int N, K;
  int l = 0;

  scanf("%d %d", &N, &K);

  int h[N];

  for(i=0; i<=N-1; i++){
    scanf("%d ", &h[i]);
  }

  for(i=0; i<=N-1; i++){
    if(h[i] >= K){
      l++;
    }
  }

  printf("%d\n", l);

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
long long a,b;
int main()
{
	cin>>a>>b;
	if(a>b) swap(a,b);
	if(a<=0&&b>=0) cout<<"Zero\n"; else
		if(a>0&&b>0) cout<<"Positive\n"; else
			if(a<0&&b<0)
			{
				if((abs(b)-abs(a))%2==0) cout<<"Negative\n"; else cout<<"Positive\n";
			}
	return 0;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;
constexpr ll mo2 = 998244353;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    ll sum = 0ll;
    for(int i=1;i<=n;++i){
        if(i%3 != 0 and i%5 != 0)sum += i;
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
  int n,m;
  int a[1010];
  int num[1010][1010];//num[time][hard]
  int time[1010];
  int per[1010];

  while(cin >> n >> m , n||m){
    for(int i=0;i<n;i++)cin >> a[i];

    for(int i=0;i<=1000;i++){
      time[i] = 0;
      for(int j=0;j<=1000;j++)num[i][j] = 0;
    }

    for(int i=0;i<n;i++){
      int j;
      for(j=a[i];j<=m;j+=a[i]){
	bool f = false;
	for(int k=0;k<j;k++){
	  if(time[k]){
	    time[j]++;
	    num[j][a[i]]++;
	    per[i] = j;
	    f = true;
	    break;
	  }
	}
	if(!f){
	  for(int k=0;k<a[i];k++){
	    if(num[j][k]){
	      time[j]++;
	      num[j][a[i]]++;
	      per[i] = j;
	      f = true;
	      break;
	    }
	  }
	}
	if(!f){
	  if(num[j][a[i]]){
	    time[j]++;
	    num[j][a[i]]++;
	    per[i] = j;
	    f = true;
	    break;
	  }
	}
	if(f)break;
      }
      if(j>m){
	time[j-a[i]]++;
	num[j-a[i]][a[i]]++;
	per[i] = j-a[i];
      }
    }
    int ans = 0;

    for(int i=0;i<n;i++)
      if(per[i]<per[ans])ans = i;

    for(int i=0;i<n;i++)
      if(per[i] == per[ans]){
	if(a[i]<a[ans])ans = i;
      }

    int cnt = 0;
    for(int i=0;i<n;i++)
      if(a[i]==a[ans])cnt++;
    if(cnt>1)cout << n << endl;
    else cout << ans+1 << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353LL;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n;
char s[N];
int ans = inf;
int sumr[N], sumw[N];

void solve()
{
    scanf("%d", &n);
    scanf("%s", s + 1);
    for (int i = 1; i <= n; ++i)
    {
        sumr[i] = sumr[i - 1] + (s[i] == 'R');
        sumw[i] = sumw[i - 1] + (s[i] == 'W');
    }
    for (int i = 0; i <= n; ++i)
    {
        int tmp = 0;
        tmp += min(sumw[i], sumr[n] - sumr[i]);
        int Left = max(sumw[i], sumr[n] - sumr[i]) - min(sumw[i], sumr[n] - sumr[i]);
        tmp += Left;
        ans = min(ans, tmp);
    }
    printf("%d\n", ans);
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 5584
N = int(input())
a = list(map(int, input().split()))

cnt = 0
cnt1 = 0
for i in range(len(a)):
    if(a[i]%4==0):
        cnt += 1
    elif(a[i]%2 == 0):
        cnt1 += 1

if(cnt+cnt1//2 >= N//2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 19996
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
string S, T;cin >> S >> T;
ll Ans = 0;

ll Sl = S.size(), Tl = T.size();

rep(i, 0, Sl - Tl + 1){

    ll count = 0;

    rep(j, 0, Tl){

        if(S[i + j] == T[j])count++;

    }

    Ans = max(Ans, count);

}

cout << Tl - Ans;

}




Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t,c;
	inline void gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			c=s==t?EOF:*s++;
		}else c=*s++;
	}
	template<class IT>inline void gi(IT &x){
		x=0;gc();while(c<'0'||c>'9')gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
	}
	char buf0[20];int a;
	template<class IT>inline void pi(IT x){
		if(x<0){putchar('-');x=-x;}
		do buf0[++a]=x%10+48;while(x/=10);
		while(a)putchar(buf0[a--]);
		putchar('\n');
	}
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=100005,M=N+(N<<1);
const ll p=998244353ll;
int r[N],g[N],b[N],f[M];
char c[M];
int main(){
	int n,m,i,R=0,G=0,B=0,RG=0,GB=0,BR=0;ll ans=1ll;
	scanf("%d%s",&n,c+1);m=n+(n<<1);
	rep(i,1,m){
		if(c[i]=='R')r[++R]=i;else
		if(c[i]=='G')g[++G]=i;else b[++B]=i;
	}
	sort(r+1,r+n+1);
	sort(g+1,g+n+1);
	sort(b+1,b+n+1);
	rep(i,1,n){
		R=r[i];
		G=g[i];
		B=b[i];
		if(R>G)swap(R,G);
		if(G>B)swap(G,B);
		if(R>G)swap(R,G);
		f[R]=1;
		f[B]=2;
	}
//	rep(i,1,m)printf("%c %d\n",c[i],f[i]);
	rep(i,2,n)ans=ans*i%p;
	R=G=B=0;
	rep(i,1,m){
		if(f[i]){
			if(f[i]==1){
				switch(c[i]){
					case 'R':++R;break;
					case 'G':++G;break;
					case 'B':++B;break;
				}
			}else{
				switch(c[i]){
					case 'R':ans=ans*(GB--)%p;break;
					case 'G':ans=ans*(BR--)%p;break;
					case 'B':ans=ans*(RG--)%p;break;
				}
			}
		}else{
			switch(c[i]){
				case 'R':if(G){ans=ans*(G--)%p;++RG;}else{ans=ans*(B--)%p;++BR;}break;
				case 'G':if(B){ans=ans*(B--)%p;++GB;}else{ans=ans*(R--)%p;++RG;}break;
				case 'B':if(R){ans=ans*(R--)%p;++BR;}else{ans=ans*(G--)%p;++GB;}break;
			}
		}
//		printf("R=%d G=%d B=%d RG=%d GB=%d BR=%d\n",R,G,B,RG,GB,BR);
	}
	printf("%lld",ans);
	return 0;
}

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

int main(){
    int min_index=0;
    long long trans[5],min,N;
    cin >> N >> trans[0];
    min = trans[0];
    for(int i=1;i<5;i++){
        cin >> trans[i];
        if(min > trans[i]){
            min = trans[i];
        }
    }
    cout << (N-1) / min + 5;
}

Measured memory_bytes: 256
//#include "stdc++.h"
#include<bits/stdc++.h>
#include<iostream>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
int main()
{
    ll n;
    cin>>n;
    ll dp[n][3];
    ll a[n][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
            cin>>a[i][j];
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+a[i][0],dp[i-1][2]+a[i][0]);
        dp[i][1]=max(dp[i-1][0]+a[i][1],dp[i-1][2]+a[i][1]);
        dp[i][2]=max(dp[i-1][0]+a[i][2],dp[i-1][1]+a[i][2]);
    }
    ll ans=max(dp[n-1][0],dp[n-1][1]);
    ans=max(ans,dp[n-1][2]);
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  int N,i,p,sum =0 ,min =100000000;
  int *x;

  scanf("%d",&N);

  x= calloc(N, sizeof(int));

  for(i=0;i<N;i++)
    scanf("%d",&x[i]);

  for(p=1; p <= 100; p++)
    {
      for(i=0; i<N; i++){
        sum += ((x[i]-p)*(x[i]-p)) ;
      }
      if( sum < min ){min = sum;}
    sum = 0;
    }
  printf("%d", min);

  free(x);
  return 0;
}


Measured memory_bytes: 1712
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

signed main(){
	int N,cnt[6]={};
	cin>>N;
	for(int i=0;i<N;i++){
		double H; cin>>H;
		int c;
		if(H<165.0) c = 0;
		else if(H>=185) c = 5;
		else c = (H-165.0)/5.0+1;
		cnt[c]++;
	}
	for(int i=0;i<6;i++){
		printf("%d:",i+1);
		for(int j=0;j<cnt[i];j++) printf("*"); puts("");
	}
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <set>
#include <map>

using namespace std;

int main(){

    int n, m;
    cin >> n; cin >> m;

    int sumA[100001] = {};
    for(int i=1; i<=n; i++)
    {
        cin >> sumA[i];
        if(i>0) sumA[i] += sumA[i-1];
        sumA[i] %= m;
    }

    map<int, int> map;
    map.insert(make_pair(0,1));

    long ans = 0;
    for(int i=1; i<=n; i++)
    {
        auto it = map.find(sumA[i]);
        if(it != map.end())
        {
            ans += it->second;
            map.erase(it);
            map.insert(make_pair(sumA[i], it->second + 1));
        }
        else
        {
            map.insert(make_pair(sumA[i], 1));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  long long N;
  cin >> N;
  //cout << N << endl;
  
  long long limitation;
  long long i = 0;
  
  while (log(i*i+i) < log(N)){
    i++;
  }
  
  limitation = i;
  //cout << limitation << endl;
  
  long long answer = 0;
  for (i=1; i < limitation; i++){
    if((N-i) % i == 0){
      answer+= (N-i)/i;
    }
  }

  cout << answer << endl;
  
}

Measured memory_bytes: 512
#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);
}

void solve() {
	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 k = 0; k <= c; ++k) {
				if (i*500+j*100+k*50 == x) ++ans;
			}
		}
	}
	cout << ans;
}

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


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


void solve(int test) {
	int a; cin >> a ;
	cout << a + a*a + a*a*a ;
}
 
int32_t main() {
 
 
    fast;
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<ll> sa(n);
	for (int i = 0; i < n; i++){
		sa[i] = i+1 - a[i];
	}
	ll ans = 0;
	sort(sa.begin(), sa.end());
	for (int i = 0; i < n; i++){
		auto it1 = lower_bound(sa.begin(), sa.end(), i+1+a[i]);
		auto it2 = upper_bound(sa.begin(), sa.end(), i+1+a[i]);
		ans += it2 - it1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6320
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,R;
  cin >> A >> B >> R;
  vector<int> Cs ( 101,0);
  for ( int i = 1 ; i<= 100 ; i++ ) {
    if ( (A%i)+(B%i) == 0 ) {
      Cs[i] = i;
    }
  }
  sort (Cs.begin(),Cs.end());
  reverse (Cs.begin(),Cs.end());
  cout << Cs[R-1] << endl;
}

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i ++) {
    if (s[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3644
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
/*
Node treeMinimum(Node x){
    
    
}
 */

Node treeSearch(Node u, int k){
    
    Node searched = u;
    
    if (searched == NIL) {
        return searched;
    }
    
    while (searched != NIL && k != searched->key) {
        if (k < searched->key) {
            searched = searched->left;
        }
        else{
            searched = searched->right;
        }
    }
    
    return searched;
    
}

/*
Node treeSuccessor(Node x){
    
    
}

void treeDelete(Node z){
    Node y; // node to be deleted
    Node x; // child of y
    
    
    
}
*/

void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;
    
    z = (Node)malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    
    if (y == NIL) {
        root = z;
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else
    {
        y->right = z;
    }
    
}

//?????????
void inorder(Node u){
    
    if(u == NIL) return;
    
    if (u->left != NIL) inorder(u->left);
    
    printf(" %d", u->key);
    
    if(u->right != NIL) inorder(u->right);
    
}

//?????????
void pre_order(Node u){
    if (u == NIL) return;
    
    printf(" %d", u->key);
    if(u->left != NIL) pre_order(u->left);
    if(u->right != NIL) pre_order(u->right);
}


int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'f' ){
            scanf("%d", &x);
            Node t = treeSearch(root, x);
            if ( t != NIL ) printf("yes\n");
            else printf("no\n");
        } else if ( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            pre_order(root);
            printf("\n");
        } else if ( com[0] == 'd' ){
            scanf("%d", &x);
            /*treeDelete(treeSearch(root, x));*/
        }
    }
    
    return 0;
}

Measured memory_bytes: 19792
from itertools import product

S = input()

summation = 0
for indices in product((0, 1), repeat=len(S) - 1):
    current_S = S[:]

    num_list = []
    counter = 0
    for i in indices:
        if i == 0:
            counter += 1
            continue
        else:
            appended_num, current_S = int(current_S[:counter + 1]), current_S[counter + 1:]
            num_list.append(appended_num)
            counter = 0
    else:
        num_list.append(int(current_S))

    summation += sum(num_list)
print(summation)


Measured memory_bytes: 3064
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,k,ans=0;

int main()
{
	cin>>n>>k;
	repn(i,n)
	{
		LL cnt=max(0LL,i-k)*(n/i),num=n%i;
		cnt+=max(0LL,(k==0 ? num:num+1-k));
		ans+=cnt;
		//cout<<i<<' '<<cnt<<endl;
	}
	cout<<ans<<endl;
	rt0;
}

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

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

using namespace std;

int f(string s, char x){
int ans = 0;
  rep(i, s.size()){
    if(s[i] != x) ans++;
    if(x == '0')x = '1';
    else x = '0';
  }
  return ans;
}

int main(void){
  string s;
  cin >> s;
  int ans = 10000000;

  ans = f(s, '0');
  ans = min(ans, f(s, '1'));

cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	string ans = "";
	for (int i = 0; i < s.length(); ++i) {
		char c = (s[i] - 'A' - 3 + 26) % 26 + 'A';
		ans += c;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

long long ori;
long long mo[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

long long mtod(long long b, long long ka, long long t, long long w, long long ki) {
	ka += b * 20;
	t += ka * 20;
	w += t * 18;
	ki += w * 20;
	return ori + ki;
}

bool isur(long long y) {
	return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
}

long long calc(long long y, long long m, long long d) {
	long long tmp = (y - 1) * 365 + (y - 1) / 4 - (y - 1) / 100 + (y - 1) / 400;
	for (long long i = 1; i < m; ++i) {
		tmp += mo[i - 1];
		if (isur(y) && i == 2) tmp++;
	}
	return tmp + d;
}

long long ytod(long long y, long long m, long long d) {
	return calc(y, m, d) - ori;
}

void ytom(long long d) {
	long long b, ka, t, w, ki;
	ki = d % 20; d /= 20;
	w = d % 18; d /= 18;
	t = d % 20; d /= 20;
	ka = d % 20; d /= 20;
	b = d % 13;
	printf("%lld.%lld.%lld.%lld.%lld\n", b, ka, t, w, ki);
}

void mtoy(long long d) {
	long long y, m;
	for (y = 1; 365 + isur(y) < d; ++y) d -= 365 + isur(y);
	for (m = 1; mo[m - 1] + (m == 2 && isur(y)) < d; ++m) d -= mo[m - 1] + (m == 2 && isur(y));
	printf("%lld.%lld.%lld\n", y, m, d);
}

int main() {
	ori = calc(2012, 12, 21);
	string s;
	while (cin >> s, s != "#") {
		long long flag = 0, now = 0, tmp[5] = {};
		for (long long i = 0; i < s.size(); ++i) {
			if (s[i] == '.') {
				tmp[flag++] = stoi(s.substr(now, i - now + 1));
				now = i + 1;
			}
		}
		tmp[flag] = stoi(s.substr(now, s.size() - now + 1));
		if (flag == 4) mtoy(mtod(tmp[0], tmp[1], tmp[2], tmp[3], tmp[4]));
		else ytom(ytod(tmp[0], tmp[1], tmp[2]));
	}
	
	return 0;
}


Measured memory_bytes: 3320
n = int(input())
a = list(map(int, input().split()))

sum_a = [0]
for v in a:
    sum_a.append(sum_a[-1] + v)

res = 0
mod = 10 ** 9 + 7
for i in range(n):
    res = (res + a[i] * sum_a[i] % mod) % mod

print(res)

Measured memory_bytes: 101920
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define div 998244353
#define rep(i,n) for(int i=0;i<n;i++)
int n,ans=0;
int a[200000];
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n){
        if(a[a[i]-1]==i+1)ans++;
    }
    ans/=2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


int main(){
	int r0,w0,c,r;
	while(cin>>r0>>w0>>c>>r&&(r0||w0||c||r)){
		for(int i=0;;i++){
			double res = (double)(r0+i*r)/c-w0;
//			cout<<res<<endl;
			if(res>=0){
				cout<<i<<endl;
				break;
			}
		}
	}
}

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

int n;

void countingSort(int*, int*, int);  

int main() {
  int *a, *b;
  int i, max = 0;

  scanf("%d",&n);
  a = (int*)malloc(sizeof(int)*(n+1));
  b = (int*)malloc(sizeof(int)*(n+1));
  for(i = 1;i <= n;i++) { 
    scanf("%d",&a[i]);
    if(max < a[i])
      max = a[i];
  }
  countingSort(a, b, max);
  for(i = 1;i <= n;i++) { 
    printf("%d", b[i]);
    if(i != n) 
      printf(" "); 
  }
  printf("\n");
  return 0;
}

void countingSort(int* a,int* b, int k) {
  int i, j, c[k+1];
  for(i = 0;i <= k;i++) 
    c[i] = 0;
  
  for(j = 1;j <= n;j++)
    c[a[j]]++;

  for(i = 1;i <= k;i++)
    c[i] += c[i-1];

  for(j = n;j > 0;j--) {
    b[c[a[j]]] = a[j];
    c[a[j]]--;
  }  
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        long[] B = new long[N];
        for (int i = 0; i < A.length; i++) {
            A[i] = sc.nextInt();
            B[i] = A[i] - (i + 1);
        }
        Arrays.sort(B);
        long mid = B[N / 2];
        long sum = 0;
        for (int i = 0; i < B.length; i++) {
            sum += Math.abs(B[i] - mid);
        }
        System.out.println(sum);
        sc.close();
    }
}

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

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int x,y,a,b;
    cin>>x>>y>>a>>b;
    int ans;
    if(a>=5 &&b>=2){
      ans=(x*a+y*b)*8/10;
    }
    else ans=x*a+y*b;
    if(ans>(x*max(5,a)+y*max(2,b))*8/10) ans=(x*max(5,a)+y*max(2,b))*8/10;
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3108
from collections import deque
def main():
    s = deque(list(input()))
    q = int(input())
    r = 1
    for _ in range(q):
        n, *fc = input().split()
        if n == "1":
            r *= -1
        else:
            f, c = fc
            f = 1 if f == "1" else -1
            if f*r == 1:
                s.appendleft(c)
            else:
                s.append(c)
    print("".join(list(s)[::r]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 10460
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>

using namespace std;

bool remaind(int num){
    int remain = 0;
    int reverse = 0;
    int tmp = num;
    while(tmp != 0){
        remain = tmp %10;
        reverse = reverse * 10 + remain;
        tmp /= 10;
    }
    return reverse==num;
}

int main() {

    int A;scanf("%d",&A);
    int B;scanf("%d",&B);

    int count = 0;
    for(int i=A; i<=B;i++){
        if(remaind(i)){
            count++;
        }
    }

    printf("%d",count);

    return 0;

}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i< n;i++){
        cin >> a.at(i);
    }
    double m = 1;
    double k = 0;
    for (int i = 0;i<n;i++){
        m *= a.at(i);
    }
    for (int i =0;i<n;i++){
        k += m/a.at(i);
    }
    cout << m/k << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int n;

        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();

        String strn = String.valueOf(n);
        int len = strn.length();

        String ans;
        int sum = 0;
        for (int i = 0; i < len; i++) {
            sum += Integer.parseInt(strn.substring(i, i + 1));
        }
        if (n % sum == 0) ans = "Yes";
        else ans = "No";

        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
S=list(input())
N=len(S)
x=0
for i in range(int((N-1)/2)):
    if S[i]!=S[-(i+1)]:
        print("No")
        break
    elif i==int((N-1)/2)-1:
        x+=1
import math
if x==1:
    S_l=S[:int((N-1)/2)]
    for i in range(int(math.ceil(len(S_l)/2))):
        if S_l[i]!=S_l[-(i+1)]:
            print("No")
            break
        elif i==int(math.ceil(len(S_l)/2))-1:
            x+=1
if x==2:
    S_m=S[int((N+3)/2)-1:N]
    for i in range(int(math.ceil(len(S_m)/2))):
        if S_m[i]!=S_m[-(i+1)]:
            print("No")
            break
        elif i==int(math.ceil(len(S_m)/2))-1:
            print("Yes")

Measured memory_bytes: 9132
#include<stdio.h>
 
int main(){
  int x, h, m, s;

  scanf("%d %d", &x,&h);

if(x>h){ 
  printf("a > b\n");
} else if(x<h){ 
  printf("a < b\n");
} else { 
  printf("a == b\n");
} 
 
  return 0;
}


Measured memory_bytes: 2624
// AOJ 2818: Imagawayaki Man
// 2017.11.23 bal4u@uu

#include <stdio.h>

#define N 10000
int p[N+N+2];
int a[N+1];
char buf[10], *bp;

int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, i, j, x;
	
	fgets(bp=buf, 10, stdin), n = getint();
	for (i = 2; i <= n; i++) {
		printf("? 1 %d\n", i), fflush(stdout);
		fgets(bp=buf, 10, stdin), a[i] = getint();
		if (a[i] == 1) j = i;
	}
	p[N] = 1, p[N-1] = j;
	for (i = 2; i <= n; i++) {
		if (i == j) continue;
		printf("? %d %d\n", j, i), fflush(stdout);
		fgets(bp=buf, 10, stdin), x = getint();
		if (x < a[i]) p[N-a[i]] = i;
		else          p[N+a[i]] = i;
	}
	for (i = 0; !p[i]; i++);
	printf("!");
	for (j = 0; j < n; j++) printf(" %d", p[i++]);
	putchar('\n');
	return 0;
}

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

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

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

  int ans=0;

  rep(i,n+1){
    int check=i;
    int keta = 0;
    
    while(check>0){
      check /= 10;
      keta++;
    }

    if(keta%2==1) ans++;
  }

  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

long long func( long long a, long long b, long long p ) {
    if ( b == 0 ) {
        return 1;
    }
    else if ( b%2 == 0 ) {
        long long temp = func( a, b/2, p );
        return (temp * temp)%p;
    }
    else {
        return ( func( a, b-1, p ) * a ) % p;
    }   
}

long long M[200001];
long long D[200001];


long long Comb( int n, int r ) {
    return (((M[n]*D[r])%MOD)*D[n-r])%MOD;
}

int main() {

    M[0] = 1;
    for ( long long i = 1; i <= 200000; i++ ) {
        M[i] = (M[i-1]*i)%MOD;
    }
    D[0] = 1;
    for ( long long i = 1; i <= 200000; i++ ) {
        D[i] = (D[i-1]*func( i, MOD-2, MOD ))%MOD;
    }

    int H,W,A,B;
    cin >> H >> W >> A >> B;

    long long ans = 0;
    for ( int x = B+1; x <= W; x++ ) {
        ans += ( Comb( x+H-A-2, x-1 ) * Comb( W-x+A-1, W-x ) )%MOD;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
signed main(){
  int n;cin>>n;
  ivec ans(n+1);
  for(int i=1;i*i<=n;i++){
    for(int j=1;j*j<=n;j++){
      for(int k=1;k*k<=n;k++){
        int po=i*i+j*j+k*k+i*j+j*k+k*i;
        if(po<=n)ans[po]++;
      }
    }
  }
  rep(i,n+1){
    if(i!=0)cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3584
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main()
{
    double w,h,x,y;
    cin >> w >> h >> x >> y;

    bool a = true;

    if(x == w/2 && y == h/2)  a = false;

    double ans = w * h / 2;

    if(a) cout << ans << " " << 0 << endl;

    else cout << ans << " " << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define fo(i, x, y) for(int i = x; i <= y; i ++)
#define fd(i, x, y) for(int i = x; i >= y; i --)
using namespace std;

int n, g, p[11], c[11];
int gg, pp[11], cc[11];
int d[11], bz[11];

int ans;

void dg(int x) {
	if(x > n) {
		fo(i, 1, n) p[i] = pp[d[i]], c[i] = cc[d[i]];
		g = gg;
		int sum = 0;
		fd(i, n, 1) {
			if(d[i] * 100 * p[i] >= g) {
				sum += g / (d[i] * 100) + (g % (d[i] * 100) > 0);
				break;
			}
			if(d[i] * 100 * p[i] + c[i] >= g) {
				sum += p[i]; break;
			}
			g -= d[i] * 100 * p[i] + c[i];
			sum += p[i];
		}
		ans = ans < sum ? ans : sum;
		return;
	}
	fo(i, 1, n) if(!bz[i]) {
		bz[i] = 1;
		d[x] = i;
		dg(x + 1);
		bz[i] = 0;
	}
}

int main() {
	scanf("%d %d", &n, &gg);
	fo(i, 1, n) scanf("%d %d", &pp[i], &cc[i]);
	ans = 1e9;
	dg(1);
	printf("%d\n", ans);
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  int n,m;
  cin >> n >> m;
  
  VI x(m);
  REP(i,m)cin >> x[i];
  sort(ALL(x));

  VI y(m-1);
  REP(i,m-1)y[i]=x[i+1]-x[i];
  sort(ALL(y));

  int ans=0;
  REP(i,m-n)ans+=y[i];

  cout << ans << endl;
}



Measured memory_bytes: 1024
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int a[2007];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    sort(a+1,a+1+n);
    long long ans=0;
    for(int i=1;i<=n-2;++i){
        for(int j=i+1;j<=n-1;++j){
            int l=j+1,r=n;
            int tamp=0;
            while(l<=r){
                int mid=(l+r)>>1;
                if(a[i]+a[j]>a[mid]){
                    tamp=mid;
                    l=mid+1;
                }
                else
                    r=mid-1;
            }
            ans+=max(0,tamp-j);
        }
    }
    cout<<ans;
    return 0;
}


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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  if ( a[0]==5&&a[1]==5&&a[2]==7 ) {
     cout << "YES";
  } else {
     cout << "NO";
  }
  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e18;
int si[] = {-1, 0, 1, 0};
int sj[] = {0, -1, 0, 1};

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<ll> x(n,0);
  rep(i,n) x[0] += a[i];
  for(int i = 1; i <= n-2; i += 2) x[0] -= 2*a[i];
  for(int i = 1; i < n; i++) x[i] = 2*a[i-1] - x[i-1];

  rep(i,n) cout << x[i] << endl;
  return 0;
}


Measured memory_bytes: 4756
import numpy as np

N = int(input())
lst = list(map(int,input().split()))

np_lst = np.array(lst)
min_val = np.min(np_lst)

ans = -1
while(True):
    tmp = set(np_lst%min_val)
    tmp = tmp - set([0])
    if min_val == 1:
        ans = 1
        break
    elif len(tmp) == 0:
        ans = min_val
        break
    else:
        if min(tmp) < min_val:
            min_val = min(tmp)
        else:
            ans = min_val
            break

print(ans)

Measured memory_bytes: 27440
def main():
	N = int(input())
	h = list( map(int, input().split()) )
	
	dp = [0 for _ in range(N)]
	dp[1] = abs(h[0] - h[1])
	for i in range(2, N):
		dp[i] = min( dp[i-1] + abs(h[i] - h[i-1]),
		             dp[i-2] + abs(h[i] - h[i-2]) )
	print(dp[N-1])

	return

main()



Measured memory_bytes: 13924
#include<stdio.h>
#define N 101
int main(){
  int G[N][N];
  int i,j,n,u,k,v;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      G[i][j]=0;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    for(j = 0;j < k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    }
  }

  for(i = 0;i < n;i++){
    for(j = 0;j < n-1;j++){
      //if(j != 0)printf(" ");
      printf("%d ",G[i][j]);
    }
    printf("%d\n",G[i][j]);
    }
  return 0;
}

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

int main(){
  int r,g,b,n;
  int cnt=0;

  cin>>r>>g>>b>>n;

  for(int i=0;i*r<=n;i++){
    for(int j=0;j*g<=n;j++){
      if(i*r+j*g>n){
        break;
      }else if((n-(i*r+j*g))%b==0){
        cnt++;
      }

    }
  }

  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    S = input()

    for i, c in enumerate(S, start=1):
        if i == K:
            print(str(c).lower(), end='')
        else:
            print(c, end='')
    else:
        print()


if __name__ == '__main__':
    main()


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

ll dp[3001][3001][2];

ll score(vector<ll>& v,int i,int j,bool turn){
    if(i>j){
        return 0;
    }
    if(dp[i][j][turn]!=-1){
        return dp[i][j][turn];
    }
    if(turn==1){
        return dp[i][j][turn] = max(v[i] + score(v,i+1,j,0),v[j] + score(v,i,j-1,0));
    }
    else{
        return dp[i][j][turn] = min(score(v,i+1,j,1),score(v,i,j-1,1));
    }
}

int main(){
    int n;
    cin>>n;
    vector<ll> v(n);
    ll sum = 0;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum += v[i];
    }
    ll scoreX = score(v,0,n-1,1);
    ll scoreY = sum - scoreX;
    cout<<scoreX - scoreY;
    return 0;
}

Measured memory_bytes: 141184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
ll N;
string s;
const ll INF = 1e12;

int main()
{
    cin >> N;
    cin >> s;
    int result = 1;
    for (int i = 0; i < N - 1; ++i)
    {
        if (s[i] != s[i + 1])
            ++result;
    }
    cout << result << endl;
}

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




int main(){
    int a,b;
    cin>>a>>b;
    if(a%3!=0&&b%3!=0&&(a+b)%3!=0)cout<<"Impossible"<<endl;
    else cout<<"Possible"<<endl;
    return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
#include <functional>
 
using namespace std;
typedef long long ll;
const ll INF = 1e18;

# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
# define pb push_back
 
ll X,Y,A,B,C;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> X >> Y >> A >> B >> C;
    
    vector<ll> p(A);
    rep(i,A) {
        cin >> p[i];
    }
    vector<ll> q(B);
    rep(i,B) {
        cin >> q[i];
    }
    vector<ll> r(C);
    rep(i,C) {
        cin >> r[i];
    }

    sort(all(p), greater<ll>());
    sort(all(q), greater<ll>());
    sort(all(r), greater<ll>());
    
    priority_queue<ll> pq;
    rep(i,X) {
        pq.push(p[i]);
    }
    rep(i,Y) {
        pq.push(q[i]);
    }
    rep(i,C) {
        pq.push(r[i]);
    }
    
    ll ans = 0;
    rep(i,X+Y) {
        ans += pq.top();
        pq.pop();
    }
    
    cout << ans << endl;

    return 0;
}


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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 110;

int na, nb, nc, k;
LL a[N], b[N], t[N];

bool cmp(LL a, LL b)
{
	return a > b;
}

void merge(int nb)
{
	priority_queue<pair<LL, int> > heap;
	for (int i = 0; i < na; i ++ ) heap.push({a[i] + b[0], 0});
	
	na = min(3000, min(k, na * nb));
	for (int i = 0; i < na; i ++ )
	{
		LL v = heap.top().F;
		int j = heap.top().S;
		heap.pop();
		
		t[i] = v;
		if (j + 1 < nb) heap.push({v - b[j] + b[j + 1], j + 1});
	}
	
	memcpy(a, t, sizeof t);
}

int main()
{
	cin >> na >> nb >> nc >> k;
	
	for (int i = 0; i < na; i ++ ) cin >> a[i];
	sort(a, a + na, cmp);
	
	for (int i = 0; i < nb; i ++ ) cin >> b[i];
	sort(b, b + nb, cmp);
	merge(nb);

	for (int i = 0; i < nc; i ++ ) cin >> b[i];
	sort(b, b + nc, cmp);
	merge(nc);
	
	for (int i = 0; i < k; i ++ ) cout << a[i] << endl;
	return 0;
}

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

int main (){
	string a,b,c;
	char temp,win;
	cin >> a >> b >> c;
	int as = a.size()+1;
	int bs = b.size()+1;
	int cs = c.size()+1;
	
	int aaa=0,bbb=0,ccc=0;
	temp = a[aaa];
	aaa = aaa++;
	while(1){
		if(aaa == as){
			win = 'A';
			break;
		}
		if(bbb == bs){
			win = 'B';
			break;
		}
		if(ccc == cs){
			win = 'C';
			break;
		}
		
		if(temp == 'a'){
			temp = a[aaa];
			aaa++;
		}
		if(temp == 'b'){
			temp = b[bbb];
			bbb++;
		}
		if(temp == 'c'){
			temp = c[ccc];
			ccc++;
		}
	}
	cout << win << endl;
	return 0;
}

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

int main(void){
  int i,n,q,mid,left,right,cnt = 0;
  int S[100000],T[50000];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&T[i]);
  }


  for(i = 0;i < q;i++){
    left = 0;
    right = n;
    while(left < right){
      
      mid = (left + right) / 2;
      
      if(S[mid] == T[i]){
	cnt++;
	break;
      }
      else if(S[mid] > T[i]){
	right = mid;
	
      }else {
	left = mid + 1;
      }
    }
  }

  printf("%d\n",cnt);     

  return 0;
}



Measured memory_bytes: 2316
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     SPEED       ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());




int main()
{
	SPEED;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>k>>s;
		// n=s.length();
		// ll a[n];
		s[k-1]=tolower(s[k-1]);
		
		cout<<s;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[0])
ans=0
for a,b in ab:
  if m>=b:
    m-=b
    ans+=b*a
  else:
    ans+=a*m
    break
print(ans)


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

using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string ans = "AC";
  
  if(s[0] != 'A') ans = "WA";
  int cnt = 0;
  for(int i = 1; i<s.size(); i++){
    if(i >= 2 && i < s.size()-1 ){
      if(s[i]=='C') cnt++;
      else if(isupper(s[i])) ans = "WA";
    }else if(isupper(s[i])) ans = "WA";
  }
  if(cnt != 1) ans = "WA";
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.equals("RRR")) System.out.println("3");
        else if (s.contains("RR")) System.out.println("2");
        else if (s.contains("R")) System.out.println("1");
        else System.out.println("0");
    }
}

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

int main() {
	string S;
	cin >> S;
	if (S.at(S.size() - 1) != 's') {
		cout << S + 's' << endl;
	}
	else if(S.at(S.size() - 1) == 's'){
		cout << S + "es" << endl;
	}
}

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

#define HASH_SIZE 65521

typedef struct _data
{
	int val;
	int flag;
	struct _data *next;
} data;

int hashKey(int key)
{
	return key % HASH_SIZE;
}


int add(data **table, int val)
{
	int key = hashKey(val);
	data *p = table[key];
	data *tmp;

	while (p != NULL)
	{
		if (p->val == val) return 1;
		p = p->next;
	}

	if ((tmp = (data*)malloc(sizeof(data))) == NULL) return -1;
	tmp->val = val;
	tmp->flag = 0;
	tmp->next = table[key];
	table[key] = tmp;

	return 0;	
}

data *search(data **table, int val)
{
	int key = hashKey(val);
	data *p = table[key];

	while (p != NULL)
	{
		if (p->val == val) return p;
		p = p->next;
	}
	return NULL;
}

void terminate(data **table)
{
	int i;
	data *p, *next;

	for (i = 0; i < HASH_SIZE; i++)
	{
		p = table[i];
		while (p != NULL)
		{
			next = p->next;
			free(p);
			p = next;
		}
		table[i] = NULL;
	}
}

int main()
{
	data *table[HASH_SIZE];
	data *p;
	int i, n, val, count;

	for (i = 0; i < HASH_SIZE; i++) table[i] = NULL;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &val);
		if (add(table, val) < 0) return -1;
	}

	count = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &val);
		if ((p = search(table,val)) == NULL || p->flag) continue;
		count++;
		p->flag = 1;
	}
	printf("%d\n", count);

	terminate(table);

	return 0;
}

Measured memory_bytes: 2316