akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<climits>
using namespace std;
#define mod (1000000007LL)
#define ll long long
int main() {
	int H,W;
	cin>>H>>W;
	vector<vector<ll> > dp (H);

	vector<string> s;
	s.resize(H);
	cin.ignore(1,'\n');
	for(int i=0;i<H;i++) {
		dp[i].resize(W);
		cin>>s[i];
	}
	dp[0][0] = 1;
	for(int i=0;i<H;i++) {
		for(int j=0; j<W;j++) {
			if(s[i][j] == '.') {
				if(i!=0)
				dp[i][j] += dp[i-1][j];
				if(j!=0)
				dp[i][j] += dp[i][j-1];
				dp[i][j] %= mod;
			}
		}
	}
	cout<<dp[H-1][W-1]<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <deque>
#include <string>
using namespace std;
typedef long long ll;
const int N=5e5+5;
int n,k,a[N],dp[N];
string s,t;
deque<int> dq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k>>s>>t;
    for(int i=2;i<=n;i++)
        a[i]=a[i-1]+(t[i-1]!=t[i-2]);
    dq.push_back(0);
    for(int i=1;i<=n;i++){
        while(dq.size()&&dq.front()+k<i) dq.pop_front();
        if(s[i-1]==t[i-1]){
            dp[i]=dp[i-1];
        }
        else dp[i]=dp[dq.front()]+(a[i]-a[dq.front()+1]+1)/2+1;
        while(dq.size()&&2*dp[dq.back()]-a[dq.back()+1]>=2*dp[i]-a[i+1]) dq.pop_back();
        dq.push_back(i);
    }
    cout<<dp[n]<<endl;
    return 0;
}



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

int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  int x[3]={a,b,c};
  sort(x,x+3);
  int num=(x[2]*10)+(x[1]+x[0]);
  printf("%d",num);
}

Measured memory_bytes: 256
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, M = list(map(int, sys.stdin.readline().split()))
    a = list(map(int, sys.stdin.readline().split()))
    b = list(map(int, sys.stdin.readline().split()))
    c = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]

    ret = float('inf')
    for w in c:
        tmp = a[w[0] - 1] + b[w[1] - 1] - w[2]
        if ret > tmp:
            ret = tmp

    if ret > min(a) + min(b):
        ret = min(a) + min(b)

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38436
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //required
// #include <ext/pb_ds/tree_policy.hpp> //required

// using namespace __gnu_pbds; 
using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
// template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // ordered_set <ynt> s; // order_of_key(value)

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

#define st first
#define nd second


const int N = 300100;
int n, k, m, a, b, p[N];

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n >> a >> b;

	for(int i = 1; i <= n; i++) p[i] = i;

	// if(a + b == n + 1) {
	// 	// return 0;
	// 	reverse(p + 1, p + b + 1);
	// 	// reverse	
	// 	for(int i = 1; i <= n; i++) cout << p[i] << ' ';

	// 	return 0;
	// }

		// dbg(1LL * a * b);
		// dbg(a * b);
	if(1LL * a * b < 1LL *n || a + b > n + 1)
		return cout << "-1\n", 0;
	// return 0;
	int rest = n;
	for(int j = 1; j <= n; j += b) {
		rest -= b - 1;
		if(rest >= a)
			reverse(p + j, min(p + j + b, p + n + 1));
		else {
			rest += b - 1;
			int cant = rest - a + 1;
			reverse(p + j, min(p + j + cant, p + n + 1));
			break;
		}
	}

	for(int i = 1; i <= n; i++) cout << p[i] << ' ';
}


Measured memory_bytes: 3328
#include<iostream>


using namespace std;


int main(){
    int N,M;
    cin >> N >> M;
    int sum=0;
    int A[M];
    for(int i=0;i<M;i++){
        cin >> A[i];
        sum=sum+A[i];
    }

    int answer;
    if(N-sum<0) answer=-1;
    else answer=N-sum;

    cout << answer << endl;

    return 0;

}

Measured memory_bytes: 3636
N=int(input())
number=list(map(int,input().split()))
Sum=sum(number)
number_sum=[0]*N
number_sum[0]=number[0]
result=[0]*(N-1)
for i in range(1,N):
  number_sum[i]=number_sum[i-1]+number[i]
