akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n){
		int a;cin>>a;
		in[a-1]=i;
	}
	set<ll>se;
	se.insert(-1);
	se.insert(n);
	ll out=0;
	rep(i,n){
		set<ll>::iterator it=se.lower_bound(in[i]);
		ll r,l;
		it--;
		l=in[i]-*it;
		it++;
		r=*it-in[i];
//		cout<<l<<" "<<r<<endl;
		out+=(ll)(i+1)*r*l;
		se.insert(in[i]);
	}
	cout<<out<<endl;
}







Measured memory_bytes: 11136
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define sz(x) (int)(x.size())
#define pb push_back
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define endl "\n"
#define int long long

const int N = (int)(1e5) + 322;
const long long inf = (long long)(1e18) + 123;
const int mod = (int)(1e9) + 7;
const double EPS = 1e-9;

int get(int x, int y) {
    return min((x + y) / 2, max(x - 1, y - 1));
}

signed main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    if ((a & 1) == (b & 1)) {
        cout << (b - a) / 2;
        return 0;
    }
    int val = get(a, b);
    a = n - a + 1;
    b = n - b + 1;
    val = min(val, get(a, b));
    cout << val;


    return 0;
}

Measured memory_bytes: 256
short t[3600];w,h,c,z;f(x,i){if(t[x]&1)for(t[x]=0;i;f(x+"<>xyz\1\2"[--i]-61,8));}main(i){for(;scanf("%d%d",&w,&h)*h;printf("%d\n",c)){for(i=h;c=i;)scanf(" %[^\n]",i--*60+1+t);for(;h;--h)for(i=w;i;)t[z=h*60+i--]&1&&++c-f(z,8);}}

Measured memory_bytes: 0
#include <stdlib.h>
#include <iostream>
using namespace std;

struct card{
	int val;
	char suit;
	int id;
	card(){
		val = 0;
		suit = ' ';
		id = 0;
	}
	card(card *c){
		val = c->val;
		suit = c->suit;
		id = c->id;
	}
};

int partition(card *cards, int left, int right);
void swap(int *a, int *b);
void quick_sort(card *cards, int left, int right);
void print_cards(card *cards, int left, int right);
bool is_stable(card *cards, int left, int right);
int main(){
	int n;

	cin >> n;

	card* cards = (card*)calloc((n+1), sizeof(card));

	if(n < 1){
		return 0;
	}

	for(int i = 0; i < n; i++){
		cin >> cards[i].suit;
		cin >> cards[i].val;
		cards[i].id = i;
	}
	quick_sort(cards, 0, n-1);
	if(is_stable(cards, 0, n)){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}
	print_cards(cards, 0, n);
	return 0;
}
int partition(card *cards, int left, int right){
	int x = cards[right].val;
	int i = left - 1;
	for(int j = left; j < right; ++j){
		if(cards[j].val <= x){
			++i;
			if(i != j){
				swap(cards[i], cards[j]);
			}
		}
	}
	if(i+1 != right){
		swap(cards[i+1], cards[right]);
	}
	return i+1;
}

void swap(card *a, card *b){
	card *temp = new card(b);
	b = a;
	a = temp;
	free(temp);
}

void quick_sort(card *cards, int left, int right){
	if(left < right){
		int q = partition(cards, left, right);
		quick_sort(cards, left, q-1);
		quick_sort(cards, q+1, right);
	}
}


void print_cards(card *cards, int left, int right){
	for(int i = left; i < right; ++i){
		cout <<  cards[i].suit << " " << cards[i].val << endl;
	}
}

bool is_stable(card *cards, int left, int right){
	for(int i = left; i < right-1; ++i){
		if(cards[i].val == cards[i+1].val && cards[i].id > cards[i+1].id) return false;
	}
	return true;
}

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define MAXN 100013

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
vi edge[MAXN];
ll dp[MAXN][2];
ll ans;

