akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N; 
	vector<int>Num(3);
	cin >> N>>Num[0]>>Num[1]>>Num[2];
	vector<string>S(N); 
	vector<string>Ans(N);
	map<string, int>mp;
	mp["A"] = 0; 
	mp["B"] = 1; 
	mp["C"] = 2;
	for (int n = 0; n < N; ++n) {
		cin >> S[n];
	}
	
	for (int n = 0; n < N; ++n) {
		//cout << Num[0] <<"_"<< Num[1] << "_"<<Num[2]<<endl;
		// 0,0
		if ((0 == Num[mp[S[n].substr(0, 1)]]) && (0 == Num[mp[S[n].substr(1, 1)]])) {
			cout << "No" << endl;
			return 0;
		}
		// 0,1
		else if((1 == Num[mp[S[n].substr(0, 1)]] + Num[mp[S[n].substr(1, 1)]])) {
			if (Num[mp[S[n].substr(0, 1)]] > Num[mp[S[n].substr(1, 1)]]) {
				Num[mp[S[n].substr(0, 1)]]--;
				Num[mp[S[n].substr(1, 1)]]++;
				Ans[n] = S[n].substr(1, 1);
			}
			else {
				Num[mp[S[n].substr(0, 1)]]++;
				Num[mp[S[n].substr(1, 1)]]--;
				Ans[n] = S[n].substr(0, 1);
			}
		}
		// 1,1
		else if ((1 == Num[mp[S[n].substr(0, 1)]])&&(1 == Num[mp[S[n].substr(1, 1)]])) {
			if (n == N-1) {//ラストターン
				Ans[n] = S[n].substr(0, 1);
			}
			else if (S[n] == S[n+1]) {//次も同じ
				Num[mp[S[n].substr(0, 1)]]++;
				Num[mp[S[n].substr(1, 1)]]--;
				Ans[n] = S[n].substr(0, 1);
			}
			else {
				if ((S[n].substr(0, 1) == S[n+1].substr(0, 1))|| (S[n].substr(0, 1) == S[n + 1].substr(1, 1))) {
					Num[mp[S[n].substr(0, 1)]]++;
					Num[mp[S[n].substr(1, 1)]]--;
					Ans[n] = S[n].substr(0, 1);
				}
				else {
					Num[mp[S[n].substr(0, 1)]]--;
					Num[mp[S[n].substr(1, 1)]]++;
					Ans[n] = S[n].substr(1, 1);
				}
			}
		}
		//その他
		else {
			if (Num[mp[S[n].substr(0, 1)]] > Num[mp[S[n].substr(1, 1)]]) {
				Num[mp[S[n].substr(0, 1)]]--;
				Num[mp[S[n].substr(1, 1)]]++;
				Ans[n] = S[n].substr(1, 1);
			}
			else {
				Num[mp[S[n].substr(0, 1)]]++;
				Num[mp[S[n].substr(1, 1)]]--;
				Ans[n] = S[n].substr(0, 1);
			}
		}
	}


	cout <<  "Yes"<< endl;
	for (int n = 0; n < N; ++n) {
		cout << Ans[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 9584
import numpy as np
A = np.array([list(map(int, input().split())) for i in range(3)])
N = int(input())
for i in range(N):
    A = np.where(A == int(input()), 0, A)
if (np.any(np.sum(A, axis = 0) == 0) or 
    np.any(np.sum(A, axis = 1) == 0) or
    np.trace(A) == 0 or
    np.trace(np.fliplr(A)) == 0):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27336
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#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 <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n, k;
  cin >> n >> k;
  cout << min(n % k, k - n % k) << endl;  

  return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
lst = []
if y < x * 2 or y > x * 4 :
    print('No')
else :
    i = x * 2
    while i <= x * 4 :
        lst.append(i)
        i += 2
    if y in lst :
        print('Yes')
    else :
        print('No')


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  int n,m;
  cin >> n >> m;
  int sum = 0;
  vi a(n);
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  sort(all(a),greater<int>());
  if(a[m-1]*4*m >= sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

struct Edge {
    int64 v, b, c;
    Edge() {}
    Edge(int64 v, int64 b, int64 c) : v(v), b(b), c(c) {}
    bool operator> (const Edge& rhs) const {
      return c > rhs.c;
    }
  };

int64 N, M, L, K, A, H;
vector<Edge> G[110][110];

void solve() {
  REP(i, 110) REP(j, 110) G[i][j].clear();
  REP(i, L) {
    int64 v;
    cin >> v;
    REP(j, M) G[v][j].emplace_back(v, j+1, 1);
  }
  REP(i, K) {
    int64 u, v, c;
    cin >> u >> v >> c;
    REP(j, M+1) {
      if (j >= c) {
        G[u][j].emplace_back(v, j-c, c);
        G[v][j].emplace_back(u, j-c, c);
//        cout << "(" << u << " " << j << ") -> (" << v << " " << j-c << " " << c << ")" << endl;
      }
    }
  }
  priority_queue<Edge, vector<Edge>, greater<Edge>> pq;
  auto d = make_v<int64>(N, M+1);
  fill_v<int64>(d, INF_LL);
  d[A][M] = 0;
  pq.emplace(A, M, 0);
  while (pq.size()) {
    Edge v;
    v = pq.top(); pq.pop();
    for (auto& e : G[v.v][v.b]) {
      if (d[e.v][e.b] > v.c + e.c) {
        d[e.v][e.b] = v.c + e.c;
        pq.emplace(e.v, e.b, d[e.v][e.b]);
      }
    }
  }
  int64 res = *min_element(all(d[H]));
  if (res == INF_LL) cout << "Help!" << endl;
  else cout << res << endl;
}

int main(void) {
  while (cin >> N >> M >> L >> K >> A >> H && N+M+K+L+A+H) {
    solve();
  }
}




Measured memory_bytes: 10536
A, B = map(int, input().split())

# 1 ^ ... ^ n
# 0-1, 2-3, 4-5, ... でペアを作る
def g(n):
    one = (n + 1) // 2
    ret = one % 2

    if n % 2 == 0:
        ret ^= n

    return ret

ans = g(A - 1) ^ g(B)
print(ans)

Measured memory_bytes: 2940
#include <stdio.h>
int main(){
    int N;
    long long Y ;
    scanf("%d %lld", &N,&Y);
    
    for(int a = 0; a <= N && 10000*a <= Y ; a++){
        for(int b = 0; a+b <= N && 10000*a+5000*b <= Y ; b++){
            if(9000*a+4000*b == Y-1000*N){
                printf("%d %d %d\n", a, b, N-a-b);
                return 0;
            }
        }
    }
    puts("-1 -1 -1");
}

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

typedef struct {
	int time;
	int x;
	int y;
} coord;

int time_sort(const void* pt1, const void* pt2) {
	return ((coord*)pt1)->time - ((coord*)pt2)->time;
}

int main() {
	int N, i, d, t, flg = 0;
	coord pts[100010];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d%d%d", &pts[i].time, &pts[i].x, &pts[i].y);
	pts[N].time = pts[N].x = pts[N].y = 0;
	qsort(pts, N + 1, sizeof(coord), time_sort);
	for (i = 1; i <= N; i++) {
		d = abs(pts[i].x - pts[i - 1].x) + abs(pts[i].y - pts[i - 1].y);
		t = pts[i].time - pts[i - 1].time;
		if (d > t || (t - d) % 2 != 0) {
			flg = 1;
			break;
		}
	}
	printf("%s", flg ? "No" : "Yes");
	return 0;
}

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

int N;

int main(){
	N = 10;
	int t;
	int mh[N];
	
	for(int i=0; i<10; i++){
		cin >> t;
		if(t>=0 && t<=10000)
			mh[i]=t;
		else{
			i=i-1;
		}
	}
	
	for(int i=0; i<10; i++){
		for(int j=i+1; j<10; j++){
			if(mh[i] < mh[j]){
				t = mh[i];
				mh[i] = mh[j];
				mh[j] = t;
			}
		}
	}
	
	for(int i=0; i<3; i++)
		cout << mh[i] << "\n";
	
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

double ave(double x,double y){
  return (x+y)/2.0;
}

int main(){
  double v[51],ans;
  int j,k,n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lf",&v[i]);
  }
  for(j=0;j<n-1;j++){
    for(k=j+1;k<n;k++){
      if(v[j]>v[k]){
        double tmp=v[j];
        v[j]=v[k];
        v[k]=tmp;
      }
    }
  }

  for(j=0;j<n-1;j++){
    if(j==0) ans=ave(v[j],v[j+1]);
    else ans=ave(ans,v[j+1]);
  //  printf("%lf\n",ans);
  }

  printf("%lf",ans);

//printf("%f",ave(v[1],v[0]));

  return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    string s;
    cin>> s;

    for(int i=0; i< s.size(); i++)
    {
        if( ( i%2== 0 && s[i] == 'L') or ( i%2== 1 && s[i] == 'R'))
        {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    return 0;
}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " "
#define outline(x) cout << x << endl;
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int b[n];
    arrinp(i, b, 0, n - 2);
    int sum = b[0];
    for(int i = 1; i < n - 1; i++)
    {
        sum += min(b[i], b[i - 1]);
    }    
    sum += b[n - 2];
    cout << sum << endl;
    return 0;
}

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

int seg[1<<21];
void add(int k,int l,int r,int a,int v){
	if(r-l==1){
		seg[k] +=v;
		return;
	}
	int m=(l+r)/2;
	if(a<m){
		add(2*k+1,l,m,a,v);
	}else{
		add(2*k+2,m,r,a,v);
	}
	seg[k] = max(seg[2*k+1],seg[2*k+2]);
}
int getMaxId(int k,int l,int r){
	if(r-l==1){
		return l;
	}
	int m=(l+r)/2;
	if(seg[2*k+1]>=seg[2*k+2])return getMaxId(2*k+1,l,m);
	return getMaxId(2*k+2,m,r);
}
int main(){
	int n,q;
	cin>>n>>q;
	while(q--){
		int a,v;
		cin>>a>>v;
		add(0,0,1<<20,a-1,v);
		a = getMaxId(0,0,1<<20)+1;
		cout<<a<<' '<<seg[0]<<endl;
	}
	return 0;
}

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

int main(){
  int n; cin>>n;
  long long T,t[n],ans=0; cin>>T;
  cin>>t[0];
  for(int i=1;i<n;i++){
    cin>>t[i];
    ans+=min(T,t[i]-t[i-1]);
  }
  cout<<ans+T<<endl;
}

Measured memory_bytes: 1792
N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
E = [0]*N
for i in range(N):
    E[i] = (1 + P[i])/2
ans = sum(E[0:K])
tmp = ans
for i in range(K,N):
    tmp = tmp + E[i] - E[i - K]
    ans = max(tmp, ans)
print(ans)

Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N;
    cin >> N;
    int A[N];
    int sum = 0;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
    }
    if(sum % (N * (N + 1) / 2) != 0) {
        cout << "NO" << endl;
        return 0;
    }
    sum = sum / (N * (N + 1) / 2);
    rep(i, N) {
        int X = A[N - 1 - i] + sum - A[(N - i) % N];
        if(X % N != 0 || X < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
const double eps = 1e-8;

struct Point {
    int x, y;

    double dist(Point that) {
        return sqrt((x - that.x) * (x - that.x) + (y - that.y) * (y - that.y));
    }

    double cross(Point a, Point b) {
        return (a.x - x) * (b.y - y) - (a.y - y) * (b.x - x);
    }
};

Point p0;

bool isZero(double x) { return fabs(x) < eps; }

bool cmp(Point a, Point b) {
    double k = p0.cross(a, b);
    return !(k < 0 || (isZero(k) && p0.dist(a) < p0.dist(b)));
}

class Solution {
public:
    void solve() {
        int n;
        cin >> n;
        vector<Point> p(n + 1);
        for (int i = 0; i < n; ++i) cin >> p[i].x >> p[i].y;
        if (n == 2) {
            cout << p[0].dist(p[1]) / 2;
            return;
        }

        int x = p[0].x;
        int y = p[0].y;
        int mi = 0;
        for (int i = 1; i < n; ++i) {
            if (p[i].x < x || (p[i].x == x && p[i].y < y)) {
                x = p[i].x;
                y = p[i].y;
                mi = i;
            }
        }
        swap(p[0], p[mi]);
        p0.x = p[0].x;
        p0.y = p[0].y;
        sort(p.begin() + 1, p.begin() + n - 1, cmp);
        p[n] = p[0];
        vector<Point> stack(n + 1);
        for (int i = 0; i < 3; ++i) {
            stack[i].x = p[i].x;
            stack[i].y = p[i].y;
        }
        int top = 2;
        for (int i = 3; i < n; ++i) {
            if (stack[top - 1].cross(stack[top], p[i]) < 0 && top >= 2) --top;
            stack[++top] = p[i];
        }

        double maxr = -1;
        double a, b, c, r, s;
        for (int i = 0; i < top; ++i) {
            for (int j = i + 1; j < top; ++j) {
                for (int k = j + 1; k <= top; ++k) {
                    a = stack[i].dist(stack[j]);
                    b = stack[i].dist(stack[k]);
                    c = stack[j].dist(stack[k]);
                    if (a * a + b * b < c * c || a * a + c * c < b * b ||
                        b * b + c * c < a * a)
                        r = max(max(a, b), c) / 2.0;
                    else {
                        s = fabs(stack[i].cross(stack[j], stack[k])) / 2.0;
                        r = a * b * c / (s * 4.0);
                    }
                    if (maxr < r) maxr = r;
                }
            }
        }
        printf("%.12lf", maxr);
    }
};

int main() {
    Solution solution = Solution();
    solution.solve();
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(n, vector<int>(n, -1));
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            int x, y;
            cin >> x >> y;
            v[i][x - 1] = y;
        }
    }

    int ret = 0;
    for (int bit = 0; bit < 1 << n; bit++) {
        vector<bool> now(n);
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                now[i] = true;
                count++;
            }
        }

        bool possible = true;
        for (int i = 0; i < n; i++) {
            if (now[i]) {
                for (int j = 0; j < n; j++) {
                    if (v[i][j] >= 0) {
                        if (v[i][j] > 0 != now[j])possible = false;
                    }
                }
            }
        }


        if (possible) ret = max(ret, count);
    }

    cout << ret << endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.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; }

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	string str;
	cin >> str;

	map<char, int> m;
	set<char> s;
	rep(i, str.length()){
		m[str[i]]++;
		s.insert(str[i]);
	}
	bool ans = true;
	for(auto t : s){
		if(m[t] % 2 != 0) ans = false;
	}

	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    ll n, m; cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    if(n == m) ans = 2;
    for(int i = 1; i <= n; i++){
        ans = ans * i % MOD;
    }
    for(int i = 1; i <= m; i++){
        ans = ans * i % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x) memset(x , 0 , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;

vector<int> cal(string s) {
  vector<int> Cnt(30 , 0);
  for(int i = 0; i < sz(s); i++) {
    Cnt[s[i] - 'a']++;
  }
  vector<int> a;
  for(int i = 0;i < 26; i++) {
    a.push_back(Cnt[i]);
  }
  sort(a.begin() , a.end());
  return a;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);

  string a, b;
  cin >> a >> b;

  vector<int> ca = cal(a);
  vector<int> cb = cal(b);

  if(ca == cb) {
    cout << "Yes" << '\n';
  }
  else cout << "No" << '\n';
}

Measured memory_bytes: 3464
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
#define MAX_N 200000
int v[MAX_N+1];
int main() {
	int N, K; cin >> N >> K;
	rep(i, N) {
		int tmp; cin >> tmp;
		v[tmp]--;
	}
	sort(v, v + MAX_N);
	int sum = 0;
	rep(i, MAX_N + 1) {
		if (v[i] == 0) break;
		sum++;
	}
	int sut = max(0, sum - K); sut = sum - sut;
	int s_sum = 0; int s_sut = 0;
	rep(i, MAX_N + 1) {
		if (v[i] == 0) break;
		if (i < sut) {
			s_sut -= v[i];
		}
		s_sum -= v[i];
	}
	cout << s_sum - s_sut << endl;
}

Measured memory_bytes: 4348
#include<stdio.h>
#include<string.h>
 
char s[100],p[100];
char S[200];
 
main(){
 
scanf("%s",s);
scanf("%s",p);
 
strcpy(S,s);
strcat(S,s);
 
if(strstr(S,p)!=NULL){
    printf("Yes\n");
    }
      
    else{
    printf("No\n");
    }
return 0;
}

Measured memory_bytes: 540
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), M = getint();

	int saishou = 1e9;
	int saidai = 0;
	rep(i, M) {
		chmax(saidai, getint());
		chmin(saishou, getint());
	}
	if (saidai > saishou) printf("0");
	else printf("%d", saishou - saidai + 1);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    string gyo1="";
    string gyo2="";
    for(int i=0;i<w;i++){
        if(i<a){
            gyo1+="0";
            gyo2+="1";
        }else{
            gyo1+="1";
            gyo2+="0";
        }
    }
    for(int i=0;i<h;i++){
        if(i<b){
            cout<<gyo1<<endl;
        }else{
            cout<<gyo2<<endl;
        }
    }
}

