akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll a,b;
  cin>>a>>b;
  if(a*b<=0){
    cout<<"Zero"<<endl;
  }else if(b<0){
    cout<<((b-a)%2?"Positive":"Negative")<<endl;
  }else{
    cout<<"Positive"<<endl;

  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for (int i=(a-1);i>=(b);--i)
#define rrep(i,n) rrepd(i,n,0)
#define PI 3.14159265
typedef long long ll;
typedef pair<int, int> P;


int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  int year = stoi(s.substr(0, 4));
  int month = stoi(s.substr(5, 2));
  // int day = stoi(s.substr(8, 2));
  if (year > 2019){
    cout << "TBD" << endl;
    return 0;
  }
  if (year == 2019){
    if (month > 4){
      cout << "TBD" << endl;
      return 0;
    }
  }
  cout << "Heisei" << endl;
  
  return 0;
}

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

int main() {
    int N,M,Q;
    vector<int> v[501];
    cin>>N>>M>>Q;
    for(size_t i = 0; i < M; i++)
    {
        int l,r;
        cin>>l>>r;
        v[l].push_back(r);
    }

    for(size_t i = 0; i < 501; i++){
        sort(v[i].begin(),v[i].end());
    }
    
    for(size_t i = 0; i < Q; i++)
    {
        int p,q;
        cin>>p>>q;
        int s=0;
        for(size_t j = p; j <= q; j++)
        {
            if(v[j].empty())continue;
            
            auto it=upper_bound(v[j].begin(),v[j].end(), q);
            if (it==v[j].end()) {
                s+=v[j].size();
                continue;
            }
            if (*it>q) {
                s+=it-v[j].begin();
            } else {
                s+=it-v[j].begin()+1;
            }
        }
        cout<<s<<endl;;
    }
    return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    map <string,int> ms,mt;
    int ans=0;
    ll n;
    n=s.size();
    string ss,tt;
    rep(i,n){
        ss=s[i];
        tt=t[i];
        ++ms[ss];
        ++mt[tt];
        if(ms[ss]!=mt[tt]){
            ans=1;
            break;
            
        }
    }

    if(ans==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    

    return 0;
}

Measured memory_bytes: 776
#include<stdio.h>
int main(void){
    int b,a,r,n,i;
    
scanf("%d",&n);
scanf("%d",&a);
for(i=0;;i++){
n=n-500;
if(n<500){
break;}
}
if(a>=n){
puts("Yes");
}else if(a<n){
puts("No");
}

return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

namespace my
{
	//-----------------------------------------------------------------------------
	inline char cn()
	{
		static char buf[1000010],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
	}
	#define cn getchar
	template<class TY>void read(TY &x)
	{
		x=0;int f1=1;char ch=cn();
		while(ch<'0'||ch>'9'){if(ch=='-')f1=-1;ch=cn();}
		while(ch>='0'&&ch<='9')x=x*10+(ch-'0'),ch=cn(); x*=f1;
	}
	char Output[1000100],Zk[100];int op_top=0,Zk_top;
	void fcheck(int Type=0){if(Type||op_top>=1000000)fwrite(Output,1,op_top,stdout),op_top=0;}
	template<class TY>inline void write(TY x)
	{
		if(x==0){Output[op_top++]='0';fcheck();return;}
		if(x<0)Output[op_top++]='-',x=-x;
		Zk_top=0;while(x)Zk[++Zk_top]=x%10+'0',x/=10;
		while(Zk_top)Output[op_top++]=Zk[Zk_top--];fcheck();
	}
	#define K_G Output[op_top++]=' '
	#define H_C Output[op_top++]='\n'
	//--------------------------------------------------------------------------------------------
	
	//--------------------------------------------------------------------------------------------
	#define ll long long
	#define uint unsigned int
	#define ull unsigned long long
	#define INV(x) ksm(x,mod-2)
	#define inf 999999999
	#define mod 998244353
	
	template<class TY>void add(TY &x,TY y){x=(x+y>=mod?x+y-mod:x+y);}
	template<class TY>void dec(TY &x,TY y){x=(x-y<0?x-y+mod:x-y);}
	template<class TY>TY add(TY x){return x>=mod?x-mod:x;}
	template<class TY>TY dec(TY x){return x<0?x+mod:0;}
	//
	int ksm(int x,int y){int re=1;for(;(y&1?re=1ll*re*x%mod:0),y;y>>=1,x=1ll*x*x%mod);return re;}
	int *fac,*inv_fac,*inv;
	void work_math(const int N)
	{
		fac=new int[N+5];inv_fac=new int[N+5];inv=new int[N+5];
		inv[1]=1;for(int i=2;i<=N;i++)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fac[0]=inv_fac[0]=1;for(int i=1;i<=N;i++)fac[i]=1ll*fac[i-1]*i%mod;
		inv_fac[N]=INV(fac[N]);
		for(int i=N-1;i>=1;i--)inv_fac[i]=1ll*inv_fac[i+1]*(i+1)%mod;
	}
	int C(int x,int y){return 1ll*fac[x]*inv_fac[y]%mod*inv_fac[x-y]%mod;}
	//
	template<class TY>TY gcd(TY x,TY y){return !y?x:gcd(y,x%y);}
	template<class TY>TY exgcd(TY a,TY b,TY &x,TY &y){
		if(!b)return x=1,y=0,a;
		TY re=exgcd(b,a%b,y,x);
		return y-=a/b*x,re;
	}
	//
	template<class TY>void discretization(TY *arr,int St,int Ed){
		vector<TY>Arr;Arr.clear();
		for(int i=St;i<=Ed;i++)Arr.push_back(arr[i]);
		sort(Arr.begin(),Arr.end());
		for(int i=St;i<=Ed;i++)arr[i]=lower_bound(Arr.begin(),Arr.end(),arr[i])-Arr.begin()+1;
	}
	//-----------------------------------------------------------------------------------------------
	
	//----------------------------------------------------------------------------------------------- 
	int n;
	
	void main()
	{
		read(n);int ans=0;
		for(int i=1;i<=n;i++){
			int j=i,now=0;
			while(j)j/=10,now++;
			if(now%2)ans++;
		}
		write(ans);
		fcheck(1);return;
	}
}

int main(){my::main();return 0;}

Measured memory_bytes: 3016
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = II()
    xyh = LIR(n)
    xyh.sort(key = lambda x:x[2], reverse = True)
    x1, y1, h1 = xyh[0]
    del xyh[0]
    for x in range(101):
        for y in range(101):
            h = abs(x - x1) + abs(y - y1) + h1
            flg = True
            for xn, yn, hn in xyh:
                if max(h - abs(x - xn) - abs(y - yn), 0) == hn:
                    continue
                flg = False
                break
            if flg:
                print(x, y, h)
                return 
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 41072
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
ll n,k;
ll num[100005];
int main()
{
    IOS;
    while(cin>>n>>k)
    {
        rep(i,n) cin>>num[i];
        sort(num,num+n);
        ll ans=1000000005;
        for(int i=0;i<n;i++)
        {
            if(i+k-1>=n) break;
            ans=min(ans,num[i+k-1]-num[i]);
        }
        cout<<ans<<"\n";
    }
}


Measured memory_bytes: 1024
import std.stdio;
import std.conv;

string s, busStop = "0123456789543210123456789";

void main(){
	int n, from, to;
	readf("%d\n", &n);
	for (int i = 0; i < n; i++) {
		readf("%d %d\n", &from, &to);
		s = "";
		for (int j = 0; j < busStop.length; j++) {
			if (busStop[j] == from + '0') s = text(from);
			else s ~= text(" ", busStop[j]);

			if (busStop[j] == to + '0' && s[0] == from + '0') break;
		}
		writeln(s);
	}
}

Measured memory_bytes: 1020
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 2e5 + 10;
struct edge {
    static int ptr;
    int to, next;
} e[MAXN * 4];
int edge::ptr = 0;

int G1[MAXN], G2[MAXN], depth2[MAXN], parent2[MAXN];
void dfs2(int o, int p, int d) {
    parent2[o] = p, depth2[o] = d;
    for (int i = G2[o]; i; i = e[i].next) {
        if (e[i].to == p) continue;
        dfs2(e[i].to, o, d + 1);
    }
}
constexpr int INF = 1e9;
int baluteshih_orz(int x, int y) {
    if (depth2[x] < depth2[y]) swap(x, y);
    if (x == y) return 0;
    if (parent2[x] == y) return 1;
    if (parent2[x] == parent2[y]) return 2;
    if (parent2[parent2[x]] == y) return 2;
    return INF;
}
int dfs1(int o, int p, int d2) {
    if (depth2[o] <= d2) return d2;
    int ret = depth2[o];
    for (int i = G1[o]; i; i = e[i].next) {
        int to = e[i].to;
        if (to == p) continue;
        if (baluteshih_orz(o, to) == INF) return INF;
        ret = max(ret, dfs1(to, o, d2 + 1));
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, X, Y;
    cin >> N >> X >> Y;
    for (int i = 1, u, v; i < N; i++) {
        cin >> u >> v;
        e[++edge::ptr] = {v, G1[u]}, G1[u] = edge::ptr;
        e[++edge::ptr] = {u, G1[v]}, G1[v] = edge::ptr;
    }
    for (int i = 1, u, v; i < N; i++) {
        cin >> u >> v;
        e[++edge::ptr] = {v, G2[u]}, G2[u] = edge::ptr;
        e[++edge::ptr] = {u, G2[v]}, G2[v] = edge::ptr;
    }
    dfs2(Y, 0, 0);
    int ans = dfs1(X, 0, 0);
    cout << (ans == INF ? -1 : 2 * ans) << endl;
    return 0;
}


Measured memory_bytes: 21360
#include<bits/stdc++.h> 
#define int long long 
using namespace std; 
void solve(); 

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

#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("error.txt", "w", stderr); 
	freopen("output.txt", "w", stdout); 
#endif 
	int t=1; 
	/*is Single Test case?*/ 
	while(t--) 
	{ 
		solve(); 
		cout<<"\n"; 
	} 

	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl; 
	return 0; 
} 
void solve() { 
	
	int n,d;
	cin>>n>>d;
	int count =0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		int po=x*x+y*y;
		if(po<=(d*d)) {
			count++;
			
		}
	}
	cout<<count;

} 


Measured memory_bytes: 3796
// B - Minimum Sum

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int a[200000];
int pos[200001];

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

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

	ll ans = 0;
	set<int> pos_set;
	for (int i=1; i<=N; i++) {
		int k = pos[i];
		pos_set.insert(k);
		ll l, r;
		auto itr = pos_set.lower_bound(k);

		if (itr == pos_set.begin()) {
			l = 0;
		} else {
			itr--;
			l = *itr + 1;
			itr++;
		}

		itr++;
		if (itr == pos_set.end()) {
			r = N - 1;
		} else {
			r = *itr - 1;
		}

		// cout << l << " " << k << " " << r << endl; // **** debug ****

		ans += i * (k - l + 1) * (r - k + 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11136
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def icc(c):
	ret=(ord('z') - ord(c) + 1)
	return ret
	
def nn(c,v):
	ret=chr(ord(c)+v)
	return ret

def main():
	s=input()
	n = int(input())
	#b , c = IN()
	#s = input()
	ret = []
	for c in s:
		#print(c,icc(c),n)
		if c != 'a' and icc(c) <= n:
			ret.append('a')
			n-=icc(c)
		else:
			ret.append(c)
	
	n%=26
	if icc(ret[-1]) <= n:
		n-=icc(ret[-1])
		ret[-1]='a'
	ret[-1]=nn(ret[-1], n)
	#pa(ret)
	return ''.join(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 4244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,t,n;
int main() {
	cin>>t;a=4*t;
	cin>>t;a=min(a,2*t);
	cin>>t;a=min(a,t);
	cin>>b;cin>>n;
	if(2*a>b) {
		cout<<(n/2*b+(n&1)*a)<<endl;
	} else {
		cout<<n*a<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <stdio.h>
#define INF 100000000
#define INFLL (long long)1e14
#define Loops(i, n) for(int i = 0; i < (int)n; i++)
#define Loops1(i, n) for(int i = 1; i <= (int)n; i++)
int dp[2000][2000];
int w[2000];
int v[2000];
int N;
int W;
int count=1;
int main(void){
    while(1){
        std::cin>>W;
        if(W==0){
            break;
        }
        std::cin>>N;
        Loops(i,N){
            int vi,wi;
            scanf("%d,%d",&vi,&wi);
            v[i]=vi;
            w[i]=wi;
//          std::cin>>w[i]>>v[i];
        }
        Loops(i,1000){
            Loops(j,1000){
                dp[i][j]=0;
            }
        }
        Loops(i,N){
            Loops(j,W+1){
                if(j-w[i]>=0){
                    dp[i+1][j]=std::max(dp[i][j],dp[i][j-w[i]]+v[i]);
                }else {
                    dp[i+1][j]=dp[i][j];                
                }
            }
        }
        int kati=0,omosa=0;
        Loops(i,W+1){
            if(kati<dp[N][i]){
                kati=dp[N][i];
                omosa=i;
            }
        }
        printf("Case %d:\n",count);
        std::cout<<kati<<std::endl;
        std::cout<<omosa<<std::endl;
        count++;
/*  Loops(i,N+1){
        Loops(j,W+1){
            std::cout<<dp[i][j]<<" ";
        }
        std::cout<<std::endl;
    }*/
 
    }
    return 0;
}

Measured memory_bytes: 11016
#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
    int a1, a2, a3;
    cin>>a1>>a2>>a3;
    if(a1+a2+a3<22)
        cout<<"win "<<endl;
    else
        cout<<"bust "<<endl;
 
	return 0;
}

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

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


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), B(N);
    REP(ll,i,0,N){
        cin >> A.at(i);
        B.at(i) = 0;
    }
    ll Number = 1;
    ll Periodic;
    B.at(0) = 1;
    REP(ll,i,0,2*N){
        if ( B.at(Number-1) == 2 ){
            Periodic = Number;
            break;
        }
        else{
            Number = A.at(Number-1);
            B.at(Number-1)++;
        }
    }
    /* 長さをチェック */
    ll Counter = 0;
    ll PeriodicLen;
    Number = A.at(Periodic-1);
    Counter++;
    REP(ll,i,0,2*N){
        if ( Number == Periodic ){
            PeriodicLen = Counter;
            break;
        }
        else{
            Number = A.at(Number-1);
            Counter++;
        }
    }
    /* 始まるまでの長さをチェック */
    Counter = 0;
    Number = 1;
    ll AntiPeriodicLen;
    REP(ll,i,0,2*N){
        if ( Number == Periodic ){
            AntiPeriodicLen = Counter;
            break;
        }
        else{
            Number = A.at(Number-1);
            Counter++;
        }
    }
    /*
    cout << PeriodicLen << endl;
    cout << AntiPeriodicLen << endl;*/
    ll NewK = ( K - AntiPeriodicLen ) % PeriodicLen;
    ll LoopNum = AntiPeriodicLen + NewK;
    Number = 1;
    if ( K <= 10000000 ) LoopNum = K;
    REP(ll,i,0,LoopNum){
            Number = A.at(Number-1);
    }
    cout << Number << endl;
    return 0;
}

Measured memory_bytes: 6408
from sys import stdin
input = stdin.readline

n = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans = ans * A[i]
    if ans > 10**18:
        for j in range(i+1,n):
            if A[j] == 0:
                print(0)
                exit()
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 21940
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX_N 100010

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;

int par[MAX_N];
int node_rank[MAX_N];

void init(int n){
  for(int i = 0; i < n; i++) {
    par[i] = i;
    node_rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}

void unite(int x, int y){
  x = find(x);
  y = find(y);
  if(x == y) return;

  if(node_rank[x] < node_rank[y])
    par[x] = y;
  else
    par[y] = x;
  if(node_rank[x] == node_rank[y]) node_rank[x]++;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m,n;
  cin>>n>>m;
  init(n);
  rep(i,m){
    int a,b;
    cin >> a>>b;
    unite(a,b);
  }

  int count =0;
  rep(i,n){
    if(par[i] == i) ++count;
  }

  cout << count-1 << endl;
  return 0;
}


Measured memory_bytes: 3940
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<long long int>a(N+2);
	vector<long long int>b(N+2);
	vector<long long int>c(N+2);
	vector<long long int>sum_b(N+2);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i];
	}
	a[N + 1] = INT_MAX;
	b[N + 1] = INT_MAX;
	c[N + 1] = INT_MAX;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	int box = 0;
	for (int i = 1; i <= N; i++) {
		while (b[i] >= c[box]) {
			box++;
		}
		sum_b[i] = N-box + 1;
	}
	for (int i = N - 1; i > 0; i--) {
		sum_b[i] += sum_b[i + 1];
	}
	box = 0;
	for (int i = 1; i <= N; i++) {
		while (a[i] >= b[box]) {
			box++;
		}
		M += sum_b[box];
	}
	cout << M << endl;
	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  string s;
  cin >> s;
  s += "T";
  vector<ll> ans(s.size(), 0);
  int rsum = 0, lsum = 0;
  bool flag = false;
  pair<int, int> p;
  for (int i = 0; i <= s.size(); ++i) {
    if (s[i] == 'R') rsum += 1;
    else if (s[i] == 'L') lsum += 1;
    

    if (i >= 0 and i < s.size()) {
      if ((s[i] == 'L' and s[i+1] == 'R') or s[i] == 'T') {
        flag = false;
        if ((rsum + lsum) % 2 == 0) {
          ans[p.first] = (rsum + lsum) / 2;
          ans[p.second] = (rsum + lsum) / 2;
        } else {
          ans[p.first] = (rsum + lsum) / 2;
          ans[p.second] = (rsum + lsum) / 2;
          lsum -= 1;
          rsum -= 1;
          if (rsum > lsum) {
            if (rsum % 2 == 0) {
              ans[p.first] += 1;
            } else {
              ans[p.second] += 1;
            }
          } else if (lsum > rsum) {
            if (lsum % 2 == 0) {
              ans[p.second] += 1;
            } else {
              ans[p.first] += 1;
            }
          }
        }
        rsum = 0;
        lsum = 0;
      } else 
      if (s[i] == 'R' and s[i+1] == 'L') {
        flag = true;
        p.first = i, p.second = i+1;
      }

    }
  }

  for (int i = 0; i < s.size()-1; ++i) {
    cout << ans[i] << " ";
  }
  END;
}


Measured memory_bytes: 1408
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)


