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

using namespace std;
int arr[100005];

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    int zer = 0, neg = 0;
    long long res = 0;
    int mn = 1e9;
    for (int i = 0; i < n; i++) {
        scanf("%d", arr + i);
        res += abs(arr[i]);
        zer += !arr[i];
        mn = min(mn, abs(arr[i]));
        neg += arr[i] < 0;
    }
    if (neg % 2 == 0 || zer) {
        printf("%lld\n", res);
    } else {
        printf("%lld\n", res - 2 * mn);
    }
    return 0;
}


Measured memory_bytes: 640
from math import ceil
from fractions import Fraction
n = int(input())

nt, na = 1, 1
for i in range(n):
    rt, ra = list(map(int, input().split()))
    r = max([ceil(Fraction(nt, rt)), ceil(Fraction(na, ra))])
    nt = r*rt
    na = r*ra
    # print(nt, na)

print(nt+na)


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

int main() {
	int price = 700;
	char s[3];
	for (int i = 0;i < 3;i++) {
	    cin >> s[i];
	    if (s[i] == 'o') price = price + 100;
	}
	cout << price;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

int main(){
	long count = 0,count_C=0,count_D=0,count_CD=0;
	long A,B,C,D,L,a,b,i,r,tmp;

	cin >> A >> B >> C >> D;

	count = B-A+1;
	count_C = B/C - (A-1)/C;
	count_D = B/D - (A-1)/D;

	a = C;
	b = D;
	if (a<b){
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while(r != 0){
		a = b;
		b = r;
		r = a % b;
	}

	L = C * D / b;

	count_CD = B/L - (A-1)/L;
	
	count = count - count_C - count_D + count_CD;
	cout << count << endl;

	return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
#include <cstdio>
using namespace std;
typedef complex<double> xy_t;

double crossPro(xy_t a, xy_t b)
{
	return (conj(a) * b).imag();
}

int main()
{
	double x[4],y[4];
	while(1)
	{
		for (int i = 0; i < 4; ++i)
		{
			cin >> x[i] >> y[i];
		}

		if (!cin) break;

		xy_t a(x[0],y[0]),b(x[1],y[1]),c(x[2],y[2]),p(x[3],y[3]);
		double s1 = crossPro(a-p,b-p);
		double s2 = crossPro(b-p,c-p);
		double s3 = crossPro(c-p,a-p);
		bool ok = false;
		if (((s1>0)&&(s2>0)&&(s3>0))||((s1<0)&&(s2<0)&&(s3<0)))
		{
			ok = true;
		}

		if (ok)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3160
import java.util.*;

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

        while (now < b) {
            now = now - 1 + a;
            num ++;
        }
        System.out.println(num);

        sc.close();
    }
}

Measured memory_bytes: 35832
// ProblemURL : https://atcoder.jp/contests/abc098/tasks/abc098_a
// ---------------------------------------------
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	ans := a + b
	if a-b > ans {
		ans = a - b
	}
	if a*b > ans {
		ans = a * b
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
  int a, b, c, x, y;
  int common_pizza, common_price, extra_pizza, extra_tanka, extra_price;
  cin >> a >> b >> c >> x >> y;
  common_pizza = x < y?x:y;
  common_price = a + b < 2*c?(a+b)*common_pizza:2*c*common_pizza;
  extra_pizza = x < y?y-common_pizza:x-common_pizza;
  extra_tanka = x < y?b:a;
  if (extra_tanka > 2*c) {
    extra_tanka = 2*c;
  }
  extra_price = extra_tanka * extra_pizza;
  cout << common_price + extra_price << endl;
  return(0);
}


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

using namespace std;

bool comp(pair<int,int> a, pair<int,int> b){
	return a.first < b.first;
}

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

	int n;
	cin >> n;
	vector<pair<int,int>> v;
	for(int i=0; i<n; i++){
		int num;
		cin >> num;
		v.push_back(make_pair(num,i));
	}
	sort(v.begin(),v.end(),comp);
	for(auto x:v){
		cout << x.second + 1<< " ";
	}
	return 0;
}

Measured memory_bytes: 4264
#include"bits/stdc++.h"
using namespace std;
namespace ORIGIN {
	#define LL long long
	#define VLL vector<long long>
	#define SORT(x) sort(x.begin(),x.end())
	#define REVE(x) reverse(x.begin(),x.end())
	#define rep(i,n) for(int i=0;i<n;i++)
	#define COUT(x) cout<<x<<endl
	double pai = 3.1415926535;
	string atc = "atcoder";
	typedef pair<long long, long long> data_t;
	string strnum = "0123456789";
	string alpS = "abcdefghijklmnopqrstuvwxyz";
	string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int sizealp = (int)(alpS.size());
	int mod = 1e9 + 7;
	bool test = false;
}
using namespace ORIGIN;

void Test(char a) {
	if (test) {
		printf("%c", a);
	}
}
int gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}

int main() {
	int N;
	cin >> N;
	VLL A(N);
	rep(i, N)cin >> A[i];
	VLL L, R;
	L.push_back(A[0]);
	for (int i = 1; i < N; i++) {
		L.push_back(gcd(A[i], L[i - 1]));
	}
	REVE(A);
	R.push_back(A[0]);
	for (int i = 1; i < N; i++) {
		R.push_back(gcd(A[i], R[i - 1]));
	}
	REVE(A);
	REVE(R);
	int MAX=0;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			MAX = R[i+1];
		}
		else if (i == N - 1) {
			MAX =max(L[i-1],(LL)MAX);
		}
		else {
			MAX = max(gcd(L[i - 1], R[i + 1]), MAX);
		}
	}
	COUT(MAX);
}