Measured memory_bytes: 1280
/*  ex3_3
    L40S38  */
#include<stdio.h>
int main(void){
  int N, K, r, digit;
  scanf("%d %d",&N, &K);
  //整数NをK進法で表す
  r=N;
  digit=0;
  while(r>0){
    //rはNをKでdigit回割ったときの商
    digit ++;
    r=r/K;
  }
  printf("%d",digit);
  return 0;
}    

Measured memory_bytes: 128
#include<iostream>
#include<utility>
#include<climits>

typedef std::pair<int, int> P;

const int MAX_N = 1 << 17;

int n;
// fst: -得点, snd: チームの番号
P dat[MAX_N * 2 - 1];

int cnt[MAX_N];

void init( int n_ )
{
	n = 1;
	while( n < n_ )
		n *= 2;

	for( int i = 0; i != n * 2 - 1; ++i )
		dat[i] = std::make_pair( INT_MAX, INT_MAX );

	return;
}

void update( int k, P x )
{
	k += n - 1;
	dat[k] = x;
	while( k > 0 )
	{
		k = (k - 1) / 2;
		dat[k] = std::min( dat[k*2+1], dat[k*2+2] );
	}

	return;
}

// [a,b)
P query( int a, int b, int k, int l, int r )
{
	if( a >= r || b <= l )
		return std::make_pair( INT_MAX, INT_MAX );
	
	if( a <= l && r <= b )
		return dat[k];
	else
	{
		P vl = query( a, b, k * 2 + 1, l, (l + r) / 2 );
		P vr = query( a, b, k * 2 + 2, (l + r) / 2, r );
		
		return std::min( vl, vr );
	}
}

