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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

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


int main(){
  string S;
  cin >> S;
  REP(i, S.length()){
    if(S[i] == '7'){
      yes;
      return 0;
    }
  }
no;
return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
	static int MOD = 1_000_000_007;
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        long res = ((modPow(2, n) - comb(n, a) - comb(n, b) - 1)) % MOD;
        System.out.println( res < 0 ? res + MOD : res);
    }

    private static long modPow(long a, long b) {
    	if(b == 0)
    		return 1;
    	if(a == 0)
    		return 0;
    	if(b == 1)
    		return a;
    	long res = modPow(a, b / 2) % MOD;
    	if(b % 2 == 1)
    		return ((res * res) % MOD) * a % MOD;
    	return (res * res) % MOD;
    }

    private static long factorial(long n, long start) {
    	long res = 1L;
    	for(long i = start; i <= n; i++)
    		res = (res % MOD)* (i % MOD) % MOD;
    	return res;
    }

    private static long comb(long a, long b) {
    	long factA = factorial(a, a - b + 1) % MOD;
    	long factB = factorial(b, 1) % MOD;
    	long inv = modPow(factB, MOD - 2) % MOD;
    	return factA * inv % MOD;
    }
}


Measured memory_bytes: 23764
use std::io::stdin;

fn main(){
    let mut A = Vec::new();
    let mut B = Vec::new();
    let nm = getvec();
    for _ in 0..nm[0]{A.push(getrow());}
    for _ in 0..nm[1]{B.push(getrow());}
    println!("{}", if solve(&A, &B) {"Yes"} else {"No"});
}

fn solve(A: &Vec<Vec<bool>>, B: &Vec<Vec<bool>>) -> bool{
    let (n, m) = (A.len(), B.len());
    for i in 0..n-m+1{
        'pattern: for j in 0..n-m+1{
            for k in 0..m{
                for l in 0..m{
                    if A[i+k][j+l]!=B[k][l]{
                        continue 'pattern;
                    }
                }
            }
            return true;
        }
    }
    false
}

fn getrow()->Vec<bool>{
    let mut x: Vec<bool> = Vec::new();
    for c in getline().chars(){
        x.push(c=='#');
    }
    x
}