Measured memory_bytes: 3316
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
template <typename T>
using Vec3 = vector<Vec2<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repe(i, n) REPN(i, 0, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define reper(i, n) REPNR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec a(n);
	rep(i, n) cin >> a[i];

	Vec dp(k+1);
	
	repe(i, k){
		if(i < a[0]) dp[i] = 1;
		else{
			ll f = 1;
			rep(j, n){
				if(a[j] > i) break;
				if(dp[i-a[j]]){
					f = 0;
					break;
				}
			}
			dp[i] = f;
		}
	}
	if(!dp[k]) co("First");
	else co("Second");

	return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
b[0] = 0
for i in range(1, n):
    if a[i-1] + b[i-1] > a[i]:
        b[i] = a[i-1] + b[i-1] - a[i]
    else:
        b[i] = 0
c = 0
for i in range(1, n):
    c = c + b[i]
print(c)


Measured memory_bytes: 32072
#include<stdio.h>
int main(void)
{
	int a, b, c,n;
	scanf("%d %d %d", &a, &b, &c);

	if (a > b)
	{
		n = a;
		a = b;
		b = n;
	}
	
	if (a > c)
	{
		n = c;
		c = b;
		b = a;
		a = n;
	}

	if (b > c)
	{
		n = c;
		c = b;
		b = n;
	}

	printf("%d %d %d\n", a, b, c);

	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair

typedef long long int ll;
typedef vector< pair<int,int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int,int> pii;

const int INF= 10000000;
const int MOD= 1e9+7;

const int nmax=40,abmax=10,cmax=100;
int dp[nmax+2][abmax*nmax+2][abmax*nmax+2];
int a[nmax+1],b[nmax+1],c[nmax+1];

int main()
{
    std::ios::sync_with_stdio(0);

    int n,ma,mb;
    cin>>n>>ma>>mb;

     for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];

    for(int i=0;i<=nmax;i++)
    {
        for(int j=0;j<=abmax*nmax;j++)
        {
            for(int k=0;k<=abmax*nmax;k++)
                dp[i][j][k]=INF;
        }
    }

    dp[0][0][0]=0;// 0 amount is required to make 0 sum;

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=abmax*nmax;j++)
        {
            for(int k=0;k<=abmax*nmax;k++)
            {
                if(dp[i][j][k]==INF)
                    continue; // no use
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);// if we do not choose the next element;
                dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],(dp[i][j][k]+c[i]));
            }
        }
    }

    int ans=INF;


    for(int i=1;i<=abmax*nmax;i++)
    {
        for(int j=1;j<=abmax*nmax;j++)
        {
            if(i*mb==j*ma)
            {
             ans=min(ans,dp[n][i][j]);
            }
        }

    }

    if(ans==INF)
        ans=-1;

    cout<<ans;

    return 0;
}


