akhauriyash/Code-Regression huggingface dataset:
N, x = map(int, input().split())
A = list(map(int, input().split()))
sum_A = sum(A)

for i in range(1, N):
    diff = A[i - 1] + A[i] - x
    if diff <= 0:
        continue
    v1 = min(A[i], diff)
    v2 = diff - v1
    A[i] -= v1
    A[i - 1] -= v2
    # print('A', A)
ans = sum_A - sum(A)
print(ans)


Measured memory_bytes: 14060
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z) cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z << "\n"
#define PRINTALL(V)    \
  for (auto v : (V)) { \
    cerr << v << " ";  \
  }                    \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair<int, int>
#define ld long double
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> using vec = std::vector<T>;
template <class T> void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  // bool active = true;
  // Nはない。
  bool ok = S[0] == '1' && S[N - 1] == '0';
  // int maxT = 0;
  vec<int> a(N + 1, false);
  REP(i, (N + 1) / 2) {
    if (S[i] != S[N - 2 - i]) {
      ok = false;
      break;
    } else {
      //    DEBUG3(i + 1, N - 1 - i, S[i]);
      if (S[i] == '1') {
        a[i + 1] = true;
        //        a[N - 1 - i] = true;
      }
    }
  }
  //そもそも条件が違っている。
  //  DEBUG(maxT);
  if (ok) {
    int par = 2;
    cout << "1 2\n";
    FORS(i, 3, N) {
      // DEBUG(a[2]);
      if (a[i - 1]) {
        cout << par << " " << i << "\n";
        par = i;
      } else {
        cout << par << " " << i << "\n";
      }
    }
    // cout << "1 2\n";
    // REP(i, maxT - 1) cout << 2 + i << " " << 3 + i << "\n";
    // REP(i, N - maxT - 1) cout << 1 << " " << maxT + 2 + i << "\n";
    /*
    int quo = (N - 1) / maxT;
    int res = (N - 1) % maxT;
    // DEBUG3(quo, res, maxT);
    REP(i, quo) {
      cout << N << " " << i * maxT + 1 << "\n";
      REP(j, maxT - 1)
      cout << i * maxT + j + 1 << " " << i * maxT + j + 2 << "\n";
    }
    if (res != 0) {
      cout << N << " " << quo * maxT + 1 << "\n";
      REP(j, res - 1) cout << quo * maxT + j + 1 << " " << quo * maxT + j + 2 << "\n";
    }*/
  } else {
    print("-1");
  }
}
/*
当初想定した解よりも大きな事がわかった。
当初では、
*/

Measured memory_bytes: 2384
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
//#define mp make_pair
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
    #define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 2e5+33, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;        // #include <ext/pb_ds/assoc_container.hpp>
typedef pair <ll, ll> pll;         // #include <ext/pb_ds/tree_policy.hpp>
typedef vector <int> vi;          // #include <ext/rope>
                // #include <ext/rope>
                                 // #include <ext/rope>
bool prime(int n) {             // template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}

void solve() {
    ll a , b , n;
    cin >> a >> b >> n;
    if(n <= b) {
        if(n == b)
            n --;
        cout << (a*n)/b;
        return;
    }
    ll x = b-1;
    ll ans = (a*x)/b - a*(x/b);
    for(; x <= b+1e6 && x <= n; x ++) {
        chmax(ans , (a*x)/b - a*(x/b));
    }
    cout << ans;
}
/*
4 3
RLRL

*/

main() {
    ios;
    int tt = 1;
    //cin >> tt;
    while(tt --) {
        solve();
//        brute();
    }
    return 0;
}
/*
++>
+++>
<[<+>-]<
++++++++++++++++++++++++++++++++++++++++++++++++.

500000000000000000000000000000000000000000000000

1 1 2 3 6


*/


Measured memory_bytes: 3692
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	int N=0,M=0,i=0,sum=0;
	int A[10000];
	
	scanf("%d %d",&N,&M);
	
	while(i<M){
		scanf("%d",&A[i]);
		sum+=A[i];
		i++;
	}

	if(N>=sum){
		printf("%d", N-sum);
	}
	else{
		printf("%d",-1);
	}

	return 0;
}


