akhauriyash/Code-Regression huggingface dataset:
/*
 NOTE:
*/
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <queue>
#include <vector>
#include <map>
#include <stack>
#include <set>
#define MP make_pair
#define F first
#define S second
#define TIME (double)clock()/CLOCKS_PER_SEC
using namespace std;
typedef long long ll;

int n, k, q;
int a[2020], ord[2020];

int b[2020], bst = 0;
int hp[2020], hst = 0;

int fans = 1e9;

int main()
{
//	freopen("test.in", "r", stdin);
//	freopen("test.out", "w", stdout);
 	ios::sync_with_stdio(false);
	cin >> n >> k >> q;
	for (int i = 1; i <= n; i ++)
		cin >> a[i], ord[i] = a[i];
	sort(ord + 1, ord + n + 1);
	
	a[n + 1] = 0;
	for (int mn = 0; mn + q - 1 <= n; mn ++) {
		bst = 0;
		int last = 1;
		for (int i = 1; i <= n + 1; i ++) {
			if (a[i] <= ord[mn]) {
				if (i - last >= k) {
//					cerr << "gap : " << mn << " -> " << last << " " << i - 1 << endl;
					hst = 0;
					for (int j = last; j < i; j ++)
						hp[++ hst] = a[j];
					sort(hp + 1, hp + hst + 1);
					for (int j = 1; j + k - 1 <= i - last; j ++)
						b[++ bst] = hp[j];
				}
//				else
//					cerr << "false gap : " << mn << " -> " << last << " " << i - 1 << endl;
				last = i + 1;
			}
		}
		if (bst < q)
			break;
		sort(b + 1, b + bst + 1);
		fans = min(fans, b[q] - b[1]);
	}
	cout << fans << endl;				
	return 0;
}
/*
*/



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char a[15];
int n;
bool ok()
{
	if(a[1]!='A') return 0;
	if(a[n]=='C') return 0;
	int o=0;
	for(int i=3;i<n;i++)
		o+=a[i]=='C';
	if(!o) return  0;
	if(o>1) return 0;
	for(int i=2;i<=n;i++)
		if(isupper(a[i]) and a[i]!='C') return 0;
	return 1;
	
}

int main()
{
	scanf("%s",a+1);
	 n=strlen(a+1);
	if(ok()) cout<<"AC";
	else cout<<"WA";
	
}

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

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;
  string Ans(N * 2, 'a');
  for (int i = 0; i < N; i++) {
    int j = i * 2;
    Ans.at(j) = S.at(i);
    Ans.at(j+1) = T.at(i);
  }
  cout << Ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<math.h>
using namespace std;
int main(){
  int n,m,i,j,x,y,h;
  cin >> n >> m;
  int ans[n][4],ch[m][2];
  for (i=0;i<n;i++) {
    cin >> x >> y;
    ans[i][0] = x;
    ans[i][1] = y;
    ans[i][2] = pow(10.0,10.0);
  }
  for (j=0;j<m;j++) {
    cin >> x >> y;
    ch[j][0] = x;
    ch[j][1] = y;
  }
  for (i=0;i<n;i++) {
    for (j=0;j<m;j++) {
      h = abs(ans[i][0]-ch[j][0])+abs(ans[i][1]-ch[j][1]);
      if (h < ans[i][2]) {
        ans[i][2] = h;
        ans[i][3] = j+1;
      }
    }
    cout << ans[i][3] << endl;
  }
}

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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int x,n;
    cin>>x>>n;
    if(n==0)
    {
        cout<<x;
        return 0;
    }
    unordered_map<int,bool> m;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]=1;
    }
    int i;
    for(i=x;i>=0;i--)
    {
        if(m.find(i)==m.end())
            break;
    }
    int res=abs(i-x);
    int str=i;
    
    
    for(i=x;i<=101;i++)
    {
        if(m.find(i)==m.end())
            break;
    }
    if(abs(i-x)<res)
        cout<<i;
    else
        cout<<str;
               
}

Measured memory_bytes: 3648
#include<string>
#include<iostream>
#include<cstdio>
using namespace std;

int main(){
    string k(200,'a');
    string k1(200,'a');
    string k2(200,'a');
    string sy="a";
    int n,h,i,j,l,y;
    while(true){
        cin>>k;
        if(k=="-")break;
        cin>>n;
        l=k.size();
        for(i=0;i<n;i++){
            k1.clear();
            k2.clear();
            cin>>h;
            for(j=0;j<h;j++){
                k1+=k[j];
            }
            for(y=h;y<l;y++){
                k2+=k[y];
            }
            k=k2+k1;
        }
        cout<<k<<endl;
    }
    return 0;
}



