akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

lli tmod(lli x,lli m){return (x%m+m)%m;}//USE AT YOUR OWN RISK
lli power(lli x, lli y) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1; 
        x = (x*x)%mod;  
    }
    if(res<0)
       res+=mod; 
    return res; 
}


// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }

int main() 
{ 
    fastio;
    // fact[0]=1;
    // f(i,1,2000009)fact[i]=(fact[i-1]*i)%mod;
    int t;
    // cin>>t;
    t=1;
    // int temp=t;
    while(t--){
      lli n,s;cin>>n>>s;
      lli a[n];f(i,0,n)cin>>a[i];
      lli dp[n][s+1],dp2[n][s+1];
      memset(dp,0,sizeof dp);
      memset(dp2,0,sizeof dp2);
      f(i,0,s+1){
        dp[0][i]=(i==0)||(i==a[0]);
        dp2[0][i]=(i==0)||(i==a[0]);
      }
      f(i,1,n){
        dp[i][0]=(((i+1)*(i+2))/2)%mod2;
        dp2[i][0]=i+1;
        f(j,1,s+1){
          dp[i][j]=(dp[i-1][j]+(j==a[i])+(j>=a[i])*dp2[i-1][j-a[i]]+dp2[i-1][j])%mod2;
          dp2[i][j]=(dp2[i-1][j]+(j==a[i])+(j>=a[i])*dp2[i-1][j-a[i]])%mod2;
          // cout<<i<<" "<<j<<" "<<dp[i][j]<<" "<<dp2[i][j]<<"\n";
        }
      }
      cout<<tmod(dp[n-1][s],mod2)<<"\n";
    }

    return 0; 	
}



Measured memory_bytes: 140928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    string s; cin >> s;
    ll ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<int> t(N), v(N);
    REP(i, N) cin >> t[i];
    REP(i, N) cin >> v[i];

    vector<double> left(N + 2), right(N + 2), vCon(N + 2);
    double sumTD = 0;
    int sumT = 0;
    REP(i, N + 2)
    {
        if (i == 0) 
        {
            left[i] = 0;
            right[i] = 0;
            vCon[i] = 0;
        }
        else if (i == N + 1)
        {
            left[i] = sumTD;
            right[i] = sumTD;
            vCon[i] = 0;
        }
        else
        {
            left[i] = sumTD;
            right[i] = sumTD + t[i - 1];
            vCon[i] = (double)v[i - 1];
            sumTD += (double)t[i - 1];
            sumT += t[i - 1];
        }
    }
  
    vector<double> vMax(2 * sumT + 1);
    REP(i, 2 * sumT + 1)
    {
        double x = i / 2.0;
        vMax[i] = 100.0;
        REP(j, N + 2)
        {
            double y;
            if (x >= 0 && x <= left[j])
            {
                y = vCon[j] + left[j] - x;
            }
            else if (x >= left[j] && x <= right[j])
            {
                y = vCon[j];
            }
            else
            {
                y = vCon[j] + x - right[j];
            }
            vMax[i] = min(vMax[i], y);
        }
    }
    double ans = 0;
    REP(i, 2 * sumT)
    {
        ans += 0.25 * (vMax[i] + vMax[i + 1]);
    }

    cout << fixed;
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        int n = Integer.valueOf(scan.next());
        Integer[] ns = new Integer[n];
        for(int i=0;i<n;i++) {
        	ns[i] = Integer.valueOf(scan.next());
        }
        for(int i = 1;i<=ns.length-1;i++) {
        	int cnt=0;
    	    for(int val:ns) {
    	    	if(cnt==n-1) break;
    	    	System.out.print(val+" ");
    	    	cnt++;
    	    }
    	    System.out.println(ns[n-1]);
    	    int key = ns[i];
    	    int j = i - 1;
    	    while(j >= 0 && ns[j] > key) {
    	        ns[j+1] = ns[j];
    	        j--;
    	    }
    	    ns[j+1] = key;
        }
        int cnt=0;
	    for(int val:ns) {
	    	if(cnt==n-1) break;
	    	System.out.print(val+" ");
	    	cnt++;
	    }
	    System.out.println(ns[n-1]);
        scan.close();
    }
}


Measured memory_bytes: 33852
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}