int main()
{
	int N, R, L;
	std::cin >> N >> R >> L;

	init( N );
	for( int i = 0; i != N; ++i )
		update( i, std::make_pair( 0, i ) );

	int prevT = 0;
	for( int i = 0; i != R; ++i )
	{
		int d, t, x;
		std::cin >> d >> t >> x;

		--d;

		if( t != prevT )
		{
			P p = query( 0, N, 0, 0, n );
			cnt[p.second] += t - prevT;
		}

		P p = query( d, d + 1, 0, 0, n );
		update( d, std::make_pair( p.first - x, p.second ) );

		prevT = t;
	}

	if( prevT != L )
	{
		P p = query( 0, N, 0, 0, n );
		cnt[p.second] += L - prevT;
	}

	int t = -1, id;
	for( int i = 0; i != N; ++i )
	{
		if( t < cnt[i] )
		{
			t = cnt[i];
			id = i + 1;
		}
	}
	
	std::cout << id << std::endl;

	return 0;
}

Measured memory_bytes: 3600
def main():
    from sys import stdin
    readline = stdin.readline
    H, N = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]

    max_A = max(a for a, _ in AB)
    inf = 10 ** 9
    dp = [inf] * (H + max_A+ 1)
    dp[0] = 0
    for i in range(H):
        if dp[i] == inf:
            continue
        for a, b in AB:
            t = dp[i] + b
            if t < dp[i + a]:
                dp[i + a] = t
    print(min(dp[H:]))


