akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define EPS (1e-10)
#define equals(a,b) ( fabs(a-b) < EPS )
#define PI 3.141592653589793238

// COUNTER CLOCKWISE
static const int CCW_COUNTER_CLOCKWISE = 1;
static const int CCW_CLOCKWISE = -1;
static const int CCW_ONLINE_BACK = 2;
static const int CCW_ONLINE_FRONT = -2;
static const int CCW_ON_SEGMENT = 0;

//Intersect Circle and Circle
static const int ICC_SEPARATE = 4;
static const int ICC_CIRCUMSCRIBE = 3;
static const int ICC_INTERSECT = 2;
static const int ICC_INSCRIBE = 1;
static const int ICC_CONTAIN = 0;

struct point{
	double x,y;
	//construct
	point() {} 
	point(double x,double y):x(x),y(y){}
	//演算子
	point operator + (point p) { return point(x+p.x,y+p.y); }
	point operator - (point p) { return point(x-p.x,y-p.y); }
	point operator * (double k) { return point(x*k,y*k); }
	point operator / (double k) { return point(x/k,y/k); }
	point operator / (point p) { return point( (x*p.x + y*p.y)/p.norm()  , (-x*p.y + y*p.x)/p.norm() ) ; }
	bool operator < (point p) { return x!=p.x ? x<p.x : y<p.y; }
	bool operator == (point p) { return equals(x,p.x) && equals(y,p.y) ; }
	//function
	double arg() { return atan2(y,x) ; }
	double norm(){return x*x+y*y; }
	double abs() { return sqrt(norm() ) ;}
	double dot(point p) { return p.x*x + p.y*y; }
	double cross(point p) { return x*p.y - y*p.x; }

	//input output
	void input(){cin>>x>>y;}
	void print(){cout<<x<<' '<<y<<endl;};

};

bool sort_x(point a,point b){
	return a.x!=b.x?a.x<b.x:a.y<b.y ;
}
bool sort_y(point a,point b){
	return a.y!=b.y?a.y<b.y:a.x<b.x ;
}

typedef vector<point> polygon;

struct segment{
	point s,t;
	segment() {}
	segment(point s,point t) : s(s),t(t){}
	void input(){s.input(),t.input(); }
};
typedef segment line;

struct circle{
	point c;
	double r;
	circle() {}
	circle(point c,double r) : c(c),r(r){}

};

double norm(point a){	return a.norm(); }
double abs(point a){ return a.abs(); }
double dot(point a,point b) { return a.x*b.x + a.y*b.y ; }
double cross(point a,point b) { return a.x * b.y - a.y * b.x ; }

point orth(point p){ return point(-p.y,p.x); }

//isOrthgonal 垂直
bool isOrthogonal(point a,point b) { return equals(dot(a,b), 0.0 ) ; }
bool isOrthogonal(point a,point b,point c,point d) { return isOrthogonal(a-b,c-d) ; }
bool isOrthogonal(line l1,line l2 ){ return isOrthogonal(l1.t-l1.s,l2.t-l2.s); }
//isParallel 平行
bool isParallel(point a,point b) { return equals(cross(a,b), 0.0) ; }
bool isParallel(point a,point b,point c,point d) { return isParallel(a-b,c-d); }
bool isParallel(line l1,line l2) { return isParallel(l1.t-l1.s,l2.t-l2.s) ; }

point project(line l,point p){
	point base = l.t-l.s;
	double r = dot(p-l.s,base) / norm(base) ;
	return l.s + base*r;
}
point reflect(line l,point p){
	return p + (project(l,p) - p) *2.0;
}




int main(){
    	line l;
	l.input();
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		point a;
		a.input();
		point b = reflect(l,a);
		printf("%0.10lf %0.10lf\n",b.x,b.y);
	}
	return 0;
}



Measured memory_bytes: 3296
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      int n;
      cin>>n;
      int a[n];
      REP(i,n)cin>>a[i];
      int ans=INT32_MIN,count=0;
      for(int i=0;i<n-1;i++)
      {
              if(a[i+1]<=a[i])
              count++;
              else 
          {
              ans=max(count,ans);
          count=0;}
      }
      ans=max(count,ans);
      cout<<ans;
  }
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'

//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#define double long double

using namespace std;
template<class T, class T2> inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const int MAXN = (1 << 20);

int k;

void read()
{
	cin >> k;
}