Measured memory_bytes: 26496
N, T = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for k in range(N)]
B[0] = A[0]
for k in range(1,N):
    B[k] = min(B[k-1],A[k])
m = 0
for k in range(N):
    m = max(A[k]-B[k],m)
ans = 0
for k in range(N):
    if A[k]-B[k] == m:
        ans += 1
print(ans)


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

using namespace std;

#define ll long long

bool isGreater(const vector<int> &a, const vector<int> &b) {
    auto min = a.size() > b.size() ? b.size() : a.size();
    for (auto i = 0; i < min; ++i) {
        if (a[i] > b[i]) return true;
        else if (a[i] < b[i]) return false;
    }
    return a.size() >= b.size();
}

int main() {
    int n;
    cin >> n;
    vector<int> avec(n);
    for (auto &v : avec) cin >> v;
    int m;
    cin >> m;
    vector<int> bvec(m);
    for (auto &b : bvec) cin >> b;
    if (isGreater(avec, bvec)) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}


Measured memory_bytes: 3104
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数

int main() {
  int N, a = 0, b = 0;
  ci(N);
  ve<ll> H(N);
  rep(i, N){
    ci(H.at(i));
  }
  rep(i, N - 1){
    if(H.at(i) >= H.at(i + 1)){
      a++;
    }
    else{
      b = max(b, a);
      a = 0;
    }
  }
  co(max(a, b));
}

Measured memory_bytes: 1152
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>

using namespace std;

int main() {
   
   int N;
   cin >> N;
   int t = N;
   int k = 1;
   bool flg = false;
   while (t > 0) {
      t -= k;
      k++;
      if (t == 0) {
         flg = true;
      }
   }
   k -= 1;
   
   int s[k];
   s[0] = 0;
   for (int i = 1; i <= k; i++) {
      s[i] = s[i-1] + i;
   }
   
   int A[k][k];
   for (int i = 0; i < k; i++) {
      for (int j = 0; j < k; j++) {
         if (i == j) A[i][j] = s[i+1];
         else A[i][j] = A[j][i] = s[i] + j + 1;
      }
   }
   if (!flg) cout << "No" << endl;
   else {
      cout << "Yes" << endl;
      cout << k+1 << endl;
      for (int i = 0; i < k; i++) {
         cout << k;
         for (int j = 0; j < k; j++) cout << " " << A[i][j];
         cout << endl;
      }
      cout << k;
      for (int i = 0; i < k; i++) cout << " " << A[i][i];
      cout << endl;
   }
   return 0;
}


Measured memory_bytes: 2176
N = int(input())
A = list(map(int, input().split()))

x = [None] * N
x[0] = sum(A) - 2 * sum([a for a in A[1::2]])
for i in range(N-1):
    x[i+1] = 2 * A[i] - x[i]
print(" ".join(map(str, x)))

Measured memory_bytes: 19140
import java.util.Scanner;

public class Main {

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

    long h = sc.nextLong();

    if (h == 1) {
      System.out.println(1);
      return;
    }
    // n段のピラミッド
    long cnt = 1;
    while (h / 2 > 1) {
      h = h / 2;
      cnt++;
    }

