akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

const int MN = 2010;

int N;
int C[MN << 1], A[MN << 1], invx[MN], invy[MN];
vector<int> X, Y;
int Mx[2][MN];
int cnt[2][MN][MN], psum[2][MN][MN];

int calc(int t, int l, int r, int x) {
    if(l > r) return 0;
    return psum[t ^ 1][x][r] - (l? psum[t ^ 1][x][l - 1] : 0);
}

int cc[MN][MN];
int dp(int pos1, int pos2) {
    if(pos1 == N && pos2 == N) return 0;
    int &ret = cc[pos1][pos2];
    if(ret != -1) return ret;

    ret = 1e9;
    if(pos1 < N) {
        ret = min(ret, dp(pos1 + 1, pos2) + calc(0, pos2, N - 1, pos1));
    }
    if(pos2 < N) {
        ret = min(ret, dp(pos1, pos2 + 1) + calc(1, pos1, N - 1, pos2));
    }
    return ret;
}

int main() {
    scanf("%d", &N);

    for(int i = 0; i < 2 * N; i++) {
        char c; scanf("\n%c %d", &c, &A[i]);
        C[i] = c == 'B';
        A[i]--;
        if(C[i]) X.push_back(A[i]);
        else Y.push_back(A[i]);
    }

    int ans = 0;
    int mx1 = -1;
    int mx2 = -1;
    for(int i = 0; i < N; i++) {
        mx1 = max(mx1, X[i]);
        mx2 = max(mx2, Y[i]);
        invx[ X[i] ] = i;
        invy[ Y[i] ] = i;
        Mx[1][ X[i] ] = mx1;
        Mx[0][ Y[i] ] = mx2;

        for(int j = 0; j < i; j++) {
            if(X[i] < X[j]) ans++;
            if(Y[i] < Y[j]) ans++;
        }
    }

    for(int i = 0; i < 2 * N; i++) {
        for(int j = 0; j < i; j++) {
            if(C[i] != C[j]) cnt[ C[i] ][ A[i] ][ A[j] ] = 1;
        }
    }
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < N; j++) {
            for(int a = 0; a < N; a++) {
                psum[i][j][a] = cnt[i][j][a];
                if(a) psum[i][j][a] += psum[i][j][a - 1];
            }
        }
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", ans + dp(0, 0));
}


Measured memory_bytes: 79360
import queue

"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""
N = int(input())
s = "No"
for i in range(1,10):
	for j in range(1,10):
		if i*j==N:
			s = "Yes"
print(s)

Measured memory_bytes: 4208
h,w=map(int,input().split())

inf=float('inf')

ans=inf

for i in range(1,h):
  a=i*w
  rest=h*w-a
  b=(w//2)*(h-i)
  c=rest-b
  max_s=max(a,b,c)
  min_s=min(a,b,c)
  ans=min(ans,max_s-min_s)
  
for j in range(1,w):
  A=j*h
  Rest=h*w-A
  B=(h//2)*(w-j)
  C=Rest-B
  Max_s=max(A,B,C)
  Min_s=min(A,B,C)
  ans=min(ans,Max_s-Min_s)
  
if w>=3:
  if w%3==0:
    ans=0
  else:
    ans=min(ans,h)
    
if h>=3:
  if h%3==0:
    ans=0
  else:
    ans=min(ans,w)
    
print(ans)
  



Measured memory_bytes: 9248
# 入力
W, H, x, y = map(int, input().split())

# 面積は必ず二等分可能
# 面積を二等分する直線は長方形の中心を通る
ans = '{} {}'.format(
    W * H / 2,
    1 if x == W / 2 and y == H / 2 else
    0
)

# 出力
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long bit[60];
  for (long i = 0; i < 60; i++) {
    bit[i] = 0;
  }
  long div;
  for (long i = 0; i < 50; i++) {
    div = pow(-2,i+1);
    if (n%div != 0) {
      bit[i] = 1;
      n -= pow(-2,i);
    }
  }
  int flag = 0;
  for (long i = 50; i > 0; i--) {
    if (bit[i] == 1) {
      flag = 1;
    }
    if (flag == 1) {
      printf("%ld", bit[i]);
    }
  }
  printf("%ld\n", bit[0]);

  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int N, M;
		cin >> N >> M;
		int x = N+M;

		cout << x*(x-1)/2 - N*M << endl;
	}
};