main()


Measured memory_bytes: 3680
// CODING BEAST
/*******************************************************************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define Precision(a) cout << fixed << setprecision(a)

using ll = long long;
ll inf = 1e18;
using vb = vector<bool>; using vc = vector<char>; using vd = vector<double>; using vi = vector<int>; using vvi = vector<vi>;
using vll = vector<ll>; using vvll = vector<vll>; using pi = pair<int, int>; using pll = pair<ll, ll>;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i = 0; i < n; i++)
#define repc(i,a,n) for(ll i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define pow2(x) (1ll<<(x))
#define Blazing_fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trav(a,v) for(auto &a:v)
int a[8] = { -1, -1, -1, 0, 0, 1, 1, 1};
int b[8] = { -1, 0, 1, -1, 1, -1, 0, 1};
inline ll power(ll x, ll y)
{
    ll temp;
    if ( y == 0)
        return 1;
    temp = power(x, y / 2) ;
    if (y % 2 == 0)
        return (temp * temp) ;
    else
        return (x * temp * temp) ;
}
bool sortbysec(pll & a, pll & b) {
    return (a.second < b.second);
}
/*
ll fact(ll n)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
        res = (res * i) ;
    return res;
}

ll ncr(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}
bool isprime(ll n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if ((n % 2 == 0) || (n % 3 == 0)) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if ((n % i == 0) || (n % (i + 2) == 0)) return false;

    return true;
}*/
/*********************************************************************************************************************************************************/
signed main() {
    ll n; cin >> n;
    if (n >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

struct RAQ{
	using T = int;
	T operator()(const T &a, const T &b) { return a + b; };
	static constexpr T identity() { return 0; }
};

template<class Monoid>
class rangeUpdateQuery{
	private:
		using T = typename Monoid::T;
		Monoid op;
		const int n;
		vector<T> dat, lazy;
		int query(int a, int b, int k, int l, int r){
			if(b <= l || r <= a) return op.identity();
			else if(a <= l && r <= b) return dat[k] * (r - l) + lazy[k];
			else{
				int res = (min(b,r) - max(a,l)) * dat[k];
				res += query(a, b, k * 2, l, (l + r) / 2);
				res += query(a, b, k * 2 + 1, (l + r) / 2, r);
				return res;
			}
		}
		void add(int a, int b, int k, int l, int r, int x){
			if(a <= l && r <= b){
				dat[k] += x;
			}else if(l < b && a < r){
				lazy[k] += (min(b,r) - max(a,l)) * x;
				add(a, b, k * 2, l, (l + r) / 2, x);
				add(a, b, k * 2 + 1, (l + r) / 2, r, x);
			}
		}
		inline void evaluate(int k){
			if(lazy[k] == op.identity()) return;
			dat[k] = lazy[k];
			if(k < n){
				lazy[2 * k] += lazy[k];
				lazy[2 * k + 1] += lazy[k];
			}
			lazy[k] = op.identity();
		}
		int power(int n){
			int res = 1;
			while(n >= res) res*=2;
			return res;
		}
	public:
		rangeUpdateQuery(int n) : n(power(n)), dat(4 * n, op.identity()), lazy(4 * n, op.identity()) {}
		rangeUpdateQuery(const vector<T> &v) : n(v.size()), dat(4 * n), lazy(4 * n, op.identity()){
			copy(begin(v), end(v), begin(dat) + n);
			for(int i = n - 1; i > 0; i--) dat[i] = op(dat[2 * i], dat[2 * i + 1]);
		}
		int query(int a, int b){ return query(a,b,1,0,n); }
		void add(int s, int t, int x){ add(s, t, 1, 0, n, x); }
		int get(int a){ return query(a, a + 1); };
};

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

	rangeUpdateQuery<RAQ> seg(n);
	rep(i,q){
		int com;
		cin >> com;
		if(not com){
			int s, t, x;
			cin >> s >> t >> x;
			//cout << s << ' ' << t << endl;
			seg.add(s + 0, t + 1, x);
		}else{
			int p;
			cin >> p;
			cout << seg.get(p + 0) << endl;
		}
	}
}



Measured memory_bytes: 6020
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
struct edge{
    int to, cost;
    edge(int a = 0, int b = 0) : to(a), cost(b) {}
};
vector<pii> dijkstra(int s, vector<vector<edge>> &g,const int L){
    int n = (int)g.size();
    vector<pii> dist(n);
    rep(i,n)dist[i] = {n * 10, 0};
    using ll_i = pair<pii, int>;
    priority_queue<ll_i,vector<ll_i>,greater<ll_i>>pq;
    dist[s] = {0,-L};
    pq.push({dist[s], s});
    while(!pq.empty()){
        auto a = pq.top();
        pq.pop();
        int v = a.second;
        if(a.first > dist[v])continue;
        for(auto &x:g[v]){
            int num = a.first.first;
            int ren = -a.first.second;
            if(x.cost > L)continue;
            if(x.cost > ren){
                num++;
                ren = L;
            }
            ren -= x.cost;
            if(dist[x.to] > pii(num, -ren)){
                dist[x.to] = pii(num, -ren);
                pq.push({dist[x.to], x.to});
            }
        }
    }
    return dist;
}
//ll dist[300][300];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int m;
    cin >> m;
    int L;
    cin >> L;
//    rep(i,n)rep(j,n)dist[i][j] = 1LL<<60;
    vector<vector<edge>>g(n);
    rep(i,m){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--,b--;
        if(c > L)continue;
//        dist[a][b] = min(dist[a][b], c);
//        dist[b][a] = min(dist[b][a], c);
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
//    rep(k,n)rep(i,n)rep(j,n)dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    int q;
    cin >> q;
    vector<vector<pii>> dist(n);
    rep(i,n)dist[i] = dijkstra(i, g, L);
//    rep(i,n)show(i, dist[i]);
    while(q--){
        int s, t;
        cin >> s >> t;
        s--, t--;
//        show(dist[s][t]);
        if(dist[s][t].first > n){
            cout << -1 << "\n";
        }else{
            cout << dist[s][t].first << "\n";
        }
    }
}


Measured memory_bytes: 2432
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
vector<ll> ans;
ll n;

void dfs(ll x, ll y, ll z, ll bit){
    if (x == y){
        if (bit != 111) return;
        ans.push_back(z);
    } else {
        for (int i = 0; i < 3; i++){
            if (i == 0) dfs(x, y + 1, z + pow(10, y) * 3, bit | (ll)pow(10, 0));
            if (i == 1) dfs(x, y + 1, z + pow(10, y) * 5, bit | (ll)pow(10, 1));
            if (i == 2) dfs(x, y + 1, z + pow(10, y) * 7, bit | (ll)pow(10, 2));
        }
    }
}

int main(void){
    // Your code here!
    for (int i = 1; i <= 10; i++){
        dfs(i, 0, 0, 0);
    }
    sort(ans.begin(), ans.end());
    cin >> n;
    ll lb = -1, ub = ans.size();
    while(lb + 1 < ub){
        ll mid = (lb + ub) / 2;
        if (ans[mid] <= n) lb = mid;
        else ub = mid;
    }
    cout << lb + 1 << endl;
}


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

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

int main() {
  ll n, k, a, b, cnt = 0, ans;
  cin >> n >> k;
  vector<pair<int, int>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;

  sort(p.begin(), p.end());

  for (int i = 0; i < n; ++i) {
    cnt += p[i].second;
    if (cnt >= k) {
      ans = p[i].first;
      break;
    }
  }
  cout << ans << endl;

  // priority_queue<int, vector<int>, greater<int>> pq;

  // for (int i = 0; i < n; ++i) {
  //   cin >> a >> b;
  //   for (int j = 0; j < b; ++j) {
  //     pq.push(a);
  //   }
  // }

  // for (int i = 0; i < k - 1; ++i) pq.pop();

  // cout << pq.top() << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}


int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int h,w;cin >> h >> w;
    int m;cin >> m;
    //原則横のmax+縦のmaxで良い
    /*
    ただそこに点があった時困る →次にいいところを見てあげればいい ...?
    x座標を全列挙してy座標がmaxのところ(ただし点が存在しない中でのmaxと比較する)
    */
    
    set<int> exix;
    set<P> exipoints;
    vec<P> xs(h+1);
    vec<P> ys(w+1);
    vec<vec<int>> point(h+1);
    rep(i,m){
        int x,y;cin>> x >> y;
        exix.insert(x);
        exipoints.insert({x,y});
        xs[x].first++;xs[x].second=x;
        ys[y].first++;ys[y].second=y;
        point[x].emplace_back(y);
    }
    sort(rall(ys));
    set<int> greaty;
    int i=0;
    while(ys[i].first==ys[0].first){
        greaty.insert(ys[i].second);i++;
    }
    ll res=0;
    for(int x:exix){
        ll nowmax=ys[0].first;
        /*
        点の存在しないgreatyの要素があるならそこが最善
        そうでなければその値-1が最善
        */
        for(int j:greaty){
            if(!exipoints.count({x,j})){
                res=max(res,xs[x].first+ys[0].first);
                goto skip;
            }
        }
        res=max(res,xs[x].first+ys[0].first-1);
        skip:;
    }
    cout << res << endl;

}

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

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

    int a,p;
    cin>>a>>p;
    if(a<1 && p<2)
      cout<<0<<endl;
    else
      cout<<((a*3)+p)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;
 
using namespace std;

int main(){
    FAST() ;
    int N ; cin >> N ;
    bigint sum = 0 ;
    for( int i = 0 ; i < N ; i++ ){
        bigint x ; cin >> x ;
        sum += x - 1 ;
    }
    cout << sum << endl ;
    return 0 ;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{


    public static void main(String[] args) {
        FastReader in = new FastReader();

        String s = in.nextLine();
        int cnt[] = new int[2];
        for (int l = 0; l < s.length(); ++l){
            cnt[(int)s.charAt(l) - (int)'0'] ++;
        }
        System.out.println(Math.min(cnt[0], cnt[1])*2);




    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 25044
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
constexpr ll INF = static_cast<ll>(1e18);

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

int main(){
	string s;
    cin>>s;
    int n=(int)s.size();
    if(is_palindrome(s) && is_palindrome(s.substr(0,(n-1)/2)) && is_palindrome(s.substr((n+1)/2))){
		co("Yes");
    }
    else
		co("No");
}


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

bool isKaibun(int N){
  string str = to_string(N);
  string copy = str;
  reverse(copy.rbegin(), copy.rend());
  if (str == copy) {
    return 1;
  }
  else {
    return 0;
  }
}

int main() {
  int A, B, sum;
  bool kaibun;
  cin >> A >> B;
  sum = 0;
  for (int i = A; i <= B; i++) {
    kaibun = isKaibun(i);
    sum += kaibun;
  }
  cout << sum << endl;
}


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

using namespace std;


int main(){
  int n,t;
  int tmp;
  cin >> n >> t;
  int c[100];
  int t1[100];
  for(int i=0;i!=n;i++){
    cin >> c[i] >> t1[i];
    if(t1[i]>t){
      i--;
      n--;
    }
  }
  if(n==0){
    cout << "TLE" << endl;
    return 0;
  }
  for (int i=0; i<n; ++i) {
      for (int j=i+1; j<n; ++j) {
        if (c[i] > c[j]) {
          tmp =  c[i];
          c[i] = c[j];
          c[j] = tmp;
        }
      }
    }
  cout << c[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

vector<int> sieveOfEratosthenes(int n) {
  vector<int> primes(n);
  for (int i = 2; i < n; ++i) primes[i] = i;
  for (int i = 2; i * i < n; ++i) {
    if (primes[i]) {
      for (int j = i * i; j < n; j += i) primes[j] = 0;
    }
  }
  // primes.erase(remove(begin(primes), end(primes), 0), end(primes));
  return primes;
}

const int dy[] = {0, -1, 0, 1};
const int dx[] = {1, 0, -1, 0};
const int sz = 1e3 + 2;
const int dsz = 1e6;

int main() {
  int y = sz / 2;
  int x = sz / 2;
  int cur = 3;
  auto tb = vector<vector<int>>(sz, vector<int>(sz, 0));
  auto rev = vector<P>(dsz + 1);
  for (int i = 1; i <= dsz; ++i) {
    tb[y][x] = i;
    rev[i] = {y, x};
    int nxt = (cur + 1) % 4;
    int ny = y + dy[nxt];
    int nx = x + dx[nxt];
    if (!tb[ny][nx]) cur = nxt;
    y += dy[cur];
    x += dx[cur];
  }

  auto p = sieveOfEratosthenes(dsz + 1);
  int m, n;
  while (cin >> m >> n, m) {
    auto dp = vector<vector<int>>(sz, vector<int>(sz, 0));
    P ans = {};
    int lx = rev[n].second;
    int rx = lx + 1;
    for (int y = rev[n].first; y < sz; ++y) {
      for (int x = lx; x < rx; ++x) {
        int k = tb[y][x];
        if (k && k <= m) {
          dp[y][x] = max({dp[y - 1][x - 1], dp[y - 1][x], dp[y - 1][x + 1]});
          if (p[k]) ans = max(ans, {++dp[y][x], k});
        }
      }
      lx = max(1, lx - 1);
      rx = min(sz - 1, rx + 1);
    }
    if (ans.first == 0) ans.second = 0;
    cout << ans.first << ' ' << ans.second << endl;
    // for (int i = rev[n].first; i <= sz; ++i) {
    //   for (auto&& val : dp[i]) cout << setw(3) << right << val;
    //   cout << endl;
    // }
  }
  return 0;
}



Measured memory_bytes: 22440
program tenki
    implicit none
    integer :: i, cnt = 0
    character(3) s, t
    read *, s(1:3)
    read *, t(1:3)
    do i = 1, 3
        if(s(i:i) .eq. t(i:i))then
            cnt = cnt + 1
        end if
    end do
    print *, cnt
end program

Measured memory_bytes: 2796
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL <class T = int> inline T IN() { T x; cin >> x; return x; }
TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> vector<T> make_v(size_t a) { return vector<T>(a); }
TPL<TNM T, TNM... Ts> auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }

TPL<TNM T> using vec2 = decltype(make_v<T>(0, 0));
TPL<TNM T> using vec3 = decltype(make_v<T>(0, 0, 0));
TPL<TNM T> using vec4 = decltype(make_v<T>(0, 0, 0, 0));
TPL<TNM T> using vec5 = decltype(make_v<T>(0, 0, 0, 0, 0));

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

	int mn = min(X, Y);
	int mx = max(X, Y);
	int cost1 = (A + B) * mn;
	/*

	*/

	int cost2 = mn * 2 * C;

	int ans = min(cost1, cost2);
	if (X > Y) {
		ans += (mx - mn) * A;
	}
	else {
		ans += (mx - mn) * B;
	}

	int cost3 = mx * 2 * C;

	ans = min(cost3, ans);
	OUT(ans);

	return 0;
}

Measured memory_bytes: 256