akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, K;
	cin >> N >> K;
	
	vector<ll> A(N);
	REP(i, N) cin >> A[i];
	
	FOR(i, K - 1, N - 1) {
		if (A[i - K + 1] < A[i + 1]) {
			puts("Yes");
		}
		else puts("No");
	}
	return 0;
}


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

using namespace std;

int pw[105][105],C[105][105];
int dp[2][105][105];

int main()
{
	int n,m,k,d;
	scanf("%d%d%d%d",&n,&m,&k,&d);
	C[0][0] = 1;
	for(int i = 1;i <= 100; ++ i)
	{
		C[i][0] = 1;
		pw[i][0] = 1;
		for(int j = 1;j <= 100; ++ j)
			pw[i][j] = pw[i][j - 1] * 1ll * i % d,
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % d;
	}
	int cur = 1,nxt = 0;
	dp[0][0][0] = 1;
	for(int i = 1;i <= k; ++ i)
	{
		cur ^= 1; nxt ^= 1; memset(dp[nxt],0,sizeof(dp[nxt]));
		for(int j = 0;j <= n; ++ j)
			for(int l = 0;l <= m; ++ l)
			{
				int tm = pw[k - i + 1][l] * 1ll * pw[i][m - l] % d;
				for(int p = 0,x = dp[cur][j][l];j + p <= n; ++ p,x = x * 1ll * tm % d)
					dp[nxt][j + p][l] = (dp[nxt][j + p][l] + x * 1ll * C[n - j][p]) % d;
			}
		cur ^= 1; nxt ^= 1; memset(dp[nxt],0,sizeof(dp[nxt]));
		for(int j = 0;j <= n; ++ j)
			for(int l = 0;l <= m; ++ l)
			{
				int tm = pw[k - i + 1][j] * 1ll * pw[i][n - j] % d;
				for(int p = 0,x = dp[cur][j][l];l + p <= m; ++ p,x = x * 1ll * tm % d)
					dp[nxt][j][l + p] = (dp[nxt][j][l + p] + x * 1ll * C[m - l][p]) % d;
			}
		cur ^= 1; nxt ^= 1; memset(dp[nxt],0,sizeof(dp[nxt]));
		for(int j = 0;j <= n; ++ j)
			for(int l = 0;l <= m; ++ l)
			{
				int tm = pw[k - i][l] * 1ll * pw[i][m - l] % d * (d - 1) % d;
				for(int p = 0,x = dp[cur][j][l];j + p <= n; ++ p,x = x * 1ll * tm % d)
					dp[nxt][j + p][l] = (dp[nxt][j + p][l] + x * 1ll * C[n - j][p]) % d;
			}
		cur ^= 1; nxt ^= 1; memset(dp[nxt],0,sizeof(dp[nxt]));
		for(int j = 0;j <= n; ++ j)
			for(int l = 0;l <= m; ++ l)
			{
				int tm = (d - 1) * 1ll * pw[k - i][j] % d * pw[i][n - j] % d;
				for(int p = 0,x = dp[cur][j][l];l + p <= m; ++ p,x = x * 1ll * tm % d)
					dp[nxt][j][l + p] = (dp[nxt][j][l + p] + x * 1ll * C[m - l][p]) % d;
			}
	}
	printf("%d\n",dp[nxt][n][m]);
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
using ll = long long;
constexpr int MOD = 1e9 + 7;

int N;
ll a[200010],h[200010];
ll dp[200010]; // dp[i] := 高さiまでの総和の最大値

void update(int i,ll x){
    for(;i<=N;i += i & -i) dp[i] = max(dp[i],x);
}

ll query(int i){
    ll ret = 0;
    for(;0<i;i -= i & -i) ret = max(ret,dp[i]);
    return ret;
}

int main(){
    cin >> N;
    for(int i=1;i<=N;++i) cin >> h[i];
    for(int i=1;i<=N;++i) cin >> a[i];
    for(int i=1;i<=N;++i){
        ll tmp = query(h[i]) + a[i];
        update(h[i],tmp);
    }
    cout << query(N) << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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

const ll mod = 998244353;





int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<pair<int,int>>> input(n);
    rep(i,n){
        int a;
        cin >> a;
        rep(j,a){
            int x,y;
            cin >> x >> y;
            --x;
            input[i].pb(make_pair(x,y));
        }
    }

    int ans = 0;
    for(ll i = 0;i < 1<<n;++i){
        bool flag = true;
        int num = 0;
        for(ll j = 0;j < n;++j){
            if(i >> j & 1){
                for(auto inp : input[j]){
                    if((i>>inp.first)%2 != inp.second){
                        flag = false;
                        break;
                    }
                }
                num++;
            }
        }
        if(flag)ans = max(ans,num);
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3668
I1 = input().split()
I2 = input().split()

result = int(I1[0])
delta = 0
flag = 0
while flag == 0:
    if str(result-delta) in I2:
        if str(result+delta) in I2:
            delta += 1
        else:
            print(result + delta)
            flag = 1
    else:
        print(result - delta)
        flag = 1

Measured memory_bytes: 9184
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)

lli data[2010][2010];
lli cnt[2][2010][2010];

lli calc(lli dir,lli startY,lli startX,lli nowY,lli nowX){
	lli dx[2]={1,0};
	lli dy[2]={0,1};

	if(data[nowY][nowX]==-1){
		cnt[dir][nowY][nowX] = abs(nowY-startY) + abs(nowX - startX);
	}

	if(cnt[dir][nowY][nowX])return cnt[dir][nowY][nowX];

	return cnt[dir][nowY][nowX]=calc(dir,startY,startX,nowY+dy[dir],nowX+dx[dir]);
}

signed main(){

	lli h,w;
	cin>>h>>w;

	REP(k,0,2)REP(i,0,2010)REP(j,0,2010){
		data[i][j]=-1;
		cnt[k][i][j]=0;
	}

	REP(i,1,h+1)REP(j,1,w+1){
		char tmp;
		cin>>tmp;
		if(tmp=='.'){
			data[i][j]=0;
		}
	}

	lli ans=0;

	for(lli i=1;i<=h;i++){
		for(lli j=1;j<=w;j++){

			lli sum=0;
			if(data[i][j]==0){
				lli flag=0;
				for(lli k=0;k<2;k++){
					sum+=calc(k,i,j,i,j);
				}
				sum--;
			}

			ans=max(ans,sum);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int max(int a, int b)
{ return (a > b) ? a : b; }

const int MAXN = 200031;
const ll INF = 10000000000000LL;
int a[MAXN];

vector<ll> p(31);

__int128 power(__int128 a, ll b)
{
    if (b == 0) return 1;
    if (a >= INF) return INF;
    __int128 res = power(a * a, b / 2);

    if (res >= INF) return INF;
    if (b % 2 == 1)
    {
        return a * res;
    }
    else return res;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n, p;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    a[n] = 0;
    sort(a.rbegin(), a.rend());
    int last = 0;
    int x = 0;
    for (int i = 0; i < n; i++)
    {
        if ((a[i] - a[i + 1]) % 2 == 1) x ^= (i + 1);
//        cerr << (a[i] - a[i + 1]) << " " << (i + 1) << endl;
    }
    if (x == 0) cout << "second"; else cout << "first";

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
 
int main() {
	unsigned long long int N , M ,a;
	cin >> N >> M;
	a = (M - 2 * N) / 4;
	long long int Mmax = M / 2;
	if (M >= 2 * N) {
		N = N + a;
		M = M - 2 * a;
	}
       else N = M /2;

	cout << N << endl;
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 176
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n;
    cin >> n;

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    ll ans=0;
    int last=a[0];
    REP(i,n){
        if (last>a[i]){
            ans+=last-a[i];
        }else{
            last = a[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3984
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>

using namespace std;

#define INIT 2147483647

class e {
public:
	int v, w;
	e(int v, int w)
	:v(v),w(w)
	{}
};

vector<e> con[100001], rcon[100001];
int up[100001];
int n, m, el[200001][3];
int ind[100001], d[100001];

int fd(int u) {
	if(up[u]==0) return u;
	return up[u]=fd(up[u]);
}

void un(int u, int v) {
	int ru=fd(u), rv=fd(v);
	up[rv]=ru;
}

bool mark(int u) {
	for(int i=0;i<con[u].size();i++) {
		int v=con[u][i].v, w=con[u][i].w;
		if(d[v]==INIT) {
			d[v]=d[u]+w;
			if(!mark(v)) return false;
		}
		else if(d[v]!=d[u]+w) return false;
	}
	for(int i=0;i<rcon[u].size();i++) {
		int v=rcon[u][i].v, w=rcon[u][i].w;
		if(d[v]==INIT) {
			d[v]=d[u]-w;
			if(!mark(v)) return false;
		}
		else if(d[v]!=d[u]-w) return false;
	}
	return true;
}

int main() {
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++) {
		int u, v, w;
		scanf("%d %d %d",&u,&v,&w);
		el[i][0]=u; el[i][1]=v; el[i][2]=w;
		if(w==0) {
			if(fd(u)!=fd(v)) {
				un(u,v);
			}
		}
	}
	for(int i=0;i<m;i++) {
		int u=el[i][0], v=el[i][1], w=el[i][2];
		if(w==0) continue;
		if(fd(u)==fd(v)) {
			puts("No");
			return 0;
		}
		con[u].push_back(e(v,w));
		rcon[v].push_back(e(u,w));
		ind[v]++;
	}
	for(int i=1;i<=n;i++)
		d[i]=INIT;
	for(int i=1;i<=n;i++) if(ind[i]==0 && d[i]==INIT) {
		d[i]=0;
		if(!mark(i)) {
			puts("No");
			return 0;
		}
	}
	for(int i=1;i<=n;i++) {
		if(d[i]==INIT) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 19328
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
int N;

void StringEquivalance(char *a,int i,char c){
	// base case
	if(i == N){
		a[i] = '\0';
		cout<<a<<endl;
		return;
	}

	// Recursive case
	for(char ch = 'a';ch<=c;ch++){
		a[i] = ch;
		if(ch == c){
			StringEquivalance(a,i+1,c+1);
		}
		else{
			StringEquivalance(a,i+1,c);
		}
	}
}


int main(){
	cin>>N;
	char a[100];
	StringEquivalance(a,0,'a');


	return 0;
}

Measured memory_bytes: 1536
n,m = map(int,input().split())
gate_list = [ list(map(int,input().split())) for i in range(m)]
#print(gate_list)
ans1 = gate_list[0][0]
ans2 = gate_list[0][1]
for i in range(1,m):
    ans1 = max(ans1,gate_list[i][0])
for i in range(1,m):
    ans2 = min(ans2,gate_list[i][1])
ans = ans2 - ans1
if ans < 0:
    print(0)
else:
    print(ans+1)

Measured memory_bytes: 60248
#include <bits/stdc++.h>
#include <ctime>
#include <cstdlib>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int N;
    cin >> N;
    int sum = 0;
    vector<int> A(N), B(N), C(N - 1);
    rep(i, N)
    {
        cin >> A[i];
    }
    rep(i, N)
    {
        cin >> B[i];
        sum += B[i];
    }
    rep(i, N - 1)
    {
        cin >> C[i];
    }
    rep(i, N)
    {
        if (A[i] + 1 == A[i + 1])
        {
            sum += C[A[i] - 1];
        }
    }
    cout << sum << endl;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T> constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


std::vector<int> zarray(const std::string& S) {
    int c = 0;
    std::vector<int> A(S.size());
    for (int i = 1; i < (int)S.size(); i++) {
        if (i + A[i - c] < c + A[c]) {
            A[i] = A[i - c];
        }
        else {
            int j = std::max(0, c + A[c] - i);
            while (i + j < (int)S.size() && S[j] == S[i + j]) ++j;
            A[i] = j;
            c = i;
        }
    }
    A[0] = S.size();

    return A;
}

int n;
string s;
void solve() {
    cin >> n >> s;

    int ans = 0;
    rep(i, n) {
        auto v = zarray(s.substr(i));
        rep(j, n - i)
            maxs(ans, min(j, v[j]));
    }

    cout << ans << endn;
}

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

    solve();

    cout << flush;

    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int t=n,w=0;
	while(t)w+=t%10,t/=10;
	cout<<(n%w==0?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#define MAX_INT 2100000000
using namespace std;
typedef long long int ll;
//#include "Header.h"
int first[110], n, i, j, mn = 0,last=0,length;
vector<int> ans;
int main()
{
	char b,c;
	cin >> b;
	if (b == 'A') c = 'T';
	if (b == 'T') c = 'A';
	if (b == 'G') c = 'C';
	if (b == 'C') c = 'G';
	cout << c << endl;
}


Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS 1

#include <set>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define rep(i,a,b) for(int i = (a) ; i <= (b) ; i++)
#define per(i,a,b) for(int i = (a) ; i >= (b) ; i--)
#define mem(a) memset(a,0,sizeof(a))
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define fast_io ios::sync_with_stdio(false)

const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int maxn = 1e3 + 7;

char s[maxn][maxn];
int n,m;
int stx,sty;
int edx,edy;
int vis[maxn][maxn];

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

struct point {
	int x,y;
	int ans;
};

deque<point>q;

int bfs() {
	point st;
	st.x = stx, st.y = sty, st.ans = 0;
	q.push_front(st);
	// vis[stx][sty] = 1;
	point k1, k2;
	bool flag = false;
	while(!q.empty()) {
		k1 = q.front();
		q.pop_front();
		vis[k1.x][k1.y] = 1;
		// cout << k1.x << " " << k1.y << " " << k1.ans << endl;
		if(k1.x == edx && k1.y == edy) {
			flag = true;
			break;
		}
		rep(i,0,3) {
			k2.x = k1.x + dx[i];
			k2.y = k1.y + dy[i];
			if(k2.x >= 0 && k2.x < n && k2.y >= 0 && k2.y < m && s[k2.x][k2.y] == '.' && !vis[k2.x][k2.y]) {
				k2.ans = k1.ans;
				// vis[k2.x][k2.y] = 1;
				q.push_front(k2);
			} 
		}
		rep(i,k1.x-2,k1.x+2) {
			rep(j,k1.y-2,k1.y+2) {
				k2.x = i;
				k2.y = j;
				if(k2.x >= 0 && k2.x < n && k2.y >= 0 && k2.y < m && s[k2.x][k2.y] == '.' && !vis[k2.x][k2.y]) {
					k2.ans = k1.ans + 1;
					// vis[k2.x][k2.y] = 1;
					q.push_back(k2);
				}	
			}
		}
	}
	if(!flag) k1.ans = -1;
 	return k1.ans;
}

int main() {
	fast_io;
	cin >> n >> m;
	cin >> stx >> sty;
	stx--, sty--;
	cin >> edx >> edy;
	edx--, edy--;
	rep(i,0,n-1) {
		cin >> s[i];
	}
	cout << bfs() << endl;
	return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int x;
    cin >> x;
    if(x==1)
        cout << 0 << endl;
    else
        cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3624
import math
from functools import reduce
import itertools

K = int(input())

gcd_sum = 0
target_range = range(1, K + 1)
for comb in itertools.combinations_with_replacement(target_range, 3):
  a, b, c = comb[0], comb[1], comb[2]
  gcd = reduce(math.gcd, comb)
  
  if a == b == c:
    gcd_sum += gcd
  elif a != b != c:
    gcd_sum += gcd * 6
  else:
    gcd_sum += gcd * 3


print(gcd_sum)

Measured memory_bytes: 9588
#include <stdio.h>

int main()
{
	char S[3];
	char T[3];
	for (int i = 0; i < 3; i++)
		scanf("%c", &S[i]);
	getchar();
	for (int i = 0; i < 3; i++)
		scanf("%c", &T[i]);

	int count = 0;
	for (int i = 0; i < 3; i++)
		if (S[i] == T[i])
			count++;

	printf("%d\n", count);
	return 0;
}


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

int main(){
    int a,b,c,d,e,k;
    cin>>a>>b>>c>>d>>e>>k;
    bool check=true;
    if(b-a>k||c-a>k||d-a>k||e-a>k||c-b>k||d-b>k||e-b>k||d-c>k||
    e-c>k||e-d>k)
        check=false;
    if(check)
        cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>

#define st first
#define nd second

using namespace std;
using ll = long long;
using ld = long double;

const int MAXN = 1e6+5, inf = 1e9;
const ll INF = 1e18;

constexpr int mod = 1e9+7;
constexpr ll MOD = 1e9+7;

ll tab[MAXN];
set<int> S;
map<int, int> M;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    /////////////////////////////
    string a, b;
    cin >> a >> b;
    string s = a + b;
    ll c = 0;
    for (char cc : s)
    {
        c = (c * 10 + (cc - '0'));
    }

    ll sq = sqrt(c);
    if (sq * sq == c)
    {
        cout << "Yes\n";
    }
    else cout<< "No\n";

}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int H, W;
int dist[1010][1010] = {0};

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

    cin >> H >> W;

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            dist[i][j] = 10000;
        }
    }

    string tmp;
    queue<tuple<int, int, int>> que;
    for(int i = 0; i < H; i++){
        cin >> tmp;
        for(int j = 0; j < W; j++){
            if(tmp[j] == '#'){
                // 左右縦横をキューに入れる
                dist[i][j] = 0;

                if(i > 0) que.push(make_tuple(i-1, j, 1));
                if(j > 0) que.push(make_tuple(i, j-1, 1));
                if(i < H-1) que.push(make_tuple(i+1, j, 1));
                if(j < W-1) que.push(make_tuple(i, j+1, 1));
            }
        }
    }

    while(que.size()){
        auto p = que.front();
        que.pop();

        int i = get<0>(p);
        int j = get<1>(p);
        int d = get<2>(p);
        
        if(dist[i][j] > d){
            dist[i][j] = d;
            //左右縦横みて、
            if(i > 0) que.push(make_tuple(i-1, j, d+1));
            if(j > 0) que.push(make_tuple(i, j-1, d+1));
            if(i < H-1) que.push(make_tuple(i+1, j, d+1));
            if(j < W-1) que.push(make_tuple(i, j+1, d+1));
        }
    }


    int ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            chmax(ans, dist[i][j]);
        }
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 52484
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main() {
    let _vec: Vec<usize> = read_line();
    let hs: Vec<i32> = read_line();
    let mut dp: Vec<i32> = Vec::new();

    for _ in 0..hs.len() { dp.push(0); }
    dp[1] = (hs[1] - hs[0]).abs();

    for i in 2..hs.len() {
        dp[i] = cmp::min(
            dp[i - 1] + (hs[i] - hs[i - 1]).abs(),
            dp[i - 2] + (hs[i] - hs[i - 2]).abs(),
        );
    }

    println!("{}", dp.last().unwrap());
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
    long long int a, b;
    cin >> a >> b;
    if(a*b<=0) {
        cout << "Zero" << endl;
    } else {
        if(a>0) {
            cout << "Positive" << endl;
        } else {
            if((b-a)%2) {
                cout << "Positive" << endl;
            } else {
                cout << "Negative" << endl;
            }
        }
    }



    return 0;
    
}

Measured memory_bytes: 256
from bisect import bisect_right
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

SA, SB = [0], [0]

for i in range(n):
    SA.append(SA[-1] + A[i])
for i in range(m):
    SB.append(SB[-1] + B[i])

res = bisect_right(SA, k) - 1

#print(SA,SB)
for i, sa in enumerate(SA):
    if k - sa > 0:
        tmp = i + bisect_right(SB, k - sa) - 1
        res = max(res, tmp)
    else:
        break
print(res)



Measured memory_bytes: 132864
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define LL long long int
 

 //greater<int>() sortの第三因数に入れて降順
 
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}
 
int main(void){

    bool flag =false;
    int ans;
    int n;
    cin >>n;
    vector<int>a(n),x(n);
    rep(i,n){
        cin >>a[i];
        x[i]=a[i];
    }
    sort(a.begin(),a.end(),greater<int>() );
    if(a[0]==a[1]){
        flag=true;
        
    }
    Rep(i,n){
        if(a[i-1]!=a[i]){
            ans=a[i];
            break;
        }
    }
    if(flag==true){
        rep(i,n){
            cout <<a[0]<<endl;
        }
    }
  else if(flag==false){
      rep(i,n){
          if(x[i]==a[0]){
              cout <<ans<<endl;
          }
          else{
              cout <<a[0]<<endl;
          }
      }
  }
 return 0;




}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cassert>
 
using namespace std;
const long long mod = 1000000007;
 
struct mat {
    long long mx[60][60];
    int x, y;
 
    mat(int x, int y) {
        this->x = x;
        this->y = y;
        memset(mx, 0, sizeof mx);
    }
 
    void setval(int x, int y, int val) {
        assert(x < this->x && y < this->y);
        this->mx[x][y] = val;
        //printf("debug: %d\n", this->mx[x][y]);
        //this->print();
    }
 
    long long getval(int x, int y) {
        //printf("%d %d -> %d %d\n", x, y, this->x, this->y); 
        //fflush(stdout);
        assert(x < this->x);
        assert(y < this->y);
        return this->mx[x][y];
    }
 
    mat operator * (mat tren) {
        assert(this->y == tren.x);
        mat ne = mat(this->x, tren.y);
 
        for (int i = 0; i < this->x; i++) {
            for (int j = 0; j < tren.y; j++) {
                long long ac = 0;
                for (int k = 0; k < this->y; k++)
                    ac += ((this->mx[i][k] * tren.getval(k, j)) % mod), ac %= mod;
                ne.setval(i, j, ac);
            }
        }
        return ne;
    }
 
    void operator = (mat tren) {
        this->x = tren.x;
        this->y = tren.y;
 
        for (int i = 0; i < this->x; i++)
            for (int j = 0; j < this->y; j++)
                this->mx[i][j] = tren.getval(i, j);
    }
 
    void print() {
        for (int i = 0; i < this->x; i++) {
            for (int j = 0; j < this->y; j++)
                printf("%d ", this->mx[i][j]);
            printf("\n");
        }
        printf("\n");
    }
};
 
int n;
long long k;
long long get(mat &a, mat &b) {
    mat cp(n, n);
    for (int i = 0; i < n; i++)
    	cp.setval(i, i, 1);
    while (k > 0) {
    	if (k & 1) cp = cp * b;
    	b = b * b;
    	k /= 2;
	}
	a = a * cp;
	long long sol = 0;
	for (int i = 0; i < n; i++)
		sol += a.getval(0, i), sol %= mod;
	return sol;
}
 
int main() {
    scanf("%d%lld", &n, &k);
    mat pot(n, n);
    for (int i = 0; i < n; i++)
    	for (int j = 0; j < n; j++)
    		scanf("%lld", &pot.mx[i][j]);
    
    mat kol(1, n);
	for (int i = 0; i < n; i++)
		kol.setval(0, i, 1);
    printf("%lld\n", get(kol, pot));
    //system("pause");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;
const int maxn=2e6+7;
const ll mod=1e9+7;
#define rep(i,a,b) for(int i=a;i<=b;++i) // rep=repeat 
#define int ll
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
int p[maxn],ivp[maxn];// p是階乘, iv ->inverse, ivp 是取模逆元 
// 因為他要用除的, 但mod無法在除法做運算, 所以要取模逆元才可以(用乘的)與(除的)等值

int ppow(int x,int y=mod-2){// 取模逆元(a^(p-2)==a^-1)
    if (y==0) return 1;
    int ret=ppow(x,y/2);//ret =return (value)
    ret=ret*ret%mod;
    if (y&1) ret=ret*x%mod;
    return ret;
}

int C(int n,int m){
    return p[n]*ivp[m]%mod*ivp[n-m]%mod;//(n!/m!(n-m)!)
}

int32_t main(){
    IOS
    int r1,r2,c1,c2;
    cin>>r1>>c1>>r2>>c2;//input
    
    p[0]=ivp[0]=1;
    rep(i,1,2000002)//init
        p[i]=p[i-1]*i%mod,ivp[i]=ppow(p[i]);

    int ans=0;
    rep(i,r1,r2)
        ans=(ans+C(i+c2+1,i+1)+2*mod-C(i+c1,i+1)+mod)%mod;// +2mod 是要讓他恆正
    
    cout<<ans<<endl;
 
}



Measured memory_bytes: 31488
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;

int main() {

	Int L, R;
	cin >> L >> R;

	Int modL = L % 2019;
	Int modR = R % 2019;

	Int ans = INF;
	if (R - L > 2019)ans = 0;
	if (modL * modR == 0)ans = 0;
	if (modL >= modR)ans = 0;
	if (modL < modR) {
		if (((modL <= 673 && 673 <= modR) || (modL <= 1346 && 1346 <= modR)) && (modR - modL >= 2))ans = 0;
		else {
			for (Int i = modL; i < modR;i++) {
				for (Int j = i + 1; j <= modR; j++) {
					ans = min(ans,(Int)(1LL*i * j % 2019));
				}
			}

		}

	}

	cout << ans << endl;


}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,A,B = LI()
    G = LIR(n)
    ma = sum([a for (a,_,_) in G])
    mb = sum([b for (_,b,_) in G])
    dp = [[float("inf")]*(mb+1) for i in range(ma+1)]
    dp[0][0] = 0
    for a,b,c in G:
        for sa in range(ma)[::-1]:
            for sb in range(mb)[::-1]:
                na = sa+a
                if na > ma:
                    continue
                nb = sb+b
                if nb > mb:
                    continue
                nd = dp[sa][sb]+c
                if nd < dp[na][nb]:
                    dp[na][nb] = nd
    ans = float("inf")
    for i in range(1,ma+1):
        s = B*i
        if s%A:
            continue
        j = B*i//A
        if j > mb:
            continue
        if dp[i][j] < ans:
            ans = dp[i][j]
    if ans == float("inf"):
        print(-1)
        return
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 45020
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
  for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
  for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
  return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
  os<<"{ ";for(auto m:M)os<<"("<<m.first<<":"<<m.second<<")";
  return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
//For multiset use less_equal operator but it does support erase operations for multiset
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
//#define endl "\n"
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mp make_pair
// inline void modadd(int &a,int &b){a+=b;if(a>=mod)a-=mod;} 
const int N = 5e5 + 100;

int tab[N];
void upt(int x, int val){
  x = N-1-x;
  while(x < N){
    tab[x] += val;
    x += x&-x;
  }
}
int query(int x){
  x = N-1-x;
  int res = 0;
  while(x){
    res += tab[x];
    x -= x&-x;
  }
  return res;
}
int ans[N];

int rht[N];
int A[N];
int L[N], R[N];
vi a[N], b[N];

int main(){
  fio; cout<<fixed<<setprecision(25);	
  int n, q; cin >> n >> q;
  for(int i =1 ;i <= n ; ++i){
    cin >> A[i];
  }
  for(int i= n;i >= 1 ; --i){
    if(rht[A[i]] == 0) rht[A[i]] = N-2;
    int nxt = A[i];
    A[i] = rht[nxt];
    rht[nxt] = i;
  }
  for(int i=  1;i <= q ; ++i){
    cin >> L[i] >> R[i];
    a[L[i]-1].pb(i);
    b[R[i]].pb(i);
  }

  for(int i =1 ;i <= n ; ++i){
    //cout << A[i] << ' ' << a[i] << ' ' << b[i] << endl;
    upt(A[i] , 1);
    for(auto it : a[i]){
      ans[it] -= query(R[it]+1);
    }
    for(auto it : b[i]){
      ans[it] += query(i+1);
    }
  }
  for(int i = 1;i <= q; ++i)
    cout << ans[i] << endl;



  return 0;
}


Measured memory_bytes: 56080
from itertools import combinations
def main():
    N, M, X = map(int, input().split())
    l = []
    for _ in range(N):
        A = list(map(int, input().split()))
        l.append(A)
    m = pow(10, 7)
    for i in range(1, N+1):
        for j in combinations([k for k in range(N)], i):
            ll = [0] * (M+1)
            for k in j:
                for w in range(M+1):
                    ll[w] += l[k][w]
            if min(ll[1:]) >= X:
                m = min(m, ll[0])
    if m >= pow(10, 7):
        return -1
    return m

print(main())


Measured memory_bytes: 9224
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int k, s, x, y, z;
   
    int a = 0;
   
      
    scanf("%d %d", &k , &s);
   

    for( x = 0 ; x <= k ; x = x + 1 ){

        for( y = 0 ; y <= k ; y = y + 1 ){

            z = s - x - y;

            if( 0 <= z && z <= k ) a += 1;

            }

        }


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


    return 0;
                                                          
}

Measured memory_bytes: 128
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-05-14 11:40:42
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 400 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , C , A[MAXN] , B[MAXN] , dp[MAXN][MAXN] , pw[MAXN][MAXN];

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

    for(int i = 1 ; i < MAXN ; i++){
        ll cur = 1;
        for(int j = 0 ; j < MAXN ; j++){
            pw[i][j] = (pw[i - 1][j] + cur) % MOD;
            cur = cur * i % MOD;
        }
    }

    cin >> n >> C;
    for(int i = 1 ; i <= n ; i++)   cin >> A[i];
    for(int i = 1 ; i <= n ; i++)   cin >> B[i];

    dp[0][0] = 1;
    for(int i = 1 ; i <= n ; i++){
        for(int j = 0 ; j <= C ; j++){
            for(int k = j ; k <= C ; k++){
                dp[i][k] = (dp[i][k] + dp[i - 1][j] * (pw[B[i]][k - j] - pw[A[i] - 1][k - j] + MOD)) % MOD;
            }
        }
    }
    cout << dp[n][C] << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int c[101][101];
int b[101];
int main(){
	int W,H,N,x,y,a;
	cin>>W>>H>>N;
	for(int n=1;n<=N;n++){
		cin>>x>>y>>a;
		if(a==1){
			for(int i=0;i<x;i++){
				for(int j=0;j<H;j++)
				c[i][j]=1;
			}
		}
		else if(a==2){
			for(int i=x;i<W;i++){
				for(int j=0;j<H;j++)
				c[i][j]=1;
			}
		}
		else if(a==3){
			for(int i=0;i<W;i++){
				for(int j=0;j<y;j++)
				c[i][j]=1;
			}
		}
		else if(a==4){
			for(int i=0;i<W;i++){
				for(int j=y;j<H;j++)
				c[i][j]=1;
			}
		}
	}
	int ans=0;
	for(int i=0;i<W;i++){
		for(int j=0;j<H;j++)
		if(!c[i][j]) ans++;
	}
	cout<<ans;
	return 0;
}
//若 1，则将满足 的小矩形涂黑。 
//若 2，则将满足 的小矩形涂黑。 
//若 3，则将满足 的小矩形涂黑。 
//若 4，则将满足 的小矩形涂黑。

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC122 {
	class ABC122_A {

		static void Main(string[] args) {
			var baseDict = new Dictionary<string, string> {
				["A"] = "T",
				["C"] = "G",
				["G"] = "C",
				["T"] = "A",
			};
			Console.WriteLine(baseDict[Console.ReadLine()]);
		}
	}
}


Measured memory_bytes: 11104
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(void){
    int i,count = 0;
    int alen,blen;
    char T[1100];
    char W[21];
    char a[]="END_OF_TEXT";
    scanf("%s",&W);
    alen = strlen(W);
    for(i=0;i<alen;i++){
        W[i] = tolower(W[i]);
    }
    while(1){
        scanf("%s",&T);
        if(strcmp(T,a)==0) break;
        blen = strlen(T);
        for(i=0;i<blen;i++){
            T[i] = tolower(T[i]);
        }
        if(strcmp(T,W)==0) count++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 548
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] ans = new int[N];

        long res = 0;
        long count=0;
        for(int i=1; i<Math.pow(N,0.5); i++){
            for(int j=1; j<Math.pow(N,0.5); j++){
                for(int l=1; l<Math.pow(N,0.5); l++){
                    res = i*i + j*j + l*l +i*j + j*l + l*i;
                    if(res<=N){
                        ans[(int)res-1]++;
                    }
                }
            }
        }

        for(int i=0; i<N; i++){
            System.out.println(ans[i]);
        }
        //System.out.println(count);
        
        }
    }

Measured memory_bytes: 39156
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    ll a, b, c, k;  cin >> a >> b >> c >> k;
    ll ans = 0;
    ans += min(k, a);
    k -= min(k,a);
    k -= min(k,b);
    if (k > 0)
        ans -= k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  string w;
  cin >> w;
  vector<int> cnt('z'+1, 0);
  rep(i, w.size()) {
    cnt[w[i]]++;
  }
  rep(i, cnt.size()) {
    if (cnt[i]%2 != 0) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;

const int MAX_INT = 1e8+1;

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

    vector<bool> primes(MAX_INT, true);
    primes[0] = primes[1] = false;
    for(int i=2; i*i<=MAX_INT; i++) {
        if (!primes[i]) continue;
        for(int j=2; i*j<=MAX_INT; j++) {
            primes[i*j] = false;
        }
    }

    int n; cin >> n;
    int ans = 0;
    rep(i, n) {
        int x; cin >> x;
        if (primes[x]) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 14852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int con =0;
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			int item = sc.nextInt();
			if (min > item) {
				min = item;
			}
			if (min >= item) {
				con++;
			}
		}

		System.out.println(con);

	}
}

Measured memory_bytes: 58096
#include <iostream>
using namespace std;
const long long MAX = 10000000;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    long long x, y;cin>>x>>y;
    long long line_num=0;
    for (long long i=1;i<=1000000;i++){
        if (x + y == 3 * i){
            line_num = i;
        }
    }
    if (line_num == 0){
        cout << 0 << endl;
        return 0;
    }

    long long start_x = line_num;
    long long end_x = start_x + line_num;
    long long start_y = line_num;
    long long end_y = start_y + line_num;
    if (!(start_x <= x && x <= end_x && start_y <= y && y<= end_y)){
        cout << 0 << endl;
        return 0;
    }

    COMinit();

    if (x < y){
        cout << COM(line_num, end_y - y) << endl;
    } else {
        cout << COM(line_num, end_x - x) << endl;
    }
    return 0;
    
}

Measured memory_bytes: 234624
def main():
    X, N = [int(x) for x in input().split()]
    if N == 0:
        print(X)
        return

    PS = [int(x) for x in input().split()]
    for i in range(0, 100):
        for sign in (-1, +1):
            v = X + i * sign
            if v not in PS:
                print(v)
                return


main()


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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#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 range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

// (to, cost)
typedef pii Edge;

vi isLeaf;
vector<vector<Edge>> edge;

pair<int, set<int>> res;
int last;

#define F first
#define S second

void dfs(pair<int, set<int>> & cur, int v){
    if(res.F < cur.F){
        res = cur;
        last = v;
    }

    for(auto e : edge[v]){
        if(isLeaf[e.F] || cur.S.find(e.F) != cur.S.end()) continue;

        cur.S.insert(e.F);
        cur.F += e.S;

        dfs(cur, e.F);

        cur.S.erase(e.F);
        cur.F -= e.S;
    }
}

int main(void){
    for(int n; cin >> n, n;){
        vi p(n - 1), d(n - 1);
        for(auto && pp : p){
            cin >> pp; pp--;
        }
        for(auto && dd : d) cin >> dd;

        edge = vector<vector<Edge>>(n);
        range(i, 1, n){
            edge[i].pb(mp(p[i - 1], d[i - 1]));
            edge[p[i - 1]].pb(mp(i, d[i - 1]));
        }

        isLeaf = vi(n);
        rep(u, n) if(edge[u].size() == 1) isLeaf[u] = true;

        //// 最遠頂点間距離
        int s;
        rep(u, n) if(!isLeaf[u]){ s = u; break; }

        res.F = -1;
        pair<int, set<int>> tmp;
        tmp.S.insert(s);
        dfs(tmp, s);

        s = last;

        res.F = -1;
        tmp = pair<int, set<int>>();
        tmp.S.insert(s);
        dfs(tmp, s);
        ////

        int ans = 0;
        rep(i, n - 1){
            int a = i + 1, b = p[i];

            int diff = d[i];
            if(isLeaf[a] || isLeaf[b]);
            else if(res.S.find(a) != res.S.end() && 
                    res.S.find(b) != res.S.end()){
                diff *= 2;
            }
            else diff *= 3;

            ans += diff;
        }

        cout << ans << endl;
    }

	return 0;
}

Measured memory_bytes: 1440
def tsort(G):
    def bfs(s):
        que = [s]
        used[s] = True
        while que:
            u = que.pop(0)
            res.append(u)

            for v in G[u]:
                indeg[v] -= 1
                if indeg[v] == 0 and not used[v]:
                    used[v] = True
                    que.append(v)

    indeg = [0] * V
    used = [False] * V
    res = []
    for u in xrange(V):
        for v in G[u]:
            indeg[v] += 1
    for u in xrange(V):
        if indeg[u] == 0 and not used[u]:
            bfs(u)
    return res


V, E = map(int, raw_input().split())
G = [[] for i in xrange(V)]
for i in xrange(E):
    s, t = map(int, raw_input().split())
    G[s].append(t)

ans = tsort(G)
for i in ans:
    print i

Measured memory_bytes: 6868
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int sum=0;
    int l,r;
    for(int i=0;i<n;i++){
        cin >> l >>r;
        sum += (r-l+1);
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 384
n,m = map(int,input().split())
a = [[0 for i in range(m)]for j in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))

b = [0 for i in range(m)]
for i in range(m):
    b[i] = int(input())

c = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]
    print(c[i])

Measured memory_bytes: 7900