Measured memory_bytes: 3216
import collections
N = int(input())
A = [0]
A += list(map(int, input().split()))
cnt = 0
L = [- 10 ** 6]
R = [- 10 ** 6]

for i in range(1, N + 1):
    L.append(i + A[i])
    R.append(i - A[i])
c = collections.Counter(L)

for j in range(1, N + 1):
    cnt += c.get(R[j], 0)
print(cnt)

Measured memory_bytes: 51764
#include <cstdio>

void insertionSort(int a[], int n)
{
  int i, j;
  for (i = 0; i < n - 1; i++)
    printf("%d ", a[i]);
  printf("%d\n", a[i]);
  for (i = 1; i <= n - 1; i++) {
    int v = a[i];
    for (j = i - 1; a[j] > v && j >= 0; j--) 
      a[j + 1] = a[j];
    a[j + 1] = v;
    for (j = 0; j < n - 1; j++)
      printf("%d ", a[j]);
    printf("%d\n", a[j]);
  }
}

int main(void)
{
  int n;
  int a[100];
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  insertionSort(a, n);

  return 0;
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n*3);
    for(int i = 0; i < n; i++){
        int t;
        cin>>t;
        a[i*3] = t;
        a[i*3+1] = t+1;
        a[i*3+2] = t-1;
    }
    map<int,int> mp;
    for(int i = 0; i < a.size(); i++){
        if(mp.find(a[i]) == mp.end())
            mp[a[i]] = 1;
        else
            mp[a[i]]++;
    }
    int max=0;
    for(auto x:mp){
        if(x.second>max)
            max = x.second;
    }
    cout<<max;
}

Measured memory_bytes: 5888
#n = int(input())
#L = list(map(int, input().split()))
#import math
#import sys
#import heapq
#import fractions
#import bisect
#import numpy




NM = list(map(int, input().split()))
ps = [list(input().split()) for i in range(NM[1])]
a=[0]*NM[0]
flg = [True]*NM[0]
for i in range(NM[1]):
    ps[i][0] = int(ps[i][0])

ans = [0]*NM[0]
ac = 0
for i in range(NM[1]):
    if ps[i][1] == "AC" and flg[ps[i][0]-1]:
        flg[ps[i][0]-1] = False
        ans[ps[i][0]-1] = a[ps[i][0]-1]
    if ps[i][1] == "WA" and flg[ps[i][0]-1]:
        a[ps[i][0]-1] += 1

for i in range(NM[0]):
    if flg[i]== False:
        ac += 1
print(ac,sum(ans))
        




Measured memory_bytes: 78808
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
// #define M 421412341324321
#define MOD 998244353

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int m, d;
	cin>>m>>d;
	int c=0;
	REP(i,1,d)
	{
		string s = to_string(i);
		REP(j,1,m)
		{
			if ((s[0]-48)*(s[1]-48)==j && (s[0]-48)>=2 && (s[1]-48)>=2) {
				c++;
				// debug2(s, j);
			}
		}
	}
	cout<<c;

 
	
}

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

using namespace std;

int main()
{
	vector<int> v;
	int n;
	
	while(true)
	{
		scanf("%d", &n);
		
		if(n == 0)
			break;
		v.push_back(n);
	}
	
	for(int i = 0; i < v.size(); i++)
		printf("Case %d: %d\n", i+1, v[i]);
	return 0;
}