void solve(int u, int p)
{
	dp[u][1] = 1; dp[u][0] = 1;
	for (int v : edge[u])
	{
		if (v == p) continue;
		solve(v, u);
		dp[u][0] *= (dp[v][0] + dp[v][1]); dp[u][0] %= INF;
		dp[u][1] *= (dp[v][0]); dp[u][1] %= INF;
	}
	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	FOR(i, 0, N - 1)
	{
		int u, v; cin >> u >> v; u--; v--;
		edge[u].PB(v);
		edge[v].PB(u);
	}
	solve(0, N);
	ans = dp[0][0] + dp[0][1]; ans %= INF;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 14208
a,b,h,m = map(int, input().split(' '))

import math
if h == 0 and m == 0:
    hang = 360
else:
    hang = 1/12*h*360 + 1/60*m*30
if m == 0:
    mang = 360
else:
    mang = 1/60*m*360

ang = min(abs(hang-mang), abs(mang-hang))
c2 = a**2 + b**2 -2*a*b*math.cos(ang*math.pi/180)
print(math.sqrt(c2))

Measured memory_bytes: 9524
#include <iostream>
#include <queue>
#include <assert.h>   
#include <vector>
#include <algorithm>
#include <time.h>
#include <numeric>
#include <string>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <numeric>
#include <deque>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <cstdio>
using namespace std;


//#define double long double
//#define int long long
//#define int unsigned long long

#define ll long long
#define ld long double 
#define pi pair<int, int> 
#define pl pair<ll,ll>  
#define pd pair<ld,ld> 
#define str string  
#define mp make_pair
#define vi vector<int> 
#define vl vector<ll> 
#define vd vector<ld> 
#define vs vector<str> 
#define vpi vector<pi> 
#define vpl vector<pl> 
#define vpd vector<pd> 
#define si set<int> 
#define FF(i,j,n) for(signed i=j;i<=n;i++)  
#define DD(i,j,n) for(signed i=j;i>=n;i--) 
#define F(i,j,n) for(signed i=j;i<n;i++)   
#define D(i,j,n) for(signed i=j;i>n;i--) 
#define mem(a,b) memset(a,b,sizeof(a))
#define ndl cout << endl
#define ull unsigned long long 

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;


#define sz(x) (signed)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back() 
#define X first
#define Y second
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define SHOWVECTOR(v) {std::cerr << #v << "\t: ";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOWVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr << yyy << " ";}std::cerr << "\n";}}
//math

const int mod = 1e9 + 7;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int pct(int x) { return __builtin_popcount(x); } 
int bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 


//DEBUG, compile with -DLOCAL
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
  cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
  DBG(t...); }
#ifdef LOCAL 
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#define HERE cout << "===GOTHERE===" << endl
#else
#define dbg(...) 42
#define HERE 42
#endif


 /* ============== END OF HEADER ============== */





const int maxn = 1e5*3+20;

int n,_,q,k;
int cnt[3000];

void solve(){
	int x,y;
	cin >> n >> x >> y;

	FF(i,1,n){
		FF(j,i+1,n){
			cnt[min(j-i, min(abs(x-i)+1+abs(y-j), abs(y-i)+1+abs(x-j)))]++;
		}
	}
	FF(i,1,n-1){
		cout << cnt[i] << endl;
	}
}

signed main(){
  //clock_t t1 = clock();  
	IOS
	solve();
  
  //cout << "THE ALGORITHM TOOK: " << (clock() - t1) * 1.0 / CLOCKS_PER_SEC * 1000 << "ms"<< endl;
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
    return b?gcd(b,a%b):a;
}
bool cmp(int x,int y)
{
    return x>y;
}
const int N=10005;
const int mod=1e9+7;
int main()
{
    std::ios::sync_with_stdio(false);
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    ll s=0;
    if(n<=k) s+=n*x;
    else s+=k*x+(n-k)*y;
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
	if (x/k>d||x/k==d)
	{
		cout<<abs(x-k*d)<<endl;
	}
	else
	{
		long long y=x%d;
		long long i=(x-y)/d;
		if ((k-i)%2==1) y=abs(y-d);
		cout<<y<<endl; 
	}
	return 0;
}

Measured memory_bytes: 3644
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

using namespace std;

long long int N;
list<int> P;
int num[1001];
long long int ans = 1;
bool flag;
int box;

int main() {
	cin >> N;
	P.push_back(2);
	for (int i = 3; i < 1000; i++) {
		flag = true;
		for (auto j = P.begin(); j != P.end(); ++j) {
			if (i%*j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			P.push_back(i);
		}
	}
	for (int i = 2; i <= N; i++) {
		box = i;
		while (box != 1) {
			for (auto j = P.begin(); j != P.end(); ++j) {
				while (box%*j == 0) {
					box /= *j;
					num[*j]++;
				}
			}
		}
	}
	for (int i = 2; i <= N; i++) {
		if (num[i]) {
			ans *= (num[i] + 1);
			ans %= 1000000007;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

const int N = 1e5 + 5;
int dp[N], a[N];
int n, k;
bool calc[N];

int solve(int x) {
    if (calc[x])
        return dp[x];
    calc[x] = true;
    dp[x] = 1e9;
    for (int i = 1; i<=k; i++) {
        if (x-i < 1)
            continue;
        dp[x] = min(dp[x], abs(a[x] - a[x-i]) + solve(x-i));
    }
    return dp[x];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for (int i = 1; i<=n; i++) {
        cin >> a[i];
    }
    calc[0] = true, calc[1] = true, calc[2] = true;
    dp[2] = abs(a[2] - a[1]);
    calc[2] = true;
    cout << solve(n) << endl;
    return 0;
}


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

int main() {
  int a, b, sum;
  cin >> a >> b;

  sum = a + b;

  if (sum % 2 == 1) {
    cout << (a + b) / 2 + 1 << endl;
  } else {
    cout << (a + b) / 2 << endl;
  }
}

Measured memory_bytes: 256
class UnionFind():
    """
    parents
        各要素の親要素の番号を格納するリスト
        要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    find(x)
        要素xが属するグループの根を返す
    union(x, y)
        要素xが属するグループと要素yが属するグループとを併合する
    size(x)
        要素xが属するグループのサイズ（要素数）を返す
    same(x, y)
        要素x, yが同じグループに属するかどうかを返す
    members(x)
        要素xが属するグループに属する要素をリストで返す
        関連記事: Pythonリスト内包表記の使い方
    roots()
        すべての根の要素をリストで返す
    group_count()
        グループの数を返す
    all_group_members
        {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        関連記事: Pythonで辞書を作成するdict()と波括弧、辞書内包表記
    __str__()
        print()での表示用
        ルート要素: [そのグループに含まれる要素のリスト]を文字列で返す
    """
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N,M=map(int,input().split())
ab=[tuple(map(int,input().split())) for _ in range(M)]
ans=0

for i in range(M):
    uf = UnionFind(N)
    
    for j in range(M):
        if i!=j:
            a,b=ab[j][0],ab[j][1]
            uf.union(a-1,b-1)
    #print(i)
    if uf.group_count()!=1:
        ans+=1
        
print(ans)



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

int main(){
  string s;
  cin >> s;
  int ans = 1, n = s.size();
  bool flag = true;
  
  for(int i = 0; i < n-2; i++){
  	if(s.at(i) == s.at(i+1)){
    	ans += 2;
    	i += 2;
    if(i == n-1){
    	ans--;
      	flag = false;
    }
    }
  
    else{
  	ans++;
    }
  }
  
  if(flag){
  	if(s.at(n-2) != s.at(n-1)){
    	ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max 100

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int count_digit(int a){int i=0;while (a!=0) {a=a/10;i++;}return i;}

int main()
{
    int n, i, hun, ten, one;
    
    scanf("%d", &n);
    
    hun=n/100;
    ten=(n-hun*100)/10;
    one=n-hun*100-ten*10;
    
    if (hun==7||ten==7||one==7) {
        printf("Yes");
    }else {
        printf("No");
    }
    
    
    return 0;
}



Measured memory_bytes: 1728
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K;
	int x[100001];
	vint xm,xp;
	int kyorimin=INF;
	scan(N);scan(K);
	xm.push_back(0);xp.push_back(0);
	rep(i,N){
		scan(x[i]);
		if(x[i]==0){
			N--;
			K--;
			i--;
		}
		else if(x[i]<0) xm.push_back(-x[i]);
		else xp.push_back(x[i]);
	}
	sort(xm.begin(),xm.end());
	rep(p,K+1){
		int m=K-p;
		if(p>=xp.size()||m>=xm.size()) continue;
		kyorimin=min(kyorimin,min(xp[p]*2+xm[m],xp[p]+xm[m]*2));
	}
	prin(kyorimin);
	return 0;
}


Measured memory_bytes: 1404
n,x,y=map(int,input().split())
x-=1 ; y-=1
A=[0 for i in range(n+8)]

for i in range(n):
  for j in range(i):
    A[min(i-j, abs(i-y)+1+abs(j-x))]+=1
for i in range(1,n):
  print(A[i])


Measured memory_bytes: 45404
import io,sys,copy
sys.setrecursionlimit(10**6)


def main():
    h,w,poi = map(int,input().split())
    G = []
    for _ in range(h):
        s = input()
        temp = []
        for i in s:
            temp.append(i)
        G.append(temp)
    
    ans = 0
    for i in range(0b1<<w):
        for j in range(0b1<<h):
            G_sub = copy.deepcopy(G)
            s = i
            k = 0
            while s > 0:
                r = s%2
                s = s//2
                if r == 1:
                    for y in range(h):
                        G_sub[y][k] = "%"
                k+=1
            
            s = j
            k = 0
            while s > 0:
                r = s%2
                s = s//2
                if r == 1:
                    for x in range(w):
                        G_sub[k][x] = "%"
                k+=1
            
            ct = 0
            for g in G_sub:
                ct+=g.count("#")
            if ct == poi:
                ans+=1
    
    print(ans)
main()

Measured memory_bytes: 9240
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n,k;
string s;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin >> n >> k >> s;
	int ct = 0;
	for (int i = 0; i < n-1; ++i)
		if(s[i] == s[i+1]) 
			ct++;
	cout << min(ct + 2*k,n-1) << endl;
}

Measured memory_bytes: 512
class UnionFind
  attr_accessor :parent, :rank
  
  def initialize(n)
    @parent = []
    @rank = []
    n.times do |i|
      @parent[i] = i
      @rank[i] = 0
    end
  end

  def find(x)
    if @parent[x] == x
      return x
    else
      return @parent[x] = find(@parent[x])
    end
  end

  def unite(x,y)
    x,y = find(x),find(y)
    return if x==y

    x,y = y,x if @rank[x] < @rank[y]
    @rank[x] += 1 if @rank[x] == @rank[y]
    @parent[y] = x
  end
end
n = gets.to_i

tree = UnionFind.new(n*2+2)

(n-1).times do |i|
  u,v,w = gets.split.map(&:to_i)
  if w % 2 == 0
    tree.unite(u*2,v*2)
    tree.unite(u*2+1,v*2+1)
  elsif w % 2 == 1
    tree.unite(u*2,v*2+1)
    tree.unite(u*2+1,v*2)
  end
end

n.times do |i|
  a,b = tree.find(2),tree.find(3)
  if tree.find(i*2+2) == a
    p 0
  else
    p 1
  end
  #p [i+1,t,a,b]
end


Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 100+10;
 
int n,k,h[N],dp[N];

int dfs(int i){
   if(i>n) return 1e9;
   if(i==n) return 0;
   int &ans = dp[i];
   if(ans != -1) return ans;
   ans = INT_MAX;
   f(j,1,k+1){
      ans = min(ans,dfs(i+j)+abs(h[i+j]-h[i]));
   }
   return ans;
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   // #ifndef ONLINE_JUDGE
   //    freopen("input.txt", "r", stdin);
   //    freopen("output.txt", "w", stdout);
   // #endif
   cin >> n >> k;
   f(i,1,n+1){
      cin >> h[i];
   }
   f(i,n+1,n+1+k+5){
      h[i] = 1e9;
   }
   f(i,0,n+10) dp[i]=-1;
   cout << dfs(1) << '\n';   
   return 0;
} 

Measured memory_bytes: 4992
#include <algorithm>
#include <stdio.h>
#include <iostream>
using namespace std;
using ll = long long;

int main(){
    ll N,D,X,P=0,count=0;
    cin >> N >> D >> X;
    ll number[N];
    for(int i=0;i<N;i++){
        cin >> number[i];
    }
    for(int i=0;i<N;i++){
        P=D;
        while(P>0){
            count++;
            P=P-number[i];
        }
    }
    cout << count+X << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=402;
const ll mod=1e9+7;
ll dp[M][M],cp[M][M];
int a[M],b[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,c;
	cin>>n>>c;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cin>>b[i];
	for(ll i=1;i<=400;i++)
	{
		cp[0][i]=1;
		for(int j=1;j<=c;j++)
			cp[j][i]=(cp[j-1][i]*i)%mod;
	}
	for(int i=1;i<=400;i++)
		for(int j=0;j<=c;j++)
			cp[j][i]=(cp[j][i]+cp[j][i-1])%mod;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=400;j++)
		{
			for(int k=0;k<=j;k++)
			{
				dp[i][j]= (dp[i][j]+(dp[i-1][j-k]*(cp[k][b[i]]-cp[k][a[i]-1]+mod)))%mod;
			}
		}
	}
	cout<<dp[n][c]<<"\n";
	return 0;
}

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

#define MOD 1000000007
#define pb push_back
#define mp make_pair

template<typename T>
void print(vector<T> &v)
{
    for_each(v.begin(), v.end(), [](auto i){cout << i << ' ';});
    cout << '\n';
}

void f(int testCase)
{
    long long n;
    cin >> n;
    long long n10 = 1;
    long long n9 = 1;
    long long n8 = 1;
    for(int i = 1; i<=n; i++) {
        n10 = (n10*10ll)%MOD;
        n9 = (n9*9ll)%MOD;
        n8 = (n8*8ll)%MOD;
    }
    cout << (n10 - n9 - n9 + n8 + 2ll*MOD)%MOD << '\n';
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;

    for(int i = 1; i<=t; i++)
        f(i);
    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
typedef long long int64;
static const int MAXN = 53;
static const int64 MAXV = 1e15 + 4;
 
int n, a, b;
int64 v[MAXN];
 
int64 binom[MAXN * 2][MAXN * 2] = {{ 0 }};
 
int main()
{
    binom[0][0] = 1;
    for (int i = 1; i < MAXN * 2; ++i) {
        binom[i][0] = 1;
        for (int j = 1; j < MAXN * 2; ++j)
            binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
    }
 
    scanf("%d%d%d", &n, &a, &b);
    for (int i = 0; i < n; ++i) scanf("%lld", &v[i]);
    std::sort(v, v + n);
 
    int64 sum = 0;
    for (int i = 0; i < a; ++i) sum += v[n - i - 1];
    printf("%.7lf\n", (double)sum / a);
 
    int p, q;
    for (p = a; p <= n; ++p)
        if (v[n - p] != v[n - a]) break;
    for (q = a; q > 0; --q)
        if (v[n - q] != v[n - a]) break;
    p = p - a - 1;
    q = a - q;
    if (q == a) {
        int64 ans = 0;
        for (int i = a; i <= b; ++i) ans += binom[p + q][i];
        printf("%lld\n", ans);
    } else {
        printf("%lld\n", binom[p + q][q]);
    }
 
    return 0;
}


Measured memory_bytes: 256
/*         ?????????
       ???????????????
????????????????????????  ?????
???????????????????????????????
??????????????????????????????
??????????????????????????????
?????????????????????????????
?????????????????? ??????????
?????????????????? ?????????
?????????????????? ????????
?????????????????? ?????????
??????        ???        ???
????????????????????????????
????????????????????????????
????????????????????????????
????????????????????????????
????????????????????????????
????????????????????????????
???????????????????????????
?????????????????????????
??????????????????????
???????????????????


 ??????     ???   ???    ???   ???    ????????    ???  ???
????????    ???? ????    ???   ???    ????????    ???  ???
????????     ???????     ???   ???    ????????    ????????
????????      ?????      ???   ???    ????????    ????????
???  ???       ???       ?????????    ????????    ???  ???
???  ???       ???        ???????     ????????    ???  ???


*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x,t;
cin>>n>>x>>t;
int ans=n/x;
if(n%x!=0)
{
    ans=n/x+1;
}
cout<<ans*t;

}

Measured memory_bytes: 3636
#include<stdio.h>
#include<string.h>
int main(void){
    int lens,lenp,i,j,hante=0;
    char s[101]={'\0'},p[101]={'\0'},sg[201]={'\0'};
 
    scanf("%s",s);
    scanf("%s",p);
    lens=strlen(s);
    lenp=strlen(p);
    strcat(sg,s);
    strcat(sg,s);
    for(i=0;i<lens;i++){
        for(j=0;j<lenp;j++){
            if(sg[i+j]!=p[j]) break;
        }
        if(lenp==(j)) hante=1;
    }
    if(hante) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll

int N;

ll qexp(ll x, ll y) { 
ll res = 1; 
while (y > 0){
if (y & 1){
res = res*x; 
			res %= N;
        		}
        		y = y>>1;
        		x = x*x; 
        		x %= N;
} 
    return res; 
}


int32_t main(){
	fast;
	
	cin>>N;
	
	int cur = 0;
	
	
	FOR(i,0,1e6){
		cur += (qexp(10,i) * 7) % N;
		cur %= N;
		
		if (cur == 0){
			cout<<i + 1;
			return 0;
		}
			
	}
	cout<<-1;
	
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
using namespace std;
int m, n, w[200009], t[200009], sw[200009], st[200009], c[16], b[16], dp[1 << 15];
int main() {
	cin >> m >> n;
	for (int i = 0; i < m; i++) cin >> w[i] >> t[i];
	for (int i = 0; i < m; i++) {
		sw[i + 1] = sw[i] + w[i];
		st[i + 1] = st[i] + t[i];
	}
	sw[m + 1] = st[m + 1] = 999999999;
	for (int i = 0; i < n; i++) cin >> c[i] >> b[i];
	for (int i = 1; i < 1 << n; i++) {
		for (int j = 0; j < n; j++) {
			if (!(i & (1 << j))) continue;
			int val = dp[i - (1 << j)];
			int ptr1 = lower_bound(sw, sw + m + 1, c[j] + sw[val] + 1) - sw - 1;
			int ptr2 = lower_bound(st, st + m + 1, b[j] + st[val] + 1) - st - 1;
			dp[i] = max(dp[i], min(ptr1, ptr2));
		}
	}
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}

Measured memory_bytes: 6340
#include <stdio.h>
int main(){
  int a,b,d,r;
  double f;
  scanf("%d%d",&a,&b);
  d=a/b;
  r=a%b;
  f=(double)a/b;
  printf("%d %d %.5f\n",d,r,f);
  return 0;
}

Measured memory_bytes: 640
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int n;
vector<vector<int>> g;
vector<int> r;
int dfs(int now, int pa, vector<int> &num, int op){
    if(now == op){
        return -1;
    }
    int res = 0;
    bool f = false;
    rep(i, g[now].size()){
        int next = g[now][i];
        if(next == pa) continue;
        int tmp = dfs(next, now, num, op);
        if(tmp == -1){
            f = true;
        } else {
            res += tmp;
        }
    }
    if(f){
        num[now] = res;
        return -1;
    } else {
        return num[now] = res + 1;
    }
}
void dfs2(int now, int pa, vector<int> &route){
    route.push_back(now);
    if(now == n - 1){
        r = route;
        return;
    }
    rep(i, g[now].size()){
        int next = g[now][i];
        if(next == pa) continue;
        dfs2(next, now, route);
    }
    route.pop_back();
}
int main(void){
    cin >> n;
    g.resize(n);
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> fnum(n, 0);
    vector<int> snum(n, 0);
    dfs(0, -1, fnum, n - 1);
    dfs(n - 1, -1, snum, 0);
    vector<int> dr;
    dfs2(0, -1, dr);

    int f = 0;
    int s = r.size() - 1;
    int fennec = fnum[r[f]];
    int snuke = snum[r[s]];
    int start = 0;
    while(abs(s - f) > 1){
        f++;
        fennec += fnum[r[f]];
        if(f == s - 1){
            start = 1;
            break;
        }
        s--;
        snuke += snum[r[s]];
        if(f + 1 == s){
            start = 0;
            break;
        }
    }

    //cout << snuke << " " << fennec << endl;
    if(start){
        if(snuke > fennec){
            cout << "Snuke" << endl;
        } else {
            cout << "Fennec" << endl;
        }
    } else {
        if(fennec > snuke){
            cout << "Fennec" << endl;
        } else {
            cout << "Snuke" << endl;
        }
    }
}

Measured memory_bytes: 15224
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    static int N, K;
    static int[] arr;

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inStr = br.readLine().split(" ");
        N = Integer.parseInt(inStr[0]);
        K = Integer.parseInt(inStr[1]);
        arr = new int[N];
        inStr = br.readLine().split(" ");
        for (int i = 0; i < N; i++) {
            arr[i] = Integer.parseInt(inStr[i]);
        }

        int min = Integer.MAX_VALUE;
        int left, right, num;
        for (int i = 0; i < N - K + 1; i++) {
            left = arr[i];
            right = arr[i + K - 1];
            if (right < 0) {
                num = Math.abs(left);
                min = Math.min(min, num);
                continue;
            }
            if (left >= 0) {
                num = right;
                min = Math.min(min, num);
                continue;
            }
            if (left < 0 && right >= 0) {
                num = Math.min(Math.abs(left) * 2 + right, Math.abs(left) + right * 2);
                min = Math.min(min, num);
            }
        }
        System.out.println(min);
    }
}

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

int main() {
  int K;
  cin >> K;
  int answer = 0;
  int gcd, ok;
  for(int i = 1; i <= K; i++){
      for(int j = 1; j <= K; j++){
          for(int k = 1; k <= K; k++){
            gcd = 1;
            ok = 0;
            while(gcd <= i && gcd <= j && gcd <= k){
              if(i % gcd == 0 && j % gcd == 0 && k % gcd == 0){
                ok = gcd;
              }
              gcd++;             
            }
            answer += ok;
          }
      }
  }
  
  cout << answer << endl;
}


Measured memory_bytes: 3620
def q2():
    S = int(input())
    d, m = divmod(S, 100)

    is_YYMM, is_MMYY = False, False
    if 1 <= d <= 12:
        is_MMYY = True
    if 1 <= m <= 12:
        is_YYMM = True

    if is_MMYY:
        if is_YYMM:
            print('AMBIGUOUS')
        else:
            print('MMYY')
    else:
        if is_YYMM:
            print('YYMM')
        else:
            print('NA')


if __name__ == '__main__':
    q2()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

const unsigned long long INF = 100000000000007;

int main()
{
	string s, t;
	cin >> s;
	cin >> t;

	map<char, vector<int> > mp;
	for(int i=0;i<s.size();i++){
		mp[s[i]].push_back(i + 1);
	}

	unsigned long long cnt = 0;
	unsigned long long index = 0;
	for(int i=0;i<t.size();i++){
		if(mp[t[i]].size() == 0){
			cout << -1 << endl;
			return 0;
		}
		auto idx = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), index);
		if(idx == mp[t[i]].end()){
			cnt++;
			index = *mp[t[i]].begin();
		}else{
			index = *idx;
		}
	}
	unsigned long long ans = cnt*s.size() + index;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include<iomanip>
#include<float.h>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
ll fact[2000007];
ll power(ll x, ll y) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % mod;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % mod; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll n) 
{ 
    return power(n, mod-2); 
} 
  
 
ll nCrModPFermat(ll n, ll r) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
  
    return (fact[n]* modInverse(fact[r]) % mod * 
            modInverse(fact[n-r]) % mod) % mod; 
}
void initiate(){
    fact[0]=1;
    int i;
    rep(i,1,2000007){
        fact[i]=(fact[i-1]*i)%mod;
    }
}
   


int main()
{   ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    initiate();
    int r1,c1,r2,c2;
    cin>>r1>>c1>>r2>>c2;
    ll ans=(nCrModPFermat(r2+c2+2,c2+1)-nCrModPFermat(r2+c1+1,c1)-nCrModPFermat(r1+c2+1,r1)+nCrModPFermat(r1+c1,c1)+mod)%mod;
    cout<<ans;

    
    




    return 0;
             
    
}

Measured memory_bytes: 15872
#include<stdio.h>
#include<string.h>
#define MAX 2000
#define max(a, b) ((a > b) ? a : b)

int w_long[MAX][MAX];//0に初期化するためにグローバルに置いてるだけ

int main(){
    int i, j;
    int n, wc1, wc2;
    char w1[MAX], w2[MAX];

    scanf("%d", &n);
    while(n--){
        scanf("%s%s", w1, w2);
        wc1 = strlen(w1);
        wc2 = strlen(w2);
        for(i = 0 ; i < wc1 ; i++){
            for(j = 0 ; j < wc2  ; j++){
                if(w1[i] == w2[j]){
                    w_long[i + 1][j + 1] = w_long[i][j] + 1;
                }else{
                    w_long[i + 1][j + 1] = max(w_long[i][j + 1], w_long[i + 1][j]);
                }
            }
        }
        printf("%d\n",w_long[wc1][wc2]);
    }
    return 0;
}



Measured memory_bytes: 9592
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}

			Line[] l = new Line[n+1];
			for(int i=0;i<=n;i++) {
				int m = sc.nextInt();
				int[] x = new int[m];
				int[] y = new int[m];
				for(int j=0;j<m;j++) {
					x[j] = sc.nextInt();
					y[j] = sc.nextInt();
				}
				l[i] = new Line(m,x,y);
			}
			for(int i=1;i<=n;i++) {
				if (l[0].equals(l[i])) {
					System.out.println(i);
				}
			}
			System.out.println("+++++");

		}
	}

	public static class Line {
		int n;
		int[] length;
		int[] turn;
		public Line(int m,int[] x,int[] y) {
			n = m - 1;
			length = new int[n];
			turn = new int[n-1];
			length[0] = dist(x[0],y[0],x[1],y[1]);
			int bdir = -1;
			for(int i=0;i<n;i++) {
				length[i] = dist(x[i],y[i],x[i+1],y[i+1]);
				int dir = dir(x[i],y[i],x[i+1],y[i+1]);
				if (bdir >= 0) {
					turn[i-1] = (dir - bdir + 4) % 4 == 1 ? 1 : -1;
				}
				bdir = dir;
			}
		}
		private Line() {

		}
		private Line reverse() {
			Line l = new Line();
			l.n = n;
			l.length = new int[n];
			l.turn = new int[n-1];
			for(int i=0;i<n;i++) {
				l.length[i] = length[n-1-i];
			}
			for(int i=0;i<n-1;i++) {
				l.turn[i] = - turn[n-2-i];
			}
			return l;
		}
		public boolean equals(Line l) {
			if (Arrays.equals(length, l.length) && Arrays.equals(turn, l.turn)) {
				return true;
			}
			l = l.reverse();
			if (Arrays.equals(length, l.length) && Arrays.equals(turn, l.turn)) {
				return true;
			}
			return false;
		}
	}

	public static int dir(int x1,int y1,int x2,int y2) {
		if (x2 > x1) {
			return 0;
		}
		if (y2 > y1) {
			return 1;
		}
		if (x2 < x1) {
			return 2;
		}
		return 3;
	}
	public static int dist(int x1,int y1,int x2,int y2) {
		return Math.max(Math.abs(x1-x2),Math.abs(y1-y2));
	}

}

Measured memory_bytes: 37796
import itertools as ite
import math
import random

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())
ls = []
for num in A:
    ls += [(num, 2)]
for num in B:
    ls += [(num, 1)]
for num in C:
    ls += [(num, 0)]
ls.sort()

sumA = sumB = 0
ans = 0
for num, tp in ls:
    if tp == 0:
        ans += sumB
    elif tp == 1:
        sumB += sumA
    else:
        sumA += 1
print ans


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

#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;

int n,r;

int main(){
    IO;
    cin>>n;
    cin>>r;
    if (n>=10) {
        cout<<r;
    }
    else {
        cout<<r+100*(10-n);
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e3+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
char pic[maxn][maxn];
ll dp[maxn][maxn];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%s",pic[i]+1);
    dp[1][1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(pic[i][j]=='#') continue;
            if(i-1>=1&&pic[i-1][j]=='.') dp[i][j]=(dp[i][j]+dp[i-1][j])%Mod;
            if(j-1>=1&&pic[i][j-1]=='.') dp[i][j]=(dp[i][j]+dp[i][j-1])%Mod;
        }
    }
    printf("%lld\n",dp[n][m]);
    //cout << "time: " << (long long)clock()* 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



Measured memory_bytes: 9088
n, m = map(int, input().split())

h = list(map(int, input().split()))

x = [[] for _ in range(n)]

for _ in range(m):
   a, b = map(int, input().split())
   x[a-1].append(h[b-1])
   x[b-1].append(h[a-1])

ans = 0
for i in range(n):
   if len(x[i]) == 0:
      ans += 1

   elif h[i] > max(x[i]):
      ans += 1

print(ans)


Measured memory_bytes: 23124
#include<iostream>
#include<queue>
using namespace std;
queue<int>Q[3]; int p, q;
void solve(int a) {
	for (int i = 0; i < 1000; i++) {
		if (Q[i % 2].size() < a) {
			while (!Q[i % 2].empty()) { Q[2].push(Q[i % 2].front()); Q[i % 2].pop(); }
		}
		else {
			for (int j = 0; j < a;j++){ Q[2].push(Q[i % 2].front()); Q[i % 2].pop(); }
		}
	}
}
int main() {
	while (cin >> p >> q) {
		for (int i = 0; i < p / 2; i++)Q[1].push(i);
		for (int i = p / 2; i < p; i++)Q[0].push(i);
		for (int i = 0; i < q; i++) {
			if (i >= 1) {
				int V = Q[2].size();
				for (int j = 0; j < V / 2; j++) { Q[1].push(Q[2].front()); Q[2].pop(); }
				for (int j = V / 2; j < V; j++) { Q[0].push(Q[2].front()); Q[2].pop(); }
			}
			int a; cin >> a; solve(a);
		}
		while (Q[2].size() >= 2)Q[2].pop();
		cout << Q[2].front() << endl; Q[2].pop();
	}
	return 0;
}

Measured memory_bytes: 1216
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
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; }
typedef pair <ll,ll> P;

int main()
{
    ll N, K;
    cin >> N >> K;
    map<ll, ll> m;
    rep(i, N) {
        ll A;
        cin >> A;
        m[A]++;
    }
    vector<ll> v;
    for(P p : m) {
        v.push_back(p.second);
    }
    sort(all(v));
    ll ans = 0;
    ll cnt = 0;
    while(v.size()-cnt > K) {
        ans += v[cnt];
        cnt++;
    }
    print(ans);
    return 0;
}

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

const int inf = INT_MAX;
const int MAXN = 100010;
int n,m;
vector<pair<int,int>> grf[MAXN];
vector<int> dis;
bool visited[MAXN];


int dijkastra(int src){
    memset(visited,false,sizeof visited);
    dis = vector<int>(n,inf);
    dis[src] = 0;
    visited[src] = true;
    set<pair<int,int>> q;
    q.insert({0,src});
    while(!q.empty()){
        int len = q.begin()->first;
        int node = q.begin()->second;
        q.erase({len,node});
        for(auto nbr: grf[node]){
            if( dis[nbr.first] > dis[node]+nbr.second){
                q.erase({dis[nbr.first],nbr.first});
                dis[nbr.first] = dis[node]+nbr.second;
                q.insert({dis[nbr.first],nbr.first});
            }
        }
    }
    int mxdv, mxd = INT_MIN;
    for(int i=0; i<n; i++){
        if( dis[i]>mxd){
            mxd = dis[i];
            mxdv = i;
        }
    }


    return mxdv;
}

int main() {
    // freopen("./input.txt","r",stdin);
    // freopen("./output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin>>n;
    for(int i=0; i<n-1; i++){
        int a,b,c; cin>>a>>b>>c;
        grf[a].push_back({b,c});
        grf[b].push_back({a,c});
    }

    int mxdv = dijkastra(1);
    mxdv = dijkastra(mxdv);
    cout<< dis[mxdv] <<"\n";
    
    
}


Measured memory_bytes: 10320
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const long inf=1e9;
int main(){
	int a,b,c; int K; cin>>a>>b>>c>>K;
	int cnt = 0;
	while(a >= b){ b *= 2; cnt++; }
	while(b >= c){ c *= 2; cnt++; }
	if(cnt <= K) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC target("avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) \
  it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

int N, W;
vii a;
ll memo[105][100050];


ll dp(int at, int w){
    if (memo[at][w] != -1) return memo[at][w];
    if (at > N - 1) return 0;
    ll mx = dp(at + 1, w);
    if (w + a[at].first <= W) mx = max(mx, dp(at + 1, w + a[at].first) + a[at].second);
    //cout << a[at].first << ' ' << a[at].second << ' ' << mx << endl;
    return memo[at][w] = mx;
}

int main(){
    cin >> N >> W;
    a = vii(N);
    memset(memo, -1, sizeof(memo));
    for (int i = 0; i < N; i++) {
        cin >> a[i].first >> a[i].second;
    }
    cout << dp(0, 0);
    return 0;
}

Measured memory_bytes: 82432