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

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

vector<pair<ll, ll> > prime_factorize(ll n) {
  vector<pair<ll, ll> > res;
  for (ll p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    ll num = 0;
    while(n % p == 0) { ++num; n /= p; }
    res.emplace_back(make_pair(p, num));
  }
  if (n != 1) res.emplace_back(make_pair(n, 1));
  return res;
}

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

ll modcomb(ll a, ll b, ll mod) {
  if (b > a-b) return modcomb(a, a-b, mod);
  ll mul = 1, div = 1;
  for(ll i = 0; i < b; ++i) {
    mul *= (a-i), div *= (i+1);
    mul %= mod, div %= mod;
    
  }
  return mul * modpow(div, mod - 2, mod) % mod;
}

void solve(void) {
  ll n, m; cin >> n >> m;
  const ll MOD = 1000000000 + 7;

  auto vec = prime_factorize(m);
  ll res = 1;
  for(auto v: vec) {
    ll tmp = modcomb(n + v.second-1, n-1, MOD);
    res = (res * tmp) % MOD;
  }
  cout << res << endl;  
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
vector< int > z_algorithm(const string &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}
int main()
{
	int n;
	cin>>n;
	int a[200020], b[200020];
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<n; i++) cin>>b[i];
	int m[30], d[30], m2[30], d2[30];
	for(int k=0; k<30; k++){
		string s, t;
		for(int i=0; i<n; i++){
			if(a[i]&(1<<k)) s+='1';
			else s+='0';
			if(b[i]&(1<<k)) t+='1';
			else t+='0';
		}
		s+=s;
		t+=s;
		vector<int> v=z_algorithm(t);
		m[k]=-1, d[k]=n;
		for(int i=0; i<n; i++){
			if(v[i+n]>=n){
				if(m[k]==-1) m[k]=i;
				else{
					d[k]=i-m[k];
					break;
				}
			}
		}
		for(int i=n; i<3*n; i++){
			if(t[i]=='1') t[i]='0';
			else t[i]='1';
		}
		v=z_algorithm(t);
		m2[k]=-1, d2[k]=n;
		for(int i=0; i<n; i++){
			if(v[i+n]>=n){
				if(m2[k]==-1) m2[k]=i;
				else{
					d2[k]=i-m2[k];
					break;
				}
			}
		}
	}
	for(int i=0; i<n; i++){
		int x=0;
		for(int j=0; j<30; j++){
			if(m[j]==-1 && m2[j]==-1){
				x=-1; break;
			}else if(m[j]==-1){
				if(i%d2[j]!=m2[j]){
					x=-1; break;
				}else{
					x^=(1<<j);
				}
			}else if(m2[j]==-1){
				if(i%d[j]!=m[j]){
					x=-1; break;
				}
			}else{
				if(i%d[j]!=m[j] && i%d2[j]!=m2[j]){
					x=-1; break;
				}else if(i%d2[j]==m2[j]){
					x^=(1<<j);
				}
			}
		}
		if(x!=-1) cout<<i<<" "<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 7724
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    for(int i = 0; i < N - 1; i++) cin >> C[i] >> S[i] >> F[i];
    vector<int> dp(N, 0);
    for(int i = 0; i < N - 1; i++) dp[i] = S[i];
    for(int i = 0; i < N; i++){
        if(i == N - 1) cout << 0 << endl;
        else{
            if(dp[i] > S[i]) dp[i] = S[i];
            for(int j = i + 1; j < N - 1; j++){
                if(dp[j] > S[j]) dp[j] = S[j];
                if(dp[j] < dp[j - 1] + C[j - 1]) dp[j] = S[j] + (dp[j - 1] + C[j - 1] + F[j] - 1 - S[j]) / F[j] * F[j];
            }
            dp[N - 1] = dp[N - 2] + C[N - 2];
            cout << dp[N - 1] << endl;
        }
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    ll x;
    cin>>x;
    ll y=__gcd(x,360ll),z=x;
    cout<<360/y;
    subt;
    return 0;
}

Measured memory_bytes: 3772
#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
T = []
for _ in range(D):
    t = int(input()) - 1
    T.append(t)
    
#スコア計算
score = 0
last_day = [-1] * 26
for t in range(D):
    test = T[t]
    score += S[t][test]
    last_day[test] = t
    for i in range(26):
        score -= (C[i] * (t - last_day[i]))
    print(score)

Measured memory_bytes: 74240
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int N = 1e5;
int a[N+5];

int main()

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

    int n, a, b;

    cin >> n >> a >> b;

    if ((b-a)%2) cout << "Borys";
    else cout << "Alice";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int a[100000];
    for(int i=0;i<N;i++)
        cin >> a[i];
    
    int ans = 0, l = 1;
    for(int count=0;count<N;count++){
        l = a[l-1];
        if(l == 2){
            cout << count + 1 << endl;
            return 0;
        }
    }

    cout << -1 << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
pair<long long,long long>a[100007];
int main(){
    long long n,m;
    cin>>n>>m;
    for(long long i=1;i<=n;i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a+1,a+1+n);
    long long sum=0;
    long long ans=0;
    for(long long i=1;i<=n;i++){
        if(sum==m)
            break;
        if(sum+a[i].second<=m){
            ans+=a[i].second*a[i].first;
            sum+=a[i].second;
        }
        else{
            ans+=(m-sum)*a[i].first;
            sum=m;
        }
    }
    cout<<ans;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int N, A;
ull dp[51][5010];

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N >> A;
    VI V(N);
    REP(i, N) {
        cin >> V[i];
        V[i] -= A;
    }
    int k = 2500;
    REP(i, N) {
        dp[i][k+V[i]] = 1;
    }
    FOR(i, 1, N-1) {
        FOR(j, 51, 5009) {
            dp[i][j] += dp[i-1][j-V[i]] + dp[i-1][j];
        }
    }
    cout << dp[N-1][k] << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,n;
    scanf("%d %d %d %d",&a,&b,&c,&n);

    if((abs(b-a) <= n && abs(c-b) <= n)||abs(c-a) <= n)
        puts("Yes\n");
    else puts("No\n");
}

Measured memory_bytes: 256
def main():
  N = int(input())
  CSF = [[int(_) for _ in input().split()] for __ in range(N-1)]
  for i in range(N-1):
    t = CSF[i][1] + CSF[i][0]
    for j in range(i+1, N-1):
      c, s, f = CSF[j]
      if t <= s:
        t = s + c
      else:
        k = (t - s + f - 1)//f
        t = s + k * f + c
    print(t)
  print(0)
  return

if __name__ == '__main__':
  main()
    

Measured memory_bytes: 3188
program hi;
var 
    si: array[2..100010] of boolean;
    x, i, j: longint;

begin
    for i := 2 to 100010 do 
        si[i] := true;
    for i := 2 to 317 do begin
        j := i * i;
        while j <= 100010 do begin
            si[j] := false;
            j := j + i;
        end;
    end;
    readln(x);
    if si[x] then 
        writeln(x)
    else begin
        i := x;
        while not si[i] do 
            inc(i);
        writeln(i);
    end;
end.

Measured memory_bytes: 1356
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;

typedef long long ll;
double unit_r = 180.0/ M_PI;

int main() {
    int A,B,X;cin>>A>>B>>X;
    double bDush = (double)B-(double)X/(A*A);
    double b2Dush = 2*bDush;
    if(A*bDush <= A*B/2){
        double ans = atan(b2Dush/A);
        printf("%.16f",ans*unit_r);
        return 0;
    }
    else {
        double aDush = (2*A*((double)B-bDush))/(double)B;
        double ans = atan(aDush/B)*unit_r;
        printf("%.16f",90-ans);
    }
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int A[5050];
bitset<8192> L[5050],R[5050];
ll LT[5050],RT[5050];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>A[i];
	L[0][0]=1;
	R[N+1][0]=1;
	FOR(i,N) {
		bitset<8192> T=L[i];
		T<<=A[i];
		L[i+1]=L[i] | T;
		if(L[i].count() != T.count()) L[i+1][8191]=1;
		LT[i+1]=LT[i]+A[i];
	}
	for(i=N-1;i>=0;i--) {
		bitset<8192> T=R[i+2];
		T<<=A[i];
		R[i+1]=R[i+2] | T;
		if(R[i+2].count() != T.count()) R[i+1][8191]=1;
		RT[i+1]=RT[i+2]+A[i];
	}
	
	int ret=0;
	FOR(i,N) {
		ll LB=max(0,K-A[i]);
		ll RB=K-1;
		deque<int> AA,BB;
		FOR(x,8192) if(R[i+2][x]) AA.push_back(x);
		
		int hoge=1;
		FOR(x,8192) if(L[i][x]) {
			ll LB2=LB-x,RB2=RB-x;
			while(AA.size() && AA.back()>=LB2) BB.push_front(AA.back()),AA.pop_back();
			while(BB.size() && BB.back()>RB2) BB.pop_back();
			if(BB.size()) {
				hoge=0;
				break;
			}
		}
		
		ret+=hoge;
		
		
	}
	
	cout<<ret<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 10496
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////
const int N = 110;
int n, x, a[N];

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n >> x;
    REP(i, n) cin >> a[i];
    int s = 0, ans = 0;
    sort(a, a+n);
    REP(i, n) {
    	s += a[i];
    	if(x >= s) ans = i+1;
    }
    if(x > s) --ans;
    cout << ans << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting min to 0 instead of -INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)


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

int MOD_N = (10 * 10 * 10) * (10 * 10 * 10) * (10 * 10 * 10) + 7;

int main() {
    int N, K;
    cin >> N; cin >> K;
    vector<int> nums;

    for (int n = 1; n * n <= N; ++n) {
        nums.push_back(n);
        nums.push_back(N/n);
    }
    sort(nums.begin(), nums.end(), std::greater<long>());
    //nums.erase(unique(nums.begin(), nums.end()), nums.end());

    int nums_n = nums.size();
    long *prev_counts = new long[nums_n];
    long *cur_counts = new long[nums_n];
    long *revs = new long[nums_n];
    long *tmp;
    for (int i = 0; i < nums_n; ++i) {
        int n = nums[i];
        int q = N / n;
        prev_counts[i] = q;
        revs[i] = q;
    }
    for (int k = 3; k <= K+1; ++k) {
        cur_counts[0] = prev_counts[nums_n-1];
        for (int i = 1; i < nums_n; ++i) {
            int p = revs[i-1];
            int q = revs[i];
            long c = cur_counts[i-1] + (q-p) * prev_counts[nums_n-1-i];
            cur_counts[i] = c % MOD_N;
        }
        tmp = prev_counts;
        prev_counts = cur_counts;
        cur_counts = tmp;
    }
    cout << prev_counts[nums_n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;

struct Edge {
  int to, cost;
};

int v, e, s, t, d;
vector<Edge> g[16];
vector<vector<int>> dp(1 << 16, vector<int>(16, -1));

int rec(int bit, int from) {
  if (dp[bit][from] >= 0) return dp[bit][from];
  if (bit == (1 << v) - 1 && from == 0) return dp[bit][from] = 0;

  int res = 1 << 30;
  for(Edge e : g[from]) {
    if (bit >> e.to & 1) continue;
    res = min(res, rec(bit | (1 << e.to), e.to) + e.cost);
  }
  return dp[bit][from] = res;
}

int main() {
  cin >> v >> e;
  REP(i, e) {
    cin >> s >> t >> d;
    g[s].push_back(Edge{t, d});
  }
  rec(0, 0);
  cout << (dp[0][0] != (1 << 30) ? dp[0][0] : -1) << endl;
  return 0;
}





Measured memory_bytes: 9332
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

const std::vector <std::pair<int,int>> direct = {
	{0,0},{-1,0},{1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}
};
std::set<std::pair<int,int>> grid, black;
int h, w, n;

int main () {
	std::cin >> h >> w >> n;
	for (int i = 0; i < n; ++i) {
		int x, y; std::cin >> x >> y;
		for (int j = 0; j < 9; ++j) {
			int dx = x + direct[j].first;
			int dy = y + direct[j].second;
			if (dx > 1 and dy > 1 and dx < h and dy < w)
				grid.insert ({dx, dy});
		}
		black.insert ({x, y});
	}
	std::vector <long long> rec (10, 0);
	for (auto it : grid) {
		int x = it.first, y = it.second;
        int cnt = 0;
		for (int j = 0; j < 9; ++j) {
			int dx = x + direct[j].first;
			int dy = y + direct[j].second;
			if (black.count ({dx,dy})) ++cnt;
		}
		std::cerr << x << " " << y << " " << cnt << "\n";
		rec[cnt]++;
	}
	rec[0] = 1LL * (h - 2) * (w - 2);
	for (int i = 1; i < 10; ++i) rec[0] -= rec[i];
	for (int i = 0; i < 10; ++i) std::cout << rec[i] << "\n";
	return 0;
}

Measured memory_bytes: 49152
#include <bits/stdc++.h>
#include <unordered_set>
#include <stdio.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI 3.141592653589793
#define vi vector<int>
inline double degcos(double ang) {return cos(ang*PI/180);}
inline double degsin(double ang) {return sin(ang*PI/180);}
#define for(i,j,k,in) for (int i = j; i < k; i += in)

/*---END OF TEMPLATE---*/




int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //ifstream fin("data.in");
    //ofstream fout("data.out");
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define MOD(x) ((x)%mod)
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
using namespace std;
int n;
long long a[30][30];
long long b[30];
int m;
int e[30];
int s,t;
long long dp[1000004];

void dfs(int x,int num)
{
	if(num) dp[s]=max(dp[s],dp[t]+dp[s^t]);
	if(num==n/2) return;
	for(int i=x;i<=m;i++)
	{
		t^=b[e[i]];
		dfs(i+1,num+1);
		t^=b[e[i]];
	}
}
int main()
{
	for(int i=0;i<=20;i++)
		b[i]=1<<i;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			scanf("%lld",&a[i][j]);
	for(int i=1;i<b[n];i++)
	{
		m=0;
		for(int j=0;j<n;j++)
			if(i&b[j]) e[++m]=j;
		s=i;
		for(int j=1;j<=m;j++)
			for(int k=j+1;k<=m;k++)
				dp[s]+=a[e[j]][e[k]];
		dfs(1,0);
	}
	printf("%lld",dp[b[n]-1]);
	return 0;
}



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

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

const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int inf = 1e16 + 2;



void solve(int z) {
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0 ; i < n ; i ++) cin >> arr[i];
    map<int , int > m;
    for(int i = 0 ; i < n ; i ++) {
        m[i - arr[i]] ++;
    }
    int cnt = 0;
    for(int i = 0 ; i < n ; i ++) {
        cnt += m[i + arr[i]];
        m[i - arr[i]] --;
    }
    cout << cnt;
}

/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int x = 1;
    while(testcase --) {
        solve(x ++);
    }
    
    return 0;
}
 



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

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001;
using namespace std;
typedef long long ll;

int n;
int x[200], y[200];
ll h[200];

int main(){
  std::cin >> n;
  rep(i,1,n+1)std::cin >> x[i] >> y[i] >> h[i];

  rep(i,0,101)rep(j,0,101){
    std::vector<int> canH;
    rep(k,1,n+1){
      int tmp_H = h[k]+abs(x[k]-i)+abs(y[k]-j);
      canH.push_back(tmp_H);
    }
    rep(k,0,canH.size()){
      bool flag = true;
      int H = canH[k];
      rep(l,1,n+1){
        int temp_h = max(H-abs(x[l]-i)-abs(y[l]-j), 0);
        if(temp_h != h[l]){
          flag = false;
          break;
        }
      }
      if(flag){
        std::cout << i << ' '<<j<<' '<<H<< '\n';
        return 0;
      }

    }

  }
  
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long long n,wa,i,t;
	
	scanf("%lld",&n);
	wa=0;
	for(i=0;i<n;i++){
		scanf("%lld",&t);
		wa+=t;
	}
	printf("%lld\n",wa/n);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int a,b,p,j,i;
	cin >> a >> b;
	p=b;
	j=1;
	while(p!=0)
	{
		p=p/10;
		j*=10;
	}
	a=a*j+b;
	p=0;
	for(i=2; i<=sqrt(a)+1; i++)
	{
		if(a%i==0)
		{
			if(a/i==i) p=1;
		}
	}
	if(p==1)
	cout << "Yes";
	else cout << "No";
}


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

int main() {
    int H, W; cin >> H >> W;
    string C[H];
    for (int i = 0; i < H; i++) {
        cin >> C[i];
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0 ; j < W; j++) {
            cout << C[i][j];
        }
        cout << endl;
        for (int j = 0 ; j < W; j++) {
            cout << C[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int n,m,p,q;
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int h,w;
  cin>>h>>w;
  int ch,cw,dh,dw;
  cin>>ch>>cw;
  cin>>dh>>dw;
  string s[1001];
  int val[1001][1001];
  int added[1001][1001];
  rep(i,h)rep(j,w) val[i][j]=INT_MAX,added[i][j]=false;
  rep(i,h) cin>>s[i];
    priority_queue<pair<int,pair<int,int> > ,vector<pair<int,pair<int,int> >>, greater<pair<int,pair<int,int> >> >  qq;
    ch--,cw--,dh--,dw--;
    int dx[]={1,-1,0,0};
    int dy[]={0,0,1,-1};
    qq.push(mk(0,mk(ch,cw)));
    val[ch][cw]=0;
    while(!qq.empty()){
        auto x=qq.top();
        qq.pop();
        if(val[x.se.fi][x.se.se]<x.fi) continue;
        //val[x.se.fi][x.se.se]=x.fi;
        if(x.se.fi==dh && x.se.se==dw) break;
        rep(i,4) {
            p=x.se.fi+dx[i];
            q=x.se.se+dy[i];
            if(p>=0 && q>=0 && p<h && q<w && s[p][q]=='.' && val[p][q]>x.fi){
                qq.push(mk(x.fi,mk(p,q)));
                val[p][q]=x.fi;
                //added[p][q]=true;
            }
        }
        reps(i,-2,3) reps(j,-2,3){
            p=x.se.fi+i;
            q=x.se.se+j;
            if(p>=0 && q>=0 && p<h && q<w && s[p][q]=='.' && val[p][q]>x.fi+1 ){
                qq.push(mk(x.fi+1,mk(p,q)));
                val[p][q]=x.fi+1;
            }
        }
    }
    if(val[dh][dw]!=INT_MAX)
    cout<<val[dh][dw]<<endl;
    else cout<<-1<<endl;
  // cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8736
N = int(input())
buffet = [int(i) for i in input().split()]
satisfaction_level_B = [int(i) for i in input().split()]
satisfaction_level_C = [int(i) for i in input().split()]
count = []
result = 0

for i in buffet:
    count.append(i)
    result += satisfaction_level_B[i - 1]
    if len(count) >= 2:
        if count[-1] - count[-2] == 1:
            result += satisfaction_level_C[i - 2]
print(result)

Measured memory_bytes: 9204
M = pow(10, 9) + 7

def pow_mod(a, n, m): # (a^n) % m
    res = 1
    while n > 0:
        if n % 2 == 1:
            res = (res * a) % m
        a = (a * a) % m
        n = n // 2
    return res

def combi_mod(p, q, m):
    numerator, denominator = 1, 1
    for i in range(1, q+1):
        numerator *= (p - i + 1)
        numerator %= m
        denominator *= i
        denominator %= m
    return numerator * pow_mod(denominator, m-2, m) % m

n, a, b = list(map(int, input().split()))
res = pow_mod(2, n, M) - 1
res -=combi_mod(n, a, M)
if res < 0:
    res += M
res -= combi_mod(n, b, M)
if res < 0:
    res += M
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
      cout << "vowel" << endl;
  }
  else {
      cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned int ui;
#define All(v) (v).begin(),(v).end()
#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 FOR(i,m,n) for(int i = m; i < n; i++)
#define FORS(i,m,n) for(int i = m; i <= n; i++)
#define INF 2e9
#define F first
#define S second
#define pb push_back
#define mp make_pair
struct speed{speed(){cin.tie(); ios::sync_with_stdio(false); cout << fixed << setprecision(18);}}speed;

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

int main (){
    int n,k;
    string s;
    cin >> n >> s >> k;
    char tmp = s[k-1];
    REP(i,n){
        if(s[i] != tmp){
            s[i] = '*';
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 384
queenExists = [[False] * 8 for _ in range(8)]

n = int(input())
for _ in range(n):
    x, y = map(int, input().split())
    queenExists[y][x] = True


def dfs(queenExists, c):
    if c >= 8:
        return True

    # check if queen exists in column c
    isQueen = False
    for r in range(8):
        if queenExists[r][c] is True:
            isQueen = True
    if isQueen is True:
        return dfs(queenExists, c + 1)

    for r in range(8):

        # check if queen can be put on [r][c]
        checkOk = True
        # check horizon
        for i in range(8):
            if queenExists[r][i] is True:
                checkOk = False
                break
        # check diagonal
        d = [[1, 1], [1, -1], [-1, 1], [-1, -1]]
        for dx, dy in d:
            n_r, n_c = r + dy, c + dx
            while 0 <= n_r < 8 and 0 <= n_c < 8:
                if queenExists[n_r][n_c] is True:
                    checkOk = False
                    break
                n_r, n_c = n_r + dy, n_c + dx
        if checkOk is False:
            continue

        # now that we can put queen on [r][c]
        queenExists[r][c] = True
        if dfs(queenExists, c + 1):
            return True
        queenExists[r][c] = False


dfs(queenExists, 0)

for i in range(8):
    for j in range(8):
        if queenExists[j][i] is True:
            print("Q", end="")
        else:
            print(".", end="")
    print()



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

#define REP(i, s, n) for(int i = (s); i < int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(co) co.begin(), co.end()

int dp[101][3][2];
int sche[101];
const int MOD = 10000;

int main()
{
	int n, k; cin >> n >> k;
	n--;
	memset(sche, -1, sizeof(sche));
	rep(i, k)
	{
		int a, b; cin >> a >> b;
		a--; b--;
		sche[a] = b;
	}

	if (~sche[0]) dp[0][sche[0]][0] = 1;
	else rep(i, 3) dp[0][i][0] = 1;

	rep(i, n)
	{
		if (~sche[i + 1]) rep(j, 3)
		{
			if (j == sche[i + 1]) dp[i + 1][sche[i + 1]][1] += dp[i][sche[i + 1]][0] % MOD;
			else dp[i + 1][sche[i + 1]][0] += (dp[i][j][0] + dp[i][j][1]) % MOD;
		}
		else rep(j, 3) rep(k, 3)
		{
			if (j == k) dp[i + 1][j][1] += dp[i][k][0] % MOD;
			else dp[i + 1][j][0] += (dp[i][k][0] + dp[i][k][1]) % MOD;
		}
	}

	int ans = 0;
	rep(i, 3) (ans += (dp[n][i][0] + dp[n][i][1])) %= MOD;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3104
import java.util.*;
import java.io.*;
import java.math.*;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner();
		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] S = new char[H][W];
		for (int i = 0; i < H; ++i) {
			S[i] = sc.next().toCharArray();
		}
		DJSet ds = new DJSet(H * W);
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (i + 1 < H && S[i][j] != S[i + 1][j]) {
					ds.setUnion(W * i + j, W * (i + 1) + j);
				}
				if (j + 1 < W && S[i][j] != S[i][j + 1]) {
					ds.setUnion(W * i + j, W * i + j + 1);
				}
			}
		}
		long[] b = new long[H * W];
		long[] w = new long[H * W];
		long ans = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				int r = ds.root(i * W + j);
				if (S[i][j] == '.')
					++b[r];
				else
					++w[r];
			}
		}
		for (int i = 0; i < H * W; ++i) {
			ans += b[i] * w[i];
		}
		System.out.println(ans);
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}

class DJSet {

	int n;
	int[] p;

	public DJSet(int n_) {
		n = n_;
		p = new int[n];
		Arrays.fill(p, -1);
	}

	int root(int x) {
		return p[x] < 0 ? x : (p[x] = root(p[x]));
	}

	boolean equiv(int x, int y) {
		return root(x) == root(y);
	}

	void setUnion(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y)
			return;
		if (p[x] < p[y]) {
			x ^= y;
			y ^= x;
			x ^= y;
		}
		p[y] += p[x];
		p[x] = y;
	}

	int sz(int x) {
		return -p[root(x)];
	}

}

class Scanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}


Measured memory_bytes: 26660
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 <= 8 && b <= 8) System.out.println("Yay!");
        else System.out.println(":(");
    }
}

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