Measured memory_bytes: 3284
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 3005;
int dp[maxn][maxn], path[maxn][maxn][2];

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    REPP(i, 1, n + 1) REPP(j, 1, m + 1) {
        dp[i][j] = dp[i][j - 1];
        path[i][j][0] = path[i][j - 1][0];
        path[i][j][1] = path[i][j - 1][1];
        if (dp[i - 1][j] > dp[i][j]) {
            dp[i][j] = dp[i - 1][j];
            path[i][j][0] = path[i - 1][j][0];
            path[i][j][1] = path[i - 1][j][1];
        }
        if (s[i - 1] == t[j - 1]) {
            if (dp[i][j] < dp[i - 1][j - 1] + 1) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                path[i][j][0] = i;
                path[i][j][1] = j;
            }
        }
    }
    int x = path[n][m][0], y = path[n][m][1];
    string ans = "";
    while (x && y) {
        if (s[x - 1] == t[y - 1]) {
            ans.push_back(s[x - 1]);
            x--, y--;
        } else {
            x = path[x][y][0];
            y = path[x][y][1];
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 105984
k['( '],n,a,b,i,m;p(int*x){return*x-*1[&x];}main(c){for(scanf("%d%d%d%d",&n,&a,&b,&c);i<n;scanf("%d",k+i++));for(qsort(k,n,4,p);~i;a+=b,c+=k[--i])m=fmax(m,c/a);a=!printf("%d\n",m);}

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

int main(void)
{
    int N, M;
    cin >> N >> M;

    vector<vector<int>> dest(N);

    for(int i = 0; i < M; i++)
    {
        int u, v;
        cin >> u >> v;

        // 1からを嫌うため
        u--; v--;
        
        dest[u].push_back(v);
    }

    int S, T;
    cin >> S >> T;
    S--; T--;

    vector<int[3]> table(N);
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < 3; j++)
        {
            table[i][j] = INT_MAX;
        }
    }

    queue<pair<int, int>> q;
    q.push(make_pair(S, 0));

    table[S][0] = 0;

    while(!q.empty())
    {
        int current_v = q.front().first;
        int current_l = q.front().second;
        q.pop();

        for(int _dest : dest[current_v])
        {
            int new_l = (current_l + 1) % 3;
            if(table[_dest][new_l] != INT_MAX) continue;

            table[_dest][new_l] = table[current_v][current_l] + 1;
            q.push(make_pair(_dest, new_l));
        }
    }

    int ans = table[T][0];
    if(ans == INT_MAX) ans = -1;
    else ans /= 3;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n;
	cin >> n;
	n--;
	cout << n * (n + 1) / 2;
}

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

int main(){
  int k,s; cin >> k >> s;
  int ans=0;
  for(int x=0;x<=k; x++){
    for(int y=0;y<=k; y++){
      int z=s-x-y;
      if(0 <= z && z <= k){
        ans++;
      }
    }
  }         
  cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>>v(8);
    rep(i,n){
        ll x,y,z;
        cin>>x>>y>>z;
        rep(a,2)rep(b,2)rep(c,2){
            v[a*4+b*2+c].pb(x*(-2)*(a==0)+y*(-2)*(b==0)+z*(-2)*(c==0)+x+y+z);
        }
    }
        ll maxv=0;
        rep(i,8){
            ll sum=0;
            sort(v[i].begin(),v[i].end(),greater<ll>());
            rep(j,m)sum+=v[i][j];
            maxv=max(maxv,sum);
        }
        cout<<maxv<<endl;
    }
    


Measured memory_bytes: 384
#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

typedef pair<int, int> P;
int H, W;
int d[1010][1010];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string G[1010];

int bfs(int sx, int sy, int gx, int gy) {
    queue<P> que;
    rep(i, H) rep(j, W) d[i][j] = INF;
    d[sx][sy] = 1;
    que.push(P(sx, sy));
    while(que.size()) {
        P p = que.front(); que.pop();
        if (p.first == gx && p.second == gy) break;
        for(int i = 0; i < 4; i++) {
            int x = p.first + dx[i];
            int y = p.second + dy[i];
            if (x < 0 || x >= H || y < 0 || y >= W) continue;
            if (G[x][y] == '#') continue;
            if (d[x][y] != INF) continue;
            d[x][y] = d[p.first][p.second] + 1;
            que.push(P(x, y));
        }
    }
    return d[gx][gy];

}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    rep(i, H) cin >> G[i];
    int score = H * W;
    int white = bfs(0, 0, H - 1, W - 1);
    if (white == INF) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, H) rep(j, W)if (G[i][j] == '#') white++;
    cout << score - white << endl;

    return 0;
}


Measured memory_bytes: 512
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define rrep(i, n) for(int i=(int)n-1; i>=0; i--)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int n, m;
bool a[100001];
int memo[100001];

int main() {
  rep(i, 100001) memo[i] = 0;
  rep(i, 100001) a[i] = true;  // 階段がある

  cin >> n >> m;
  rep(i, m) {
    int ai;
    cin >> ai;
    a[ai] = false;
  }

  // cout << dfs(n) << endl;/

  memo[0] = 1;
  rep1(i, n+1) {
    if(!a[i])continue;
    int n1 = 0, n2 = 0;
    if(a[i-1]) n1 = memo[i-1] % MOD;
    if(a[i-2] && i-2>=0) n2 = memo[i-2] % MOD;
    memo[i] = (n1 + n2) % MOD;
  }
  cout << memo[n] << endl;

  // cout << "---" << endl;
  // rep(i, n+1) {
  //   cout << memo[i] << endl;
  // }

  return 0;
}

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

