akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,D; cin >> N >> D;
    double X,Y;
    int out=0;
    for(int i=0;i<N;i++){
        cin >> X >> Y;
        if(sqrt(X*X+Y*Y)<=1.0*D) out++;
    }
    cout << out << endl;

    return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;

int main()
{
  int a,b,c,d,e;
  int ans=0;
  cin>>a>>b>>c>>d>>e;

  if(a<0)
    ans+=abs(a-0)*c;
  
  if(a<=0)
    ans+=d;

  if(b>0)
    if(a>0)
      b=b-a;
    ans+=e*b;

  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 3116
n=int(input())
List = [int(i) for i in input().split()]

List_sort =sorted(List)
#print(List_sort)

j=0
if List_sort[int(n/2)-1]==List_sort[int(n/2)]:
    j=0
else:
    j=List_sort[int(n/2)]-List_sort[int(n/2)-1]
    
print(j)

Measured memory_bytes: 52780
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  int N, H;
  int cnt = 0; // 最初の山は必ず見える
  int max_mount = 0;

  cin >> N;
  rep(i, N){
    cin >> H;
    if (max_mount <= H) cnt++;
    max_mount = max(max_mount, H);

  }
  
  cout << cnt << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  string s;
  cin >> s;
  int n=s.size();
  int k=0;
  rep(i,n){
    k=(k+(s[i]-'0'))%9;
  }
  if(k==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#if DEBUG && !ONLINE_JUDGE
    #include "/home/tushar_garg/Desktop/cpp/debug.h"
#else
    #define dbg(x...)
#endif

typedef     long long                            ll; 
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;

#define rep(i, a, n) for (auto i=(a)-((a)>(n)); i!=(n)-((a)>(n)); i+=1-2*((a)>(n)))
#define trav(i, a) for(auto &i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define eb emplace_back
#define flash ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define QuickSilver cin.exceptions(cin.failbit),setprecision(12),cout.precision(12);
#define fill(a, b) memset(a, b, sizeof(a)
#define get(a) rep(i,0,sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000009

int main(){
	flash; QuickSilver;
	int n; cin>>n;
	vl v(3, 0), p(3, 0);
	rep(i,0,n){
		int a, b, c; cin>>a>>b>>c;
		p[0]=a+max(v[1], v[2]);
		p[1]=b+max(v[0], v[2]);
		p[2]=c+max(v[0], v[1]);
		v=p;
	}
	cout<<max(v[0], max(v[1], v[2]))<<"\n";
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  string s, t="";
  cin>>s;
  int n=s.size(), m;

  if(n<=2){
    cout<<0<<endl;
    return 0;
  }

  REP(i, n){
    if(i<n-1) if(s[i]=='B'&&s[i+1]=='C'){
      t+='X';
      ++i;
    }
    else t+=s[i];
  }
  m=t.size();
  int count=0;
  LL ans=0;
  for(int i=m-1; i>-1; --i){
    if(t[i]=='X') ++count;
    else if(t[i]=='A') ans += count;
    else count=0;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 776
import math

while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        s1 = (x2-x1)*(yp-y1) - (y2-y1)*(xp-x1)
        s2 = (x3-x2)*(yp-y2) - (y3-y2)*(xp-x2)
        s3 = (x1-x3)*(yp-y3) - (y1-y3)*(xp-x3)
        if math.copysign(1, s1) == math.copysign(1, s2) and math.copysign(1, s1) == math.copysign(1, s3):
            print("YES")
        else:
            print("NO")
    except:
        break



Measured memory_bytes: 5648
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
//<DEFINE>
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
void File() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
	return __builtin_popcount((unsigned int)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
using ll = long long;
using ull = unsigned long long;
#define mod 1000000007
ll gcd(ll a, ll b) {
	return!b ? a : gcd(b, a % b);
}
#define fix(n) cout << fixed << setprecision(n);
#define all(a) a.begin(), a.end()
#define skip continue
#define stop(n) return cout<<n,0
#define pi  acos(-1)
#define endl "\n"
#define ceil(x,y) (x+y-1)/y
//sin(x*pi/180)
//be careful from the multiplication while using this define 
//alot of memset may couse TLE
#define TC int t;cin>>t;while(t--)
//</DEFINE>
int dx[] = { 0,0,-1,1,1,1,-1,-1 };
int dy[] = { 1,-1,0,0,1,-1,1,-1 };
int n, k;
//<FUNCTIONS>
//</FUNCTIONS>	
bool dp[100001][2];
int main() {
	Fast(), File();
	cin >> n >> k;
	vector<int>v(n);
	for (int i = 0; i < n; i++)cin >> v[i];
	for (int i = 0; i <= k; i++) {
		dp[i][0] = 1;
		for (int j = 0; j < n; j++) {
			if (i - v[j] >= 0)dp[i][1] |= dp[i - v[j]][0];
			if (i - v[j] >= 0)dp[i][0] &= dp[i - v[j]][1];
		}
	}
	cout << (dp[k][1] ? "First" : "Second");
}

Measured memory_bytes: 3844
n,k = map(int,input().split())
lose = 0
if n >= k:
    for i in range(1,k):
        x = 0
        j = i
        while j < k:
            j *= 2
            x += 1
        lose += (2**x - 1)/(n * (2**x))
else:
    for i in range(1,n+1):
        x = 0
        j = i
        while j < k:
            j *= 2
            x += 1
        lose += (2**x - 1)/(n * (2**x))
print(1 - lose)


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << a*b/2 << endl;

  return 0;
}



///


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

using namespace std;

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v

vector<int> W;
int N, K;
int solve(int P) {
  int w = 0;
  int k = 1;
  REP(i, N) {
    if (w + W[i] <= P)
      w += W[i];
    else {
      w = W[i];
      ++k;
      if (w > P || k > K)
        return i;
    }
  }
  return N;
}
int main() {
  cin >> N >> K;

  REP(i, N) {
    IN(w);
    W.push_back(w);
  }
  if (K >= N) {
    cout << *max_element(ALL(W)) << endl;
    return 0;
  }
  int start = 0, end = 1000000000;
  int res = 0;
  while (start <= end) {
    int mid = start + (end - start) / 2;
    if (solve(mid) < N) {
      start = mid + 1;
    } else {
      res = mid;
      end = mid - 1;
    }
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 3504
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 1e5 + 20;
const int inf = 1e9 + 7;

int n, m;
int dp[1010][1010];

int go(int x, int y) {
	if (dp[x][y] != -1) re dp[x][y];
	if (x == 0 && y == 0) re 1;
	int ans = 0;
	if (x) ans = (ans + go(x - 1, y)) % inf;
	if (y) ans = (ans + go(x, y - 1)) % inf;
	re dp[x][y] = ans;
}

int main() {
	cin >> n >> m;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		for (int j = 0; j < m; j++)
			if (s[j] == '#') dp[i][j] = 0;
	}
	cout << go(n - 1, m - 1);
	return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
using namespace std;
int B[(1<<18)+1],N;
void solve(int m,int a,int b){
	if(m==0) return;
	if(B[m]||m==1){
		printf("%d %d ",a,b);
		return;
	}
	int bit=B[m&-m];
	int s1=a>>bit&1,s2=b>>bit&1,p;
	if(s1!=s2){
		int q=m^(1<<bit);
		p=q&-q;
		//if(p==0) printf("\nyyyy");
		solve(m^(1<<bit),a,a^p);
		solve(m^(1<<bit),a^p^(1<<bit),b);
	}
	else{
		p=B[(a^b)&-(a^b)];
		int q;
		for(q=0;q<N;q++)
			if((m>>q&1)&&q!=p&&q!=bit) break;
		if(q!=N){
			solve(m^(1<<bit)^(1<<p),a,a^(1<<q));
			solve(m^(1<<bit),a^(1<<bit)^(1<<q),a^(1<<bit)^(1<<q)^(1<<p));
			solve(m^(1<<bit)^(1<<p),a^(1<<p)^(1<<q),b);
		}
		else{
			q=(m^(1<<bit))&-(m^(1<<bit));
			printf("%d %d %d %d ",a,a^(1<<bit),a^q^(1<<bit),b);
		}
	}
}
int main(){
	int a,b,sum=0,i;
	scanf("%d %d %d",&N,&a,&b);
	for(i=0;i<=18;i++) B[1<<i]=i;
	for(i=0;i<N;i++)
		sum+=(a>>i&1)^(b>>i&1);
	if((sum&1)==0) printf("NO");
	else{
		printf("YES\n");
		solve((1<<N)-1,a,b);
	}
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main (void)
{
    int n,k;
    char s[10];
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%d",&k);
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[k-1])
        {
            s[i]='*';
        }
    }
    printf(s);
    return 0;
}


Measured memory_bytes: 1708
S = list(input())
S_odd = [s for i, s in enumerate(S) if i % 2 == 0]
S_even = [s for i, s in enumerate(S) if i % 2 != 0]
if 'L' in S_odd or 'R' in S_even:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 61820
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

struct node {
	bool done;
	vi to, cap;
	int id, from;
	int f;
};

class Max_Flow {
private:
	int fbuf;
	int n, s, t;
	stack<int> f;
	stack<int> stk;
	bool reset;
public:
	vector<node> nodes;
	int fret;
	Max_Flow(vector<node> A, int start, int goal) {
		nodes = A;
		n = A.size();
		s = start;
		t = goal;
		Loop(i, n) {
			Loop(j, A[i].to.size()) {
				nodes[A[i].to[j]].to.push_back(i);
				nodes[A[i].to[j]].cap.push_back(0);
			}
		}
		Loop(i, n) {
			int m = nodes[i].to.size();
			vector<P> p(m);
			Loop(j, m) p[j] = { nodes[i].to[j], nodes[i].cap[j] };
			sort(p.begin(), p.end());
			Loop(j, m) {
				nodes[i].to[j] = p[j].first;
				nodes[i].cap[j] = p[j].second;
			}
		}
		fbuf = 0;
		Loop(j, nodes[t].cap.size()) {
			fbuf += nodes[t].cap[j];
		}
	}
	void main_func() {
		while (stk.size()) stk.pop();
		Loop(i, n) nodes[i].done = false;
		stk.push(s);
		reset = false;
		dfs();
		if (reset) {
			main_func();
		}
		else {
			fret = 0;
			Loop(j, nodes[t].cap.size()) {
				fret += nodes[t].cap[j];
			}
			fret -= fbuf;
		}
		return;
	}
	//nodes[a]???nodes[b]????????????????????????
	int find_edge(int a, int b) {
		return lower_bound(nodes[a].to.begin(), nodes[a].to.end(), b) - nodes[a].to.begin();
	}
	void dfs() {
		if (stk.top() == t) {
			int flow = INF;
			while (f.size()) {
				flow = min(flow, f.top());
				f.pop();
			}
			int a = t, b;
			while (a != s) {
				b = nodes[a].from;
				nodes[b].cap[find_edge(b, a)] -= flow;
				nodes[a].cap[find_edge(a, b)] += flow;
				a = b;
			}
			reset = true;
		}
		else {
			int a = stk.top();
			nodes[a].done = true;
			Loop(i, nodes[a].to.size()) {
				if (nodes[a].cap[i] == 0) continue;
				int b = nodes[a].to[i];
				if (nodes[b].done) continue;
				stk.push(b);
				nodes[b].from = a;
				f.push(nodes[a].cap[i]);
				dfs();
				if (reset) break;
				f.pop();
			}
			stk.pop();
		}
		return;
	}
};

int main() {
	int n, m; cin >> n >> m;
	vector<node> nodes(n);
	Loop(i, m) {
		int a, b, c; cin >> a >> b >> c;
		nodes[a].to.push_back(b);
		nodes[a].cap.push_back(c);
	}
	Max_Flow mf(nodes, 0, n - 1);
	mf.main_func();
	cout << mf.fret << endl;
	return 0;
}

Measured memory_bytes: 3224
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	int N=S.size();
	int NS=S.size()/2;
	REP(i,NS){
		if(S[i]!=S[N-1-i]){
			out("No");
			return 0;
		}
	}
	string SL(S.substr(0,NS)),SR(S.substr(NS+1,NS));
	int M = SL.size();
	int NH=M/2;
	REP(i,NH){
		if(SL[i]!=SL[M-1-i]){
			out("No");
			return 0;
		}
		if(SR[i]!=SR[M-1-i]){
			out("No");
			return 0;
		}
	}
	out("Yes");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(a) cout << #a << ": " << a << endl
using ll = long long;
#define int long long
int trailing_zeros(int n) {
    if (n == 0) {
        return -1;
    }
    int count = 0;
    while (n % 2 == 0) {
        count++;
        n >>= 1;
    }
    return count;
}

int32_t main(){
	int n; cin>>n;
	vector<int> a(n);
	rep(i,n) {
		cin>>a[i];
	}
	int ans = 29;
	rep(i, n){
		//debug(trailing_zeros(a[i]));
		ans = min(ans, trailing_zeros(a[i]));
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
/************************************************
   Start coding only after you have clear idea. 
*************************************************/

#include <bits/stdc++.h>

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxm = 2e3+23;
const int maxn = 2e5+35;
int main(){
    int n; string s; map<string,int> mp;
    cin >> n;
    while(n--){
        cin >> s; mp[s] += 1;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3632
import math
 
 
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
  
 
a, b = map(int, input().split())
 
gcd = gcd(a, b)
 
res = set([1])
while gcd % 2 == 0: 
        res.add(2)
        gcd = gcd // 2
 
for i in range(3,int(math.sqrt(gcd))+1,2): 
    while gcd % i == 0: 
        res.add(i)
        gcd = gcd // i 
            
if gcd > 2: 
    res.add(gcd)
 
print(len(res))

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

multiset<int> d, t, intersect;
int n, m, temp;

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

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		d.insert(temp);
	}

	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> temp;
		t.insert(temp);
	}

	set_intersection(d.begin(), d.end(), t.begin(), t.end(), inserter(intersect, intersect.begin()));

	if (intersect.size() == t.size())
		cout << "YES\n";
	else
		cout << "NO\n";
}


Measured memory_bytes: 28416
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define mp make_pair
#define v vector
#define inp_push(no, v) \
    ll no;              \
    cin >> no;          \
    v.push_back(no);
#define pb push_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define UN(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define N 200005
#define mod 1000000009
#define INF INT64_MAX

//////////////////////////IMPORTANT FUNCTIONS/////////////////////////////////////////////

/* Guidlines berfore submitting solution
1. Check N value before submitting
2. Check all constant kind of values you are using. Might give WA. Think
3. Check mod value
*/

v<ll> fact(N);
v<ll> prime_check(1e6 + 2);
v<ll> primes;

long long powmod(long long x, long long y, long long m)
{
    long long res = 1LL;
    while (y)
    {
        if (y & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        y /= 2;
    }
    return res;
}

void init_fact()
{
    fact[0] = 1;
    for (ll i = 1; i < N; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

ll C(ll n, ll r)
{
    if (n < r)
        return 0;
    ll temp = fact[n] * powmod(fact[r], mod - 2, mod) % mod;
    temp *= powmod(fact[n - r], mod - 2, mod);
    temp %= mod;
    return temp;
}

void Sieve()
{
    for (ll i = 2; i <= 1e6 + 1; i++)
    {
        if (prime_check[i])
            continue;
        primes.pb(i);
        for (ll j = 2 * i; j <= 1e6 + 2; j += i)
            prime_check[j] = i;
    }
}
ll phi(ll n)
{
    ll i, res = n;
    for (i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            while (n % i == 0)
                n /= i;
            res -= res / i;
        }
    if (n > 1)
        res -= res / n;
    return res;
}

/////////////////////////////////////START CODE HERE/////////////////////////////////////////////

ll n, m;
v<ll> a(N), b(N);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // init_fact();
    // Sieve();
    ll k;
    cin >> n >> m >> k;
    for (ll i = 1; i <= n; i++)
        cin >> a[i], a[i] = a[i] + a[i - 1];
    for (ll i = 1; i <= m; i++)
        cin >> b[i], b[i] = b[i] + b[i - 1];
    ll ans = 0;
    for (ll i = 0; i <= n; i++)
    {
        ll j = upper_bound(b.begin() + 1, b.begin() + m + 1, k - a[i]) - b.begin();
        j--;
        // cout << a[i] << " " << b[j] << " ";
        // cout << j << "\n";
        if (a[i] + b[j] <= k)
            ans = max(ans, i + j);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 15840
// 26/01/20 // 10:06 AM //

#include <bits/stdc++.h>

using namespace std;

const int MAXN = (int)(1e2) + 10;
const int MAXK = (int)(1e5) + 10;

int n, k;
int a[MAXN], memo[MAXK];

int solve(int h){ // player, height
    if(memo[h]!=-1) return memo[h];

    if(!h) return memo[h] = 0;

    memo[h] = 0;

    for(int i=0; i<n && a[i]<=h; i++){
        memo[h] = !solve(h-a[i]);

        if(memo[h]) break;
    }

    return memo[h];
}

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

    memset(memo, -1, sizeof(memo));

    cin >> n >> k;
    for(int i=0; i<n; i++) cin >> a[i];

    cout << (solve(k)?"First":"Second") << endl;

    return 0;
}


Measured memory_bytes: 5376
import sys
input_data = input()
input_numbers = input_data.split()

if __name__ == '__main__':
    area = int(input_numbers[0]) * int(input_numbers[1])
    perimeter = (int(input_numbers[0]) * 2) + (int(input_numbers[1]) * 2)
    print(str(area) + " " + str(perimeter))



Measured memory_bytes: 5600
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
 
const int N = 4e7 + 10; 
 
typedef  long long ll;
 
map <int , int> ans;
set <int> res;
 
int main(){
    int n ;
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        int k ;
        cin>>k;
        if (res.count(k)){
            puts("NO");
            return 0;
        }
        else{
            res.insert(k);
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>

int main(int argc, char const *argv[]) {

    while(1) {
        int a, b;
        char op;
        scanf("%d %c %d", &a, &op, &b);

        if (op == '?') {
            break;
        } else if (op == '+') {
            printf("%d\n", a + b);
        } else if (op == '-') {
            printf("%d\n", a - b);
        } else if (op == '*') {
            printf("%d\n", a * b);
        } else {
            printf("%d\n", a / b);
        }

    }


    return 0;
}


Measured memory_bytes: 2088
#AGC046-B Extension
"""
https://maspypy.com/atcoder-%E5%8F%82%E5%8A%A0%E6%84%9F%E6%83%B3-2020-06-20agc046
「操作列の結果、完成図としてありうるものを数えよ」
という問題は、複数の操作後の完成図が同じ結果を取りうることを考慮し、
・完成図としてあり得るパターンの同値な言い換えを探す
・操作に制約を加えても同じ完成図を作成できることが一意になる
のどちらかを目指して、考察していく。

以下、問題の「縦を選んだ場合のマスの変化」は上ではなく下として考える。

ケース2の
2 1 3 4
について考える。
これは縦に1回と横に3回の追加を行うが、
実は縦の制御について、最も左端に存在する黒タイルについて場合分けをして良い。
w???
w???
b???
の盤面について考えた時、これは初手に縦の操作を選ぶことで達成できるが、
そうでないような操作で上図と同じような盤面になったとして、実は左下の位置が
黒になるような場合、？の位置もまた同じように決定されるので、そのような
操作は考慮しなくて良いことが分かる。

そのような操作とは、つまり、"縦方向の拡張を最速で行わなかった"ような操作である。
考察すべき2つめの条件、操作に制約を加えても同じ完成図を作成できることが一意になる
を達成することができた。

この時の?の組み合わせは、横拡張3回のうち、すべての拡張で3つを選べるので、
3*3通り
である。
次は、一番下の行で、初めて黒が出る位置を1つずつずらして考えていく。
w???
w???
wb??

この場合、右に1回横拡張を挟んで、すぐさま縦拡張,そのあと横拡張を2回行うので、
2*3*3

w???
w???
wwb?

2*2*3

w???
w???
wwwb

2*2*2

よって合計65通りとなる。

この操作をdpによって拡張する。
具体的には、
dp[i][j]:横幅iの時点で残りの縦幅がjの時、縦幅を利用する際の通し数
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
A,B,C,D = map(int,readline().split())
mod = 998244353
dp0 = [[0] * (D + 1) for _ in range(C + 1)]
dp1 = [[0] * (D + 1) for _ in range(C + 1)]
 
 
dp0[A][B] = 1
 
for x in range(A, C + 1):
    for y in range(B, D + 1):
        if x == A and y == B:
            continue
        dp0[x][y] = (dp0[x][y - 1] * x + dp1[x][y - 1] * 1) % mod
        dp1[x][y] = (dp0[x - 1][y] * y + dp1[x - 1][y] * y) % mod

ans = (dp0[C][D] + dp1[C][D]) % mod
print (ans)

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

  reverse(S.begin(),S.end());
  for (int i = 0; i < 4; i++)reverse(divide[i].begin(),divide[i].end());

  bool can = true;
  for (int i = 0; i < S.size();){
    bool can2 = false;
    for (int j = 0; j < 4; j++){
      string d = divide[j];
      if ( S.substr(i,d.size()) == d){
        can2 = true;
        i += d.size();
      }
    }
    if (!can2){
      can = false;
      break;
    }
  }
  if(can)cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <complex>

typedef long long ll;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

using namespace std;

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

int n[2];
vector<vector<P>> p;

bool solve(){
    if(n[0]==1 && n[1]==1)return true;
    vector<double> ths;

    rep(i,n[0])rep(j,i){
        P &p0=p[0][i], &p1=p[0][j];
        double th=arg(p0-p1);
        ths.push_back(th);
    }

    rep(i,n[1])rep(j,i){
        P &p0=p[1][i], &p1=p[1][j];
        double th=arg(p0-p1);
        ths.push_back(th);
    }

    for(double th:ths){
        auto before = p;
        rep(i,2)rep(j,n[i]){
            p[i][j] /= polar(1. ,th);
        }
        double M[2]={-INF,-INF}, m[2]={INF,INF};
        rep(i,2){
            rep(j,n[i]){
                M[i] = max(M[i],p[i][j].imag());
                m[i] = min(m[i],p[i][j].imag());
            }
        }
        if(M[0] < m[1] || M[1] < m[0]) return true;
        p = before;
    }
    return false;
}

int main(){
    while(cin>>n[0]>>n[1] && n[0]){
        // cout <<++c << endl;
        p={{},{}};
        rep(i,2){
            p[i].resize(n[i]);
            rep(j,n[i]){
                int x,y;
                cin>>x>>y;
                p[i][j] = P(x,y);
            }
        }

        puts(solve() ? "YES" : "NO");
    }
}

Measured memory_bytes: 1476
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	s := next()
	if s == "AAA" || s == "BBB" {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a[300];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long minx=1500000,s;
	for(int i=-500;i<=500;i++){
		s=0;
		for(int j=0;j<n;j++){
			s+=pow((a[j]-i),2);
		}
		minx=min(minx,s);
	}
	cout<<minx;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long int 
int main()
{
  string s,t;
  cin>>s>>t;
  
  int cnt=0;
  for(int i=0;i<s.size();i++)
  {
      if(s[i]!=t[i])
      {
          cnt++;
      }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3836
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//•*¨*•.¸¸♪I/O•*¨*•.¸¸♪

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	a := scanInts(5)
	k := scanInt()

	for i := 0; i < 5; i++ {
		for j := i+1; j < 5; j++ {
			if a[j]-a[i] > k {
				fmt.Println(":(")
				return
			}
		}
	}

	fmt.Println("Yay!")
}


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

#define repeat(i, x) for (int64_t i = 0; (i) < (int64_t)(x); (i)++)

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

    int n;
    cin >> n;

    map<int, int> counter;
    repeat (i, n) {
        int a;
        cin >> a;
        counter[a]++;
    }

    int numEven = 0;
    for (auto& mp : counter) {
        if (mp.second % 2 == 0) numEven++;
    }

    cout << counter.size() - numEven % 2 << endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>
using namespace std;

//long long a[100000];
//long long b[100000];

using namespace std;
 
string nums = "357";
int pow(int x, int y){
    if(y == 0){
        return 1;
    } else {
        return x * pow(x, y - 1);
    }
}
//int cost[100000][100000];
int main(){
    int N;
    cin >> N;

    int digit_num = 0;
    int tmp = 1;
    for(int i = 0; i < 9; i++){
        tmp *= 10;
        digit_num ++;
        if(N < tmp){
            break;
        }
    }

    if(digit_num < 3){
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for(int i = 3; i < digit_num; i++){
        ans += pow(3, i) - 3 * pow(2, i) + 3;
    }

    for(int three_set = 0; three_set < pow(3, digit_num); three_set++){
        string t;
        int tmp = three_set;
        bool appeared[3] = {false, false, false};
        for(int i = 0; i < digit_num; i++){
            int digit = tmp % pow(3, i + 1) / pow(3, i);
            tmp -= digit * pow(3, i);
            t.push_back(nums[digit]);
            appeared[digit] = true;
        }
        if(appeared[0] && appeared[1] && appeared[2] && atoi(t.c_str()) <= N){
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001

int main(){
  int i,j,n,k=0;
  int *A,*B,*C;
  scanf("%d",&n);
  A=malloc(sizeof(int)*n+1);
  B=malloc(sizeof(int)*n+1);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<A[i])k=A[i];
  }
  C=malloc(sizeof(int)*k+1);
  for(i=0;i<k;i++){
    C[i]=0;
  }
  for(j=0;j<n;j++){
    C[A[j]]++;
  }
  for(i=0;i<=k;i++){
    C[i]+=C[i-1];
  }
  for(j=n-1;j>=0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n+1;i++){
    if(i==1)printf("%d",B[i]);
   else printf(" %d",B[i]);
  }
  printf("\n");
  free(A);
  free(B);
  free(C);
  return 0;
}



Measured memory_bytes: 17108
n, m = map(int, input().split())
d = [list() for i in range(n+1)] 
out = []
for i in range(m):
    pi, yi = map(int, input().split())
    d[pi].append([yi, i])
    out.append(-1)

for i in range(len(d)):
    d[i].sort()

for i in range(1, n+1):
    for j in range(len(d[i])):
        out[d[i][j][1]] = str(i).zfill(6) + str(j+1).zfill(6)

for i in range(len(out)):
    print(out[i])

Measured memory_bytes: 39464
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 666666

signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int f=1;
	while(1){
		if(f%2){
			c-=b;
		}else{
			a-=d;
		}
		if(c<=0){
			 cout<<"Yes";return 0;
		}
		if(a<=0){
			cout<<"No";return 0;
		}
		f++;
		
	}
	return 0;
}

Measured memory_bytes: 3592
a=list(map(int,input().split()))
a.sort()
count=0
while a[1]!=a[2]:
    a[1]+=1
    a[0]+=1
    count+=1

if (a[1]-a[0])%2==0:
    count+=(a[1]-a[0])//2
else:
    count+=(a[1]-a[0])//2+2

print(count)


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

int main() {
  int n, x, sum=0;
  cin >> n >> x;
  
  int arr[n];
  for (int i=0; i<n; i++) {
    cin >> arr[i];
    sum+=arr[i];
  }

  sort(arr, arr+n);

  cout << n+((x-sum)/arr[0]);
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int A, B, C, D, P;
	long long int S1, S2;
	
	scanf("%d\n", &A);
	scanf("%d\n", &B);
	scanf("%d\n", &C);
	scanf("%d\n", &D);
	scanf("%d", &P);
	
	S1 = A * P;
	if(P > C) S2 = B + (P - C) * D;
	else S2 = B;
	printf("%lld\n", (S1 > S2) ? S2 : S1);
	
	return 0;
}


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

	int n = sc.nextInt();
     int a[] = new int[n];
      boolean h = true;
     for(int i=0; i<n; i++){
		a[i] = sc.nextInt();

       if(a[i]%2==0 && a[i]%3!=0 && a[i]%5!=0){
		    h = false;
       }
     }
      System.out.println(h?"APPROVED":"DENIED");
}
}

Measured memory_bytes: 23892
//lca
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

/*
lca(u,v)????????¨???O(logN)??§?±???????
?????????O(NlogN)
p??¨depth???????????£????????°????????????genlca????????§????????????,?????¬?????°??????G???????????¶????????¨
??????dfs+genlca??????????????????

path???????§£????????¨??????[u,z) + [v,z) + z ?????????????????????, ???????????????????????????(depth-1???????????????)??¨ok

*/

int bsr(int x){	//4~7 -> 2
	if(x==0) return -1;
	return 31 ^ __builtin_clz(x);
}
struct LCA{
	int N,n;
	vector<int> depth;
	vector<vector<int>> par;

	void dfs(int v,int p,const vector<vector<int>>& G){
		if(p<0) depth[v]=0;
		else depth[v]=depth[p]+1;
		par[v][0]=p;
		for(int u:G[v]){
			if(u!=p) dfs(u,v,G);
		}
	}

	LCA(const vector<vector<int>>& G){
		N = G.size();
		n = bsr(N);
		depth = vector<int>(N,0);
		par = vector<vector<int>>(N,vector<int>(n+1,0));

		dfs(0,-1,G);
		rep1(i,n){
			rep(v,N){
				if(par[v][i-1]==-1){
					par[v][i]=-1;
				}else{
					par[v][i]=par[par[v][i-1]][i-1];
				}
			}
		}
	}

	int lca(int u,int v){
		if(depth[u]<depth[v]){
			swap(u,v);
		}
		int d=depth[u]-depth[v];
		rep(i,n+1){
			if((d>>i)&1) u=par[u][i];
		}
		if(u==v) return u;
		for(int i=n;i>=0;i--){
			if(par[u][i]!=par[v][i]){
				u=par[u][i];
				v=par[v][i];
			}
		}
		return par[v][0];
	}

	int distance(int u,int v){
		return depth[u] + depth[v] - 2*depth[lca(u,v)];
	}
};


int main(){
	int N,Q;
	cin>>N;
	vector<vector<int>> G(N);
	rep(i,N){
		int n;
		cin>>n;
		rep(j,n){
			int x;
			cin>>x;
			G[i].pb(x);
			G[x].pb(i);
		}
	}
	LCA lca(G);
	cin>>Q;
	rep(q,Q){
		int x,y;
		cin>>x>>y;
		cout<<lca.lca(x,y)<<endl;
	}
}

Measured memory_bytes: 22048
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int A = Int32.Parse(args[0]);
		int B = Int32.Parse(args[1]);
		Console.WriteLine((Math.Max(A,B) <= 8) ? "Yay!" : ":(");
	}
}





Measured memory_bytes: 11092
#include<stdio.h>
int main()
{
 int a,b,c;
 scanf("%d %d %d",&a,&b,&c);
 if(a==b && b==c && c==a){
    printf("No");
 }
    else if(a==b || b==c || c==a){
        printf("Yes");
    }
   else{
    printf("No");
   }
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.valueOf(br.readLine());

		String[] s;
		for(int i=0; i<n; i++) {
			s = br.readLine().split(" ");
			int a = Integer.valueOf(s[0]);
			int b = Integer.valueOf(s[1]);
			int c = Integer.valueOf(s[2]);
			if( (a*a == b*b + c*c) || (b*b == a*a + c*c) || (c*c == b*b + a*a) )
				System.out.println("YES"); 
			else 	System.out.println("NO");
		}
	}
}

Measured memory_bytes: 10000
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


w, h, x, y = Is()
xd = w/2
yd = h/2
s = w*h/2

if xd == x and yd == y:
    print("{} {}".format(s, 1))
else:
    print("{} {}".format(s, 0))


Measured memory_bytes: 63340
#include <bits/stdc++.h>
using namespace std;
#define for(i, a, n) for (int i = a; i < (int)(n); i++)
#define rep(i, n) for(i, 0, n)
int MOD = pow(10,9)+7;

int main() {
  int h, w;
  cin >> h >> w;
  int map[h+1][w+1];
  
  string s;
  rep(i,h) {
    cin >> s;
    rep(j,w) {
      if (s[j] == '.') map[i+1][j+1] = 1;
      else map[i+1][j+1] = 0;
    }
  }
  
  int dp[h+1][w+1];
  rep(i,h+1)rep(j,w+1)dp[i][j]=0;
  dp[1][1]=1;
  for(i,1,h+1)for(j,1,w+1) {
    if (i==1 and j==1) continue;
    //dp[i][j] = dp[i-1][j]*map[i-1][j] + dp[i][j-1]*map[i][j-1];
    dp[i][j] = (dp[i-1][j] + dp[i][j-1]) * map[i][j] % MOD;
  }
  cout << dp[h][w];
}


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

typedef long long ll;

const int INF = 100000000;

int main() {
    int N;
    string ans = "Yes";
    cin >> N;
    vector<ll>H(N);

    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    if (H[0] > 1) {
        H[0] -= 1;
    }
    for (int i = 1; i < N; i++) {
       if (H[i-1] < H[i]) {
           H[i] -= 1;
       }  else if (H[i-1] == H[i]) {
           continue;
       } else {
           ans = "No";
           break;
       }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1152
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll INF = 1e9;
const ll LINF = ll(1e18);
const ll MOD = 1000000007;
const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin>>a>>b>>c;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        if (i % c == 0)
            ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
        String c = sc.nextLine();
        switch (c) {
             case "a":
             case "e":
             case "i":
             case "o":
             case "u":
                 System.out.println("vowel");
                  break;
              default:
                 System.out.println("consonant");
         }
    }    
}


Measured memory_bytes: 21844
import qualified Data.Map as M
solve :: Int -> Char -> Char 
solve shiftVar inChar = outChar
            where inInt   = fromEnum inChar
                  outInt  = (((toEnum (inInt + shiftVar)) - 65) `mod` 26) + 65
                  outChar = toEnum outInt
main = do
 n <- read <$> getLine :: IO Int
 s <- map (solve n) <$> getLine :: IO[Char]
 putStr s

Measured memory_bytes: 4968
#include<stdio.h>
int main(void){
  int a,b,c,x;
  scanf("%d %d %d %d",&a,&b,&c,&x);
  x/=50;
  int count=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(10*i + 2*j + k == x){
          count++;
        }
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
struct Maze {
  int id;
  int parent;
  int cost;
};
int N;

vec< vec< int > > g;
vec< int > c;
queue< Maze > q;
vec< int > parent;

int bfs() {
  Maze s = {N - 1, -10, 0};
  parent[N - 1] = -10;
  q.push(s);
  while (!q.empty()) {
    Maze now = q.front();
    q.pop();
    if (now.id == 0) {

      return now.cost;
    }
    FORA(e, g[now.id]) {
      Maze next = {e, now.id, now.cost + 1};
      if (parent[e] == -1) { //  注意
        parent[e] = now.id;
        q.push(next);
      }
    }
  }
  return -1;
}
void dfs(int id, int color) {
  c[id] = color;
  FORA(e, g[id]) {
    if (c[e] == -1) {
      dfs(e, color);
    }
  }
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> N;
  g.resize(N, vec< int >());
  REP(i, N - 1) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    g[p].pb(q);
    g[q].pb(p);
  }
  c.assign(N, -1);
  parent.assign(N, -1);
  bfs();

  // find path
  int now = 0;
  vec< int > path;
  while (now != N - 1) {
    path.pb(now);
    now = parent[now];
  }
  path.pb(N - 1);
  int pathsize = path.size();
  // PRINTALL(path);

  // REP(i, ((pathsize + 1) / 2)) { c[path[i]] = 1; }
  FOR(i, ((pathsize + 1) / 2), pathsize) { c[path[i]] = 0; }
  int col = 1;
  dfs(0, col);
  //  REP(i, (int)path.size() / 2) { c[path[i]] = 1; }
  int ans = 0;
  REP(i, N) {
    if (c[i] == col) {
      ans++;
      //     DEBUG(i);
    }
  }
  // DEBUG(ans);
  //  DEBUG(N);
  if (ans > N / 2) {
    print("Fennec");
  } else {
    print("Snuke");
  }
}

Measured memory_bytes: 9716