#[allow(dead_code)]
fn getline() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn getvec() -> Vec<i64>{
    let line = getline();
    line.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

Measured memory_bytes: 4352
n,k=map(int,input().split())
a=int(n**0.5)
mod=10**9+7
l=[0]*(a+1)
for i in range(a,0,-1):
    l[i]=i
    l.append(n//i)
for i in range(1,2*a+1):
    l[-i]=l[-i]-l[-i-1]
dp=[l]+[[0]*(2*a+1) for i in range(k-1)]
for i in range(1,k):
    t=0
    for j in range(1,2*a+1):
        t+=dp[i-1][j]
        t%=mod
        dp[i][-j]=t*l[-j]%mod
ans=0
for i in dp[-1][1:]:
    ans+=i
    ans%=mod
print(ans)

Measured memory_bytes: 90760
unittest
{
	assert( [ "4 3", "4 3 -4 -2" ].parse.expand.solve == -8 );		// 追加ケース
	assert( [ "10 40", "-5 -4 -3 -2 1 0 0 0 0 0" ].parse.expand.solve == 6 );		// 追加ケース
	
	assert( [ "4 3", "3 3 -4 -2" ].parse.expand.solve == -6 );
	assert( [ "10 40", "5 4 3 2 -1 0 0 0 0 0" ].parse.expand.solve == 6 );
	assert( [ "30 413", "-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0" ].parse.expand.solve == 448283280358331064 );
	
	assert( ( [ "200000 19999900000" ] ~ iota( 1, 200001 ).map!( ( a ) => a.to!( string ) ).join( " " ) ).parse.expand.solve == 39999800000 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nk[ 1 ], as );
}

auto solve( long k, long[] as )
{
	// マイナス、ゼロ、プラスに分類
	auto as_s = as.sort();
	auto ts = as_s.trisect( 0 );
	auto ms = ts[ 0 ].retro.array;
	auto zs = ts[ 1 ];
	auto ps = ts[ 2 ].array;
	
	// 積がマイナス、ゼロ、プラスになるペアの数を計算
	auto mc = ms.length.signed * ps.length.signed;
	auto pc = ms.length.signed * ( ms.length.signed - 1 ) / 2 + ps.length.signed * ( ps.length.signed - 1 ) / 2;
	auto zc = as.length.signed * ( as.length.signed - 1 ) / 2 - mc - pc;
	
	// 積がマイナスになるペア (m,p) の場合
	if( k <= mc ) return minusK( k, ms, ps );
	k -= mc;
	
	// 積がゼロになるペア (z,m)or(z,z)or(z,p) の場合
	if( k <= zc ) return 0;
	k -= zc;
	
	// 積がプラスになるペア (m,m)or(p,p) の場合
	return plusK( k, ms, ps );
}

auto minusK( long k, long[] ms, long[] ps )
{
	// (m,p)のペアの積のうち、小さい順でK番目に来るものを二分探索
	auto l = -10L ^^ 18;
	auto r = 0L;
	while( l < r )
	{
		auto c = ( l + r - 1 ) / 2;
		auto t = 0L;
		auto i = 0L;
		foreach_reverse( m; ms )
		{
			while( i < ps.length && c < m * ps[ i ] ) i++;
			t += ps.length.signed - i;
		}
		if( t < k ) l = c + 1;
		else        r = c;
	}
	return l;
}

auto plusK( long k, long[] ms, long[] ps )
{
	// (m,m)or(p,p)のペアの積のうち、小さい順でK番目に来るものを二分探索
	auto l = 0L;
	auto r = 10L ^^ 18;
	while( l < r )
	{
		auto c = ( l + r - 1 ) / 2;
		auto t = 0L;
		auto i = 0L;
		foreach_reverse( j, m; ms )
		{
			while( i < ms.length && m * ms[ i ] <= c ) i++;
			t += i - ( j < i );		// (自分,自分)のペアは除外
		}
		i = 0L;
		foreach_reverse( j, p; ps )
		{
			while( i < ps.length && p * ps[ i ] <= c ) i++;
			t += i - ( j < i );		// (自分,自分)のペアは除外

		}
		t /= 2;		// (x,y)と(y,x)で二重カウントしているので半分除外
		if( t < k ) l = c + 1;
		else        r = c;
	}
	return l;
}


Measured memory_bytes: 11440
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

ll n, k;
vector<ll> V;

ll calc(ll nowmax, vector<ll> v) {
  ll cnt[52] = {};
  REP(j, v.size()) {
    for (ll i = nowmax; i >= 0; i--) {
      if ((v[j] & ((ll)1 << i))) {
        cnt[i]++;
      }
    }
  }
  vector<ll> aa;
  for (ll i = nowmax; i >= 0; i--) {
    if (cnt[i] >= k) {
      REP(j, v.size()) {
        if (v[j] & ((ll)1 << i)) {
          aa.pb(v[j]);
        }
      }
      // cout << i << " " << nowmax << endl;
      return calc(i - 1, aa) + ((ll)1 << i);
    }
  }
  return 0;
}

int main() {
  cin >> n >> k;
  V.pb(0);
  REP(i, n) {
    ll p;
    cin >> p;
    V.pb(p);
  }
  vector<ll> imos;
  REP(i, n) {
    V[i + 1] += V[i];
  }
  REP(i, n) {
    REP(j, n) {
      if (i > j) {
        continue;
      }
      imos.pb(V[j + 1] - V[i]);
    }
  }

  for (auto &a : imos) {
    // cout << a << " ";
  }
  // cout << endl;
  cout << calc(50, imos) << endl;
}

Measured memory_bytes: 10616
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
#define CEIL(A,B) ((A)+(B)-1)/(B)
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N;
vector<ll> A;

int main() {
    fastio();
    cin >> N; A.resize(N);
    REP(i, N) cin >> A[i];
    ll ans = 0;
    for(int x = 0; x <= 61; x++) {
        ll cnt = 0;
        REP(i, N) if((A[i] >> x) & 1LL) cnt++;
        ll tmp = (1LL << x) % MOD;
        // cerr << tmp << " " << cnt << endl;
        ans = (ans + tmp * ((cnt * (N - cnt)) % MOD) % MOD) % MOD;
    }
    cout << ans << endl;
	return 0;
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts

int main()
{
  int n;cin>>n;
  vector<bool> ptable(56000,true);
  ptable[0]=false;
  ptable[1]=false;
  int i,j;
  for(i=2;i<ptable.size();i++)
  {
    for(j=2*i;j<ptable.size();j+=i)ptable[j]=false;
  }
  int ans=0;
  i=2;
  while(ans<n)
  {
    if(ptable[i]&&(i%10==1))
    {
      if(ans!=0)cout<<' ';
      cout<<i;
      ans++;
    }
    i++;
  }
  cout<<endl;
}


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

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

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

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

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

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

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    ll n, k; cin >> n >> k;
    vi a(n);
    rep(i,n) cin >> a[i];

    vvi next(110, vi(n));
    rep(i,n) next[0][i] = a[i] - 1;
    rep(i,100){
        rep(j,n){
            next[i+1][j] = next[i][next[i][j]];
        }
    }
    int cur = 0;
    rep(i,100){
        if(k <= 0) break;
        if(k & 1) cur = next[i][cur];
        k >>= 1;
    }
    cout << cur+1 << endl;
    return 0;
}

Measured memory_bytes: 91152
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<math.h>
#include<algorithm>
using namespace std;

#define INF 987654321
#define ll long long

int X, K, Q;
vector<ll> fen(100101), seg(400404), lazy(400404);
vector<int> r(100101), res(100101);
vector<pair<pair<int, int>, int> > q;
vector<pair<int, int> > q2;

ll Init(int n, int l, int r)
{
	if (l == r) return seg[n] = q[l].first.first;
	int mid = (l + r) / 2;
	return seg[n] = Init(n * 2, l, mid) + Init(n * 2 + 1, mid + 1, r);
}

void Propagate(int n, int l, int r)
{
	if (l != r)
	{
		lazy[n * 2] += lazy[n];
		lazy[n * 2 + 1] += lazy[n];
	}
	seg[n] += lazy[n];
	lazy[n] = 0;
}

ll Query(int L, int R, int n, int l, int r)
{
	Propagate(n, l, r);
	if (r < L || R < l) return 0;
	if (L <= l && r <= R) return seg[n];
	int mid = (l + r) / 2;
	return Query(L, R, n * 2, l, mid) + Query(L, R, n * 2 + 1, mid + 1, r);
}

ll Update(int L, int R, int val, int n, int l, int r)
{
	Propagate(n, l, r);
	if (r < L || R < l) return seg[n];
	if (L <= l && r <= R)
	{
		lazy[n] += val;
		Propagate(n, l, r);
		return seg[n];
	}
	int mid = (l + r) / 2;
	return seg[n] = Update(L, R, val, n * 2, l, mid) + Update(L, R, val, n * 2 + 1, mid + 1, r);
}

/*
ll Sum(int idx)
{
   ll ret = 0;
   while (idx)
   {
	  ret += fen[idx];
	  idx &= (idx - 1);
   }
   return ret;
}

void Add(int idx, int val)
{
   while (idx <= Q)
   {
	  fen[idx] += val;
	  idx += idx & -idx;
   }
}
*/

int main()
{
	scanf("%d %d", &X, &K);
	for (int i = 0; i < K; i++)
		scanf("%d", &r[i]);
	r[K] = 1'000'000'001; //더미 추가

	scanf("%d", &Q);
	for (int i = 0; i < Q; i++)
	{
		int t1, t2;
		scanf("%d %d", &t1, &t2);
		q.push_back({ { t2, t1 }, i }); //res[i]
	}
	sort(q.begin(), q.end()); // a순 정렬

	for (int i = 0; i < Q; i++)
		q2.push_back({ q[i].first.second, i }); //q[i]
	sort(q2.begin(), q2.end()); // 시간순 정렬

	Init(1, 0, Q - 1);

	int before = 0, ansP = 0, lo = 0, hi = Q - 1, type = -1;
	ll lval = 0, hval = X;
	//type 정방향은 -1 역방향은 1, (lo, hi)
	for (int i = 0; i <= K; i++)
	{
		while (ansP < Q && q2[ansP].first <= r[i]) //정답 적기, 틀린 이유(1)
		{
			int qi = q2[ansP].second;
			ll val;

			if (qi < lo) val = lval;
			else if (qi > hi) val = hval;
			else val = Query(qi, qi, 1, 0, Q - 1);
			val += type * (q2[ansP].first - before);
			if (val < 0) val = 0;
			if (val > X) val = X;
			res[q[qi].second] = (int)val;

			ansP++;
		}

		Update(0, Q - 1, type * (r[i] - before), 1, 0, Q - 1);
		lval += type * (r[i] - before);
		if (lval < 0) lval = 0;
		if (lval > X) lval = X;
		hval += type * (r[i] - before);
		if (hval < 0) hval = 0;
		if (hval > X) hval = X;

		while (lo <= hi)
		{
			ll val = Query(lo, lo, 1, 0, Q - 1);
			if (val < 0) lo++;
			else break;
		}
		while (lo <= hi)
		{
			ll val = Query(hi, hi, 1, 0, Q - 1);
			if (val > X) hi--; //틀린 이유(2)
			else break;
		}

		before = r[i];
		type *= -1;
	}

	for (int i = 0; i < Q; i++)
		printf("%d\n", res[i]);

	return 0;
}

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

int X;
bool a=false;
void func(){
  for(int i=-200;i<201;i++){
    for(int j=-200;j<201;j++){
      if(pow(i,5)-pow(j,5)==X){
        cout << i << " " << j << endl;
        a=true;
        return ;
      }
    }
  }
}
int main(){
  cin >> X;
  func();
}

Measured memory_bytes: 4064
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };


int main() {
	string s;
	int x, y;
	cin >> s;
	int n = s.size();
	cin >> x >> y;

	vector<int>X;
	vector<int>Y;
	int temp = 0;
	bool fl = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'T') {
			if (!fl) {
				X.push_back(temp);
			}
			else {
				Y.push_back(temp);
			}
			temp = 0;
			if (fl)fl = 0;
			else fl = 1;
		}
		else if (i == s.size() - 1) {
			temp++;
			if (!fl) {
				X.push_back(temp);
			}
			else {
				Y.push_back(temp);
			}
		}
		else {
			temp++;
		}
	}

	if (Y.size() != 0) {
		vector< vector<int> >x_ok(X.size(), vector<int>(16200, 0));
		x_ok[0][8100 + X[0]]++;

		rep(i, 1, X.size()) {
			rep(j, 0, 16200) {
				if (x_ok[i - 1][j] > 0) {
					x_ok[i][j + X[i]]++;
					x_ok[i][j - X[i]]++;
				}
			}
		}




		vector< vector<int> >y_ok(Y.size(), vector<int>(16200, 0));
		y_ok[0][8100 + Y[0]]++;
		y_ok[0][8100 - Y[0]]++;

		rep(i, 1, Y.size()) {
			rep(j, 0, 16200) {
				if (y_ok[i - 1][j] > 0) {
					y_ok[i][j + Y[i]]++;
					y_ok[i][j - Y[i]]++;
				}
			}
		}

		if (x_ok[X.size() - 1][x + 8100] > 0 && y_ok[Y.size() - 1][y + 8100] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		if (y == 0 && x == X[0]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 502784
N, M = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(M)]

exred = [i == 0 for i in range(N)]
n_ball = [1] * N

for i, (xi, yi) in enumerate(xy):
    exred[yi - 1] = exred[xi - 1] | exred[yi - 1]
    n_ball[xi - 1] -= 1
    n_ball[yi - 1] += 1
    if n_ball[xi - 1] == 0: exred[xi - 1] = False

ans = sum([int(item == True) for item in exred])
print(ans)

Measured memory_bytes: 29848
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll powmod(ll m, ll p, ll mod) {
    if (p == 0) return 1;
    ll tmp = powmod(2, p / 2, mod);
    if (p & 1) return (tmp * tmp % mod) * m % mod;
    else return tmp * tmp % mod;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    string x; cin >> x;
    ll cnt1 = 0;
    for (ll i = 0; i < n; i++) if (x[i] == '1') cnt1++;

    V< V<int> > edges(200001);
    for (int i = 200000; i >= 1; i--) {
        edges[i % (int)__builtin_popcount(i)].emplace_back(i);
    }
    V<int> dist(200001, INF); dist[0] = 0;
    queue<int> que; que.push(0);
    while (!que.empty()) {
        int q = que.front(); que.pop();
        for (int e: edges[q]) {
            dist[e] = dist[q] + 1;
            que.push(e);
        }
    }

    ll cnt1m = cnt1 - 1, cnt1p = cnt1 + 1;
    ll popm = 0, popp = 0;
    for (ll i = 0; i < n; i++) {
        if (x[i] == '0') continue;
        ll bbb = n - i - 1;
        if(cnt1m != 0) (popm += powmod(2, bbb, cnt1m)) %= cnt1m;
        (popp += powmod(2, bbb, cnt1p)) %= cnt1p;
    }

    for (ll i = 0; i < n; i++) {
        if (x[i] == '1') {
            if (cnt1m == 0) {
                cout << 0 << '\n';
                continue;
            }
            // 1個減る
            ll tmprem = powmod(2, n - i - 1, cnt1m);
            tmprem = (popm - tmprem + cnt1m) % cnt1m;
            cout << dist[tmprem] + 1 << '\n';
        } else {
            ll tmprem = powmod(2, n - i - 1, cnt1p);
            tmprem = (popp + tmprem) % cnt1p;
            cout << dist[tmprem] + 1 << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 10204
#include <stdio.h>
#include <math.h>
int main(){
   
  int n,s[1000],i;
  double ave,result,Save[1000];
   
  while(1){
     
    scanf("%d",&n);
     
    if(n != 0){
 
      ave=result=0;
       
      for(i = 0; i < n; i++){
     
    scanf("%d",&s[i]);
     
    ave += s[i];
     
      }
       
      ave=ave/n;
       
      for(i = 0; i < n; i++){
     
    Save[i]=s[i]-ave;
     
    result += Save[i]*Save[i];
       
      }
       
      result=result/n;
       
      result=sqrt(result);
       
      printf("%.5lf\n",result);
       
    } else {
       
      break;
       
    }
     
  }
   
  return 0;
 
}


Measured memory_bytes: 2048
import scipy.sparse.csgraph
L=lambda:list(map(int,input().split()))
n,m=L()
s=[n*[float("inf")]for _ in range(n)]
d=[L()for _ in range(m)]
for a,b,c in d:s[a-1][b-1]=s[b-1][a-1]=c
x=scipy.sparse.csgraph.floyd_warshall(s)
print(sum(c!=x[a-1][b-1]for a,b,c in d))

Measured memory_bytes: 14216
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
#define MAX_N 1000000
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r); // n * (n-1) * ... * (n-r+1)
  ans = (ans * finv[r]) % mod; // フェルマーの小定理
  return ans;
}
int main() {
  int X, Y;
  cin >> X >> Y;
  int a = (2*Y-X)/3;
  int b = (2*X-Y)/3;
  if(a < 0 || b < 0 || a+2*b!=X || 2*a+b!=Y) cout << 0 << endl;
  else {
    make();
    cout << comb(a+b, min(a, b)) << endl;
  }
  return 0;
}


Measured memory_bytes: 23680
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>
using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
typedef vector<int> vi;
typedef pair<int,int> vii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

const int no=4e5+5;
const int modulo=1e12+7;
int a[no]={},bb[no]={},vsd[no]={},suma[no]={};
stack<int> S;
stack<int> ma;

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------*/

signed main()
{
    night_rider
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);

    int t=1; //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        if(n%1000==0) cout<<0<<en;
        else
            cout<<1000-(n%1000);
    }
}


Measured memory_bytes: 3612
import sys
n=int(input())
s=[input() for i in range(n)]
c=[0,0,0,0,0]
cnt=0
ans=0
for i in s:
	if i[0] == 'M':
		c[0]+=1
	elif i[0] == 'A':
		c[1]+=1
	elif i[0] == 'R':
		c[2]+=1
	elif i[0] == 'C':
		c[3]+=1
	elif i[0] == 'H':
		c[4]+=1
	else:
		cnt+=1
if n-cnt < 3:
	print(ans)
	sys.exit()
for i in range(5):
	for j in range(i+1,5):
		for k in range(j+1,5):
			ans+=c[i]*c[j]*c[k]
print(ans)

Measured memory_bytes: 9776
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(b-a == c-b ? "YES" : "NO");
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  string s;
  cin >> s;
  if(s[0] == s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

using namespace std;
using ll = long long;

int main(int argc, char** argv)
{
  int n, k; cin >> n >> k;
  vector<int> h(n);
  for(int& i : h) cin >> i;
  sort(h.begin(), h.end());
  ll ans = 0;
  for (int i = 0; i < n-k; i++) ans += h[i];
  cout << ans << endl;
  return 0;
}
  


Measured memory_bytes: 1024
using System;

namespace dp
{
    class Program
    {
        static int[] ReadNumList()
        {
            var line = Console.ReadLine().Split(' ');
            var numList = new int[line.Length];
            for (var i = 0; i < line.Length; ++i)
            {
                numList[i] = int.Parse(line[i]);
            }
            return numList;
        }
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ');
            var k = int.Parse(nk[1]);
            var hList = ReadNumList();
            var cList = new int[hList.Length];
            for (var i = 1; i < hList.Length; ++i)
            {
                var min = int.MaxValue;
                for (var j = i - 1; j >= 0 && j >= i - k; --j)
                {
                    var cost = cList[j] + Math.Abs(hList[i] - hList[j]);
                    min = Math.Min(min, cost);
                }
                cList[i] = min;
            }
            Console.WriteLine(cList[cList.Length - 1]);
        }
    }
}


Measured memory_bytes: 35420
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long ans(){if(n==1)return m<=2?m%2:m-2;if(n==2)return 0;return (n-2)*(m-2);}
int main(){
	scanf("%lld%lld",&n,&m);if(n>m)swap(n,m);
	printf("%lld\n",ans());
	return 0;
}


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


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

  vector<int> nums(n);

  
  for (int i=0;i<n;i++){
    cin >> nums[i];
  }

  int min,max;
  long long sum = 0;


  min = *min_element(nums.begin(), nums.end());
  max = *max_element(nums.begin(), nums.end());
  
  
  for (int i = 0; i < n;i++){
    sum += nums[i];
  }
  cout << min << " " << max << " " << sum << endl;
}




