akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

vector<int> prime;
bool pr[3010];
void init(){
	memset(pr,-1,sizeof(pr));
	For(i,2,3005){
		if(pr[i]){
			prime.emplace_back(i);
			for(int j=i*2;j<=3005;j+=i) pr[j]=0;
		}
	}
}

void get(vector<int> &cnt,int n){
	int i=0;
	while(n>1){
		while(n%prime[i]==0){
			cnt[i]++;
			n/=prime[i];
		}
		i++;
	}
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	init();
	vector<int> cnt(sz(prime),0);
	int n; cin>>n;
	//for(auto &i:prime) cout<<i<<"\n";
	For(i,2,n) get(cnt,i);
	int ans=1;
	for(auto &i:cnt) ans=(ans*(i+1))%MOD;
	cout<<ans<<"\n";
	return 0;
}





























Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    

    string s;
    cin >> s;
    if (s == "ABC")
      cout << "ARC" << endl;
    else
      cout << "ABC" << endl;
}

Measured memory_bytes: 3580
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val inputs = readLine()!!.split(" ").map { it.toInt() }.toMutableList()

    var tmp = gcd(inputs[0], inputs[1])

    for(i in 2 until n) {
        tmp = gcd(tmp, inputs[i])
    }

    println(tmp)
}

private fun gcd(a: Int, b: Int): Int {
    // 最大公約数を求める
    if (a % b == 0) {
        return b
    }
    return gcd(b, a % b)
}

Measured memory_bytes: 52240
#include<cstdio>
typedef long long ll;
const ll infty=1e15;
inline ll d(ll x,ll y,ll z){
    if(x>y)return d(y,x,z);
    if(y>z)return d(x,z,y);
    if(x>y)return d(y,x,z);
    if(x<0)return infty;
    return z-x;
}
inline ll min(ll x,ll y){
    if(x<y)return x;
    return y;
}
inline ll min(ll x,ll y,ll z){
    return min(min(x,y),z);
}
//T字型に切るときの最適解
//制約からh,w>=2
inline ll dif(ll h,ll w){
    return min(d(w*(h/3),(w/2)*(h-h/3),(w-w/2)*(h-h/3)),
               d(w*(h/3+1),(w/2)*(h-h/3-1),(w-w/2)*(h-h/3-1)));
}
int main(){
    ll h,w,ans=infty;
    scanf("%lld%lld",&h,&w);
    //どちらかの辺が3の倍数ならそこで切ればよい
    if(h%3==0||w%3==0)ans=0;
    //1方向に3等分する場合、差は各辺の長さになる
    ans=min(ans,h,w);
    //T字型とトの字型の場合
    ans=min(ans,dif(h,w),dif(w,h));
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    map_li[a].append(b)
    map_li[b].append(a)
 
ans_li = [-1]*n
queue=[0]
visited = [False]*n
 
while queue:
    x = queue.pop(0)
    for g in map_li[x]:
        if visited[g]==False:
            queue.append(g)
            if ans_li[g]==-1:
                ans_li[g]=x
                visited[g]=True 
if -1 in ans_li[1:]:
    print('No')
else:
    print('Yes')
    for ans in ans_li[1:]:
        print(ans+1)

Measured memory_bytes: 35376
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n, k, ans;
vector<Int> p;
vector<Int> q;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> k;
	p.resize(n);
	for(auto &i:p) cin >> i;
	q.resize(n);
	q[0] = 1;
	for(Int i=1; i<n; ++i) q[i] = p[i] > p[i-1] ? q[i-1] + 1 : 1;
	ans = 1;
	bool f = (q[k-1] < k);
	deque<Int> a, b;
	for(Int i=0; i<k; ++i){
		while(!a.empty() && p[a.front()] > p[i]) a.pop_front();
		while(!a.empty() && p[a.back()] > p[i]) a.pop_back();
		a.push_back(i);
		while(!b.empty() && p[b.front()] < p[i]) b.pop_front();
		while(!b.empty() && p[b.back()] < p[i]) b.pop_back();
		b.push_back(i);
	}
	for(Int i=k; i<n; ++i){
		bool g, h;
		while(!a.empty() && a.front() < i-k) a.pop_front();
		g = a.front() == i-k;
		while(!a.empty() && p[a.front()] > p[i]) a.pop_front();
		while(!a.empty() && p[a.back()] > p[i]) a.pop_back();
		a.push_back(i);
		while(!b.empty() && p[b.front()] < p[i]) b.pop_front();
		while(!b.empty() && p[b.back()] < p[i]) b.pop_back();
		b.push_back(i);
		while(!b.empty() && b.front() <= i-k) b.pop_front();
		h = b.front() == i;
		if(q[i] >= k){
			if(f) ++ans;
			f = false;
		}else if(!g || !h){
			++ans;
		}
//		cout << i << "\n";
//		for(auto i:a) cout << i << " ";
//		cout << "\n";
//		cout << i << " " << "01"[g] << " " << "01"[h] << "\n";
	}
	cout << ans << "\n";
}

