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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s, t;
  cin >> s >> t;

  vector<int> sA(s.length()+1), tA(t.length());
  sA[0] = 0;
  tA[0] = 0;

  rep(i, s.length()){
    if(s[i]=='A'){
      sA[i+1] = sA[i] + 1;
    }else{
      sA[i+1] = sA[i];
    }
  }

  rep(i, t.length()){
    if(t[i] == 'A'){
      tA[i+1] = tA[i] + 1;
    }else{
      tA[i+1] = tA[i];
    }
  }

  int q;
  cin >> q;
  vector<bool> ans(q);

  rep(i, q){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    a--;
    c--;

    int v1 = (b-a) - 2 * (sA[b] - sA[a]);
    int v2 = (d-c) - 2 * (tA[d] - tA[c]);

    if(abs(v1 - v2) % 3 == 0){
      ans[i] = true;
    }else{
      ans[i] = false;
    }

  }

  rep(i, q){
    if(ans[i]){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }



  return 0;
}


Measured memory_bytes: 1744
import math

a = []
for i in range(3):
	a.append(input())

if int(a[0]) >= int(a[1]):
  if int(a[2]) % int(a[0]) == 0:
    print(math.ceil(int(a[2]) // int(a[0])))
  else:
    print(math.ceil((int(a[2]) // int(a[0])) + 1))
else:
  if int(a[2]) % int(a[1]) == 0:
    print(math.ceil(int(a[2]) // int(a[1])))
  else:
    print(math.ceil((int(a[2]) // int(a[1]))) + 1)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

#define ALL(x) begin(x), end(x)


int main() {
  int A,B,K;
  cin >> A >> B >> K;

  for (int i = A; i <= min(B, A+K-1); ++i) {
    cout << i << endl;
  }
  
  for (int i = max(B-K+1, A+K); i <= B; ++i) {
    cout << i << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#define llint long long

using namespace std;

llint N, A, B;
llint v[55];
llint comb[55][55];

int main(void)
{
	comb[0][0] = 1;
	for(int i = 1; i < 55; i++){
		for(int j = 0; j < 55; j++){
			comb[i][j] = comb[i-1][j];
			if(j > 0) comb[i][j] += comb[i-1][j-1];
		}
	}
	
	cin >> N >> A >> B;
	for(int i = 0; i < N; i++){
		cin >> v[i];
		v[i] *= -1;
	}
	sort(v, v+N);
	
	double avg = 0.0;
	for(int i = 0; i < A; i++) avg += v[i];
	avg /= A;
	printf("%.8f\n", -avg);
	
	llint ans, num = upper_bound(v, v+N, v[A-1]) - lower_bound(v, v+N, v[A-1]);
	if(v[A-1] == v[0]){
		ans = 0;
		for(int i = A; i <= min(num, B); i++) ans += comb[num][i];
	}
	else{
		ans = 0;
		int p = lower_bound(v, v+N, v[A-1]) - v;
		ans = comb[num][A-p];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;
int dp[41][101][101];

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

    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector< vector<int> > chem(N, vector<int>(3));
    REP(i, N)REP(j, 3) cin >> chem[i][j];
    
    REP(i, 41)REP(j, 101)REP(k, 101) dp[i][j][k] = INF;
    dp[0][0][0] = 0;

    REP(i, N)REP(a, 91)REP(b, 91){
        // 薬品をとらない
        dp[i+1][a][b] = min(dp[i+1][a][b], dp[i][a][b]);
        // 薬品をとる
        dp[i+1][a+chem[i][0]][b+chem[i][1]] = min(dp[i+1][a+chem[i][0]][b+chem[i][1]], dp[i][a][b] + chem[i][2]);
    }
    
    int ans = INF;
    FOR(i, 1, 101)FOR(j, 1, 101){
        if(Ma*j == Mb*i){
            ans = min(ans, dp[N][i][j]);
        }
    }
    if(ans == INF) ans = -1;
    cout << ans << "\n";

    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

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

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

struct MaxFlowCalculator {
	int max_flow(int s, int t, const vector<vector<pair<int, int>>>& g) {
		struct edge_ { int to, cap, rev; };
		vector<bool> used(g.size(), false);
		vector<vector<edge_>> G(g.size());
		for (int i = 0; i < g.size(); i++) for (int j = 0; j < g[i].size(); j++)
		{
			int from = i, to = g[i][j].second;
			int cap = g[i][j].first;
			G[from].push_back({ to, cap, (int)G[to].size() });
			G[to].push_back({ from, 0, (int)G[from].size() - 1 });
		}
		auto dfs = [&](auto&& f, int v, int t, int fl)->int {
			if (v == t) return fl;
			used[v] = true;
			rep(i, G[v].size()) {
				edge_& e = G[v][i];
					if (!used[e.to] && e.cap > 0) {
					int d = f(f, e.to, t, min(fl, e.cap));
					if (d > 0) {
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		};
		int flow = 0;
		while (1) {
			used.assign(used.size(), false);
			int f = dfs(dfs, s, t, INT_MAX);
			if (f == 0) return flow;
			flow += f;
		}
	}
};

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<bool>> grid(h, vector<bool>(w));
	rep(i, h) {
		string s;
		cin >> s;
		rep(j, w) {
			grid[i][j] = s[j] == '.';
		}
	}
	vector<vector<P>> xr(h, vector<P>(w));
	rep(i, h) {
		int left = 0;
		int right = 0;
		rep(j, w) {
			if (!grid[i][j]) {
				left = j + 1;
				right = j + 1;
			}
			else {
				while (right < w && grid[i][right]) {
					right++;
				}
				xr[i][j] = { left, right };
			}
		}
	}
	vector<vector<P>> yr(h, vector<P>(w));
	rep(j, w) {
		int top = 0;
		int bottom = 0;
		rep(i, h) {
			if (!grid[i][j]) {
				top = i + 1;
				bottom = i + 1;
			}
			else {
				while (bottom < h && grid[bottom][j]) {
					bottom++;
				}
				yr[i][j] = { top, bottom };
			}
		}
	}

	ll u = 0;
	rep(i, h) {
		rep(j, w) {
			if (grid[i][j]) {
				ll x = xr[i][j].second - xr[i][j].first;
				ll y = yr[i][j].second - yr[i][j].first;
				chmax(u, x+y-1);
			}
		}
	}
	cout << u << endl;
    return 0;
}


Measured memory_bytes: 129104
#include<iostream>
#include<stack>
#include<string.h>
using namespace std;
struct ST {
	int a;
	int b;
	int c;
};
long long brock[1000][1000];
long long ds[1000][1000];
int q[4]={0,-1,0,1};
int p[4]={1,0,-1,0};
int main(){
	stack <ST> S;
	ST ma;
	ST ba;
	int w,h;//???????????§??????
	int xs,ys;//??????????????§?¨?
	int xg,yg;//??´????????§?¨?
	int n;//????????????????????°
	int c,d,x,y;//????????????????????±
	int i,j,m,check=0;
	while(1){
		memset(ds,0,sizeof(ds));
		memset(brock,0,sizeof(brock));
		cin>>w>>h;//???????????§????????\???
		if(w==0&&h==0){
			break;
		}
		cin>>xs>>ys>>xg>>yg;//??????????????¨??´???????????§?¨???\???
		cin>>n;//????????????????????°
		for(i=0;i<n;i++){
			cin>>c>>d>>x>>y;
			if(d==0){
				for(m=y;m<y+2;m++){
					for(j=x;j<x+4;j++){
						brock[m][j]=c;
					}
				}
			}
			else{
				for(m=y;m<y+4;m++){
					for(j=x;j<x+2;j++){
						brock[m][j]=c;
					}
				}
			}
		}
		/*for(i=1;i<h;i++){
			for(j=1;j<w;j++){
				cout<<brock[i][j];
			}
			cout<<endl;
		}*/
		if(brock[ys][xs]!=brock[yg][xg]){
			cout<<"NG"<<endl;
		}
		else{
			ma.a=ys;
			ma.b=xs;
			ma.c=brock[ys][xs];
			ds[ys][xs]=1;
			S.push(ma);
			check=0;
			while(!S.empty()){
				ba=S.top();
				S.pop();
				ds[ba.a][ba.b]=1;
				if(ba.a==yg&&ba.b==xg){
					check=1;
					continue;
				}
				for(i=0;i<4;i++){
					if(ba.a+p[i]>0&&ba.a+p[i]<=h&&ba.b+q[i]>0&&ba.b+q[i]<=w&&ds[ba.a+p[i]][ba.b+q[i]]==0&&brock[ba.a+p[i]][ba.b+q[i]]==brock[yg][xg]){
						ma.a=ba.a+p[i];
						ma.b=ba.b+q[i];
						ma.c=brock[ba.a+p[i]][ba.b+q[i]];
						S.push(ma);
					}
				}
			}
		if(check==1){
			cout<<"OK"<<endl;
		}
		else{
			cout<<"NG"<<endl;
		}
		}
	}
	return 0;
}

Measured memory_bytes: 18620
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
string s,t;
string ans=""; 
int fun=0,con=0; 
string maximum(string x,string y){
    if(x.length()>=y.length()) return x;
    else return y;
}
string len(int n,int m){
    vector<vector<int>> dp(n+1,vector<int> (m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    //int i=0,j=0;
    //int x=dp[n][m];
    string ans="";
    int i=n,j=m;
    while(i>0&&j>0){
        if(s[i-1]==t[j-1]){
            ans+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i][j-1]>dp[i-1][j]){
            j--;
        }
        else i--;
        //cout<<ans<<endl;
    }
    return ans;
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);  
	cin>>s;
	cin>>t;
	ans=len(s.length(),t.length()); 
	reverse(ans.begin(),ans.end());
	cout<<ans;
}


Measured memory_bytes: 38476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n;
	cin >> n;
	vector<int> a(n),b(n),c(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n-1) cin >> c[i];

	int ans = 0;
	rep(i,n){
		ans += b[a[i]-1];
		if(i>=1 && a[i] == a[i-1] + 1){
			ans += c[a[i-1]-1];
		}
	}
	cout << ans << endl;



  return 0;
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int a, b, c, n;
void in(){
    cin >> a >> b >> c >> n;
}

void solve(){
    int ans = 0;
    rep(i,0,3001){
        rep(j,0,3001){

            if(a * i + b * j > n) continue;
            if((n - a * i - b * j) % c == 0) ans++;
        }
    }

    print(ans);

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 998244353
#define ld long double
#define pll pair<ll,ll>
using namespace std;

ll powa(ll a,ll b)
{
	a%=mod;
	if(a==0)return 0;
	ll ans=1;

	while(b>0)
	{
		if(b&1)ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

int main()
{ 
	

fast;

ll n,s;
cin>>n>>s;

ll a[n+1];
for(ll i=1;i<=n;i++)
cin>>a[i];

ll dp[n+1][s+1];
memset(dp,0,sizeof(dp));

dp[0][0]=powa(2,n);
ll inv2=powa(2,mod-2);
// cout<<inv2<<endl;
for(ll i=1;i<=n;i++)
{
	for(ll j=0;j<=s;j++)
	{
		dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;

		if(j+a[i]<=s)
			dp[i][j+a[i]]=(dp[i][j+a[i]]+ dp[i-1][j]*inv2%mod)%mod;
	}
}
cout<<dp[n][s]<<endl;
}


Measured memory_bytes: 74004
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  while (cin >> n, n) {
    map<char, char> t;
    rep(i, n) {
      char a, b;
      cin >> a >> b;
      t[a] = b;
    }
    int m;
    cin >> m;
    rep(i, m) {
      char x;
      cin >> x;
      cout << char(t.count(x) ? t[x] : x);
    }
    cout << endl;
  }
}

Measured memory_bytes: 2996
function Main(input) {

    var H = Number(input);

    if (H === 1) return console.log(1);

    var counter = 1;
    while (true) {
        H = Math.floor(H / 2);
        counter++;
        if (H === 1) break;
    }

    const answer = Math.pow(2, counter) - 1;

    //出力
    console.log(answer);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
        int b = sc.nextInt();
        int n = b - a;
        int x = 1;
        for(int i = 2; i <= n; i++){
        	x += i;
        }
        System.out.println(x - b);
    }
}

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

int main(){
  int64_t h, w;
  cin >> h >> w;
  if(min(h, w) == 1) cout << 1;
  else cout << ( h * w + 1) / 2;
  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    //１人につき2d+1本の木を監視できる
    int a = n / (2*d + 1);
    int b = 0;
    if (n % (2*d + 1) != 0) {
      b = 1;
    }
    int c = a+b;
    System.out.println(c);
  }
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;


int n;
int f[61];

vector<ll> a;

ll basis[61];


void addVector(ll x) {
    for (int i=59; i>=0; i--) {
	if (!(x>>i&1)) continue;
	if (!basis[i]) {
	    basis[i] = x;
	    return;
	} else {
	    x ^= basis[i];
	}
    }
}

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

    cin>>n;
    a.resize(n);
    
    for (int i=0; i<n; i++) {
	ll x;
	cin>>x;
	for (int j=0; j<60; j++) {
	    if (x>>j&1) {
		f[j]++;
	    }
	}
	a[i] = x;
    }

    ll res = 0;
    ll mask = 0;
    for (int i=0; i<60; i++) {
	if (f[i]%2) {
	    res += (1ll<<i);
	} else {
	    mask |= (1ll<<i);
	}
    }

    // keep bits that occ even # of times.
    for (ll& x: a) {
	x &= mask;
	addVector(x);
    }


    // max xor subset
    ll mx = 0;
    for (int i=59; i>=0; i--) {
	if (!basis[i]) continue;
	if (mx>>i&1) continue;
	mx ^= basis[i];
    }

    res += (2ll*mx);

    cout<<res<<endl;    
    return 0;
}


Measured memory_bytes: 3908
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define dom 998244353
#define all(c) begin(c),end(c)
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
#define long long long
#define List vector
#define var auto
#define Count size()
#define Length size()
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

template <typename T, typename U>
struct LazySegTree {
	int n;
	function<T(T, T)> calc;
	function<T(T, U, int)> apply;
	function<U(U, U)> merge;
	T ex;
	vector<T> data;
	vector<U> lazy;
	vector<bool> is_lazy;
	LazySegTree(int n_, function<T(T, T)> calc,
		function<T(T, U, int)> apply,
		function<U(U, U)> merge,
		T ex){
		this->calc = calc;
		this->apply = apply;
		this->merge = merge;
		this->ex = ex;	
		init(n_);
	}
	void init(int n_) {
		n = 1;
		while (n < n_) n *= 2;
		data.clear();
		data.resize(2 * n - 1, ex);
		lazy.clear();
		lazy.resize(2 * n - 1, U());
		is_lazy.clear();
		is_lazy.resize(2 * n - 1, false);
	}
	void assign_lazy(int k, U x)
	{
		if (k >= (int)lazy.size()) return;
		if (is_lazy[k]) lazy[k] = merge(lazy[k], x);
		else
		{
			is_lazy[k] = true;
			lazy[k] = x;
		}
	}
	void eval(int len, int k) {
		if (!is_lazy[k]) return;
		assign_lazy(k * 2 + 1, lazy[k]);
		assign_lazy(k * 2 + 2, lazy[k]);
		data[k] = apply(data[k], lazy[k], len);
		is_lazy[k] = false;
	}
	T update(int a, int b, U x, int k, int l, int r) {
		eval(r - l, k);
		if (r <= a || b <= l) return data[k];
		if (a <= l && r <= b) {
			assign_lazy(k, x);
			return apply(data[k], lazy[k], r - l);
		}
		return data[k] = calc(update(a, b, x, k * 2 + 1, l, (l + r) / 2),
			update(a, b, x, k * 2 + 2, (l + r) / 2, r));
	}
	// [a, b]に対する閉区間更新 0-indexed
	T update(int a, int b, U x) {
		b++;
		return update(a, b, x, 0, 0, n);
	}
	T query(int a, int b, int k, int l, int r) {
		eval(r - l, k);
		if (r <= a || b <= l) return ex;
		if (a <= l && r <= b) return data[k];
		T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return calc(vl, vr);
	}
	// return node [a,b] 閉区間クエリ 0-indexed
	T query(int a, int b) {
		b++;
		return query(a, b, 0, 0, n);
	}

	//デバッグ用
	vector<T> items()
	{
		vector<T> ret(n);
		for (int i = 0; i < n; i++)
		{
			ret[i] = query(i, i);
		}
		return ret;
	}
};
//呼び出し方
//区間Add区間Sum


void solve()
{
	int N, Q;
	cin >> N >> Q;

	LazySegTree<int, int> raq(N,
		[](int a, int b) { return a + b; },
		[](int a, int b, int len) {return a + b * len; },
		[](int a, int b) {return a + b; },
		0);
	rep(i, Q)
	{
		int com;
		cin >> com;
		if (com == 0)
		{
			int s, t, x;
			cin >> s >> t >> x;
			s--; t--;
			raq.update(s, t, x);
		}
		else
		{
			int k;
			cin >> k;
			k--;
			cout << raq.query(k, k) << endl;
		}
	}
	//auto p = raq.items();
	//rep(i, p.size())
	//{
	//	cout << p[i] << " ";
	//}
}

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



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

int N, A, B;

int digit_sum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

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

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (A <= digit_sum(i) && digit_sum(i) <= B) {
            ans += i;
        }
    }

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


Measured memory_bytes: 256
S = input().strip()

stack = []
dc = 0
for s in S:
  if len(stack) == 0:
    stack.append(s)
  elif s == '0' and stack[-1] == '1':
    stack.pop()
    dc += 2
  elif s == '1' and stack[-1] == '0':
    stack.pop()
    dc += 2
  else:
    stack.append(s)
print(dc)

Measured memory_bytes: 3956
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let n;
    let ans;
    // init
    n = Number(input.shift());
    // solve
    ans = 0;
    for (var nx = 1; nx < n; nx++) {
        ans += Math.floor((n - 1) / nx);
    }
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 32652
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <set>
#include <map>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iterator>
#include <string.h>
#include <string>
#define debug() puts("what the fuck")
#define mem(x,y) memset(x,y,sizeof(x))
using namespace std;
const int INF= 0x3f3f3f3f;
const int MAXN= 1e6+10;
const int N=2e5+1;
const int mod=1e9+7;
double PI=3.1415926535898;
typedef long long ll;
/*int fastpow_mod(long long a,long long b)
{
    long long ans=1,base;
    if(a<0)
        base=(a+mod)%mod;
    else
        base=a%mod;
    while(b)
    {
        if(b&1!=0)
            ans=ans*base%mod;
        b=b>>1;
        base=base*base%mod;
    }
    return ans;
}*/
int main()
{
    int n,k,s,i;
    cin>>n>>k>>s;
    if(n==k)
    {
        for(i=0; i<n; ++i)
            cout<<s<<" ";
    }
    else
    {
        if(s%2==0)
        {
            for(i=0; i<=k; ++i)
                cout<<s/2<<" ";
            for( ; i<n; ++i)
            {
                if(s==2)
                    cout<<s+1<<" ";
                else
                    cout<<s-1<<" ";
            }
        }
        else
        {
            if(s==1)
            {
                for(i=0; i<k; ++i)
                    cout<<s<<" ";
                for(; i<n; ++i)
                    cout<<s+1<<" ";
            }
            else
            {
                for(i=0;i<=k;++i)
                {
                    if(i%2==0)
                        cout<<s/2<<" ";
                    else
                        cout<<s/2+1<<" ";
                }
                for(;i<n;++i)
                    cout<<s+1<<" ";
            }
        }
    }
    return 0;
}


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

int main(){
    int num[90001] = {};
    int a,b;
    cin >> a >> b;
    for(int i=1;i<90001;i++){
        std::string s;
        int j = 9999 + i;
        s = to_string(j);
        if(s[0] == s[4] && s[1] == s[3]){
            num[i] = num[i-1] + 1;
        }else{
            num[i] = num[i-1];
        }
    }
    cout << num[b-9999]-num[a-10000] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#ifndef LOCAL
struct ostdmy{template<class T>ostdmy&operator<<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>ostream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(const T&i:v)o<<i<<' ';return o;}
template<typename T>
T gcd(T a,T b){ // log N
    while((a%=b)&&(b%=a));
    return a|b;
}
template<typename T>
T lcm(T a,T b){
    return a/gcdl(a,b)*b;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int a,b,k;
    cin>>a>>b>>k;
    int g=gcd(a,b);
    int ans=g+1;
    while(k){
        if(!(g%--ans)){
            cerr<<ans<<endl;
            k--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define ITR(v, i) for(auto ite = v.begin(); ite != v.end(); ite++)
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k >> a >> b;
    if(b / k > (a - 1) / k)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
}

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

int main()
{
    int x, y;
    cin >> x >> y;
    if(y > 4 * x) cout << "No" << endl;
    else if(y < 2 * x) cout << "No" << endl;
    else if((y - 2 * x) % 2 == 0 && (4 * x - y) % 2 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

class Dijkstra {
  using QItem = pair<int, int>;

 public:
  vector<int> minDistance(vector<array<int, 3>> edges, int n, int src) {
    vector<int> costs(n, -1);
    costs[src] = 0;

    // 各ノードの隣接ノードとその距離を初期化
    vector<map<int, int>> distances(n);
    for (auto &edge : edges) {
      int n1 = edge[0], n2 = edge[1], d = edge[2];
      distances[n1][n2] = d;
      distances[n2][n1] = d;
    }

    vector<bool> used(n, false);
    priority_queue<QItem, vector<QItem>, greater<QItem>> q;
    q.push({0, src});

    while (!q.empty()) {
      // 未確定で，コストの一番低いノードを選択する
      auto [min_cost, min_idx] = q.top();
      q.pop();

      // 選択したノードは確定とする
      used[min_idx] = true;

      // 選択したノードの隣接ノードについて，そのコストを再計算する
      auto dist = distances[min_idx];
      for (auto p : dist) {
        int new_cost = min_cost + p.second;
        if (costs[p.first] < 0 || costs[p.first] > new_cost) {
          costs[p.first] = new_cost;
          q.push({new_cost, p.first});
        }
      }
    }

    return costs;
  }
};

int main(int argc, const char *argv[]) {
  int n, m, r;
  cin >> n >> m >> r;

  vector<int> vr(r);
  for (int i = 0; i < r; ++i) {
    cin >> vr[i];
    vr[i]--;
  }

  vector<array<int, 3>> edges(m);
  for (auto &e : edges) {
    cin >> e[0] >> e[1] >> e[2];
    e[0]--;
    e[1]--;
  }

  vector<vector<int>> costs(r);

  // costs[i][j]: vr[i]からjまで移動するときのコスト
  Dijkstra dijkstra;
  for (int i = 0; i < vr.size(); ++i) {
    costs[i] = dijkstra.minDistance(edges, n, vr[i]);
  }

  // 順番を全探索
  vector<int> order;
  for (int i = 0; i < r; ++i) {
    order.push_back(i);
  }

  int ans = -1;
  do {
    int cost_sum = 0;
    for (int i = 0; i < order.size() - 1; ++i) {
      cost_sum += costs[order[i]][vr[order[i + 1]]];
    }

    if (ans < 0 || cost_sum < ans) {
      ans = cost_sum;
    }
  } while (next_permutation(order.begin(), order.end()));

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 5660
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;
 
int N, Q;
int main() {
    while(cin >> N >> Q, N||Q){
        int num[101];
        for(int i=0; i<101; ++i) num[i]=0;
        for(int i=0; i<N; ++i){
            int M; cin >> M;
            for(int j=0; j<M; ++j){
                int a; cin >> a;
                num[a]++;
            }
        }
        bool ok=false;
        int maxV = 0;
        int ans=0;
        for(int i=0; i<101; ++i){
            if(num[i]>=Q){
                if(maxV<num[i]) {
                    ans = i;
                    maxV = num[i];
                }
                ok =true;
            }
        }
        if(!ok) cout << 0 << endl;
        else cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3040
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <bitset>
using namespace std;

#define ll long long int
#define pb push_back
#define FastIO cin.sync_with_stdio(false),cin.tie(NULL)
#define file freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)

ll max(ll a, ll b){
    if(a>b) return a;
    return b;}

ll min(ll a, ll b){
    if(a<b) return a;
    return b;}

const ll N = 1e6 + 5, INF = 1e18, MOD = 1e9 + 7, M = 6000;
int a[N], b[N];
bool c[N];
vector<int> prm;

void f(int n){
	int sq = sqrt(n);
	for(int i = 0; prm[i] <= sq; i++){
		if(n % prm[i] == 0){
			while(n % prm[i] == 0)n /= prm[i];
			b[ prm[i] ]++;
		}
	}
	if(n > 1)b[n]++;
}

int main(){
	FastIO;
	
	for(int i = 2; i < N; i++){
		if(!c[i]){
			for(int j = i; j < N; j+= i)c[j] = true;
			prm.pb(i);
		}
	}

	int n;
	cin >> n;

	int tp = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i)tp = __gcd(tp, a[i]);
		else tp = a[i];
	}

	for(int i = 0; i < n; i++)f(a[i]);

	if(*max_element(b, b+N) > 1 && tp == 1) cout << "setwise coprime";
	else if(tp == 1) cout << "pairwise coprime";
	else cout << "not coprime";


	return 0;
}




Measured memory_bytes: 12464
"""
難しい :(
"""

import sys
input = sys.stdin.readline
from functools import reduce
from fractions import gcd
from math import ceil

def is_same(A:list):
    exp = 0
    for i in range(len(A)):
        now = 0
        while A[i] % 2 == 0:
            A[i] >>= 1
            now += 1

        if i == 0:
            exp = now
            continue

        if exp != now:
            return False, exp
    
    return True, exp

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,M = map(int,input().split())
A = [int(i)//2 for i in input().split()]

flag, exp = is_same(A)
if not flag:
    print(0)
    exit()

power = 2 ** exp
MINX = lcm_list(A)

ans = (M+MINX*power) // (2*power*MINX)
print(ans)

Measured memory_bytes: 16244
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
  double n; cin>>n;
  reps(a,3500){
    reps(b,3500){
      // double c;
      ll x = n*a*b;
      ll y = 4*a*b - n*(a+b);
      if(y<=0) continue;
      ll c = x/y;
      if(c>0 && c*y==x) return cout<<a SP b SP c SP endl, 0;
      // c = 1.0*(double)n*(double)a*(double)b;
      // cerr << c<< endl;
      // c /= 4.0*(double)a*(double)n-1.0*(double)n*(double)((double)a+(double)b);
      // cerr << c << endl;
      // if(ceil(c)==floor(c)) return cout<<a SP b SP (int)c SP endl, 0;
    }
  }
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <sstream>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

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

int main() {
    ios::sync_with_stdio(false);

    int n;
    ll ans, a;
    bool big = false;
    bool zero = false;
    cin >> n;
    ans = 1;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a == 0) {
            zero = true;
            ans = 0;
            break;
        }
        if (big == false) {
            if (a > 1'000'000'000'000'000'000 / ans) {
                ans = -1;
                big = true;
            } else {
                ans *= a;
            }
        }
    }

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


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

const int nax = 4e3 + 5;
string s;
int r[nax], g[nax], b[nax];
int n;

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    fastRead;
    cin >> n;
    cin >> s;
    s = "#" + s;
    for (int i = 1; i <= n; i++){
        r[i] = r[i - 1];
        g[i] = g[i - 1];
        b[i] = b[i - 1];
        if (s[i] == 'R')        r[i]++;
        else if (s[i] == 'G')   g[i]++;
        else                    b[i]++;
    }
    ll res = 0;
    for (int i = 1; i <= n; i++){
        for (int j = i + 1; j <= n; j++){
            if (s[i] == s[j])   continue;
            ll cnt = 0;
            if (s[i] == 'R' && s[j] == 'G' || s[i] == 'G' && s[j] == 'R'){
                cnt = b[n] - b[j];
                if (j + (j - i) <= n && s[j + (j - i)] == 'B')  cnt--;
            }
            else if (s[i] == 'R' && s[j] == 'B' || s[i] == 'B' && s[j] == 'R'){
                cnt = g[n] - g[j];
                if (j + (j - i) <= n && s[j + (j - i)] == 'G')  cnt--;
            }
            else{
                cnt = r[n] - r[j];
                if (j + (j - i) <= n && s[j + (j - i)] == 'R')  cnt--;
            }
            res += cnt;
        }
    }
    cout << res << endl;
    return 0;
}




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

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

  vector<int> H(N, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &H.at(i));
  }

  int ans = 0;
  int count = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H.at(i) >= H.at(i + 1)) {
      count++;
      ans = max(ans, count);
    } else {
      count = 0;
    }
  }

  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vl b(n);
    ll j = 0;
    for(ll i = n-1; i >= 0; i -= 2) {
        b[j] = a[i];
        j++;
    }
    if(n%2 == 1) {
        for(ll i = 1; i < n; i += 2) {
            b[j] = a[i];
            j++;
        }
    }
    else {
        for(ll i = 0; i < n; i += 2) {
            b[j] = a[i];
            j++;
        }
    }
    
    rep(i, n) {
        cout << b[i] << " ";
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 5248
#include <stdio.h>

int n,A[50];

int fanc(int i, int m){
	/*数列から二つを選ぶ*/
	int num;
	if(m==0) return 1;
	if(i >= n) return 0;
	num = fanc(i+1,m)||fanc(i+1, m-A[i]);
	return num;
}

int main(){
	int q,M,i;
	scanf("%d",&n);
	for(i=0; i<n; i++)scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0; i<q; i++){
		scanf("%d",&M);
		if(fanc(0,M))printf("yes\n");
		else printf("no\n");
	}
	
	return 0;
}



Measured memory_bytes: 2080
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	sc.Scan()
	s := sc.Text()

	// loop until no non-preceded ))))
	lc := 0
	ur := 0
	for _, r := range s {
		if r == '(' {
			lc++
		}
		if r == ')' {
			if lc == 0 {
				ur++
			} else {
				lc--
			}
		}
	}
	for i := 0; i < ur; i++ {
		s = "(" + s
	}
	lc = 0
	for _, r := range s {
		if r == '(' {
			lc++
		}
		if r == ')' {
			lc--
		}
	}
	for i := 0; i < lc; i++ {
		s = s + ")"
	}

	fmt.Println(s)

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back

#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const double pi=acos(-1);
const int N=1e4+10;
int a[N],n,m;
void solve()
{
    cin>>m>>n;
    int sum=0;
    rep(i,1,n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int ans=m-sum;
    ans=max(-1,ans);
    cout<<ans<<endl;
}
int main()
{
	//int _;cin>>_;while(_--)
	solve();
}


Measured memory_bytes: 3624
n = int(input())
ary = list(map(int, input().split()))
#print(n,ary)

ary_2 = [ary[0]]
for i in range(1, n):
    ary_2.append(ary[i] + ary_2[i-1])
ary_2 = [0] + ary_2
#print(ary_2)

from collections import Counter #総当たり二重ループでは'TLE'
c = Counter(ary_2)
v = (c.values())
#print(v)

ans = 0
for j in v:
    if j > 1:
        ans += j * (j-1) // 2 # 'J'個から'2'個選ぶ場合の数_combination, 重複無し

print(ans)


Measured memory_bytes: 44408
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


template<typename T>
struct BIT {
	int n;
	vector<T>dat;
	BIT(int n = 0) {
		initialize(n);
	}
	void initialize(int temp) {
		n = temp;
		dat.resize(n);
		rep(i, 0, n)dat[i] = 0;
	}
	T sum(int i) {
		T s = 0;
		while (i >= 0) {
			s += dat[i];
			i = (i & (i + 1)) - 1;
		}
		return s;
	}
	T sum_between(int i, int j) {
		if (i > j)return 0;
		return sum(j) - sum(i - 1);
	}
	void plus(int i, T x) {
		while (i < n) {
			dat[i] += x;
			i |= i + 1;
		}
	}
	int lower_bound(T x) {
		if (sum(n - 1) < x)return -1;
		else if (sum(0) >= x)return 0;
		int ng = 0, ok = n - 1;
		while (ok - ng > 1) {
			int mid = (ok + ng) / 2;
			if (sum(mid) >= x)ok = mid;
			else ng = mid;
		}
		return ok;
	}
};

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


	ll N;
	cin >> N;
	vector<ll>a;
	a.resize(N);
	set<ll>li;
	vector<ll>adic;

	ll ma = -1;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		if (a[i] > ma) {
			li.insert(i);
			ma = a[i];
		}
		adic.pb(a[i]);
	}
	sort(all(adic));
	adic.erase(unique(all(adic)),adic.end());
	


	ll sz = adic.size();
	BIT<ll>bit(sz);
	BIT<ll>bitsum(sz);
	vector<ll>ans(N);
	for (int i = N-1; i >= 0;i--){
		ll idx = lower_bound(all(adic), a[i]) - adic.begin();
		bit.plus(idx,1);
		bitsum.plus(idx,a[i]);
		if (li.count(i)) {
			li.erase(i);
			if (li.size()) {
				ll idx1 = lower_bound(all(adic), a[i]) - adic.begin();
				auto itr = li.end();
				itr--;
				ll idx2 = lower_bound(all(adic),a[*itr]) - adic.begin();
				ans[i] += (bit.sum_between(idx1,sz-1))*(a[i]-a[*itr]);
				ans[i] += bitsum.sum_between(idx2,idx1-1)-bit.sum_between(idx2,idx1-1)*a[*itr];
			}
			else {
				ll idx1 = lower_bound(all(adic), a[i]) - adic.begin();
				ans[i] += (bit.sum_between(idx1, sz - 1))*a[i];
				ans[i] += bitsum.sum_between(0, idx1 - 1);
			}
		}
	}


	for (int i = 0; i < N; i++)puts(ans[i]);


	return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> input(h);
  vector<vector<int>> a(h, vector<int>(w));
  queue<pair<int, int>> q; // bfs 用
  for (int i=0; i<h; i++) {
    cin >> input[i];
    for (int j=0; j<w; j++) {
      if (input[i][j] == '#') { // 入力で # の箇所の初期値を 1 に
        a[i][j] = 1;
        q.push({i, j});
      } else { // それ以外の初期値を 0 に
        a[i][j] = 0;
      }
    }
  }

  int cnt = 1;
  while (!q.empty()) { // 幅優先探索 最大でh * w 個のセルを探索
    auto p = q.front();
    q.pop();

    //      y1
    // x1 [x, y] x2
    //      y2
    int y = p.first, x = p.second;
    // cout << y << " " << x << endl;
    int y1 = y - 1, y2 = y + 1;
    int x1 = x - 1, x2 = x + 1;

    // cout << "a[x][y]: " << a[x][y] << endl;

    if (y1 >= 0 && y1 < h && a[y1][x] == 0) {
      a[y1][x] = a[y][x] + 1;
      q.push({y1, x});
      cnt = max(cnt, a[y1][x]);
    }
    if (y2 >= 0 && y2 < h && a[y2][x] == 0) {
      a[y2][x] = a[y][x] + 1;
      q.push({y2, x});
      cnt = max(cnt, a[y2][x]);
    }
    if (x1 >= 0 && x1 < w && a[y][x1] == 0) {
      a[y][x1] = a[y][x] + 1;
      q.push({y, x1});
      cnt = max(cnt, a[y][x1]);
    }
    if (x2 >= 0 && x2 < w && a[y][x2] == 0) {
      a[y][x2] = a[y][x] + 1;
      q.push({y, x2});
      cnt = max(cnt, a[y][x2]);
    }
  }

  cout << cnt - 1 << endl;

  return 0;
}


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

typedef long long ll;

int main(){
  int n; cin >> n;
  ll a[n];
  ll s=0;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    s += a[i];
  }

  ll snuke=0, arai;
  ll ans = 1e11;
  for(int i=0; i<n-1; i++){
    snuke += a[i];
    ans = min(ans, abs(snuke-(s-snuke)));
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int d, k;
    cin >> d >> k;
    d = pow(100, d);
    if(k == 100) k = 101;

    cout << d*k << endl;
}



Measured memory_bytes: 256