void solve()
{
	int64_t val = (int64_t)1e15 - 1, dwn = (int64_t)1e11, cntr = (int64_t)1e14 - 1;
	vector<int64_t> li;
	
	double last = 1e19;
	while(val)
	{
		int64_t cc = val, c = 0;
		while(cc)
		{
			c += cc % 10;
			cc /= 10;
		}

		double curr = val / (double)c;
		
		//cout << val << " -> " << last << " " << curr << endl;
		
		if(curr <= last)
		{
			last = curr;
			li.push_back(val);
		}

		val -= dwn;
		if(val == cntr) dwn /= 10, cntr /= 10;
		if(!dwn) dwn = 1;
	}

	sort(li.begin(), li.end());
	for(int i = 0; i < k; i++) 
		cout << li[i] << endl;

	/*int c = 0, dgs = 0;
	while(k--)
	{
		c++;
		int x = c, S = c;
		cout << c;
		for(int i = 0; i < dgs; i++) x = x * 10 + 9, S += 9, cout << 9;
		cout << endl;

		//cout << "-> " << setprecision(9) << fixed << x / (double)S << endl;

		if(c == 9)
		{
			dgs++;
			c = 0;
			if(dgs >= 3 && k)
			{
				cout << 90;
				for(int d = 0; d < dgs - 1; d++)
					cout << 9;
				cout << endl;
				k--;
			}
		}
	}*/
}

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

	read();
	solve();
	return 0;
}



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

using namespace std;
#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<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  ll X, Y;
  cin >> X >> Y;

  if(X % Y == 0){
    cout << -1 << endl;
  }else{
    cout << X << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s; 
	cin>>s; 
	ll k;
	cin>>k;
	vector<ll>vec;
	int z = s.size();
	ll x=1;
	for(int i=1;i<z;i++){
		if(s[i]==s[i-1])x++;
		else{
			vec.pb(x);
			x = 1;
		}
	}
	vec.pb(x);
	ll ans = 0;

	if(vec.size()==1){
		ans = z*k/2;
		cout<<ans<<endl;
		return 0;
	}
	for(ll x:vec){
		ans+=x/2;
	}
	ans*=k;
	ll trt;
	if(s[0]==s[z-1]){
		trt = vec[0]/2;
		trt = trt*(k-1);
		ans-=trt;
		trt = vec.back()/2;
		trt = trt*(k-1);
		ans-=trt;
		trt = (vec[0]+vec.back())/2;
		trt = trt*(k-1);
		ans+=trt;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<numeric>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int>PII;
typedef pair<ll,ll>PLL;
typedef long double ld;

const int maxn=1e6+10;

ll ans;

int a[maxn];

int main(){

	ll n,m;
	cin>>n>>m;
	ans=0;
	for(ll i=1;i<=m;i++){
		cin>>a[i];
		ans+=a[i];
	}
	if(ans>n)cout<<-1<<endl;
	else cout<<n-ans<<endl;

	return 0;
}

Measured memory_bytes: 3632
N = gets.to_i
MAX = 10 << 60
dp = Array.new(N + 1000) { MAX }
dp[0] = 0
(0...N).each do |i|
  next unless dp[i]
  dp[i + 1] = dp[i] + 1 if dp[i] + 1 < dp[i + 1]
  a = 6
  while i + a <= N
    dp[i + a] = dp[i] + 1 if dp[i] + 1 < dp[i + a]
    a *= 6
  end
  a = 9
  while i + a <= N
    dp[i + a] = dp[i] + 1 if dp[i] + 1 < dp[i + a]
    a *= 9
  end
end
puts dp[N]


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long ll;

ll ans = LLONG_MAX;

void relax (ll a, ll b) {
  // by - ax = 1
  ll r = b - inv_mod(a, b);
  assert(r);
  ans = min(ans, a * r);
}

int main() {
  ll n; cin >> n; n <<= 1;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i) continue;
    ll j = n / i;
    if (__gcd(i, j) == 1) {
      relax(i, j); relax(j, i);
    }
  }
  cout << ans << '\n';
  return 0;
}



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

using namespace std;

struct edge {
  int to, cap, rev, cost;
};

constexpr int MAX_V = 1000;
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
int flag[MAX_V][MAX_V];

void add_edge(int from, int to, int cap, int cost) {
  G[from].push_back(edge{to, cap, (int)G[to].size(), cost});
  G[to].push_back(edge{from, 0, (int)G[from].size() - 1, -cost});
}