Measured memory_bytes: 1768
#include<bits/stdc++.h>
using namespace std;
int n,m,ans=0;
int dx[5]={0,1,0,-1,0},dy[5]={0,0,1,0,-1};
char a[30][30];
int dis[30][30][30][30]={};
bool vis[30][30][30][30]={};
queue<pair<int,int> > q;
void bfs(int x,int y)
{
    q.push(make_pair(x,y));
    dis[x][y][x][y]=0;
    vis[x][y][x][y]=true;
    while(!q.empty())
    {
        pair<int,int> t=q.front();
        for(int i=1;i<=4;i++)
        {
            int tx=t.first+dx[i],ty=t.second+dy[i];
            if(!vis[x][y][tx][ty]&&a[tx][ty]=='.')
            {
                q.push(make_pair(tx,ty));
                dis[x][y][tx][ty]=dis[x][y][t.first][t.second]+1;
                vis[x][y][tx][ty]=true;
            }
        }
        q.pop();
    }
    return ;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) a[i][0]=a[i][m+1]='#';
    for(int j=1;j<=m;j++) a[0][j]=a[n+1][j]='#';
    for(int i=1;i<=n;i++) scanf("%s",&a[i][1]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(a[i][j]=='.')
                bfs(i,j);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            for(int k=1;k<=n;k++)
                for(int l=1;l<=m;l++)
                    if(vis[i][j][k][l])
                        ans=max(ans,dis[i][j][k][l]);
    printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
#define debug(...) { printf("#  "); printf(__VA_ARGS__); puts(""); }
#define fi first
#define se second
#define endl "\n" 
using ll = long long;
using pII = pair <int, int>;
using pLL = pair <ll, ll>;
using VI = vector <int>;
using VL = vector <ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2> inline void chadd(T1 &x, T2 y) { x += y; if (x >= mod) x -= mod; else if (x < 0) x += mod; } 
template <class T1, class T2> inline void chmax(T1 &x, T2 y) { if (x < y) x = y; }
template <class T1, class T2> inline void chmin(T1 &x, T2 y) { if (x > y) x = y; }
inline int rd() { int x; cin >> x; return x; }
template <class T> inline void rd(T &x) { cin >> x; }
template <class T> inline void rd(vector <T> &vec) { for (auto &it : vec) cin >> it; }
template <class T> inline void out(T s) { cout << s << "\n"; }
template <class T> inline void out(vector <T> &vec) { for (auto &it : vec) cout << it << " "; cout << endl; } 
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll qpow(ll base, ll n) { ll res = 1; while (n) { if (n & 1) res = res * base % mod; base = base * base % mod; n >>= 1; } return res; }
constexpr int N = 1e5 + 10;
ll n; 
void run() {
	cout << n * (n - 1) / 2 << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cout << fixed << setprecision(20);
	while (cin >> n) run();
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
j = [0]*n
w = [0]*n
wa = 0
ac = 0

for i in range(m):
    p,s = input().split()
    p = int(p)-1
    if s == 'AC' and j[p] == 0:
        ac += 1
        j[p] = 1
        wa += w[p]
    elif s == 'WA' and j[p] == 0:
        w[p] += 1

print(ac,wa)

Measured memory_bytes: 4596
#include <stdio.h>
int main() {
	char s[17], ans[17] = "CODEFESTIVAL2016";
	int cnt = 0;
	scanf("%s", s);
	for (int i = 0; i < 16; i++) {
		if (s[i] != ans[i]) {
			cnt++;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

s = STR()
ans = ''
for i in range(len(s)):
    if s[i] == '0':
        ans += '0'
    if s[i] == '1':
        ans += '1'
    if s[i] == 'B' and len(ans) > 0:
        ans = ans[:-1]
print(ans)

Measured memory_bytes: 61676
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] a = sc.nextIntArray(n);
    int total = 0;
    for (int ai : a) total += ai;
    double threshold = (double) total / (4.0 * (double) m);
    int count = 0;
    for (int ai : a) {
      if (ai >= threshold) count++;
    }
    System.out.println(count >= m ? "Yes" : "No");
  }
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int n=0;
	int i=0;
	int j=0;
	int k=0;
	int a[12];
	int m=0;
	int sa=0;
	string c;
	string b;
	b="MSL";
	vector<int> v1[105];
	cin>>n;
	while(n!=0){
		cin>>c;
		memset(a,0,sizeof(a));
		for(i=0;i<100;i++){
			m=i%n;
			if(c[i]==b[0]){
				a[m]++;
			}
			if(c[i]==b[1]){
				sa=sa+a[m]+1;
				a[m]=0;
			}
			if(c[i]==b[2]){
				a[m]=a[m]+sa+1;
				sa=0;
			}
		}
		for(i=0;i<n;i++){
			v1[j].push_back(a[i]);
		}
		sort(v1[j].begin(),v1[j].end());
		v1[j].push_back(sa);
		sa=0;
		j++;
		cin>>n;
	}
	for(i=0;i<j;i++){
		sa=v1[i].size();
		for(k=0;k<sa-1;k++){
			cout<<v1[i][k]<<" ";
		}
		cout<<v1[i][sa-1]<<endl;
	}
}			

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

#define ll long long

int main(){
    char b,a;
    cin >> b;
    if(b == 'A')a = 'T';
    else if(b == 'T')a = 'A';
    else if(b == 'C')a = 'G';
    else if(b == 'G')a = 'C';
    cout << a << endl;
    return 0;
}

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

static const int MAX_NUM = 101;
static const int NO_VISIT  = 0;
static const int NOW_VISIT = 1;
static const int END_VISIT = 2;

void DSF(int* matrix, int num)
{
    int i, j;
    int ttime = 0;
    int stime[MAX_NUM+1] = {0};
    int etime[MAX_NUM+1] = {0};
    int state[MAX_NUM+1] = {0};
    stack<int> S;
    int target, next;
    int *tmp;

    for (j = 1; j <= num; j++) {
        if (state[j] != NO_VISIT) {
            continue;
        }
        S.push(j);
        ++ttime;
        stime[j] = ttime;
        state[j] = NOW_VISIT;

        while (S.empty() == false) {
            target = S.top();
            for (i = 1; i <= num; i++) {
                tmp = matrix + MAX_NUM * target + i;
                if ((*tmp == 1) && (state[i] == NO_VISIT)) {
                    *tmp = 2;
                    S.push(i);
                    ++ttime;
                    stime[i] = ttime;
                    state[i] = NOW_VISIT;
                    break;
                }
            }

            if (i == num + 1) {
                S.pop();
                ++ttime;
                etime[target] = ttime;
                state[target] = END_VISIT;
            }
        }
    }

    for (i = 1; i <= num; i++) {
        printf("%d %d %d\n", i, stime[i], etime[i]);
    }

    return;
}

int main(void)
{
    int i, j;
    int num;
    int elem;
    int nume;
    int tmp;
    int matrix[MAX_NUM][MAX_NUM] = {0};

    scanf("%d", &num);

    for (i = 0; i < num; i++) {
        scanf("%d %d", &elem, &nume);
        for (j = 0; j < nume; j++) {
            scanf("%d", &tmp);
            matrix[elem][tmp] = 1;
        }
    }

    DSF(&matrix[0][0], num);

    return 0;
}

Measured memory_bytes: 1240
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import defaultdict
from collections import deque
import bisect
from decimal import *
def main():
    N = I()
    mod = 10 ** 9 + 7
    print((pow(10, N, mod) - (2 * pow(9, N, mod) % mod) + pow(8, N, mod)) % mod)
if __name__ == "__main__":
    main()



Measured memory_bytes: 77076
#include <bits/stdc++.h>
using namespace std;
int a[300];
int main()
{
	int n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(i%2==1&&a[i]%2==1) ans++; 
	}
	printf("%d",ans);
 } 

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

int main()
{
   long long int n,k,x,y,i,sum=0;
    cin>>n>>k>>x>>y;
    for(i=1;i<=n;i++)
    {
        if(i<=k)
            {
                sum=sum+x;
            }
        else
            {
                sum=sum+y;
            }
    }
    cout<<sum;


    return 0;
}


Measured memory_bytes: 256
while True :
	a, op, b = input().split()
	a = int(a)
	b = int(b)
	if op == "?" :
		break
	elif op == "+" :
		print(int(a+b))
	elif op == "-" :
		print(int(a-b))
	elif op == "*" :
		print(int(a*b))
	else :
		print(int(a/b))



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

const int Maxn = 12;

int n, m;
vector <int> my[Maxn];
int p[Maxn];
int res;

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int k; scanf("%d", &k);
        my[i].resize(k);
        for (int j = 0; j < k; j++) {
            scanf("%d", &my[i][j]);
            my[i][j]--;
        }
    }
    for (int i = 0; i < m; i++)
        scanf("%d", &p[i]);
    for (int i = 0; i < 1 << n; i++) {
        bool ok = true;
        for (int j = 0; j < m && ok; j++) {
            int cur = p[j];
            for (int z = 0; z < my[j].size(); z++) {
                int v = my[j][z];
                if (i & 1 << v) cur ^= true;
            }
            ok = cur == 0;
        }
        res += ok;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

int main()
{
	for(string s;getline(cin,s);){
		vector<int> cs;
		for(int i=0;i<s.size();i++)
			if(i==0 || s[i]!=s[i-1])
				cs.push_back(1);
			else
				cs.back()++;
		s.erase(unique(s.begin(),s.end()),s.end());
		
		int res=0;
		for(int i=2;i<s.size();i++)
			if(s[i-2]=='J' && s[i-1]=='O' && s[i]=='I')
				if(cs[i-2]>=cs[i-1] && cs[i-1]<=cs[i])
					res=max(res,cs[i-1]);
		cout<<res<<endl;
	}
	
	return 0;
}

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

int main()
{
  int card[5];
  while (scanf("%d, %d, %d, %d, %d", &card[0], &card[1], &card[2], &card[3], &card[4]) != EOF){
    sort(card, card + 5);
    int ct[14] = {0};
    for (int i = 0; i < 5; i++){
      ct[card[i]]++;
    }

    int a = 0;
    for (int i = 0; i < 4; i++){
      if (card[i] + 1 == card[i + 1]) a++;
    }
    if (card[4] == 13 && card[0] == 1) a++;
    if (a == 4){
      cout << "straight\n";
      continue;
    }
    int ma = 0;
    for (int i = 1; i < 14; i++) ma = max(ma, ct[i]);

    if (ma == 4) {
      cout << "four card\n";
      continue;
    }
    if (ma == 3){
      if (card[0] == card[1] && card[1] != card[2] || card[3] == card[4] && card[3] != card[2]){
        cout << "full house\n";
      }
      else {
        cout << "three card\n";
      }
      continue;
    }
    if (ma == 2){
      int b = 0;
      for (int i = 1; i < 14; i++) if (ct[i] == 2) b++;
      if (b == 2) cout << "two pair\n";
      else cout << "one pair\n";
      continue;
    }
    cout << "null\n";
  }
}

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

int main() {
  int n, m, p, x, ans;
  cin >> n;
  vector<int> T(n);
  rep(i, n) cin >> T.at(i);
  int sum = 0;
  cin >> m;
  rep(i, n) sum += T.at(i);
  int tmp = sum;
  rep(i, m) {
    cin >> p >> x;
    tmp = sum - (T.at(p-1) - x);
    cout << tmp << endl;
  }
}

Measured memory_bytes: 256
using System;
class p
{
  static void Main()
  {
    string[] ipt = Console.ReadLine().Split(' ');
    int N = int.Parse(ipt[0]);
    int K = int.Parse(ipt[1]);
    ipt = Console.ReadLine().Split(' ');
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[i] = int.Parse(ipt[i]);
    }
    Array.Sort(arr);
    long sum = 0;
    for (int i = 0; i < (N - K); i++) {
      sum += arr[i];
    }
    Console.WriteLine(sum);
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  double sum = 0.0;
  int count = n - 1;
  while(count > 0) {
    count--;
    double ave = (v[0] + v[1]) / 2;
    v.erase(v.begin());
    v.erase(v.begin());
    v.insert(v.begin(), ave);
  }
  cout << v[0] << endl;
  return 0;
}

Measured memory_bytes: 256
a,b,c,k = map(int,input().split())
ans = 0
if a <= k:
    ans += a
else:
    print(k)
    exit()
k = k - a
if b <= k:
    ans += 0
else:
    print(ans)
    exit()
k = k - b
ans += k*-1
print(ans)

Measured memory_bytes: 9124
#include<stdio.h>
int main(){
int a1,a2,a3,a4,b1,b2,b3,b4,a_sum,b_sum;
scanf("%d %d %d %d\n%d %d %d %d\n",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4);
a_sum=a1+a2+a3+a4;
b_sum=b1+b2+b3+b4;
if(a_sum>b_sum)printf("%d\n",a_sum);else printf("%d\n",b_sum);
return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
void solveA()
{
  long long a,b,tem;
  cin>>a>>b;
  tem=(a+b);
  if(tem%2==0)
  {
    cout<<tem/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
}
void solveB()
{
  int n,i,j,count;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  j=1;
  count=0;
  for(i=0;i<n;i++)
  {
    if(ar[i]!=j)
    {
      count++;
    }
    if(count>2)
    {
      cout<<"NO"<<endl;
      return;
    }
    j++;
  }
  cout<<"YES"<<endl;
}
void solveC()
{
  int a,b,x,y;
  cin>>a>>b;
  x=max(a,b);
  y=min(a,b);
  if((x-y)>=2)
  {
    cout<<2*x-1<<endl;
  }
  else
  {
    cout<<x+y<<endl;
  }
}
void solveD()
{
  int n,i,j;
  cin>>n;
  int ar[n];
  for(i=0;i<n;i++)
  {
    cin>>ar[i];
  }
  int count=n;
  for(i=n-1;i>=0;i--)
  {
    for(j=i-1;j>=0;j--)
    {
      if(ar[i]<ar[j])
      {
        count--;
        break;
      }
    }
  }
  cout<<count<<endl;
}
void solveE()
{
  int h,w,x,y,H,W;
  cin>>H>>W;
  cin>>h>>w;
  x=h*W;
  y=(H-h)*w;
  cout<<(H*W)-(x+y)<<endl;
}
void solveF()
{
  int n,m,c,i,j;
  cin>>n>>m>>c;
  int b[m];
  int ar[n][m];
  for(i=0;i<m;i++)
  {
    cin>>b[i];
  }
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      cin>>ar[i][j];
    }
  }
  int count=0;
  int sum;
  for(i=0;i<n;i++)
  {
    sum=0;
    for(j=0;j<m;j++)
    {
      sum=sum+ar[i][j]*b[j];
    }
    if((sum+c)>0)
    {
      count++;
    }
  }
  cout<<count<<endl;
}
void solveG()
{
  
}
int main()
{
  // solveA();
  //solveB();
  // solveC();
  // solveD();
 solveE();
// solveF();
  return 0;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = Console.ReadLine();
            var count = nums.Select(p => p - '0').Where((p, i) => (i % 2) == p).Count();
            var min = Math.Min(nums.Length - count, count);
            Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 11488
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
void read_And_write(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void raushan_kumar(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int l,r;cin>>l>>r;
    if(l<=0 and r>=0){
    	cout<<"Zero";
    	return;
    }
    else{
    	d=r-l+1;
    	if(r<=-1 and d%2){
    		cout<<"Negative";
    	}
    	else
    		cout<<"Positive";
    }
}

int32_t main()
{
   fast;int t=1;
    // cin>>t;
    while(t--){raushan_kumar();}
}

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

int K,sur,sum=0;
vector<long long> ans[10];

void add(int i,long long n){
	ans[i].push_back(n);
	if(++sum==K)cout<<n;
}
int main(){
	cin>>K;
	for(int i=1;i<=9;i++)add(0,i);
	for(int i=0;i<9;i++){
		for(int j=0;j<ans[i].size();j++){
			sur=ans[i][j]%10;
			if(sur!=0)add(i+1,ans[i][j]*10+sur-1);
			add(i+1,ans[i][j]*10+sur);
			if(sur!=9)add(i+1,ans[i][j]*10+sur+1);
			if(sum>=K)return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 301000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int H,W;
char a[1010][1010];
int dist[1010][1010] = {0};
int main(){
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a[i][j];
            dist[i][j] = 0;
        }
    }
    dist[0][0] = 1;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            dist[i][j] %= MOD;
            if(a[i+1][j] == '.'){
                dist[i+1][j] += dist[i][j];
            }
            if(a[i][j+1] == '.'){
                dist[i][j+1] += dist[i][j];
            }
        }
    }
    dist[H-1][W-1] %= MOD; 
    cout << dist[H-1][W-1] << endl;
}


Measured memory_bytes: 5248
# ABC069C - 4-adjacent (ARC080C)
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    f, t, m = 0, 0, 0  # two, four, misc
    for i in A:
        if i % 4 == 0:
            f += 1
        elif i % 2 == 0:
            t += 1
        else:
            m += 1
    m += t % 2
    flg = f + 1 >= m
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 14352
import java.util.*;

public class Main {

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

        int cnt = 0;
        int tmp = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= i; ++j) {
                if (i % j == 0) ++tmp;
            }
            if (tmp == 8 && i % 2 == 1) ++cnt;
            tmp = 0;
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 23120
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
     int a,b;
   cin>>a; cin>>b;
   int d = a/b;
   int r = a%b;
   double f =double(a)/double(b);
   cout<<d;
   cout<< " ";
   cout<<r;
   cout<<" ";
   cout<< fixed<<setprecision(5)<< f;
   cout<<endl;
   
}


Measured memory_bytes: 3256
def main():
	N = int(input())
	A = list(map(int, input().split()))
	while(len(A) != 1):
		A.sort()
		mini = A[0]
		i = 1
		while(True):
			if A[i] % mini == 0:
				A.pop(i)
			else:
				A[i] = A[i] % mini
				i += 1
			if i == len(A):
				break
		A = list(set(A))
	print(A[0])

if __name__ == '__main__':
	main()

Measured memory_bytes: 14252
o=str(input());e=str(input())
if(len(o)-len(e)==0):
    for i in range(0,len(o)):
        print(o[i]+e[i],end='')
else:
    for i in range(0,len(e)):
        print(o[i]+e[i],end='')
    print(o[len(o)-1])


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

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define all(a) (a).begin(),(a).end()
#define sz(x) ((ll)(x).size())
#define pb push_back
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
const ll inf = 1ll<<62;

int main(){
#define int ll
  int n,k,q; cin >> n >> k >> q;
  vi a(n); rep(i,n) cin >> a[i];

  int res = inf;
  rep(minpos,n){
    vvi tmp(n);
    int m = 0;
    rep(i,n){
      if(a[i] >= a[minpos]) tmp[m].pb(a[i]);
      else m++;
    }
    m++;
    rep(i,m) sort(all(tmp[i]));
    vi take;
    rep(i,m) rep(j,sz(tmp[i])-k+1) take.pb(tmp[i][j]);
    sort(all(take));
    if(sz(take) >= q) res = min(res, take[q-1] - a[minpos]);
  }
  cout << res << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
 
using namespace std;

int i,j,k;
 
int max(int a, int b)
{
    if(a>b) return a;
    else return b;
}
 
int min(int a,int b)
{
    if(a<b) return a;
    else return b;
}

int fast_power(int a,int b)
{
    int res=1;
    while(b>0)
    {
        if(b%2==0)
        {
            b/=2;
            a=(a*a)%mod;
        }
        else
        {
             b/=2;
             res=(res*a)%mod;
            a=(a*a)%mod;
        }
    }
    return res;
}
int palindrone(string s,int l,int r)
{
    int flag=1;
    while(l<r)
    {
        if(s[l]!=s[r])
        {
            flag=0; 
            break;
        }
        l++;
        r--;
    }
    return flag;
}

signed main()
{
    IOS;
    string s;
    cin>>s;
    int n=s.length();
    int a=(n-1)/2-1;
    int b=(n+3)/2-1;
    if(palindrone(s,0,n-1)==1&&palindrone(s,0,a)==1&&palindrone(s,b,n-1)) cout<<"Yes";
    else cout<<"No";
    // cout<<palindrone(s,0,n-1);
    // cout<<palindrone(s,0,a);
    // cout<<palindrone(s,b,n-1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second


int main() {
    int n;
    cin>>n;
    vector<int>p(n);
    vector<int>q(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<n;i++){
        cin>>q[i];
    }
    int pnum=0;
    int qnum=0;
    do{
        pnum++;
    }
    while(next_permutation(p.begin(),p.end()));
    do{
        qnum++;
    }
    while(next_permutation(q.begin(),q.end()));

    cout<<abs(pnum-qnum)<<endl;



    return 0;
}


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

int main() {
	int n,m; cin>>n>>m;
	int arr[n];
	for(int i =0; i<n; i++)
		cin>>arr[i];
		
	vector<int> g[n+1];
	
	for(int i=0; i<m; i++){
		int u,v; cin>>u>>v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	int rta = 0;
	
	for(int i=0; i<n; i++){
		bool flag  = true;
		for(auto&x : g[i]){
			if(arr[i]<=arr[x]){
				flag = false;
				break;
			}
		}
		if(flag)rta++;
	}
	cout<<rta<<endl;
}

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    ll ans=0;
    ll num=0,m;
    for(int i=n-1;i>=0;i--){
        m=(s[i]-'0');
        m+=num;
        if(m>5||(i&&m>=5&&(s[i-1]-'0')>=5)){
            ans+=10-m;
            num=1;
        }else{
            ans+=m;
            num=0;
        }
    }
    ans+=num;
    cout << ans<<endl;

    return 0;
}


Measured memory_bytes: 1948
from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(n)]
b = [[int(stdin.readline().rstrip())] for _ in range(m)]
c = [[0] for _ in range(n)]
for i in range(n):
    for j in range(m):
    	c[i][0] += (a[i][j]*b[j][0])

for i in range(n):
    print(*c[i])


Measured memory_bytes: 6036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
LL facctorialMethod(int k);
int main(){
    LL n,a,sum;
    LL len_a,len_sum;
    cin >> n ;
    vector<LL> array_a(n);

    for(int i = 0; i < n; i++) {
        cin >> a;
        array_a[i] =  a;
        if(a == 0) {
            cout << "0" << endl;
            return 0;
        }
    }
/*
    for(int i = 0; i < n; i++) {
        cout << "array_a[i] :[" << i << "] :" << array_a[i] << endl;
    }
*/
    sum = 1;
    for(int i = 0; i < n; i++) {
        if(((LL)1e18 / array_a[i]) < sum ) {
            cout << -1 << endl;
            return 0;            
        } 
        sum *= array_a[i];
        if(sum > (LL)1e18) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << sum << endl;
    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int n, f[101000], las[3];
char s[101000];

int main(){
    cin>>s+1; n=strlen(s+1);
    for (int i=2;;++i){
        if (i>n) return puts("1"), 0;
        if (s[i]==s[i-1]) break;
    }
    las[0]=n+1; las[1]=las[2]=n+2;
    int sum=0; f[n+1]=1;
    for (int i=n;i>=1;--i){
        sum=(sum+1+(s[i]=='b'))%3;
        f[i]=f[i+1];
        int aim=(sum-1-(s[i]=='a')+3)%3;
        f[i]=(f[i]+f[las[aim]])%mod;
        las[sum]=i;
        if (!sum&&i>1) f[i]=(f[i]+1)%mod;
    }
    cout<<f[1]<<endl;
}

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

int main(){
    long long int l, a, b, m;
    cin >> l >> a >> b >> m;

    vector<long long int> pow10(19, 1);// pow10[i] = 10^i
    for(int i=0; i+1<19; i++) pow10[i+1] = pow10[i] * 10;

    vector<vector<long long int>> base_matrix(3, vector<long long int>(3));
    base_matrix[0][0] = 1;
    base_matrix[0][1] = 1;
    base_matrix[1][1] = 1;
    base_matrix[1][2] = b % m;
    base_matrix[2][2] = 1;

    bool flag = false;
    vector<long long int> ans = {0, (a % m), 1};
    for(int d=0; d<18; d++){
        if(pow10[d+1] > a+(l-1)*b) flag = true;

        base_matrix[0][0] = pow10[d+1] % m;
        vector<vector<long long int>> matrix = base_matrix;

        long long int c = 0;
        if((pow10[d+1]-1) - a >= 0LL) c = (min(a+(l-1)*b, (pow10[d+1]-1)) - a) / b + 1;
        if((pow10[d]  -1) - a >= 0LL) c -= ((pow10[d]-1) - a) / b + 1;
        //cout << c << " ";
        for(int b=0; b<60; b++){
            if(c >> b & 1){
                vector<long long int> memo_ans(3);
                for(int i=0; i<3; i++){
                    for(int j=0; j<3; j++){
                        memo_ans[i] += (matrix[i][j] * ans[j]) % m;
                        memo_ans[i] %= m;
                    }
                }
                ans = memo_ans;
            }

            // doubling
            vector<vector<long long int>> memo_matrix(3, vector<long long int>(3));
            for(int i=0; i<3; i++){
                for(int j=0; j<3; j++){
                    for(int k=0; k<3; k++){
                        memo_matrix[i][j] += (matrix[i][k] * matrix[k][j]) % m;
                        memo_matrix[i][j] %= m;
                    }
                }
            }
            matrix = memo_matrix;
        }
        if(flag == true) break;
    }
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
const int MOD=1000000007;
const int INF=1000000007;
using ll=long long;

int main() {
	string s;
	int a=0,b=0;
	cin>>s;
	a=(s[0]-'0')*10+s[1]-'0';
	b=(s[2]-'0')*10+s[3]-'0';
	if(a>12&&b<=12){
		if(b==0){
			cout<<"NA"<<endl;
			return 0;
		}
		cout<<"YYMM"<<endl;
		return 0;
	}else if(a>12&&b>12||(a==0&&b==0)){
		cout<<"NA"<<endl;
		return 0;
	}else if(a<=12&&b<=12){
		if(a==0){
			cout<<"YYMM"<<endl;
			return 0;
		}else if(b==0){
			cout<<"MMYY"<<endl;
			return 0;
		}
		cout<<"AMBIGUOUS"<<endl;
		return 0;
	}else if(a<=12&&b>12){
		cout<<"MMYY"<<endl;
		return 0;
	}
	
}


Measured memory_bytes: 256
// Problem : D - Caracal vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_d
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
		
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const int INF = 1e18;
const int N = (int)3e5+5;

map<int, int> mp;

int dp(int x)
{
	if(x == 1)
		return 1;
	if(mp.find(x) == mp.end()){
		return mp[x] = 1 + 2*dp(x/2);
	}else{
		return mp[x];
	}
}

int32_t main()
{
	IOS;
	int t = 1;
	//cin >> t;
	for(int msi = 0; msi < t; msi++){
		int x;
		cin >> x;
		int ans = dp(x);
		cout << ans << endl;
	}
 	return 0;
}


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

using namespace std;

#define int         long long
#define ld          double
#define vi          vector <int>
#define vp          vector <pair<int,int>>
#define vvi         vector <vector <int>>
#define pb          push_back
#define mp          make_pair
#define pi          pair<int,int>
#define all(a)      a.begin(),a.end()
#define sz(a)       a.size()
#define sl(a)       a.length()
#define rev(a)      sort(all(a),greater<int>())
#define ff          first
#define ss          second
#define minel(a)	*min_element(all(a))
#define maxel(a)	*max_element(all(a))
#define Mod         1000000007
#define deb(x)      cout << x << endl;
#define o(x)        for(auto a:x)cout << a <<" ";cout << endl;
#define o2(x,n,m)   for(int i =0;i<n;i++){for(int j=0;j<m;j++)cout << x[i][j] << " ";cout << endl; } 
#define i(x,n)      for(int i=0;i<n;i++)cin >> x[i];
#define i2(x,n,m)   for(int i =0;i<n;i++){for(int j=0;j<m;j++)cin >> x[i][j]; }
int inf = 1e18;

//vvi a(n, vi(10));

int power(int a,int b, int m);

signed main()
{
    int n,W;
    cin >> n >> W;
    vi weight,value;weight.pb(0);value.pb(0);

    int V = 0;
    for(int i=0;i<n;i++)
    {
        int w,v;
        cin >> w >> v;
        weight.pb(w);value.pb(v);
        V+= v;
    }
    int dp[n+1][V+1];

    for(int i=0;i<n+1;i++)dp[i][0] = 0;
    for(int i=0;i<V+1;i++)dp[0][i] = inf;
    dp[0][0] = 0;

    for(int i=0;i<n+1;i++)
    {
        for(int j=0;j<V+1;j++)
        {
            if(i == 0 || j == 0)continue;
            if(j-value[i]>= 0)
            {
                dp[i][j] = min(dp[i-1][j],dp[i-1][j-value[i]]+weight[i]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    int ans = -1;
    for(int i=0;i<n+1;i++)
    {
        for(int j=0;j<V+1;j++)
        {
            if(dp[i][j] <= W)ans = max(ans,j);
        }
    }

    cout << ans <<endl;

    
}

//utility function

int power(int a,int b,int m)
{
    int ans = 1;
    while(b > 0)
    {
        if(b&1){ans *= a;ans %= m;}
        a *= a;
        a %= m;
        b >>= 1;
    }
    return ans;
}



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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        
        for(int i = 0; i < a.length; i ++) {
            a[i] = sc.nextInt();
        }
            Arrays.sort(a);
            System.out.println(a[0] + " " + a[1] + " " + a[2]);
    }
}


Measured memory_bytes: 26220
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    int a;
    char buf[30];

    //標準入力から1行bufに格納
    fgets(buf, sizeof(buf), stdin);

    a = atoi(buf);
    int result = a+a*a+ a*a*a;

    //標準入力に書き出す
    printf("%d\n", result);
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int l[105],d[105];
int main()
{
    int n,x;
    cin>>n>>x;
    for(int i=1;i<=n;i++)
    {
        cin>>l[i];
    }
    int ans;
    for(int i=2;i<=n+1;i++)
    {
        d[i]=d[i-1]+l[i-1];
        if(d[i]>x)
        {
            ans=i-1;
            break;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define rev_rep(i, n) for(int i = n - 1; i >= 0; --i)
#define range(a, i, b) for(int i = a; i <b; ++i)
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()
#define readl(N) ll N; cin >> N
#define readlv(N, vec) vector<ll> vec(N); rep(i, N){cin >> vec[i];}
#define greater_than [](ll l, ll r){return l > r;}
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

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

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  readl(n);
  readl(k);

  map<ll, ll> a;

  rep(i, n){
    ll x;
    cin >> x;
    a[x]++;
  }

  vector<pair<ll, ll>> b;

  for(auto && x: a){
    b.push_back(x);
  }

  sort(all(b), [&](auto l, auto r){return l.second > r.second;});

  ll res = 0;
  if(k >= b.size()){
    cout << 0;
    return 0;
  }
  rep(i, k){
    // dump(b[i]);
    res += b[i].second;
  }
  cout << n - res;
}
#endif


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

int main()
{
	int N;
	cin >> N;
	char S[100000];
	for (int i = 0; i < N; i++)
	{
		cin >> S[i];
	}

	int count[26] = { 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0 };

	for (int i = 0; i < N; i++)
	{
		switch (S[i])
		{
		case 'a':
			count[0]++;
			break;
		case 'b':
			count[1]++;
			break;
		case 'c':
			count[2]++;
			break;
		case 'e':
			count[3]++;
			break;
		case 'f':
			count[4]++;
			break;
		case 'g':
			count[5]++;
			break;
		case 'h':
			count[6]++;
			break;
		case 'i':
			count[7]++;
			break;
		case 'j':
			count[8]++;
			break;
		case 'k':
			count[9]++;
			break;
		case 'l':
			count[10]++;
			break;
		case 'm':
			count[11]++;
			break;
		case 'n':
			count[12]++;
			break;
		case 'o':
			count[13]++;
			break;
		case 'p':
			count[14]++;
			break;
		case 'q':
			count[15]++;
			break;
		case 'r':
			count[16]++;
			break;
		case 's':
			count[17]++;
			break;
		case 't':
			count[18]++;
			break;
		case 'u':
			count[19]++;
			break;
		case 'v':
			count[20]++;
			break;
		case 'w':
			count[21]++;
			break;
		case 'x':
			count[22]++;
			break;
		case 'y':
			count[23]++;
			break;
		case 'z':
			count[24]++;
			break;
		case 'd':
			count[25]++;
			break;


		}
	}

	long long ans = 1;

	for (int i = 0; i < 26; i++)
	{
		ans *= (count[i] + 1);
		ans = ans % 1000000007;
	}

	ans = ans -1;
	ans = ans % 1000000007;

	

	cout << ans;
	

	return 0;

}

Measured memory_bytes: 384