Measured memory_bytes: 4992
#include<stdio.h>

#define max(a,b) ((a)>(b)?(a):(b))

long long ans;
int m[41];

int solve(int kt,int hn,long long then){
	//printf("%lld\n",ans);
	if(hn==0){
		ans=max(ans,then+9*(kt+1));
		return 0;
	}else{
		if(kt!=0){
			solve(kt-1,1,then+m[kt]);
			if(m[kt]>0)solve(kt-1,0,then+m[kt]-1);
			return 0;
		}else {
			ans=max(ans,then+m[kt]);
			return 0;
		}
	}
}

int main(){
	int i;
	long long n;
	scanf("%lld",&n);
	for(i=0;i<40;i++){
		m[i]=n%10;
		n/=10;
	}
	solve(40,1,0);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N, x;
    cin >> N >> x;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(ALL(a));
    int ans = 0;
    for (int i = 0; i < N-1; i++) {
        if(a[i] <= x){
            x -= a[i];
            ans++;
        }
        else{
            break;
        }
    }
    if(a[N-1] == x){
        ans++;
    }

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

}

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

using namespace std;

#define foru(i, l, r) for (int i = l; i <= r; i++)
#define ford(i, r, l) for (int i = r; i >= l; i--)

const int maxn = 1e5 + 5;

vector<int> G[maxn];
int N, K, Ans;
int fa[maxn], dis[maxn];

void dfs(int x) {
  for (int to : G[x]) dfs(to), dis[x] = max(dis[x], dis[to] + 1);
  if (fa[x] != 1 && dis[x] == K - 1) Ans++, dis[x] = -1;
}

int main() {
  scanf("%d%d", &N, &K);
  foru(i, 1, N) scanf("%d", &fa[i]);
  Ans += fa[1] != 1, fa[1] = 1;
  foru(i, 2, N) G[fa[i]].push_back(i);
  memset(dis, 0, sizeof(dis));
  dfs(1);
  printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 11136
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
b = [0]*n
for i in range(n):
  if a[i]%2:
    b[i] = 1
  elif a[i]:
    b[i] = 2
DP = [[10**18 for i in range(5)] for j in range(n+1)]
for i in range(5):
    DP[0][i] = 0
for i in range(1,n+1):
  for j in range(5):
    for k in range(j,5):
      if k == 0 or k == 4:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+a[i-1])
      elif k == 1 or k == 3:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-2))
      else:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-1))
print(min(DP[n]))

Measured memory_bytes: 95952
n = int(input())

ac, wa, tle, re = 0, 0, 0, 0
for i in range(n):
  s = input()
  if s == "AC":
    ac += 1
  elif s == "WA":
    wa += 1
  elif s == "TLE":
    tle += 1
  elif s == "RE":
    re += 1
    
print(f"AC x {ac}")
print(f"WA x {wa}")
print(f"TLE x {tle}")
print(f"RE x {re}")

Measured memory_bytes: 9176
#include <stdio.h>