void bfs(int s) {
  fill_n(level, MAX_V, -1);
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int i = 0; i < G[v].size(); i++) {
      edge &e = G[v][i];
      if (e.cap > 0 && level[e.to] < 0) {
        level[e.to] = level[v] + 1;
        que.push(e.to);
      }
    }
  }
}
int dfs(int v, int t, int f) {
  if (v == t) return f;
  for (int &i = iter[v]; i < G[v].size(); i++) {
    edge &e = G[v][i];
    if (e.cap > 0 && level[v] < level[e.to]) {
      int d = dfs(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
int max_flow(int s, int t) {
  int flow = 0;
  for (;;) {
    bfs(s);
    if (level[t] < 0) return flow;
    fill_n(iter, MAX_V, 0);
    int f;
    while ((f = dfs(s, t, numeric_limits<int>::max())) > 0) {
      flow += f;
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    add_edge(a, b, 1, 0);
    add_edge(b, a, 1, 0);
    flag[b][a] = i + 1;
  }
  int s, t;
  cin >> s >> t;
  cout << max_flow(s, t) << endl;
  set<int> ans;
  for (int i = 0; i < MAX_V; ++i) {
    for (auto e : G[i]) {
      if (flag[i][e.to] && e.cap < 1) ans.insert(flag[i][e.to]);
    }
  }
  cout << ans.size() << endl;
  for (auto x : ans) {
    cout << x << endl;
  }
}



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

int main() {
  int n;
  cin >> n;
  
  if(n % 2 != 0){
    n += 1;
  }  
  cout << n / 2 << endl;
  return 0;
}

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

using namespace std;

int main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  int s = max(a,c);
  int e = min(b,d);
  int ans = e - s;
  if(ans < 0) ans = 0;

  cout << ans << endl;
}


Measured memory_bytes: 256
x, y = map(int, input().split())

if x < y:
    if x * y >= 0:
        print(y - x)
    else:
        print(abs(x + y) + 1)
else:
    if x * y <= 0:
        print(abs(x + y) + 1)
    else:
        print(x - y + 2)

Measured memory_bytes: 2940
<?php
$str = trim(fgets(STDIN));
$chars = str_split($str);
if ($str === 'RRR') {
    echo 3;
} elseif ($str === 'RRS' || $str === 'SRR') {
    echo 2;
} elseif (count(array_unique($chars)) === 1 && array_unique($chars)[0] === 'S') {
    echo 0;
} else {
    echo 1;
}

Measured memory_bytes: 16204
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
  int h,w;
  while(cin>>h>>w,h||w){
    int x=0,y=0;
    vector<string> map(h);
    for(auto &str:map)
      cin>>str;
    while(x!=-1){
      char tile=map[y][x];
      map[y][x]='=';
      switch(tile){
        case '>':
          x++;
          break; 
        case '<':
          x--;
          break;  
        case '^':
          y--;
          break;
        case 'v':
          y++;
          break;
        case '.':
          cout<<x<<' '<<y<<endl;
          x=-1;
          break;
        case '=':
          cout<<"LOOP"<<endl;
          x=-1;
          break;
      }

    }
  }

}

Measured memory_bytes: 1232
from subprocess import call
call (('pypy3', '-c', """
from collections import deque

def main():
    h, w = map(int, input().split())
    A = [list(input()) for _ in range(h)]
    d = [[10**9] * w for _ in range(h)]
    que = deque([])
    
    for i in range(h):
        for j in range(w):
           if A[i][j] == "#":
               que.append([i, j])
               d[i][j] = 0
           else:
               d[i][j] = 10 ** 9
            
    while que:
        x, y = que.popleft()
        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]
        for i in range(4): 
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < h and 0 <= ny < w and d[nx][ny] == 10**9:
                d[nx][ny] = d[x][y] + 1
                que.append([nx, ny])
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, d[i][j])
    print(ans)
    
    return
    
main()

"""))


Measured memory_bytes: 180920
import collections


n = int(input())
v = list(map(int, input().split()))

v1 = []
v2=[]

for i in range(n):
    if i%2==0:
        v1.append(v[i])
    else:
        v2.append(v[i])

v1_1 = collections.Counter(v1).most_common()[0][1]
v2_1 = collections.Counter(v2).most_common()[0][1]

if collections.Counter(v1).most_common()[0][0]==collections.Counter(v2).most_common()[0][0]:
    if v1_1!=n//2 and v2_1!=n//2:
        v1_2 = collections.Counter(v1).most_common()[1][1]
        v2_2 = collections.Counter(v2).most_common()[1][1]
        print(min(n-v2_1-v1_2,n-v1_1-v2_2))
    elif v1_1==n//2 and v2_1==n//2:
        print(n//2)
    elif v1_1!=n//2 and v2_1==n//2:
        v1_2 = collections.Counter(v1).most_common()[1][1]
        print(n-v2_1-v1_2)
    elif v1_1==n//2 and v2_1!=n//2:
        v2_2 = collections.Counter(v2).most_common()[1][1]
        print(n-v2_2-v1_1)
else:
    print(n-v1_1-v2_1)

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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool is_prime(ll n){
	if (n == 1) return false;
	for(int i = 2; i * i <= n; i++){
		if (n % i == 0) return false;
	}
	return true;
}

int main()
{
	int a,d,n;
	while(cin>>a>>d>>n,a!=0&&d!=0&&n!=0){
		int cnt=0;
		int p=0;
		int i=0;
		while(cnt<n){
			if(is_prime(ll(a+i*d)))cnt++,p=a+i*d;
			i++;
		}
		cout<<p<<endl;
	}
	return 0;
}


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

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

const long long MAXN = 1e5 + 21, inf = 1e18 + 21, LG = 20;

int n, m;
int a[MAXN];
map <int, bool> mp;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    mp[1] = true;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        a[i] = 1;

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        if (mp[x] == true) {
            if (a[x] == 1) {
                mp[x] = false;
                mp[y] = true;
            }
            else if (a[x] > 1) 
                mp[y] = true;
        }
        a[x]--;
        a[y]++;
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++)
        if (mp[i])
            ans++;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N);
    ll t = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        t += a[i];
    }

    ll s = 0;
    ll ans = MAXINF;
    Rep(i, 0, N-1){
        s += a[i];
        t -= a[i];
        ans = min(ans, abs(s-t));
    }
    pr(ans);
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
int main(void){
    int n,m;
    scanf("%d%d",&n,&m);
    unsigned long long p[m],y[m];
    unsigned long long x[m];
    for(int i=0;i<m;i++){
        scanf("%lu%lu",&p[i],&y[i]);
        x[i]=(p[i]<<47)+(y[i]<<17)+i;
    }
    std::sort(x,x+m);
    int c=1;
    y[(x[0]<<47)>>47]=c;
    for(int i=1;i<m;i++){
        if(x[i]>>47==x[i-1]>>47)c++;
        else c=1;
        y[(x[i]<<47)>>47]=c;
        y[(x[i]<<47)>>47]=c;
    }
    for(int i=0;i<m;i++){
        printf("%06lu%06lu\n",p[i],y[i]);
    }
}

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

int main() {
  int n; cin >> n;
  int four = 0, two = 0, other = 0;
  for (int i = 0; i < n; i ++) {
    int t; cin >> t;
    if (t % 4 == 0) four ++;
    else if (t % 2 == 0) two ++;
    else other ++;
  }

  string ans;
  if (four+1 == other && four+other == n) ans = "Yes";
  else if (four >= other) ans = "Yes";
  else ans = "No";

  cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
s += "R"
n = len(s)
ans = [0] * n
p = 0
rs = 0
ls = 0
for i in range(n):
    if p == 0:
        if s[i] == "L":
            ans[i - 1] += (i - rs + 1) // 2
            ans[i] += (i - rs) // 2
            ls = i
            p = 1
    if p == 1:
        if s[i] == "R":
            ans[ls - 1] += (i - ls) // 2
            ans[ls] += (i - ls + 1) // 2
            rs = i
            p = 0


print(*ans[:n - 1])

Measured memory_bytes: 47756
#include<algorithm>
#include<iostream>
using namespace std;
int a[100035],n,l,t,x,cnt;
int main(){
	cin>>n>>l>>t;
    for(int i=1;i<=n;i++){
    	cin>>a[i]>>x;
        a[i]+=((x==1)?t:-t);
        cnt+=a[i]/l;
        if(a[i]%l<0){
			cnt--;
		}
        ((a[i]%=l)+=l)%=l;
    }
    sort(a+1,a+n+1);
    ((cnt%=n)+=n)%=n;
    for(int i=cnt+1;i<=n;i++){
    	cout<<a[i]<<endl;
    }
    for(int i=1;i<=cnt;i++){
    	cout<<a[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1536
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    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; 
}
vector<int> A[200010];
void solve() {
    int n;cin>>n;
    int temp;
    fr(i,2,n){
        cin>>temp;
        A[temp].pb(i);
    }
    fr(i,1,n)cout<<A[i].size()<<endl;
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 14544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void readInt(int &x) {
	x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;
}
inline void readLong(ll &x) {
	x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x*=f;
}
/*================Header Template==============*/
ll n;
int main() {
	readLong(n);
	for(ll h=1;h<=3500;h++) {
		for(ll w=1;w<=3500;w++) {
			ll tmp=4*h*w-n*h-n*w;
			ll get=n*h*w;
//			cout<<tmp<<endl;
			if(tmp<=0)
				continue;
			if(get%tmp==0) {
				cout<<h<<" "<<get/tmp<<" "<<w<<endl;
				return 0;
			}
		}
	}
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int a[32]={1,1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
signed main(){
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

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

struct UnionFind{
    vector<int> parent;
    UnionFind(int size): parent(size, -1) {}
    
    int root(int x){
        return parent[x]<0? x: parent[x] = root(parent[x]);
    }
    void uniteSet(int x, int y){
        x = root(x);
        y = root(y);
        if (x==y) return;
        if (parent[x]>parent[y]) swap(x,y);
        //parent[x] += parent[y];
        parent[y] = x;
    }
    bool findSet(int x, int y){
        return root(x) == root(y);
    }
};

int main(){cin.tie(0);ios::sync_with_stdio(false);
    
    int nb_v, nb_lines;
    cin >>nb_v
        >>nb_lines;
    UnionFind G(nb_v);
    for(int i=0; i<nb_lines; ++i){
        int v1, v2;
        cin >>v1
            >>v2;
        G.uniteSet(v1,v2);
    }

    cin >>nb_lines;
    for(int i=0; i<nb_lines; ++i){
        int v1, v2;
        cin >>v1
            >>v2;
        cout<<(G.findSet(v1, v2)? "yes\n":"no\n");
    }    
}

Measured memory_bytes: 3356
#include<iostream>
#include<map>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    int a[105];
    int mn=1000000;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }

    for(int i=1;i<=100;i++)
    {
        int sum=0;
        for(int j=0;j<n;j++)
        {
            sum+=(a[j]-i)*(a[j]-i);
        }
        mn=min(mn,sum);
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 256
import sys
import numpy as np
import math
import random
from decimal import Decimal
import itertools
import re
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(2147483647)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def main():
	n = I()
	A = np.zeros(n)
	B = np.zeros(n)
	for i in range(n):
			A[i], B[i] = LI()
	if n % 2 == 0:
		print(int((np.median(B)-np.median(A))*2+1))
	else:
		print(int(np.median(B)-np.median(A)+1))



if __name__ == '__main__':
    main()

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

using namespace std;

vector< int > nums;

template< typename T >
struct SegmentTree
{
  vector< T > seg, add;
  int sz;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, 0);
    add.assign(2 * sz - 1, 0);
  }

  T merge(T a, T b)
  {
    return (a + b);
  }

  void set(int k, int x)
  {
    seg[k + sz - 1] = x;
  }

  void build()
  {
    for(int k = sz - 2; k >= 0; k--) {
      seg[k] = merge(seg[2 * k + 1], seg[2 * k + 2]);
    }
  }

  T rmq(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (0);
    if(a <= l && r <= b) return (seg[k] + add[k] * (nums[r] - nums[l]));
    return (merge(rmq(a, b, 2 * k + 1, l, (l + r) >> 1),
                  rmq(a, b, 2 * k + 2, (l + r) >> 1, r)) +
            (add[k] * (min(nums[r], nums[b]) - max(nums[l], nums[a]))));
  }

  T rmq(int a, int b)
  {
    return (rmq(a, b, 0, 0, sz));
  }

  void rangeadd(int a, int b, T x, int k, int l, int r)
  {
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      add[k] += x;
      return;
    }
    rangeadd(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    rangeadd(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    seg[k] += x * (min(nums[r], nums[b]) - max(nums[a], nums[l]));
  }

  void rangeadd(int a, int b, T x)
  {
    rangeadd(a, b, x, 0, 0, sz);
  }
};

using int64 = long long;

int main()
{
  int N, M, Q;
  int A[100000], B[100000], C[100000];
  int X[100000], Y[100000];
  int64 Z[100000];
  int L[100000], R[100000];

  scanf("%d %d %d", &N, &M, &Q);

  for(int i = 0; i < M; i++) {
    scanf("%d %d %d", &A[i], &B[i], &C[i]);
    --A[i];
    nums.emplace_back(A[i]);
    nums.emplace_back(B[i]);
  }

  for(int i = 0; i < Q; i++) {
    scanf("%d %d %lld", &X[i], &Y[i], &Z[i]);
    --X[i];
    L[i] = -1, R[i] = M - 1;
    nums.emplace_back(X[i]);
    nums.emplace_back(Y[i]);
  }
  sort(begin(nums), end(nums));
  nums.erase(unique(begin(nums), end(nums)), end(nums));

  for(int i = 0; i < M; i++) {
    A[i] = lower_bound(begin(nums), end(nums), A[i]) - begin(nums);
    B[i] = lower_bound(begin(nums), end(nums), B[i]) - begin(nums);
  }
  for(int i = 0; i < Q; i++) {
    X[i] = lower_bound(begin(nums), end(nums), X[i]) - begin(nums);
    Y[i] = lower_bound(begin(nums), end(nums), Y[i]) - begin(nums);
  }

  vector< int > order(M);
  iota(begin(order), end(order), 0);
  sort(begin(order), end(order), [&](int a, int b)
  {
    return (C[a] < C[b]);
  });

  for(int i = 0; i < 17; i++) {
    vector< pair< int, int > > mid(Q);
    for(int j = 0; j < Q; j++) {
      mid[j] = {(L[j] + R[j]) / 2, j};
    }
    sort(begin(mid), end(mid));
    int tail = 0;
    SegmentTree< int64 > tree(nums.size());
    for(int j = 0; j < M; j++) {
      tree.rangeadd(A[order[j]], B[order[j]], 1);
      while(tail < Q && mid[tail].first == j) {
        const int idx = mid[tail].second;
        if(tree.rmq(X[idx], Y[idx]) >= Z[idx]) R[idx] = j;
        else L[idx] = j;
        ++tail;
      }
    }
  }

  for(int i = 0; i < Q; i++) {
    printf("%d\n", C[order[R[i]]]);
  }
}

Measured memory_bytes: 25564
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e6 + 17;

int n, a, b;

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	scanf("%d %d", &a, &b);
	return true;
}

void solve()
{
	printf("%lld\n", max(0ll, 1ll * (n - 1) * b + a - (1ll * (n - 1) * a + b) + 1ll));
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N; cin >> N;
	LLONG ans = 0;
	for (int A = 1; A <= N - 1; ++A)
	{
		ans += (N - 1) / A;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b,q;
    cin>>a>>b>>q;
    vector<ll> s(a), t(b), x(q);
    rep(i,a) cin>>s[i];
    rep(i,b) cin>>t[i];
    rep(i,q) cin>>x[i];
    sort(btoe(s)); sort(btoe(t));
    rep(i,q){
        int l1=0, l2=0, r1=a-1, r2=b-1;
        int m1,m2;
        ll ans;
        while(r1-l1>1){
            m1=(l1+r1)/2;
            if(s[m1]>x[i]) r1=m1;
            else l1=m1;
        }
        while(r2-l2>1){
            m2=(l2+r2)/2;
            if((t[m2]>x[i])) r2=m2;
            else l2=m2;
        }
        ll ans1=abs(x[i]-s[l1])+min(abs(s[l1]-t[l2]),abs(s[l1]-t[r2]));
        ll ans2=abs(x[i]-s[r1])+min(abs(s[r1]-t[l2]),abs(s[r1]-t[r2]));
        ll ans3=abs(x[i]-t[l2])+min(abs(t[l2]-s[l1]),abs(t[l2]-s[r1]));
        ll ans4=abs(x[i]-t[r2])+min(abs(t[r2]-s[l1]),abs(t[r2]-s[r1]));
        ans=ans1;
        ans=min(ans,ans2);
        ans=min(ans,ans3);
        ans=min(ans,ans4);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include<stdio.h>
int main(void)
{
	int n,h[20];
	int highest=0;
	int num=1;
	scanf("%d",&n);
	for (int i=0;i<n;i++)
	{
		scanf("%d",&h[i]);	
	}
	highest=h[0];
	for (int i=1;i<n;i++)
	{
		if(highest<=h[i])
		{
			highest=h[i];
			num++;
		}
	}
	printf("%d",num);
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

    public class Program
    {
        public static void Main(string[] args)
        {
            new A().test();
        }
    }
	public class A
	{
		public void test()
		{
			// 普通の文字列
			var before = CommonRead.ReadStr();
			var after = CommonRead.ReadStr();

			if (after.Length == before.Length + 1
				&& before.Equals(after.Substring(0, after.Length - 1)))
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}

		}
	}
static class CommonRead
{
    public static string ReadStr()
    {
        return Console.ReadLine();
    }
    public static string[] ReadStrA()
    {
        return ReadStr().Split(' ');
    }
    public static List<string> ReadStrL()
    {
        return ReadStrA().ToList();
    }
    public static int ReadInt()
    {
        return Convert.ToInt32(ReadStr());
    }
    public static int[] ReadIntA()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray();
    }
    public static List<int> ReadIntL()
    {
        return ReadStrA().Select(s => Convert.ToInt32(s)).ToList();
    }
    public static long ReadLong()
    {
        return Convert.ToInt64(ReadStr());
    }
    public static long[] ReadLongA()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray();
    }
    public static List<long> ReadLongL()
    {
        return ReadStrA().Select(s => Convert.ToInt64(s)).ToList();
    }

    public static decimal ReadDecimal()
    {
        return Convert.ToDecimal(ReadStr());
    }
    public static decimal[] ReadDecimalA()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray();
    }
    public static List<decimal> ReadDecimalL()
    {
        return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList();
    }

    public static double ReadDouble()
    {
        return Convert.ToDouble(ReadStr());
    }
    public static double[] ReadDoubleA()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray();
    }
    public static List<double> ReadDoubleL()
    {
        return ReadStrA().Select(s => Convert.ToDouble(s)).ToList();
    }

}





Measured memory_bytes: 25896
k,s=map(int,input().split())
ans=0

for x in range(k,-1,-1):
    if s-x > k*2:
        break
    if s < x:
        continue
    for y in range(k,-1,-1):
        if s-x-y > k:
            break
        if 0<= s-x-y <=k:
            ans +=1

print(ans)


Measured memory_bytes: 2940
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;

void dfs(vector<vector<int>>& childLists, vector<vector<int>>& edgeIds, vector<int>& weights, const int& v){
    for(int i = 0; i < childLists[v].size(); i++){
        int u = childLists[v][i];
        weights.push_back(0);
        edgeIds[u].push_back(weights.size()-1);
        dfs(childLists, edgeIds, weights, u);
        weights.push_back(0);
        edgeIds[u].push_back(weights.size()-1);
    }
}

void add(vector<int>& tree, const int& n, const int& k, const int& w){
    int i = k + n - 1; 
    while(i > 0){
        tree[i] += w;
        i = (i - 1)/2;
    }
    tree[i] += w;
}

int getSumUtil(vector<int>& tree, const int& L, const int& R, const int& i, const int& l, const int& r){
    if(i >= tree.size() || l > r){
        return 0;
    }
    if(r < L || l > R){
        return 0;
    }
    if(l >= L && r <= R){
        return tree[i];
    }
    int m = l + (r - l)/2;
    return  getSumUtil(tree, L, R, 2*i+1, l, m) + getSumUtil(tree, L, R, 2*i+2, m+1, r);
}

int getSum(vector<int>& tree, const int& n, const int& L, const int& R){
    return getSumUtil(tree, L, R, 0, 0, n-1);
}

int main(){
    int n, q, k, x, v, w;
    scanf("%d", &n);
    vector<vector<int>> childLists(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &k);
        for(int j = 0; j < k; j++){
            scanf("%d", &x);
            childLists[i].push_back(x);
        }
    }
    vector<int> weights;
    vector<vector<int>> edgeIds(n);
    dfs(childLists, edgeIds, weights, 0);
    int h = ceil(log2(weights.size()))+1;
    int max_size = pow(2, h)-1;
    vector<int> tree(max_size, 0);
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        scanf("%d", &x);
        if(x == 0){
            scanf("%d %d", &v, &w);
            add(tree, pow(2, h-1), edgeIds[v][0], w);
            add(tree, pow(2, h-1), edgeIds[v][1], -w);
        }
        else if(x == 1){
            scanf("%d", &v);
            printf("%d\n", v == 0? 0 : getSum(tree, pow(2, h-1), 0, edgeIds[v][0]));
        }
        else printf("invalid query %d\n", x);
    }
}



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

int main(){
  int n;
  cin >> n;
  int x = 0;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    if(a.at(i) % 2 == 0){
      if(a.at(i) % 3 == 0 || a.at(i) % 5 == 0)
        x++;
      else
        x -= 100000;
    }
  }
  if(x>=0)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    set<int>s;
    cin>>a>>b>>c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if(s.size()==2){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

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

using namespace std;

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    bool ans = true;
    while (true)
    {
        if (s.size() < 2)
        {
            ans = false;
            break;
        }
        if (s.substr(0, 2) != "hi")
        {
            ans = false;
            break;
        }
        s.erase(0, 2);
        if (s.size() == 0)
        {
            break;
        }
    }
    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).expect("Fail");
    let vec: Vec<&str> = line.split_whitespace().collect();
    let a:u32 = vec[0].parse().unwrap();
    let b:u32 = vec[1].parse().unwrap();
    if a > 9 || b > 9 {
        print!("-1");
    } else {
        print!("{}", a * b);
    }
}

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

int n;

int check(string s)
{
    int x=0;
    int three=0,five=0,seven=0;
    for(int i=0;i<s.size();i++){
        x*=10;
        x+=s[i]-'0';
        if(s[i]=='3') three++;
        if(s[i]=='5') five++;
        if(s[i]=='7') seven++;
    }
    if(x>n) return 0;
    if(three==0 or five==0 or seven==0) return 0;
    return 1;
}

int dfs(string s)
{
    if(s.size()>9) return 0;
    
    int r=check(s);
    r+=dfs(s+'3');
    r+=dfs(s+'5');
    r+=dfs(s+'7');
    return r;
}

int main()
{   
   cin>>n;
   cout<<dfs("")<<endl;
}

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

int main() {
  int a, b, c, d;
  int L = 0, R = 0;
  
  cin >> a >> b >> c >> d;
  L = a + b;
  R = c + d;
  
  if(L == R)
 	cout << "Balanced" << endl;
  else if(L > R)
    cout << "Left" << endl;
  else
    cout << "Right" << endl;
  
}

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

int main(){
ll n; cin >> n;
int white = 0; int red = 0;
int w[200005] = {0};
int r[200005] = {0};
string t;
for(int i=0; i< n; i++){
char c; cin >> c;
t += c;
}
for(int i=0; i< n; i++){
if(t[i]=='W'){
white++;
w[i] = white;
}else{
w[i]=white;
}
}
reverse(t.begin(),t.end());
for(int i=0; i< n; i++){
if(t[i]=='R'){
red++;
r[i] = red;
}else{
r[i]=red;
}
}
int ans = 0;
for(int i = 0; i< n; i++){
if(w[i] != r[n-2-i]) continue;
ans = w[i];
}

cout << ans << endl;
return 0;
}

Measured memory_bytes: 5256
s = int(input())

def gusu(n):
    return(n/2)

def kisu(n):
    return(3*n + 1)

ss = [s]
count = 1

while True:
    n = ss[count-1]
    if n % 2 == 0:
        nn = gusu(n)
    else:
        nn = kisu(n)
    if nn in ss:
        print(count+1)
        break
    else:
        ss.append(nn)
        count += 1
#         print(ss)
    



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

#define FOR(i, n) for(int i = 0; i < (n); i++)
#define FORq(i, m, n) for(int i = (m); i < (n); i++)
#define FORr(i, n) for (int i = (n); i >= 0; i++)

int main() {
	int D;
	cin >> D;
	if (D == 25) {
		cout << "Christmas" << endl;
	}
	else if (D == 24) {
		cout << "Christmas Eve" << endl;
	}
	else if (D == 23) {
		cout << "Christmas Eve Eve" << endl;
	}
	else if (D == 22) {
		cout << "Christmas Eve Eve Eve" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    char a[3][3];
    for(int i=0;i<=2;i++){
        for(int j=0;j<=2;j++){
            cin>>a[i][j];
        }
    }
    cout<<a[0][0]<<a[1][1]<<a[2][2]<<endl;
    return 0;
}


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

#define Art Code
#define Artist Shivam Gupta
#define MoT This Art belongs to Artist
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FoR(i,s,x) for(i=s-1;i>=x;i--)
#define ForE(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define mod 1000000007
#define MAX 200005

int main() {
    FASTIO;
    ll t=1, i, j, k, l;
    // cin>>t;
    W(t--) {
        ll n, m;
        cin>>n>>m;
        string s[n+1], S;
        Fore(i,0,m) s[0]+='0';
        Fore(i,1,n) cin>>S, s[i]='0'+S;
        // Fore(i,1,n) { Fore(j,1,m) cout<<s[i][j]; nl; }
        ll dp[n+1][m+1]={};
        Fore(i,1,n) {
            Fore(j,1,m) {
                if(i*j==1) { dp[i][j]=1; continue; }
                if(s[i-1][j]=='.') dp[i][j]+=dp[i-1][j];
                if(s[i][j-1]=='.') dp[i][j]+=dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
        pr(dp[n][m]);        
        nl;
    }
    return 0;
}

Measured memory_bytes: 12512
s = input()
t = input()
ls = []
for i in range(len(s) - len(t) + 1):
    ls.append(s[i:i+len(t)])
now = 0
minimum = len(t)
for i in range(len(ls)):
    now = 0
    for j in range(len(t)):
        if t[j] == ls[i][j]:
            now += 1
    if len(t) - now < minimum:
        minimum = len(t) - now
print(minimum)

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

int main()
{
	int n;
	int score[1000];
	while(cin >> n){
		if(n==0)
			break;
		for(int i=0;i<n;i++){
			cin >> score[i];
		}
		sort(score, score+n);
		int sum = 0;
		for(int i=1;i<n-1;i++){
			sum += score[i];
		}
		cout << sum/(n-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 0