akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void PrintVector(const vector<int> &vec)
{
    for (auto val : vec)
        cout << val << " ";
    cout << endl;
}

int main()
{
    int n; cin >> n;
    vector<int> p(n), q(n), o(n);
    rep(i, n) cin >> o[i];
    rep(i, n) cin >> q[i];

    p = o;
    sort(o.begin(), o.end());
    int a = 0, b = 0, cnt = 0;
    do {
        cnt++;
        if (p == o) a = cnt;
        if (q == o) b = cnt;
    } while (next_permutation(o.begin(), o.end()));

    cout << abs(a - b) << endl;
}

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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int sy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

ll solve(ll a) {
	ll sum = 1;
	for (int i = 2; i <= a; i++) {
		sum *= i;
		sum %= atcoder;
	}
	return sum;
}

ll a[100010];

int main(){

	int n;
	int a0 = 0, a1=0, a2=0;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (a[i] % 4 == 0) {
			a2++;
		}
		else if (a[i] % 2 == 0) {
			a1++;
		}
		else {
			a0++;
		}
	}
	if (a1==0 && a0-1 <= a2)pr("Yes");
	else if(a0 <= a2)pr("Yes");
	else pr("No");

	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <unordered_map>

const int MOD = pow(10,9)+7;
typedef long long ll;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



ll solve(vector<ll> csum, ll N, ll sig){
    
    ll cumOper = 0;
    
    ll sign = sig;
    ll count = 0;
    
    
    ll signi;
    
    for(auto i = 0; i < N; i++){
        
        
        if( (csum[i]+cumOper) == 0){
            count++;
            cumOper -= sign;
        }
        
        signi = (csum[i]+cumOper)/abs(csum[i]+cumOper);
        
        if (signi!= sign) {
            sign = signi;
            continue;
        }
        
        ///  csum[i]+cumOperを (-sign)にする。
        
        
        /// sign = 1のとき、csum[i]+cumOper > 0なので、 -1になるまで減らす。
        /// sign = -1のとき、csum[i]+cumOper < 0なので、+1になるまで増やす
        
        if (sign == 1){
            count +=(csum[i] + cumOper + 1);
            cumOper += (-1) * (csum[i] + cumOper + 1);
        }else{
            count +=  (-(csum[i] + cumOper) + 1);
            cumOper += (1) * (-(csum[i] + cumOper) + 1);
        }
        
        sign = -sign;
    }
    
    return count;
}




int main() {

    ll N = lin(); ll T = lin();
    
    vector<ll> ts;
    
    for(auto i = 0; i<N; i++){
        ts.push_back(lin());
    }
    
    ll ans = 0;
    ll pre = ts[0];
    for(auto it = ts.begin()++; it != ts.end(); it++){
        
        if (*it < pre + T){
            ans += *it -pre;
        }else{
            ans +=T;
        }
        
        pre = *it;
        
    }
    cout << ans + T << endl;
    
    return 0;
    
    
}







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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

