akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int C;
const int M[4] = {10,50,100,500};
int num[4], use[4], ans[4], res;
void dfs(int idx){
  if(idx == 4){
	int sum = 0;
	REP(i,4)
	  sum += use[i] * M[i];
	if(sum < C) return;
	sum = sum - C;
	int buf[4]; fill(buf, buf+4, 0);
	REP(i,3){
	  buf[i] = sum % M[i+1] / M[i];
	  sum -= buf[i] * M[i];
	}
	buf[3] = sum / 500;
	sum = 0;
	REP(i,4)
	  if(use[i] > 0 && buf[i] > 0) return;
	  else sum += use[i] - buf[i];
	if(res < sum){
	  res = sum;
	  REP(i,4) ans[i] = use[i];
	}
	return;
  }
  for(int i=0;i<=num[idx];++i){
	use[idx] = i;
	dfs(idx+1);
  }
}

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

  bool flag = false;
  while(true){
	cin >> C; if(!C) break;
	REP(i,4) cin >> num[i];
	if(flag) cout << endl;

	int sum = 0;
	REP(i,4) sum += num[i] * M[i];
	C = sum - C;
	for(int i=3;i>=0;--i)
	  while(C >= M[i]){
		C -= M[i];
		--num[i];
	  }
	REP(i,4)
	  if(num[i] > 0) cout << M[i] << " " << num[i] << endl;
	flag = true;
  }

  return 0;
}

Measured memory_bytes: 1192
n,q = map(int, input().split())
s = input()
l = [0]*(n+1)
for i in range(1,n):
  if s[i-1:i+1] == "AC":
    l[i] = l[i-1]+1
  else:
    l[i] = l[i-1]
for _ in range(q):
  a,b = map(int, input().split())
  print(l[b-1]-l[a-1])

