akhauriyash/Code-Regression huggingface dataset:
"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function main(input) {
  var lines = input.split('\n');

  var _splitNum = splitNum(lines.shift()),
      _splitNum2 = _slicedToArray(_splitNum, 2),
      D = _splitNum2[0],
      G = _splitNum2[1];

  var data = lines.slice(0, D).map(function (line) {
    var _splitNum3 = splitNum(line),
        _splitNum4 = _slicedToArray(_splitNum3, 2),
        p = _splitNum4[0],
        c = _splitNum4[1];

    return {
      p,
      c
    };
  });
  var min = Infinity; // check for all completion.

  for (var i = 0; i < Math.pow(2, D); i++) {
    var sum = 0;
    var score = 0;
    var maxnd = -1;

    for (var d = 0; d < D; d++) {
      var used = !!(i & 1 << d);

      if (used) {
        // take all points.
        score += data[d].p * 100 * (d + 1) + data[d].c;
        sum += data[d].p;
      } else {
        maxnd = d;
      }
    }

    if (maxnd >= 0) {
      var dp = data[maxnd].p;
      var taken = Math.ceil(Math.max(0, (G - score) / (100 * (maxnd + 1))));

      if (taken >= dp) {
        // constraint is not satisfied.
        continue;
      }

      sum += taken;
    }

    if (min > sum) {
      min = sum;
    }
  }

  console.log(min);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 7628
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*b) % 2 == 0) {
	 System.out.println("Even");
	} else {
	 System.out.println("Odd");
	}

	}
	
}

Measured memory_bytes: 21844
#include <stdio.h>
#define N 100005
#define NIL -1
 
struct Node{
  int p, l, r;
};
struct Node T[N];
int getDepth(int p);

int main(){
  int n, i, k, j, c;
  int id, tmp;
  int dep[N];
 
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    T[i].l = T[i].p = T[i].r = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d%d", &id, &k);
    for(j = 0; j < k; j++){
      scanf("%d", &c);
      if(j == 0){
    	T[id].l = c;
    	T[c].p = id;
    	tmp = c;
      }
      else{
    	T[tmp].r = c;
    	T[c].p = id;
    	tmp = c;
      }
    }    
  }
  for(i = 0; i < n; i++)
    dep[i] = getDepth(i); 
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, T[i].p, dep[i]);
    if(T[i].p == NIL)
      printf("root, [");
    else if(T[i].l == NIL)
      printf("leaf, [");
    else
    	printf("internal node, [");
    	if(T[i].l != NIL){
    		printf("%d", T[i].l);
   			tmp = T[i].l;
    		while(1){
    			if(T[tmp].r == NIL) break;
    			printf(", %d", T[tmp].r);
    			tmp = T[tmp].r;
    		}
    	}
    	printf("]\n", tmp);
	}
	return 0;
}

int getDepth(int p){
  if(T[p].p == NIL) return 0;
  return getDepth(T[p].p) + 1;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD9, b / 2) % MOD9;
//     else return a * POW(a * a % MOD9, b / 2) % MOD9;
//   }
// }

int main(){
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double HtoM = 5 * H + 5 * M / 60;;
  double diff = max(HtoM, M) - min(HtoM, M);
  double theta = diff * PI / 30;
  if(diff > 30){
    theta = (60 - diff) * PI / 30;
  }
  double DOUBLE;
  DOUBLE = pow(A, 2) + pow(B, 2) - 2 * A * B * cos(theta);
  double ans = sqrt(DOUBLE);
  cout << fixed  << setprecision(16) << ans << endl;
}


Measured memory_bytes: 4216
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main(){
	int n;
	while(scanf("%d",&n),n){
		int m=0,v[4][2] = {{0,-1},{-1,0},{1,-1},{-1,-1}},dp[257][257];
		int map[257][257] = {{0}};
		for(int y=1;y<=n;y++){
			for(int x=1;x<=n;x++){
				scanf("%1d",&map[x][y]);
			}
		}

		for(int i=0;i<4;i++){
			memset(dp,0,sizeof(dp));
			//cout << "--------------------" << endl;//Test
			for(int k=1;k<=n;k++){
				for(int j=1;j<=n;j++){
					dp[j][k] = map[j][k]?map[j][k] + dp[j+v[i][0]][k+v[i][1]]:0;
					//cout << dp[j][k];//Test
					m = max(m,dp[j][k]);
				}
				//cout << endl;//Test
			}
		}
		printf("%d\n",m);
	}
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;

char buf[1<<15],*fs,*ft;
inline char getc() { return (ft==fs&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),ft==fs))?0:*fs++; }
template<typename T>inline void read(T &x)
{
	x=0;
	T f=1, ch=getchar();
	while (!isdigit(ch) && ch^'-') ch=getchar();
	if (ch=='-') f=-1, ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x*=f;
}