    Double d = 0d;
    for (long i = 0; i < cnt + 1; i++) {
      d += Math.pow(2, i);
    }
    System.out.println(d.longValue());
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


#define N 2000007
ll fac[N], inv[N], finv[N];

void cominit(int n) {
    int i;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (i = 2; i < n + 2; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
    return;
}

ll com(int n, int r) {
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    if (r == 0 || r == n) return 1;
    return (fac[n] * finv[r]) % mod * finv[n - r] % mod;
}

ll comsum(int r, int c) {
    int i;
    ll res = 0, tfe = 1;
    for (i = 0; i < r + c; i++) {
        res = (res + tfe) % mod;
        tfe = tfe * 2 % mod;
        if (i >= r) {
            tfe = (tfe + mod - com(i, r)) % mod;
        }
        if (i >= c) {
            tfe = (tfe + mod - com(i, c)) % mod;
        }
    }
    return (res + com(r + c, r)) % mod;
}

int main(void) {
    int r1, c1, r2, c2;
    ll ans;

    scanf("%d%d%d%d", &r1, &c1, &r2, &c2);

    cominit(r2 + c2 + 3);

    r1--;
    c1--;
    
    ans = (comsum(r2, c2) - comsum(r1, c2) - comsum(r2, c1) + comsum(r1, c1) + mod) % mod;

    printf("%lld\n", ans);
    
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;cin >> s;
    int y = 0,z=0,x=0;
    REP(i,SZ(s)){
        if(!(s[i]=='h'||s[i]=='i')){
            cout << "No"
                 << "\n";
            return 0;
        }
        if(s[i]=='i'){
            if (y == 1){
                z = 1;
                y = 0;
                continue;
            }else{
                cout << "No"
                     << "\n";
                return 0;
            }
                
        }
        if(s[i]=='h'){
            if(y==1){
                cout << "No"
                     << "\n";
                return 0;
            }else{
                y = 1;
            }
        }

    }
    if(y==0){

        cout << "Yes"
             << "\n";
    }else{
        cout << "No"
             << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int a,b,c,x,y;
  // vector<int> m;

  cin >>a>>b>>c>>x>>y;
  // for (int i = 0; i < n; ++i) {
  //   cin >> mt;
  //   m.push_back(mt);
  // }
  // for (auto l:m) {
  //   cout<<l<<endl;
  // }
  vector<int> p;
  int na=0, nb=0, nc=0;
  int big = (x>y) ? x : y;

  


  c=c*2;
  int value,rx,ry;
  for (int i=0; i <= big; ++i) {
    rx = (x>=i) ? (x -i): 0;
    ry = (y>=i) ? (y -i) : 0;
    value= rx * a + ry * b + i * c;
    p.push_back(value);
  }

  
  int minn = *min_element(p.begin(), p.end());
  cout<<minn<<endl;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define maxn 500005
#define ll long long
#define mod 1000000007

typedef pair<int, int> P;

int n;
char s[maxn];
vector<int> v[maxn];
bool used[maxn];
ll d[maxn];

void dfs(int now)
{
    if (used[now])
        return;
    used[now] = 1;
    d[now] = 0;
    if (v[now].empty())
        return;
    for (int x : v[now])
    {
        dfs(x);
        d[now] = max(d[now], d[x]);
    }
    d[now]++;
}

int main()
{
    //cin >> n;
    scanf("%s", s + 1);
    n = strlen(s + 1) + 1;
    for (int i = 1; i <= n - 1; i++)
    {
        if (s[i] == '<')
            v[i + 1].push_back(i);
        else
            v[i].push_back(i + 1);
    }
    for (int i = 1; i <= n; i++)
    {
        if (!used[i])
            dfs(i);
        //printf("i=%d %d\n", i, d[i]);
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans += d[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 55936
import math
def C(a,b):
    return math.factorial(a) // (math.factorial(b)*math.factorial(a-b))

def count(N, K):
    if K == 0:
        return 1
    if N == 0:
        return 0
    keta = int(math.log10(N)) + 1
    if keta < K:
        return 0
    elif keta == K:
        if K == 1:
            return N
        elif K == 2:
            return (N//10 - 1) * 9 + N % 10
        else:
            return (N//100 - 1) * 81 + ((N//10)%10 - 1) * 9 + N % 10
    else:
        keta1 = (N//(10**(keta-1)))%10
        ans = C(keta - 1, K) * (9**K)
        ans += (keta1 - 1) * C(keta-1, K-1) * (9**(K-1))
        ans += count(N-(keta1*(10**(keta-1))), K-1)
        return ans

N = int(input())
K = int(input())
print(count(N,K))

Measured memory_bytes: 3064
module.exports=function(r){var e={};function t(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=r,t.c=e,t.d=function(r,e,n){t.o(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:n})},t.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},t.t=function(r,e){if(1&e&&(r=t(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var o in r)t.d(n,o,function(e){return r[e]}.bind(null,o));return n},t.n=function(r){var e=r&&r.__esModule?function(){return r.default}:function(){return r};return t.d(e,"a",e),e},t.o=function(r,e){return Object.prototype.hasOwnProperty.call(r,e)},t.p="",t(t.s=0)}([function(r,e,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,e){function t(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(t.push(i.value),!e||t.length!==e);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return t}(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){for(var e=t(r[0].split(" ").map(function(r){return Number(r)}),2),n=e[0],o=e[1],u=r[1].split(" ").map(function(r){return Number(r)}),i=0,f=0;f<n;f++)if(u[f]>o&&(i+=u[f]-o,u[f]=o),f<n-1&&u[f]+u[f+1]>o){var l=u[f]+u[f+1]-o;u[f+1]-=l,i+=l}console.log(i)}},function(r,e){r.exports=require("fs")}]);

Measured memory_bytes: 19020
import sys
from heapq import heappush, heappop
#input = sys.stdin.readline

def main():
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    ans=0
    for i in range(n-1,-1,-1):
        if a[i+1]>b[i]:
            ans+=b[i]
        else:
            ans+=min(a[i]+a[i+1],b[i])
            a[i]=max(a[i]-(b[i]-a[i+1]),0)
    print(ans)    

if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    int n,t,e;
    cin>>n>>t>>e;
    for (int i = 0; i < n; ++i) {
        int x;
        cin>>x;
        int xi=x;
        while(x<=t+e){
            if(x>=t-e&&x<=t+e){
                cout<<i+1<<endl;
                return 0;
            }
            x+=xi;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    long long n,i,j,k,x,y,z;
    z=0;
    cin>>n;
    for (i=0;i<n;i++)
    {
    	cin>>arr[i];
	}
	for (i=1;i<n;i++)
	{
		if (arr[i]<arr[i-1])
		{
			z=z+arr[i-1]-arr[i];
			arr[i]=arr[i-1];
		}
	}
	cout<<z<<endl;
}

Measured memory_bytes: 5168
#include <iostream>
#include <math.h>
#include <cstring>
#include <algorithm>

using namespace std;

int main(void){
  int a, b, c;
  cin >> a >> b >> a >> c;
  if(++b != c){
    cout << "1" << endl;
  }
  else{
    cout << "0" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
/*
      @author: Charan Sai
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define itr(i, n) for(int i = 0; i < n; ++i)
#define itr1(i, a, n) for(int i = a; i < n; ++i)
#define INF 1e9 + 5
#define pb push_back 
#define ppi pair<int, int>
#define min_heap(type) priority_queue<type, vector<type>, greater<type>>
#define max_heap(type) priority_queue<type>
#define endl "\n"
#define nl cout << "\n"
// For Debugging
#define deb(x) cout << #x << " " << x << endl;

bool solution() {
    string s; cin >> s;
    return (s[2] == s[3] && s[4] == s[5]);
}
int32_t main() {
      IOS;
      int t = 1;
      // cin >> t;
      while(t--) {
            if(solution()) cout << "Yes" << endl;
            else cout << "No" << endl;
      }
      return 0;
}

Measured memory_bytes: 256
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 = Integer.parseInt(sc.next());
        int[] ary = new int[N];
        int[] aryOrg = new int[N];
        for (int i = 0; i < N; i++) {
            int a = Integer.parseInt(sc.next());
            ary[i] = a;
            aryOrg[i] = a;
        }
        Arrays.sort(ary);
        int cnt = 0;
        for (int i = 0; i < N; i++) {
            if (ary[i] == aryOrg[i]) {
                cnt++;
            }
        }
        if (N - cnt == 2 || N - cnt == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 22996
n, x, y = map(int, input().split())
x -= 1
y -= 1

dist = [0]*n
for i in range(n-1):
  for j in range(i, n):
    dist[min(j-i, abs(i-x)+abs(j-y)+1)] += 1

for i in range(1, n):
  print(dist[i])

Measured memory_bytes: 3444
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


fn main() {
    input!{n:usize, l:i32, s:[String;n]};
    let mut s = s;
    s.sort();
    println!("{}", s.concat());
}

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

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

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b; cin >> a >> b;
  string s = "";
  if(a < b) {
    for(int i=0;i<b;++i) {
      s.push_back(a+'0');
    }
  } else {
    for(int i=0;i<a;++i) {
      s.push_back(b+'0');
    }
  }
  cout << s << endl;

}


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

const int INF = 1 << 30;
vector<vector<pair<int, int>>> graph;
int sum, D;

int dfs(int v, int r) {
	vector<int> ch = {0, 0};
	for(auto p : graph[v]) {
		int sv, d;
		tie(sv, d) = p;
		if (sv == r) continue;
		int res = dfs(sv, v);
		if (res < 0) {
			ch.push_back(0);
			sum += d;
		} else {
			sum += d * 3;
			ch.push_back(res + d);
		}
	}

	if (ch.size() <= 2) return -1;
	sort(ch.rbegin(), ch.rend());
	D = max(D, ch[0] + ch[1]);
	return ch[0];
}

bool solve(){
	int N;
	cin >> N;
	if (N == 0) return false;

	vector<int> p(N), d(N);
	for(int i = 1; i < N; ++i) {
		cin >> p[i];
		--p[i];
	}
	for(int i = 1; i < N; ++i) {
		cin >> d[i];
	}

	graph.clear();
	graph.resize(N);
	for(int i = 1; i < N; ++i) {
		graph[i].emplace_back(p[i], d[i]);
		graph[p[i]].emplace_back(i, d[i]);
	}

	sum = 0, D = 0;
	for(int v = 0; v < N; ++v) {
		if (graph[v].size() <= 1) continue;
		dfs(v, -1);
		break;
	}

	cout << sum - D << endl;
	return true;	
}
int main(){
	while(solve()){}
	return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
long long a1[200], b[200], c, m[200][200000];
int n;
int main()
{
    scanf("%d %llu", &n,&c);
    for(int i=1; i<=n; i++)
        scanf("%llu %llu", &a1[i], &b[i]);
    for(int i=1; i<=n; i++)
        for(int j=0; j<=c; j++)
        {
            m[i][j] = m[i-1][j];
            if(j>=a1[i])
                m[i][j] = max(m[i][j], m[i-1][j-a1[i]] + b[i]);
        }
    printf("%llu", m[n][c]);
}

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

int main(void){
  int N,M;
  cin >> N >> M;
  int vote_sum=0;
  int item[N];
  for(int i=0;i<N;i++){
  	cin >> item[i];
  	vote_sum+=item[i];
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(float(item[i]) >= (float)(vote_sum/(4.0*M)) ){
      count++;
    }
  }
  if(count >= M){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d  long double
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (int)1e18
#define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

 
signed main()
{
    haha
    int b[3][3];
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        cin>>b[i][j];
    }
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
         for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        if(b[i][j]==x)
        b[i][j]=0;
    }
        
    }
    int f=0;
    for(int i=0;i<3;i++)
    {
        int t=0;
        for(int j=0;j<3;j++)
        
        {
            if(b[i][j]==0)
            continue;
            t=1;
            
        }
        if(t==0)
        f=1;
    }
      for(int i=0;i<3;i++)
    {
        int t=0;
        for(int j=0;j<3;j++)
        
        {
            if(b[j][i]==0)
            continue;
            t=1;
            
        }
        if(t==0)
        f=1;
    }
    if(b[0][0]==0 && b[1][1]==0 && b[2][2]==0)
    f=1;
     if(b[0][2]==0 && b[1][1]==0 && b[2][0]==0)
    f=1;
    if(f==1)
    cout<<"Yes";
    else
    cout<<"No";
  
 
    
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int n;
vector <int> E[200020];
int d[200020];

int good(vector <int> h, int mxl) {
	rep(i, szz(h)/2) if(h[i] + h[szz(h)-1-i] > mxl) return 0;
	return 1;
}

int dfs(int x, int fa, int mxl) {
	if(szz(E[x]) - (fa != -1) == 0) { d[x] = 0; return 1; }
	vector <int> L;
	for(int e : E[x]) if(e != fa) {
		if(!dfs(e, x, mxl)) return 0;
		L.pb(d[e]);
	}
	sort(all(L));
	if(szz(L) % 2 == 0) {
		if(good(L, mxl - 2)) { d[x] = 0; return 1; }
		if(fa == -1) { return 0; }
		int low = 0, high = szz(L) - 1, res = -1;
		while(low <= high) {
			int mid = (low + high) >> 1;
			vector <int> nh;
			rep(i, szz(L)) if(i != mid) nh.pb(L[i]);
			int ok = 1;
			if(nh.back() + 1 > mxl) ok = 0;
			nh.pop_back();
			if(good(nh, mxl - 2) == 0) ok = 0;
			if(ok) res = mid, high = mid - 1;
			else low = mid + 1;
		}
		if(res == -1 || L[res] + 1 > mxl) return 0;
		d[x] = L[res] + 1;
		return 1;
	}
	else {
		int low = 0, high = szz(L) - 1, res = -1;
		while(low <= high) {
			int mid = (low + high) >> 1;
			vector <int> nh;
			rep(i, szz(L)) if(i != mid) nh.pb(L[i]);
			int ok = 1;
			if(good(nh, mxl - 2) == 0) ok = 0;
			if(ok) res = mid, high = mid - 1;
			else low = mid + 1;
		}
		if(res == -1 || L[res] + 1 > mxl) return 0;
		d[x] = L[res] + 1;
		return 1;
	}
}

void solve() {
	scanf("%d", &n);
	rep(i, n-1) {
		int x, y; scanf("%d%d", &x, &y);
		E[x].pb(y);
		E[y].pb(x);
	}
	
	int odd = 0;
	for(int i=1;i<=n;i++) {
		if(szz(E[i]) & 1) ++odd;
	}
	
	printf("%d ", odd / 2);
	int low = 1, high = n-1, res = -1;
	while(low <= high) {
		int mid = (low + high) >> 1;
		if(dfs(1, -1, mid)) res = mid, high = mid - 1;
		else low = mid + 1;
	}
	printf("%d\n", res);
}

int main(){
	int Tc = 1; // scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}




Measured memory_bytes: 20480
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
ll X;
void MAIN() {
	cin>>X;
	ll cur=100;
	int i=0;
	while(cur<X)cur=(ll)(1.01*cur),i++;
	cout<<i;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <array>
#include <queue>
#include <set>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    string S_prime, T;
    cin >> S_prime >> T;
    string S = S_prime;

    priority_queue<string, vector<string>, greater<string>> q;
    for (int index=0; index <= (int)S_prime.size() - (int)T.size(); index++)
    {
        bool found = false;
        // Tの頭の文字と一致 or '?'なら詳しく調査開始
        if (S_prime[index] == T[0] || S_prime[index] == '?')
        {
            S = S_prime;

            // 探索範囲外の'?'は全部'a'に置換
            for (int replace_index=0; replace_index < (int)S_prime.size(); replace_index++)
            {
                if (S[replace_index] == '?')
                {
                    if (replace_index < index || index + (int)T.size() <= replace_index)
                    {
                        S[replace_index] = 'a';
                    }
                }
            }
            
            // 被らないと明らかにわかる文字が見つかるまで探索してみる
            for (int check_index=0; check_index < (int)T.size(); check_index++)
            {
                // 一致せず'?'でもない部分があれば終わり
                if (S_prime[index + check_index] != T[check_index] && S_prime[index + check_index] != '?')
                    break;
                
                // 探索範囲内の'?'は該当するTの文字に置き換え
                if (S_prime[index + check_index] == '?')
                {
                    S[index + check_index] = T[check_index];
                }

                // 最後まで探索し終えた（完全に一致した）ならそれは解候補になる
                if (check_index == (int)T.size() - 1)
                {
                    found = true;
                }
            }

            // 解候補になるならキューに入れておく
            if (found)
            {
                q.push(S);
            }
        }
    }

    if (q.empty())
    {
        cout << "UNRESTORABLE" << endl;
    }
    else
    {
        string answer = q.top();
        cout << answer << endl;
    }
    
}

Measured memory_bytes: 888
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ

int main(){
	int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	for(int i=0;i*a<=d;i++){
		for(int j=0;i*a+j*b<=d;j++){
			int req=d-i*a-j*b;
			if(req%c==0)ret++;
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int n, a, b; cin >> n >> a >> b;
	cout << min(n * a, b);



	cout << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
		"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)
var f = make([]string, 10)
var s, w = make([]int, 10), make([]int, 10)
var n int
func main() {
	for scanner.Scan() {
		n, _ = strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			tmpf :=buf[0]
			tmpw, _ := strconv.Atoi(buf[1])
			tmps, _ := strconv.Atoi(buf[2])
			f[i] = tmpf
			s[i] = tmps
			w[i] = tmpw
		}
		sort()
		for i := 0; i < n; i++ {
			for j := 0; j < n-1; j++ {
				if w[j]<w[j+1] {
					swap(j)
					a := get_weight(j+1)
					if a>s[j] {
						swap(j)
					}
				}
			}
		}
		for i := 0; i < n; i++ {
			fmt.Println(f[i])
		}
	}
}

func sort() {
	for i := n-1; i > 0; i-- {
		for j := 0; j < i; j++ {
			if s[j]<s[j+1] {
				swap(j)
			} else if s[j]==s[j+1]&&w[j]<w[j+1] {
				swap(j)
			}
		}
	}
}

func swap(x int) {
	w[x], w[x+1] = w[x+1], w[x]
	s[x], s[x+1] = s[x+1], s[x]
	f[x], f[x+1] = f[x+1], f[x]
}

func get_weight(x int) int {
	ret := 0
	for i := x; i < n; i++ {
		ret += w[i]
	}
	return ret
}



Measured memory_bytes: 1092
import java.util.*;

public class Main {

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

        int ans = 0;
        if (op.equals("+")) {
            ans = a + b;
        } else {
            ans = a - b;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 20564
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n,d,x;
string s,t,r;
int main(){
    cin>>n>>s;
    for(int i=0;i<n;i++){
        d+=(s[i]=='('?1:-1);
        x=min(x,d);
    }
    t=string(-x,'(');
    r=string(d-x,')');
    cout<<t+s+r<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
using namespace std;

int N,W;
int w[maxn],v[maxn];
ll dp[maxn];
int main(){
    // debug;
    ios;
    
    cin>>N>>W;
    for(int i = 1;i<=N;i++) cin>>w[i]>>v[i];
    for(int i = 1;i<=N;i++){
        for(int j = W;j>=w[i];j--){
            dp[j] = max(dp[j],dp[j-w[i]] + v[i]);
        }
    }
    cout<<dp[W]<<'\n';
        
    return 0;
}


Measured memory_bytes: 5120
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>

using namespace std;

int main(){
	int N, M, X, Y, x[100], y[100];
	bool ans = false;

	cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; ++i){
		cin >> x[i];
	}
	for (int i = 0; i < M; ++i){
		cin >> y[i];
	}

	for (int i = X + 1; i <= Y; ++i){
		int j, k;
		for (j = 0; j < N; ++j){
			if (x[j] >= i)
				break;
		}
		for (k = 0; k < M; ++k){
			if (y[k] < i)
				break;
		}
		if (j == N && k == M){
			ans = true;
			break;
		}
	}

	if (ans)
		cout << "No War" << endl;
	else
		cout << "War" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[28] = {}, z = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 2; i < n; i++) {
        if (a[i] > a[i - 1] && a[i] < a[i + 1]) z++;
        if (a[i] < a[i - 1] && a[i] > a[i + 1]) z++;
    }
    cout << z;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

main(){
  int n;
  while(cin>>n && n){
    int ans=0;
    REP(i,1,n){
      int cur=0;
      REP(j,i,n && cur < n){
	cur+=j;
	if (cur == n)ans++;
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    string s;
    int K;
    cin >> s >> K;
    int n = s.size();
    lint dp[n+1][2][K+1];
    rep(i, n+1)rep(j, 2)rep(k, K+1) dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    rep(i, n)rep(j, 2)rep(k, K+1){
        int x = j ? 9 : s[i]-'0';
        rep(d, x+1){
            if(d == 0) dp[i+1][j || d < x][k] += dp[i][j][k];
            else if(k < K) dp[i+1][j || d < x][k+1] += dp[i][j][k];
        }
    }
    lint ans = 0;
    rep(j, 2) ans += dp[n][j][K];
    printf("%lld\n", ans);
}

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

int main(void) {

	map<string, int> mp;
	string temp;
	int bnum, rnum, max = 0;
	cin >> bnum;

	for (int i = 0; i < bnum; i++) {
		cin >> temp;
		if (mp.count(temp)) mp.at(temp)++;
		else mp[temp] = 1;
	}
	cin >> rnum;
	for (int i = 0; i < rnum; i++) {
		cin >> temp;
		if (mp.count(temp)) mp.at(temp)--;
	}
	for (auto it : mp) {
		if (max < it.second) max = it.second;
	}

	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256