result[0]=abs(number_sum[0]*2-Sum)
for i in range(1,N-1):
  result[i]=abs(((number_sum[i])*2-Sum))

print(min(result))

Measured memory_bytes: 28700
#include <iostream>

int main()
{
    bool n = false, s = false, w = false, e = false;
    char buf;
    while(std::cin >> buf)
    {
        switch(buf)
        {
        case 'N':
            n = true;
            break;
        case 'S':
            s = true;
            break;
        case 'W':
            w = true;
            break;
        case 'E':
            e = true;
            break;
        }
    }
    std::cout << (!(n ^ s) && !(w ^ e) ? "Yes" : "No") << std::endl;
    return 0;
}


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

const int k = 300;
int n, m;
int cnt[100002];

void sub(int l, int r) {
  int prev_pl = 1e9;
  for (int i = 1; i <= k; ++i) {
    int pl = (l + i - 1) / i;
    int pr = (r + i - 1) / i;
    pr = min(pr, prev_pl);
    ++cnt[pl];
    --cnt[pr];
    prev_pl = pl;
  }
  
  for (int j = 1; j < prev_pl; ++j) {
    if ((l + j - 1) / j * j < r) {
      ++cnt[j];
      --cnt[j + 1];
    }
  }
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int l, r;
    cin >> l >> r;
    ++r;
    sub(l, r);
  }
  
  partial_sum(cnt, cnt + m + 2, cnt);
  for (int j = 1; j <= m; ++j) {
    cout << cnt[j] << endl;
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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 (b < a) { a = b; return 1; } return 0; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c; cin >> c;
    if (c >= 'A' && c <= 'Z') cout << "A\n";
    else cout << "a\n";
    return 0;
}

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

bool IsOneBit(int bits, int i) {
	return (bits & (1 << i)) > 0;
}
int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> truth;
	vector<pair<int, int>> untruth;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		for (int j = 0; j < A; j++) {
			int x, y;
			cin >> x >> y;
			if (y == 0) untruth.push_back({ i,x-1 });
			else truth.push_back({ i,x-1 });
		}
	}

	int Max = 0;
	for (int i = 0; i < (1 << N); i++) {
		bool B = true;
		for (const auto &tp : truth) {
			if (IsOneBit(i,tp.first) && !IsOneBit(i,tp.second)) B=false;
			if (!B) break;
		}
		if (!B) continue;
		for (const auto& tp : untruth) {
			if (IsOneBit(i, tp.first) && IsOneBit(i, tp.second)) B = false;
			if (!B) break;
		}
		if (!B) continue;
		int ans = 0;
		for (int j = 0; j < N; j++) ans += IsOneBit(i, j);
		Max = max(ans, Max);
	}
	cout << Max << endl;
}


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

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

int main(){
  int N, K;
  cin >> N >> K;

  vector<int> H(N);
  rep(i,N){
    cin >> H.at(i);
  }

  sort(H.begin(), H.end(),  std::greater<int>());

  int64_t ans=0;
  if(K>=N) cout << 0;
  else{
    for(int i=K; i<N; i++){
      ans += H.at(i);
    }
    cout << ans;
  }
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 310;

//head

int n;
int a[N], cnt[4];
ld _[N][N][N];

ld dfs(int i, int j, int k) {
	if(_[i][j][k] > -0.5) return _[i][j][k];
	ld &res = _[i][j][k] = 0;
	int n_ = i+j+k;
	if(i) res += dfs(i-1, j, k) * i/n_;
	if(j) res += dfs(i+1, j-1, k) * j/n_;
	if(k) res += dfs(i, j+1, k-1) * k/n_;
	if(n_) res += (ld)n/n_;
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) cnt[a[i]]++;
	rep(i, n+1) rep(j, n+1) rep(k, n+1) _[i][j][k] = -1;
	cout << fixed << setprecision(20) << dfs(cnt[1], cnt[2], cnt[3]) << endl;
}