signed main(){
    io();
    int a, b; cin >> a >> b;
    cout << 6 - a - b << '\n';
    return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    int a[m]; for (int i = 0; i < m; i++) cin >> a[i];
    int b[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    pair<int, int> dp[10002] = {};
    for (int i = 2; i <= n; i++) {
        for (int d : a) {
            if (b[d] > i) continue;
            auto x = dp[i-b[d]];
            int len = x.first;
            if (len == 0 && i != b[d]) continue;
            dp[i] = max(dp[i], make_pair(len+1, d));
        }
        // cerr << i << ' ' << dp[i].first << ' ' << dp[i].second << endl;
    }
    string ans;
    for (int i = n; i > 0; i -= b[dp[i].second]) {
        ans += string(1, dp[i].second + '0');
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); }
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; }
constexpr ll pow2(const int n) { return 1ll << n; }
constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60;
constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N;
vi A, B, C;

int main() {
    cin >> N;
    A.resize(N);
    B.resize(N);
    rep(i, N) {
        cin >> A[i];
    }
    rep(i, N) {
        cin >> B[i];
    }

    int ans = 0;
    C.resize(N);
    rep(bit, 29) {
        rep(i, N) {
            C[i] = B[i] % (1 << bit + 1);
        }
        sort(all(C));

        ll cnt = 0;
        rep(i, N) {
            const int x = A[i] % (1 << bit + 1);
            const int a = (1 << bit) - x;
            const int b = 2 * (1 << bit) - x;
            const int c = 3 * (1 << bit) - x;
            const int ia = lower_bound(all(C), a) - C.begin();
            const int ib = lower_bound(all(C), b) - C.begin();
            const int ic = lower_bound(all(C), c) - C.begin();

            cnt += ib - ia;
            cnt += N - ic;
        }

        ans |= cnt % 2 << bit;
    }

    write(ans);
}

Measured memory_bytes: 2560
var n,i,j,r,g,b,cnt  :int64;
    s:string;

begin
  readln(n);
  readln(s);
  r:=0; g:=0; b:=0; cnt:=0;
  for i:=1 to n do begin
    if s[i]='R' then inc(r,1);
    if s[i]='G' then inc(g,1);
    if s[i]='B' then inc(b,1);
  end;
  for i:=1 to n-1 do
    for j:=i to n do begin
      if ((j-i)mod 2=0)and(s[i]<>s[j])and(s[j]<>s[(i+j)div 2])and(s[i]<>s[(i+j)div 2])
      then inc(cnt,1)
    end;
  writeln(r*g*b-cnt)
end.

Measured memory_bytes: 1372
n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        x1,y1 = xy[i]
        x2,y2 = xy[j]
        ans += ((x2-x1)**2 + (y2-y1)**2)**(1/2)

print(ans*(2/n))

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