int main() {
	Solver().solve();
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    
    double m_angle = 360/60 * m;
    double h_angle = 360/12 * h + 0.5 * m;
    double angle = abs(h_angle - m_angle);
    if (angle > 360 - angle) angle = 360 - angle;
    double term1 = a * sin(angle * M_PI / 180.0);
    double term2 = b - a * cos(angle * M_PI / 180.0 );
    cout.setf(ios::fixed);
    cout.precision(9);
    cout << sqrt( term1*term1 + term2*term2 ) << endl;
    
    
    return 0;
}



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

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

  for (int i = 0; i < 3; i++) {
    if(n[i]=='1') cout << "9";
    else if(n[i]=='9') cout << "1";
    else cout << n[i];
  }

  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
 
struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

template<typename Monoid>
struct SegmentTree{
    using F=function<Monoid(Monoid,Monoid)>;
    int sz;
    vector<Monoid> seg;
    const F f;
    const Monoid gen;
    SegmentTree(int n,const F f,const Monoid &gen):f(f),gen(gen){
        sz=1;
        while(sz<n)sz<<=1;
        seg.assign(2*sz,gen);
    }
    void set(int k,const Monoid &x){
        seg[k+sz]=x;
    }
    void build(){
        for(int k=sz-1;k>0;k--) seg[k]=f(seg[2*k],seg[2*k+1]);
    }
    void update(int k,const Monoid &x){
        k+=sz;
        seg[k]=x;
        while(k>>=1) seg[k]=f(seg[2*k],seg[2*k+1]);
    }
   // [a,b)
    Monoid query(int a,int b){
        Monoid L=gen,R=gen;
        for(a+=sz,b+=sz;a<b;a>>=1,b>>=1){
            if(a&1) L=f(L,seg[a++]);
            if(b&1) R=f(seg[--b],R);
        }
        return f(L,R);
    }
    Monoid operator[](const int &k)const {
       return seg[k+sz];
    }
};

signed main(){
    int n,q;cin>>n>>q;
    SegmentTree<ll> seg(n,[](ll a,ll b){return a+b;},0ll);
    rep(i,n){
        ll a;cin>>a;
        seg.set(i,a);
    }
    seg.build();
    while(q--){
        int t;cin>>t;
        if(t){
            int l,r;cin>>l>>r;
            cout<<seg.query(l,r)<<endl;
        }else{
            int p;ll x;cin>>p>>x;
            seg.update(p,seg[p]+x);
        }
    }
    return 0;
}