Measured memory_bytes: 3136
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    seika s;
    cin >> n >> s;
    for (int i = 0; i < n / 2; i++)
    {
        if (s[i] != s[i + n / 2])
        {
            cout << "No" << endl;
            return;
        }
    }
    cout << (n & 1 ? "No" : "Yes") << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>//"M_PI"→円周率(小数点以下5桁)
#include<iomanip>//fixed<<setprecision(15)<<
#define rep(i,n) for(int i=0;i<(n);i++)
#define LL long long
#define E "\n"
#define PI 3.141592653589793


int main(){
  int N,K;
  int sum=0;
  cin>>N>>K;
  vector<int> P(N);
  rep(i,N){
    cin>>P[i];
  }
  sort(P.begin(),P.end());
  rep(i,K){
    sum+=P[i];
  }
  cout<<sum<<E;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n;
    cin >> n;

    string s;
    if (n == 25) {
        s = "Christmas";
    } else if (n == 24) {
        s = "Christmas Eve";
    } else if (n == 23) {
        s = "Christmas Eve Eve";
    } else if (n == 22) {
        s = "Christmas Eve Eve Eve";
    }

    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int n, p[200000], count = 1, min;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	min = p[0];
	for (int i = 1; i < n; i++) {
		if (p[i] < min) {
			min = p[i];
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
import math
import bisect

def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    max_val = 0
    val = 0
    for i in range(n):
        val += A[i]
        if i >= m:
            val -= A[i-m]
        if i >= m - 1:
            max_val = max(max_val, val)
    max_val = (max_val + m) / 2
    print('%.10f' % max_val)

if __name__ == "__main__":
    main()


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

using namespace std;

#define pb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define pii pair<int, int>

int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 998244353;
const int maxn = 4e3+10;
const int N = 1e5+10;
const int E = 2e5+10;  
ll n;
string s;
ll cnt[maxn][3];

map<char,int>m;

int main(){
	m['R'] = 0;
	m['G'] = 1;
	m['B'] = 2;
	cin>>n;
	cin>>s;
	for(int i=n-2;i>=0;i--){
		if(s[i+1]=='R'){
			cnt[i][0] = cnt[i+1][0]+1;
			cnt[i][1] = cnt[i+1][1];
			cnt[i][2] = cnt[i+1][2];
		}
		else if(s[i+1]=='G'){
			cnt[i][0] = cnt[i+1][0];
			cnt[i][1] = cnt[i+1][1]+1;
			cnt[i][2] = cnt[i+1][2];
		}
		else if(s[i+1]=='B'){
			cnt[i][0] = cnt[i+1][0];
			cnt[i][1] = cnt[i+1][1];
			cnt[i][2] = cnt[i+1][2]+1;
		}
	}
	//cout<<cnt[0][0]<<cnt[0][1]<<cnt[0][2]<<endl;
	ll ans = 0;
	F(i,0,n-3){
		F(j,i+1,n-2){
			if(s[j]==s[i]) continue;
			ans+=cnt[j][3-m[s[i]]-m[s[j]]];
			if(2*j-i<n&&s[j+(j-i)]!=s[i]&&s[j+(j-i)]!=s[j]){
				ans--;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3700
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

string S;
int N;
int arr[100005];

void construct()
{
	for(int i = 1; i <= N - 2; i++)
	{
		if(arr[i] == 0)	// sheep
		{
			if(S[i] == 'o')
				arr[i + 1] = arr[i - 1];
			else
				arr[i + 1] = !arr[i - 1];
		}
		else
		{
			if(S[i] == 'o')
				arr[i + 1] = !arr[i - 1];
			else
				arr[i + 1] = arr[i - 1];
		}
	}

	// for(int i = 0; i < N; i++)
	// {
	// 	cout << arr[i];
	// }
	// cout << "\n";
}

bool satisfied()
{
	for(int i = 0; i < N; i++)
	{
		int next = (i + 1) % N;
		int prev = ((i - 1) + N) % N;

		if(arr[i] == 0)
		{
			if(S[i] == 'o')
			{
				if(arr[next] != arr[prev])
					return 0;
			}
			else
			{
				if(arr[next] == arr[prev])
					return 0;
			}
		}
		else
		{
			if(S[i] == 'o')
			{
				if(arr[next] == arr[prev])
					return 0;
			}
			else
			{
				if(arr[next] != arr[prev])
					return 0;
			}
		}
	}
	return 1;
}

int main()
{
	int i, j;

	si(N);

	cin >> S;

	int s, e;

	fl(s,0,2)
	{
		fl(e,0,2)
		{
			arr[0] = s;
			arr[1] = e;
			construct();
			if(satisfied())
			{
				fl(i,0,N)
				{
					if(arr[i] == 0)
						printf("%c", 'S');
					else
						printf("%c", 'W');
				}
				return 0;
			}
		}
	}

	printf("-1\n");


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 896
int main(){
  char s[101],t[101],tmp[3];
  int i,x,ans=0,j;
  scanf("%s%s",s,t);
  x=strlen(s);
  for(i=0;i<=x;i++){
    if(strcmp(s,t)==0){
      ans=1;
      break;
    }
    tmp[0]=s[x-1];
    for(j=x-1;j>=1;j--){
      s[j]=s[j-1];
    }
    s[0]=tmp[0];
  }
  if(ans==1)
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for (int i=(a-1);i>=(b);--i)
#define rrep(i,n) rrepd(i,n,0)
typedef long long ll;
typedef pair<int, int> P;


int main(int argc, const char * argv[]) {

  int a, b;
  cin >> a >> b;
  if (a > 9 | b > 9){
    cout << -1 << endl;
    return 0;
  }
  cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<stdio.h>
int main(void){
  int x,count[4]={0,0,0,0};
  char str[3];
  while(scanf("%d,%s",&x,str)!=EOF){
    if(str[0]=='B')count[1]++;
    else if(str[0]=='O')count[3]++;
    else {
      if(str[1]=='B')count[2]++;
      else count[0]++;
    }
  }
  for(x=0;x<4;x++)
    printf("%d\n",count[x]);
  return 0;
}

Measured memory_bytes: 0
N = int(input())

ans = N
for i in range(N + 1):
    nine, pvt = 0, i
    while pvt > 0:
        nine += pvt % 9
        pvt //= 9

    six, pvt = 0, N - i
    while pvt > 0:
        six += pvt % 6
        pvt //= 6
    
    ans = min(ans, nine + six)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin >> n;
	if(n == 0){
		cout << 0 << endl;
	}
	else if(n % 2 == 1){
		cout << 0 << endl;
	}
	else{
		n = n / 2;
		ll cnt = 0;
		while(n){
			cnt += n / 5;
			n /= 5;
		}
		cout << cnt << endl;
	}
}		

Measured memory_bytes: 256
import math

MOD = 1000000007

def normalize(p):
  if p[0] == 0:
    return (0, 1)
  if p[1] == 0:
    return (1, 0)
  if p[0] < 0:
    p = (-p[0], -p[1])
  g = math.gcd(p[0], abs(p[1]))
  return (p[0] // g, p[1] // g)

def enemy(p):
  return normalize((-p[1], p[0]))

n=int(input())
solo=0
groups=dict() #groups[p] = k <=> グループpにk匹イワシ
for _ in range(n):
  x,y=map(int, input().split())
  if x == 0 and y == 0:
    solo += 1
  else:
    p = normalize((x,y))
    groups[p] = groups.get(p, 0) + 1
# print(groups)

ans = 1
done=set()
for p in groups:
  q = enemy(p)
  if p in done or q in done:
    continue
  pcnt, qcnt = groups[p], groups.get(q, 0)
  # print(f"{p}*{pcnt} {q}*{qcnt}")
  mul = pow(2, pcnt, MOD) + pow(2, qcnt, MOD) + MOD - 1
  ans = ans * mul % MOD
  done.add(p)
  done.add(q)

ans = (ans + solo + MOD - 1) % MOD
print(ans)
    

Measured memory_bytes: 168428
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        double ave = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            ave += a[i];
        }
        ave /= n;
        double b[] = new double[n];
        for (int i = 0; i < n; i++) {
            b[i] = Math.abs(a[i] - ave);
        }
        double min = b[0];
        int mini = 0;
        for (int i = 1; i < n; i++) {
            if (min > b[i]) {
                min = b[i];
                mini = i;
            }
        }
        System.out.println(mini);
    }

}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,x,y,n = 1;
    double s = 0;
    cin >> N;
    int A[N][2];
    for(int i = 0; i < N; i++)
    {
        cin >> A[i][0] >> A[i][1];
    }
    for(int i = 0;i < N;i++)
    {
        for(int j = 0;j < N;j++)
        {
            x = pow((A[i][0]-A[j][0]),2);
            y = pow((A[i][1]-A[j][1]),2);
            s += sqrt(x + y);
        }
    }
    s = s/N;
    cout << fixed <<setprecision(10) <<  s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,M;
  while(1) {
    cin >> H >> M;
    for ( int i = 0; i < H; i++ ){
    for ( int j = 0; j < M; j++ ){
        if(i*j>=1&&i<=(H-2)&&j<=(M-2)){
           cout<<".";
        }
        else {
          cout<<"#";
        }
}
    cout<<endl;
    if(H==0&&M==0) {
      break;
    }
}
    if(H==0&&M==0) {
      break;
    }
    cout<<endl;
}
           }
            



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

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

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

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

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

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

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

signed main(){
  int N;cin>>N;
  int S=0,ans=0;
  vector<int> A(N),B(N);
  vector<P> pairs(N);
  REP(i,0,N)cin>>A[i];
  REP(i,0,N)cin>>B[i];
  REP(i,0,N){
    pairs[i].first=A[i];
    pairs[i].second=B[i];
    if(A[i]<B[i]){
      ans++;
      S+=A[i]-B[i];
    }
  }
  sort(ALL(pairs),[](auto a,auto b){
    return a.first-a.second>b.first-b.second;
  });
  REP(i,0,N){
    if(S>=0)br;
    ans++;
    if(pairs[i].first-pairs[i].second<=0){
      print(-1);
      re 0;
    }
    S+=pairs[i].first-pairs[i].second;
  }
  print(ans);



}


Measured memory_bytes: 3328
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func main() {
  N := NextInt()
  A := NextIntVec()
  S := make([]int, N + 1)
  for i, a := range A {
    S[i + 1] = S[i] + a
  }
  D := map[int]int{}
  for _, s := range S {
    _, ok := D[s]
    if ok {
      D[s]++
    } else {
      D[s] = 1
    }
  }
  cnt := 0
  for _, v := range D {
    cnt += v * (v - 1) / 2
  }
  Write(cnt)
  Output()
}

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

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

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (S[i].at(j) == '#')
            {
                continue;
            } else
            {
                int ans = 0;
                if (i > 0)
                {
                    if ((j > 0 ) && (S[i - 1].at(j - 1) == '#'))
                    {
                        ans++;
                    }
                     if (S[i - 1].at(j) == '#')
                    {
                        ans++;
                    }
                    if ((j < W - 1) && (S[i - 1].at(j + 1) == '#'))
                    {
                        ans++;
                    }

                }
                if ((j > 0 ) && (S[i].at(j - 1) == '#'))
                {
                    ans++;
                }
                if ((j < W - 1) && (S[i].at(j + 1) == '#'))
                {
                    ans++;
                }
                if (i < H - 1)
                {
                    if ((j > 0 ) && (S[i + 1].at(j - 1) == '#'))
                    {
                        ans++;
                    }
                    if (S[i + 1].at(j) == '#')
                    {
                        ans++;
                    }
                    if ((j < W - 1 ) && (S[i + 1].at(j + 1) == '#'))
                    {
                        ans++;
                    }

                }
                
                S[i].at(j) = to_string(ans)[0];
            }
            
            
        }
        
    }

    for (int i = 0; i < H; i++)
    {
        cout << S[i] << endl;
    }

      return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int n = sc.nextInt();
        int[] a = new int[n+2];
		int[] x = new int[n+2];
        for(int i = 1; i<n+1; i++)
        {
            a[i] = sc.nextInt();
          	x[i] = 0;
        }

        int count = 0;
        int sum = 0;
        List<Integer> b = new ArrayList<>();

        for(int i = n; i > 0; i--){
            sum = 0;
            for(int j=2; j < n+1;j++){
              if(j*i > n){
                break;
              }
              else{
              	sum = sum + x[i*j];
              }
            }
            sum = sum%2;

            if(sum!=a[i]){
              	x[i] = 1;
                b.add(i);
            }
        }

        System.out.println(b.size());
        for(int i = 0; i < b.size(); i++)
        {
            if(i == b.size()-1)
            {
                System.out.println(b.get(i));
            }
            else
            {
                System.out.print(String.valueOf(b.get(i)) + " ");
            }
        }
        
    }
}

Measured memory_bytes: 93764
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = A[0]//2
flag = 0
numofdiv2 = 0
for s in range(A[0]):
    if A[0] % 2 == 0:
        numofdiv2 += 1
        A[0] //= 2
    else:
        break

for i in range(1, N):

    if A[i] % (2**numofdiv2) != 0 or A[i] % (2**(numofdiv2+1)) == 0:
        flag = 1
        break
    gcd = fractions.gcd((A[i] // 2), lcm_half)
    lcm_half = (lcm_half * (A[i] // 2)) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    M -= lcm_half
    ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)


Measured memory_bytes: 16280