int main(void) {

	int n;
	string s;
	cin >> n >> s;

	int r = 0, b = 0;
	for (char c : s) {
		if (c == 'R')
			r++;
		else
			b++;
	}

	if (r > b)
		COUT("Yes");
	else
		COUT("No");

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

class Main {
    
    public static void main(String[] areg) {
        Scanner sc = new Scanner(System.in);
		int N = sc.	nextInt();
		int K = sc.	nextInt();
		sc.close();
        
        long ans = 1;
        for (int i = 0; i < N; i++)
            ans = Math.min(ans * 2, ans + K);
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int n, k;
    cin >> n >> k;
    int ans = 1;
    n -= k;
    while (1 <= n) {
        n++;
        n -= k;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
	char s[100];
	while(~scanf("%s",s))
	{
		int i,x=0;
		for(i=1;i<strlen(s);i++)
		{
			if(s[i]==s[i-1])
			{
				printf("Bad");
				x=1;
				break;
			}
		}
		if(x==0) printf("Good");
		printf("\n");
	}
}

Measured memory_bytes: 1732
N, K = map(int, input().split())
A = [int(x) for x in input().split()]

M = 10 ** 9 + 7

R = [0] * N
L = [0] * N

for i in range(N):
    Tr = 0
    if i <= N - 2:
        for r in range(i + 1, N):
            if A[i] > A[r]:
                Tr += 1
    Tl = 0
    if i > 0:
        for l in range(i - 1, -1, -1):
            if A[i] > A[l]:
                Tl += 1
    R[i] = Tr
    L[i] = Tl

sum = 0
for i in range(N):
    sum += R[i] * K * (K + 1) // 2 % M + L[i] * (K - 1) * K // 2 % M


print(sum % M)


Measured memory_bytes: 42732
#include <stdio.h>
#define N (110)
#define M (10010)
int n, m, a[N][N];
char s[N][N];
int cnt[N], u[N], f[M];
int main(){
    scanf("%d%d", &n, &m);;
    for (int i = 1; i <= n; ++i){
        scanf("%s", s[i] + 1);
        for (int j = 1; j <= m; ++j){
            cnt[s[i][j]]++;
        }
    }
    int tot = 0;
    for (int i = 1; i <= n+1>>1; ++i){
        for (int j = 1; j <= m+1>>1; ++j){
            a[i][j] = a[n+1-i][j] = a[i][m+1-j] = a[n+1-i][m+1-j] = tot++;
        }
    }
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j){
            f[a[i][j]]++;
        }
    }
    for (int i = 0; i < tot; ++i){
        u[f[i]]++;
    }
    int ok = 1;
    for (int g = 4; g; g>>=1){
        for (char c = 'a'; c <= 'z'; ++c){
            while (u[g] && cnt[c] >= g){
                cnt[c] -= g;
                u[g]--;
            }
        }
    }
    printf("%s\n", u[1]+u[2]+u[4] > 0 ? "No" : "Yes");
}

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

int main(){
    int n;
    cin >> n;
    while(n > 0){
        vector<int> a(n);
        for(int i=0; i<n; i++) cin >> a[i];
        long long sm = accumulate(a.begin(), a.end(), 0LL);
        int ans = 0;
        for(int i=0; i<n; i++)if(sm/n >= a[i]) ans++;
        cout << ans << endl;
        cin >> n;
    }
}


Measured memory_bytes: 3044
#include<stdio.h>

#define N 10000
 
typedef struct{
  int p;
  int l;
  int r;
}Node;
 
Node Tr[N];
int n, D[N], A[N];


void setDepth(int u, int d){
  if(u == -1) return;
  D[u] = d;
  setDepth(Tr[u].l, d+1);
  setDepth(Tr[u].r, d+1);
}


int setHeight(int u){
  int h1=0, h2=0;
  
  if(Tr[u].l != -1){
    h1 = setHeight(Tr[u].l) + 1;
  }
  
  if(Tr[u].r != -1){
    h2 = setHeight(Tr[u].r) + 1;
  }
  
  return A[u] = (h1 > h2 ? h1 : h2);
}


int getSibling(int u){
  if(Tr[u].p == -1) return -1;
  if(Tr[Tr[u].p].l != u && Tr[Tr[u].p].l != -1) return  Tr[Tr[u].p].l;
  if(Tr[Tr[u].p].r != u && Tr[Tr[u].p].r != -1) return Tr[Tr[u].p].r;
  return -1;
}


int main(){
  int i, q, l, r, deg, root=0;
 
  scanf("%d", &n);
 
  for(i=0; i<n; i++) Tr[i].p = -1;
 
  for(i=0; i<n; i++){
    scanf("%d %d %d",&q,&l,&r);
    Tr[q].l = l;
    Tr[q].r = r;
    if(l != -1) Tr[l].p = q;
    if(r != -1) Tr[r].p = q;
  }
 
  for(i=0; i<n; i++){
    if(Tr[i].p == -1) root = i;
  }
 
  setDepth(root,0);
  setHeight(root);
 
  for(i=0; i<n; i++){
    printf("node %d: ", i);
    printf("parent = %d, ", Tr[i].p);
    printf("sibling = %d, ", getSibling(i));
    
    deg = 0;
    
    if(Tr[i].l != -1) deg++;
    if(Tr[i].r != -1) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", D[i]);
    printf("height = %d, ", A[i]);
 
    if(Tr[i].p == -1){
      printf("root\n");
    }
    else if(Tr[i].l == -1 && Tr[i].r == -1){
      printf("leaf\n");
    }
    else printf("internal node\n");
  }
   
  return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

int n,m;
vector<int> vf;
vector<int> vs;

int main() {

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

	while (scanf("%d%d",&n,&m) && n!=0) {
		vf.clear();
		for (int i=0; i<n; i++) {
			int a;
			scanf("%d",&a);
			vf.push_back(a);
		}
		vs.clear();
		for (int i=0; i<m; i++) {
			int a;
			scanf("%d",&a);
			vs.push_back(a);
		}
		sort(vf.begin(),vf.end());
		sort(vs.begin(),vs.end());
		reverse(vf.begin(),vf.end());
		reverse(vs.begin(),vs.end());
		int i = 0, j = 0;
		int ans = 0;
		while (i<n || j<m) {
			if (i==n) {
				ans += vs[j++];
			}
			else if (j==m) {
				ans += vf[i++];
			}
			else {
				if (vf[i]==vs[j]) {
					ans += vs[j++];
					i++;
				}
				else if (vf[i]>vs[j]) {
					ans += vf[i++];
				}
				else if (vs[j]>vf[i]) {
					ans += vs[j++];
				}
			}
		}
		printf("%d\n",ans);
	}

    return 0;

}

Measured memory_bytes: 1212
# --- fetch input ---

inputs: list = []
while True:
    try:
        inputs.append(input().strip('\n'))
    except EOFError:
        break

# --- write code below ---

n = int(inputs[0])
total: int = 0

for i in range(1, n+1):

    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        total += i

print(total)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 998244353
#define inf 1000000000000000000
const int sz = 200006;
ll n,m;
vector<int>adj[sz];
vector<int>vis, dis, dp;
int dfs(int u) {
	if(vis[u] == 1) {
		return dp[u];
	}
	vis[u] = 1;
	for(int v : adj[u]) {
		dp[u] = max(dp[u], 1+dfs(v));
	}
	return dp[u];
}
int main() {
	io
	cin>>n>>m;
	vis.assign(n+1, 0);
	dis.assign(n+1, 0);
	dp.assign(n+1,0);
	for(int i = 0; i<m; i++) {
		int u, v;
		cin>>u>>v;
		adj[u].pb(v);
	}
	int ans = 0;
	for(int i = 1; i<=n; i++) {
		if(vis[i] == 0) {
			dfs(i);
		}
		ans = max(ans, dp[i]);
	}
	cout<<ans;
}




Measured memory_bytes: 11264
import sys
 
patterns = ( 'S', 'H', 'C', 'D' )
n = int( sys.stdin.readline() )
cards = { pattern:[False]*13 for pattern in patterns }
for i in range( n ):
    pattern, num = sys.stdin.readline().split( " " )
    cards[ pattern ][ int( num )-1 ] = True
 
for pattern in patterns:
    for i in range( 13 ):
        if not cards[ pattern ][ i ]:
            print( "{:s} {:d}".format( pattern, i+1 ) )

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

#define mk make_pair

const int MAXN = 112345;
const double PI = atan(1) * 4;
const int MOD = 1e9 + 7;

long long x[MAXN], y[MAXN];

int main() {

	int n, m;
	scanf("%d %d", &n, &m);
	
	for(int i = 0; i < n; i++)
		scanf("%lld", &x[i]);
		
	for(int i = 0; i < m; i++)
		scanf("%lld", &y[i]);
		
	long long totalx = 0, totaly = 0;
	
	long long a = 0, b = n - 1LL;
	for(int i = 0; i < n; i++) {
		
		long long temp = ((a * x[i]) % MOD - (b * x[i]) % MOD) % MOD;
		if(temp < 0LL) temp += MOD;
		totalx = (totalx + temp) % MOD;
		
		a++, b--;		
	}
	
	a = 0, b = m - 1LL;
	for(int i = 0; i < m; i++) {
		
		long long temp = ((a * y[i]) % MOD - (b * y[i]) % MOD) % MOD;
		if(temp < 0LL) temp += MOD;
		totaly = (totaly + temp) % MOD;
		
		a++, b--;		
	}
	
	long long ans = (totalx * totaly) % MOD;
	
	cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 5292
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include <utility>
using namespace std;
int main(){
int dp[10100];
int W,N;
int v[1010],w[1010];
int count=0;
while(cin>>W,W){
cin>>N;
count++;
for(int i=0;i<N;i++){
scanf("%d,%d",&v[i],&w[i]);
}
for(int j=0;j<W+1;j++){
if(j<w[0]){
dp[j]=0;
}else{
dp[j]=v[0];
}
}
for(int i=1;i<N;i++){
for(int j=W;j;j--){
if(j<w[i]){
dp[j]=dp[j];
}else{
dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
}
}
}
cout<<"Case "<<count<<":"<<endl;
cout<<dp[W]<<endl;
while(dp[W]==dp[W-1])W--;
cout<<W<<endl;
}
return 0;
}

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    string S;
    cin >> S;

    /* ------- 計算 ------- */

    string ans;

    if (S.at(S.length() - 1) == 's')
    {
        ans = S + "es";
    }
    else
    {
        ans = S + "s";
    }

    ost << ans << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

int main() {
    ll N, alpha[26] = {};
    string S;
    cin >> N >> S;
    REP(i, S.size()) alpha[S[i] - 'a']++;
    
    ll ans = 0;
    REP(i, S.size()) {
        int a = S[i] - 'a'; 
        alpha[a]--;
        ll tmp = 1;
        REP(j, 26) if (j != a) tmp = tmp * (alpha[j] + 1) % MOD;
        ans = (ans + tmp) % MOD;
    }   
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int calc(int n) {
  int i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int temp = n / i;
      while (temp % i == 0) {
	n /= i;
	temp /= i;
      }
    }
  }
  return n;
}

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

int main(void) {
  int p, q;
  scanf("%d %d", &p, &q);
  q /= gcd(p, q);

  int ans = calc(q);
  printf("%d\n", ans);

  return 0;
}

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

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  i32 N;
  string S;
  cin >> N >> S;
  
  i32 ans = 0;
  auto pos = S.size();
  decltype(pos) st = 0;
  while(pos != string::npos) {
    pos = S.find("ABC", st);
    if(pos == string::npos) {
      break;
    }
    ans++;
    st = pos + 3;
  }
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

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

int main(void)
{
	string s;
	cin >> s;
	string c = "CODEFESTIVAL2016";
	int ans = 0;
	rep(i, s.length()) if (c[i] != s[i]) ans++;
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int top,S[101];
string str;


void initialize() {
  top = 0;
}

int isEmpty() {
  return top == 0;
}

int isFull() {
  return top >= 100;
}

void push(int x) {
  if ( isFull() )cout << "overflow" << endl;
  else {
    top++;
    S[top] = x;
  }
}

int pop() {
  if ( isEmpty() ) cout << "underflow" << endl;
  else {
    top--;
    return S[top+1];
  }
}

int main() {
  
  initialize();
  
  int num1,num2;
  
  while ( cin >> str ) {
    
    if ( str[0] == '+') {
      num1 = pop();
      num2 = pop();
      push( num1 + num2 );
      
    }else if ( str[0] == '-' ) {
      
      num1 = pop();
      num2 = pop();
      push( num2 - num1 );
      
    }else if ( str[0] == '*' ) {
      
      num1 = pop();
      num2 = pop();
      push( num1 * num2 );
      
    } else {
      
      push(atoi(str.c_str()));
      
    }
    
  }
  
  cout << pop() << endl;

  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

 int n;
 cin >> n;

 int m[n+1][n+1];
 for(int i = 0;i <= n;i++) {
   for(int j = 0;j <= n;j++) {
     m[i][j] = 0;
   }
 }

 for(int i = 0;i < n;i++) {
   int u,k;
   cin >> u >> k;
   for(int j = 0;j < k;j++) {
     int v;
     cin >> v;
     m[u][v] = 1;
   } 
 }

 for(int i = 1;i <= n;i++) {
   for(int j = 1;j <= n;j++) {
     if(j>1) cout << " ";
     cout << m[i][j];
   }
   cout << endl;
 }


  
}



Measured memory_bytes: 3160
module Main where

import           Control.Monad
import           Debug.Trace
import qualified Data.Vector.Unboxed           as VU
import           Data.List
import qualified Data.ByteString               as BS
import qualified Data.ByteString.Char8         as BSC8
import           Data.Char
import           Data.Maybe

tuplify2 (x : y : _) = (x, y)
tuplify2 _           = undefined

getVUIntFromInputLineAtBSC8 :: IO (VU.Vector Int)
getVUIntFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine
getVUIntListFromInputLineAtBSC8 =
    VU.unfoldr (BSC8.readInt . BSC8.dropWhile isSpace) <$> BSC8.getLine

readInt = fst . fromJust . BSC8.readInt
readIntTuple = tuplify2 . map readInt . BSC8.words
readIntList = map readInt . BSC8.words

getInt = readInt <$> BSC8.getLine
getIntList = readIntList <$> BSC8.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BSC8.getLine
getIntMatrix = map readIntList . BSC8.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BSC8.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BSC8.getLine
getIntTuples = map readIntTuple . BSC8.lines <$> BSC8.getContents

main :: IO ()
main = do

    [aN,aK] <- getIntList

    print $ special aN aK

special x 0 = x
special _ 1 = 0
special x k = 
    let modx = x `mod` k
    in min modx (k-modx)


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};
ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	ll c=power(a,b/2);
	if(b%2==0)
		return ((c%mod)*(c%mod))%mod;
	else
		return ((((c%mod)*(c%mod))%mod)*a)%mod;
}
int main()
{
	boost
	ll ans=0;
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++)
		cin>>a[i];
	ll cur=0;
	for(ll i=1; i<n; i++)
	{
		if(a[i]>a[i-1])
			cur=0;
		else
			cur++;
		ans=max(ans,cur);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>

using namespace std;

int A, B, C, D, E, F;
bool tried[3001][3001];

void solve(int water, int suger, int& max_water, int& max_suger)
{
  if (tried[water][suger]) return;
  tried[water][suger] = true;
  if ((100 + E) * suger > E * (water + suger)) return;
  // cerr << water << " " << suger << endl;
  if (max_suger * (water + suger) <= suger * (max_water + max_suger)) {
    max_suger = suger;
    max_water = water;
  }
  if (water + 100*A + suger <= F) solve(water + 100*A, suger, max_water, max_suger);
  if (water + 100*B + suger <= F) solve(water + 100*B, suger, max_water, max_suger);
  if (water + suger + C <= F) solve(water, suger + C, max_water, max_suger);
  if (water + suger + D <= F) solve(water, suger + D, max_water, max_suger);
}

int main()
{
  cin >> A >> B >> C >> D >> E >> F;
  int water = 0;
  int suger = 0;
  for (int i = 0; i <= 3000; ++i) for (int j = 0; j <= 3000; ++j) tried[i][j] = false;
  solve(0, 0, water, suger);
  cout << (water + suger) << " " << suger << endl;
  return 0;
}

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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int x, a; cin >> x >> a;
	if(x < a) cout << 0 << endl;
	else cout << 10 << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> e[10];
bool check[10];
int ans,n,m;
void dfs(int p,int tot)
{
    check[p] = 1;
    if (tot == n)
    {
        ans++;
    } else {
        for (int i = 0;i < e[p].size();i++)
        {
            if (check[e[p][i]]) continue;
            dfs(e[p][i],tot+1);
        }
    }
    check[p] = 0;
}
int main()
{
    cin >> n >> m;
    for (int i = 0;i < m;i++)
    {
        int x,y;
        cin >> x >> y;
        e[x].push_back(y);
        e[y].push_back(x);
    }
    dfs(1,1);
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define int long long int
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define pf push_front
#define indexof order_of_key
#define valueat find_by_order

int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dxx[8]={0,0,1,-1,-1,-1,1,1};
int dyy[8]={1,-1,0,0,-1,1,1,-1};

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

int t;
int n;
int arr[51];

void input(){
    cin>>n;
    rep(i,0,n)
        cin>>arr[i];
}

void solve(){
    int sum=0;
    rep(i,0,n)
        rep(j,i+1,n)
            sum+=arr[i]*arr[j];
    cout<<sum<<endl;
}

main(){
    fastio;
    t=1;
    while(t--){
        input();
        solve();
    }
}

Measured memory_bytes: 256
// In god we trust
 
#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>
#include <signal.h>
#include <thread>
 
#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define Q queue
#define Qi Q<int>
#define INF 1000000000 
#define LINF 1000000000000000000
#define int long long
using namespace std;
using namespace std::chrono;

const int max_ = 1000010;
bool dp[max_];
bool dbl[max_];
bool visited[max_];

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

  int n;
  cin >> n;
  int a[n];

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

  sort(a, a + n);

  for (int i = 0; i < n - 1; i++)
    if (a[i] == a[i + 1])
      dbl[a[i]] = true;

  for (int i = 1; i < max_; i++)
    if (dbl[i])
      dp[i] = true;
  
  for (int i = 0; i < n; i++){
    if (dbl[a[i]] and visited[a[i]])
      continue;
    visited[a[i]] = true;
    int j = a[i];
    while (j + a[i] < max_)
      j += a[i], dp[j] = true;
  }
  
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (!dp[a[i]])
      cnt++;

  cout << cnt << "\n";
  
}


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

int main() {
	int a, b, c; cin >> a >> b >> c;

	int maxNum = 3*max({ a,b,c });
	int rest = maxNum - a - b - c;

	if (rest % 2 == 0)cout << rest / 2 << endl;
	else cout << (rest + 3) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct student{
	int i;
	int rank;
	bool operator < (const student& e)const{
		if(rank!=e.rank){
			return rank<e.rank;
		}
		return true;
	} 
}a[100010];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		a[i].i=i;
		cin>>a[i].rank;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		printf("%d ",a[i].i);
	}
	return 0;
} 


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

using namespace std;

int main () {
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0; i < s.size(); i++)
    sum += (s[i] - '0');
  if (sum % 9) cout << "No\n";
  else cout << "Yes\n";
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(ReadLine());
        var v = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var evenV = v.Where((v, i) => i % 2 == 0).GroupBy(x => x).Select(g => (v: g.Key, c: g.Count())).OrderByDescending(x => x.c).ToArray();
        var oddV = v.Where((v, i) => i % 2 == 1).GroupBy(x => x).Select(g => (v: g.Key, c: g.Count())).OrderByDescending(x => x.c).ToArray();

        var ans = 0;

        if (evenV[0].v != oddV[0].v)
        {
            ans = n - evenV[0].c - oddV[0].c;
        }
        else
        {
            if(1 < evenV.Length && 1 < oddV.Length)
            {
                var a = n - evenV[0].c - oddV[1].c;
                var b = n - evenV[1].c - oddV[0].c;
                ans = Math.Min(a, b);
            }
            else if(1 < evenV.Length)
            {
                ans = n - evenV[1].c - oddV[0].c;
            }
            else if(1 < oddV.Length)
            {
                ans = n - evenV[0].c - oddV[1].c;
            }
            else
            {
                ans = n / 2;
            }
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 42684
N=int(input())
ans=0
for a in range(1,10**6):
    if a>=N:
        break
    for b in range(1,10**6):
        A=a*b
        c=N-A
        if c<=0:
            break
        if 1<=c<=10**6:
            ans+=1
print(ans)

Measured memory_bytes: 67708
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n,m; cin >>n>>m;
  cout<< (n-1)*(m-1)<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3


def solv(n, k, s):
    s = [c for c in s]
    s[k-1] = s[k-1].lower()
    return "".join(s)


if __name__ == '__main__':

    n, k = map(int, input().split())
    s = input()

    ans = solv(n, k, s)

    print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

typedef vector<string> VS;

#define X first
#define Y second

const LL MOD = 1000000007;

template<typename T>
void dump(T a, int n) { for (int i = 0; i < n; i++) cout << a[i] << (i == n - 1 ? '\n' : ' '); }

template<typename T>
void dump(T a) { dump<T>(a, a.size()); }

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

bool can_reverse(VS &S, int y, int x, int di, bool is_mami) {
	int i = 0;
	while (true) {
		x += dx[di];
		y += dy[di];

		if (x < 0 || y < 0 || x >= 8 || y >= 8 || S[y][x] == '.') {
			return false;
		}
				
		if (S[y][x] == (is_mami ? 'o' : 'x')) {
			break;
		}
		i++;
	}

	return i;
}

bool simulation(VS &S, int y0, int x0, bool is_mami) {
	if (S[y0][x0] != '.') {
		return false;
	}
	
	S[y0][x0] = is_mami ? 'o' : 'x';

	bool flg = false;
	for (int i = 0; i < 8; i++) {
		if (!can_reverse(S, y0, x0, i, is_mami)) {
			continue;
		}

		int x = x0;
		int y = y0;
		

		while (true) {
			x += dx[i];
			y += dy[i];

			if (x < 0 || y < 0 || x >= 8 || y >= 8
					|| S[y][x] == '.'
					|| S[y][x] == (is_mami ? 'o' : 'x')) {
				break;
			}

			S[y][x] = is_mami ? 'o' : 'x';
			flg |= true;
		}
	}

	return flg;
}

int counter(VS &S, bool is_mami) {
	int cnt = 0;
	
	for (int i = 0; i < 8; i++) {
		cnt += count(S[i].begin(), S[i].end(), is_mami ? 'o' : 'x');
	}

	return cnt;
}

int main(void) {
	VS S(8);
	for (auto &s : S) cin >> s;

	bool is_mami = true;
	bool cannot = false;
	while(true) {
		VS max_next;
		int now = counter(S, is_mami);
		int max_cookie = -1;
		
		for (int y = 0; y < 8; y++) {
			for (int x = 0; x < 8; x++) {	
				VS next(S);

				if (!simulation(next, y, x, is_mami)) {
					continue;
				}

				int cookie = counter(next, is_mami);
				if (cookie != now &&
						((is_mami && cookie > max_cookie) || 
						 (!is_mami && cookie >= max_cookie))) {
					max_cookie = cookie;
					max_next = next;
				}
			}
		}

		if (max_cookie == -1) {
			if (cannot) {
				break;
			}else {
				cannot = true;
				is_mami = !is_mami;
				continue;
			}
		}

		cannot = false;
		S = max_next;
		is_mami = !is_mami;
	}

	for (auto s : S) cout << s << endl;
	

	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if((a+b)>(a-b) && (a+b)>(a*b)){
		cout<<(a+b);
	}else if((a*b)>(a+b) && (a*b)>(a-b)){
		cout<<(a*b);
	}else{
		cout<<(a-b);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	Scanner sc;
	
	private void calc() {
		sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] H = new int[N];
		for (int i = 0; i < N; i++) {
			H[i] = sc.nextInt();
		}
		Arrays.sort(H);
		long s = 0;
		for (int i = 0; i < N-K; i++) {
			s += H[i];
		}
		System.out.println(s);
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 89348
def main():
    a, b, c, d = [int(x) for x in input().split()]

    xs = [0] * 101
    xs[a] += 1
    xs[b] -= 1
    xs[c] += 1
    xs[d] -= 1

    cursum = 0
    t = 0
    for x in xs:
        cursum += x
        if cursum == 2:
            t += 1

    print(t)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		long sum = (b/x + 1);
		if(a!=0)sum -=(a - 1)/x + 1;
		System.out.println(sum);
	}
}

Measured memory_bytes: 23636
#include<stdio.h>

int main()
{
  int x, y;
       
  while(1){
           scanf("%d %d",&x,&y);
           if(x == 0 && y == 0)
              break;
           if(x > y)
              printf("%d %d\n", y, x);
           else
              printf("%d %d\n", x, y);
}

  return 0;
}


Measured memory_bytes: 1964
#include"bits/stdc++.h"
using namespace std;

struct Point {
    int x, y;
};

#define all(c) (c).begin(), (c).end()

struct graph {
    int L, R;
    vector<vector<int>> adj;
    graph(int L, int R) : L(L), R(R), adj(L + R) { }
    void add_edge(int u, int v) {
        adj[u].push_back(v + L);
        adj[v + L].push_back(u);
    }
    int maximum_matching() {
        vector<int> visited(L), mate(L + R, -1);
        function<bool(int)> augment = [&](int u) { // DFS
            if (visited[u]) return false;
            visited[u] = true;
            for (int w : adj[u]) {
                int v = mate[w];
                if (v < 0 || augment(v)) {
                    mate[u] = w;
                    mate[w] = u;
                    return true;
                }
            }
            return false;
        };
        int match = 0;
        for (int u = 0; u < L; ++u) {
            fill(all(visited), 0);
            if (augment(u)) ++match;
        }
        return match;
    }
};

int main() {
    int N;
    cin >> N;
    vector<Point> red(N), blue(N);
    for (int i = 0; i < N; i++) {
        cin >> red[i].x >> red[i].y;
    }
    for (int i = 0; i < N; i++) {
        cin >> blue[i].x >> blue[i].y;
    }

    graph g(N, N);


    vector<vector<bool>> connect(N, vector<bool>(N, false));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (red[i].x < blue[j].x && red[i].y < blue[j].y) {
                connect[i][j] = connect[j][i] = true;
                g.add_edge(i, j);
            }
        }
    }

    cout << g.maximum_matching() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll x;
    cin >> x;
    ll ans = 1;
    for(ll i = 2; i <= x; i++){
        for(ll j = i * i; j <= x; j*=i){
            ans = max(ans, j);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

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

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

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	REP(i,n)cin>>a[i];
	int cnt=0;
	bool pre=false;
	for(int i=0;i<n-1;i++){
		if(pre){
			pre=false;
			continue;
		}
		if(a[i]==a[i+1]){
			cnt++;
			pre=true;
		}
	}
	cout<<cnt<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a,b,c,d; 
int main()
{
   cin>>a>>b>>c>>d;
   while(1)
   {
   	   c-=b;
   	  if(c<=0){
   	   	cout<<"Yes"<<endl;return 0;
		  } 
   	  
      a-=d;
		if(a<=0) {
   	   	cout<<"No"<<endl;return 0;
		  }
   }


return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    long long  N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << " " << max(A + B - N, 0LL) << endl;
    return 0;
}

Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll a[3], k;
ll f(ll i, ll d = 1)
{
    if (d > k)
        return 0;
    a[i] *= 2;
    if (a[0] < a[1] && a[1] < a[2])
        return 1;
    for (ll i = 0; i < 3; i++)
        if (f(i, d + 1))
            return 1;
    a[i] /= 2;
    return 0;
}
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> a[0] >> a[1] >> a[2] >> k;
    for (ll i = 0; i < 3; i++)
        if (f(i))
            return cout << "Yes", 0;
    cout << "No";
}

Measured memory_bytes: 3648
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(k+1)
dp[0]=0

for i in range(1,k+1):
    z=0
    for j in range(n):
        if i-a[j]>=0:
            if z==0:
                dp[i]=1
            dp[i]= dp[i] and dp[i-a[j]]
            z=1
    if z:
        dp[i]=(dp[i]+1)%2

print("First" if dp[k] else "Second")

Measured memory_bytes: 43660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,k;
const int max_n=1e5 + 7;
ll memo[103][max_n];
int w[105], v[105];
ll dp(int pos,int k){
    if(pos==n) return 0;
    if(memo[pos][k]!=-1) return memo[pos][k];
    memo[pos][k]=dp(pos+1,k);
    if(k>=w[pos]) memo[pos][k]=max(memo[pos][k],v[pos]+ dp(pos+1,k-w[pos]));
    
    return memo[pos][k];
}

int main() {
    cin>>n>>k;
    memset(memo,-1,sizeof(memo));
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    cout<<dp(0,k)<<"\n";
   return 0;
}


Measured memory_bytes: 84060
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  int n;
  cin >> n;
  long c = 100000;
  for (int i = n; i > 0; i--) {
    c = ceil(c * 1.05 / 1000) * 1000;
  }
  cout << c << endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
using lint = long int;
#define MOD 1000000007

lint N, a, b, res = 0;


lint binary_pow(lint a, lint n, lint m){
    lint res = 1;
    /*以降,nの2進数表記で考える...aもそれに合わせる*/
    while(n > 0){
        if(n & 1) res = (res * a) % m;  //奇数分は別
        a = (a * a) % m;
        n >>= 1; 
    }
    return res;
}

lint mod_inv(int x, int y){
    lint alpha = x, beta = y, u = 1, v = 0;
    lint d;
    while(beta){
        d = alpha / beta;
        alpha -= beta * d; swap(alpha, beta);
        u -= v * d; swap(u, v);
    }

    u %= y;
    if(u < 0) u += y;  //法を加えて正に
    return u;
}



lint mod_Comb(lint n, lint k, lint m){
    lint val = 1, inv = 1;
    for(int i = n-k+1; i <= n; i++){ val *= i; val %= m; }
    for(int i = 1; i <= k; i++){ inv *= i; inv %= m; }
    inv = mod_inv(inv, m);
    return (val * inv) % m;
}


int main(){
    cin >> N >> a >> b;
    res = (binary_pow(2,N,MOD)-mod_Comb(N,a,MOD)-mod_Comb(N,b,MOD)-1)%MOD;
    if(res < 0) res += MOD;
    cout << res << endl;
    return 0;
}

    

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define OP_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fo(i,a,b) for(int i = a; i < b; i++)
#define foi(i,a,b) for(int i = a; i>=b; i--)
#define fi first
#define si second
#define pb push_back
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const ll INF = 1e18L + 5;
const int MAXN = 405;
//const ll modn = 1e9+7;

ll sum(vll &prefix_sum, int l, int r){
  ll res = prefix_sum[r];
  if(l > 0){
    res -= prefix_sum[l-1];
  }
  return res;
}

ll solve(vi &inp, int n){
  ll dp[MAXN][MAXN];
  vll prefix_sum(n,0);
  prefix_sum[0] = inp[0];
  fo(i, 1, n){
    prefix_sum[i] = prefix_sum[i-1] + inp[i];
  }
  foi(L, n, 0){
    fo(R, L, n){
      if(L == R){
	dp[L][R] = 0;
      }else{
	dp[L][R] = INF;
	fo(i, L, R+1){
	  dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + sum(prefix_sum, L, R));
	}
      }
    }
  }
  return dp[0][n-1];
}

int main(){
  OP_IO;
  int n;
  cin>>n;
  vi inp(n);
  fo(i,0,n){
    cin>>inp[i];
  }
  cout<<solve(inp, n)<<endl;
  return 0;
}


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

using namespace std;

int a[100010], dp[100010];

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        if(a[i]==a[i-1])
            i--,n--;

    }

    for(int i = 1; i < n; i++) {
        if(a[i] > a[i - 1])
            dp[i] = 1;
        else if(a[i] < a[i - 1])
            dp[i] = -1;
else
        dp[i]=dp[i-1];
    }
    int cnt = 0;
    for(int i = 1; i < n; i++) {
        if(dp[i] * dp[i - 1] == -1)
            ++cnt, i++;
    }

    cout << cnt + 1;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF=1e9+7;