int t[2],to[maxn],a[4][maxn];
int main()
{
	int n;read(n);
	for (int i=1; i<=3; ++i)
		for (int j=1; j<=n; ++j) read(a[i][j]);
	for (int i=1; i<=n; ++i)
	{
		to[i]=a[2][i]/3+1;
		if (!((a[1][i]-a[2][i]==-1 && a[2][i]-a[3][i]==-1 && a[1][i]%3==1) || (a[1][i]-a[2][i]==1 && a[2][i]-a[3][i]==1 && !(a[1][i]%3))) || (abs(i-to[i])&1))
		{
            puts("No"); exit(0);
		}
        t[i&1]^=(a[1][i]>a[2][i]);
	}
	for (int i=1; i<=n; ++i)
		while (to[i]^i)
		{
			t[i&1^1]^=1;
			swap(to[i],to[to[i]]);
		}
	puts(t[0] || t[1] ? "No" : "Yes");
	return 0;
}

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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	string S, T; cin >> S >> T;
	int ans = 0;

	rep(i, S.length()) {
		if (S[i] != T[i])ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3912
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;

//vector<vector<ll>> vec(100000,vector<ll>(3,0));
int main(){
  ll n;
  cin >> n;
  ll a[n];
  ll mul=1;
  rep(i,n){
    cin >> a[i];
    mul *= a[i];
  }
  long double bunbo = 0.0;
  rep(i,n){
    bunbo += 1.0 / a[i];
  }
  double ans = 1 / bunbo;
  printf("%.10f",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 20010
using namespace std;
typedef long long ll;
inline ll read()
{
	ll x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge
{
	int u,v,next;
}vs[N*30*2];
int n,st[N*7],ee,las,id[N],nd[N*7],idx[N];
ll X[N],Y[N],V[N];
int dfn[N*7],low[N*7],tim,vis[N*7],op[N],tot,bl[N*7];
stack <int> St;
 
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
 
inline bool cmp(const int a,const int b)
{
	return V[a]<V[b];
}
void built(int l,int r,int rt)
{
	nd[rt]=++las;
	if(l==r)
	{
		addedge(nd[rt],op[l]);
		return ;
	}
	int mid=(l+r)>>1;
	built(l,mid,rt<<1);
	built(mid+1,r,rt<<1|1);
	addedge(nd[rt],nd[rt<<1]);
	addedge(nd[rt],nd[rt<<1|1]);
}
void linkedge(int L,int R,int x,int l,int r,int rt)
{
	if(L<=l&&r<=R)
	{
		addedge(x,nd[rt]);
		return ;
	}
	int mid=(l+r)>>1;
	if(mid>=L) linkedge(L,R,x,l,mid,rt<<1);
	if(mid<R) linkedge(L,R,x,mid+1,r,rt<<1|1);
}
void dfs(int rt)
{
	vis[rt]=1; dfn[rt]=low[rt]=++tim;
	St.push(rt);
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vis[vs[i].v])
		{
			low[rt]=min(low[rt],dfn[vs[i].v]);
		}
		else if(!dfn[vs[i].v])
		{
			dfs(vs[i].v);
			low[rt]=min(low[rt],low[vs[i].v]);
		}
	}
	if(low[rt]==dfn[rt])
	{
		++tot;
		while(St.top()!=rt)
		{
			bl[St.top()]=tot;
			vis[St.top()]=0;
			St.pop();
		}
		St.pop(); bl[rt]=tot; vis[rt]=0;
	}
}
bool check(ll x)
{
	memset(st,0,sizeof st);
	ee=0; las=n+n; tim=0;
	built(1,n+n,1);
	for(int i=1;i<=n+n;i++)
	{
		int pr=upper_bound(V+1,V+1+n+n,V[i]-x)-V;
		int nx=lower_bound(V+1,V+1+n+n,V[i]+x)-V-1;
		if(pr<i) linkedge(pr,i-1,i,1,n+n,1);
		if(nx>i) linkedge(i+1,nx,i,1,n+n,1);
	}
	for(int i=1;i<=las;i++) vis[i]=dfn[i]=low[i]=0;
	for(int i=1;i<=las;i++) if(!dfn[i]) dfs(i);
	for(int i=1;i<=n+n;i++) if(bl[i]==bl[op[i]]) return 0;
	return 1;
}
int main()
{
	//freopen("read.in","r",stdin);
	n=read();
	for(int i=1;i<=n;i++)
		X[i]=read(),Y[i]=read(),
		V[++V[0]]=X[i],id[V[0]]=V[0],
		V[++V[0]]=Y[i],id[V[0]]=V[0];
	sort(id+1,id+1+n+n,cmp);
	for(int i=1;i<=n+n;i++) idx[id[i]]=i;
	for(int i=1;i<=n+n;i++) op[i]=idx[(id[i]&1)? id[i]+1: id[i]-1];
	sort(V+1,V+1+n+n);
	ll l=0,r=1000000000,ans;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 15872
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

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

  print(n * 800 - n / 15 * 200);
}


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


struct Node{
	int point;
	int dis;
	bool done;
	Node *mul;
	Node *add;
};

int main()
{
	int k;
	cin >> k;
	deque<pair<int, int> > c;
	vector<Node> a(k);
	rep(i, k){
		if(i==k-1){
			a[i]={i, INT_MAX, false, &a[(i*10)%k], &a[0]};
			break;
		}
		a[i] = {i, INT_MAX, false, &a[(i*10)%k], &a[i+1]};
	}

	a[1].dis = 1;
	c.push_back(make_pair(1, 1));
	while(c.size()!=0){
		pair<int, int> tmp = c.front();
		c.pop_front();
		// cout << "tmp a[0] "<< a[0].dis << endl;
		if(a[tmp.first].dis > tmp.second){
		a[tmp.first].dis = tmp.second;}
		a[tmp.first].done = true;
		if(a[tmp.first].mul->done == false){
			c.push_front(make_pair(a[tmp.first].mul->point, tmp.second));
			// cout << "muli:" << a[tmp.first].mul->point << " " << tmp.second <<endl;
		}
		if(a[tmp.first].add->done == false){
			c.push_back(make_pair(a[tmp.first].add->point, tmp.second+1));
			// cout << "addi:" << a[tmp.first].add->point << " " << tmp.second+1 <<endl;
		}

		// cout << "tmp2 a[0] "<< a[0].dis << endl;
	}

	cout << a[0].dis << endl;
}



Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
using namespace std;

int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<int64_t> a(x);
    vector<int64_t> b(y);
    vector<int64_t> c(z);
    for(int i=0;i<x;++i)
        cin >> a[i];
    for(int i=0;i<y;++i)
        cin >> b[i];
    for(int i=0;i<z;++i)
        cin >> c[i];

    sort(a.begin(),a.end(),greater<int64_t>());
    sort(b.begin(),b.end(),greater<int64_t>());
    sort(c.begin(),c.end(),greater<int64_t>());

    vector<int64_t> d;

    for(int i0=0;i0<x;++i0)
        for(int i1=0;i1<y;++i1)
            for(int i2=0;i2<z;++i2)
            {
                if((i0+1)*(i1+1)*(i2+1)<=k) 
                    d.push_back(a[i0]+b[i1]+c[i2]);
                else
                    break;
            }

    sort(d.begin(),d.end(),greater<int64_t>());
    for(int i=0;i<k;++i)
        cout << d[i] << endl;

    return 0;
}

Measured memory_bytes: 1404
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        boolean isAns = false;
        for (int i = s.length-1; i >= t.length-1; i--) {
            char[] tmp = s.clone();
            isAns = true;
            for (int j = 0; j < t.length; j++) {
                if (s[i-j] == t[t.length-1-j] || s[i-j] == '?') {
                    tmp[i-j] = t[t.length-1-j];
                } else {
                    isAns = false;
                    break;
                }
            }

            if (isAns) {
                s = tmp;
                break;
            }
        }

        if (isAns) {
            for (char c : s)
                System.out.print(c == '?' ? 'a' : c);
        } else {
            System.out.println("UNRESTORABLE");
        }
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

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

using ll=long long; 

int ketawa(int a){
	int ret=0;
	while(a>0){
		ret+=a%10;
		a/=10;
	}
	return ret;
}

void solve(){
	int n;cin>>n;
	int minv=1000000;
	for(int i=1; i<n; i++){
		int x=ketawa(i)+ketawa(n-i);
		minv=min(minv, x);
	}
	cout<<minv<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
/*input
997764507000
*/

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

int main() {
  ll n;
  cin >> n;
  const ll M = 1e6+5;
  vector<int> used(M);
  ll ans = 0;
  for (int i = 2; i < M; ++i) {
    if (used[i]) continue;
    ll mod = i;
    while (mod < M && n%mod == 0) {
      ans++;
      n /= mod;
      used[mod] = 1;
      mod *= i;
    }
    while (n%i == 0) n /= i;
  }
  if (n > 1) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 7200
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans = []
    s = 0
    for ai in a:
        s = s ^ ai
    for i in range(n):
        ans.append(s ^ (a[i]))
    print(*ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 102904
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart)/CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
int main(){
  int n, m;
  int sum = 0;
  cin >> n;
  m = n;
  while(m){
    sum+=m%10;
    m/=10;
  }
  if(n%sum==0)
    return cout << "Yes", 0;
  return cout << "No", 0;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int f[2][5];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1,x,y,z;i<=n;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        f[1][1]=max(f[0][2],f[0][3])+x;
        f[1][2]=max(f[0][1],f[0][3])+y;
        f[1][3]=max(f[0][1],f[0][2])+z;
        for(int j=1;j<=3;j++)
        {
            swap(f[0][j],f[1][j]);
        }
    }
    printf("%d\n",max(f[0][1],max(f[0][2],f[0][3])));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


ll po(ll a,ll b){return b?power(a*a,b/2)*(b%2?a:1):1;}
int main()
{
    fast();
    ll x;
    cin>>x;
    for(ll i=-1000;i<=1000;i++)
    {
        for(ll j=-1000;j<=1000;j++)
        {
            ll a=po(i,5);
            ll b=po(j,5);

            if(a-b==x)
            {
                cout<<i<<" "<<j<<nl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3568
#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, q;
    seika s;
    cin >> n >> q >> s;
    akari<int> as(n + 1);
    for (int i = 0; i < n - 1; i++)
    {
        as[i + 1] = as[i];
        if (s[i] == 'A' && s[i + 1] == 'C')
        {
            as[i + 1]++;
        }
    }
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        int ans = as[r - 1] - as[l - 1];
        cout << ans << endl;
    }
}

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


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,s=0;
  cin>>n>>k;
  vector<int> l(n);
  for(int i=0;i<n;++i)cin>>l[i];
  sort(l.begin(),l.end(),greater<int>());
  for(int i=0;i<k;++i)s+=l[i];
  cout<<s;
  return 0;
}

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

int main(){
    int N;
    cin >>N;
    int k[N],p[N];
    for(int a= 0;a<N;++a){
    cin >>k[a]>>p[a];
    }
    for(int i =0;i<N;++i){
        if(k[i]%p[i]==0){
            cout <<p[i]<<endl;
    }
        else{ cout << k[i]%p[i] <<endl;
    }
    }
    return 0;
}

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

int main() {
  long long int n;
  cin >> n;
  long long int a[n];
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 2 != 0) {
      count += 1;
    }
    }
    if(count % 2 == 0){
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <ctime>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 1LL << 62
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    if(M % 2 == 1) {
        output("-1");
        return 0;
    }
    vector<int> depth(N, -1);
    vector<int> deg(N, 0);
    vector<pair<int, int>> ret;
    function<void(int, int)> dfs = [&](int cur, int par) {
//        cout << cur << "," << par << endl;
        for(int v: G[cur]) {
//            if(v == par) continue;
            if(depth[v] == -1) {
                depth[v] = depth[cur] + 1;
                dfs(v, cur);
            }
            else if(depth[cur] < depth[v]) {
                ret.pb(mp(cur, v));
                deg[cur]++;
            }
        }
        if(deg[cur] % 2 == 1) {
            ret.pb(mp(cur, par));
            deg[cur]++;
        }
        else if (par != -1) {
            ret.pb(mp(par, cur));
            deg[par]++;
        }
    };
    
    depth[0] = 0;
    dfs(0, -1);
    rep(i, ret.size()) {
        cout << ret[i].first + 1 << " " << ret[i].second + 1 << endl;
    }
    
    return 0;
}



Measured memory_bytes: 17908
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

const int maxn = 2e6 + 5;

char s[maxn], t[maxn];

int mp[30];

int main() {
  //  freopen("a.in", "r", stdin);
  //  freopen("a.out", "w", stdout);
  scanf("%s%s", s, t);
  int ls = strlen(s);
  memset(mp, -1, sizeof(mp));
  for(int i = 0; i < ls; i++) {
    int nows = s[i] - 'a';
    int nowt = t[i] - 'a';
    if(~mp[nowt] && mp[nowt] != nows)
      {puts("No"); return 0;}
    mp[nowt] = nows;
  }
  memset(mp, -1, sizeof(mp));
  for(int i = 0; i < ls; i++) {
    int nows = t[i] - 'a';
    int nowt = s[i] - 'a';
    if(~mp[nowt] && mp[nowt] != nows)
      {puts("No"); return 0;}
    mp[nowt] = nows;
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N := scanInt()

	S := make([]string, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		S[i] = sc.Text()

		sp := strings.Split(S[i], "")
		sort.Strings(sp)
		S[i] = strings.Join(sp, "")
	}

	sort.Strings(S)
	ans := 0
	cnt := 1
	for i := 1; i < N; i++ {
		if S[i] == S[i-1] {
			cnt++
		} else {
			ans += ((cnt) * (cnt - 1)) / 2
			cnt = 1
		}
	}
	ans += ((cnt) * (cnt - 1)) / 2

	fmt.Println(ans)
}


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

int gcd(int m, int n) {
  if (n == 0) return m;
  else return gcd(n, m % n);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int L[N + 1];
  int R[N + 1];
  L[0] = 0;
  R[0] = 0;
  for (int i = 0; i < N; i++) {
    L[i + 1] = gcd(L[i], A[i]);
    R[i + 1] = gcd(R[i], A[N - i - 1]);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(ans, gcd(L[i], R[N - i - 1]));
    ans = max(ans, gcd(L[N - i - 1], R[i]));
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))

def output(a):
    print(" ".join(map(str, a)))


def insertionSort(a:list, n:int):
    for i in range(1, n):
        now = a[i] #未ソート部分の先頭（未ソート部分の左端)
        j = i - 1 #jはiのひとつ前から始まる
        while j >= 0 and a[j] > now: #未ソート部分の先頭(now)より左にあり、かつnowよりも大きい要素を後方に移動するためのループ
            #一つ右にjの位置にある要素を代入
            a[j+1] = a[j]
            #jを左に動かしてwhile条件判定
            j -= 1
        #jの位置にはnowを入れる
        a[j + 1] = now
        output(a)
output(a)       
insertionSort(a, n)


Measured memory_bytes: 5600
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <tuple>
using namespace std;


int main() {
    string s;
    cin>>s;
    bool nine = false;
    for (int i=0; i<s.length(); i++) {
        if (s[i] == '9') nine = true;
    }
    if (nine) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
def main():
    N = int(input())

    i = 1
    sum = 0
    temp = 0
    while True:
        temp = 0
        i += 1
        sum += 1
        for j in range(1,i):
            temp += 26**j

        if N <= temp:
            break

    #文字数はsum
    temp = 0
    for j in range(1,sum):
        temp += 26**j
    #print(N)
    N -= (temp+1)
    #print(N,sum)

    ans = []
    for j in range(sum):
        amari = N%26
        N = N//26
        #print(amari,flag)
        ans.append(amari)

    ans2 = [0]*len(ans)
    dict = {0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j',10:'k',11:'l',12:'m',13:'n',14:'o',15:'p',16:'q',17:'r',18:'s',19:'t',20:'u',21:'v',22:'w',23:'x',24:'y',25:'z'}
    for j in range(sum):
        ans2[sum-1-j] = dict[ans[j]]
    print(''.join(ans2))


main()


Measured memory_bytes: 9236
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>

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

using namespace std;

class union_find{
	vector<int> a;
public:
	union_find(int n):a(n,-1){}
	int find(int x){
		if(a[x]<0) return x;
		return a[x]=find(a[x]);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x!=y){ a[x]+=a[y]; a[y]=x; }
	}
	int size(int x){ return -a[find(x)]; }
};

int main(){
	for(int test=0,n,m;scanf("%d%d",&n,&m),n;test++){
		if(test>0) puts("");

		char lang[30][200];
		rep(i,n) scanf("%s",lang[i]);

		vector<int> a[30];
		rep(i,m){
			int sz; scanf("%d",&sz);
			rep(j,sz){
				char s[200]; scanf("%s",s);
				rep(k,n) if(strcmp(s,lang[k])==0) { a[k].push_back(i); break; }
			}
		}

		int one,p[30];
		for(one=1;one<=5;one++){
			rep(i,n) p[i]=(i<one?1:0);
			do{
				union_find U(m);
				rep(i,n) if(p[i]==1) rep(j,(int)a[i].size()-1) U.unite(a[i][j],a[i][j+1]);
				if(U.size(0)==m) goto YUKO;
			}while(prev_permutation(p,p+n));
		}

		puts("Impossible");
		continue;

		YUKO:
		printf("%d\n",one);
		rep(i,n) if(p[i]==1) puts(lang[i]);
	}

	return 0;
}

Measured memory_bytes: 836
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
ll gcd(ll a, ll b) {
    if(a < b)
        gcd(b, a);
    ll r = 1;
    while(r != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
int main() {
    ll a, b;
    cin >> a >> b;
    cout << a * b / gcd(a, b) << endl;
}


Measured memory_bytes: 256
N,M,X = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
L, R = [], []
for i in a:
    if i < X:
        L.append(i)
    elif X < i:
        R.append(i)

if len(L) > len(R):
    print(len(R))
else:
    print(len(L))

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
int n,i,ans=0,juge=0;
  
 scanf("%d",&n);
  
 char s[n];
  
 scanf("%s",s);
  
 for(i=0;i<n;i++){
    	if(s[i]=='.') {
          ans++;
        }
    }
 juge=ans;
 for(i=0;i<n;i++){
    	if(s[i]=='#') {juge++;}
      	else {juge--;}
      	if(juge<ans) {ans=juge;}
    }
  printf("%d",ans);
	return 0;
}

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

#define _LL long long

int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int* inputint(int n)
{
    int *ans = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

int main()
{
    int n;
    cin >> n;
    int *a = inputint(3 * n);

    multiset<int> left;
    multiset<int> right;

    _LL *leftsum = new _LL[n + 1];
    _LL *rightsum = new _LL[n + 1];

    _LL sum = 0;

    for( int i = 0; i < n; i++ ) 
    {
        left.insert(a[i]);
        sum += a[i];
    }

    leftsum[0] = sum;

    for( int i = 0; i < n; i++ ) 
    {
        auto itr = left.begin();
        if( a[n + i] > *itr )
        {
            sum -= *itr;
            sum += a[n + i];
            left.erase(itr);
            left.insert(a[n + i]);
        }
        leftsum[i + 1] = sum;
    }

    sum = 0;
    for( int i = 0; i < n; i++ ) 
    {
        right.insert(-a[2 * n + i]);
        sum += a[2 * n + i];
    }
    rightsum[n] = sum;
    for( int i = 0; i < n; i++ ) 
    {
        auto itr = right.begin();
        if( -a[2 * n - 1 - i] > *itr )
        {
            sum -= -*itr;
            sum += a[2 * n - 1 - i];
            right.erase(itr);
            right.insert(-a[2 * n - 1 - i]);
        }
        rightsum[n - 1 - i] = sum;
    }

    _LL bestans = leftsum[0] - rightsum[0];
    for( int i = 0; i < n + 1; i++ ) 
    {
//        cout << leftsum[i] << " " << rightsum[i] << endl;
        bestans = max(bestans, leftsum[i] - rightsum[i]);
    }

    cout << bestans;
}

Measured memory_bytes: 15688
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

X = int(input())
di = make_divisors(X)
for i in range(len(di)):
    k = di[i]
    for b in range(-200, 201):
        val = 5 * k * b ** 4 + 10 * k ** 2 * b ** 3 + 10 * k ** 3 * b ** 2 + 5 * k ** 4 * b + k ** 5 - X
        if val == 0:
            a = k + b
            print(a, b)
            exit()


Measured memory_bytes: 66500
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：Round-Robin Scheduling
// 問題文URL：https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_3_B
// 所要時間：
// 学んだこと：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll n, q;
queue<pair<string, ll>> Q;

void solve() {
  ll t = 0; // 時刻
  while (Q.empty() == false) {
    string workName = Q.front().first;
    ll reqTime = Q.front().second; // キューの先頭の所要時間
    if (reqTime <= q) {
      t += reqTime;
      cout << workName << " " << t << endl;
      Q.pop();
    } else {
      t += q;
      reqTime -= q;
      Q.pop();
      Q.push(make_pair(workName, reqTime));
    }
  }
}

int main() {
  cin >> n >> q;
  rep(i, n) {
    string name;
    ll time;
    cin >> name >> time;
    Q.push(make_pair(name, time));
  }
  solve();
  return 0;
}



Measured memory_bytes: 6172
W,H,N=map(int,input().split())
vec=[[False]*W for i in range(H)]
for i in range(N):
  x,y,a=map(int,input().split())
  if a==1:
    for i in range(x):
      for j in range(H):
        vec[j][i]=True
  elif a==2:
    for i in range(x,W):
      for j in range(H):
        vec[j][i]=True
  elif a==3:
    for i in range(W):
      for j in range(y):
        vec[j][i]=True
  else:
    for i in range(W):
      for j in range(y,H):
        vec[j][i]=True
ans=0
for i in range(W):
  for j in range(H):
    if vec[j][i]==False:
      ans+=1
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define mp make_pair
#define ri register int
#define rc register char
#define rb register bool
#define lowbit(x) (x&(-x))
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)

const int N=12,M=1e3+10;
int n,m,f[(1<<N)+10],zt[M],cst[M],tot;

il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}

int main()
{
	//freopen("E.in","r",stdin);freopen("E.out","w",stdout);
	n=read();m=read();tot=(1<<n)-1;rp(i,1,m){cst[i]=read();ri t=read();while(t--){ri tmp=read()-1;zt[i]|=1<<tmp;}}
	memset(f,63,sizeof(f));f[0]=0;
	rp(i,1,m)
		rp(j,0,tot)f[j|zt[i]]=min(f[j|zt[i]],f[j]+cst[i]);
	if(f[tot]==f[tot+1])printf("-1\n");else printf("%d\n",f[tot]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
int t,n,m;
int arr[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		int a;cin>>a;
		arr[a]++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<arr[i]<<endl;
	}
	return 0;
}

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

long long find(long long num){

    long long po = 1LL;
    for(;;){
        if(po > num) break;
        po *= 2;
    }

    return po - num;
}

int main(){

    int n; cin >> n;
    map<long long, long long> M;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        M[-a]++;
    }


    long long ans = 0LL;

    for(auto x : M){
        long long num1 = -x.first;
        long long cnt1 = x.second;
        long long num2 = find(num1);
        long long cnt2 = M[-num2];

        //cout << num1 << " " << cnt1 << " " << num2 << " " << cnt2 << endl;
        if(num1 == num2){
            ans += cnt1 / 2;
        }else if(cnt1 > cnt2){
            ans += cnt2;
            M[-num2] = 0;
        }else{
            ans += cnt1;
            M[-num2] = M[-num2] - cnt1;
        }
        
        //cout << x.first << " " << x.second << endl;
    }

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

Measured memory_bytes: 85504
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;

int64_t N, X;

//a<b
int64_t get_dis(int64_t a, int64_t b){
	if (a>b)  return get_dis(b, a);
	//if (b%a == 0) return 2*b-a;
	//return get_dis(b-a, a)+ 2*a;
	if (a==0) return -b;
	int64_t t = b / a;
	return get_dis(b - t * a, a) + t * a * 2; 
}

int main()
{
	cin >> N >> X;
	cout << get_dis(X, N-X)+N << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input1 = Console.ReadLine().Split(" ");
		int gyou = int.Parse(input1[0]);
		int retu = int.Parse(input1[1]);
		int afterBlack = int.Parse(input1[2]);
		int sumBlack = 0;

		string[] WAB = new string[gyou];

		for (int i = 0; i < gyou; ++i)
		{
			WAB[i] = Console.ReadLine();
		}

		for (int lgyou = 0; lgyou < 1 << gyou; lgyou++)
		{
			for (int lretu = 0; lretu < 1 << retu; lretu++)
			{
				int cnt = 0;
				for (int mgyou = 0; mgyou < gyou; mgyou++)
				{
					for (int mretu = 0; mretu < retu; mretu++)
					{
						if ((lgyou >> mgyou & 1)==1) continue;
						if ((lretu >> mretu & 1)==1) continue;
						if (WAB[mgyou][mretu] == '#') cnt++;

					}
				}
				if (cnt == afterBlack) sumBlack++;
			}
		}



		//出力
		Console.WriteLine(sumBlack);
	}
}

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

int main(){
  int n,d;
  int counter=0;
  cin>>n>>d;
  vector<vector<int>> v(n,vector<int>(d));
  rep(i,n){
    rep(j,d){
      cin>>v.at(i).at(j);
    }
  }

  int sum=0;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      if(i==j) continue;
      sum=0;
      rep(k,d){
        sum+=pow(v.at(i).at(k)-v.at(j).at(k),2);
      }
      if(pow(sum,0.5)==int(pow(sum,0.5))) counter++;
    }
  }
  cout<<counter<<endl;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
const ll p=1000000007;
int main(){
  ll n,ans=0;
  cin >> n;
  ll k[n];
  rep(i,n)cin >> k[i];
  sort(k,k+n);
  ll u[n];
  u[0]=k[0];
  rep(i,n-1)u[i+1]=u[i]+k[i+1];
  if(n%2==0){
    ll y=n/2-1;
    cout << (u[n-1]*2-u[y]-u[y+1])-(u[y]*2-k[y]) << endl;
  }
  else {
    ll y=n/2-1;
    cout << max((u[n-1]*2-u[y]*2-k[y+1]-k[y+2])-(u[y]*2),(u[n-1]*2-u[y+1]*2)-(u[y+1]*2-k[y]-k[y+1])) << endl;
  }
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void bubble_sort(String[] a, int n) {
        int flag = 0; // 完了した場所
        while (flag < n - 1) {
            for (int i = n - 2; i >= 0; i--) {
                if (a[i].charAt(1) - '0' > a[i + 1].charAt(1) - '0') {
                    String temp = a[i + 1];
                    a[i + 1] = a[i];
                    a[i] = temp;
                }

            }
            flag++;
        }
    }

    public static void selection_sort(String a[], int n) {
        for (int i = 0; i < n - 1; i++) {
            int min = a[i].charAt(1) - '0';
            int minflag = i;
            for (int j = i + 1; j < n; j++) {
                if (min > a[j].charAt(1) - '0') {
                    min = a[j].charAt(1) - '0';
                    minflag = j;
                }
            }
            if (minflag != i) {
                String temp = a[i];
                a[i] = a[minflag];
                a[minflag] = temp;
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String a[] = new String[n];
        String b[] = new String[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.next();
            b[i] = a[i];
        }
        bubble_sort(a, n);
        selection_sort(b, n);
        for (int i = 0; i < n; i++) {
            System.out.print(a[i]);
            if (i < n - 1)
                System.out.print(" ");
        }
        System.out.println();
        System.out.println("Stable");
        Boolean ok = true;
        for (int i = 0; i < n; i++) {
            if (a[i] != b[i])
                ok = false;
            System.out.print(b[i]);
            if (i < n - 1)
                System.out.print(" ");
        }
        System.out.println();
        if (ok)
            System.out.println("Stable");
        else
            System.out.println("Not stable");
        sc.close();

    }

}


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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	friend modnum inv(const modnum& m) { return m.inv(); }
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	friend modnum neg(const modnum& m) { return m.neg(); }

	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

template <typename T> T pow(T a, long long b) {
	assert(b >= 0);
	T r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;
}

using num = modnum<int(1e9)+7>;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;

	num ans = pow(num(2), N) - 1;

	for (int z = 0; z < 2; z++) {
		int A; cin >> A;
		num numer = 1, denom = 1;
		for (int i = 0; i < A; i++) {
			numer *= N-i;
			denom *= i+1;
		}
		ans -= numer / denom;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include <string.h>
#define N 51
using namespace std;
vector<int>G[N];
int n,m,low[N],dfn[N];
int father[N];
int tim = 0;
void Tarjan(int i,int Father)
{
    father[i] = Father;
    dfn[i] = low[i] = tim++;
    for(int j = 0;j < G[i].size();++j)
    {
        int k = G[i][j];
        if(dfn[k] == -1)
        {
            Tarjan(k,i);
            low[i] = min(low[i], low[k]);
        }
        else if(Father != k) low[i] = min(low[i], dfn[k]);
    }
}
void count()
{
    Tarjan(1,0);
	int bridge = 0;
    for(int i = 1;i <= n; ++i)
    {
        int v = father[i];
        if(v > 0 && (low[i] > dfn[v])) bridge ++;
    }
    cout << bridge << endl;
}
int main()
{
    cin >> n >> m;
    int a,b;
    for(int i = 1;i <= m;++i)
    {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    memset(dfn, -1, sizeof(dfn));
    memset(father, 0, sizeof(father));
    memset(low, -1, sizeof(low));
    count();
    return 0;
}

Measured memory_bytes: 256
import static java.lang.System.out;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int range = scan.nextInt();
        long min = 0;
        long max = 0;
        long sum = 0;                                                  

        for (int i = 0; i < range; i += 1) {
            int tmp = scan.nextInt();
            if (i == 0) {
                min = tmp;
                max = tmp;
                sum += tmp;
            } else {
                if (min > tmp) {
                    min = tmp;
                }
                if (max < tmp) {
                    max = tmp;
                }
                sum += tmp;
            }
        }

        out.printf("%d %d %d%n", min, max, sum);
    }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int l = 0, r = n;
	cout << 0 << endl;
	string t;
	cin >> t;
	if (t[0] == 'V')return 0;

	while (r - l > 1) {
		int mid = (r + l) / 2;
		cout << mid << endl;
		string s;
		cin >> s;
		if (s[0] == 'V')return 0;
		if (s[0] == t[0]) {
			if (mid % 2)r = mid;
			else l = mid;
		}
		else {
			if (mid % 2)l = mid;
			else r = mid;
		}
	}
}


Measured memory_bytes: 852