Measured memory_bytes: 12536
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main()
{
    int N;
    cin >> N;
    cout << N*(N+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A,B,C,X,counter=0;
    cin >> A >>B>>C>>X;

    for(int i=0;i<=A;i++){
      for(int j=0;j<=B;j++){
        for(int k=0;k<=C;k++){
          if(500*i+100*j+50*k==X){
            counter++;
          }
        }
      }
    }
   cout << counter << "\n";

    return 0;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

const int NODE_SIZE=1010;

int H;  //フィールドの高さ
int W;  //フィールドの幅
int start_y, start_x;    //開始座標

char field[NODE_SIZE][NODE_SIZE];    //格子状のフィールド (配列)

int d[NODE_SIZE][NODE_SIZE];    //各座標までの距離

int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { -1, 0, 1, 0 };
int dx8[8] = { 0,1,1,1,0,-1,-1,-1 };
int dy8[8] = { -1,-1,0,1,1,1,0,-1 };

int ansMax=0;
//幅優先探索 (フィールド: 配列/string)
void bfs_field() {
    queue<pair<int,int>> q; //<コスト, 座標(y,x)>
    bool visited[H][W];
    REP(i,0,H)REP(j,0,W) visited[i][j]=false; //初期位置を設定
    REP(i,0,H)REP(j,0,W) d[i][j] = -1;// 最後まで-1なら到達不可能
    q.push({start_y, start_x});  // 開始ノードを追加
    d[start_y][start_x] = 0; // 初期状態のコスト
    while(!q.empty()){
        int cur_y = q.front().first;
        int cur_x = q.front().second;
        int curStep = d[cur_y][cur_x];
        q.pop();
        if(visited[cur_y][cur_x]) continue;
        visited[cur_y][cur_x] = true;
        REP(k,0,4){
            int next_y = cur_y + dy[k];
            int next_x = cur_x + dx[k];
            
            if(!CK(next_y,0,H) || !CK(next_x,0,W)) continue;  //範囲外
            if(field[next_y][next_x]=='#') continue;
            if(!visited[next_y][next_x]){     //未到達の座標だけpush.
                q.push({next_y, next_x});
                d[next_y][next_x] = d[cur_y][cur_x] + 1;
                ansMax = max(ansMax, d[next_y][next_x]);
            }
        }
    }
}

/*==================================================*/
/* example */

int main(){

    cin >> H >> W;
    REP(y,0,H){
        REP(x,0,W){
            cin >> field[y][x];
        }
    }
    REP(y,0,H){
        REP(x,0,W){
            if(field[y][x]=='.'){
                start_y = y;
                start_x = x;
                bfs_field();
            }
        }
    }
    P(ansMax);
    return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define N 200
#define Max 1000000
int top;
int S[N];

int pop(){
	return S[top--];
}

void init(){
	top = 0;
}

void push(int x){
	S[++top] = x;
}
int main(){
	char s[Max];
	int a,b;
	init();
	while(scanf("%s",s)!=EOF){
		if(!strcmp(s,"+")){
			a = pop();
			b = pop();
			push(a+b);
		}
		else if(!strcmp(s,"-")){
			a = pop();
			b = pop();
			push(b - a);
		}
		else if(!strcmp(s,"*")){
			a = pop();
			b = pop();
			push(a * b);
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}


const int MAX_N = 112345;
int x[MAX_N];

ll f(int a, int b) {
  if (b <= 0) return abs(a);
  if (0 <= a) return b;
  a = abs(a);
  b = abs(b);
  return min(a,b)*2 + max(a,b);
}

int main2() {
  int N = nextInt();
  int K = nextInt();
  REP(i, N) x[i] = nextInt();

  ll ans = 1LL << 58;
  for (int i = 0; i + K <= N; i++) {
    chmin(ans, f(x[i], x[i+K-1]));
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int Q;cin>>Q;
  vector<int> primes(100010,0);
  REP(i,2,100010){
    if(primes[i]==0){
      primes[i]=1;
      int j=2*i;
      for(;j<100010;j+=i){
        primes[j]=-1;
      }
    }
  }
  vector<int> arr(100010,0);
  REP(i,3,100010){
    if(primes[i]==1&&primes[(i+1)/2]==1)arr[i]=arr[i-1]+1;
    else arr[i]=arr[i-1];
  }
  // view(arr);
  int l,r;
  REP(i,0,Q){
    cin>>l>>r;
    print(arr[r]-arr[l-1]);
  }



}


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

using namespace std;

int main() {
	// your code goes here
	int  n,i=1;
	int count=0;
	cin>>n;
	while(i<=n){
	    if(i%2!=0){
	        count++;
	        }
	        i++;
	}
	cout<<fixed<<setprecision(10)<<(float)count/(float)n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking 
#define fi first
#define se second
#define BG begin
#define ED end

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF (1ll<<60)
using namespace std;
/*
const int N=265000;
int a[N],mx[N][2],ans[N],n;
int main(){
	scanf("%d",&n); a[(1<<n)]=-1e9;
	For(i,0,(1<<n)-1) scanf("%d",&a[i]);
	For(i,0,(1<<n)-1) mx[i][0]=i,mx[i][1]=(1<<n);
	For(i,0,n-1) For(j,0,(1<<n)-1)
		if (j&(1<<i)){
			int k=j-(1<<i);
			if (a[mx[j][0]]<a[mx[k][0]])
				mx[j][1]=mx[j][0],mx[j][0]=mx[k][0];
			else if (a[mx[j][1]]<a[mx[k][0]])
				mx[j][1]=mx[k][0];
			if (a[mx[j][1]]<a[mx[k][1]])
				mx[j][1]=mx[k][1];
		}
	For(i,1,(1<<n)-1) ans[i]=a[mx[i][0]]+a[mx[i][1]];
	For(i,1,(1<<n)-1) printf("%d\n",ans[i]=max(ans[i],ans[i-1]));
}*/
ll a[200005];
int n;
ll S(ll l,ll r){
	return a[r]-a[l-1];
}
pll getl(int l,int r){
	int L=l,R=r; 
	int ans=l; --r;
	while (l<=r){
		int mid=(l+r)/2;
		if (S(L,mid)<=S(mid+1,R))
			ans=mid,l=mid+1;
		else r=mid-1;
	}
	ll v1=S(L,ans);
	ll v2=S(ans+1,R);
	return pll(max(v1,v2),min(v1,v2));
}
pll getr(int l,int r){
	int L=l,R=r;
	int ans=l; --r;
	while (l<=r){
		int mid=(l+r)/2;
		if (S(L,mid)>=S(mid+1,R))
			ans=mid,r=mid-1;
		else l=mid+1;
	}
	ll v1=S(L,ans);
	ll v2=S(ans+1,R);
	return pll(max(v1,v2),min(v1,v2));
}
ll merge(pll a,pll b){
	return max(a.fi,b.fi)-min(a.se,b.se);
}
void upd(ll &x,ll y){
	x=min(x,y);
}
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%lld",&a[i]),a[i]+=a[i-1];
	ll ans=INF;
	For(i,2,n-2){
		pll v1=getl(1,i);
		pll v2=getr(1,i);
		pll v3=getl(i+1,n);
		pll v4=getr(i+1,n);
		upd(ans,merge(v1,v3));
		upd(ans,merge(v1,v4));
		upd(ans,merge(v2,v3));
		upd(ans,merge(v2,v4));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int sum=0;
	cin>>s;
	s=s[0]+s;
	for(int i=1;i<s.size();i++)
	{
		if(s[i]!=s[i-1]) 
		{
			sum++;
		}
	}
	cout<<sum;
    return 0;
}

Measured memory_bytes: 512
int main(int argc, const char * argv[]) {
    
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    //評価
    if (a<b && b<c) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2048
import fractions

def lcm(x,y):
  return x * y // fractions.gcd(x,y)


mod = 10**9+7


N = int(input())

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

B = 0
for i in A:
    B += pow(i,mod-2,mod)
    B %= mod

g = 1

for i in range(N):
    g = lcm(g,A[i])

print (g * B % mod)
    


Measured memory_bytes: 67688
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] padding = new String[]{"", "0", "00", "000", "0000", "00000"};
        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = parseInt(st.nextToken());
        int M = parseInt(st.nextToken());
        int[][] cities = new int[M][4];//[p,y,index,sort]

        for (int i = 0; i < M; i++) {
            st = new StringTokenizer(br.readLine());
            cities[i][0] = parseInt(st.nextToken());
            cities[i][1] = parseInt(st.nextToken());
            cities[i][2] = i;
        }
        br.close();

        Arrays.sort(cities, (e1, e2) -> (e1[0] == e2[0]) ? (e1[1] - e2[1]) : (e1[0] - e2[0]));
        cities[0][3] = 1;
        for (int i = 1; i < M; i++) {
            cities[i][3] = (cities[i][0] == cities[i - 1][0]) ? cities[i - 1][3] + 1 : 1;
        }

        Arrays.sort(cities, (e1, e2) -> e1[2] - e2[2]);
        StringBuilder sb = new StringBuilder(100000 * 13);

        for (int[] city : cities) {
            sb.append(padding[getZeroCnt(city[0])]).append(city[0]);
            sb.append(padding[getZeroCnt(city[3])]).append(city[3]).append('\n');
        }
        System.out.println(sb.toString());
    }

    private static int getZeroCnt(int n) {
        if (n < 10) return 5;
        else if (n < 100) return 4;
        else if (n < 1000) return 3;
        else if (n < 10000) return 2;
        else if (n < 100000) return 1;
        else return 0;
    }
}


Measured memory_bytes: 51048
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator++() { x += 1; return *this;}
  mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
  mint& operator--() { x -= 1; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { mint res(*this); return res+=a; }
  mint operator-(const mint a) const { mint res(*this); return res-=a; }
  mint operator*(const mint a) const { mint res(*this); return res*=a; }
  bool operator==(const int n) const { mint a(n); return this->x == a.x; }
  bool operator==(const ll n) const { mint a(n); return this->x == a.x; }
  bool operator!=(const int n) const { mint a(n); return this->x != a.x; }
  bool operator!=(const ll n) const { mint a(n); return this->x != a.x; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { mint res(*this); return res/=a; }
};
istream& operator>>(ostream& is,const mint& m) { return is >> m.x; }
ostream& operator<<(ostream& os,const mint& m) { return os << m.x; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w,K;
    cin >> h >> w >> K;
    if(w == 1) {
        cout << 1 << endl;
        return 0;
    }
    vector<vector<mint>> dp(h+1,vector<mint>(w,0));
    dp[0][0] = 1;
    rep2(i,1,h+1) rep(bit,1<<(w-1)) {
        bool ok = true;
        rep(j,w-2) if(bit>>j&1 && bit>>(j+1)&1) ok = false;
        if(!ok) continue;
        dp[i][0] += bit&1 ? dp[i-1][1] : dp[i-1][0];
        dp[i][w-1] += bit>>(w-2)&1 ? dp[i-1][w-2] : dp[i-1][w-1];
        rep2(j,1,w-1) {
            dp[i][j] += bit>>j&1 ? dp[i-1][j+1] : (bit>>(j-1)&1 ? dp[i-1][j-1] : dp[i-1][j]);
        }
    }
    cout << dp[h][K-1] << endl;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <cctype>
#include <iostream>
using namespace std;

typedef long long LL;
typedef stringstream strstm;
#define PI acos(-1.0)
#define E 2.718281829459
#define pb push_back
#define lowbit(x) (x & (-x))
#define DBG(x) cout << (x) << " ";
#define MST(a,b) memset(a,b,sizeof(a));
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define _ech(x,z) for(auto x = z.begin(); x != z.end(); ++x)

struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;


const int maxn = 10011;
int arr[maxn];
int a = 10000, b = 5000, c= 1000;
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,money; cin >> n >> money;
    int i,j,k;
    int flag = 0;
    int ta = money/a, tb = money/b;
    for(i = 0; i <= ta; i++){
        for(j = 0; j <= tb; j++){
            if(i*a + j*b + (n-i-j)*c == money && (i+j) <= n){
                cout << i << " " << j << " " << (n-i-j) << endl;
                flag = 1;
                break;
            }
        }
        if(flag == 1) break;
    }
    if(flag == 0){
        cout << -1 << " " << -1 << " " << -1 << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ldouble;
int compare(const void *a, const void *b){return *(ll *)a>*(ll *)b?1:*(ll *)a<*(ll *)b?-1:0;}

int main(void){
    // ldouble t;
    ll n,p[5],i,t;
    scanf("%lld",&n);
    for(i=0;i<5;i++){
        scanf("%lld",&p[i]);
    }
    qsort(p,5,sizeof(ll),compare);
    t=4+ (n%p[0]==0 ?  n/p[0]:n/p[0]+1);
    printf("%lld\n",t);
    return 0;
}

Measured memory_bytes: 128
import statistics

k, n = map(int, input().split())
a = list(map(int, input().split()))
dist = []

for num, i in enumerate(a[:]):
  if num == (n - 1):
    dist.append(abs((k + a[0]) - i))
  else:
    dist.append(abs(a[num + 1] - i))
ind = dist.index(max(dist))
dist.pop(ind)
print(sum(dist))

Measured memory_bytes: 28376
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 2e5+10;


ll ans[n_max] = {};
bool is_moved[n_max] = {};
vector<int> ab[n_max];
void dfs(int x, ll a){
    is_moved[x] = 1;
    ans[x] += a;
    for(auto i : ab[x]){
        if(is_moved[i] == 0){
            dfs(i,ans[x]);
        }
    }
}

int main(){
    int n,q; cin >> n >> q;
    rep(i,n-1){
        int atemp,btemp; cin >> atemp >> btemp;
        atemp--;btemp--;
        ab[atemp].push_back(btemp);
        ab[btemp].push_back(atemp);
    }
    rep(i,q){
        int p,x; cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0,0);
    rep(i,n){
        cout << ans[i] << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 21376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    int n,y; cin >> n >> y;
    y/=1000;
    if(n*10<y){
        cout << -1 << " " << -1 << " " << -1 << endl;
    }
    else{
        int ans=0;
        int count=0;
        int a1,b1,c1;
        rep(i,n+1){
            rep(j,n-i+1){
                int k = n-i-j;
                ans = 10*i + 5*j + k;
                if(ans==y){
                    a1 = i;
                    b1 = j;
                    c1 = k;
                    count += 1;
                }
            }
        }
        if(count!=0){
            cout << a1 << " " << b1 << " " << c1 << endl;
        }else{
            cout << -1 << " " << -1 << " " << -1 << endl;
        }
    }
    


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  vector<int> vec(N) ;
  rep(i,N) {
cin >>vec.at(i);
  }
  vector<double>vect(N);
  rep(i,N) {
vect.at(i)=(double)1/(double)vec.at(i);
  }
  double count=0;
  rep(i,N) {
    count +=vect.at(i);
  }
  
  double x=(double)1/(double)count;
  cout << x<< endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        //塔を生成
        int[] tower = new int[999];
        for(int i=0; i<999; i++) {
            if(i == 0) {
                tower[i] = i + 1;
            } else {
                tower[i] = tower[i-1] + i + 1;
            }
        }

        int index = b - a - 1;

        int answer = tower[index] - b;

        System.out.println(answer);
    }

}


Measured memory_bytes: 22996
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <vector>
using namespace std;

#define ll long long
#define fi first
#define se second
#define mp make_pair

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

void vdump(vector<int> v){
  for (auto itr = v.begin(); itr != v.end(); ++itr)
  {
    print(*itr);
  }
  println("");
}

int main(int argc, char const *argv[])
{
	int A,B;
	cin >> A >> B;
	print((A-1)*(B-1));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

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

int n;
int A[SIZE];
ll K;

int main()
{
	cin >> n;
	rep(i,0,n)cin >> A[i];
	int p,q;
	sort(A,A+n);
	p = A[n-1];
	int s = lower_bound(A,A+n,p/2)-A;
	int t = s-1;
	//cout << A[s] << A[t] < endl;
	if(s < 0 or s >= n){
		cout << p << " " << A[t] << endl;
	}else if(A[s] == p){
		cout << p << " " << A[t] << endl;
	}else if(t < 0 or t >= n){
		cout << p << " " << A[s] << endl;
	}else if(A[t] == p){
		cout << p << " " << A[s] << endl;
	}else{
		if(abs(double(p)/2 - double(A[s])) >= abs(double(p)/2 - double(A[t]))){
			cout << p << " " << A[t] << endl;
		}else{
			cout << p << " " << A[s] << endl;
		}
	}

	return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  long long sumNum = 0;
  long long minNum = 10000000000;
  int minusCnt = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < 0) {
      minusCnt++;
    }
    minNum = min(abs(A[i]), abs(minNum));
    sumNum += abs(A[i]);
  }

  if (minusCnt % 2 == 1) {
    sumNum -= minNum * 2;
  }

  cout << sumNum << endl;
}


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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

int n,mod;
const int MAXN = 100*1000+1;
vi V[MAXN];
LL dp[MAXN][2];
bool visited[MAXN];
int ans[MAXN];

void dfs(int x,int p) {
    visited[x]=1;
    for(auto nbh:V[x]) {
        if(!visited[nbh]) {
            dfs(nbh,x);
        }
    }
    if(p!=-1&&V[x].size()==1) {
        dp[x][1] = dp[x][0] = 1;
    }
    else {
        dp[x][1] = 1;
        dp[x][0] = 0;
        for(auto nbh:V[x]) {
            if(nbh!=p) {
                dp[x][1] = ((LL)dp[x][1]*(dp[nbh][1]+1))%mod;
                dp[x][0] = (dp[x][0]+dp[nbh][0]+dp[nbh][1])%mod;
            }
        }
    }
}

void dfs2(int x,int p) {
    visited[x]=1;
    ans[x] = dp[x][1];
    vector<LL> pref={1},suf={1};
    int pos = 0;
    for(auto nbh:V[x]) {
        pref.PB(((LL)pref.back()*(dp[nbh][1]+1))%mod);
        pos++;
    }
    for(int i=V[x].size()-1; i>=0; i--) {
        suf.PB((suf.back()*(dp[V[x][i]][1]+1))%mod);
    }
    reverse(suf.begin(),suf.end());
    pos=0;
    for(auto nbh:V[x]) {
        if(!visited[nbh]) {
            //changes
            dp[x][0] = (dp[x][0] - (dp[nbh][0]+dp[nbh][1]))%mod;
            dp[x][0] = (dp[x][0]+mod)%mod;
            dp[nbh][0] = (dp[nbh][0]+dp[x][0]+dp[x][1])%mod;
            dp[x][1] = (pref[pos]*suf[pos+1])%mod;
            dp[nbh][1] = (dp[nbh][1]*(dp[x][1]+1))%mod;
            dfs2(nbh,x);
            //roll back
            dp[nbh][0] = (dp[nbh][0]-dp[x][0]-dp[x][1])%mod;
            dp[nbh][0] = (dp[nbh][0]+mod)%mod;
            dp[x][0] = (dp[x][0]+dp[nbh][0]+dp[nbh][1])%mod;
            dp[x][1] = pref.back();
        }
        pos++;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>mod;
    for(int a,b,i=1; i<n;i++) {
        cin>>a>>b;
        V[a].PB(b);
        V[b].PB(a);
    }
    dfs(1,-1);
    for(int i=1; i<=n;i++) visited[i]=0;
    dfs2(1,-1);
    for(int i=1; i<=n;i++) cout<<ans[i]<<"\n";
}


Measured memory_bytes: 26880
x, y = (int(i) for i in input().split())

a = (1, 3, 5, 7, 8, 10, 12)
b = (4, 6, 9, 11)
c = (2,)

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x == y == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 8904
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
template<typename T=lint>T in(){
    T x;
    cin>>x;
    return x;
}
template<typename T=lint>initializer_list<T> in(lint n){
    vector<T> x(n);
    rep(i,n)cin>>x[i];
    return x;
}
int main(){
    lint n;
    cin>>n;
    vec a(n),b(n);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    lint cnt=0;
    rep(j,200)rep(i,n){
        lint near=b[(i+n-1)%n]+b[(i+n+1)%n];
        lint sn=min(b[(i+n-1)%n],b[(i+n+1)%n]);
        if(b[i]-a[i]>=near){
            lint tmp=min((b[i]-a[i])/near*near,(b[i]-sn)/near*near+near);
            cnt+=tmp/near;
            b[i]-=tmp;
        }
    }
    if(a==b)cout<<cnt;
    else cout<<-1;
}

Measured memory_bytes: 3328
import math
while True:
    n= int(input())
    if n==0:
        break
        
    s = list(map(float, input().split()))
    i=0
    sum=0
    sum_s=0
    for i in range(n):
        sum_s+=s[i-1]
    m=sum_s/len(s)
    for i in range(n):
        sum+=(s[i-1]-m)**2

    print(math.sqrt(sum/n))



Measured memory_bytes: 5780
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	const ll MOD=998244353;
	ll w[100010];
	w[0]=1, w[1]=1000000000000000000ll%MOD;
	for(int i=2; i<=n; i++) w[i]=w[i-1]*w[1]%MOD;
	int m[3];
	vector<ll> c[3];
	for(int t=0; t<3; t++){
		cin>>m[t];
		vector<vector<int>> g(n);
		vector<int> v(n);
		for(int i=0; i<m[t]; i++){
			int x, y; cin>>x>>y; x--; y--;
			if(x>y) swap(x, y);
			g[x].push_back(y);
		}
		for(int i=n-1; i>=0; i--){
			set<int> st;
			for(auto y:g[i]){
				st.insert(v[y]);
			}
			for(int k=0; ; k++){
				if(st.find(k)==st.end()){
					v[i]=k;
					break;
				}
			}
		}
		int mx=0;
		for(int i=0; i<n; i++) mx=max(mx, v[i]);
		c[t].resize(mx+1);
		for(int i=0; i<n; i++){
			c[t][v[i]]+=w[i+1];
			if(c[t][v[i]]>=MOD) c[t][v[i]]-=MOD;
		}
	}
	ll ans=0;
	for(int i=0; i<c[0].size(); i++){
		for(int j=0; j<c[1].size(); j++){
			int k=(i^j);
			if(k>=c[2].size()) continue;
			(ans+=c[0][i]*c[1][j]%MOD*c[2][k])%=MOD;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5584
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define ld long double
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    cout << (s == "ABC" ? "ARC" : "ABC");
    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll A, V;
    cin >> A >> V;
    ll B, W;
    cin >> B >> W;
    ll T;
    cin >> T;
    if(W >= V) {
        cout << "NO" << endl;
    } else {
        ll dist = abs(A - B);
        ll s = V - W;
        if(s * T >= dist) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
using System;
using System.Linq;

namespace atcoder1234
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int b = (A[0] / A[1]);
            if (A[0] % A[1] == 0)
            {
                Console.WriteLine(b * A[2]);
            }
            else { Console.WriteLine((b + 1) * A[2]); }
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 28072
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((int)(x).size())

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

int main() {
  int X;
  cin >> X;
  if (X >= 30) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

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



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

	long double a;
	cin >> a;
	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			long double b = i;
			long double c = j;
			long double d = (long double)4 / a - 1 / b - 1 / c;
			if (d < EPS) {
				continue;
			}
			d = (long double)1 / d;
			if (abs(round(d) - d) < EPS) {
				cout << i << " " << j << " " << (long long int)(d + EPS) << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
const int N = 1e9;
using namespace std;
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define read(x) scanf("%d",&x)
#define put(x) printf("%d\n",x)
#define memset(x,y) memset(x,y,sizeof(x))
#define ll long long

int main(){
	double x,shui=1.08;
	cin>>x;
	int ans=x/1.08;
	if(ans==x/1.08) put(ans);
	else if(ans<x/1.08){
		ans++;
		if((int)(ans*1.08)==x) put(ans);
		else puts(":(\n");
	}
	return 0;
}


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

bool Dislike(int n, bool *dislike) {
	while (n > 0) {
		if (dislike[n % 10]) return true;
		n /= 10;
	}
	return false;
}

int main() {
	int n, k;
	cin >> n >> k;
	bool dislike[10] = {};
	for (int i = 0; i < k; i++) {
		int d;
		cin >> d;
		dislike[d] = true;
	}
	while (Dislike(n, dislike)) {
		n++;
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int D[3][2]={{1,0},{0,1},{-1,0}};
int main(){
	int W,H,N,d,r=0;
	scanf("%d%d%d",&W,&H,&N);
	vector<vector<int>> v={{W-1,H-1,W-1},{W-2,H-3,W-2}}, p={{0,0},{0,1}}, c={{0,0},{0,0}};
	for(;N--;){
		scanf("%d",&d);
		p[d][0]+=D[c[d][0]][0];
		p[d][1]+=D[c[d][0]][1];
		c[d][1]++;
		if(c[d][1]==v[d][c[d][0]])c[d][0]++,c[d][1]=0;
		if(abs(p[0][0]-p[1][0])+abs(p[0][1]-p[1][1])<2)r++;
	}
	printf("%d\n",r);
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N =1e5+5;
vector<int> adj[N];
const int MOD = 1e9+7;

int dp[N][2];

void dfs(int u, int par = -1){
	int a = 1, b = 1;
	for(auto v : adj[u]){
		if(v==par) continue;
		dfs(v,u);
		a = (a*(dp[v][0]+dp[v][1]))%MOD;
		b = (b*dp[v][0])%MOD;
	}
	dp[u][0] = a;
	dp[u][1] = b;
}

void solve(){
	int n;
	cin >> n;
	for(int i = 1;i < n;i++){
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	//0->black, 1-white
	dfs(1);
	cout << (dp[1][0] + dp[1][1])%MOD << "\n";
}

signed main(){
	fastio
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 17504
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;
int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
        mx = max(mx, mp[s]);
    }
    for (auto it : mp) {
        if (it.second == mx) {
            cout << it.first << '\n';
        }
    }
}




Measured memory_bytes: 25216
import math

n = int(input())
d = n
m = {}

for i in range(2, int(math.sqrt(n)) + 1):
    m[i] = 0
    while (d % i == 0):
        d //= i
        m[i]+=1
res = 0
for i in m.values():
    res+=int(math.sqrt(i*2+0.25)-0.5)

if d > 1:
    res += 1
print(res)


Measured memory_bytes: 92768
c=eval('[0]*50,'*50)
r=0
for a in[*open(0)][1:]:
 a=round(float(a)*1e9);x=y=1
 while a%2**x<1:x+=1
 while a%5**y<1:y+=1
 r+=sum(sum(d[max(0,20-y):])for d in c[max(0,20-x):]);c[x][y]+=1
print(r)

Measured memory_bytes: 88880
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()


int main() {
    int n;
    cin>>n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p.at(i);
    rep(i,n) cin >> q.at(i);
    
    vector<int> a(n);
    rep(i,n) a.at(i) = i+1;
    
    map<vector<int>, int> mp;
    do{
        mp[a] = (int)mp.size();
    } while(next_permutation(all(a)));
    
    int ans = abs(mp[q] - mp[p]);
    dunk(ans);
    
    return 0;
}



Measured memory_bytes: 6528
#include<stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  while(a>0 && c>0){
    c-=b;
    a-=d;
  }
  if(c<=0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long comb(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    map<int,int> mp;
    int l,r;
    REP(i,n+1){
        int x;cin>>x;
        if(mp[x]!=0){
            l = mp[x];
            r = i+1;
            continue;
        }
        mp[x] = i+1;
    }
    comb_init();
    for(int k=1;k<=n+1;k++) cout<<(comb(n+1,k)-comb(l+n-r,k-1)+MOD)%MOD<<endl;

}

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

using ll = long long;
const ll mod = ll(1e9)+7;

ll modinv(ll a, ll m) {
  return a == 1 ? 1 : m - modinv(m % a, a) * m / a;
}

ll choose(ll n, ll r) {
  r = min(r, n - r);
  if (r < 0) return 0;
  ll num = 1, den = 1;
  for (int i = 0; i < r; i++) {
    num *= (n - i), num %= mod;
    den *= i+1, den %= mod;
  }
  return num * modinv(den, mod) % mod;
}

int main() {
  ll N, M, K; cin >> N >> M >> K;
  ll res = (M + N) % mod * M % mod * N % mod * ((M * N - 1) % mod) % mod;
  res *= modinv(6, mod), res %= mod;
  res *= choose(N * M - 2, K-2), res %= mod;
  cout << res << '\n';
}

Measured memory_bytes: 256