int main(void)
{
	int N = 0;
	int sum = 0;
	int result[7] = {64,32,16,8,4,2};

	scanf("%d", &N);

	if (1 < N && N <= 100) {
		for (int i = 0; i < 7; i++) {
			if (result[i] <= N) {
				sum = result[i];
				break;
			}
		}
	} else {
		if (N == 1) {
			sum = N;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

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

int main() {
    int n, k; cin>>n>>k;
    vector<int> d(k);
    for(int i=0; i<k; i++) cin>>d[i];

    for(int i=n; i<MOD; i++){
        int ans=i;
        while(ans>0){
            for(int j=0; j<k; j++){
                if(d[j] == (ans % 10)) goto END;
            }
            ans /= 10;
        }
        cout<<i<<endl;
        return 0;
        END:;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
	int N;
	int K;
	int squareNum = 1;
	int cnt = 0;
	scanf("%d %d", &N, &K);
	while (N >= squareNum) {
		squareNum = squareNum * K;
		cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

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

ll ans; int N, d[52];
int main(){
    scanf("%d", &N);
    for (int i = 0; i < N; i++)scanf("%d", &d[i]);
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            ans += d[i]*d[j];
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
p = int(input())

x_price = p*a
y_price = b 
if p>c:
    y_price += d*(p-c)

if x_price<y_price:
    print(x_price)
else:
    print(y_price)
    

Measured memory_bytes: 7664
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <bitset>

using namespace std;
#define ll long long

string Op(bool opt)
{
    if (opt)
        return "+";
    return "-";
}

int main()
{
    string S;
    cin >> S;
    ll sum = 0;
    for (int i = 0; i < (1 << 4); i++)
    {
        bitset<3> op(i);
        sum = S.at(0) - 48;
        int sc = 1;
        for (int j = 0; j < op.size(); j++)
        {
            if (op.test(j))
                sum += S.at(sc) - 48;
            else
                sum -= S.at(sc) - 48;
            sc++;
        }
        if (sum == 7)
        {
            cout << S.at(0) << Op(op.test(0))
                 << S.at(1) << Op(op.test(1))
                 << S.at(2) << Op(op.test(2))
                 << S.at(3) << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll n;
char add[]={'3','5','7'};

bool isok(string &s){
  if(s.empty())return false;
  set<char>st;
  for(auto c:s){
    st.insert(c);
  }
  int num=stoi(s);
  return ((int)st.size()==3 && num<=n);
}
int dfs(string &s){  
  int sum=0;
  sum+=isok(s);
  if(s.length()==9) return sum;
  rep(i,3){
    s.push_back(add[i]);
    sum+=dfs(s);
    s.pop_back();
  }
  return sum;
}
  

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  cin >> n;
  string s="";
  cout << dfs(s) << endl;
  return 0;     
}


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

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int n;
    int ans = 0;
    cin >> n;
    vector<int> h(n + 1, 0);
    for (int i = 1; i < n + 1; i++) cin >> h.at(i);
    rep(i, n) {
        if (h.at(i + 1) > h.at(i)) {
            ans += h.at(i + 1) - h.at(i);
        }
    }
    cout << ans << endl;
}

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

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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

//////////////////////////////////////////////////
//
// フェルマーの小定理による実装
// （mod の値は素数である必要があるが、大きい n に対応可能）
//

// 参考 : https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae

#include <vector>
template<typename T_mcf_data>

class ModCombF
{
private:
    int max_n;
    T_mcf_data mod; // M
    std::vector<T_mcf_data> fac; // n! (mod M)
    std::vector<T_mcf_data> ifac; // k!^{M - 2} (mod M)

    T_mcf_data mpow(T_mcf_data x, T_mcf_data n)
    {
        T_mcf_data ans = 1;
        while(n != 0) {
            if(n & 1) {
                ans = ans * x % mod;
            }
            x = x * x % mod;
            n = n >> 1;
        }
        return ans;
    }

public:

    // 引数: n の最大値、M は mod の値
    ModCombF(int n, T_mcf_data M) : fac(n + 1), ifac(n + 1)
    {
        max_n = n;
        mod = M;
        fac[0] = 1;
        ifac[0] = 1;
        for(int i = 0; i < n; i++) {
            fac[i + 1] = fac[i] * (i + 1) % mod;
            ifac[i + 1] = ifac[i] * mpow(i + 1, mod - 2) % mod;
        }
    }

    // aCb を求める
    T_mcf_data calc(T_mcf_data a, T_mcf_data b)
    {
        if(a > max_n || a < b || a < 0) return 0; // error
        if(a == 0 && b == 0) return 1;
        T_mcf_data tmp = ifac[a - b] * ifac[b] % mod;
        return tmp * fac[a] % mod;
    }
};
//////////////////////////////////////////////////



int main()
{
    int N, K;
    cin >> N >> K;
    ll mod = 1000000007;
    ModCombF<ll> mc(N, mod);

    rep(i, K) {
        ll ans = 0;
        // (N-K+1)C(i+1) 赤い石の間に青い石を入れる総数
        IFD cout << "i: " << i << endl << N - K + 1 << " " << i + 1 << " " << K - 1 << endl;
        ans = mc.calc(N - K + 1, i + 1);
        if(i != 0) {
            // (K-1)C(i) 青い石の塊ごとに何個ずつにするかの総数
            ans = ans * mc.calc(K - 1, i) % mod;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def com(n,r,mod):
    k=min(r,n-r)
    C=1
    for i in range(1,k+1):
        C=(C*(n+1-i)*pow(i,mod-2,mod))%mod
    return C

n,k = map(int,input().split())
mod = 10 ** 9 + 7

for i in range(1, k + 1):
    if n - k +1 < i:
        print(0)
        continue
    ans = com(n - k + 1, i, mod) * com(k - 1, i - 1, mod)
    print(ans % mod)

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

#pragma GCC optimize ("O3")
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define TIME cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<int, int> mi;
typedef map<ll, ll> ml;
#define fr(i, n) for (int i = 0; i < n; i++)

const int N = 5e5 + 5;
const int M = 998244353;
ll fact[N], inv[N];
vector<bool> prime;
vector<int> drow4{1, -1,  0,  0};
vector<int> dcol4{0,  0, -1,  1};
vector<int> drow8{0,  1,  1,  1,  0, -1, -1, -1};
vector<int> dcol8{1,  1,  0, -1, -1, -1,  0,  1};

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "debug statement : " << *it << " = " << a << endl;
    err(++it, args...);
} 

ll powerModM(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res=(res * x)%M; 
        y = y >> 1; 
        x = (x *x) % M;
    } 
    return res % M; 
}

ll power(ll x, ll y){ 
    ll res = 1; 
    while(y){ 
        if(y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x*x;
    } 
    return res; 
}
 
void preCalcFactorial(int n){
    fact[0] = inv[0] = 1;
    for(ll i = 1; i <= n; i++){
        fact[i] = (fact[i-1] * i) % M;
        inv[i] = powerModM(fact[i], M - 2);
    }
}
 
ll nCr(ll n,ll r){
    ll ans = ((fact[n] * inv[r]) % M + M) % M;
    ans = ((ans * inv[n-r]) % M + M) % M;
    return ans;
}

void sieve(int n) { 
    prime.resize(n+1, true);
    prime[1] = false;
    for (int p = 2; p * p <= n; p++){ 
        if (prime[p] == true) {
            for (int i = p*p; i <= n; i += p) 
                prime[i] = false; 
        } 
    }
} 

class BIT{
public:
    int size;
    vector<int> v;
    BIT(int s){
        size = s;
        v.resize(s, 0);
    }
    void update(int i, int delta){
        while(i < size){
            v[i] += delta;
            i += i & (-i);
        }
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += v[i];
            i -= i & (-i);
        }
        return s;
    }
};

void testCase(){
    int n;
	string s;
	vi v(4, 0);
	cin >> n;
	fr(i, n) {
		cin >> s;
		if(s == "AC") v[0]++;
		else if(s == "WA") v[1]++;
		else if(s == "TLE") v[2]++;
		else v[3]++;
	}
	cout << "AC x " << v[0] << endl;
	cout << "WA x " << v[1] << endl;
	cout << "TLE x " << v[2] << endl;
	cout << "RE x " << v[3] << endl;
}

int main(){
    FAST
    int t = 1;
    //cin >> t;
    while(t--){
        testCase();
    }
}


Measured memory_bytes: 3648
package main

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

func main() {
	fsc := NewFastScanner()
	W, a, b := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	if a > b {
		b, a = a, b
	}
	if a+W < b {
		fmt.Println(b - a - W)
	} else {
		fmt.Println(0)
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


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

int h[100000];
long long dp[100000];
const long long INF = (1LL<<60);

long long solve(int i)
{
	if (dp[i] != INF)
		return dp[i];
	else {
		dp[i] = min(solve(i - 1) + abs(h[i - 1] - h[i]), solve(i - 2) + abs(h[i - 2] - h[i]));
		return dp[i];
	}
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> h[i];
	for (int i = 1; i < n; i++) {
		dp[i] = INF;
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	cout << solve(n - 1) << endl;
}

Measured memory_bytes: 2944
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[6][200007];
ll A[200007];

int main(){
  ll L;
  cin >> L;
  rep(i,L){
    cin >> A[i+1];
  }
  Rep(i,1,L+1){
    ll X,Y,Z;
    if(A[i]==0){
      X=2;
      Y=1;
    }
    else{
      X=A[i]%2;
      Y=(A[i]+1)%2;
    }
    dp[0][i]=dp[0][i-1]+A[i];
    dp[1][i]=min(dp[0][i-1],dp[1][i-1])+X;
    dp[2][i]=min(dp[0][i-1],min(dp[1][i-1],dp[2][i-1]))+Y;
    dp[3][i]=min(min(dp[0][i-1],dp[1][i-1]),min(dp[2][i-1],dp[3][i-1]))+X;
    dp[4][i]=min(min(min(dp[0][i-1],dp[1][i-1]),min(dp[2][i-1],dp[3][i-1])),dp[4][i-1])+A[i];
  }
  cout << min(dp[0][L],min(dp[1][L],min(dp[2][L],min(dp[3][L],dp[4][L])))) << endl;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n;

int main(){
    readi(n);
    if(n%10 == 9) cout <<"Yes";
    else if(n/10%10 == 9) cout <<"Yes";
    else cout <<"No";
}

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define fill(x, y)     memset(x, y, sizeof(y))
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
#define fastio ios::sync_with_stdio(false)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
const   int            inf = 0;
const   double         eps = 0;
const   int            ms  = 0;
const   int            md  = 0;


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

    string T;
    cin >> T;

    for(int i = 0; i < T.length(); i++)
    {
	if(T[i] != '?') continue;

	if(i && T[i-1] == 'P')
	    T[i] = 'D';
	else if(i < T.length()-1 && T[i] == '?' && T[i+1] == 'D')
	    T[i] = 'P';
	else if(i < T.length()-1 && T[i+1] == '?')
	    T[i] = 'P', T[i+1] = 'D';
	else
	    T[i] = 'D';
    }

    std::cout << T << "\n";
     
   
   return 0;
}


Measured memory_bytes: 3744
#include <stdio.h>



int main(){


	long a, b;
	long rem;

	scanf( "%ld %ld", &a, &b );



	//Euclidean Algorithm
	
	while( (rem=a%b) != 0 ){
		//printf( "%ld & %ld = %ld\n", a, b, rem );
		a = b;
		b = rem;
	}
		

	printf( "%ld\n", b );



	return 0;

}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

template<int mod>
struct ModInt{
    int x;

    ModInt() : x(0) {}
    
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    
    ModInt &operator+=(const ModInt &p){
        if((x += p.x) >= mod)   x -= mod;
        return *this;
    }
    
    ModInt &operator-=(const ModInt &p){
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    
    ModInt operator-() const {return ModInt(-x);}

    ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}

    ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}

    ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}

    ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}

    bool operator==(const ModInt &p) const {return x == p.x;}

    bool operator!=(const ModInt &p) const {return x != p.x;}

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const{
        ModInt ret(1), mul(x);
        while(n > 0){
            if(n & 1)   ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p){
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a){
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() {return mod;}
};

using modint = ModInt<mod>;

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

    int n, m;
    cin >> n >> m;
    modint X = 0, Y = 0, x, y;
    for(int i = 0; i < n; ++i){
        cin >> x;
        X += x * i;
        X -= x * (n - i - 1);
    }
    for(int i = 0; i < m; ++i){
        cin >> y;
        Y += y * i;
        Y -= y * (m - i - 1);
    }
    modint ans = X * Y;
    cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int m1, m2, d;


int main() {
    cin >> m1 >> d >> m2 >> d;
    if (m1 == m2) cout << 0 << endl;
    else cout << 1 << endl;
}

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

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e5+5;

int n;
char s[N];

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	int cnt=0;
	LL ans=0;
	fo(i,1,n){
		if (s[i]=='B')cnt++;
		else ans+=cnt;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int ans = 0;

		if (N >= 2) {
			ans += (N * (N-1)) /2;
		}
		if (M >= 2) {
			ans += (M * (M-1)) /2;
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 35764
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools
import heapq
#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)


def main():
    k=int(input())
    a,b=map(int,input().split())
    ans="NG"
    for i in range(a,b+1):
        if i%k==0:
            ans="OK"
            break
    print(ans)




if __name__ == "__main__":

    main()

Measured memory_bytes: 68136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();
        
    vector<string> s(3); cin >> s;
    bool ng = false;
    FOR(i, 0, 2)ng |= s[i].back() != s[i + 1][0];
    if (ng)cout << "NO\n";
    else cout << "YES\n";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import sys

sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap





@mt
def slv(N, A, UV):
    A.insert(0, -1)
    g = [list() for _ in range(0, N+1)]
    ans = [-1] * (N+1)
    for u, v in UV:
        g[u].append(v)
        g[v].append(u)

    def dfs(u, p, dp):
        for v in g[u]:
            if v == p:
                continue

            i = bisect.bisect_left(dp, A[v])
            b = dp[i]
            dp[i] = A[v]
            ans[v] = bisect.bisect_left(dp, INF)
            dfs(v, u, dp)
            dp[i] = b
    dp = [INF] * (N+1)
    dp[0] = A[1]
    dfs(1, 0, dp)

    ans[1] = 1
    for i in range(1, N+1):
        print(ans[i])


def main():
    N = read_int()
    A = read_int_n()
    UV = [read_int_n() for _ in range(N-1)]
    slv(N, A, UV)


if __name__ == '__main__':
    main()


Measured memory_bytes: 381428
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    
    if(a>b) {
        for(int i=0; i<a; i++) {
            cout << b;
        }
        cout << endl;
    } else {
        for(int i=0; i<b; i++) {
            cout << a;
        }
        cout << endl;
    }



    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
 
pair<int, int> AB[100100];
int main(){
    ll N, K;
    cin >> N >> K;
    REP(i,N){
        ll a,b;
        cin >> a >> b;
        AB[i] = make_pair(a,b);
    }
    sort(AB, AB+N);

    ll index = 0;
    ll k = K;
    ll ans;
    while(1){
       k -= AB[index].second; 
       if(k <= 0){
            ans = AB[index].first;
            break;
       }
       index++;
       if(index >= N){
            ans = AB[index-1].first;
            break;
       }
    }

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


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

// i > 0
int parent(int i) { return ((i + 1) / 2) - 1; }

int left(int i) { return 2 * (i + 1) - 1; }

int right(int i) { return 2 * (i + 1); }

int main() {
  int n;
  cin >> n;
  vector<int> v;
  while (cin >> n)
    v.push_back(n);
  for (int i = 0; i < v.size(); ++i) {
    cout << "node " << i + 1 << ": key = " << v[i] << ", ";
    if (i > 0)
      cout << "parent key = " << v[parent(i)] << ", ";
    if (left(i) < v.size())
      cout << "left key = " << v[left(i)] << ", ";
    if (right(i) < v.size())
      cout << "right key = " << v[right(i)] << ", ";
    cout << endl;
  }
}


Measured memory_bytes: 3156
ins = [ int(i) for i in raw_input('').split()]
A, B = ins 
#A, B = 4, 4

flag = True

if 16 < A or A < 1 : 
    flag = False

if 16 < B or B < 1 : 
    flag = False

if 16 < A+B or 8 < A or 8 < B:
    flag = False

if flag:
    print('Yay!')
else:
    print(':(')

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	string s;
	cin >> s;
	int n = s.size();
	bool one = false, two = false;
	int a = 10*(s[0] - '0') + (s[1]-'0');
	int b = 10*(s[2] - '0') + (s[3]-'0');
	if(1 <= a && a <= 12){
		one = true;
	}
	if(1 <= b && b <= 12){
		two = true;
	}
	if(one && two){
		cout << "AMBIGUOUS" << endl;
	}
	else if(one) {
		cout << "MMYY" << endl;
	} else if(two){
		cout <<"YYMM" << endl;
	} else {
		cout << "NA" << endl;
	}
}


Measured memory_bytes: 3620
def gcm(a,b):
    if a < b:
        a,b = b,a
    while True:
        if a % b == 0:
            return b
        else:
            a,b = b,a % b

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A,B = map(int,input().split())
gcm1 = gcm(A,B)
prime = prime_factorize(gcm1)
primeset = set()
for p in prime:
    primeset.add(p)

print(len(primeset)+1)

Measured memory_bytes: 3064
#include<stdio.h>
#define N 1000
#define WHITE 0
#define BLACK 2
#define GRAY 1
int n,M[N][N],color[N],d[N],f[N],tt;
void dfs();
void visit(int);
int main(){
  scanf("%d",&n);
  int i,j,u,v,k;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  
  return 0;
}
void dfs(){
  int u;
  for(u=0;u<n;u++){
    color[u]=WHITE;
  }
  tt=0;
  for(u=0;u<n;u++){
    if(color[u]==WHITE) visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}
void visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}



Measured memory_bytes: 2172
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int main() {
	cin >> s;
	vector<char> op = { '+','-' };
	for (int bit = 0; bit < (1 << 3); bit++) {
		ll sum = s[0] - '0';
		for (int i = 0; i < 3; i++) {
			if (bit & 1 << i) {
				sum -= s[i + 1] - '0';
			}
			else {
				sum += s[i + 1] - '0';
			}
		}
		if (sum == 7) {
			cout << s[0];
			for (int j = 0; j < 3; j++) {
				cout << op[(bit >> j) & 1] << s[j + 1];
				if (j == 2) {
					cout << "=7" << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int ans;
  ans = abs(a-b);
  if(ans%2==0){
    cout<<(a+b)/2<<endl;
    return 0;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  ll x;cin>>x;
  if(x==0){out(1);}
  else {out(0);}
  
}



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

int main(void) {
    int c1[26] = {}, c2[26] = {};
    string in1, in2, s, t;
    cin >> in1 >> in2;
    for (int i = 0; i < in1.size(); i++) c1[in1[i] - 'a']++;
    for (int i = 0; i < in2.size(); i++) c2[in2[i] - 'a']++;
    for (int i = 0; i < 26; i++)
        for (int j = 0; j < c1[i]; j++) s += i + 'a';
    for (int i = 25; i >= 0; i--) {
        for (int j = 0; j < c2[i]; j++) t += i + 'a';
    }
    cout << (s < t ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i

ans = []
while true
  if n % 2 == 1
    ans.unshift(1)
    n -= 1
  else
    ans.unshift(0)
  end
  break if n == 0 || n == 1
  n /= -2
end
puts ans.join('').to_i.to_s


Measured memory_bytes: 1788
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include<string>
#include<vector>
using namespace std;


int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> vec(n);
	bool boo[10][10] = { 0 };
	bool b[10] = { 0 };
	int count = 0;
	for (int i = n - 1; i >= 0; i--) {
		vec[i] = count; 
		if (b[s[i] - '0'] == 0) {
			count++;
			b[s[i] - '0'] = 1;
		}
	}
	int ans = 0;
	for (int i = 0; i < n-2; i++) {
		for (int j = i + 1; j < n-1; j++) {
			if (boo[s[i] - '0'][s[j] - '0'] == 1)continue;
			boo[s[i] - '0'][s[j] - '0'] = 1;
			ans += vec[j];
		}
	}
	cout << ans;
}



Measured memory_bytes: 3760
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16000000")
using namespace std;

typedef pair <int, int> ii;

const int Maxn = 100005;
const int Maxm = 20;

int n, q;
int A[Maxn], B[Maxn], C[Maxn], D[Maxn];
vector <ii> neigh[Maxn];
vector <int> cole[Maxn], colquer[Maxn];
int qa[Maxn], qb[Maxn], qc[Maxn], qd[Maxn];
int qsum[Maxn], qcnt[Maxn];
int cur, lef[Maxn], rig[Maxn];
int L[Maxn], Dist[Maxn], P[Maxn][Maxm];
ii BIT[Maxn];

void Traverse(int v)
{
    lef[v] = ++cur;
    for (int i = 0; i < neigh[v].size(); i++) {
        ii u = neigh[v][i];
        if (P[v][0] == u.first) continue;
        P[u.first][0] = v; L[u.first] = L[v] + 1;
        Dist[u.first] = Dist[v] + u.second;
        Traverse(u.first);
    }
    rig[v] = cur;
}

void Insert(int x, const ii &val)
{
    for (int i = x; i <= n; i += i & -i) {
        BIT[i].first += val.first;
        BIT[i].second += val.second;
    }
}

ii Get(int x)
{
    ii res = ii(0, 0);
    for (int i = x; i > 0; i -= i & -i) {
        res.first += BIT[i].first;
        res.second += BIT[i].second;
    }
    return res;
}

int getLCA(int a, int b)
{
    if (L[a] < L[b]) swap(a, b);
    for (int i = Maxm - 1; i >= 0; i--)
        if (L[a] - (1 << i) >= L[b])
            a = P[a][i];
    if (a == b) return a;
    for (int i = Maxm - 1; i >= 0; i--)
        if (P[a][i] != P[b][i])
            a = P[a][i], b = P[b][i];
    return P[a][0];
}

int main()
{
    scanf("%d %d", &n, &q);
    for (int i = 0; i < n - 1; i++) {
        scanf("%d %d %d %d", &A[i], &B[i], &C[i], &D[i]);
        neigh[A[i]].push_back(ii(B[i], D[i]));
        neigh[B[i]].push_back(ii(A[i], D[i]));
        cole[C[i]].push_back(i);
    }
    Traverse(1);
    for (int j = 1; j < Maxm; j++)
        for (int i = 1; i <= n; i++)
            P[i][j] = P[P[i][j - 1]][j - 1];
    for (int i = 0; i < q; i++) {
        scanf("%d %d %d %d", &qa[i], &qb[i], &qc[i], &qd[i]);
        colquer[qa[i]].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < cole[i].size(); j++) {
            int ind = cole[i][j];
            if (L[A[ind]] > L[B[ind]]) swap(A[ind], B[ind]);
            Insert(lef[B[ind]], ii(D[ind], 1));
            Insert(rig[B[ind]] + 1, ii(-D[ind], -1));
        }
        for (int j = 0; j < colquer[i].size(); j++) {
            int ind = colquer[i][j];
            int lca = getLCA(qc[ind], qd[ind]);
            ii got1 = Get(lef[qc[ind]]);
            ii got2 = Get(lef[qd[ind]]);
            ii got3 = Get(lef[lca]);
            qsum[ind] = got1.first + got2.first - 2 * got3.first;
            qcnt[ind] = got1.second + got2.second - 2 * got3.second;
        }
        for (int j = 0; j < cole[i].size(); j++) {
            int ind = cole[i][j];
            if (L[A[ind]] > L[B[ind]]) swap(A[ind], B[ind]);
            Insert(lef[B[ind]], ii(-D[ind], -1));
            Insert(rig[B[ind]] + 1, ii(D[ind], 1));
        }
    }
    for (int i = 0; i < q; i++) {
        int lca = getLCA(qc[i], qd[i]);
        int sum = Dist[qc[i]] + Dist[qd[i]] - 2 * Dist[lca];
        printf("%d\n", sum - qsum[i] + qcnt[i] * qb[i]);
    }
    return 0;
}


Measured memory_bytes: 32508
#include <stdio.h>

int main(void){
	int a, b;

	scanf("%d%d", &a, &b);

	if(a<b)
		printf("a < b\n");
	else if(a>b)
		printf("a > b\n");
	else
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<pair<int, int>> solve(const string& S){
    const int N = S.size();
    if(S[0] == '0' || S[N-2] == '0' || S[N-1] == '1') return vector<pair<int, int>>();
    for(int i=0;i<N-2-i;i++){
        if(S[i] != S[N-2-i]) return vector<pair<int, int>>();
    }
    int size = 0;
    int src = 1;
    vector<pair<int, int>> res;
    for(int i=2;i<=N;i++){
        res.emplace_back(src, i);
        if(S[i-2] == '1'){
            src = i;
        }
    }
    return res;
}

int main(){
    string S; cin >> S;
    auto res = solve(S);
    if(res.empty()){
        cout << -1 << endl;
    } else {
        for(auto& p : res) cout << p.first << " " << p.second << endl;
    }
}

Measured memory_bytes: 4436