Measured memory_bytes: 443868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,K; cin >> N >> K;
	if(N%2==1) YN(N/2+1>=K);
	else YN(N/2>=K);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,m; cin >> n >> m;
    vector<ll> x(m);
    rep(i,m) cin >> x[i];
    sort(all(x));
    vector<ll> dif(m-1);
    ll sum = 0;
    rep(i,m-1){
        dif[i] = x[i+1] - x[i];
        sum += dif[i];
    }
    sort(all(dif),greater<ll>());
    rep(i,min(n-1, m-1))sum -= dif[i];
    cout << sum << endl;

}

Measured memory_bytes: 1792
p = input().split()

k = int(p[0])
s = int(p[1])

x = -1
y = -1
z = 0
answer = 0

for num in range(k+1):
    x += 1
    y = -1
    for n in range(k+1):
        y += 1
        z = s - x - y
        if 0 <= z and z <= k:
            answer += 1
 



print(answer)     

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  vector<int>x(n);
  vector<int>y(n);
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  int ans=0;
  for(int i=0;i<n;i++){
    long l=pow(x[i],2)+pow(y[i],2);
    if(pow(d,2)>=l)ans++;
  }
  cout<<ans<<endl;
}
    
  

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  int a[210000];
  list<int> b;
  int res=0;
  cin >> N;

  rep(i,N) cin >> a[i];

  rep(i,N){
    if(i%2==0) b.push_back(a[i]);
    if(i%2==1) b.push_front(a[i]);
  }
  if(N%2==1) b.reverse();

  for(auto it:b) cout << it << endl;

}


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

int main() {
  string S, T;
  cin >> S >> T;
  bool ans = false;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == T.at(i)) {
      ans = true;
    }
    if (S.at(i) != T.at(i)) {
      ans = false;
      break;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
	int A,B,C,X,Y,sum=0,ans=1000000000;
	cin>>A>>B>>C>>X>>Y;
	for(int i=0;i<max(X,Y)+1;i++)
	{
		sum+=(i*C*2);
		if(X>i)sum+=((X-i)*A);
		if(Y>i)sum+=((Y-i)*B);
		ans=min(sum,ans);
		//cout<<sum<<endl;
		sum=0;
	}
	cout<<ans;
	}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