def fn(N, X):
    #print(N, X)
    if N == 0:
        if X <= 0:
            return 0
        else:
            return 1
    elif X <= 1+a[N-1]:
        return fn(N-1, X-1)
    else:
        return p[N-1] + 1 + fn(N-1, X-2-a[N-1])


print(fn(N, X))

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

using namespace std;

int x[100010],ans = 1e9 + 10;

int main()
{
    int n,k,l,r;
    cin >> n >> k;
    for(int i = 1; i <= n; i ++)
        scanf("%d",&x[i]);
    for(int i = 1; i <= n-k+1; i ++)
    {
        l = i,r = i+k-1;
        if(x[l] <= 0 && x[r] <= 0)
        {
            ans=min(ans,-x[l]);
        }
        else if(x[l] <= 0&&x[r] >= 0)
        {
            ans=min(ans,-2 * x[l] + x[r]);
            ans=min(ans,-x[l] + 2 * x[r]);
        }
        else ans=min(ans,x[r]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
loop do
  n, r = gets.chomp.split.map{|s| s.to_i}
  if n == 0 && r == 0
    break
  end

  set = (1..n).to_a.reverse

  r.times do
    p, c = gets.chomp.split.map{|s| s.to_i}
    
    set = set[(p-1)...(p+c-1)] + set[0...(p-1)] + set[(p+c-1)...set.length]
  end 

  p set[0]
end

Measured memory_bytes: 6136
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
int main()
{
	int x1, y1, x2, y2, x3, y3, x4, y4, a;
	cin >> x1 >> y1 >> x2 >> y2;
	
	int dx = x2-x1;
	int dy = y2-y1;

	x3 = x2-dy;
	y3 = y2+dx;
	x4 = x3-dx;
	y4 = y3-dy;

	cout << x3 << " "<< y3 << " " <<x4 << " " << y4 <<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BISU solver = new BISU();
        solver.solve(1, in, out);
        out.close();
    }

    static class BISU {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt(), y = in.nextInt(), z = in.nextInt();
            out.println((x - z) / (y + z));
        }

    }
}


Measured memory_bytes: 23252
n = int(input())
probs = [float(i) for i in input().split()]
dp = [[0]*n for i in range(n)]
for i in range(n):
    if i==n//2:
        dp[n-1][i] = probs[n-1]
    elif i<n//2:
        dp[n-1][i] = 0 
    else:
        dp[n-1][i] = 1
for i in range(n-2, -1,-1):
    for j in range(i, -1,-1):
        dp[i][j] = probs[i] * dp[i+1][j+1] + (1-probs[i])*dp[i+1][j] 
print(dp[0][0])

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
//}}}


int solve(){
  int a,b;cin>>a>>b;

  cout <<a*b - a - b + 1 << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
t = na()
a = na()
mod = 10**9+7

ans = 1
for i in range(n):
    tt,aa = 1,1
    if i == 0 or t[i-1] < t[i]:
        tt = t[i]
    if i == n-1 or a[i+1] < a[i]:
        aa = a[i]
    if tt > a[i] or aa > t[i]:
        print(0)
        exit()
    p = min(t[i],a[i]) - max(tt,aa) + 1
    ans = ans*p%mod

print(ans)

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

long long nc2(long long n)
{
  return n * (n-1) / 2;
}

int main()
{
  unordered_map<string, int> m;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }
  long long result = 0;
  for (const auto& p : m) {
    result += nc2(p.second);
  }
  cout << result << '\n';
  return 0;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a; i < n; i++)
#define per(i,a,n) for (int i=n-1; i >= a; i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
using namespace std;
int main(){
    int64 best = -1.1e18;
    int64 a[4];
    rep(i,0,4){
        cin >> a[i];
    }
    rep(i,0, 2){
        rep(j, 2,4){
            best = max(best, a[i] * a[j]);
            
        }
    }
    cout << best << endl;
}

Measured memory_bytes: 3628
import math
from datetime import date

def f(x, a):
	ans = 0
	for y in a:
		ans += (x - y) ** 2

	return ans

def main():
	
	n = int(input())
	a = [int(x) for x in input().split()]
	s = 0
	for x in a:
		s += x

	s = s // n
	ans = 10**17

	for x in range(s - 2, s + 3):
		ans = min(ans, f(x, a))

	print(ans)
	
main()


Measured memory_bytes: 9412
#include <stdio.h>
#define N 100

int main(){
	int a,b,flag,i,j,c,v;
	int A[N];

	scanf("%d",&b);
	for(i=0;i<b;i++){
		scanf("%d",&A[i]);
		v=A[i];
	}
	c = 0;
	for (i = 0; i < b-1; i++){
		for ( j = 0; j < b-1; j++){
			if (A[j] > A[j+1]){
				v = A[j];
				A[j] = A[j+1];
				A[j+1] = v;
				c++;
			}
		}
	}
	for(j=0;j<b;j++){
		printf("%d",A[j]);
		if(j<b-1) printf(" ");
	}
	printf("\n");
	printf("%d\n",c);
	return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

int main(void)
{
    int n, x;
    int i, j, k;
    int count;
    
    while(1){
        scanf("%d%d", &n, &x);
        if(!n&&!x){
            break;
        }
        count = 0;
        for(i=1; i<n-1; i++){
            for(j=i+1; j<n; j++){
                for(k=j+1; k<=n; k++){
                    if(i+j+k==x){
                        count++;
                    }
                }
            }
        }
        printf("%d\n", count);
    }
    
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
typedef long long int lli;

using namespace std;

int main(void){
    lli n, m;
    lli a, b;
    cin>>n>>m;
    
    vector<pair<lli, lli>> v;
    for(lli i=0; i<n; i++){
        cin>>a>>b;    
        v.push_back({a, b});
    }

    sort(v.begin(), v.end());

    lli num_sum = 0;
    lli ans = 0;
    for (lli i = 0; i<v.size(); i++){
        ans += v[i].first*v[i].second;
        num_sum += v[i].second;
        if(num_sum >= m){
            ans = ans - (num_sum - m)*v[i].first;
            break;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3444
fn main() {
    let s = read::<String>();
    if s.len() == 2 {
        println!("{}", s);
    } else {
        println!("{}", s.chars().rev().collect::<String>());
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
N, K = map(int, input().split())
import numpy as np
 
ans = 0
if  N >= K:
    ans+= (N-K+1)/N
    max_N = K-1
else:
    max_N = N
a_=0
for x in range(max_N):
    a_+=pow(1/2,np.ceil(np.log2(K/(x+1))))
#     print(ans)
ans += a_/N
print(ans)

Measured memory_bytes: 21404
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;
 
 
typedef long long ll;
typedef vector<int> VI;
    
vector<pair<int, int> > vp;
 
struct Less {
    bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
        return x.first > y.first;
    }
};
#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
 
//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];
ll N;
string s;
ll a[100010];
int main(void) {
    cin >> N;
    ll cnt=0;
    int flag =0;
    REP(i, N+1) cin >> a[i];
    
    int idx=0;
    while(1){
        if(idx>=N+1) break;
        if(a[idx]<a[idx+1]){
            if(flag == 0){
                flag = 1;
                cnt++;
            }else if(flag==-1) flag = 0;
        }
        if(a[idx]>a[idx+1]){
            if(flag == 0){
                flag = -1;
                cnt++;   
            }else if(flag==1) flag = 0;
        }
        idx++;
    }

    cout << cnt << endl;   
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
    ll n, ans = 0, x, y;
    cin >> n;
    for (x = 1; x <= n; x++) {
        y = n/x;
        ans += x * y*(y+1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a,b;
    cin>>a>>b;
    if((a*b)%2!=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if( A == B && B != C)
    cout << "Yes" << endl;
  else if (A == C && B != C)
    cout << "Yes" << endl;
  else if( B == C && A != B)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main()
{
	int l[10],v1,v2;
	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2) !=EOF)
	{
		int gou = 0,kaku = 0;
		for (int i = 0; i < 10; ++i)
			gou += l[i];
		double are = (double)gou*v1/(v1+v2);
		int ans;
		for (int i = 0; i < 10; ++i)
		{
			kaku += l[i];
			if(kaku >= are)
			{
				ans = i + 1;
				break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1208
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	int b = sc.nextInt();
    	int t = sc.nextInt();
    	sc.close();
    	System.out.println((t/a)*b);
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#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 mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	string s;
	while(cin>>s,s!="-"){
		string t,r;
		cin>>t>>r;
		char c=t[0];
		t.erase(t.begin());
		while(s.size()||t.size()){
			if(c==r[0]){
				r.erase(r.begin());
				c=s[0];
				s.erase(s.begin());
			}else{
				cout<<c;
				c=t[0];
				t.erase(t.begin());
			}
		}
		if(r.size()==0)cout<<c;
		cout<<endl;
	}
}

Measured memory_bytes: 1200
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pi pair<int,int>
#define ff first
#define ss second
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
struct cx{
    int w,r,v;
    void read(){
        cin >> w >> r >> v;
    }
    bool operator<(const cx& b){
        return (w + r < b.w + b.r);
    }
};

int32_t main(){
    int n;
    fastio;
    cin >> n;
    vector<cx> v(n);
    for(int i=0;i<n;i++){
        v[i].read();        
    }
    sort(td(v));
    int maxr = 1e4 * 3;
    vector<int> dp(maxr);
    for(int i=0;i<n;i++){
        for(int j=min(v[i].r,maxr - v[i].w);j>=0;j--){
            dp[j+v[i].w] = max(dp[j+v[i].w],dp[j] + v[i].v);
        }
    }
    cout << *max_element(td(dp)) << endl;
    
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 10000;

vector<pii> G[N];
long long d[N];

int main() {
	int n; cin >> n;
	rep(i, n) {
		int _, n2; cin >> _ >> n2;
		rep(j, n2) {
			int v, c; cin >> v >> c;
			G[i].push_back(pii(c, v));
		}
	}
	rep(i, n) d[i] = INFL;

	priority_queue<pii, vector<pii>, greater<pii>> Q;
	d[0] = 0;
	Q.push(pii(0, 0));
	while (!Q.empty()) {
		pii p = Q.top(); Q.pop();
		for (auto i : G[p.second]) {
			if (d[i.second] <= d[p.second] + i.first) continue;
			d[i.second] = d[p.second] + i.first;
			Q.push(i);
		}
	}
	rep(i, n) cout << i << ' ' << d[i] << endl;
}



Measured memory_bytes: 8004
#include<iostream>
#include<climits>
using namespace std;


int main(){
	int N;
	int val;
	cin >> N;
	int evenCnt=0;
	int oddCnt = 0;
	bool ok=true;

	
	int minval = INT_MAX;
	int maxval =0;
	for(int i = 0;i<N;i++){
		int value;
		cin >>value;
		if(value>maxval)maxval=value;
		if(value<minval) minval = value;
		if(0==value%2){evenCnt++;}
			else{oddCnt++;}		
	}
	ok=ok&&(maxval < N);
	ok=ok&&(maxval-minval <=1);
	int ku;
	int k;
	if(maxval ==minval){//all unique or not
		if(maxval == N-1){//unique
		ku=N;
		k=N;
		}else{//not
			ku=0;
			k=maxval;
			ok=ok&&(k>0);
			ok=ok&&(k<=max(evenCnt,oddCnt)/2);
			}
	}else{//mix
		k=maxval;
		int kk;
		if(maxval%2){
			kk=oddCnt;
			ku=evenCnt;
			} else {
				kk=evenCnt;
				ku=oddCnt;
			}
		ok=ok&&(k>ku);
		ok=ok&&(k<=ku+kk/2);		
	}
	

	if(ok)cout<<"Yes"<<endl; else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
class UnionFindTree():
    # Union find tree
    # 2つの効率化　経路圧縮、ランク
    # つなげることはできるか分離することはできないので、木をつなげる方向に利用する
    # 
    def __init__(self, node_size):
        # node_num: 全体のノード数
        # parent: ノードがrootなら-1、親がいれば親の番号を入れる
        # size:
        # rank:  
        # self.parent =[-1] * node_size
        self.parent =[-1]*node_size
 
        self.size = [1] * node_size
        self.rank = [1] * node_size
    
    def find_root(self,node):
        # node属する木のrootを探す
        # たどった経路に含まれるnodeの親をrootにつなぎ替える
        if self.parent[node] == -1:             # 自身がrootの場合
            root = node
        else:                                   # 自身がrootでない場合
            root = self.find_root(self.parent[node]) # 再帰的にrootを探す
            self.parent[node] = root            # たどった経路に含まれるnodeの親をrootにつなぎ替える(経路圧縮)
        return root

    def unite(self,node0, node1):
        # node0とnode1が含まれる木を結合する
        
        #node0 node1のrootを求める
        root_node0 = self.find_root(node0) 
        root_node1 = self.find_root(node1)

        if root_node0 != root_node1:
            # rankを比較しrankが小さい方の木を大きい方の木のrootにつなげる
            # rank is sameのときのみrankが増える
            if self.rank[root_node0] == self.rank[root_node1]: # rank is same
                self.parent[root_node1] = root_node0
                self.rank[root_node0] += 1
                self.size[root_node0] += self.size[root_node1]

            elif self.rank[root_node0] > self.rank[root_node1]:
                self.parent[root_node1] = root_node0
                self.size[root_node0] += self.size[root_node1]

            else:
                self.parent[root_node0] = root_node1

                self.size[root_node1] += self.size[root_node0]

    def same(self,node0,node1):
        #同じグループか確かめる
        return self.find_root(node0)==self.find_root(node1)


    # def recombind(self,node):
    #     # rootがnodeのものを整理し直す


N,M,K = map(int,input().split())

ut = UnionFindTree(N)
friend_dict = {i:0 for i in range(N)}

for i in range(M):
    x,y = map(int,input().split())
    x-=1
    y-=1
    ut.unite(x,y)
    friend_dict[x]+=1
    friend_dict[y]+=1
    # friend_dict[x].extend([y])
    # friend_dict[y].extend([x])

# for i in range(N):
#     ut.find_root(i)

# block_dict = {i:[] for i in range(N)}
block_dict = {i:0 for i in range(N)}

for i in range(K):
    x,y = map(int,input().split())
    x-=1
    y-=1
    if ut.same(x,y):
        block_dict[x]+=1
        block_dict[y]+=1
        # block_dict[x].extend([y])
        # block_dict[y].extend([x])

ans =""
for i in range(N):
    group =  ut.find_root(i)
    group_size = ut.size[group]

    # cand = group_size - len(friend_dict[i]) - len(block_dict[i])
    cand = group_size - friend_dict[i] - block_dict[i] - 1
    ans += str(cand) + " "
print(ans)

Measured memory_bytes: 32948
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int dp[110][10010]={}; //[v][w]

int main() { 
    int n;
    string s;
    cin>>n>>s;

    int ans=1;
    char c=s[0];

    rep(i,s.size()){
        if(s[i]!=c){
            ans++;
            c=s[i];
        }
    }
    cout<<ans<<endl;

}



Measured memory_bytes: 512
// AOJ 0558
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<map>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define X first
#define Y second
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> S;

int H, W, N;
const int HMAX = 1008, WMAX = 1008;
char field[HMAX][WMAX];

bool legal(P p) {
  return 0 <= p.X and p.X < W and 0 <= p.Y and p.Y < H
    and field[p.X][p.Y] != 'X';
}

const int INF = 1e7;
int dist[HMAX][WMAX];

int distance(P start, P goal) {
  priority_queue<S, vector<S>, greater<S> > que;
  REP(x,W) REP(y,H) { dist[x][y] = INF; }

  dist[start.X][start.Y] = 0;
  que.push(S(0, start));

  while (!que.empty()) {
    S state = que.top(); que.pop();
    P cur = state.second;
    if (dist[cur.X][cur.Y] < state.first) continue;
    
    const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    REP(i, 4) {
      P p = P(cur.X + dx[i], cur.Y + dy[i]);
      if (legal(p) and dist[p.X][p.Y] > dist[cur.X][cur.Y] + 1) {
        dist[p.X][p.Y] = dist[cur.X][cur.Y] + 1;
        que.push(S(dist[p.X][p.Y], p));
      }
    }
  }
  return dist[goal.X][goal.Y];
}

P search(char c) {
  REP(y, H) REP(x, W) {
    if (field[x][y] == c)
      return P(x, y);
  }
}

int solve() {
  int ans = 0;
  P start = search('S');
  for (int i = 1; i <= N; i++) {
    P goal = search('0' + i);
    ans += distance(start, goal);
    start = goal;
  }
  return ans;
}

int main() {
  cin >> H >> W >> N;
  REP(y, H) {
    string row;
    cin >> row;
    REP(x, W) {
      field[x][y] = row[x];
    }
  }

  cout << solve() << endl;
}

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

const long long  INF = 1LL << 60;

int N;
int H[100010];

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

    long long dp[100010];
    for (int i = 0; i < 100010; ++i) dp[i] = INF;
    dp[0] = 0;

    for (int i = 1; i < N; ++i) {
        dp[i] = min(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]));
        if (i >= 2) dp[i] = min(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]));
    }

    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
int main(){
        int n;
        int ans=0; int b=0;
        cin >>n;
        int a[n];
        for(int i=0; i<n; i++) {
                cin >> a[i];
        }
        while(!b) {
                for(int i=0; i<n; i++) {
                        b=a[i]%2;
                        if(b) break;
                        a[i]=(a[i]/2);
                }
                if(b) continue;
                ans++;
        }
        cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
using namespace std;
int main(){
    int N,M,ans=0;
    map<string , int>   mp;
    string str;
    cin >> N;
    vector<string> st;
    for(int i=0;i<N;i++){
            cin >> str;
            mp[str]++;
            st.push_back(str);
    }
    cin >> M;
    for(int i=0;i<M;i++){
            cin >> str;
            mp[str]--; 
            st.push_back(str);
    }
    for(int i=0;i<st.size();i++){
        ans = max(ans,mp[st[i]]);
    }
    cout << ans << endl;
    return 0;
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
  N = W*H
  |E| = N-1
*/

int main()
{
  int n;
  cin >> n;

  vi a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  vector<pii> v;
  rep(i, n) v.pb(mp(a[i], 0));
  rep(i, n) v.pb(mp(b[i], 1));

  sort(all(v));

  ll ans = 1, cnt = 0;
  rep(i, 2*n){
    if(v[i].second == 0){
      if(cnt < 0){
        ans = ans*-cnt%mod;
      }
      cnt++; 
    }else{
      if(cnt > 0){
        ans = ans*cnt%mod;
      }
      cnt--;
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef int in;
#define int long long

in main(){
    string s;
    cin >> s;
    int n = s.size();
    string ans = "";
    for(int i = 0 ; i < n ; i ++){
        if(s[i] != 'B'){
            ans.push_back(s[i]);
        }
        else{
            if(ans.size()){
                ans.pop_back();
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// You can edit this code!
// Click here and start typing.
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	wc := 0
	ans := 0
	for p, r := range s {
		if r == 'W' {
			ans += p - wc
			wc++
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 1920