inline void readChar(char &c) {
	for (c = getchar(); c != '.' && c != '#'; c = getchar());
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 2e3;
int n, m, ans;
vector<int> rol[MAXN + 5], col[MAXN + 5];
char s[MAXN + 5][MAXN + 5];

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) {
		rol[i].push_back(0);
		rol[i].push_back(m + 1);
	}
	for (int i = 1; i <= m; ++i) {
		col[i].push_back(0);
		col[i].push_back(n + 1);
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j) {
			readChar(s[i][j]);
			if (s[i][j] == '#') {
				rol[i].push_back(j);
				col[j].push_back(i);
			}
		}
	for (int i = 1; i <= n; ++i) sort(rol[i].begin(), rol[i].end());
	for (int i = 1; i <= m; ++i) sort(col[i].begin(), col[i].end());
	for (int i = 1; i <= n; ++i) {
		for (int sum, j = 1; j <= m; ++j) {
			if (s[i][j] == '#') continue;
			sum = *upper_bound(rol[i].begin(), rol[i].end(), j) - 
			*(upper_bound(rol[i].begin(), rol[i].end(), j) - 1) + 
			*upper_bound(col[j].begin(), col[j].end(), i) - 
			*(upper_bound(col[j].begin(), col[j].end(), i) - 1) - 3;
			ans = max(ans, sum);
		}
	}
	write(ans);
	putchar('\n');
	return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=a;i<10000000;i+=a){
		if(i%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#define MaxN 200005
using namespace std;

vector<vector<int> > g(MaxN);
vector<int> vis(MaxN,0);
int temp = 0;
void dfs(int node)
{
    vis[node] =1;
    temp++;
    for(auto nxt : g[node])
    {
        if(!vis[nxt])
            dfs(nxt);
    }
}
int main()
{
    set<pair<int,int> > edg;
    int n,m;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int u,v;
        cin >> u >> v;
        if(edg.find({u,v}) == edg.end() &&
                edg.find({v,u}) == edg.end() )
        {
            g[u].push_back(v);
            g[v].push_back(u);
            edg.insert({u,v});
        }
    }

    int ans = 0;
    for(int i  =1; i<= n;i++)
    {
        temp = 0;
        if(!vis[i])
            dfs(i);
        ans = max(temp,ans);
    }

    cout << ans << endl;
    
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

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

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

int x[100];
int y[100];
ll h[100];

ll calch(int cx, int cy, int x, int y, ll h) {
    ll tmp = abs(x - cx) + abs(y - cy);
    return h + tmp;
}

int main(){
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    
    REP(i, N) {
        cin >> x[i] >> y[i] >> h[i];
    }
    
    REP(i, 101) REP(j, 101) {
        ll H_ans = 0;
        bool isAns = true;
        // 高さが0ではない
        REP(k, N) {
            if (h[k] == 0) continue;
            ll htmp = calch(i, j, x[k], y[k], h[k]);
            if (H_ans == 0) {
                H_ans = htmp;
            } else {
                if (H_ans != htmp) {
                    isAns = false;
                    break;
                }
            }
        }
        if (!isAns) continue;
        // 高さが0
        REP(k, N) {
            if (h[k] != 0) continue;
            if (H_ans > calch(i, j, x[k], y[k], h[k])) {
                isAns = false;
                break;
            }
        }
        
        if (isAns) {
            cout << i << " " << j << " " << H_ans << endl;
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 2000
#define inf 9999999
#define NIL -1 

int G[N][N], n, w[N][N];

void prim(){

  int a, i, j, u, v, color[N], d[N], pi[N], mincost;
  
  for(u = 0 ; u < n ; u++){
    d[u] = inf;
    pi[u] = NIL;
    color[u] = 1;
  }
  d[0]=0;
  while(1){
    mincost = inf;
    for(i = 0 ; i < n ; i++){
      if(color[i] != 2 && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == inf){
      break;
    }
    color[u] = 2;
    for(v = 0 ; v < n ; v++){
      if(color[v] != 2 && G[u][v] < d[v] && G[u][v] != -1){
	pi[v] = u;
	d[v] = G[u][v];
      }
    }
  }
  a = 0;
  for(i = 0 ; i < n ; i++){
    a += G[i][pi[i]];
  }
  printf("%d\n", a);
}

int main(){

  int i, j;

  scanf("%d", &n);
  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      scanf("%d", &G[i][j]);
    }
  }

  prim();
  
  return 0;
}

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

int main()
{
	string days[]={
		"Mon",
		"Tues",
		"Wednes",
		"Thurs",
		"Fri",
		"Satur",
		"Sun"
	};
	int cal[12][31]={{0}};
	int today=3;
	for (int i=0; i<12; i++) {
		for (int j=0; j<31; j++) {
			cal[i][j]=today;
			++today%=7;
			if (i==3 || i== 5 || i==8 || i==10) {
				if (j==29) {
					break;
				}
			}
			else if (i==1) {
				if (j==28) {
					break;
				}
			}
		}
	}
	int a,b;
	for (cin >> a >> b; a; cin >> a >> b) {
		cout << days[cal[a-1][b-1]] << "day" << endl;
	}	
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
int dp[100][4][4][4];
int mod = 1E9+7;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N;
	cin >> N;
	dp[0][3][3][3] = 1;
	for (int len = 0; len < N; len++) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				for (int k = 0; k < 4; k++) {
					if (dp[len][i][j][k] == 0) continue;
					for (int m = 0; m < 4; m++) {
						if (m == 2 && i == 1 && j == 0) continue;
						if (m == 2 && i == 0 && j == 1) continue;
						if (m == 1 && i == 2 && j == 0) continue;
						if (m == 2 && i == 1 && k == 0) continue;
						if (m == 2 && j == 1 && k == 0) continue;
						dp[len + 1][m][i][j] += dp[len][i][j][k];
						dp[len + 1][m][i][j] %= mod;
					}
				}
			}
		}
	}
	int res = 0;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				res += dp[N][i][j][k];
				res %= mod;
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
n=int(input())
E=[0]*n
for _ in range(n):
    u,k,*V=map(int,input().split())
    E[u-1]=sorted(V)[::-1]
todo=[1]
seen=[0]*n
d=[0]*n
f=[0]*n
t=0
while 0 in f:
    if not todo:
        todo.append(seen.index(0)+1)    
    if seen[todo[-1]-1]==0:
        seen[todo[-1]-1]=1
        t+=1
        d[todo[-1]-1]=t
        for v in E[todo[-1]-1]:
            if d[v-1]==0:
                todo.append(v)
    elif f[todo[-1]-1]==0:
        t+=1
        f[todo.pop()-1]=t
    else:
        todo.pop()
for i in range(n):
    print(i+1,d[i],f[i])


Measured memory_bytes: 5648
//#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
double dist(double x1,double y1,double x2,double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main(){
	int N,K;
	double x[334],y[334],c[334];
	scan(N>>K);
	rep(i,N){
		scan(x[i]>>y[i]>>c[i]);
	}
	if(K==1){
		prin(0);
		return 0;
	}
	double Tmin=0,Tmax=1e+6;
	while(Tmax-Tmin>eps){
		double Tmid=(Tmax+Tmin)/2;
		double r[334];
		rep(i,N) r[i]=Tmid/c[i];
		int maxkaburi=1;
		rep(i,N){
			rep(j,N){
				if(i==j) continue;
				double d=dist(x[i],y[i],x[j],y[j]);
				if(d>r[i]+r[j]) continue;
				double asi=(d*d+r[i]*r[i]-r[j]*r[j])/2/d;
				double h=sqrt(r[i]*r[i]-asi*asi);
				double vecx=(double)(x[j]-x[i]),vecy=(double)(y[j]-y[i]);
				double asix=x[i]+asi*vecx/sqrt(vecx*vecx+vecy*vecy),asiy=y[i]+asi*vecy/sqrt(vecx*vecx+vecy*vecy);
				double hvecx=h*vecy/sqrt(vecx*vecx+vecy*vecy),hvecy=-h*vecx/sqrt(vecx*vecx+vecy*vecy);
				double p[2],q[2];
				p[0]=asix+hvecx,q[0]=asiy+hvecy;
				p[1]=asix-hvecx,q[1]=asiy-hvecy;
				rep(s,2){
					int kaburi=2;
					rep(k,N){
						if(k==i||k==j) continue;
						if(dist(x[k],y[k],p[s],q[s])<=r[k]){
							kaburi++;
						}
					}
					maxkaburi=max(maxkaburi,kaburi);
				}
			}
		}
		rep(i,N){
			int kaburi=1;
			rep(j,N){
				if(i==j) continue;
				if(dist(x[i],y[i],x[j],y[j])<=r[j]) kaburi++;
			}
			maxkaburi=max(maxkaburi,kaburi);
		}
		debug(Tmid,maxkaburi);
		if(maxkaburi>=K) Tmax=Tmid;
		else Tmin=Tmid;
	}
	prin(setprecision(11)<<Tmin);
	return 0;
}


Measured memory_bytes: 384
n, *L = map(int, open(0).read().split())

# dp = [float("inf")] * n
dp = [0] * n

for i in range(1, n):
    j = max(0, i - 2)
    e = L[i]
    dp[i] = min([DP + abs(e - COST) for DP, COST in zip(dp[j:i], L[j:i])])

print(dp[-1])


Measured memory_bytes: 13876
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    ll H;
    cin >> H;

    vector<ll> v = {0, 1, H};

    while(v[2] > 0){
        v[0] += v[1];
        v[1] *= 2;
        v[2] /= 2;
    }

    cout << v[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  vector<int> l(n);
  for(int i=0; i<n; i++) cin>>l.at(i);
  sort(l.begin(), l.end());
  int a=0;
  for(int i=0; i<n-1; i++)
    a+=l.at(i);
  if(l.at(n-1) < a)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int K, T;
int a[105];

int main(void)
{
	cin >> K >> T;
	for(int i = 0; i < T; i++) cin >> a[i];
	sort(a, a+T);
	reverse(a, a+T);
	
	if(T == 1){
		cout << a[0]-1 << endl;
		return 0;
	}
	if(T == 2){
		cout << max(0, a[0] - a[1] - 1) << endl;
		return 0;
	}
	
	int sum = 0;
	for(int i = 2; i < T; i++) sum += a[i];
	cout << max(0, a[0] - a[1] - sum - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#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(){
    int n, m;
    cin >> n >> m;
    vector<P> ab;
    rep(i, n){
        int a, b;
        cin >> a >>b;
        ab.push_back(P(a,b));
    }
    sort(ab.begin(), ab.end());
    priority_queue<int> can;
    int j = 0;
    int ans = 0;
    for(int i = 1; i<m+1; i++){
        while(j<n){
            if(ab[j].first<=i){
                can.push(ab[j].second);
                j++;
                continue;
            }else break;
        }
        if(!can.empty()){
            ans += can.top();
            can.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4744
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

#define INF (1<<29)
#define INFL (1ll<<60)
#define EPS (1e-8)
#define PI (acos(-1))
#define MOD 1000000007ll

template<class A, class B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<class A, class B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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

ll n, a, b;
ll x[100000];

int main() {
	cin >> n >> a >> b;
	REP(i, n) scanf("%lld", &x[i]);
	
	ll ans = 0;
	FOR(i, 1, n) {
		ans += min((x[i] - x[i - 1]) * a, b);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<string>
#include<vector>
using namespace std;

int main() {
	int n;cin>>n;
	string s;cin>>s;
	vector<int> b(n+1),r(n+1),g(n+1);
	b[0]=0;
	r[0]=0;
	g[0]=0;
	for(int i=0;i<n;i++){
		if(s[i]=='B'){
			b[i+1]=1;
		}else{
			b[i+1]=0;
		}
		if(s[i]=='R'){
			r[i+1]=1;
		}else{
			r[i+1]=0;
		}
		if(s[i]=='G'){
			g[i+1]=1;
		}else{
			g[i+1]=0;
		}
	}
	for(int i=1;i<=n;i++){
		b[i]+=b[i-1];
		r[i]+=r[i-1];
		g[i]+=g[i-1];
	}
	long long ans=0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			if(((s[i]=='R')*(s[j]=='G'))+((s[i]=='G')*(s[j]=='R'))){
				ans+=b[n]-b[j+1];
				if(j+j-i<n){
					if(s[j+j-i]=='B'){
						ans--;
					}
				}
			}else if(((s[i]=='B')*(s[j]=='G'))+((s[i]=='G')*(s[j]=='B'))){
				ans+=r[n]-r[j+1];
				if(j+j-i<n){
					if(s[j+j-i]=='R'){
						ans--;
					}
				}
			}else if(((s[i]=='R')*(s[j]=='B'))+((s[i]=='B')*(s[j]=='R'))){
				ans+=g[n]-g[j+1];
				if(j+j-i<n){
					if(s[j+j-i]=='G'){
						ans--;
					}
				}
			}


//			cout<<i<<' '<<j<<endl;
//			cout<<ans<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
/* created   : 2019-10-27 23:09:49
 * accepted  : 2019-10-27 23:09:49
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mt make_tuple
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n; cin >> n;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == n) {
        cout << "Yes" << '\n';
        return;
      }
    }
  }
  cout << "No" << '\n';
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n;

    scanf("%d", &n);

    int H[n];
    int count = 0, max = 0;
    for(int i = 0; i < n; i++){
        scanf("%d", &H[i]);

        if(H[i-1] >= H[i]){
          count++;
        } else {
            if(max < count){
                max = count;
            }
            count = 0;
        }
    }
	if(max < count){
      max = count;
    }
    printf("%d", max);
}


Measured memory_bytes: 512
h,w = gets.chomp.split.map &:to_i
c = []
a = []
10.times{ c << gets.chomp.split.map(&:to_i) }
h.times{ a << gets.chomp.split.map(&:to_i) }

10.times do |k|
  10.times do |i|
    10.times do |j|
      c[i][j] = [c[i][j], c[i][k] + c[k][j]].min
    end
  end
end

need_change = a.flatten.select{|v| v != 1 && v != -1}
if need_change.empty?
  p 0
else
  p need_change.map{|v| c[v][1]}.inject(:+)
end


Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef int64_t lint;
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;

int main() {
	int N;
	cin >> N;
	if (N%2 == 0) {
		std::cout << "-1" << '\n';
		return 0;
	}
	int a=7, b=1, c=0, x, y, z;
	rep(i, N) {
		if (a % N == 0) {
			std::cout << b << '\n';
			return 0;
		}
		a *= 10;
		a += 7;
		a %= N;
		b++;
	}
	std::cout << "-1" << '\n';
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main() {
  unsigned short *A,*B;
  
  int C[VMAX + 1];
  int n,i,j;
  scanf("%d",&n);
  
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);
  
  for(i=0;i<=VMAX;++i)C[i]=0;
  
  for(i=0;i<n;++i){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  
  for(i=1;i<=VMAX;++i)C[i]=C[i]+C[i-1];
  
  for(j=1;j<=n;++j){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  
  
  return 0;
}

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

#define pb push_back

void solve(){
 ll sx,sy,tx,ty; 
 cin>>sx>>sy>>tx>>ty;

 ll dx=tx-sx;
 ll dy=ty-sy;
 string s1,s2;
 for(int i=0;i<dy;i++){
    s1+='U';
    s2+='D';
 } 
 for(int i=0;i<dx;i++)
{
  s1+='R';
  s2+='L';
}
string f1= "LU"+s1+"RD";
string f2="RD"+s2+"LU";
cout<<s1+s2+f1+f2<<endl;
}


int main() {
   #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

 ios_base::sync_with_stdio(0);
 cin.tie(0);

int t=1 ;  while(t--)
 solve();

return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
 
 
int main() {
	string s,t;
	cin>>s>>t;
	int c=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
		{
			c++;
		}	
	}	
 	if(c==0)
	{
		cout<<"Yes"<<endl;
	}	
	else
	{
		cout<<"No"<<endl;	
	}	
}

Measured memory_bytes: 3620
s = raw_input()
ss = s.split()
d = int(ss[0])
n = int(ss[1])
i = 1
while 1:
	x = i
	c = 0
	while x % 100 == 0:
		x //= 100
		c += 1
	if c == d:
		n -= 1
		if n == 0:
			print i
			break
	i += 1


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

//temmplate------
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define INF 1e9
#define ZERO(a) memset(a, 0, sizeof(a))
typedef long long lint;
//------template

int main(){
    int N;
    cin >> N;
    int P[N];
    REP(i,N){
        cin >> P[i];
    }
    int min = N;
    int count = 0;
    REP (i,N){
        if (P[i] <= min){
            count += 1;
            min = P[i];
            //cout << min << " " << P[i] << "\n";
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 1024
def shred str, pattern
    arr, add = [], ""
    pattern.length.times{|i|
        add += str[i]
        if pattern[i] == "1"
            arr << add
            add = ""
        end
    }
    add += str[-1] if str.length > 1
    arr << add
    arr
end

while true
    target, paper = gets.chomp.split
    break if [target, paper] == ["0", "0"]

    target = target.to_i
    max = Hash.new{|h, k| h[k] = []}
    (2 ** (paper.length - 1)).times{|i|
        pattern = sprintf("%0#{paper.length - 1}b", i)
        numbers = shred(paper, pattern)
        sum = numbers.map(&:to_i).inject(:+)
        max[sum] << numbers if sum <= target
    }
    first = max.to_a.sort_by!{|k, v| -k}[0]
    answer = nil
    if first.nil?
        answer = "error"
    elsif first[1].length > 1
        answer = "rejected"
    else
        answer = "#{first[0]} " + first[1].join(" ")
    end
    puts answer
end


Measured memory_bytes: 6860
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    vector<ll> x(3);
    for (ll i = 0; i < 3; i++) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    if (x[0] == 5 && x[1] == 5 && x[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

std::string is_shiritori(std::vector<std::string> v_str) {
  for (int i = 0; i < v_str.size() - 1; i++) {
    if (v_str[i].back() != v_str[i+1][0]) {
      return std::string("No");
    }
  }

  std::sort(v_str.begin(), v_str.end());
  auto it = std::unique(v_str.begin(), v_str.end());
  std::string result = it == v_str.end() ? "Yes" : "No";
  return result;
}

int main(int argc, char *argv[]) {
  int num;
  std::cin >> num;
  int j = 0;
  std::vector<std::string> v_str;
  std::string _str;

  while (j < num) {
    std::cin >> _str;
    v_str.push_back(_str);
    j++;
  }

  std::cout << is_shiritori(v_str) << "\n";
  return 0;
}


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

using namespace std;

int main(){
    int a,b,m;
    cin>>a>>b>>m;
    vector<int> reizo(a);
    vector<int> densi(b);
    int ans=99999999;
    
    for(int i=0;i<a;i++) cin>>reizo.at(i);
    for(int i=0;i<b;i++) cin>>densi.at(i);
    
    for(int i=0;i<m;i++){
        int x,y,c;
        cin>>x>>y>>c;
        ans=min(ans,reizo.at(x-1)+densi.at(y-1)-c);
    }
    
    sort(reizo.begin(),reizo.end());
    sort(densi.begin(),densi.end());
    
    cout<<min(ans,reizo.at(0)+densi.at(0))<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int a,b,i;
  a=100000;
  scanf("%d",&b);
  for(i=0;i<b;i++){
    a*=1.05;
    a+=999;
    a/=1000;
    a*=1000;
  }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            //var exStdIn = new System.IO.StreamReader("stdin.txt");
            //System.Console.SetIn(exStdIn);

            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int d = int.Parse(input[1]);
            // 1 3   2  5   3  
            int cp = d * 2 + 1;

            int count = n / cp;
            int amari = n % cp;
            if (amari == 0)
            {
                Console.WriteLine(count.ToString());
            }
            else
            {
                Console.WriteLine((count+1).ToString());
            }

        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
const int Mod=1000000007;
int a[200005];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    int res=1;
    if(a[n]<0)
    {
        if(k&1)for(int i=n-k+1;i<=n;i++)
            res=1LL*res*a[i]%Mod;
        else for(int i=1;i<=k;i++)
            res=1LL*res*a[i]%Mod;
    }
    else
    {
        int l=1,r=n;
        if(k&1)res=1LL*res*a[r]%Mod,r--,k--;
        while(k)
        {
            if(1LL*a[l]*a[l+1]>1LL*a[r]*a[r-1])
                res=1LL*res*a[l]%Mod*a[l+1]%Mod,l+=2;
            else res=1LL*res*a[r]%Mod*a[r-1]%Mod,r-=2;
            k-=2;
        }
    }
    res=(res+Mod)%Mod;
    return 0*printf("%d\n",res);
}


Measured memory_bytes: 4536
import java.util.Scanner;

public class Main {

    static char[] c;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        c = S.toCharArray();
        long count = 0, tempCount;
        for(int j=0;j<N;j++){
            tempCount = 0;
            switch (c[j]){
                case 'R':
                    tempCount = findNumOf(j, 'G', true) * findNumOf(j, 'B', false);
                    tempCount += findNumOf(j, 'B', true) * findNumOf(j, 'G', false);
                    tempCount -= findEqualDest(j, 'R');
                    break;
                case 'G':
                    tempCount = findNumOf(j, 'R', true) * findNumOf(j, 'B', false);
                    tempCount += findNumOf(j, 'B', true) * findNumOf(j, 'R', false);
                    tempCount -= findEqualDest(j, 'G');
                    break;
                case 'B':
                    tempCount = findNumOf(j, 'G', true) * findNumOf(j, 'R', false);
                    tempCount += findNumOf(j, 'R', true) * findNumOf(j, 'G', false);
                    tempCount -= findEqualDest(j, 'B');
                    break;
            }
            count += tempCount;
        }
        System.out.println(count);
    }

    static long findNumOf(int endIndex, char toFind, boolean left){      //left=trueなら左側、falseなら右側を探索
        long count = 0;
        if(left){
            for (int i=0;i<endIndex;i++){
                if(c[i] == toFind){
                    count++;
                }
            }
        }else{
            for (int i=endIndex+1, n=c.length;i<n;i++){
                if(c[i] == toFind){
                    count++;
                }
            }
        }
        return count;
    }

    static int findEqualDest(int index, char cExcept){    //i==j&&j==kになる組の数。たかだかc.length/2しかないのでintでOK
        int count = 0;
        for(int i=1, n=c.length;i<n;i++){
            if(index-i < 0 || index+i >= n){
                break;
            }
            if(c[index-i] != cExcept && c[index+i] != cExcept && c[index-i] != c[index+i]){
                count++;
            }
        }
        return count;
    }
}


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


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

    if(r<1200) cout<<"ABC"<<endl;
    else if(r<2800) cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;


    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return int(input())
from collections import defaultdict

n = SI()
print(180*(n-2))

Measured memory_bytes: 3572
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def S(): return input()


def main():
    a = LI()
    if sum(a)  == max(a)*2:
        return 'Yes'
    return 'No'


print(main())


Measured memory_bytes: 6976
#include<stdio.h>

int main(void)
{

    int n, i, max, min;
    long int sum=0;
    int box[10000];
    

    scanf("%d", &n);
    for (i = 0; i < n; i++)scanf("%d", &box[i]);

    max = box[0];
    min = box[0];

    for (i = 0; i < n; i++) {
        if (box[i] >= max) max = box[i];
        if (box[i] <= min) min = box[i];
        sum += box[i];
    }

    printf("%d %d %ld\n", min, max, sum);

    return 0;
}


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

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

int main() {
	string  S;
	cin >> S;
	string ans="Yes";
	rep(i, S.length()/2) {
		if(S[i]!=S[S.length()-i-1])ans = "No";
	}
	rep(i, S.length() / 4) {
		if (S[i] != S[S.length()/2 - i-1])ans = "No";
	}
	if (S.length()<6) {ans="No";	}
	
	if (S.length() ==3) { ans = "Yes"; }

     cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    int total = 100 * r + 10 * g + b;
    if (total % 4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

class edge {
public:
  int to, cost;
  edge(int a, int b) {to = a, cost = b;}; 
};

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

  ll V, E; cin >> V >> E;
  vector<edge> G[V];
  for (ll i = 0; i < E; i++) {
    ll s, t, w; cin >> s >> t >> w;
    G[s].emplace_back(edge(t, w));
    G[t].emplace_back(edge(s, w));
  }

  ll ans = 0;
  vector<bool> used(V);
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;
  q.push(make_pair(0, 0));

  while (!q.empty()) {
    pair<ll, ll> p = q.top(); q.pop();
    if (used[p.second]) continue;
    used[p.second] = true;
    ans += p.first;

    for (auto n: G[p.second]) {
      if (used[n.to]) continue;
      q.push(make_pair(n.cost, n.to));
    }
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 7876
import java.util.*;
import java.io.*;
import java.math.*;
public class Main{
	static int mod = (int)1e9+7;
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static void main(String sp[])throws IOException{
		FastReader sc = new FastReader();
		
		int n = sc.nextInt();
		ArrayList<Long> al  = new ArrayList<>();
		for(int i=0;i<n;i++){
			al.add(sc.nextLong());
		}
		long prefix[] = new long[n+2];
		long sufix[] = new long[n+2];
		long xor=0;
		for(int i=0;i<n;i++){
			xor = gcd(al.get(i),xor);
			prefix[i+1] = xor;
		}
		xor=0;
		for(int i=n-1;i>=0;i--){
			xor = gcd(al.get(i),xor);
			sufix[i+1] = xor;
		}
		long max = Long.MIN_VALUE;
		for(int i=0;i<n;i++){
			long restxor = gcd(prefix[i],sufix[i+2]);
			if(restxor==0){
				max = (long)1e9;
			}else{
				max = Math.max(xor,Math.max(max,restxor));
			}
		}
		out.println(max);
		
		
		out.close();
	}
	
	
	public static int[] quick(int[] arr, int s, int e){
		
		if(s>=e)
			return arr;
		
		int y = partition(arr, s, e);
		int[] l = quick(arr, s, y-1);
		int[] r = quick(arr, y+1, e);
		
		return arr;
		
	}
	
	public static int partition(int [] arr, int s, int e){
		
		int index=s;
		int pivot = arr[e];
		for(int i=s;i<=e-1;i++){
			if(arr[i]<=pivot){
				arr = swap(arr, index, i);
				index++;
			}
		}
		swap(arr,index,e);
		print(arr);
		return index;
	}
	
	public static int[] swap(int[] arr, int low, int high){
		int temp = arr[low];
		arr[low]=arr[high];
		arr[high]=temp;
		return arr;
	}
	
	
	public static long gcd(long a, long b){
		if(a==0)
			return b;
		
		return gcd(b%a,a);
	}
	
	public static void print(int[] arr){
		for(int i=0;i<arr.length;i++)
			System.out.print(arr[i]+" ");
		System.out.println();
	}
	
	public static class pair{
		int ai;
		int bi;
	}
	
	public static class comp implements Comparator<pair>{
		public int compare(pair o1, pair o2){
			return o1.bi-o2.bi;
		}
	}
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
	
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
}

Measured memory_bytes: 45164
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;

double dfact(const int a) {
	assert(a >= 0);
	if (a == 0)return 1;
	return a*dfact(a - 1);
}
double dcomb(const int a, const int b) {
	return (dfact(a) / dfact(b)) / dfact(a-b);
}
double eps = 1e-9;

int main() {
	int N, M, L; cin >> N >> M >> L;
	vector<map<double, double>>mps,ruisekimps;
	for (int i = 0; i < N; ++i) {
		double P,T,V; cin >> P >> T >> V;
		P /= 100;
		map<double, double>mp;
		if (T < eps) {
			mp[L / V] = 1;
		}
		else {
			for (int rest = 0; rest <= M; ++rest) {
				mp[L / V + T*rest] = pow(P, rest)*pow(1 - P, M - rest)*dcomb(M, rest);
			}
		}
		
		mps.push_back(mp);
	}
	for (int rn = 0; rn < N; ++rn) {
		map<double, double>mp;
		double nowprob = 0;
		mp[0] = 0;
		
		for (auto prob : mps[rn]) {
			nowprob += prob.second;
			mp[prob.first] = nowprob;
		}
		mp[1e18] = 1;
		ruisekimps.push_back(mp);
	}
	for (int rn = 0; rn < N; ++rn) {
		double ans = 0;
		for(auto i:mps[rn]){
			double atime = i.first;
			double prob = i.second;
			for (int ob = 0; ob < N; ++ob) {
				if (rn == ob)continue;
				
				auto it(ruisekimps[ob].lower_bound(atime + eps));
				prob *= (1-prev(it)->second);
			}
			ans += prob;
		}
		cout <<setprecision(22)<<fixed<< ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4064
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        PriorityQueue<Integer> A = new PriorityQueue<>(Collections.reverseOrder());
        while(true){
            String cmd = sc.next();
            if(cmd.equals("end")) break;
            else if(cmd.charAt(0)=='i')A.add(sc.nextInt());
            else System.out.println(A.poll());
        }
    }
}



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

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	vector<int> p(a), q(b), r(c);
	rep(i,a) cin >> p.at(i);
	rep(i,b) cin >> q.at(i);
	rep(i,c) cin >> r.at(i);
	sort(p.begin(), p.end(), greater<int>());
	sort(q.begin(), q.end(), greater<int>());
	sort(r.begin(), r.end(), greater<int>());

	vector<int> res;
	rep(i,x) res.push_back(p.at(i));
	rep(i,y) res.push_back(q.at(i));
	rep(i,c) res.push_back(r.at(i));
	sort(res.begin(), res.end(), greater<int>());
	ll ans = 0;
	rep(i,x + y) ans += res.at(i);
	cout << ans << endl;
}


Measured memory_bytes: 3700
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
	fwrite(buf, 1, _bl, stdout);
	_bl = 0;
}
__inline void _putchar(char c) {
	if(_bl == _B) flush();
	buf[_bl++] = c;
}
inline void print(LL x, char c) {
	static char tmp[20];
	int l = 0;
	if(!x) tmp[l++] = '0';
	else {
		while(x) {
			tmp[l++] = x % 10 + '0';
			x /= 10;
		}
	}
	for(int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
	_putchar(c);
}
const int N = 333;
const int LOG = 60;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
LL a[N], c[N];
char s[N];
int main() {
	int t;
	scanf("%d", &t);
	for(int qq = 1; qq <= t; qq++) {
		int n;
		scanf("%d", &n);
		for(int i =1; i <= n; i++) 
		cin >> a[i];
		scanf("%s", s + 1);
		bool zerowins = true;
		memset(c, -1, sizeof(c));
		for(int i = n; i >= 1; i--) {
			LL x = a[i];

			if(s[i] == '0') {
				for(int j = 0; j < LOG; j++) {
					if(c[j] != -1) {
						if((x >> j) & 1) {
							x ^= c[j];
						}
					}else {
						if((x >> j) & 1) {
							c[j] = x;
						//	cout << j << ' ' << x << endl;
							break;
						}
					}
				}
			}else {
				for(int j = 0; j < LOG; j++) {
					if(c[j] != -1) {
						if((x >> j) & 1) {
							x ^= c[j];
						}
					}
				}
				if(x != 0) {
					zerowins = false;
					break;
				}
			}
		}
		printf("%d\n", zerowins ? 0 : 1);
	}
}






Measured memory_bytes: 3824
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i64,
    }
    // annotate for rust-analyzer
    let n: i64 = n;

    let mut ans = 0;
    for k in 1..=n {
        let cnt = n / k;
        let sum = (k + k * cnt) * cnt / 2;
        ans += sum;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2172
package main

import (
	"fmt"
	"os"
	"bufio"
	"strings"
	"strconv"
)

func binary_search(key int, S []int) bool{
	left := 0
	right := len(S)-1
	if S[right] == key{
		return true
	}
	for ; left<right; {
		mid := (left+right)/2
		if S[mid] == key{
			return true
		}else if S[mid] > key{
			right = mid
		}else{
			left = mid+1
		}
	}
	return false
}

// Scannerのバッファサイズ許容量で死ぬ
// バッファサイズをあらかじめ変更するか、1文字ずつ読むのが良い

func main(){
	var n, q, ans int
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 10000)
	sc.Buffer(buf, 1000000)
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	sc.Scan()
	S := make([]int, n)
	for i, v := range(strings.Split(sc.Text(), " ")){
		S[i], _ = strconv.Atoi(v)
	}
	sc.Scan()
	q, _ = strconv.Atoi(sc.Text())
	sc.Scan()
	T := make([]int, q)
	for i, v := range(strings.Split(sc.Text(), " ")){
		T[i], _ = strconv.Atoi(v)
	}
	for _, key := range(T){
		if binary_search(key, S){
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6448
#include <stdio.h>

int main(void){
    int a,b,c,i;
    int x=0;
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            x++;
        }
    }
    printf("%d\n",x);
    return 0; /*0?????????*/
}

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  string s;
  cin >> s;
  bool judge[26]={};
  rep(i,s.size())
  {
    judge[s[i]-'a']=true;
  }
  rep(i,26)
  {
    if(!judge[i])
    {
      print((char)(i+'a'));
      return 0;
    }
  }
  print("None");

  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int main()
{
	int n,l;
	while(~scanf("%d%d",&n,&l))
  {
	char a[n][l+1];
	int i,j;
	for(i=0;i<=n-1;i++)
	 {
	 	scanf("%s",a[i]);
	 	getchar();
	 }
	 int m=0; 
	 char b[l+1];
	for(i=0;i<n-1;i++)
	 {
	     for(j=i+1;j<=n-1;j++)
	 	  {
	 	  	m=0;
	 	  	while(a[i][m]==a[j][m]&&m!=l-1)
	 	  	     m=m+1;
	 	  	if(a[i][m]>a[j][m])
	 	  	{
	 	  		strcpy(b,a[i]);
	 	  		strcpy(a[i],a[j]);
	 	  		strcpy(a[j],b);
	 	  	}
	 	  }
	 }
	 for(i=0;i<=n-1;i++)
	    printf("%s",a[i]);
	    printf("\n") ;
    }
	 return 0;
	 
	
}

Measured memory_bytes: 128
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();
    if(a>=13){
      System.out.println(b);
    }else{
      if (a<=5) {
        System.out.println(0);
      }else{
        System.out.println(b/2);
      }
    }
  }
}


Measured memory_bytes: 22100
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int N =scan.nextInt();
		int max=0,midx=0;
		int max2=0,midx2=0;

		for(int i=0; i<N ;i++)
		{
			int a =scan.nextInt();
			if(max<a){
				max=a;
				midx=i;
			}else if(max2<a) {
				max2=a;
				midx2=a;
			}
		}
		PrintWriter pw=new PrintWriter(System.out);
		for(int i=0;i<N;i++) {
			if(i==midx) {
				pw.println(max2);
			}else {
				pw.println(max);
			}
		}
		pw.flush();


	}
}

Measured memory_bytes: 64032
#include <iostream>

using namespace std;

int main(void)
{
	char s[5];
	int price = 700;

	cin >> s;

	for (int i = 0; i < 3; i++)
	{
		if (s[i] == 'o')
		{
			price += 100;
		}
	}

	cout << price << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		if (A - B >= 0) {
			System.out.println("delicious");
		}else if(Math.abs(A - B) <= X){
			System.out.println("safe");
		}else{
			System.out.println("dangerous");
		}
	}
	
}

Measured memory_bytes: 21972
#include<stdio.h>

int main( void ){
	
	int n;
	int i;
	int max , min;
	
	scanf( "%d" , &n );
	int r[n];
	
	for( i = 0; i < n; i++ ){
		scanf( "%d" , &r[i] );
	}
	
	max = r[1]-r[0];
	min = r[0];
	
	for( i = 1; i <= n - 1; i++ ){
		
		if( max < r[i] - min ){
			max = r[i] - min;
		}
		if( r[i] < min ){
			min = r[i];
		}
	}
	
	printf( "%d\n" , max );
	
}


Measured memory_bytes: 2488