int main (){
  int a;
  cin >> a;
  char c;
  int ans = 0;
  
  for ( int i = 0; i < a; i++ ){
    cin >> c;
    if ( c == 'Y' ) ans = 1;
  }
  
  if ( ans == 1 ) 
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}

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

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

  int A[N + 1];
  int B[51];
  int C[51];

  rep(i, N) { cin >> A[i]; }

  rep(i, N) { cin >> B[i]; }

  rep(i, N - 1) { cin >> C[i]; }

  int tmp = 0;
  int result = 0;

  rep(i, N) {
    result += B[A[i] - 1];

    if (tmp != 0 && tmp == A[i] - 1) {
      result += C[tmp - 1];
    }
    tmp = A[i];
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int  d;
	scanf("%d", &d);
	if (d == 22) {
		printf("Christmas Eve Eve Eve\n");
	}
	if (d == 23) {
		printf("Christmas Eve Eve\n");
	}
	if (d == 24) {
		printf("Christmas Eve\n");
	}
	if (d == 25) {
		printf("Christmas\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

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

using namespace std;

int main() {
	int cnt=0;
	string s,t;
	cin >> s >> t;
	rep(i, s.length())
		if (s[i] != t[i]) cnt++;
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int mod = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const int maxn = (2000 + 10) * 3 + 100;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}
 
int len;
char sa[maxn], sb[maxn];
 
bool chk(char *s) {
    for(int i = 0; i < len; ++i) {
        if(s[i] == '1') return true;
    }
    return false;
}
 
int calc(int np) {
    static char na[maxn];
    static int l[maxn], r[maxn];
 
    int j = np;
    for(int i = 0; i < len; ++i) 
    { 
        na[j] = sa[i]; ++ j; 
        if(j == len) j = 0; 
    }
 
    for(int i = 0; i < len; ++i) sa[2*len+i] = sa[len+i] = sa[i];
 
    for(int i = 0; i < 3*len; ++i) 
        if(sb[i % len] == '1') l[i] = i; else l[i] = (i ? l[i-1] : -1);
    for(int i = 3*len-1; i >= 0; --i) 
        if(sb[i % len] == '1') r[i] = i; else r[i] = (i < 3*len-1 ? r[i+1] : -1);
 
    vector<pii> vec;
    static int mx[maxn];
    int ans = 0, res = INT_MAX;
 
    for(int i = len; i < 2*len; ++i) if(na[i % len] != sb[i % len]) {
        ++ ans;
        int lst = len + (i - np) % len;
        vec.pb(pii(lst - l[lst], r[lst] - lst));
    }
 
    sort(vec.begin(), vec.end());
 
    mx[vec.size()] = 0;
    for(int i = int(vec.size())-1; i >= 0; --i) { mx[i] = max(mx[i+1], vec[i].snd); }
 
    for(int i = 0; i < int(vec.size()); ++i) {
        int L = vec[i].fst, R = mx[i+1];
        
        if(np >= R) 
            chkmin(res, L*2 + np);
        else
            chkmin(res, (L+R) * 2 - np);

        if(len - np >= L) 
            chkmin(res, R*2 + len - np);
        else
            chkmin(res, (L+R) * 2 - (len - np));
    }
    int L = 0, R = mx[0];
    if(np >= R) 
        chkmin(res, L*2 + np);
    else
        chkmin(res, (L+R) * 2 - np);

    if(len - np >= L) 
        chkmin(res, R*2 + len - np);
    else
        chkmin(res, (L+R) * 2 - (len - np));
 
    return res + ans;
}
 
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif
 
    scanf("%s%s", sa, sb);
    len = strlen(sa);
 
    if(!chk(sb)) { 
        if(!chk(sa)) puts("0");
        else puts("-1");
        return 0;
    }
 
    int ans = INT_MAX;
    for(int i = 0; i < len; ++i) chkmin(ans, calc(i));
    printf("%d\n", ans);
 
    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>(),T=in<string>();
	vector<int> SC(26,0);
	vector<vector<int>> SP(26);
	int SN = S.size();
	REP(i,SN){
		SC[S[i]-'a']++;
		SP[S[i]-'a'].push_back(i);
	}
	int TN = T.size();
	ll num = 0;
	ll spos = 0;
	REP(i,TN){
		ll index = T[i]-'a';
		if(!SC[index]){
			out(-1);
			return 0;
		}
		auto res = lower_bound(SP[index].begin(),SP[index].end(),spos);
		if(res!=SP[index].end()){
			num += *res-spos+1;
			spos = *res+1;
		}
		else{
			num += SN-spos+SP[index][0]+1;
			spos = SP[index][0]+1;
		}
	}
	
	out(num);
	return 0;
}


Measured memory_bytes: 1228
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Jun  7 21:10:13 JST 2020
 **/
std::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());

int get_msb(long long x) {
    assert(x != 0);
    return 63 - __builtin_clzll(x);
}
int get_lsb(long long x) {
    assert(x != 0);
    return __builtin_ctzll(x);
}

void GaussJordan(std::vector<Int> &A, bool is_extended = false) {
    Int rank = 0;
    // for (Int col = 0; col < 62; ++col) {
    for (Int col = 62 - 1; col >= 0; col--) {
        if (is_extended && col == 62 - 1) break;
        Int pivot = -1;
        for (Int row = rank; row < A.size(); ++row) {
            if (A[row] >> col & 1) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        std::swap(A[pivot], A[rank]);
        for (Int row = 0; row < A.size(); ++row) {
            if (row != rank && (A[row] >> col & 1)) A[row] ^= A[rank];
        }
        ++rank;
        dump(A);
    }
    dump(A);
    REP(i, A.size() - 1) {
        if (A[i] == 0 || A[i + 1] == 0) continue;
        if (!(get_msb(A[i]) > get_msb(A[i + 1]))) {
            dump(get_msb(A[i]), get_msb(A[i + 1]));
            assert(false);
        };
    }
}
void solve() {
    Int n;
    std::cin >> n;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    // REP(i, n) a[i] = rnd() % 1000000000000000001;
    std::string s;
    // REP(i, n / 2) s.push_back('0' + rnd() % 2);
    // REP(i, n - n / 2) s.push_back('0');
    std::cin >> s;
    dump(a, s);
    std::vector<Int> acc;
    for (Int i = n - 1; i >= 0; i--) {
        if (s[i] == '0') {
            acc.push_back(a[i]);
            GaussJordan(acc);
        } else {
            while (a[i]) {
                Int ms = get_msb(a[i]);
                bool ok = false;
                for (Int x : acc) {
                    if (x && get_msb(x) == ms) {
                        a[i] ^= x;
                        assert(a[i] == 0 || get_msb(a[i]) < ms);
                        ok = true;
                        break;
                    }
                }
                if (!ok) {
                    dump(i);
                    std::cout << 1 << "\n";
                    return;
                }
            }
        }
    }
    std::cout << 0 << "\n";
}
signed main() {
    Int T;
    std::cin >> T;
    while (T--) solve();
}


Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<functional>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
LL N;
LL a[300010];
LL sorted_a[300010];
LL Q;
map<int ,set<int> > mp;
int main(){
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>a[i];
        sorted_a[i]=a[i];
    }
    sort(sorted_a+1,sorted_a+N+1);
    int cnt=0;
    for(int i=1;i<=N;i++){
        mp[sorted_a[i]].insert(i);
        if(sorted_a[i]==a[i]){
            cnt++;
        }
    }
    cin>>Q;
    bool f=false;
    int ans=-1;
    if(cnt>=N){
        ans=0;
        f=true;
    }
    for(int i=0;i<Q;i++){
        int x,y;
        cin>>x>>y;
        int change=0;
        if(mp[a[x]].count(x)>0){
            change--;
        }
        if(mp[a[y]].count(y)>0){
            change--;
        }
        if(mp[a[x]].count(y)>0){
            change++;
        }
        if(mp[a[y]].count(x)>0){
            change++;
        }
        cnt+=change;
        if(cnt>=N && !f){
            ans=i+1;
            f=true;
        }
        swap(a[x],a[y]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 50012
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
MOD = 10**9+7

ans = 1
for i in range(N):
    min_t = min_a = 1
    if i == 0 or T[i-1] < T[i]:
        min_t = T[i]
    if i == N-1 or A[i+1] < A[i]:
        min_a = A[i]
    if min_t > A[i] or min_a > T[i]:
            print(0)
            exit()
    n = min(T[i],A[i]) - max(min_t,min_a) + 1
    ans = (ans * n) % MOD
print(ans)

Measured memory_bytes: 18884
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n;
        cin >> n;
        vector<ll> p(n);
        rep(i, n) {
            cin >> p[i];
            p[i]--;
        }
        ll a[n], b[n];
        rep(i, n) a[i] = (n + 10) * i + 1;
        rep(i, n) b[i] = (n + 10) * (n - i - 1) + 1;
        rep(i, n) a[p[i]] += i;
        rep(i, n) cout << a[i] << ' ';
        printf("\n");
        rep(i, n) cout << b[i] << ' ';

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
// #include "prettyprint.hpp"

using namespace std;
using ll = long long;

const int sz = 35;
int arr[sz][sz], row[sz], col[sz];

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    char ch;
    int tb = 0;
    for(int i = 0; i < h; i++) {
        int cs = 0;
        for(int j = 0; j < w; j++) {
            cin >> ch;
            arr[i][j] = (ch == '#');
            cs += arr[i][j];
            tb += arr[i][j];
        }
        row[i] = cs;
    }
    // cout << row << "\n";
    for(int j = 0; j < w; j++) {
        int cs = 0;
        for(int i = 0; i < h; i++) {
            cs += arr[i][j];
        }
        col[j] = cs;
    }
    // cout << col << "\n";

    int mh = (1 << h) - 1;
    int mw = (1 << w) - 1;
    int res = 0;
    for(int i = 0; i <= mh; i++) {
        for(int j = 0; j <= mw; j++) {
            int cnt = 0;
            for(int k = 0; k <= 30; k++) {
                if(i & (1 << k)) {
                    cnt += row[k];
                }
                if(j & (1 << k)) {
                    cnt += col[k];
                }
                // if((i & (1 << k)) && (j & (1 << k))) {
                //     cnt -= arr[i][j];
                // }
            }
            for(int k = 0; k <= 30; k++) {
                if((i & (1 << k)) == 0) continue;
                for(int l = 0; l <= 30; l++) {
                    if ((j & (1 << l)) == 0) continue;
                    cnt -= arr[k][l];
                }
            }
            if((tb - cnt) == k) {
                res++;
            }
        }
    }
    cout << res << "\n";



    return 0;
}



Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>a(N);

    rep(i,N){
        cin>>a[i];
    }
    ll ans1=0;
    ll sum1=0;
    rep(i,N){
        sum1+=a[i];
        if(i%2==0){
            if(sum1<=0){
                ans1+=1-sum1;
                sum1=1;
            }
        }else{
            if(sum1>=0){
                ans1+=1+sum1;
                sum1=-1;
            }
        }
    }
    ll ans2=0;
    ll sum2=0;
    rep(i,N){
        sum2+=a[i];
        if(i%2==1){
            if(sum2<=0){
                ans2+=1-sum2;
                sum2=1;
            }
        }else{
            if(sum2>=0){
                ans2+=1+sum2;
                sum2=-1;
            }
        }
    }
    cout << min(ans1,ans2) << endl;


    return 0;
    

}

Measured memory_bytes: 4012