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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    if (s=="ABC"){
        cout<<"ARC\n";
    }else{
        cout<<"ABC\n";
    }
    return 0;
}


Measured memory_bytes: 3640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI_()
    r = 0
    for i in range(n-1):
        if a[i] == i:
            r += 1
            a[i+1] = i
    if a[-1] == n-1:
        r += 1
    return r


print(main())



Measured memory_bytes: 16280
d = 1000000007

def pow_rem(x, n):
    if n == 0:
        return x ** n % d
    if n % 2 == 0:
        return pow_rem(x, n // 2) ** 2 % d
    else:
        return ((pow_rem(x , n // 2) ** 2) * x) % d

def solve():
    m, n = map(int, input().split())
    print(pow_rem(m, n))

solve()

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

int main (){
  ll s,w;
  cin>>s>>w;
  if (w>=s){
    cout << "unsafe" << endl;
  }
  else{
    cout << "safe" << endl;
  }
}

Measured memory_bytes: 3636
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    int n,x,t,s;
    cin>>n>>x>>t;
    s=(n/x)*t;
    if(n%x==0)
        cout<<s<<endl;
    else
        cout<<s+t<<endl;

}


Measured memory_bytes: 3632
using namespace std;

#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

#define int long long
#define double long double
typedef pair<int, int> ii;
typedef vector<int> vi;

int n;
int t[102];
int v[102];
int dp[252][50003];
int tab[50003];
int sum;
//double x[102];
//double speed[102];
int INF = 1000000000;

int compute(int time, int speed) {
    if (speed < 0) return -INF;
    if (time == sum) {
        if (speed == 0) return 0;
        else return -INF;
    }
    if (dp[speed][time] != -1) return dp[speed][time];
    int index = tab[time];
    if (speed > v[index]) return -INF;
    
    int ans = -INF;
    if (speed < v[index]) ans = max(ans, compute(time + 1, speed + 1));
    ans = max(ans, compute(time + 1, speed));
    if (speed > 0) ans = max(ans, compute(time + 1, speed - 1));
    ans += speed;
    //printf("%lld %lld %lld: %lld\n", index, speed, time, ans);
    return dp[speed][time] = ans;
}
/*
double maxSpeed(double speed, int index) {
    double ans = (double) min(speed + t[index], (double) v[index]);
    int cnt = 0;
    for (int i = index + 1; i < n; i++) {
        cnt += t[i - 1];
        x[index] = min(x[index], cnt - ans + v[i]);
    }
    cnt = 0;
    for (int i = index + 1; i < n; i++) {
        cnt += t[i - 1];
        double tmp = (cnt + speed + v[i]) / 2.;
        if (tmp < ans) {
            ans = tmp;
            x[index] = tmp - speed;
        }
    }
    return ans;
} */

signed main() {
    //freopen("out.txt", "w", stdout);
    scanf("%I64d", &n);
    sum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%I64d", &t[i]);
        t[i] *= 2;
        //x[i] = (double) INF;
        for (int j = sum; j < sum + t[i]; j++) {
            tab[j] = i;
        }
        sum += t[i];
    }
    for (int i = 0; i < n; i++) {
        scanf("%I64d", &v[i]);
        v[i] *= 2;
    }
    
    for (int i = 0; i <= 251; i++) {
        for (int j = 0; j <= 50001; j++) {
            dp[i][j] = -1;
        }
    }
    /*
    t[n] = 0; v[n] = 0;
    n++; */
    
    /*
    for (int i = 0; i < n; i++) {
        speed[i] = maxSpeed((i == 0) ? 0: min(speed[i - 1], (double) v[i]), i);
    }
    
    double ans = 0; */
    
    /*for (int i = 0; i < n; i++) {
        cout << speed[i] << " " << x[i] << "\n";
    } */
    
    /*
    double curSpeed = 0;
    for (int i = 0; i < n - 1; i++) {
        double diff = speed[i] - curSpeed;
        if (diff > 0) ans += diff * diff / 2. + curSpeed * diff; // first triangle
        curSpeed = speed[i];
        //cout << ans << "\n";
        if (min(x[i], (double) t[i]) > diff) {
            ans += (min(x[i], (double) t[i]) - diff) * speed[i]; // second triangle
        }
        //cout << ans << "\n";
        if (x[i] < t[i]) {
            ans += (t[i] - x[i]) * (t[i] - x[i]) / 2. + (t[i] - x[i]) * (speed[i] - (t[i] - x[i]));
            curSpeed = curSpeed - (t[i] - x[i]);
        }
        //cout << ans << "\n";
    } */
    
    printf("%.20lf\n", compute(0, 0) / 4.);
}


Measured memory_bytes: 100864
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node {
    int id;
    Node *parent, *left, *right;
};

int n;
Node nodes[25];

inline int getheight(int id) {
    int lh = 0, rh = 0;
    if (nodes[id].left) {
        lh = 1 + getheight(nodes[id].left->id);
    }
    if (nodes[id].right) {
        rh = 1 + getheight(nodes[id].right->id);
    }
    return lh > rh ? lh : rh;
}

int main(void) {

    scanf("%d", &n);

    for (int i = 0, id, left, right; i < n; ++i) {
        scanf("%d %d %d", &id, &left, &right);
        nodes[id].id = id;
        if (left != -1) {
            nodes[id].left = &nodes[left];
            nodes[left].parent = &nodes[id];
        }
        if (right != -1) {
            nodes[id].right = &nodes[right];
            nodes[right].parent = &nodes[id];
        }
    }

    for (int i = 0; i < n; ++i) {

        int parent = (nodes[i].parent ? nodes[i].parent->id : -1);

        int sibling = -1;
        if (parent != -1) {
            Node *pnode = &nodes[parent];
            if (pnode->left && pnode->left != &nodes[i]) {
                sibling = pnode->left->id;
            }
            else if (pnode->right && pnode->right != &nodes[i]) {
                sibling = pnode->right->id;
            }
        }

        int degree = 0;
        if (nodes[i].left) {
            ++degree;
        }
        if (nodes[i].right) {
            ++degree;
        }

        int depth = 0;
        Node *node = nodes[i].parent;
        while (node) {
            ++depth;
            node = node->parent;
        }

        int height = getheight(i);

        const char *type = "internal node";
        if (nodes[i].parent == NULL) {
            type = "root";
        }
        else if (!nodes[i].left && !nodes[i].right) {
            type = "leaf";
        }

        printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", nodes[i].id, parent, sibling, degree, depth, height, type);
    }

    return 0;
}

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

void solve(){
    int n; cin >> n;
    int h[n+1];
    for(int i = 0; i < n; i++){
        cin >> h[i+1];
    }

    int dp[n+1];
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);

    for(int i = 3; i <= n; i++){
        dp[i] = min(dp[i-1]+abs(h[i-1]- h[i]), dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout << dp[n] << endl;
}

int main(){
    solve();
}

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

using namespace std;

const int MOD = 1e9 + 7;

int lgp(int a, int b) {
    int res = 1;
    while(b) {
        if(b & 1) {
            res = 1LL * res * a % MOD;
        }
        a = 1LL * a * a % MOD;
        b >>= 1;
    }
    return res;
}
int main() {
   // ifstream cin("data.in");
    int n, start;
    cin >> n >> start;
    vector<int>val(n);
    for(int i = 0; i < n; i++)
        cin >> val[i];

    sort(val.begin(), val.end(), greater<int>());
    vector<int>prob(start + 1), nprob(start + 1);

    prob[start] = 1;
    for(int i = 0; i < n; ++i) {
        nprob = vector<int>(start + 1);
        int y = val[i];
        int take = lgp(n - i, MOD - 2);
        int not_take = (1 - take+MOD) % MOD;
        for(int x = 0; x <= start; x++) {
            nprob[x] = (nprob[x] + 1LL * not_take * prob[x]) % MOD;
            nprob[x % y] = (nprob[x % y] + 1LL * take * prob[x]) % MOD;
        }
        prob = nprob;
    }

    int res = 0;

    for(int i=0; i<=start; ++i)
        if(prob[i])
            res = (res + 1LL * prob[i] * i) % MOD;
    for(int i=1; i<=n; ++i)
        res=(1LL*res*i)%MOD;
    cout << res;


}


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


int main(void){
int k;scanf("%d",&k);
int cha[35]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
printf("%d\n",cha[k-1]);

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
double a,b,c,d;
int main(){
    cin>>a>>b>>c>>d;
    a/2==c&&b/2==d ? printf("%.6lf 1\n",(a*b)/2) : printf("%.6lf 0\n",(a*b)/2);
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

def is_lower_case(c):
  lower_case_alphabets = 'abcdefghijklmnopqrstuvwxyz'
  return c in lower_case_alphabets

S = input()
cnt = Counter(S[2:-1])

flag = True
if S[0] != 'A':
  flag = False
if cnt['C'] != 1:
  flag = False
for c in S[1:]:
  if c != 'C' and not is_lower_case(c):
    flag = False
print('AC' if flag else 'WA')


Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
using namespace std;
#define brk system("pause");

const int mod = 1e9 + 7;
const int N = 101, K = 1e5 + 1;
int dp[N][K], a[N], n, k, pr[K];

int add(int a, int b) {
	return (a + b) % mod;
}

int subt(int a, int b) {
	return (a - b + mod) % mod;
}

main()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	
	for(int i = 0; i <= n; i++)
		dp[i][0] = 1;
	
	for(int i = 1; i <= n; i++)
	{
		pr[0] = dp[i - 1][0];
		for(int j = 1; j <= k; j++)
			pr[j] = add(pr[j - 1], dp[i - 1][j]);
		for(int j = 1; j <= k; j++)
		{
			dp[i][j] = pr[j];
			if(j - a[i] - 1 >= 0)
				dp[i][j] = subt(dp[i][j], pr[j - a[i] - 1]);
		}
	}
	
	printf("%d\n", dp[n][k]);
}


Measured memory_bytes: 39680
#include<stdio.h>
#include<stdlib.h>
/*
int comp(const void* a, const void* b){
    return *(int*)b - *(int*)a;
}
*/
int gcd(int x, int y){
    if(y == 0) return x;
    return gcd(y, x%y);
}

int main(void){
    int N;
    scanf("%d", &N);
    int A[N];
    int i;
    for(i = 0; i < N; i++){scanf("%d", &A[i]);}
    //qsort(A, N, sizeof(A[0]), comp);
    int tmp;
    int l[N]; l[0] = 0;
    int r[N]; r[N-1] = 0;
    for(tmp = 0; tmp < N-1; tmp++){
        l[tmp+1] = gcd(l[tmp], A[tmp]);
    }
    for(tmp = N-1; tmp > 0; tmp--){
        r[tmp-1] = gcd(r[tmp], A[tmp]);
    }
    int max = -1;
    for(i = 0; i < N; i++){
        if(max < gcd(r[i], l[i])){max = gcd(r[i], l[i]);}
    }
    printf("%d\n", max);
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  if (A != 2 && B != 2) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
  return 0;
}


Measured memory_bytes: 256
import numpy as np

n, k = map(int, input().split())
h = np.array(input().split(), dtype=np.int)
cost = np.zeros(n, dtype=np.int)
for i in range(1, n):
  cur_h = h[i]
  start = max(0, i - k)
  cost[i] = np.min(cost[start : i] + np.abs(h[start : i] - cur_h))
print(cost[-1])

Measured memory_bytes: 21948
#include<cstdio>
#include<algorithm>

using namespace std;

int N, Y;

int main() {
    scanf("%d%d", &N, &Y);
    Y /= 1000;
    int a = Y - N;
    int am = a % 4;
    int b = 5 * N - Y;
    int x = (max((-b + 4) / 5, 0) + 3 - am) / 4 * 4 + am;

    if (am == (4 - b % 4) % 4 and x <= a / 9) printf("%d %d %d\n", x, (a-9*x)/4, (b+5*x)/4);
    else printf("-1 -1 -1\n");
}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
vi child[100100];
vi hoge;
int n,k;
int ans;
int depth[100100];
int dfs(int now,int par){
	int dep=0;
	for(int i=0;i<child[now].size();i++){
		dep=max(dep,dfs(child[now][i],now));
	}
	
	if(par==0){
		if(dep+1==k){
			return 0;
		}else return dep+1;
	}else{
		if(dep+1==k){
			ans++;
			return 0;
		}else return dep+1;
	}
}
int main(){
	cin>>n>>k;
	int x;
	ans=0;
	for(int i=0;i<n;i++){
		cin>>x;x--;
		hoge.pb(x);
		if(i!=0)child[x].pb(i);
	}
	if(hoge[0]!=0)ans++;
	dfs(0,0);
	//rep(i,n)cout<<depth[i]<<endl;
	cout<<ans<<endl;
}

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

int main()
{
	int n;
	string intro,str;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> intro >> str;
		for (int j = intro.length() - 1; j >= 0; j--) {
			switch (intro[j])
			{
			case 'A': {
				string res;
				res.reserve(str.length());
				for (int k = str.length() - 1; k >= 0; k--) {
					res.push_back(str[k]);
				}
				str = res;
			}
				break;
			case 'C': {
				string res;
				res.reserve(str.length());
				for (int k = 0; k < str.length(); k++) {
					res.push_back(str[(k + 1) % str.length()]);
				}
				str = res;
			}
					  break;
			case 'E': {
				string res;
				res.reserve(str.length());
				for (int k = 0; k < str.length(); k++) {
					if (k < str.length() / 2) {
						res.push_back(str[k + str.length() - str.length() / 2]);
					}
					else if (k >= str.length() - str.length() / 2) {
						res.push_back(str[k - (str.length() - str.length() / 2)]);
					}
					else {
						res.push_back(str[k]);
					}
				}
				str = res;
			}
					  break;
			case 'J': {
				string res;
				res.reserve(str.length());
				for (int k = 0; k < str.length(); k++) {
					res.push_back(str[(k + str.length() - 1) % str.length()]);
				}
				str = res;
			}
				break;
			case 'M': {
				for (int k = 0;k < str.length(); k++) {
					if (str[k] <= '9' && str[k] >= '0') {
						str[k] = '0' + (str[k] - '0' + 1) % 10;
					}
				}
			}
				break;
			case 'P': {
				for (int k = 0; k < str.length(); k++) {
					if (str[k] <= '9' && str[k] >= '0') {
						str[k] = '0' + (str[k] - '0' + 9) % 10;
					}
				}
			}
				break;
			}
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MAX (2000000)
#define INF (1145141919)
using namespace std;

int dp[MAX + 1];

int main()
{
	dp[0] = 0;
	for (int i = 1; i <= MAX; i++){
		dp[i] = INF;
	}
	
	for (int i = 1000000; i >= 0; i--){
		if (dp[i] < INF){
			for (int x = 0; x <= 1000000; x++){
				dp[i + x] = min(dp[i + x], dp[i] + x);
			}
		}
	}
	
	for (int i = 1000000; i >= 0; i--){
		if (dp[i] < INF){
			for (int y = 0; y <= 1000; y++){
				dp[i + y * y] = min(dp[i + y * y], dp[i] + y);
			}
		}
	}
	
	for (int i = 1000000; i >= 0; i--){
		if (dp[i] < INF){
			for (int z = 0; z <= 100; z++){
				dp[i + z * z * z] = min(dp[i + z * z * z], dp[i] + z);
			}
		}
	}
	
	int e;
	while (scanf("%d", &e), e){
		printf("%d\n", dp[e]);
	}
	
	return 0;
}

Measured memory_bytes: 8840
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

#include <climits>

using namespace std;


int main(){
	int w, h, n;

	cin >> w >> h >> n;

	vector<int> xx(n);
	vector<int> yy(n);
	vector<int> aa(n);

	for (int i = 0; i < n; i++)cin >> xx[i] >> yy[i] >> aa[i];

	vector<vector<int> > xxxx(2, vector<int>(n+1));
	vector<vector<int> > yyyy(2, vector<int>(n+1));

	xxxx[0][0] = 0;
	xxxx[1][0] = w;
	yyyy[0][0] = 0;
	yyyy[1][0] = h;

	for (int i = 0; i < n; i++) {
		if (aa[i] == 1) {
			if (xxxx[0][i] < xx[i]) {
				xxxx[0][i + 1] = xx[i];
			}
			else {
				xxxx[0][i + 1] = xxxx[0][i];
			}

			xxxx[1][i + 1] = xxxx[1][i];
			yyyy[0][i + 1] = yyyy[0][i];
			yyyy[1][i + 1] = yyyy[1][i];
		}
		else if (aa[i] == 2) {

			if (xxxx[1][i] > xx[i]) {
				xxxx[1][i + 1] = xx[i];
			}
			else {
				xxxx[1][i + 1] = xxxx[1][i];
			}

			xxxx[0][i + 1] = xxxx[0][i];
			yyyy[0][i + 1] = yyyy[0][i];
			yyyy[1][i + 1] = yyyy[1][i];
		}
		else if (aa[i] == 3) {
			xxxx[0][i + 1] = xxxx[0][i];
			xxxx[1][i + 1] = xxxx[1][i];
			if (yyyy[0][i]<yy[i]) {
				yyyy[0][i + 1] = yy[i];
			}
			else {
				yyyy[0][i + 1] = yyyy[0][i];
			}

			yyyy[1][i + 1] = yyyy[1][i];
		}
		else {
			xxxx[0][i + 1] = xxxx[0][i];
			xxxx[1][i + 1] = xxxx[1][i];
			
			if (yyyy[1][i] > yy[i]) {
				yyyy[1][i + 1] = yy[i];
			}
			else {
				yyyy[1][i + 1] = yyyy[1][i];
			}

			yyyy[0][i + 1] = yyyy[0][i];
		}
			
	}

	if ((xxxx[1][n] - xxxx[0][n])>0 && (yyyy[1][n] - yyyy[0][n]) > 0)
		cout << (xxxx[1][n] - xxxx[0][n]) * (yyyy[1][n] - yyyy[0][n]) << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int m = max(max(a,b),c);
  if ((3*m)%2 != (a+b+c)%2) m++;

  COUT( (3*m - (a+b+c)) / 2);

  /*
  int a[3]; REP(i,3) cin >> a[i];
  int ans = 0;
  auto sorta = [&](){ sort(a, a+3); };
  auto same = [&](){ return a[0] == a[1] && a[0] == a[2]; };
  sorta();
  while(1) {
    if (same()) break;
    int add = (a[2] - a[0]) / 2;
    if (add > 0) {
      a[0] += add*2;
      ans+=add;
    } else {
      a[2]--;
      ans++;
    }
    sorta();
  }
  COUT(ans);
  */
  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    int A, B, X; cin >> A >> B >> X;

    if(A > X || A + B < X) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
string S; int N, cnt;
 
int main() {
	int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << A[K-1] << endl;
}

Measured memory_bytes: 3572
st=input()
n=int(input())
for i in range(n):
  moji=list(map(str,input().split()))

  a=int(moji[1])
  b=int(moji[2])
  if moji[0]=="print":
    print(st[a:b+1])
  if moji[0]=="reverse":
    st=st[:a] + st[a:b+1][::-1] + st[b+1:]
  if moji[0]=="replace":
    st=st[:a]+moji[3]+st[b+1:]


Measured memory_bytes: 5616
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair


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

using namespace std;

bool graph[8][8];
int n, m;

int dfs(int x, bool visited[], int num_visited){
  if(num_visited == n){
    return 1;
  }

  int res = 0;
  REP(i, n){
    if(graph[x][i] == true && visited[i] == false){     
      bool next_visited[8];
      memcpy(next_visited, visited, sizeof(bool) * 8);
      next_visited[i] = true;
      res += dfs(i, next_visited, num_visited + 1);
    }
  }
  return res;
}

int main(){

  scanf("%d %d", &n, &m);
  REP(i,m){
    int t1, t2;
    scanf("%d %d", &t1, &t2);
    graph[t1 - 1][t2 - 1] = graph[t2 - 1][t1 - 1] = true;
  }

  bool visited[8] = {};
  visited[0] = true;
  printf("%d\n", dfs(0, visited, 1));

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int       long long
#define nn        100005

struct act{
    int a,b,c;
};
act obj[nn];
int n;

int solve(){
    int dp[n+1][3] = {0};
    dp[1][0] = obj[1].a;
    dp[1][1] = obj[1].b;
    dp[1][2] = obj[1].c;

    for(int i=2;i<=n;i++){
        dp[i][0] = obj[i].a + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = obj[i].b + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = obj[i].c + max(dp[i-1][0],dp[i-1][1]);
    }

    return max(dp[n][0], max(dp[n][1], dp[n][2]));
}

int32_t main() {
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>obj[i].a>>obj[i].b>>obj[i].c;
    }
    cout<<solve();
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<math.h>
int pn(int);

int main(){
  int r,n,i,cnt=0;
  scanf("%d",&r);
  for(i=0;i<r;i++){
    scanf("%d",&n);
    if(pn(n)==1){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  return 0;
}

int pn(int n){
  
  int a=3;
  
  if(n==2){
    return 1;
  }
  if(n<2 || n%2==0){
    return -1;
  }
  while(a <= sqrt(n)){
    if(n%a==0){
      return -1;
    }
    a+=2;
  }
  return 1;
}

Measured memory_bytes: 596
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static int[] mincost = new int[10];
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        for (int i = 0;i < 10;++i){
            mincost[i] = Integer.MAX_VALUE;
        }
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int cost[][] = new int[10][10];
        int wall[][] = new int[w][h];
        for (int i = 0;i < 100;++i){
            cost[i / 10][i % 10] = scanner.nextInt();
        }
        for (int i = 0;i < h * w;++i){
            wall[i % w][i / w] = scanner.nextInt();
        }
        int costsnumarray[] = new int[10];
        for (int y = 0;y < h;++y){
            for (int x = 0;x < w;++x){
                if(wall[x][y] == -1){
                    continue;
                }
                ++costsnumarray[wall[x][y]];
            }
        }
        for (int i = 0;i < 10;++i){
            ArrayList<Integer> arrayList = new ArrayList<>();
            arrayList.add(i);
            search(cost, arrayList, 0);
        }
        int lastcost = 0;
        for (int i = 0;i < 10;++i){
            if(i == 1){
                continue;
            }
            lastcost += mincost[i] * costsnumarray[i];
        }
        System.out.println(lastcost);
    }

    public static void search(int costarray[][],ArrayList<Integer> root,int cost){
        for (int i = 0;i < 10;++i){
            boolean flag = false;
            for (int k:root){
                if(k == i){
                    flag = true;
                    break;
                }
            }
            if(flag){
                continue;
            }
            int last = root.get(root.size() - 1);
            if(i == 1){
                int start = root.get(0);
                int newcost = cost + costarray[last][i];
                if(newcost < mincost[start]){
                    mincost[start] = newcost;
                }
            }
            else{
                ArrayList<Integer> newarray = new ArrayList<>();
                for (int c = 0;c < root.size();++c){
                    newarray.add(root.get(c));
                }
                newarray.add(i);
                int newcost = cost + costarray[last][i];
                search(costarray, newarray, newcost);
            }
        }
    }


}

Measured memory_bytes: 225640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int a, b, h;
  cin >> a >> b >> h;
  cout << (a + b) * h / 2 << endl;

}


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

dp[0] = 0
for i in range(1,n+1):
  if H[i] > H[i-1]:
    dp[i] = dp[i-1] + (H[i] - H[i-1])
  else:
    dp[i] = dp[i-1]
print(dp[n])

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

long int mod = (long int)1e9+7;
int main(){
  
  string num;
  cin>>num;
  int i,j,k;
  int n  = num.length();
  
  int dp[n+1][13];
  for(i=0;i<=n;i++)
    for(j=0;j<13;j++)
      dp[i][j]=0;
  dp[0][0]=1;
  
  for(i=0;i<n;i++){
    for(j=0;j<10;j++){
     
      int next = num[i]-'0';
      if(num[i]=='?')
        next = j;
      
      for(k=0;k<13;k++){
        int rem = (10*k + next)%13; 
        dp[i+1][rem] += dp[i][k];
        dp[i+1][rem]%=mod;
      }
      
      if(num[i]!='?') break;
      
    }
    
  }
  
  cout<<dp[n][5];
  
  
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ul, ul> P;

const int INF = 1e9;
const int MOD =1e9+7;
const ll LINF = 1e18;

int main(){
    int A, B;

    cin >> A >> B;

    int counter = 0;
    rep(i, B - A + 1){
        int n = A + i;
        int a[5] = {0};
        rep(j, 5){
            a[j] = n % 10;
            n /= 10;
        }
        if(a[0] == a[4] && a[1] == a[3]) counter++;
    }
    cout << counter << endl;
}

Measured memory_bytes: 256
using System;

public class SmallOrLarge
{
    //?????????????????§?°????????????????
    static void Main(string[] args)
    {
        /*---??£?¨???¨---*/
        int W; //?????????????????¨??????????????¢????????????X??§?¨?
        int H; //?????????????????¨??????????????¢????????????Y??§?¨?
        int x; //??????X??§?¨?
        int y; //??????Y??§?¨?
        int r; //????????????
        string[] num_unit;
        bool flag = false;
        /*---??£?¨???¨---*/

        /*W???H???x???y???r ?????????????????????*/
        num_unit = Console.ReadLine().Split(' ');
        W = int.Parse(num_unit[0]);
        H = int.Parse(num_unit[1]);
        x = int.Parse(num_unit[2]);
        y = int.Parse(num_unit[3]);
        r = int.Parse(num_unit[4]);

        /*??????????????¢???????????????????????????????????????*/
        if(0 <= (x - r)){
            if (0 <= (y - r)){
                if (W >= (x + r)){
                    if (H >= (y + r))
                    {
                        flag = true;
                    }
                }
            }
        }

        /*???????????????*/
        if (flag == true) {
            Console.WriteLine("Yes");
        }
        else {
            Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 8956
#include <bits/stdc++.h>
using namespace std;
long long ans;
long long x;
long long cnt;
vector<long long> vec_num;
long long solve(vector<long long> arg1) {
    long long retnum;
    retnum = arg1.back() - arg1.front();
    return retnum;
}
int main(int argc, char* argv[]) {
    scanf("%d", &cnt);
    for(int i = 0; i < cnt; i++) {
        scanf("%d", &x);
        vec_num.push_back(x);
    }
    sort(vec_num.begin(), vec_num.end());
    ans = solve(vec_num);
    cout << ans << endl;
    return 0;
}

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) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int K;
    int[] A;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.K = sc.nextInt();
        A = new int[N];
        for (int i=0; i<N; i++) {
        	A[i] = sc.nextInt();
        	
        }
    }
    
    //解答処理
    private List<Boolean> solve() {
    	List<Boolean> judge = new ArrayList<Boolean>();
        
        for (int i=K; i<N; i++) {
        	if (A[i] > A[i-K]) {
        		judge.add(true);
        	} else {
        		judge.add(false);
        	}
        }
        
        return judge;
    }
    
    //出力
    public void show(List<Boolean>answer) {
    	for (int i=0; i<answer.size(); i++) {
    		if (answer.get(i)) {
    			System.out.println("Yes");
    		} else {
    			System.out.println("No");
    		}
    	}
        
    }

}


Measured memory_bytes: 60380
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };


#define fs  first
#define sc  second


ll M = 1e9 + 7;

int main() {
	ll n, m;
	cin >> n >> m;
	if (abs(n - m) > 1) {
		puts("0");
		return 0;
	}

	ll ret = 1;
	if (n == m) ret = 2;

	rep(i, n) {
		ret = (ret*(i + 1)) % M;
	}
	rep(i, m) {
		ret = (ret*(i + 1)) % M;
	}

	cout << ret << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <queue>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;


int main() {
  int N;
  ll x[101], y[101], h[101];

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

  for (int cx = 0; cx < 101; ++cx) {
    for (int cy = 0; cy < 101; ++cy) {
      ll l = 1LL, r = ll(1e18) + 1, H;

      while (r - l > 1LL) {
        H = (l + r) / 2;
        bool flag = true;

        for (int i = 0; i < N; ++i) {
          ll tmp_h = std::max(H - llabs(x[i] - cx) - llabs(y[i] - cy), 0LL);

          if (tmp_h > h[i]) {
            r = H;
            flag = false;
            break;
          }
          else if (tmp_h < h[i]) {
            l = H;
            flag = false;
            break;
          }
        }

        if (flag) {
          cout << cx << " " << cy << " " << H << endl;
          return 0;
        }
      }

      for (ll H_ = l; H_ <= r; ++H_) {
        bool flag = true;
        for (int i = 0; i < N; ++i) {
          ll tmp_h = std::max(H_ - llabs(x[i] - cx) - llabs(y[i] - cy), 0LL);
          if (tmp_h != h[i]) {
            flag = false;
            break;
          }
        }

        if (flag) {
          cout << cx << " " << cy << " " << H_ << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef                 long long ll;
typedef                 unsigned long long ull;
#define mkp             make_pair
#define pii             pair<int,int>
#define piii            pair<pii,int>
#define vi              vector<int>
#define PI              acos(-1)
#define all(v)          v.begin(),v.end()
#define mmset(a,val)    memset(a,val,sizeof(a))
#define sc(a)           scanf("%d",&a)
#define sc2(a,b)        scanf("%d%d",&a,&b)
#define sc3(a,b,c)      scanf("%d%d%d",&a,&b,&c)
#define sc4(a,b,c,d)    scanf("%d%d%d%d",&a,&b,&c,&d)
#define sc5(a,b,c,d,e)  scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define scll(a)         scanf("%I64d",&a)
#define scll2(a,b)      scanf("%lld%lld",&a,&b)
#define scll3(a,b,c)    scanf("%lld%lld%lld",&a,&b,&c)
#define scll4(a,b,c,d)  scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d)
#define Pr(a)           printf("%d\n",a)
#define Prll(a)         printf("%lld\n",a)
#define pb(a)           push_back(a)
#define SZ              size()
#define tcs(t)          for(int tc=1;tc<=t;tc++)
#define INF             0x3f3f3f3f
#define hash_val        347
#define popcount        __builtin_popcount
#define MOD             1000000007
#define MX              10005
//int fx[]={-1,-1,0,1,1,1,0,-1};
//int fy[]={0,1,1, 1,0,-1,-1,-1};
int Set(int n,int pos){return n=n|(1<<pos);}
int reset(int n,int pos){return n=n& ~ (1<<pos);}
bool check(int n,int pos){return (bool) (n& (1<<pos));}
ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);};
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);};

int main()
{
            #ifdef AINAN
                       freopen("input.txt","r",stdin);
              //  freopen("output.txt","w",stdout);
              #endif
               int x,a,b,c;
               sc4(a,b,c,x);
               int cnt=0;
               bool f1=0,f2=0,f3=0;
               for(int i=0;i<=a;i++)
               {
                   int sum=(500*i);
                   if(sum==x && i>0)cnt++;
                   for(int j=0;j<=b;j++)
                   {
                      int sum2= sum+(100*j);
                      if(sum2==x && j>0)cnt++;
                       for(int k=0;k<=c;k++)
                       {
                           int sum3=sum2+(50*k);
                          // cout<<sum<<" "<<sum2<<" "<<sum3<<endl;


                            if(sum3==x && k>0)cnt++;

                       }
                   }


               }
            Pr(cnt);
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    
    if (a + b > c + d) {
      System.out.println("Left");
    } else if (a + b < c + d) {
      System.out.println("Right");
    } else if (a + b == c + d) {
      System.out.println("Balanced");
    }
    
  }
}


Measured memory_bytes: 23124
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> A(N), B(N), AS(N), BS(N);
    
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    reverse(all(B));
    AS[0] = A[0], BS[0] = B[0];
    rep(i, N - 1){
        AS[i + 1] = AS[i] + A[i + 1];
        BS[i + 1] = BS[i] + B[i + 1];
    }
    reverse(all(BS));
    
    int ma = 0;
    rep(i, N){
        ma = max(AS[i] + BS[i], ma);
    }
    output(ma);
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(int(1e9))

N,M,Q = list(map(int, input().split()))

cnt = [[0] * 501 for i in range (501)]
for i in range(M):
    L, R = list(map(int,input().split()))
    cnt[L][R] = cnt[L][R] + 1

H, W = (501, 501)
for i in range(H):
    for j in range(1, W):
        cnt[i][j] = cnt[i][j] + cnt[i][j-1]

for j in range(W):
    for i in range(1, H):
        cnt[i][j] = cnt[i][j] + cnt[i-1][j]

def Sum(l, r):
    return cnt[r][r] - cnt[l][r] - cnt[r][l] + cnt[l][l]

for i in range(Q):
    l, r = list(map(int, input().split()))
    ans = Sum(l-1, r)
    print(ans)
    


Measured memory_bytes: 15284
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n; cin>>n;
    int m=0;
    int ans=0;
    for(int i=0; i<n; i++){
        int p; cin>>p;
        m = max(p,m);
        ans += p;
    }
    cout << ans-m/2 << endl;
}
  
  
  

Measured memory_bytes: 256
// 解き直し.
// ABC 132解説.
// https://img.atcoder.jp/abc132/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
const int MAX_V = 1e5;
int memo[321123];
vector<int> graph[321123];

// 幅優先探索.
// https://ja.wikipedia.org/wiki/幅優先探索
// グラフを幅優先探索する.
// ※bfsの動作確認用.
// @param s: 探索開始の頂点番号.
// @param g: 探索終了の頂点番号.
// @return: 特に無し.
void bfs(int s, int g){

    // 1. 空のキュー.
    queue<int> q;

    // 2. 訪問済みフラグ設定.
    // ※スタート地点は, 距離ゼロを指定.
    memo[s] = 0;

    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    
    // 4. キュー q が 空になるまで, 探索.
    while(!q.empty()) {
        
        // 5. 頂点 u を キュー q から取り出す.
        int u = q.front();
        q.pop();
        
        // 6. 頂点 u が ゴールだったら終了.
        if(u == g) break;
        
        // 7. 取り出した要素を処理.
        for(auto &e : graph[u]){
            // 7-1. 頂点u の 隣接する頂点e が, 未訪問だったら, キュー q に追加.
            if(memo[e] == 0 && e != s){
                // 頂点e を キュー q に追加.
                q.push(e);
                // 頂点e に 距離memo[a] プラス 1 を 加算.
                memo[e] += memo[u];
                memo[e]++;
            }
        }
    }
}

int main() {

    // 1. 入力情報取得.
    int N, M;
    scanf("%d %d", &N, &M);

    // 2. グラフ作成.
    // 解説通り, グラフを3倍化？してみる.
    // 3辺 u0 -> v1, u1 -> v2, u2 -> v0 を 張る.
    // 具体的には, 
    // u0 = u + i * 3, u1 = u + 1, u2 = u + MAX_V * 2
    // v0 = v, v1 = v + MAX_V, v2 = v + MAX_V * 2
    for(int i = 0; i < M * 3; i += 3){
        int u, v;
        scanf("%d %d", &u, &v);
        u--, v--;
        // u0 -> v1
        graph[u].push_back(v + MAX_V * 1);
        // u1 -> v2
        graph[u + MAX_V * 1].push_back(v + MAX_V * 2);
        // u2 -> v0
        graph[u + MAX_V * 2].push_back(v);
    }
    
    // 3. スタート地点, ゴール地点.
    int S, T;
    scanf("%d %d", &S, &T);
    S--, T--;
    
    // 4. S0 -> T0 の 最短距離 を 計算.
    bfs(S, T);
    // for(int i = 0; i < N * 3; i++) cout << memo[i] << " ";
    // cout << endl;
    
    // 5. 後処理.
    int ans = memo[T] / 3;
    if(ans == 0) printf("%d\n", -1);
    else         printf("%d\n", ans);
    return 0;

}

Measured memory_bytes: 18304
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str;

        //String[] num = str.split(" ",0);
        int i = 1;
        while(true){
            str = scan.nextLine();
            if(Integer.valueOf(str) == 0){
                break;
            }
            System.out.println("Case " + i++ +": " + str);
        }


        scan.close();
    }

}



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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int n, q; string s;
void solve(int k){
    vector<lint> d(n+1), m(n+1), dm(n+1);
    lint res = 0;
    rep(i, n){
        d[i+1] = d[i];
        m[i+1] = m[i];
        dm[i+1] = dm[i];

        if(i>=k){
            if(s[i-k]=='D'){
                d[i+1]--; dm[i+1] -= m[i+1];
            }
            else if(s[i-k]=='M') m[i+1]--;
        }

        if(s[i]=='D') d[i+1]++;
        else if(s[i]=='M'){
            m[i+1]++; dm[i+1] += d[i+1];
        }
        else if(s[i]=='C') res += dm[i+1];
    }
    out(res);
}

int main(){
    cin>>n>>s>>q;
    rep(i,q){
        int k; cin>>k; solve(k);
    }
}

Measured memory_bytes: 24836
import math

def cmb(N,X,mod):
	P=1
	Q=1
	for i in range (X):
		P=P*(N-i)%mod
		Q=Q*(i+1)%mod
	return (P*pow(Q,mod-2,mod))%mod

N,A,B=map(int,input().split())
mod=pow(10,9)+7

ans=0
ans=(pow(2,N,mod)-1)

tmp_A=cmb(N,A,mod)
tmp_B=cmb(N,B,mod)
#print(ans,tmp_A,tmp_B)
ans=ans-tmp_A-tmp_B
print(ans%mod)

Measured memory_bytes: 3064
N=int(input())
XY=[[] for _ in range(N)]
for i in range(N):
  A=int(input())
  for _ in range(A):
    x,y = map(int, input().split())
    x-=1
    XY[i].append([x,y])

ans=0
for bit_state in range(2**N):
  flag=True
  for i in range(N):
    if (bit_state>>i)&1:
      for x, y in XY[i]:
        if (bit_state >>x)&1 != y:
          flag=False
  if flag:
    ans=max(ans, bin(bit_state).count("1"))
    
print(ans) 

Measured memory_bytes: 68604
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
typedef vector<i64> vi;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 n,k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(rng(a));
  vi cs(n+1,0);
  rep(i,n) cs[i+1] = cs[i]+a[i];

  if(k==1){
    cout << 0 << endl;
    return;
  }

  i64 ans = 0;
  i64 c = 1;
  rep(i,n-k+2){
    ans += ((cs[n]-cs[k-1+i]-cs[n-k+1-i])%MOD)*c;
    ans %= MOD;
    c *= k-2+1+i;
    c %= MOD;
    c *= pow_mod(i+1,MOD-2,MOD);
    c %= MOD;
  }
  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 1792
s = input()
t = input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]

for i in range(1, len(s) + 1):
    for j in range(1, len(t) + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

length = dp[len(s)][len(t)]
ans = [0] * length
i = len(s)
j = len(t)
while length > 0:
    if s[i - 1] == t[j - 1]:
        ans[length - 1] = s[i - 1]
        length -= 1
        i -= 1
        j -= 1
    elif dp[i][j] == dp[i - 1][j]:
        i -= 1
    else:
        j -= 1

print(''.join(ans))


Measured memory_bytes: 144320
A = int(input())
B = int(input())
C = int(input())
X = int(input())

result = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if (i * 500 + j * 100 + k * 50) == X:
                result += 1

print(result)

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

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	for(int i=0; i<=n; i++){
		for(int j=0; j<=m; j++){
			int t = i*m + j*n - 2*i*j;
			if(t==k){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
}

Measured memory_bytes: 256