const ll INF=1e18+5;
int main() {
    IO;
    int arr[5];
    for(int i = 0; i< 5 ; i++)cin>>arr[i];
    for(int i = 0 ;i< 5 ; i++){
        if(arr[i]==0){
            cout<<i+1<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int ans[510][510];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    string S[510];
    rep(i, H) cin >> S[i];
    int num = 1;
    int upper = 0;
    rep(i, H) {
        int cnt = 0;
        bool update = false;
        int left = 0;
        rep(j, W) {
            if (S[i][j] == '#') {
                update = true;
                if (cnt == 0) cnt++;
                else {
                    REP(r, upper, i) {
                        REP(c, left, j - 1) {
                            ans[r][c] = num;
                        }
                    }
                    num++;
                    left = j;
                }
            }
        }
        if(cnt > 0) {
            REP(r, upper, i) {
                REP(c, left, W - 1) {
                    ans[r][c] = num;
                }
            }
            num++;
        }
        if(update) upper = i + 1;
        // rep(r, H) {
        //     rep(c, W) {
        //         if (c != 0) cout << " ";
        //         cout << ans[r][c];
        //     }
        //     cout << endl;
        // }
        // cout << endl;
    }
    rep(i, H) rep(j, W) if(ans[i][j] == 0) ans[i][j] = ans[i - 1][j];
    rep(i, H) {
        rep(j, W) {
            if (j != 0) cout << " ";
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}
// .....
// ..#.#
// #..#.

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

int N;

int main()
{
    cin >> N;
    vector<long long> sum(N);
    for (int i = 0; i<N; i++)
    {
        int tmp;
        cin >> tmp;
        if (i == 0) sum[0] = tmp;
        else sum[i] = sum[i-1] + tmp;
    }
    long long res = -1;
    for (int i = 0; i < N-1; i++)
    {
        if (res < 0 || res > abs(sum[N - 1] - 2 * sum[i]))
            res = abs(sum[N - 1] - 2 * sum[i]);
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  int x,y,k=0;
  cin >> x >> y;
  
  for(int i=0;i<=x;i++){
      if(4*i + 2*(x-i) == y){
        k = -1;
      }
    }
  
  if(k == -1) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
int main(){
  int n,k;cin >> n >> k;
  vector<int> a(n);
  rep(i,n)cin>>a[i];
  rep(i,k){
    vector<int> b(n+1);
    rep(j,n){
      int l=max(0,j-a[j]);
      int r=min(a[j]+j+1,n);
      b[l]++,b[r]--;
    }
    rep(j,n)b[j+1]+=b[j];
    if(a==b)break;
    a=b;
  }
  rep(i,n)cout << a[i] << endl;
}

Measured memory_bytes: 5608
x, y = list(map(int, input().split()))
#    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
m = [0, 0, 2, 0, 1, 0, 1, 0, 0, 1,  0,  1,  0]
print('Yes' if m[x]==m[y] else 'No')

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
	int n, total;

	while (cin >> n){
		total = 0;

		for (int a = 0; a <= 9; a++){
			for (int b = 0; b <= 9; b++){
				for (int c = 0; c <= 9; c++){
					for (int d = 0; d <= 9; d++){
						if (a + b + c + d == n){
							total++;
						}
					}
				}
			}
		}
		cout << total << endl;
	}
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */

ll ch2(ll n){
    return n*(n-1)/2;
}

int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        a[i]--;
    }
    vector<int> cnt(n);
    rep(i,n){
        cnt[a[i]]++;
    }
    ll sum = 0;
    rep(i,n){
        sum += ch2(cnt[i]);
    }
    rep(i,n){
        ll ans = sum;
        ans -= ch2(cnt[a[i]]);
        ans += ch2(cnt[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, A, B, C; cin >> N >> A >> B >> C;
    vector<char> ans(N);
    vector<string> s(N);
    rep(i, N) cin >> s[i];
    rep(i, N) {
        if (s[i] == "AB") {
            if (A == 0 && B == 0) {
                cout << "No" << endl;
                return 0;
            }
            if (A > B) {
                A--;
                B++;
                ans[i] = 'B';
            }
            else if (A < B) {
                A++;
                B--;
                ans[i] = 'A';
            }
            else if (A > 1 || i == N-1){
                A++;
                B--;
                ans[i] = 'A';
            }
            else {
                if (s[i+1][0] == 'A') {
                    A++;
                    B--;
                    ans[i] = 'A';
                }
                else {
                    A--;
                    B++;
                    ans[i] = 'B';
                }
            }
        }
        else if (s[i] == "AC") {
            if (A == 0 && C == 0) {
                cout << "No" << endl;
                return 0;
            }
            if (A > C) {
                A--;
                C++;
                ans[i] = 'C';
            }
            else if (A < C) {
                A++;
                C--;
                ans[i] = 'A';
            }
            else if (A > 1 || i == N-1){
                A++;
                C--;
                ans[i] = 'A';
            }
            else {
                if (s[i+1][0] == 'A') {
                    A++;
                    C--;
                    ans[i] = 'A';
                }
                else {
                    A--;
                    C++;
                    ans[i] = 'C';
                }
            }
        }
        else {
            if (C == 0 && B == 0) {
                cout << "No" << endl;
                return 0;
            }
            if (C > B) {
                C--;
                B++;
                ans[i] = 'B';
            }
            else if (C < B) {
                C++;
                B--;
                ans[i] = 'C';
            }
            else if (B > 1 || i == N-1){
                B++;
                C--;
                ans[i] = 'B';
            }
            else {
                if (s[i+1][0] == 'B' || s[i+1][1] == 'B') {
                    B++;
                    C--;
                    ans[i] = 'B';
                }
                else {
                    B--;
                    C++;
                    ans[i] = 'C';
                }
            }
        }
    }
    cout << "Yes" << endl;
    rep(i, N) {
        cout << ans[i] << endl;
    }
}


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int minnum,maxnum;
  maxnum = min(b,c);
  if(a<b+c) minnum=b+c-a;
  else minnum=0;
  cout<<maxnum<<' '<<minnum<<endl;
}

Measured memory_bytes: 256
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : Wednesday August 19, 2020
 */

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof(arr))
#define finally(value) {cout << value << '\n'; return;}
#define ll    int64_t

const int oo = int(1e9);
const ll lloo  = (ll)(1e18);
const int N = int(1001);

const int MOD = int(1e9+7);

template<typename T>
T sub(T a, T b) {
    return ((a-b)%MOD + MOD) % MOD;
}

template<typename T>
T add(T a, T b) {
    return ((a%MOD) + (b%MOD)) % MOD;
}

template<typename T>
T mul(T a, T b) {
    return ((a%MOD) * (b%MOD)) % MOD;
}

template<typename T>
T power(T a, T b) {
    T answer = (T)1;
    while (b > 0) {
        if (b & 1) {
            answer = mul(answer, a);
        }
        a = mul(a, a);
        b >>= 1;
    }
    return answer;
}

template<typename T>
T inverse(T a) {
    a %= MOD;
    if (a < 0) a += MOD;
    T b = MOD, u = 0, v = 1;
    while (a) {
        T t = b / a;
        b -= t * a; swap(a, b);
        u -= t * v; swap(u, v);
    }
    assert(b == 1);
    if (u < 0) u += MOD;
    return u;
}

template<typename T>
T divi(T a, T b) {
    return mul(a ,  inverse(b));
}


class Task {
public:
    int H, W;
    vector<vector<char>> grid;
    int dp[N][N];

    int go(int row, int col) {
        if(row<0 || col <0) return 0;
        if(row==0 && col == 0) return 1;
        if(grid[row][col] == '#') return 0;
        int &ans = dp[row][col];
        if(ans != -1) return ans;
        ans = 0;
        ans = add(ans, go(row-1, col));
        ans = add(ans, go(row, col-1));
        return ans;
    }

    void solveOne(istream &in, ostream &out) {
        in >> H >> W;
        string line;
        grid.clear();
        grid.resize(H, vector<char>(W));

        for(int i = 0; i < H; ++i){
            in >> line;
            for(int j = 0; j < W; ++j){
                grid[i][j] = line[j];
            }
        }
        ms(dp, -1);
        int ans = go(H-1, W-1);
        finally(ans);
    }
    
    void solve(istream &in, ostream &out) {
        int t=1;
        while(t--) solveOne(in, out);
    }
};

auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 8580
#include <stdio.h>

int main(void) {
	int N, D, X;
	int A[128];
	int i;
	int tomatuharuka = 0;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%d%d", &D, &X) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}

	for (i = 0; i < N; i++) {
		tomatuharuka += (D + A[i] - 1) / A[i];
	}
	printf("%d\n", X + tomatuharuka);

	return 0;
}


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

typedef long long lint;
#define fint register int
#define flint register lint

inline int ty()
{
	fint a=0,b=1,c=getchar();
	while(!isdigit(c))b^=c=='-',c=getchar();
	while(isdigit(c))a=a*10+c-48,c=getchar();
	return b?a:-a;
}

const int _ = 1000007 , mo = 1000000007;

int n;
lint f[_]={0};

int main()
{
	n=ty();

	f[n]=n,f[n-1]=1ll*n*n%mo;
	flint sf=0;
	for(fint i=n-2;i>=1;i--)
	{
		sf=(sf+f[i+3])%mo;
		f[i]=(f[i+1]+(1ll*n-1)*(1ll*n-1)%mo+sf+i+1)%mo;
	}
	printf("%lld\n",f[1]);
	return 0;
}


Measured memory_bytes: 8064
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let xs: Vec<u64> = sc.chars().iter().map(|&c| ((c as u8) - ('0' as u8)) as u64).collect();
    put!(max!(
        xs.iter().sum::<u64>(),
        xs[0] - 1 + 9 * (xs.len() - 1) as u64
    ));
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define M 1000000007
#define N 1005
LL t=1,ans=1,i;
int m,n;
LL a(int x)
{
    LL ans=1;
    for(i=1;i<=x;i++)
        ans=((ans%M)*i)%M;
    return ans;

}
int main()
{
    scanf("%d%d",&n,&m);
    if(n-m>1||m-n>1)
    {
    printf("0");
    return 0;
    }
    if(n==m){printf("%lld",(2*(a(m)%M)*(a(n)%M))%M);
    return 0;}
    printf("%lld",((a(m)%M)*(a(n)%M))%M);


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;

vector<vector<int> > g;  // to
vector<int> vis;
vector<int> pars;

void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    g.resize(n);
    pars.resize(n);
    vis.resize(n);
    int i;
    for (i = 0; i < m; i++) {
        int a, b;
        scanf("%d%d", &a, &b); a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> que;
    que.push(0);
    vis[0] = 1;

    while (!que.empty()) {
        int curr=que.front();
        que.pop();

        for (i = 0; i < (int)g[curr].size(); i++) {
            int next = g[curr][i];
            if (vis[next]) continue;
            pars[next] = curr;
            vis[next] = 1;
            que.push(next);
        }     


    }



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

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 10188
#include <bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int N,M;
  cin>>N>>M;
  Graph ship(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    ship.at(a).push_back(b);
    ship.at(b).push_back(a);
  }

  bool flag=false;
  for(auto x:ship.at(0)){
    for(auto y:ship.at(x)){
      if(y==N-1){
        flag=true;
        break;
      }
    }
    if(flag){
      break;
    }
  }
  if(flag){
    cout<<"POSSIBLE"<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
}


Measured memory_bytes: 12016
#include <bits/stdc++.h>
 
typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout<<i<<endl;
#define AS(i) cout<<i<<" ";
 
const int INF = 1001001001;
 
using namespace std;
 
int main() {

    int n, k;
    cin >> n >> k;

    int next = n;
    int cut = 0;
    while (next >= k) {
        next /= k;
        cut++;
    }
    cut++;

    cout << cut << endl;
}

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

struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
} ;

int flag = 0;

typedef struct node Node;

Node *root, *NIL;

void Insert(int);
void Inorder(Node *);
void Preorder(Node *);
void Find(Node *, int);

int main()
{
  int n,i,a;
  char in[7],insert[7] = "insert",find[5] = "find",print[6] = "print";
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%s",in);
    (void)getchar();
    if(strcmp(in, insert) == 0) {
      scanf(" %d",&a);
      Insert(a);
    }
    else if(strcmp(find, in) == 0) {
      scanf("%d",&a);
      Find(root,a);
      if(flag == 1) printf("yes\n");
      else printf("no\n");
      flag = 0;
    }
    else  {
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void Insert(int a) {
  Node *b = NIL;
  Node *c = root;
  Node *d;

  d = malloc(sizeof(Node));
  d -> key = a;
  d -> left = NIL;
  d -> right = NIL;
  while(c != NIL) {
    b = c;
    if(d -> key < c -> key) c = c -> left;
    else  c = c -> right;
  }

  d -> parent = b;
  if(b == NIL)  root = d;
  else {
    if(d -> key < b -> key)  b -> left = d;
    else    b -> right = d;
  }
}

void Inorder(Node *u) {
  if(u == NIL) return;
  else {
    Inorder(u -> left);
    printf(" %d", u->key);
    Inorder(u -> right);
  }
}

void Preorder(Node *u) {
  if(u == NIL) return;
  else {
    printf(" %d", u->key);
    Preorder(u -> left);
    Preorder(u -> right);
  }
}

void Find(Node *u, int k) {
    if(u == NIL) return;
  else {
    if(u -> key == k) {
      flag = 1;
      return;
    }
  }
    if(u -> key > k) {
      Find(u -> left, k);
      return;
    }
    else {
      Find(u -> right, k);
      return;
  }
}


Measured memory_bytes: 20484
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<mint> d(k+1), d2(k+1);
    for(int i = 1; i <= k; i++) {
        //全部iの倍数
        d2[i] = ((mint)(k/i)).pow(n);
    }
    mint ans = 0;
    for(int i = k; i >= 1; i--) {
        //
        d[i] = d2[i];
        for(int j = 2; j*i <= k; j++) {
            d[i] -= d[j*i];
        }
        ans += d[i] * i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4836
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int n;
vector<mp> vs[805];
int gone[805];
//fir ?????? sec ??????

mp dfs(int no,int p){
	if(vs[no].size()==1 && vs[no][0].fir==p){
		return mp(0,0);
	}
	
	vector<mp> nps;
	int oc=0;
	rep(i,vs[no].size()){
		mp pa=vs[no][i];
		int to=pa.fir,co=pa.sec;
		if(to==p)continue;
		
		mp np=dfs(to,no);
		np.fir+=co;
		np.sec+=co*2;
		oc+=np.sec;
		nps.push_back(np);
	}
	
	int kc=oc;
	rep(i,nps.size()){
		kc= min(kc,oc-nps[i].sec+nps[i].fir);
	}
	return mp(kc,oc);
}

int main(void){
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		rep(i,805)vs[i].clear();
		
		int ids[805][2];
		rep(j,2)
			rep(i,n-1)
				scanf("%d",&ids[i][j]);
		
		int bn[805]={};
		rep(i,n-1)bn[ids[i][0]]++;
		reg(i,2,n)bn[i]++;
		
		int bs=0;
		rep(i,n-1){
			int a=ids[i][0],b=i+2;
			bs+=ids[i][1];
			if(bn[a]==1 || bn[b]==1)continue;
			vs[a].push_back(mp(b,ids[i][1]));
			vs[b].push_back(mp(a,ids[i][1]));
		}
		//printf("bs .. %d\n",bs);
		int ans=INT_MAX;
		reg(i,1,n){
			if(bn[i]==1)continue;
			mp pa = dfs(i,-1);
			ans = min(ans,pa.fir);
		}			
		printf("%d\n",ans+bs);
	}
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t { as swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;
using XY = pair<int, int>;
//#include<bits/stdc++.h>

int main() {
    vector<int> n(3);
    for(auto &v:n) cin >> v;
    sort(n.begin(), n.end());
    auto a = n[0], b = n[1], c = n[2];
    auto count = c - b;
    count += (b - a) / 2;
    if ((b - a) % 2 == 1) count += 2;
    cout << count;
}



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

using namespace std;

int main(){
  //それぞれの数の入力
  int64_t A, B, C;
  cin >> A >> B >> C;
  //何枚選ぶか
  int64_t K;
  cin >> K;
  //答えans
  int64_t ans;
  //K<A ans = K
  //K< A+B ans =A(同上)
  //それ以外はans = A-(K-A-B)=2A+B-K
  if (K < A){
    ans = K;
  }
  else if(K < A+B){
    ans = A;
  }
  else{
    ans = 2*A + B - K;
  }

  cout << ans << endl;
}


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

int r, c, n, x, y, z, t;
vector <pair <int, int> > arr;
stack<int> key;
bool check(int x, int y) {
	if(x != 0 && x != r && y != 0 && y != c) return false;
	return true;
}
int encode(int x, int y) {
	int ans = 0;
	if(x == 0) ans = y;
	else if(x == r) ans = r + 2*c - y;
	else if(y == 0) ans = 2*r + 2*c - x;
	else if(y == c) ans = c + x;
	return ans;
}
int main() {
	scanf("%d%d%d", &r, &c, &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d%d%d%d", &x, &y, &z, &t);
		if(check(x, y) && check(z, t)) {
			int a = encode(x, y), b = encode(z, t);
			if(a > b) swap(a, b);
			arr.push_back({a, i});
			arr.push_back({b, -i});
		}
	}
	sort(arr.begin(), arr.end());
	for(int i = 0; i < arr.size(); i++) {
		if(arr[i].second > 0) key.push(arr[i].second);
		else {
			if(not key.empty() && arr[i].second + key.top() == 0) key.pop();
			else return !printf("NO");
		}
	}
	printf("YES");
}

Measured memory_bytes: 2420
#include <stdio.h>

int main(void) {
    int N;
    scanf("%d", &N);

    int array[N];
    for (int i=0; i<N; i++) {
        scanf("%d", &array[i]);
    }

    int sum = 0;
    for (int i=0; i<N; i++) {
        sum += array[i] - 1;
    }

    printf("%d\n", sum);
}


Measured memory_bytes: 128
L = [int(i) for i in input().split()]
N = sorted(L)
if N[0] < N[2]+ N[1] and N[1] < N[0] + N[2] and N[2] < N[1] + N[0] and N[0]==N[2]:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <stdio.h>

long long int min(long long int a, long long int b){
	if(a < b){
		return a;
	}
	else{
		return b;
	}
}

int main(){
	long long int N, A, B, i;
	scanf("%lld%lld%lld", &N, &A, &B);
	long long int X[N], res = 0;
	for(i = 0; i < N; i++){
		scanf("%lld", &X[i]);
	}
	for(i = 1; i < N; i++){
		res += min(A*(X[i] - X[i-1]), B);
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 896
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

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

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    string S; cin >> S;

    int f=1;
    for (auto s : S)
    {
        if (f >0) cout << s;
        f *= -1;
    }
    cout << endl;


    return 0;
}



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

int ketasum(int n){
  int sum = 0;
  while (n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  sort(s.begin(), s.end());
  string S;
  for(int i = 0; i < n; i++){
    S += s[i];
  }

  cout << S << endl;
}


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

namespace AtCoderRegularContest069
{
    public class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(program1(new String[] { Console.ReadLine(), Console.ReadLine() }));
        }

        public static string program1(string[] args)
        {
            var n = int.Parse(args[0]);
            var s = args[1].ToCharArray();

            var animalPattern = new List<char>[] { new List<char>() { 'S', 'S' }, new List<char> { 'S', 'W' }, new List<char> { 'W', 'W' }, new List<char> { 'W', 'S' } };

            return string.Join("", animalPattern.Select(animals =>
            s.Skip(1).Aggregate(animals, (ani, ans) =>
            {
                if (ani.Last() == 'S' && ans == 'x' || ani.Last() == 'W' && ans == 'o')
                {
                    ani.Add(ani.ElementAt(ani.Count() - 2) == 'S' ? 'W' : 'S');
                }
                else
                {
                    ani.Add(ani.ElementAt(ani.Count() - 2));
                }
                return ani;
            }))
            .Where(animals => animals.First() == animals.Last())
            .Select(animals => animals.Take(n))
            .FirstOrDefault(animals => {
                if (s.First() == 'o' && animals.First() == 'S' || s.First() == 'x' && animals.First() == 'W')
                {
                    return animals.ElementAt(1) == animals.Last();
                }
                else
                {
                    return animals.ElementAt(1) != animals.Last();
                }
            }) ?? new List<char>() { '-', '1' }) ;
        }
    }
}


Measured memory_bytes: 16736
for e in iter(input, "0 0"):
    
    n,x=map(int,e.split())

    i = 1
    j = i + 1
    k = i + 2

    result = 0

    while True:
        if i + j + k == x:
            result += 1
        
        k += 1

        if n < k:
            j += 1
            k = j + 1
            if n < k:
                i += 1
                j = i + 1
                k = j + 1 
                if n < k:
                    break

    print(result)



Measured memory_bytes: 5596
import java.util.Scanner;
    
class Main{
 Scanner sc;
    int a,b;
    
    public void solve(){
        sc = new Scanner(System.in);   
        sub();
        sub();
        sub();
        sub();
        sub();
        sub();
        sub();
    }
    void sub(){ 
        a = sc.nextInt();
        b = sc.nextInt();
        System.out.println(a-b);
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 17352
import java.util.*;
import static java.lang.System.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String al="abcdefghijklmnopqrstuvwxyz";
        String N = sc.next();
        String ans="a";
        
        for (int i = 0; i < 26; i++) {
            if (N.equals(al.substring(i,i+1))) {
                ans = al.substring(i+1,i+2);
            }

        }
        out.print(ans);
       
    }
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if(b==1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    b -= a;
    a--;
    ans += (b + a - 1) / a;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
    int i;
    int N;
    int a,b,c;
    int x;

    scanf("%d", &N);
    for (i = 0; i < N; i++){
        scanf("%d %d %d", &a, &b, &c);
        if (a > b){
            x = a;
            a = b;
            b = x;
        }
        if (b > c){
            x = b;
            b = c;
            c = x;
        }
        if (a > b){
            x = a;
            a = b;
            b = x;
        }
        if ((a * a) + (b * b) == (c * c)){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }

    return (0);
}




Measured memory_bytes: 2032