int main() {
	int N,K,a=INF;
	cin >> N >> K;
	vector<int> x(N);
	rep(i,N)
		cin >> x.at(i);
	
	rep(i, N-K+1) {
		int l=x.at(i), r=x.at(i+K-1);
		if(abs(l) < abs(r))
			a = min(a, abs(l)+r-l);
		else
			a = min(a, abs(r)+r-l);
	}

	cout << a << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int main() {

    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    int ans=0;
    if(a[1]%2==a[2]%2){
        ans+=(a[2]-a[1])/2;
        a[1]=a[2];
    }
    else {
        a[0]++;
        ans+=(a[2]-1-a[1])/2+1;
        a[1] = a[2];
    }
    // fin(ans);
    // cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    if(a[0]%2==a[1]%2)ans+=(a[1]-a[0])/2;
    else {
        ans+=(a[1]+1-a[0])/2+1;
    }
    fin(ans);
}

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

using namespace std;


int main()
{
	int N, a[1000];
	cin >> N;
	int i = 0;
	while (i != N) {
		cin >> a[i];
		i++;
	}
	sort(a, a + N);
	cout << a[N - 1] - a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
#HN=list(map(int,input().split()[:N]))
HN=[int(x) for x in map(int,input().split()[:N])]

for i in range(N-1,0,-1):
    if HN[i-1]<=HN[i]:
        continue
    elif (HN[i-1]-1)==HN[i]:
        HN[i-1]-=1
    else:
        print('No')
        exit()

print('Yes')

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

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


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

	ll n;
	cin>>n;
	ll limit=sqrt(n+1);
	
	ll ans=n*1000;

	for(ll i=1;i<=limit;i++)
	{
		if(n%i==0)
		{
			ll temp=n/i;
			ans=min(ans,i-1+temp-1);
		}
	}
	
	cout<<ans;
				
			
	cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{

    char a[3][3] = {};
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> a[i][j];
        }
    }
    cout << a[0][0] << a[1][1] << a[2][2] << endl;
    return 0;


}


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

int main(){
  int N;
  cin >> N;
  int ans=0;
  vector<int> p(N);
  for(int i=0; i<N; i++){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  for(int i=0; i<N; i++){
    ans+=p.at(i);
  }
  ans-=p.at(N-1)/2;
  cout << ans << endl;
}

Measured memory_bytes: 256