akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n;cin>>n;
	vector<long long> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]-=i+1;
	}
	sort(a.begin(),a.end());
	long long b=a[n/2];
	long long ans=0;
	for(int i=0;i<n;i++){
		if(a[i]>b){
			ans+=a[i]-b;
		}else{
			ans+=b-a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


#define MAX_V 200000//調節！！！！！！！！！！！！！！！！！！！！！！！！
struct edge{ll to,cost;};
ll d[MAX_V];//頂点sからの最短距離
ll V;//頂点数！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！！
vector<edge>G[MAX_V];
void dijkstra(ll s){
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;//firstは最短距離、secondは頂点の番号
    fill(d,d+V+1,inf);//頂点番号は0~V-1でも1~Vでもお好きな方で
    d[s]=0;
    que.push(l_l(0,s));
    while(!que.empty()){
        //greater<l_l>なのでfirstが小さい順に取り出せる！
        l_l p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
        for(ll i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(l_l(d[e.to],e.to));
            }
        }
    }
}
////////////////////////////////////////

int main(){fastio
    ll n,m,s,t;cin>>n>>m>>s>>t;
    V=n+1;
    ll u[m][4];
    rep(i,0,m-1)rep(j,0,3){
        cin>>u[i][j];
    }
    rep(i,0,m-1){
        G[u[i][0]].pb({u[i][1],u[i][2]});
        G[u[i][1]].pb({u[i][0],u[i][2]});
    }
    dijkstra(s);
    ll ans[n+1];memset(ans,0,sizeof(ans));
    rep(i,1,n){
        ans[i]+=d[i];
    }
    //rep(i,1,n)cout<<ans[i]<<" ";cout<<endl;
    
    rep(i,1,n){
        G[i].clear();
    }
    
    rep(i,0,m-1){
        G[u[i][0]].pb({u[i][1],u[i][3]});
        G[u[i][1]].pb({u[i][0],u[i][3]});
    }
    dijkstra(t);
    rep(i,1,n){
        ans[i]+=d[i];
    }
    //rep(i,1,n)cout<<ans[i]<<" ";cout<<endl;
    for(ll i=n-1;i>=1;i--)Min(ans[i],ans[i+1]);
    rep(i,1,n){
        cout<<(ll)pow(10,15)-ans[i]<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 17092
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long
#define eb emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define MA 10e17
int va=10e8+7;
ll int dp[100004]={0};
using namespace std;
//Conditional Operator (condition?true part:false part) eg : cout<<(y<=3?"YES":"NO")<<endl;
//string s(3,'1');
// if number of elements in array >10^5 then declare global array.
ll getmul(ll n){ll int k{0};while(n>0){k+=n%10;n=n/10;}return k;}//Sum OF n DIGITS 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t{1};
    //cin>>t;
    while(t--){
       int d,t,s;
       cin>>d>>t>>s;
       ll x=ceil((double)d/s);
       if(x<=t) cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
    }
 return 0;
}

Measured memory_bytes: 3752
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
n=0
m=0
for i in range(N):
	n=n+int(min(A[i]+A[i+1],B[i]))
	if A[i]<=B[i] and A[i]+A[i+1]>=B[i]:
		A[i+1]=A[i+1]-(B[i]-A[i])
	elif A[i]<=B[i] and A[i]+A[i+1]<=B[i]:
		A[i+1]=0
for i in reversed(range(N)):
	m=m+int(min(A[i]+A[i+1],B[i]))
	if A[i+1]<=B[i] and A[i+1]+A[i]>=B[i]:
		A[i]=A[i]-(B[i]-A[i+1])
	elif A[i+1]<=B[i] and A[i+1]+A[i]<=B[i]:
		A[i]=0
print(max(m,n))


Measured memory_bytes: 18476
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int kaijou(int n){
  int kaijou_sum = 1;
  if(n!=0){
    for(int i=1;i<=n;i++){
      kaijou_sum *= i;
    }
    return kaijou_sum;
  }
  else return 1;
}

int main() {
  int n;
  cin >> n;
  int countAC  = 0;
  int countWA  = 0;
  int countTLE = 0;
  int countRE  = 0;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    if(s=="AC")   countAC++;
    if(s=="WA")   countWA++;
    if(s=="TLE")  countTLE++;
    if(s=="RE")   countRE++;
  }
  cout << "AC x " << countAC << endl;
  cout << "WA x " << countWA << endl;
  cout << "TLE x " << countTLE << endl;
  cout << "RE x " << countRE << endl;
}

Measured memory_bytes: 3624
def solve(n, k, a):
    x = [2**i for i in range(50, -1, -1)]
    ans = 0
    for x_i in x:
        u, v = 0, 0
        for a_j in a:
            u += x_i ^ (x_i & a_j)
            v +=       (x_i & a_j)
        if (x_i <= k) and (u > v):
            k -= x_i
            ans += u
        else:
            ans += v
    return ans

assert solve(3, 7, [1,6,3]) == 14
assert solve(4, 9, [7,4,0,3]) == 46

n, k = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, k, a))

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,k;
    cin>>n>>k;
    cout<<(n%k!=0)<<"\n";
    return 0;
}
/**

**/


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