Measured memory_bytes: 6140
def main():
    s = input()
    q = int(input())
    left = ""
    right = ""
    hanten = False
    for i in range(q):
        query = input().split()
        if query[0] == "1":
            hanten = not hanten
        else:
            c = query[2]
            if query[1] == "1":
                if not hanten:
                    left = "".join([left,c])
                else:
                    right = "".join([right,c])
            else:
                if not hanten:
                    right =  "".join([right,c])
                else:
                    left = "".join([left,c])
        #print(query)
        #print(s,left,right)
    left = left[::-1]
    answer = left + s + right

    if not hanten:
        print(answer)
    else:
        print(answer[::-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=1000005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int A[MAXN], N;
string S;

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>S;
	N=S.size();
	FOR(i,1,N)A[i]=(int)S[i-1]-'0';
	int ans=0;
	DEC(i,N,1){
		A[i-1]+=A[i]/10;
		A[i]=A[i]%10;
		if ((A[i]==5 && A[i-1]>=5) || A[i]>5){
			ans+=10-A[i];
			A[i-1]++;
		}
		else ans+=A[i];
	}
	ans+=A[0];
	cout<<ans;
}


Measured memory_bytes: 5276
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.sqrt


fun main(args: Array<String>) {
    val inputReader = InputReaderc168(System.`in`)

    var a = inputReader.nextInt()
    var b = inputReader.nextInt()
    var h = inputReader.nextInt()
    var m = inputReader.nextInt()

    val x = (h * 60 + m) * 0.5
    val y = m * (360/60)

    val angle = abs(x - y) * PI/180

    val c = sqrt((a * a) + (b * b) - (2 * a * b * cos(angle)))
    print(c)
}

class InputReaderc168(stream: InputStream) {
    private var reader: BufferedReader = BufferedReader(InputStreamReader(stream))
    private var tokenizer: StringTokenizer? = null

    init {
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }

    fun nextLine(): String {
        var str = ""
        try {
            str = reader.readLine()
        } catch (e: IOException) {
            e.printStackTrace()
        }

        return str
    }
}


Measured memory_bytes: 34556
n =int(input())
list=[]
for i in range(n):
    s = input()
    list.append(s)
print('AC x '+str(list.count('AC')))
print('WA x '+str(list.count('WA')))
print('TLE x '+str(list.count('TLE')))
print('RE x '+str(list.count('RE')))

Measured memory_bytes: 16168
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int tot, A[10];

int main() {
    while (cin >> tot) {
        if (tot == 0) break;
        for (int i = 0; i < 9; ++i) {
            cin >> A[i];
            tot -= A[i];
        }
        cout << tot << endl;
    }
    return 0;
}


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

int main(void)
{
    int n, k;
    int h[100001];
    int dp[100001];
    int step[100];
    cin >> n >> k;

    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    dp[0] = 0;
    
    for(int i = 1; i < n; i++) {
        dp[i] = dp[i - 1] + abs(h[i] - h[i-1]);
        for(int j = 2; j <= k; j++) {
            if(i - j < 0) {
                break;
            }
            step[j] = abs(h[i-j] - h[i]);
            step[j] += dp[i-j];
            dp[i] = min(step[j], dp[i]);
        }
    }
    cout << dp[n-1];
}

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

using namespace std;

int n, x, g;
int ta;

int gcd(int a, int b) {
	while (a) {
		b %= a;
		swap(a, b);
	}
	return b;
}

int main() {
	scanf("%d%d", &n, &x);
	while (n--) {
		scanf("%d", &ta);
		ta = abs(x - ta);
		if (g)
			g = gcd(g, ta);
		else
			g = ta;
	}
	printf("%d\n", g);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

constexpr unsigned Mod = 1000000007;

unsigned Mul(unsigned a, unsigned b) {
  return (unsigned) ((unsigned long long) a * b % Mod);
}

int main() {
  int N;
  scanf("%d", &N);
  if (N == 1) {
    printf("2\n");
    return 0;
  }
  static vector<int> H[100000];
  for (auto i = 1; i < N; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    H[u - 1].emplace_back(v - 1);
    H[v - 1].emplace_back(u - 1);
  }
  static int P[100000];
  static int Q[100000];
  fill(P, P + N, -1);
  P[0] = 0;
  for (auto qb = 0, qe = 1; qb < qe; ++qb)
    for (auto v : H[Q[qb]])
      if (P[v] == -1)
        P[Q[qe++] = v] = Q[qb];
  static array<unsigned, 2> F[100000];
  fill(F, F + N, array<unsigned, 2>{1, 1});
  for (auto i = N - 1; i; --i) {
    auto u = Q[i];
    auto v = P[u];
    F[v][0] = Mul(F[v][0], F[u][0] + F[u][1]);
    F[v][1] = Mul(F[v][1], F[u][0]);
  }
  printf("%u\n", (F[0][0] + F[0][1]) % Mod);
  return 0;
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}




int main(){

  ll n;
  string s;
  cin >> n >> s;
  vector<ll> cnt[3];
  FOR(i,0,3) cnt[i].resize(n);
  FOR(i,0,3) cnt[i][0] = s[0]%3==i;

  FOR(i,1,n)FOR(j,0,3){
    cnt[j][i] = cnt[j][i-1] + (s[i]%3==j);
  }

  ll ans = 0;
  FOR(i,0,n)FOR(j,i+1,n){
    ll k = 2*j-i;
    ll c = 3 - s[i]%3 - s[j]%3;
    if(s[i]!=s[j]){
      ans += cnt[c][n-1] - cnt[c][j];
      if(k<n && k>=0 && s[k]%3==c && k>j)ans--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b, k;
  cin >> a >> b >> k;
  map<int, int> data;
  int j = 1;
  for(int i = 1; i <= 100; i++){
    if(a % i == 0 && b % i == 0){
      data[i] = j;
    }
  }
  vector<int> answer(data.size());
  int i = 0;
  for(auto x : data){
    auto a = x.first;
    auto b = x.second;
    answer.at(i) = a;
    i++;
  }
  cout << answer.at(answer.size() - k) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

ll gcd(ll x,ll y){
  if(x%y==0) return y;
  return gcd(y,x%y);
}

ll res(ll n,ll c,ll d,ll l){
  return n-(n/c+n/d-n/l);
}

ll a,b,c,d;

int main(){
  cin >> a >> b >> c >> d;
  ll l = c / gcd(c,d) *d;
  cout<< res(b,c,d,l)-res(a-1,c,d,l) <<endl;
}


Measured memory_bytes: 256
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]

c = 0
for i in range(n):
    if d[i][0] == d[i][1]:
        c += 1
        if c == 3:
            print('Yes')
            exit()
    else:
        c = 0
if c == 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9188
#include<iostream>

using namespace std;

int main(){
    int k,i,j,l=0,flg=0;
    cin >> k >> i >> j;
    for(l=i;l<j+1;l++){
        if(l%k==0){
            flg = 1;
        }
    }
    if(flg==1){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
def dfs(c, i, l):
    if i == n:
        for j in l:
            if j < x:
                return None
        ans.append(c)
        return None
    else:
        for j in range(1, m + 1):
            l[j - 1] += ca[i][j]
        dfs(c + ca[i][0], i + 1, l)
        for j in range(1, m + 1):
            l[j - 1] -= ca[i][j]
        dfs(c, i + 1, l)
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for i in range(n)]
ans = []
li = [0] * m
dfs(0, 0, li)
try:
    print(min(ans))
except:
    print(-1)

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

/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define endl '\n'

/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

void solve() {
	int n; cin >> n;
	int ans = n % 1000;
	if (ans) {
		ans = 1000 - ans;

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

int32_t main() {

	/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	/* → → → → → → → → → → → → → → → → → → → → → → → → → → → →
	→ → → → → → → → → → → → → → → → → → → → → → → → → → → → */

	//int t;cin>>t;while(t--)
	solve();

	return 0;
}

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

Vec fac, finv;

ll PowMod(ll a, ll n){
	if(n == 1) return a;
	if(n%2 == 0) return PowMod(a*a%MOD, n/2);
	return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
	return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

void init(ll n = 2e6){
	fac.resize(n+1);
	fac[0] = 1;
	repn(i, n) fac[i] = (fac[i-1]*i)%MOD;
	finv.resize(n+1);
	finv[n] = PowMod(fac[n], MOD-2);
	repr(i, n) finv[i] = (finv[i+1]*(i+1))%MOD;
	finv[0] = 1;
}

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

	while(q--){
		ll n, x, m;
		cin >> n >> x >> m;
		Vec cs(k+1);
		repn(i, k){
			cs[i] = d[i-1]%m+cs[i-1];
		}
		ll cnt = 0;
		n--;
		rep(i, k){
			if(d[i]%m == 0){
				cnt += n/k;
				if(n%k > i) cnt++;
			}
		}

		ll a = n/k, r = n%k;
		ll sum = x%m+a*cs[k]+cs[r];
		//co({sum, cnt});
		ll ans = n-sum/m-cnt;
		co(ans);
	}

	return 0;
}


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


vector<long long> sp[3];
int N, K;
int input[50][6];

int cnt[100][100][100];

int main()
{
  cin >> N >> K;
  for(int i = 0; i < N; i++)
  {
    int x1, y1, z1, x2, y2, z2;
    cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
    sp[0].push_back(x1);
    sp[0].push_back(x2);
    sp[1].push_back(y1);
    sp[1].push_back(y2);
    sp[2].push_back(z1);
    sp[2].push_back(z2);
    input[i][0] = x1;
    input[i][1] = y1;
    input[i][2] = z1;
    input[i][3] = x2;
    input[i][4] = y2;
    input[i][5] = z2;
  }
  for(int i = 0; i < 3; i++)
  {
    sort(sp[i].begin(), sp[i].end());
    unique(sp[i].begin(), sp[i].end());
  }
  for(int i = 0; i < N; i++)
  {
    auto x1 = distance(sp[0].begin(), lower_bound(sp[0].begin(), sp[0].end(), input[i][0]));
    auto y1 = distance(sp[1].begin(), lower_bound(sp[1].begin(), sp[1].end(), input[i][1]));
    auto z1 = distance(sp[2].begin(), lower_bound(sp[2].begin(), sp[2].end(), input[i][2]));
    auto x2 = distance(sp[0].begin(), lower_bound(sp[0].begin(), sp[0].end(), input[i][3]));
    auto y2 = distance(sp[1].begin(), lower_bound(sp[1].begin(), sp[1].end(), input[i][4]));
    auto z2 = distance(sp[2].begin(), lower_bound(sp[2].begin(), sp[2].end(), input[i][5]));
    for(int x = x1; x < x2; x++)
      for(int y = y1; y < y2; y++)
        for(int z = z1; z < z2; z++)
          cnt[x][y][z]++;
  }
  long long area = 0;
  for(int x = 0; x < 100; x++)
    for(int y = 0; y < 100; y++)
      for(int z = 0; z < 100; z++)
        if(cnt[x][y][z] >= K)
          area += (sp[0][x + 1] - sp[0][x]) * (sp[1][y + 1] - sp[1][y]) * (sp[2][z + 1] - sp[2][z]);
  cout << area << endl;
}

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

int main (){
  int A,B,C,X;
  cin >> A >> B >> C >>X;
  //int n = x/50;
  //Ritik COdE
  int cnt =0;
  for(int i =0;i<=A;i++){
   for(int j=0;j<=B;j++){
     for(int k=0;k<=C;k++){
       if(500*i+100*j+50*k ==X)cnt++;
     }
   }
  }
  
  cout <<cnt<<endl;
  
}

Measured memory_bytes: 256
// #pragma GCC optimize "trapv" Uncomment when dealing with huge numbers
/*<----------PBDS---------->

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
template <typename T>
using order_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

order_set<datatype>oset;
Kth smallest : *oset.find_by_order(k-1); // 0 based index
No of elements less than k : oset.order_of_key(k);
Erase X : oset.erase(x)
<----------PBDS---------->*/
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int a[1000001];
int32_t main()
{
  fast;
	int n;
	int ans;
	cin >> n;
	int sum = 0;
	for(int i = 1 ; i<=n ; i++ ){
		for(int j = 1 ; j<=n ; j++){
			for(int k =1 ; k<=n ; k++ ){
				sum+=gcd(gcd(i,j),k);
			}
		}
	}
	cout << sum;
}





Measured memory_bytes: 3652
import java.util.*;

public class Main {
	static ArrayList<Path>[] graph;
	static int[][] mins;
	static int n;
	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		graph = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			graph[i] = new ArrayList<Path>();
		}
		mins = new int[n][n];
		int m = sc.nextInt();
		Path[] paths = new Path[m];
		for (int i = 0; i < m; i++) {
			int from = sc.nextInt() - 1;
			int to = sc.nextInt() - 1;
			int value = sc.nextInt();
			Path p = new Path(from, to, value);
			paths[i] = p;
			graph[from].add(p);
			graph[to].add(new Path(to, from, value));
		}
		for (int i = 0; i < n; i++) {
			mins[i][i] = 1;
			search(i, 0, mins[i]);
		}
		int count = 0;
		for (Path p : paths) {
			if (mins[p.from][p.to] < p.value) {
				count++;
			}
		}
		System.out.println(count);
	}
	
	static void search(int idx, int v, int[] arr) {
		if (arr[idx] != 0 && arr[idx] <= v) {
			return;
		}
		arr[idx] = v;
		for (Path p : graph[idx]) {
			search(p.to, v + p.value, arr);
		}
	}
	
	static class Path {
		int from;
		int to;
		int value;
		public Path(int from, int to, int value) {
			this.from = from;
			this.to = to;
			this.value = value;
		}
	}
}


Measured memory_bytes: 47556
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int k=scanner.nextInt();
		long ans=0;
		if(k%2==0) {
			int cnt=0;
			for(int i=1;i<=n;i++) {
				if(i%k==k/2)cnt++;
			}
			ans=(long)Math.pow(n/k, 3)+(long)Math.pow(cnt, 3);
		}else {
			ans=(long)Math.pow(n/k, 3);
		}
		System.out.println(ans);
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21332
using System;

namespace AtC157
{
    class Program
    {
        static void Main(string[] args)
        {
            string[][] A = new string[3][];
            for (int i = 0; i < 3; i++) A[i] = Console.ReadLine().Split(' ');
            bool[][] bingo = new bool[3][];
            for (int i = 0; i < 3; i++) bingo[i] = new bool[3];

            int N = int.Parse(Console.ReadLine());
            for(int i = 0; i < N; i++)
            {
                string str = Console.ReadLine();
                for(int n = 0; n < 3; n++)
                {
                    for(int m = 0; m < 3; m++)
                    {
                        if (A[n][m] == str) bingo[n][m] = true;
                    }
                }
            }
            bool Bingo = false;
            for(int i = 0; i < 3; i++)
            {
                if (bingo[i][0] && bingo[i][1] && bingo[i][2]) Bingo = true;
                if (bingo[0][i] && bingo[1][i] && bingo[2][i]) Bingo = true;
            }
            if (bingo[0][0] && bingo[1][1] && bingo[2][2]) Bingo = true;
            if (bingo[0][2] && bingo[1][1] && bingo[2][0]) Bingo = true;
            if (Bingo) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11348
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	K, N := ReadInt(), ReadInt()
	A := ReadInts(N)
	ans := K
	for i := 0; i < N; i++ {
		j := (i + N - 1) % N
		if A[j] > A[i] {
			ans = Min(ans, A[j]-A[i])
		} else {
			ans = Min(ans, K-A[i]+A[j])
		}
	}
	fmt.Println(ans)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 5112
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<iomanip>
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<string> vs;
Def inf = sizeof(Def) == sizeof(ll) ?2e18:1e9+10;
int main(){
  int n,m;
  vi sos(200000);
  sos[0]=sos[1]=1;
  for(int i=2;i*i<=200000;i++)if(sos[i]==0)
				for(int j=i*2;j<200000;j+=i)sos[j]=1;
  while(cin>>n>>m,n+1){
    vi a,b;
    loop(i,n+1,200000)if(sos[i]==0){
      a.pb(i);
      if(a.size()>m)break;
    }
    rep(i,a.size())rep(j,a.size())if(i<=j)b.pb(a[i]+a[j]);
    sort(all(b));
    cout<<b[m-1]<<endl;
  }
}



Measured memory_bytes: 3452
def searchnode(i,u,path):
    r = 1
    u[i] = 1
    for j in range(26):
        if path[i][j] and (not u[j]):
            r += searchnode(j,u,path)
    return r

while(True):
    n = int(input())
    if not n: break
    strs = list(map(lambda x: [x[0],x[-1]], [ input() for i in range(n)]))
    ss,ee = [0]*26,[0]*26
    path = [[0]*26 for _ in range(27)]
    u = [0]*26
    for s,e in strs:
        ss[ord(s)-ord('a')] += 1
        ee[ord(e)-ord('a')] += 1
        path[ord(s)-ord('a')][ord(e)-ord('a')] += 1
    if [1 for s1,e1 in zip(ss,ee) if s1-e1]:
        print("NG")
        continue
    print("OK" if len([1 for s in ss if s]) == searchnode(ord(s)-ord('a'),u,path) else "NG")
    



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int maxtime(int x) {
	// Maximum consuming time for x-minute order
	return (x + 9) / 10 * 10;
}
int remtime(int x) {
	// Remained time for x-minute order
	return maxtime(x) - x;
}

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

	int ans = maxtime(a) + maxtime(b) + maxtime(c) + maxtime(d) + maxtime(e);
	ans -= max({ remtime(a), remtime(b), remtime(c), remtime(d), remtime(e) });
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# dpD - Knapsack 1 (01 knapsack problem)
import sys
input = sys.stdin.readline

def knapsack(W: int, weight: "Array[int]", value: "Array[int]") -> int:
    # dp[i] := optimum value of Weight i
    dp = [0] * (W + 1)
    for w, v in zip(weight, value):
        for cur_w in range(W, w - 1, -1):
            dp[cur_w] = max(dp[cur_w], dp[cur_w - w] + v)
    return dp[-1]


def main():
    N, W = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N))
    weight, value = zip(*A)
    ans = knapsack(W, weight, value)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 39664
# H

h = gets.chomp.to_i

C = {}

def cul(x)
  if x == 1
    return 1
  end

  if n = C[x]
    return n
  end

  r = cul(x / 2)
  s = r + r + 1

  C[x] = s

  return s
end

puts(cul(h))


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

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

int main(){
    int n, m;
    cin >> n >> m;
    int s[m], c[m];
    rep(i, m) cin >> s[i] >> c[i];
    if (n == 1) {
        for(int i = 0; i < 10; i++){
            bool flag = true;
            for(int j = 0; j < m; j++){
                if (c[j] != i) {
                    flag = false;
                }
            }
            if (flag) {
                cout << i << endl;
                return 0;
            }   
        }
    }else if (n == 2) {
        for(int i = 10; i < 100; i++){
            bool flag = true;
            for(int j = 0; j < m; j++){
                if (s[j] == 2) {
                    int num = i % 10;
                    if (num != c[j]) {
                        flag = false;
                    }
                }else if (s[j] == 1) {
                    int num = i / 10;
                    if (num != c[j]) {
                        flag = false;
                    }
                }
            }
            if (flag) {
                cout << i << endl;
                return 0;
            }   
        }
        
    }else if (n == 3) {
        for(int i = 100; i < 1000; i++){
            bool flag = true;
            for(int j = 0; j < m; j++){
                if (s[j] == 3) {
                    int num = i % 10;
                    // cout << "1 " << num << endl;
                    if (num != c[j]) {
                        flag = false;
                    }
                }else if (s[j] == 2) {
                    int num = ((i % 100) - (i % 10)) / 10;
                    // cout << "2 " << num << endl;
                    if (num != c[j]) {
                        flag = false;
                    }
                }else if (s[j] == 1) {
                    int num = (i / 100);
                    // cout << "3 " << num << endl;
                    if (num != c[j]) {
                        flag = false;
                    }
                }
            }
            if (flag) {
                cout << i << endl;
                return 0;
            }   
        }
    }
    cout << -1 << endl;
    
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int x = s.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i =0;i<n;i++){
            list.add(s.nextInt());
        }
        int count = 0;
        int d =0;
        int i=0;
        while(d<=x){
            count++;
            if(i==n) break;
            d+=list.get(i);
            i++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 22612
n,m = map(int,input().split())
L = [0]*m
R = [0]*m

max_l = 1
min_r = n
for i in range(m):
    l,r = map(int,input().split())
    max_l = max(max_l,l)
    min_r = min(min_r,r)
if min_r>=max_l:
    print(min_r-max_l+1)
else:
    print(0)

Measured memory_bytes: 4596
import math
import queue

def readInt():
	return int(input())

def readInts():
	return list(map(int, input().split()))

def readChars():
	return input().split()


q = queue.Queue()

for i in range(1,10):
	q.put(i)

n = readInt()

for i in range(1,100001):
	a = str(q.get())
	b = int(a[-1])
	if b!=0:
		q.put(int(a+str(b-1)))
	q.put(int(a+str(b)))
	if b!=9:
		q.put(int(a+str(b+1)))	
	if i==n:
		print(int(a))
		break

Measured memory_bytes: 11512
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define MP make_pair
#define PB push_back
#define F first
#define S second

struct Node {
    Int parentIndex = -1; // -1 は根を表す
    Int componentSize = 1; // 各木の根の場合に連結成分サイズ情報を保持
};

int main() {
    Int n, m;
    cin >> n >> m;
    auto nodes = vector<Node>(n);

    auto edges = vector<pair<Int, Int>>();
    rep(i, m) {
        Int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges.PB(MP(a, b));
    }

    function<Int(const Int)> rootIndex = [&](const Int targetIndex) {
        auto &targetNode = nodes[targetIndex];
        auto parentIndex = targetNode.parentIndex;
        if (parentIndex == -1) {
            return targetIndex;
        } else {
            auto result = rootIndex(parentIndex);
            targetNode.parentIndex = result; // 根の直属の子として挿し直す
            return result;
        }
    };

    auto answers = vector<Int>(0);
    auto current = n * (n - 1) / 2; // 現状での不便さ
    answers.PB(current);

    // 後ろの辺からつないでゆく
    for (Int i = m - 1; i >= 1; i--) {
        auto &edge = edges[i];
        auto x = edge.F;
        auto y = edge.S;
        auto rx = rootIndex(x); // xの属する木の根
        auto ry = rootIndex(y); // yの属する木の根
        if (rx != ry) { // 根の異なる連結成分を連結するとき
            auto originalSizeX = nodes[rx].componentSize; // 連結前のxの属する連結成分の大きさ
            auto originalSizeY = nodes[ry].componentSize; // 連結前のyの属する連結成分の大きさ
            nodes[rx].parentIndex = ry; // xの属する木の根をyの属する木の根の子として接続
            nodes[ry].componentSize += originalSizeX; // yの属する木の根に書き込まれたサイズ情報を更新
            current -= originalSizeX * originalSizeY; // 不便さを減らす
        }
        answers.PB(current);
    }

    // 逆順出力
    for (auto itr = answers.rbegin(); itr != answers.rend(); itr++) {
        PUTS(*itr);
    }
}



Measured memory_bytes: 6256
#include<cstdio>
int cd(int *l,int x){
    int n=0;
    for(int i=1;i<=x;i++){
        if(x%i==0){
            l[n]=i;
            n++;
        }
    }
    return n;
}
int gcd(int x,int y){
    if(x<y)return gcd(y,x);
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(){
    int a,b,k,l[100];
    scanf("%d%d%d",&a,&b,&k);
    int g=gcd(a,b), n=cd(l,g);
    printf("%d\n",l[n-k]);
    return 0;
}

Measured memory_bytes: 128
import sys
a, b, c = map(int, sys.stdin.readline().split())
d, e, f = map(lambda t: abs(t[0] - t[1]), [(a, b), (b, c), (c, a)])
if d > e and d > f:
    print(e + f)
elif e > f:
    print(d + f)
else:
    print(d + e)


Measured memory_bytes: 3060
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

/*lld fac[100001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=100000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}*/


lld gcd(lld a,lld b)
{
    if(a>b) return gcd(b,a);
    if(b%a==0) return a;
    else return gcd(b%a,a);
}

lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;



void solve()
{
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(i=0;i<n;i++) cout<<s[i]<<t[i];
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    //cin>>t;
    //cout<<t;
   //  getfac(p2);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3580
#include<stdio.h>

int main(){
	int i,k[2]={0},ge,f=0;
	char s[101],keyence[]="keyence";
	scanf("%s",s);
	for(i=0;s[i]!=0;i++){
		if(i<7&&s[i]==keyence[i]){
			if(f==0)k[0]++;
		}else f++;
	}f=0;
	ge=i;
	for(i=0;i<ge;i++){
		if(i<7&&s[ge-i-1]==keyence[6-i]){
			if(f==0)k[1]++;
		}else f++;
	}f=0;
	if(k[0]+k[1]>=7)puts("YES");
	else puts("NO");
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> h(N);
    vector<int> cost(N, 1e9);

    for (int i = 0; i < N; i++)
    {
        cin >> h.at(i);
    }

    cost.at(0) = 0;
    cost.at(1) = abs(h.at(1) - h.at(0));

    for (int i = 2; i < N; i++)
    {
        int step1, step2;
        step1 = cost.at(i - 1) + abs(h.at(i) - h.at(i - 1));
        step2 = cost.at(i - 2) + abs(h.at(i) - h.at(i - 2));
        cost.at(i) = min(step1, step2);
        // cout << cost.at(i) << " ";
    }

    cout << cost.at(N - 1) << endl;
}


Measured memory_bytes: 1024
import bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
c = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    c += bisect.bisect_right(l,l[j]+l[i]-1) - bisect.bisect_left(l,l[j],j+1)
print(c)

Measured memory_bytes: 44508
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
for k in range(N):
  P[k] -= 1
scorelist = []
roop = []
now = 0
visited = [-1 for _ in range(N)]
for k in range(N):
  now = k
  if visited[now] == -1:
    roop.append([])
    scorelist.append([])
    start = 0 + now
    while visited[start] == -1:
      roop[-1].append(start)
      visited[start] = 1 
      start = P[start]
      scorelist[-1].append(C[start])
    scorelist[-1] = scorelist[-1] + scorelist[-1] + scorelist[-1]
    
#print(roop)
#print(scorelist)

ans = - float('inf')
for l in range(len(roop)):
  #print(scorelist[l][:len(roop[l])])
  Q = K // len(roop[l])
  R = K % len(roop[l])
  if Q > 0:
    Q -= 1
    R += len(roop[l]) 
  #print(Q, R)
  if sum(scorelist[l][:len(roop[l])]) > 0:
    basis = sum(scorelist[l][:len(roop[l])])*Q
  else:
    basis = 0
  #print(basis)
  advlist = -float('inf')
  for k in range(len(roop[l])):
    adv = 0
    for j in range(k, k + R):
      adv += scorelist[l][j]
      advlist  = max(advlist, adv) 
  ans = max(ans, basis + advlist)

print(ans)

Measured memory_bytes: 69848
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 C = sc.nextLong();
    long K = sc.nextLong();
    long ans = A-B;
		if(Math.abs(ans)>Math.pow(10, 18)) {
			System.out.println("Unfair");
			return;
		}
		if(K%2 == 0) {
			System.out.println(ans);
		}
		else {
			System.out.println(ans*-1);
		}
	}
}

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

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] cost=new int[N];
		for(int i=0; i<N; i++) {
			cost[i]=sc.nextInt();
		}
		Arrays.sort(cost);
		int price=0;
		for(int i=0; i<N; i++) {
			if(i==N-1) {
				price+=(cost[i]/2);
			}
			else {
				price+=cost[i];
			}
		}
		System.out.println(price);
	}
}


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

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 absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
int translate(char c){
  if(c == '1') return 1;
  if(c == '2') return 2;
  if(c == '3') return 3;
  if(c == '4') return 4;
  if(c == '5') return 5;
  if(c == '6') return 6;
  if(c == '7') return 7;
  if(c == '8') return 8;
  if(c == '9') return 9;
  
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  string s; cin >> s;
  
  int localmin = 1000;
  for(int i=0;i<s.size()-2;i++){
  	int number;
    number = translate(s.at(i)) * 100 + translate(s.at(i+1)) * 10 + translate(s.at(i+2));
    localmin = min(localmin,absolute(753,number));
  }
  cout << localmin << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  string str;
  cin>>str;
  int n = str.size();
  int sum = 0;
  for(int i = 0;i < n;i++)
  {
    sum = sum + str[i] - '0';
  }
  if(sum%9 == 0)
    	cout<<"Yes"<<"\n";
  else
    	cout<<"No"<<"\n";
}

Measured memory_bytes: 3744
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
char s[SIZE];
int dp[SIZE];
int main(){
    RS(s);
    int n=LEN(s);
    LL an=0;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='B'&&s[i+1]=='C'){
            dp[i]=dp[i+2]+1;
        }
        else if(s[i]=='A'){
            dp[i]=dp[i+1];
            an+=dp[i];
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 3072
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int a, b;
	string s;
	cin >> a >> b >> s;

	bool check = true;

	for(int i=0;i<a;i++) {
		if(s.at(i) == '-') check = false;
	}

	for(int i=a+1;i<a+b+1;i++) {
		if(s.at(i) == '-') check = false;
	}
	
	if(s.at(a) != '-') check = false;

	if(check) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
M=int(input())
t=list(map(int,input().split()))
import collections
ac=collections.Counter(a)
tc=collections.Counter(t)

for task in tc.items():
  if task[0] not in ac or ac[task[0]]<task[1]:
    print("NO")
    break
else:
  print("YES")

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

char s[100005];

int dist[30][100005];
int alphabet[30];

int main() {

	scanf("%s",s);

	int i,j;

	int len = strlen(s);

	for (i = 0; i < len; i++) {
		dist[s[i] - 'a'][alphabet[s[i] - 'a']] = i + 1;
		alphabet[s[i] - 'a']++;
	}

	int a = -1;
	int b = -1;

	for (i = 0; i < 26; i++) {
		for (j = 0; j < len; j++) {
			if (dist[i][j] == 0 || dist[i][j + 1] == 0) { break; }
			if (dist[i][j + 1] - dist[i][j] <= 2) {
				a = dist[i][j];
				b = dist[i][j + 1];
			}
		}
		if (a != -1 && b != -1) {
			break;
		}
	}
	printf("%d %d\n",a,b);

	return 0;
}

Measured memory_bytes: 768