int main() {
  string s;
  cin>>s;
  map<char,int> memo;
  for(int i=0;i<s.size();i++){
    memo[s[i]]++;
  }
  bool ans=true;
  for(auto itr=memo.begin();itr!=memo.end();itr++){
    if((itr->second)%2==1) ans=false;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
# from functools import reduce

N = int(input())
AL = list(map(int, input().split()))

R = True
for b in [n % 3 == 0 or n % 5 == 0 for n in AL if n % 2 == 0]:
    R = R and b

if R:
    print('APPROVED')
else:
    print('DENIED')



Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define rep(i,x,y) for(int i=x;i<=y;++i)

const int INF=1<<30;

using namespace std;

typedef long long ll;
const int MOD=1e9+7;
ll fac(int n)
{
	ll ret=1;
	rep(i,1,n) ret=ret*i%MOD;
	return ret;
}

int main()
{
	int a,b;cin>>a>>b;
	if(a<b) swap(a,b);
	if(a>b+1) puts("0");
	else cout<<fac(a)*fac(b)%MOD*(a==b?2:1)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a[10000] = {}, i, j;
    i = 0;
    while(1){
        scanf("%d", &a[i]);
        if(a[i] == 0){
            break;
        }
        i++;
    }
    for(j = 0; j < i; j++){
        printf("Case %d: %d\n", j + 1, a[j]);
    }
    return 0;
}


Measured memory_bytes: 2020
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int A, B, C;
int ans;
vector<int> v;

int main(){
    scanf("%d%d%d", &A, &B, &C);

    int a = A % 2;
    int b = B % 2;
    int c = C % 2;

    ans = 0;

    if(a == b && b != c){
        ++ans; ++A; ++B;
    } else if(b == c && c != a){
        ++ans; ++B; ++C;
    } else if(c == a && a != b){
        ++ans; ++C; ++A;
    }

    v.push_back(A);
    v.push_back(B);
    v.push_back(C);
    sort(v.begin(), v.end());

    ans += (v[1] - v[0]) / 2;
    ans += v[2] - v[1];

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

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
 
typedef long long ll;
const ll MOD = 1e9+7;
const ll INF = 1e18;


#define PB push_back
#define MP make_pair
#define F first
#define S second

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}
bool compare_by_second(pair<ll,ll> a,pair<ll,ll> b){
    if(a.S != b.S){
        return a.S < b.S;
    }else{
        return a.F < b.F;
    }
}

vector<pair<ll,ll>> task;

int main(){
    ll n;
    cin >> n;
    for(ll i=0;i<n;i++){
        ll tmp,tmp2;
        cin >> tmp >> tmp2;
        task.PB(MP(tmp,tmp2));
    }
  	
    sort(task.begin(),task.end(),compare_by_second);
    ll sum=0;
    for(auto &e: task){
        sum+=e.F;
        if(sum>e.S){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 6256
#include <iostream>

using namespace std;

typedef long long ll;

int cnt(ll n) {
	int rt = 0;
	do {
		rt++;
		n /= 10;
	} while (n);
	return rt;
}

int f(ll a, ll b) {
	return max(cnt(a), cnt(b));
}

int main() {
	ll n;
	cin >> n;
	ll x = 1;
	ll y = n;
	for (ll a = 1; a * a <= n; a++) {
		if (n % a == 0) {
			if (f(a, n / a) < f(x, y)) {
				x = a;
				y = n / a;
			}
		}
	}
	cout << f(x, y) << "\n";
	return 0;
}



Measured memory_bytes: 256
n,d,a=map(int,input().split())
d*=2
xh=[list(map(int,input().split()))for _ in range(n)]
xh.sort()
x=[i for i,j in xh]+[10**20]
h=[j for i,j in xh]
notimos=[0]*(n+1)
c=0
ans=0
from bisect import bisect_right
for i in range(n):
  c+=notimos[i]
  xx,hh=xh[i]
  hh=max(0,hh-c*a)
  m=0--hh//a
  ans+=m
  c+=m
  notimos[bisect_right(x,xx+d)]-=m
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

ll a, b, c;

void solve() {
    cin >> a >> b >> c;
    // int sum = 0;
    // sum = 0;
    // for (int i = 1; i <= a; ++i) {
    //     for (int j = 1; j <= a; ++j) {
    //         for (int k = 1; k <= a; ++k) {
    //             for (int l = 1; l <= a; ++l) {
    //                 int s = 0;
    //                 if (abs(i - j) == c) s++;
    //                 if (abs(j - k) == c) s++;
    //                 if (abs(k - l) == c) s++;
    //                 sum += s;
    //             }
    //         }
    //     }
    // }
    // printf("%.10f\n", 1. * sum / (a * a * a * a));
    // sum = 0;
    // for (int i = 1; i <= a; ++i) {
    //     for (int j = 1; j <= a; ++j) {
    //         for (int k = 1; k <= a; ++k) {
    //             int s = 0;
    //             if (abs(i - j) == c) s++;
    //             if (abs(j - k) == c) s++;
    //             sum += s;
    //         }
    //     }
    // }
    // printf("%.10f\n", 1. * sum / (a * a * a));
    // sum = 0;
    // for (int i = 1; i <= a; ++i) {
    //     for (int j = 1; j <= a; ++j) {
    //         int s = 0;
    //             if (abs(i - j) == c) s++;
    //             sum += s;
    //     }
    // }
    // printf("%.10f\n", 1. * sum / (a * a));
    if (a == 1) {
        double ans = b-1;
        printf("%.10f\n", ans);
    } else if (c == 0) {
        double ans = 1. * b / a;
        printf("%.10f\n", ans);
    } else {
        double ans = 1. * (b-1) / (a * a) * ((a - c) * 2.0);
        printf("%.10f\n", ans);
    }
    
}

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


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

ll N, K;
vector<ll> A;

void all(){
  for(int i = 0; i<N+1; i++){
    cout << A.at(i) << " ";
  }
  return;
}

int main(){
  cin >> N >> K;
  A = vector<ll>(N+1);

  A.at(0) = 0;

  ll buf;
  for(int i = 0; i<N; i++){
    cin >> buf;
    A.at(i+1) = buf + A.at(i);
    // A.at(i+1) = (1.0+buf) / 2.0 + A.at(i);
  }

  // all();
  // cout << endl;

  ll ans = 0;
  for(int i = K; i<=N; i++){
    ans = max(ans, A.at(i) - A.at(i-K));
    // cout << A.at(i) - A.at(i-K) << endl;
  }

  cout << fixed << setprecision(12) << (ans + K) / 2.0 << endl;




}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  string ans="Impossible";
  if(A%3==0||B%3==0||(A+B)%3==0)ans="Possible";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int,int);
int main(){
    long long x, y;
    long long st;
    while(cin >> x >> y){
        if(x >= y){
            st = gcd(x, y);
            cout << st << " ";
        }else{
            st = gcd(y, x);
            cout << st << " ";
        }
        cout << x * y / st << endl;
    }
    return 0;
}
int gcd(int a, int b){
    int r;
    while(b > 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

Measured memory_bytes: 3080
#[warn(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};
use std::cmp::{min, Reverse};

#[fastout]
fn main() {
   input! {
      n: usize,
      mut s: [Chars; n]
   }
   let mut pos = Vec::new();
   let mut neg = Vec::new();
   for i in 0..n {
      let mut mn = 0;
      let mut h = 0;
      for c in s[i].iter() {
         if *c == ')' {
            h -= 1;
            mn = min(mn, h);
         } else {
            h += 1;
         }
      }
      if h > 0 {
         pos.push((mn as i64, h as i64));
      } else {
         neg.push(((mn - h) as i64, -h as i64));
      }
   }

   pos.sort_by_key(|&(a, b)| (Reverse(a), b));
   let mut pp = 0;
   for (mn, h) in pos.iter().copied() {
      if pp + mn < 0 {
         println!("No");
         return;
      }
      pp += h;
   }

   neg.sort_by_key(|&(a, b)| (Reverse(a), b));
   let mut pn = 0;
   for (mn, h) in neg.iter().copied() {
      if pn + mn < 0 {
         println!("No");
         return;
      }
      pn += h;
   }

   if pp == pn {
      println!("Yes");
   } else {
      println!("No");
   }
}


Measured memory_bytes: 74504
s=input()
#print(s)
y=1000*int(s[0])+100*int(s[1])+10*int(s[2])+int(s[3])

m=10*int(s[5])+int(s[6])
d=10*int(s[8])+int(s[9])
#print(y,m,d)
flag=0
if 2019 < y:
  flag=1
elif 2019 == y:
  if 5<=m:
    flag=1

print('Heisei' if flag==0 else 'TBD')

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

char c[][2]{ "A","B","C" };
int main() {
	string s; cin >> s;
	unordered_map<string, bool>mp;
	queue<string>que;
	que.push(s);
	while (!que.empty()) {
		string u = que.front(); que.pop();
		if (u == "ABC") {
			puts("Yes"); return 0;
		}
		rep(i, 3) {
			string v = u;
			int d = 0, k = 0;
			while (~(d = (int)v.find("ABC", d))) {
				v.replace(d, 3, c[i]);
				d++; k++;
			}
			if (k != count(v.begin(), v.end(), 'A' + i))continue;
			if (!mp[v]) {
				mp[v] = true;
				que.push(v);
			}
		}
	}
	puts("No");
}

Measured memory_bytes: 9316
#include <iostream>
using namespace std;
 
int main()
{
       int n, sum = 0;
       cin >> n;
 
       for(int i = 1; i <= n; i++)
       {
              int curr;
              cin >> curr;
 
              sum += curr - 1;
       }
 
       cout << sum << endl;
       return 0;
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

signed main(){
	fastio
	map<pair<int,int>,int> mp;
	map<int,int> ma, mb;
	int h,w,m;
	cin >> h >> w >> m;
	
	while(m--){
		int x,y;
		cin >> x >> y;
		ma[x]++;
		mb[y]++;
		mp[{x,y}]++;
	}

	int mr = 0, mc = 0;
	for(auto [a,b] : ma) mr = max(mr,b);
	for(auto [a,b] : mb) mc = max(mc,b);

	vector<int> v1, v2;
	for(auto [a,b] : ma) if(b==mr) v1.push_back(a);
	for(auto [a,b] : mb) if(b==mc) v2.push_back(a);
	int ans = mr + mc -1;
	for(auto a : v1){
		for(auto b : v2){
			if(mp[{a,b}]) continue;
			ans = mr + mc;
			goto stop; 
		}
	}	
	stop:;
	cout << ans << "\n";
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a;
string s;

signed main() {
	cin >> n >> s;
	reps(m,1,n) {
		bool l[26] = {}, r[26] = {};
		rep(i,m) l[s[i]-'a']++;
		reps(i,m,n) r[s[i]-'a']++;
		int t = 0;
		rep(i,26) t += l[i]&r[i];
		chmax(a,t);
	}
	cout << a << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N, K;
    cin >> N >> K;
    VI A(N);
    REP(i, N) cin >> A[i];
    if (N == K) {
        cout << 1 << endl;
    } else if (K == 2) {
        cout << N - 1 << endl;
    } else {
        cout << (N - 1) / (K - 1) + ((N - 1) % (K - 1) != 0) << endl;
    }
}


Measured memory_bytes: 640
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    a, b, c = MI()
    ans = int(a*b*0.5)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
n, p = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

odd = a.count(&:odd?)
even = n - odd

if p == 0
  puts odd == 0 ? 2**even : 2**(odd - 1) * 2**even
else
  puts odd == 0 ? 0 : 2**(odd - 1) * 2**even
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 1e4 + 5;
ll n, p, ans, cnt[N];
string s;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> p >> s;
    if(p == 2 || p == 5)
    {
        for(int i = 0;i < n;++i)
            if((s[i] - '0') % p == 0)
                ans += (i + 1);
    }
    else
    {
        reverse(s.begin(), s.end());
        ll cum = 0, ten = 1;
        ++cnt[0];
        for(int i = 0;i < n;++i)
        {
            (cum += (s[i] - '0') * ten) %= p;
            (ten *= 10) %= p;
            ans += cnt[cum]++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3708
#include<stdio.h>
#include<utility>
#include<algorithm>
using namespace std;
#define ran 222222
int n;
struct Node{
	int pos,v;
};
Node a[ran];
int maxv[ran],minv[ran];
pair<int,int> vv[ran];
int v[ran],lv;
bool cmp_pos(Node&x,Node&y){
	return x.pos<y.pos;
}

#define mod 1000000007
int add(int x,int y){
	return (x+=y)<mod?x:x-mod;
}
int sub(int x,int y){
	return (x-=y)>=0?x:x+mod;
}
int dp[ran],sum[ran];
int main(){
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
		scanf("%d%d",&a[i].pos,&a[i].v);
	sort(a+1,a+n+1,cmp_pos);
	maxv[0] = 0;
	for(int i=1; i<=n; i++)
		maxv[i] = max(a[i].v, maxv[i-1]);
	minv[n+1] = 1111111111;
	for(int i=n; i>=1; i--)
		minv[i] = min(a[i].v, minv[i+1]);
	for(int i=1; i<=n; i++)
		v[lv++] = a[i].v;
	sort(v,v+lv);
	lv=unique(v,v+lv)-v;
	for(int i=1; i<=n; i++){
		minv[i] = lower_bound(v,v+lv,minv[i]) - v+1;
		maxv[i] = lower_bound(v,v+lv,maxv[i]) - v+1;
		vv[i] = make_pair(minv[i], maxv[i]);
	}
	sort(vv+1, vv+n+1);
	for(int i=1; i<=n; i++){
		minv[i] = vv[i].first;
		maxv[i] = vv[i].second;
	}
	int pnt = 0;
	dp[0] = 1;
	sum[0] = 1;
	int res = 0;
	for(int i=1; i<=n; i++){
		while(maxv[pnt+1] < minv[i] - 1)pnt++;
		dp[i] = sub(sum[i-1], minv[i] > 1?sum[
			pnt
		]:0);
		sum[i] = add(sum[i-1], dp[i]);
		if(maxv[i] == lv)
			res = add(res, dp[i]);
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 7680
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



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

    int l = a+b,r = c+d;

    if(l == r)P("Balanced");
    else if(l > r)P("Left");
    else P("Right");
	return  0;
}

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


int main(){
	string s;
	cin >> s;
	int q;
	cin >> q;
	deque<char> dq;
	for(char c : s) dq.push_back(c);
	bool rev = false;
	rep(i,q){
		int t;
		cin >> t;
		if(t == 1){
			rev = !rev;
		}else{
			int f; char c;
			cin >> f >> c;
			if(rev == false && f == 1 || rev == true && f == 2){
				dq.push_front(c);
			}else{
				dq.push_back(c);
			}
		}
	}
	if(rev) reverse(dq.begin(), dq.end());
	string ans;
	for(char c : dq) ans += c;
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1412
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  var T = one[2];
  var output = 0;
  myout(Math.floor(T / A) * B);
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ull T;
    cin >> T;
    rep(t, T){
        ull N, A, B, C, D;
        cin >> N >> A >> B >> C >> D;

        ull total = 0;
        unordered_map<ull, ull> m;
        queue<pair<ull, ull>> q;
        q.push({N, 0});
        auto uq = [&](pair<ull, ull> np){
            auto it = m.find(np.first);
            if(it!=m.end()){
                if(np.second<it->second){
                    m[np.first] = np.second;
                    q.push(np);
                }
            }
            else{
                m[np.first] = np.second;
                q.push(np);
            }
        };
        while(!q.empty()){
            auto p = q.front();
            q.pop();
            if(p.first==0) continue;
            if(p.first%2==0){
                pair<ull, ull> np = {p.first/2, p.second+A};
                uq(np);
            }
            else{
                pair<ull, ull> np1 = {(p.first+1)/2, p.second+A+D};
                pair<ull, ull> np2 = {(p.first-1)/2, p.second+A+D};
                uq(np1);
                uq(np2);
            }
            if(p.first%3==0){
                pair<ull, ull> np = {p.first/3, p.second+B};
                uq(np);
            }
            else{
                pair<ull, ull> np1 = {(p.first+(3-p.first%3))/3, p.second+B+D*(3-p.first%3)};
                pair<ull, ull> np2 = {(p.first-p.first%3)/3, p.second+B+D*(p.first%3)};
                uq(np1);
                uq(np2);
            }
            if(p.first%5==0){
                pair<ull, ull> np = {p.first/5, p.second+C};
                uq(np);
            }
            else{
                pair<ull, ull> np1 = {(p.first+(5-p.first%5))/5, p.second+C+D*(5-p.first%5)};
                pair<ull, ull> np2 = {(p.first-p.first%5)/5, p.second+C+D*(p.first%5)};
                uq(np1);
                uq(np2);
            }
            uq({0, p.second+p.first*D});
        }
        cout << m[0] << endl;
    }
}


Measured memory_bytes: 4076
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

int main() {
	string N;
	cin >> N;

	ll nine = 0;
	REP(i, N.length()) {
		char buf = N[i];
		nine += atoi(&buf);
	}

	if (nine % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3708
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void draw(priority_queue<int> tmp){
  while(!tmp.empty()){
    cout << tmp.top() << " ";
    tmp.pop();
  }
  cout << endl;
  return;
}


void solve(void){
  
  int N, M;
  cin >> N >> M;
  
  vector<int> A(N);
  priority_queue<int> pq;
  
  REP(i,N){
    cin >> A[i];
    pq.push(A[i]);
  }
  
  REP(i,M){
    int t=pq.top();
    pq.pop();
    pq.push(t/2);
//    draw(pq);
  }
  
  ll ans=0;
  
  while (!pq.empty()) {
    ans += pq.top();
    pq.pop();
  }

  cout << ans << endl;


  return;
   
}


int main(int argc, const char * argv[]) {
  
    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n=s.size();
  int l=n/2-1;
  int r=0;
  int ans=0;
  int m=s[n/2];
  if(n%2==0){
    r=n/2;
    ans=n/2;
  }else{
    r=n/2+1;
    ans=n/2+1;
  }
  while(r<n){
    if(s[l]==s[r] && m==s[r]){
      ans++;
      l--;r++;
    }
    else break;
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 512
a = []
for _ in range(3):
    a.append(list(map(int,input().split())))
n = int(input())
r = [[0,0,0],[0,0,0],[0,0,0]]
for b in range(n):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == b:
                r[i][j] = 1

s = 0

for i in range(3):
    if r[i][0] == r[i][1] == r[i][2] == 1:
        s += 1
        break
    elif r[0][i] == r[1][i] == r[2][i] == 1:
        s += 1
        break

if r[0][0] == r[1][1] == r[2][2] == 1:
    s += 1
elif r[2][0] == r[1][1] == r[0][2] == 1:
    s += 1

if s > 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064