char a[15];

int main(){

    scanf("%s",&a);
    int n = 753;
    int tmp = 0;
    int dif = 10000;
    int len = strlen(a);
    tmp = a[0]-48;
    tmp = (tmp*10)+(a[1]-48);


    for(int i=2;i<len;i++){

        tmp = (tmp*10)+(a[i]-48);
        if(abs(n-tmp)<dif) dif = abs(n-tmp);
        tmp = tmp%100;

    }

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

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define ll long long
#define int long long 
#pragma GCC diagnostic error "-std=c++11"
using namespace std;
const int mxn=200005;
struct vertex{
	int nxt,col;ll dist;
	vertex(){}
	vertex(int _x,int _c,int _d):nxt(_x),col(_c),dist(_d){}
};
struct query{
	int id,x,y,f;
	query(){}
	query(int _i,int _x,int _y,int _f):id(_i),x(_x),y(_y),f(_f){}
};
vector<vertex> g[mxn<<1];
int n,m;
ll ans[mxn],cnt[mxn],dis[mxn],dep[mxn];
vector<query> q[mxn];
int fa[mxn][22];
inline void predfs(int u,int par,ll dp){
	fa[u][0]=par;dep[u]=dp;
	for(vertex v:g[u]){
		if(v.nxt==par) continue;
		predfs(v.nxt,u,dp+1);
	}
}
inline void parinit(){
	for(int j=1;j<=19;++j) for(int i=1;i<=n;++i) fa[i][j]=fa[fa[i][j-1]][j-1];
}
inline int lca(int x,int y){
	if(dep[x]>dep[y]) swap(x,y);
	int step=dep[y]-dep[x],i;
	for(i=19;~i;--i) if(step&1<<i) y=fa[y][i];
	if(x==y) return x;
	for(i=19;~i;--i) if(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}
inline void dfs(int u,int par,ll dist){
	int i;
	for(i=0;i<q[u].size();++i){
		int id=q[u][i].id,a=q[u][i].x,b=q[u][i].y,f=q[u][i].f;
		ans[id]+=1ll*f*(dist-dis[a]+cnt[a]*b);
	}
	for(vertex v:g[u]){
		int vv=v.nxt,c=v.col,ds=v.dist;
		if(vv==par) continue;
		++cnt[c],dis[c]+=ds;
		dfs(vv,u,dist+ds);
		--cnt[c],dis[c]-=ds;
	}
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n>>m;
	int i,j,x,y,col,len,u,v;
	for(i=1;i<n;++i){
		cin>>x>>y>>col>>len;
		g[x].push_back(vertex(y,col,len));
		g[y].push_back(vertex(x,col,len));
	}
	predfs(1,0,0);
	parinit();
	for(i=1;i<=m;++i){
		cin>>x>>y>>u>>v;
		q[u].push_back(query(i,x,y,1));
		q[v].push_back(query(i,x,y,1));
		int l=lca(u,v);
		q[l].push_back(query(i,x,y,-2));
	}
	dfs(1,0,0);
	for(i=1;i<=m;++i) cout<<ans[i]<<endl;
}

Measured memory_bytes: 63856
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  string s;
  cin >> s;
  bool f = false;
  rep(i,s.size()){
    if(s[i]=='C') f = true;
    else if(f&&s[i]=='F'){
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
  return 0;
}


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

ll MOD = 1000000007;
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll fact(ll x,ll a){
	ll ans = 1;
	for(ll i = a; i <= x; i++){
		i %= MOD;
		ans = ans * i % MOD;
	}
	return ans;
}

int main(){	
	ll n,a,b; cin>>n>>a>>b;
	ll bad1 = (fact(n,(n-a)+1)*binpow(fact(a,1),MOD-2,MOD))%MOD;
	ll bad2 = (fact(n,(n-b)+1)*binpow(fact(b,1),MOD-2,MOD))%MOD;
	ll good = (bad1+bad2)%MOD;
	cout<<(((binpow(2,n,MOD)-1)%MOD)-good+MOD)%MOD<<"\n";
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char s[11],t[11];
int a,b;
char u[11];
int main(){
    while (scanf("%s %s",s,t)!=EOF){
        scanf("%d %d",&a,&b);
        scanf("%s",u);
        if (strcmp(s,u)) {
            printf("%d %d\n",a,b-1);
        }
        else {
            printf("%d %d\n",a-1,b);
        }

    }
    return 0;
}



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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N, K;
    cin >> N >> K;
    Vi A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    cout << (N - 1 + K - 2) / (K - 1) << endl;

    return 0;
}

Measured memory_bytes: 640
/*input
6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6
*/
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mod 998244353
//#define int long long
#define N 100005

int H[N], ok[N];
signed main() {
	int n,m;
	cin>>n>>m;
	//memset(ok,1,sizeof(ok));
	for(int i=1;i<=n;i++) cin>>H[i],ok[i]=1;
	while(m--) {
		int x, y;
		cin>>x>>y;
		if(H[x] < H[y]) swap(x,y);
		ok[y] = 0;
		if(H[x] == H[y]) ok[x] = 0;
	}
	int ans = 0;
	for(int i=1;i<=n; i++) ans+= ok[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<ll> pickdiv(ll n){
    vector<ll> res;
    for(ll i=1; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i);
        ll q = n/i;
        if(q != i){
            res.emplace_back(q);
        }
    }
    return res;
}
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>> res;
    for(ll i=2; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1)res.emplace_back(n,1);
    return res;
}
int main(){
    ll N;
    cin >> N;
    if(N==1){
        cout << 0 << endl;
        return 0;
    }
    auto v = factorize(N);
    ll ans = 0;
    rep(i,v.size()){
        auto p = v[i];
        int cnt = 1;
        while(cnt <= p.second){
            p.second -= cnt;
            cnt++;
            ans++;
        }
    }
    //map<ll,ll> mp;
    cout << ans << endl;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<double> a(n);
  rep(i,n) cin >> a[i];
  double ave=0;
  rep(i,k) ave += a[i]/k;
  for(int i=k; i<n; i++){
    if(ave < ave-a[i-k]+a[i]) cout << "Yes" << endl;
    else cout << "No" << endl;
    ave = ave-a[i-k]+a[i];
  }
}


Measured memory_bytes: 4840
N,M = gets.split(" ").map(&:to_i)
c = []
M.times do |i|
  c[i] = gets.split(" ").map(&:to_i)
end
c.sort!
l = c[0][0]; r = c[0][1]
cnt = 1
1.upto(M-1) do |i|
  if c[i][0] < r
    l = c[i][0]
    if r > c[i][1]
      r = c[i][1]
    end
  else
    cnt += 1
    l = c[i][0]; r = c[i][1]
  end
end
puts cnt

Measured memory_bytes: 10488
import collections
n=int(input())
v=list(map(int,input().split()))
ans=0
e=v[::2]
o=v[1::2]
ec=collections.Counter(e)
oc=collections.Counter(o)
E=len(e)
O=len(o)

E1=ec.most_common()[0][0]
e1=ec.most_common()[0][1]
try:
  E2=ec.most_common()[1][0]
  e2=ec.most_common()[1][1]
except:
  e2=0
O1=oc.most_common()[0][0]
o1=oc.most_common()[0][1]
try:
  O2=oc.most_common()[1][0]
  o2=oc.most_common()[1][1]
except:
  o2=0

if E1!=O1:
  ans=(E-e1)+(O-o1)
else:
  ans=min((E-e1)+(O-o2),(E-e2)+(O-o1))
print(ans)




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

int main(){
    string s,t;
    cin >> s >> t;
    size_t size1 = s.length();
    size_t size2 = t.length();
    int size = size2 - size1;
    if((equal(s.begin(),s.end(),t.begin()) == 1) && size == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
P = list(map(float, input().split()))

dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(1,N+1):
    p = P[i-1]
    for j in range(N+1):
        if j == 0:
            dp[i][j] = dp[i-1][j] * p
        else:
            dp[i][j] = dp[i-1][j-1] * (1-p) + dp[i-1][j] * p


print(sum(dp[N][:N//2+1]))

Measured memory_bytes: 259464
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}


int H,W,N;
int X,Y;
string S,T;
vector<pair<int,bool>> A,B;

signed main(){
	cin>>H>>W>>N>>Y>>X>>S>>T;
	Y--,X--;
	int l=0,r=W;
	if(S[N-1]=='L'){
		l++;
	}
	if(S[N-1]=='R'){
		r--;
	}
	for(int i=N-2;0<=i;i--){
		if(T[i]=='L'){
			r=min(r+1,W);
		}
		else if(T[i]=='R'){
			l=max(0,l-1);
		}
		if(S[i]=='L'){
			l=l+1;
		}
		else if(S[i]=='R'){
			r=r-1;
		}
		if(l>=r){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	if(X<l||r<=X){
		cout<<"NO"<<endl;
		return 0;
	}
	l=0,r=H;
	if(S[N-1]=='U'){
		l++;
	}
	if(S[N-1]=='D'){
		r--;
	}
	for(int i=N-2;0<=i;i--){
		if(T[i]=='U'){
			r=min(r+1,H);
		}
		else if(T[i]=='D'){
			l=max(0,l-1);
		}
		if(S[i]=='U'){
			l=l+1;
		}
		else if(S[i]=='D'){
			r=r-1;
		}
		if(l>=r){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	if(Y<l||r<=Y){
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  out(a * b / 2);
  memi;
}

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

int n;

void task(string s, int mx);

int main(void)
{
    //const double PI=3.141592653589793238;

    cin >> n;
    task("a", 0);
    return 0;
}

void task(string s, int mx)
{
    if(s.size() == n)
    {
        cout << s << endl;
        return;
    }

    for(int i=0; i<=mx+1; ++i){
        task(s + char('a'+i), max(mx, i));
    }

    
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vector<string> ss(n);
    rep(i,n) cin >> ss[i];
    vector<pii> va;
    vector<pii> vb;
    rep(i,n){
        string s = ss[i];
        int cnt = 0;
        int mi = 0;
        rep(j,s.size()){
            if(s[j] == '(') cnt++; else cnt--;
            mi = min(mi, cnt);
        }
        if(cnt >= 0) va.emplace_back(-mi, cnt);
        else vb.emplace_back(-mi, cnt);
    }
    sort(all(va));
    sort(all(vb), [&](pii a, pii b){ return a.fi+a.se > b.fi+b.se; });
    int cnt = 0;
    auto count = [&](vector<pii> &v){
        for(auto p : v){
            if(p.fi > cnt) return false;
            cnt += p.se;
        }
        return true;
    };
    bool can = count(va) && count(vb);
    if(can & cnt == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 42496
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    ll a = 0;
    ll b = 0;
    int k = 0;
    rep(i, N) {
        if(S[i] == 'B') {
            a += i;
            k++;
        }
    }
    for(int i = N-k; i < N; i++) {
        b += i;
    }

    cout << b - a;

    cout << endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int[] A = new int[M+1];
        for(int i=1;i<=M;i++) A[i]=sc.nextInt();
        int pos = 0;
        while(X>A[pos]) pos++;
        int ans = Math.min(pos-1,M-(pos-1));
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
typedef long long LL;
const int Maxn = 1e5 + 5;
LL n, b[Maxn], a[Maxn];

int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + 1 + n);
    int cnt = 0;
    for (int i = n; i > 1; i--) {
        if (a[i] == a[i-1]){
            b[++cnt] = a[i];
            i--;
            if(cnt == 2){
                cout << b[1]*b[2] << endl;
                return 0;
            }
        }
    }
    cout << "0" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}

int main() {
    int n,x,t; cin >> n >> x >> t;
    int ans = 0;int a = 0;
    while(a < n){
        a+=x;
        ans+=t;
    }
    cout << ans;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second
#define int long long

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;
#define TIMES_PER_SEC (CLOCKS_PER_SEC)



double get_absolute_time()
{
	return (double)clock()/TIMES_PER_SEC;
}
double starttime_acrush;
void starttime()
{
	starttime_acrush=get_absolute_time();
}
double gettime()
{
	return get_absolute_time()-starttime_acrush;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define MOD   1000000007
#define maxn 100002
#define inf 1e18


int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n,x;
  cin >> n >>x;
  int c = 0;
  vector<int> a(n);
  for(int i = 0 ; i<n ; i++)
    cin >> a[i];
  sort(a.begin(),a.end(),greater<int>());
  //int c=  0;
  for(int i = x ; i<n;i++)
    c+=a[i];
  cout << c;

}



Measured memory_bytes: 1792
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
SumBefore = sum(A)
for i in range(N):
    A[i+1] = max(A[i+1] - max(B[i]-A[i],0) ,0)
    A[i] = max(A[i]-B[i],0)
SumAfter = sum(A)
print(SumBefore-SumAfter)

Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    string s, t;
    cin >> s>>t ;
    cout << t << s << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace C_Answer
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(' ');
            int N = int.Parse(a[0]);
            int Q = int.Parse(a[1]);
            var field = Console.ReadLine();
            string[] op;
            List<char> t = new List<char>();
            List<char> d = new List<char>();
            for(int i = 0; i < Q; i++)
            {
                op = Console.ReadLine().Split(' ');
                t.Add(char.Parse(op[0]));
                d.Add(char.Parse(op[1]));
            }

            int min = N / 2;
            int max = N / 2;
            int ng = 0;
            int ok = N;
            while(ok - ng != 1)
            {
                var b = BinSearch(min, field, Q, t, d);
                if (b == 'L')
                {
                    ng = min;
                }
                else
                {
                    ok = min;
                }
                min = (ng + ok) / 2;
            }
            min = ng;
            ng = N;
            ok = 0;
            while(ng - ok != 1)
            {
                var c = BinSearch(max, field, Q, t, d);
                if(c == 'R')
                {
                    ng = max;
                }
                else
                {
                    ok = max;
                }
                max = (ng + ok) / 2;
            }
            max = ng;

            Console.WriteLine(max - min - 1);
        }

        static char BinSearch(int threshold,string s,int q, List<char> t, List<char> d)
        {
            for(int i = 0; i < q; i++)
            {
                if(s[threshold] == t[i])
                {
                    if (d[i] == 'L') threshold--;
                    else threshold++;

                    if (threshold < 0) return 'L';
                    if (threshold >= s.Length) return 'R';
                }
            }
            return 'A';
        }
    }
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int a,b,c;

int main(){
  scanf("%d %d %d",&a,&b,&c);
  int sum = a+b+c;
  int ma = a;
  ma = max(ma,b);
  ma = max(ma,c);
  printf("%d\n",sum-ma);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  rep(i,100000){
    if((int)(i*0.08)==a && (int)(i*0.1)==b){
      cout<<i;
      return(0);
    }
  }
  cout<<-1;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, 0, N) cin >> A[i] >> B[i];
    ll cnt = 0;
    for(ll i = N-1; i >= 0; i--){
        A[i] += cnt;
        if(A[i] % B[i] == 0) continue;
        ll rem = (ll)((A[i] + B[i] - 1)/B[i]) * B[i] - A[i];
        //cerr << i << ":" << rem << endl;
        cnt += rem;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long n;

	std::cin >> n;

	std::vector<std::pair<std::string, long long> > v(n);
	
	for (long long i = 0; i < n; i++)
	{
		long long a;
		std::string s;

		std::cin >> s >> a;
		v[i] = { s, a };
	}

	std::string s;
	std::cin >> s;

	bool flag = false;
	long long ans = 0;
	for (size_t i = 0; i < v.size(); i++)
	{
		if (flag) {
			ans += v[i].second;
		}
		if (v[i].first == s) {
			flag = true;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cstdlib>
#include <ctime>
#include <cstdint>
#include <cmath>

#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define EACH(i,x)   for(auto & i : x)
#define ALL(x)      begin(x),end(x)

using namespace std;

typedef vector<int> vecint;

int root(int i,vecint& p){
  if(p[i] != i+1)
    p[i] = root(p[i]-1,p);
  return p[i];
}
void join(int i,int j,vecint& p){
  p[root(i,p)-1] = root(j,p);
}

int main()
{
  while(true){
    int w,h;cin>>w>>h;
    if(!(w||h))break;
    vector<vecint> m(h+2,vecint(w+2));
    REP(i,h)REP(j,w)cin>>m[i+1][j+1];
    int n=(w+2)*(h+2);
    vecint p(n);
    REP(i,n)p[i]=i+1;
    REP(i,h)REP(j,w){
      int di[8] = {1,1,1,0,-1,-1,-1,0};
      int dj[8] = {1,0,-1,-1,-1,0,1,1};
      REP(k,8){
        int ni=i+di[k];
        int nj=j+dj[k];
        if (m[i+1][j+1] && m[ni+1][nj+1]){
          int ijn = (i+1)*(w+2)+(j+1);
          int nijn = (ni+1)*(w+2)+(nj+1);
          join(ijn,nijn,p);
        }
      }
    }
    set<int> s;
    REP(i,h)REP(j,w){
      if(m[i+1][j+1]){
        int ijn = (i+1)*(w+2)+(j+1);
        s.insert(root(ijn,p));
      }
    }
    cout<<s.size()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1264
N, T = map(int, input().split())
buttons = list(map(int, input().split()))
water = [[buttons[0], buttons[0]+T]]
for i in range(1, N):
	if buttons[i] < water[-1][1]:
		water[-1][1] = buttons[i] + T
	else:
		water.append([buttons[i], buttons[i]+T])
sum = 0
for i in range(0, len(water)):
	sum += water[i][1] - water[i][0]
print(sum)

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

int main(void) {
	int N; cin >> N;
	int L[2 * N], i, sum = 0;
	for (i = 0; i < 2 * N; i++) {
		cin >> L[i];
	}
	sort(L, L + 2 * N);

	for (i = 0; i < 2 * N; i += 2) {
		sum += min(L[i], L[i + 1]);
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				(1000 * 1000 * 1000 * 2)
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<int, int>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) {
		cin >> A[i];
	};
	sort(ALL(A));
	reverse(ALL(A));

	vector<ll> hen;
	REP(i, N - 1) {
		if (A[i] == A[i + 1]) {
			hen.emplace_back(A[i]);
			i++;
		}
	}

	sort(ALL(hen));
	reverse(ALL(hen));
	if (hen.size() < 2) {
		cout << 0 << endl;
	} else {
		cout << (ll)hen[0] * hen[1] << endl;
	}
	return 0;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, a[1000];
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = n-1; i > 0; i--) cout << a[i] << " ";
    cout << a[0] << endl;
}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

int main(){
	int n, m;
	vector<bool> flag;
	vector<int> h, p;
	cin >> n >> m;

	for(int i = 0; i < n; i++){
		int a; cin >> a;
		h.pb(a);
	}

	//sort(h.begin(), h.end());

	for(int i = 0; i < n; i++){
		flag.pb(true);
	}

	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		if(h[a] >= h[b]) flag[b] = false;
		if(h[a] <= h[b]) flag[a] = false;
	}

/*	for(int i = 0; i < m; i++){
		int a, b;
		a = h[path[i].first].second;
		b = h[path[i].second].second;
		cout << a << ", " << b << endl;
		if(h[path[i].first].first > h[path[i].second].first){
			flag[path[i].first] = false;
		}
	}
	*/
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(flag[i]){
			cnt++;
	//		cout << i + 1 << endl;
		}
	}

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


Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main(){
  int h, w, d, x;
  cin >> h >> w >> d;
  vector<P> ai(h*w+5);
  for(int i=0; i<h; ++i) for(int j=0; j<w; ++j){
    cin >> x;
    ai[x] = make_pair(i,j);
  }
  
  int dig[h*w+5];
  for(int i=1; i<=h*w; ++i){
    if(i <= d) dig[i] = 0;
    else{
      int mag = abs(ai[i].first - ai[i-d].first) + abs(ai[i].second - ai[i-d].second);
      dig[i] = dig[i-d] + mag;
    }
  }
  int q, l, r;
  cin >> q;
  for(int i=0; i<q; ++i){
    cin >> l >> r;
    cout << dig[r] - dig[l] << endl;
  }
}

Measured memory_bytes: 2176
N = int(input())
X = list(map(int, list(input())))
X.reverse()
def int2bit(n):
	ret = [0 for i in range(18)]
	cnt = 0
	i = 0
	while n > 0:
		ret[i] = n % 2
		cnt += n % 2
		n = n // 2
		i += 1
	return (ret, cnt)

def func(bit, popcount):
	ret = 0
	base = 1
	for b in bit:
		ret = (ret + base*b) % popcount
		base = (base * 2) % popcount
	return ret

def func2(n):
	(bit, popcount) = int2bit(n)
	return func(bit, popcount)

F = [0 for _ in range(N+1)]

for n in range(1, N+1):
	a = func2(n)
	F[n] = 1 + F[a]
P = sum(X)

f_1 = func(X, P+1)
f_0 = func(X, max(1, P-1))

base_1 = [1]
base_0 = [1]
for i in range(N-1):
	base_1.append((base_1[i] * 2) % (P+1))
	base_0.append((base_0[i] * 2) % max(1, P-1))
for i in range(N):
	idx = N - 1 - i
	if X[idx] == 0:
		print(1 + F[(f_1 + base_1[idx]) % (P+1)])
	if X[idx] == 1:
		if P == 1:
			print(0)
		else:
			print(1 + F[(f_0 - base_0[idx]) % (P-1)])

Measured memory_bytes: 30408
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(1000000000)

N, *XY = map(int,open(0).read().split())
MOD = 10**9 + 7

neighbor = [[] for _ in range(N)]
for x,y in zip(*[iter(XY)]*2):
    neighbor[x-1].append(y-1)
    neighbor[y-1].append(x-1)

memo = [[-1]*2 for _ in range(N)]

def dp(node, color, parent):
    if memo[node][color] != -1:
        return memo[node][color]
    output = 1
    for child in neighbor[node]:
        if child == parent:
            pass
        else:
            tmp = dp(child, 0, node)
            if color == 0:
                tmp += dp(child, 1, node)
            output *= tmp
            output %= MOD
    memo[node][color] = output
    return output

print((dp(0,0,-1) + dp(0,1,-1)) % MOD)

Measured memory_bytes: 223760
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class Prigram
{
	public static void Main()
	{
        int N = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        List<int> A = new List<int>() { Capacity = N };
        for (int i = 0; i < N; i++)
            A.Add(int.Parse(s[i]));

        A.Sort();
        LinkedList<int> T = new LinkedList<int>();
        foreach (var v in A)
            T.AddLast(v);
        while (T.Count != 1)
        {
            while (T.First.Value == 0)
                T.RemoveFirst();

            int NewHP = T.Last.Value % T.First.Value;
            T.RemoveLast();
            if (NewHP != 0)
            {
                LinkedListNode<int> node = T.First;
                while (node.Value < NewHP)
                    node = node.Next;

                T.AddBefore(node, NewHP);
            }
        }
        Console.WriteLine(T.First.Value);
    }
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    if(b == 0) return a;
    return gcd(b, a %b);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    vector<ll> left(n), right(n);
    left[0] = a[0], right[n-1] = a[n-1];
    for(int i=1;i<n;i++) left[i] = gcd(left[i-1], a[i]);
    for(int i=n-2;i>=0;i--) right[i] = gcd(right[i+1], a[i]);
    ll maxg = 0;
    for(int i=0;i<n;i++){
        // (..., a_{i-1}), a_i, (a_{i+1}, ...)
        ll g;
        if(i - 1 >= 0 && i + 1 < n){
            g = gcd(left[i-1], right[i+1]);
        }else if(i - 1 >= 0){
            g = left[i-1];
        }else{
            g = right[i+1];
        }
        maxg = max(g, maxg);
    }
    cout << maxg << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    vector<string> YN{"NO","YES"};
    vector<string> yn{"No","Yes"};
    int a,b,c;
    cin>>a>>b>>c;
    cout<<yn[a<=c&&b>=c]<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static ArrayList<Group> preset = new ArrayList<Group>();
	static Group U;

	public static void main(String[] args) throws Exception {
		while (sc.hasNext()) {
			preset.clear();
			for (int i = 0; i < 5; ++i) {
				preset.add(new Group());
			}
			while (true) {
				String label = sc.next();
				int N = sc.nextInt();
				if (label.equals("R")) break;
				for (int i = 0; i < N; ++i) {
					preset.get(label.charAt(0) - 'A').set.add(sc.nextInt());
				}
			}
			U = new Group();
			for (int i = 0; i < preset.size(); ++i) {
				U.set.addAll(preset.get(i).set);
			}
			Parser parser = new Parser(sc.next());
			Group result = parser.parse();
			ArrayList<Integer> ans = new ArrayList<Integer>(result.set);
			Collections.sort(ans);
			if (ans.isEmpty()) {
				System.out.println("NULL");
			} else {
				for (int i = 0; i < ans.size(); ++i) {
					if (i != 0) System.out.print(" ");
					System.out.print(ans.get(i));
				}
				System.out.println();
			}
		}
	}

	static class Parser {
		String expr;
		int pos = 0;

		Parser(String expr) {
			this.expr = expr;
		}

		Group parse() {
			Group left = term();
			while (pos < expr.length()) {
				char op = expr.charAt(pos);
				++pos;
				if (op == ')') break;
				Group right = term();
				switch (op) {
				case 'u':
					left.set.addAll(right.set);
					break;
				case 'i':
					left.set.retainAll(right.set);
					break;
				case 'd':
					left.set.removeAll(right.set);
					break;
				case 's':
					HashSet<Integer> intersect = new HashSet<Integer>(left.set);
					intersect.retainAll(right.set);
					left.set.removeAll(intersect);
					right.set.removeAll(intersect);
					left.set.addAll(right.set);
					break;
				}
			}
			return left;
		}

		Group term() {
			char c = expr.charAt(pos);
			++pos;
			if (c == '(') {
				return parse();
			}
			if (c == 'c') {
				Group g = term();
				Group ret = new Group();
				ret.set.addAll(U.set);
				ret.set.removeAll(g.set);
				return ret;
			}
			Group ret = new Group();
			ret.set.addAll(preset.get(c - 'A').set);
			return ret;
		}
	}

	static class Group {
		HashSet<Integer> set = new HashSet<Integer>();;
	}

}

Measured memory_bytes: 11000
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {

        
        static void Main(string[] args) 
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int M = int.Parse(str[1]);

            int S = N - M;

            long kaisu = (long)Math.Pow(2, M);

            long ans = (100 * S + 1900 * M) * kaisu;

            Console.WriteLine(ans);


        }
    }
}


Measured memory_bytes: 13140
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N,H; cin >> N >> H;
    vector<ll> a(N), b(N); REP(i,N) cin >> a[i] >> b[i];
    SORT(a); REVERSE(a); SORT(b); REVERSE(b);
    vector<ll> c(N,0); c[0] = b[0];
    REP(i,N-1) c[i+1] = c[i] + b[i+1];
    ll ans = 0;
    while(ans < N && c[ans] < H && a[0] <= b[ans]) ans++;
    if(ans < N && c[ans] >= H) ans++;
    else{
        if(ans == N){
            ans += (H-c[N-1])/a[0];
            if((H-c[N-1])%a[0]) ans++;
        }
        else{
            if((H-c[ans-1])%a[0])
                ans += (H-c[ans-1])/a[0]+1;
            else
                ans += (H-c[ans-1])/a[0];
        }
    }
        

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

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int K;
	cin >> K;

	ll num = 7;
	for (int i = 0; i < K; i++) {
		num %= K;
		if (num == 0) {
			cout << i + 1 << endl;
			return 0;
		}
		num = num * 10 + 7;
	}

	cout << "-1" << endl;

	return 0;
}


Measured memory_bytes: 3512
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  if (b == 'T') cout << 'A' << endl;
  if (b == 'G') cout << 'C' << endl;
  if (b == 'C') cout << 'G' << endl;
  return 0;
}


Measured memory_bytes: 764