akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N, std::vector<long long> X){
    sort(ALL(X));
    ll ans = INF;
    for(ll p = X[0]; p <= X[N-1]; p++){
        ll tmp = 0;
        for(auto x: X){
            tmp += (x-p)*(x-p);
        }
        ans = min(ans, tmp);
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i,n) for(int i = 0;  i < n ; ++i)
#define REP(i,a,b) for(int i = a ; i <= b ; ++i)
#define filei freopen("input.txt", "r", stdin);
#define fileo freopen("output.txt", "w", stdout);
#define gooi cout<<"Case #"<<i+1<<" :";
#define s(n) scanf("%d",&n)
#define rev(i,n) for(int i = n ; i >= 0 ; --i)
#define REV(i,a,b) for(int i = a ; i >= b ; --i)
#define miN(a,b) (((a)<(b))?(a):(b))
#define sc(n) scanf("%c",&n)
#define tr(c,i) for(typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define INF 1000000000
#define pii pair<long long int,long long int>
#define pb(a) push_back(a)
#define F first
#define S second
typedef long long ll;
using namespace std;
const long long int mod = 998244353;
long long int power(long long int x,long long int y){  
    long long int res = 1;
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % mod;  
        y = y>>1;
        x = (x*x) % mod; 
    }  
    return res;
}  
long long int inv(long long int a){return power(a,mod-2);}
long long int add(long long int a,long long int b){return (a+b)%mod;}
long long int sub(long long int a,long long int b){return (a-b+mod)%mod;}
long long int mul(long long int a,long long int b){return (a*b)%mod;}
long long int divi(long long int a,long long int b){return (a*inv(b))%mod;}
void pre(){}
ll dp[3001][3001]{0};
void solve(){
    ll n,t;cin>>n>>t;
    ll arr[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n+1);
    dp[0][0]=power(2,n);
    for(int i=1;i<=n;i++){
        for(int j=0;j<=3000;j++){
            dp[i][j]=dp[i-1][j];
        }
        for(int j=0;j<=3000;j++){
            if(arr[i]+j<=3000){
                dp[i][arr[i]+j]+=divi(dp[i-1][j],2);
                dp[i][arr[i]+j]%=mod;
            }
        }
    }
    cout<<dp[n][t]<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}





Measured memory_bytes: 73988
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string.h>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int a[100010], b[100010];
	int n, h; cin >> n >> h;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n, greater<int>());
	sort(b, b + n, greater<int>());
	for (int i = 0; i < n; i++) {
		if (a[0] < b[i]) {
			sum += b[i];
		}
		else {
			sum += a[0];
		}
		if (sum >= h) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	int count = n;
	if ((h - sum) % a[0] == 0) {
		count += (h - sum) / a[0];
	}
	else {
		count += (h - sum) / a[0] + 1;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
vector<int>pat[5050];
bool flag[5050];
#define SIZE 100000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
ll ip2[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = ip2[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
		ip2[i] = ip2[i - 1] * ((mod + 1) / 2) % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
vector<ll>merge(vector<ll>a, vector<ll>b)
{
	vector<ll>r;
	r.resize(a.size() + b.size() - 1);
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < b.size(); j++)
		{
			r[i + j] = (r[i + j] + a[i] * b[j]) % mod;
		}
	}
	return r;
}
vector<ll>calc(int node)
{
	flag[node] = true;
	vector<ll>r;
	r.push_back(0);
	r.push_back(1);
	for (int i = 0; i < pat[node].size(); i++)
	{
		if (flag[pat[node][i]])continue;
		vector<ll>z = calc(pat[node][i]);
		r = merge(r, z);
	}
	for (int i = 2; i < r.size(); i += 2)r[0] = (r[0] + mod - r[i] * kai[i] % mod*invkai[i / 2] % mod*ip2[i / 2] % mod) % mod;
	return r;
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num - 1; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		pat[za].push_back(zb), pat[zb].push_back(za);
	}
	invinit();
	vector<ll>r = calc(0);
	printf("%lld\n", (mod - r[0]) % mod);
}

Measured memory_bytes: 4480
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
import math
N=i1()
x=[]
for i in range(N):
 z=i2()
 x.append([math.atan2(z[1],z[0]),z])

x.sort()
a=0
for i in range(N):
 s1=[0,0]
 aa=0
 for j in range(N):
   y1=(i+j)%N
   s1[0]+=x[y1][1][0]
   s1[1]+=x[y1][1][1]
   aa=max(aa,math.sqrt(s1[0]**2+s1[1]**2))
   
 a=max(a,aa)
 
print('{:.12f}'.format(a))

Measured memory_bytes: 39280
#include <cstdio>
#include <cstring>

using namespace std;

typedef unsigned long long ull;
const ull B = 1e9+7;
char s[1111111];
int len;
ull a[1111111];
ull h[1111111];
ull Bh[1111111];

int main(void) {
  scanf("%s", s);
  len = strlen(s);

  Bh[0] = 1;
  for (int i = 0; i < len; i++) {
    h[i+1] = h[i]*B + s[i];
    Bh[i+1] = Bh[i]*B;
  }

  /*
  for (int i = 0; i < len; i++) {
    printf("%c %20llu\n", s[i], h[i+2]-h[i]*B*B);
  }
  */

  int res = -1;
  for (int i = 1; i*3 < len; i++) {
    if ((len - i*3)%2 != 0 || len - i*3 <= 0) continue;
    int al = i;
    int bl = (len - i*3)/2;
    // printf("%d %d\n", al, bl);
    // printf("%llu [%d, %d]=%llu\n", h[al], al+bl, al+bl + al, h[al+bl + al]-h[al+bl]*Bh[al]);
    if (h[al] == h[al+bl + al]-h[al+bl]*Bh[al] &&
        h[al+bl + al]-h[al+bl]*Bh[al] == h[al*2+bl*2+al]-h[al*2+bl*2]*Bh[al] &&
        h[al+bl]-h[al]*Bh[bl] == h[al*2+bl + bl]-h[al*2+bl]*Bh[bl]) {
      if (res == -1 || res > al+bl) {
        res = al+bl;
      }
      /*
      for (int i = 0; i < al+bl; i++) {
        printf("%c", s[i]);
      }
      puts("");
      */
    }
  }

  if (res < 0) {
    puts("mitomerarenaiWA");
  } else {
    printf("Love ");
    for (int i = 0; i < res; i++) {
      printf("%c", s[i]);
    }
    puts("!");
  }
  return 0;
}

Measured memory_bytes: 19344
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class A
{
    static void Main()
    {
        int[] intRecord = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
        var N = intRecord[0];
        var M = intRecord[1];
        Console.WriteLine(N > M ? "No": "Yes");
    }
}

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

int money(int a) {
  if(a == 1) {
    return 300000;
  } else if(a == 2) {
    return 200000;
  } else if(a == 3) {
    return 100000;
  } else {
    return 0;
  }
}

int main() {
  int X, Y;
  cin >> X >> Y;

  int total = money(X) + money(Y) + ((X == 1 && X == Y) ? 400000 : 0);
  cout << total << endl;

  return 0;
}

Measured memory_bytes: 256
# include <stdio.h>
int a[200000+3], n;
bool small(int i, int j, int k) {return a[i]<=k && a[j]<=k;}
bool big(int i, int j, int k) {return a[i]>k && a[j]>k;}
bool judge(int k)
{
    for(int i=0; i<n-1; ++i)
    {
        // if(big(n+i, n+i+1, k) || big(n-i, n-i-1, k)) return false;
        if ( ( a[n+i] > k && a[n+i+1] > k ) || ( a[n-i] > k && a[n-i-1] > k ) ) return false ;
        //if(small(n+i, n+i+1, k) || small(n-i, n-i-1, k)) return true;
        if ( ( a[n+i] <= k && a[n+i+1] <= k ) || ( a[n-i] <= k && a[n-i-1] <= k ) ) return true ;
    }
    //return small(1,1,k);
    return ( a[1] <= k && a[1] <= k ) ;
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<n<<1; ++i)
        scanf("%d",&a[i]);
    int l=1, r=(n<<1)-1, mid;
    while(l < r)
    {
        mid = l+r>>1;
        if(judge(mid))
            r = mid;
        else
            l = mid + 1;
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 896
import sys
import fractions
def input(): return sys.stdin.readline().rstrip()
import math

def main():
    n,x=map(int,input().split())
    X=[int(_) for _ in input().split()]
    X.append(x)
    X.sort()
    ans=X[1]-X[0]
    for i in range(1,n):
        ans=fractions.gcd(ans,X[i+1]-X[i])
    print(ans)

if __name__=='__main__':
    main()

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

using namespace std;

int main(){
string str;
cin>>str;
map<char,int> is;
set<char>il;
for(int i = 0;i<str.size();i++){
    is[str[i]]++;
    il.insert(str[i]);
}
int cnt=0;
for(auto i : is){
     if(i.second%2==0){
            cnt++;
     }
}
if(cnt==il.size()) puts("Yes");
else puts("No");
return 0;
}


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

int euclidean_gcd(int a, int b) {
  if(a < b) euclidean_gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(void){
  int a, b, c, d;
  std::cin >> a >> b >> c >> d;

  int x = c-a>=0?c-a:a-c;
  int y = d-b>=0?d-b:b-d;


  int gcd = euclidean_gcd(y,x);
  int count = y+x-gcd;

  std::cout << count << std::endl;

  return 0;
}






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

int main(){
    int a, b ,c; cin >> a >> b >> c;
    int can = false;
    for(int i = 1; i < b; i++){
        if(i * a % b == c) can = true;
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;

long gcd(long a, long b);
long lcm(long a, long b);

int main(){
  vector<long> a,b;
  long c,d;
  while(cin >> c >> d){
    a.push_back(c);
    b.push_back(d);
  }
  
  for(int i=0; i<a.size(); i++){
    cout << gcd(a[i],b[i]) << " " << lcm(a[i],b[i]) << endl;
  }

  return 0;
}

long gcd(long a, long b){
  long tmp;
  while(a%b != 0){
    tmp = a;
    a = b;
    b = tmp%b;
  }
  return b;
}

long lcm(long a, long b){
  long c=a,d=b;
  while(a != b){
    if(a > b){
      b+=d;
    }else{
      a+=c;
    }
  }
  return a;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,m;
int head[maxn],nex[maxn<<2],to[maxn<<2],cnt,col[maxn];
void add(int u,int v)
{
	to[++cnt]=v;nex[cnt]=head[u];head[u]=cnt;
}
LL I,p,q;
bool vis[maxn],flag;
void dfs(int x)
{
	vis[x]=1;
	for(int i=head[x];i;i=nex[i])
	{
		if(!vis[to[i]]) col[to[i]]=col[x]^1,dfs(to[i]);
		else if(col[to[i]]==col[x]) flag=1; 
	}
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		int u=read(),v=read();
		add(u,v);add(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		flag=0;
		if(!head[i]) I++;
		else if(!vis[i])
		{
			dfs(i);
			if(flag) p++;
			else q++;
		}
	}
	printf("%lld\n",I*I+I*(n-I)*2+p*q*2+p*p+q*q*2);
	return 0;
}


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

int main() {
    int N, K;
    int h;
    int counter = 0;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> h;
        if(h >= K){
            counter++;
        }
    }
    cout << counter;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int add(int x, int y) {
	return x + y;
}
int jian(int x, int y) {
	return x - y;
}
int main() {
	int a[10], i, j, k;
	char sign[2] = { '+','-' };
	int(*p[2])(int, int) = { add,jian };
	for (i = 0; i < 4; i++) scanf("%1d", a + i);
    int sum=a[0];
	for (i = 0; i < 2; i++) {
		for (j = 0; j < 2; j++) {
			for (k = 0; k < 2; k++) {
				sum = p[k](p[j](p[i](sum,a[1]),a[2]),a[3]);
				if (sum == 7) goto label;
				else sum = a[0];
			}
		}
	}
label:
	printf("%d%c%d%c%d%c%d=7", a[0], sign[i], a[1], sign[j], a[2], sign[k], a[3]);
    
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int X;
    scanf("%d", &X);
    if(X==3) {printf("YES\n");}
    else if(X==5) {printf("YES\n");}
    else if(X==7) {printf("YES\n");}
    else {printf("NO\n");}
    return 0;}


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


void solve(long long N, long long D, std::vector<std::vector<long long>> X){
    int res = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            ll d = 0;
            for (int k = 0; k < D; k++) {
                d += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            ll s = sqrt(d + 1e-9);
            if (s * s == d) {
                res++;
            }
        }
    }
    cout << res << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    std::vector<std::vector<long long>> X(N, std::vector<long long>(D));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < D ; j++){
            scanf("%lld",&X[i][j]);
        }
    }
    solve(N, D, std::move(X));
    return 0;
}


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

int main(){
int N,T,A;
   cin>>N>>T>>A;
  vector<int>H(N);
  vector<double>kion(N);
  for(int i=0; i<N; i++){
    cin>>H[i];
    kion[i]=abs(A-(T-H[i]*0.006));
  }
  
  int m=0;
  for(int i=0; i<N; i++){
   if(kion[m]>kion[i]){m=i;} 
  }
  cout<<m+1;
  
}

Measured memory_bytes: 256
#include <iostream>


int main()
{
	int N;

	std::cin >> N;
	std::cout << std::endl;

	int num = 0;

	for (int i = 1; i <= N; ++i)
	{
		for (int j = 1; j <= N; j *= 100)
		{
			for (int k = 1; k != 10; ++k)
			{
				if (i / j == k)
				{
					num++;
					break;
				}
			}
		}
	}

	std::cout << num << std::endl;

	return 0;
}

Measured memory_bytes: 256
x,n = gets.chomp.split.map(&:to_i)
p = gets.chomp.split.map(&:to_i)

if !p.include?(x)
  p x
  exit
end

1.upto(100) do |i|
  xx = x-i
  if !p.include?(xx)
    p xx
    exit
  end

  xxx = x+i
  if !p.include?(xxx)
    p xxx
    exit
  end
end


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

using str = string;
using ss = stringstream;

#define fi first
#define se second

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

    str s;cin>>s;

    int ans=1000;

    for(int i=0;i<26;i++)
    {
        int maxn=0;
        int pos=-1;
        for(int j=0;j<s.size();j++)if(s[j]==i+'a')
        {
            maxn=max(maxn,j-pos-1);
            pos=j;
        }
        maxn=max(maxn,(int)(s.size()-pos-1));
        ans=min(ans,maxn);
    }

    cout<<ans<<"\n";

    return 0;
}


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

int main(){
	int n;
    cin >> n;
    VI e(n/2), o(n/2);
    rep(i,n){
        if(i%2 == 0) cin >> e[i/2];
        if(i%2 == 1) cin >> o[i/2];
    }

    sort(e.begin(), e.end());
    sort(o.begin(), o.end());

    vector<P> el(1, P(0,-1));
    vector<P> ol(1, P(0,-1));

    rep(i,n/2){
        if(el.empty() || el.back().second != e[i]){
            P p;
            p.first = 1;
            p.second = e[i];
            el.push_back(p);
        }else{
            el.back().first++;
        }

        if(ol.empty() || ol.back().second != o[i]){
            P p;
            p.first = 1;
            p.second = o[i];
            ol.push_back(p);
        }else{
            ol.back().first++;
        }
    }

    sort(el.begin(), el.end(), greater<P>());
    sort(ol.begin(), ol.end(), greater<P>());

    int ans=0;
    if(el[0].second != ol[0].second){
        ans = n - (el[0].first + ol[0].first);
    }else{
        int x = el[0].first + ol[1].first;
        int y = el[1].first + ol[0].first;
        ans = n - max(x,y);
    }

    cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for (Int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    string result = "";
    for (Int i = 0; i < n; ++i) {
        result += s[i];
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3592
n = int(input())

a,b,c = [],[],[]

for i in range(n):
    i = list(map(int, input().split()))
    a += [i[0]]
    b += [i[1]]
    c += [i[2]]

prea, preb, prec = a[0], b[0], c[0]

for i in range(1, n):
    prea, preb, prec = max(preb, prec) + a[i], max(prea, prec) + b[i], max(preb, prea) + c[i]

print(max(prea, preb, prec))


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

int main(){
  int a,b;
  cin >> a >> b;
  string s="";
  s=to_string(a)+to_string(b);
  int n=stoi(s);
  cout << (sqrt(n)==int(sqrt(n))?"Yes":"No") << endl;
}

Measured memory_bytes: 3672
//
//  main.cpp
//  complete_binary_tree
//
//  Created by ???????????? on 2017/10/16.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>

using namespace std;

int n;

void print(int A[]){
    int idx;
    for(int i = 1; i <= n; i++){
        cout <<"node "<<i<<": ";
        cout <<"key = "<<A[i]<<", ";
        if(i/2 >= 1){
            idx = i/2;
            cout <<"parent key = "<<A[idx]<<", ";
        }
        if(i*2<=n){
            idx = 2*i;
            cout <<"left key = "<<A[idx]<<", ";
        }
        if(i*2+1 <=n){
            idx = 2*i+1;
            cout <<"right key = "<<A[idx]<<", ";
        }
        cout <<endl;
        
    }
}

int main(int argc, const char * argv[]) {
    int i;
    scanf("%d", &n);
    int A[n+1];
    for(i = 1; i <= n; i++){
        scanf("%d", &A[i]);
    }
    
    print(A);

    return 0;
}

Measured memory_bytes: 3152
def bomb(x,y):
    s=M[y]
    if s[x]=="0":return
    M[y]=s[:x]+"0"+s[x+1:]
    R=[-3,-2,-1,1,2,3]
    for e in R:
        bomb(x+e,y)
        bomb(x,y+e)
    return

A=range(14)
B=range(3,11)
M=["0"*14 for i in A]
z="000"
N=range(input())
for i in N:
    s=raw_input()
    for j in B:
        M[j]=z+raw_input()+z
    x=input()+2
    y=input()+2
    bomb(x,y)
    print "Data %d:" %(i+1)
    for j in B:
        print M[j][3:-3]

Measured memory_bytes: 4284
import java.util.*;

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

    int H = in.nextInt();
    int W = in.nextInt();
    int A = in.nextInt();
    int B = in.nextInt();

    int[][] ans = new int[H][W];

    // Fill row
    for (int i = 0; i < H; i++) {
      int count = 0;
      for (int j = 0; j < W; j++) {
        if (count < A) {
          ans[i][j] = 0;
          count++;
        } else {
          ans[i][j] = 1;
        }
      }
    }

    // Flip for column
    for (int i = 0; i < B; i++) {
      for (int j = 0; j < W; j++) {
        if (ans[i][j] == 0) {
          ans[i][j] = 1;
        } else {
          ans[i][j] = 0;
        }
      }
    }

    StringBuilder s = new StringBuilder();
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (ans[i][j] == 0) {
          s.append("0");
        } else {
          s.append("1");
        }
      }
      s.append("\n");
    }
    System.out.printf("%s", s);
  }

  public static int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);

  }

  public static long gcd(long a, long b) {
    if (b == 0) return a;
    return gcd(b, a % b);
  }
}

Measured memory_bytes: 39232
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
	ll A,B;
	cin >> A >> B;
	if(B%A == 0)cout << A+B << endl;
	else cout << B-A << endl;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

void solve() {
  string s, t; cin >> s >> t;
  int ans = 1e9, n = s.size(), m = t.size();
  for (int pos = 0; pos + m - 1 < n; pos++) {
    int res = 0;
    for (int i = 0; i < m; i++)
      res += (s[pos + i] != t[i]);
    ans = min(ans, res);
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

// Range Chmin Point Get
struct SegTree {
    int sz;
    vector<int> dat;
    SegTree(int n, int INF = 1 << 30) {
        for(sz = 1; sz < n;)
            sz <<= 1;
        dat.assign(sz << 1, INF);
    }
    void update(int l, int r, int x) {
        for(l += sz, r += sz; l < r; l >>= 1, r >>= 1) {
            if(l & 1) dat[l] = min(dat[l], x), l++;
            if(r & 1) --r, dat[r] = min(dat[r], x);
        }
    }
    int get(int k) {
        k += sz;
        int res = dat[k];
        while(k >>= 1)
            res = min(res, dat[k]);
        return res;
    }
};

int n, q;

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

    cin >> n >> q;
    ll ans = 1LL * (n - 2) * (n - 2);

    SegTree sx(n, n - 2), sy(n, n - 2);

    while(q--) {
        int t, x;
        cin >> t >> x;
        x--;
        if(t == 1) {
            int y = sx.get(x);
            sy.update(1, 1 + y, x - 1);
            ans -= y;
        } else {
            int y = sy.get(x);
            sx.update(1, 1 + y, x - 1);
            ans -= y;
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define N 100

int main(void){

  int n, A[N];
  int i, j, key;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
    if(i) printf(" %d",A[i]);
    else  printf("%d", A[i]);
  }
  printf("\n");

  for(i=1; i<n; i++){
    key=A[i];
    j=i-1;

    while(j >= 0 && A[j] > key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;

    for(j=0; j<n; j++){
      if(j) printf(" %d", A[j]);
      else  printf("%d", A[j]);
    }
    printf("\n");
  }
  
  return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;

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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order
//order_of_key

const int maxn = 1e6 + 5;

const int N = 55555;
//const int N = 100;
bool sieve[N+1];

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

  sieve[0]=sieve[1]=true;
  for (int i=2; i*i<=N; i++) {
    if (!sieve[i]) {
      for (int j=i*i; j<=N; j+=i) {
	sieve[j]=true;
      }
    }
  }

  vector<int> primes;

  for (int i=2; i<=N; i++) {
    if (!sieve[i]) primes.push_back(i);
  }

  
  int n; cin>>n;
  for (int i=0; n>0; i++) {
    if (primes[i]%10 == 1) {
      cout<<primes[i]<<" ";
      n--;
    }
  }
  cout<<endl;
  

  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(void)
{
   char s1[200],s2[200];
   scanf("%s%s",s1,s2);
   int l,h,i,j;
   l=strlen(s1);
   h=strlen(s2);
   if(l>h)
      printf("GREATER\n");
   else if(l<h)
      printf("LESS\n");
   else
   {
      j=0;
      for(i=0;i<l;i++)
      {
         if(s1[i]<s2[i])
         {
            j=1;
            printf("LESS\n");
            break;
         }
         else if(s1[i]>s2[i])
         {
            j=1;
            printf("GREATER\n");
            break;
         }
      }
      if(j==0)
         printf("EQUAL\n");
   }
   return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); //3つのキャンディーパックを２人に分ける
        int a = sc.nextInt(); //キャンディーa
        int b = sc.nextInt(); //キャンディーb
        int c = sc.nextInt(); //キャンディーc
        
        if(a+b==c || b+c==a || a+c==b){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }     
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define ASSERT(expr...) assert((expr))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
using ll = long long;

constexpr i64 INF = 1010000000000000017LL;

constexpr i64 MOD = 1000000007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

ll mod_pow(ll x, ll n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        return mod_pow(x * x % MOD, n / 2) % MOD;
    } else {
        return x * mod_pow(x, (n - 1)) % MOD;
    }
}

ll mod_pow_r(ll x, ll n) {
    if (x == 0) return 0;
    if (n == 0) return 1;

    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n /= 2;
    }
    return ret;
}

ll factorial(ll n) {
    ll ret = 1;
    REP(i, n) {
        ret *= (i + 1);
        ret %= MOD;
    }
    return ret;
}

ll combination(ll n, ll r) {
    if (n < 0 || n < r || r < 0) return 0;
    ll fn = factorial(n);
    ll fr = factorial(r);
    ll fn_r = factorial(n-r);

    ll d = (mod_pow(fr, MOD - 2) * mod_pow(fn_r, MOD - 2)) % MOD;
    ll u = fn % MOD;
    return u * d % MOD;
}

bool isPrime(int x) {
    if (x < 2) return false;
    if (x == 2) return true;
    for (int i = 2; (i * i) < x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}

void solve() {
    int x; cin >> x;
    int max_x = 100010;
    for (int i = x; i < max_x; ++i) {
        if (isPrime(i)) {
            cout << i; break;
        }
    }
}

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

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

using namespace std;

const int N = 123456;

int n, a[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n, greater<int>());
  for (int i = 1; i <= n; ++i) {
    if (a[i] >= i && a[i + 1] < i + 1) {
      int u = !(a[i] - i & 1), j = i + 1;
      while (a[j] == i) {
        ++j;
      }
      --j;
      int r = !(j - i & 1);
      cout << ((u & r) ? "Second" : "First") << '\n';
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 640
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;

#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back

typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned uint;
typedef unsigned long long ull;

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

unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 Rand(seed);
uniform_int_distribution<ll> range(0, 1ll << 32);
inline void ucin() {
   ios::sync_with_stdio(0); cin.tie(0);
}

const int N = 4e5 + 10;
const int mod = 1e9 + 7;

int qpow(int a, int b) {
   int ans = 1;
   for(; b >= 1; b >>= 1, a = (ll) a * a % mod)
      if(b & 1) ans = (ll) ans * a % mod;
   return ans;
}

int main() {
   int l, r, d;
   cin >> l >> r >> d;
   cout << (r / d - (l-1) / d) << endl;
   return 0;
} 


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
const double bit =  380000.0;
int main(){
  int n;
  double x, ans = 0;
  string u;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x >> u;
    if(u == "JPY") ans += x;
    else ans += x * bit;
  }
  cout << ans << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}



void smain() {


    int n;
    cin>>n;
    int cnt=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        cnt+=a%2;
    }
    if(cnt%2==1)
        cout<<"NO";
    else
        cout<<"YES";



}


Measured memory_bytes: 256
i = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる
A = i[0] #出力：i_1
B = i[1] #出力：i_2

if A >= 13:
    print(B)
elif A >= 6:
    print(int(B/2))
else:
    print(0)

Measured memory_bytes: 3060
import std.stdio;
import std.array;
import std.algorithm;
import std.conv;
import std.numeric;
import std.string;

void main() {
  int N = readln.chomp.to!int;
  long[] L = new long[N + 1];

  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; ++i) L[i] = L[i - 1] + L[i - 2];

  L[N].writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=101234;

int n,k,a[101];
ll dp[nmax],dp2[nmax];

int main()
{
    scanf("%d %d",&n,&k);
    for(int i=0; i<n; ++i)
    {
        scanf("%d",&a[i]);
    }
    dp2[0]=dp[0]=1;
    for(int i=0; i<n; ++i)
    {
        for(int j=1; j<=k; ++j)
        {
            dp2[j]=(dp2[j-1]+dp[j])%MOD;
            if(j-a[i]>0)
                dp[j]=dp2[j]-dp2[j-1-a[i]];
            else
                dp[j]=dp2[j];
            if(dp[j]<0)
                dp[j]+=MOD;
        }
    }
    printf("%lld",dp[k]);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#define int long long
using namespace std;
signed main(){
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	for(int i=0;i<=n-1;i++){
		if((b-a)>=(c*(n-1-i)-d*i) && (b-a)<=((n-1-i)*d-c*i)){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nn 20
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair

int n,m;
pii link[nn*nn];

int cnt[1<<nn];int dep[nn];int topa[nn],pa[nn];
vector<int> v[nn],c[nn];
void dfs(int x,int p)
{
	dep[x]=dep[p]+1;pa[x]=p;
	for(int i=0;i<v[x].size();i++)
	{
		int y=v[x][i];
		if(y!=p)topa[y]=c[x][i],dfs(y,x);
	}
}


int solve(int x,int y)
{
	int mask=0;
	while(x!=y)
	{
		if(dep[x]<dep[y]) swap(x,y);
		mask|=1<<topa[x],x=pa[x];
	}
	return mask;
}

ll dp_tms[1<<nn],dp_val[1<<nn];

void add(ll &x,ll y) {x=(x+y)%mod;}
int noway[1<<nn];

ll fib[100*nn],rf[100*nn];
ll qpow(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}

int main()
{
	rf[0]=fib[0]=1;for(int i=1;i<100*nn;i++) fib[i]=fib[i-1]*i%mod,rf[i]=qpow(fib[i],mod-2);
	
	
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) 
	{
		int x,y;scanf("%d%d",&x,&y);x--,y--;
		link[i]=mp(x,y);
		if(i<n) v[x].push_back(y),v[y].push_back(x),c[x].push_back(i-1),c[y].push_back(i-1);
	} 
	
	dfs(0,-1);
	
	for(int i=n;i<=m;i++) cnt[solve(link[i].first,link[i].second)]++;
	
	for(int i=1;i<(1<<nn);i<<=1)
		for(int j=0;j<(1<<nn);j+=i+i)
			for(int k=j;k<j+i;k++)
				cnt[k+i]+=cnt[k];
	int S=1<<n-1;
	dp_tms[S-1]=1;
	
	for(int i=S-1;i>=0;i--)
		for(int j=0;j<n-1;j++)
			if((1<<j)&i)
			{
				int ava=cnt[i]-cnt[i^(1<<j)];
				int alr=m-(cnt[i]+__builtin_popcount(i));

				ll tms=dp_tms[i]*fib[alr+ava]%mod*rf[alr]%mod;
				ll val=dp_val[i]*fib[alr+ava+1]%mod*rf[alr+1]%mod;
				add(dp_tms[i^(1<<j)],tms);
				add(dp_val[i^(1<<j)],val+tms*(n-__builtin_popcount(i)) );
			}
	
	cout<<dp_val[0]<<"\n";
	return 0;
}


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

using namespace std;

int main()
{
    //for (int s=0; s<10; s++)
    //{
    //    for (int d=1; d<20; d++)
    //    {
    //        for (int i=0; i<100; i++)
    //        {
    //            if (min(i, abs(i-d)) > s)
    //            {
    //                cout<<s<<" "<<d<<" "<<i-1<<" "<<endl;
    //                break;
    //            }
    //        }
    //    }
    //    cout<<endl;
    //}

    int N, D;
    cin>>N>>D;
    vector<int> d(N);
    for (int &t: d)
        cin>>t;
    vector<int> A(N+1);
    A[0] = D;
    for (int i=0; i<N; i++)
    {
        A[i+1] = min(A[i], abs(A[i]-d[i]));
    }

    vector<long long> S(N+1);
    long long s = 0;
    for (int i=N-1; i>=0; i--)
    {
        //R[i] = A[i]>s;
        if (d[i]<=s*2+1)
            s += d[i];
        S[i] = s;
    }
    S[N] = 0;

    //for (int i=1; i<=N; i++)
    //    cout<<i<<" "<<A[i-1]<<" "<<S[i]<<" "<<(A[i-1]>S[i])<<endl;
    int Q;
    cin>>Q;
    for (int i=0; i<Q; i++)
    {
        int q;
        cin>>q;
        q--;
        cout<<(A[q]>S[q+1] ? "YES" : "NO")<<endl;
    }
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(i+k<=n)
		{
			if(a[i]<a[i+k])
			cout<<"Yes"<<endl;
			else
			cout<<"No"<<endl;
		}
		else
		return 0;
	}
}

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

int main() {
    int K;
    cin>>K;
    vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << vec.at(K-1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=500010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int h,w;
multiset<int> Q; map<int,int> f;
#define gg map<int,int>::iterator
signed main()
{
    h=read(), w=read();
    for(ri int i=0;i<w;i++) f[i]=i, Q.insert(0);
    for(ri int i=0;i<h;i++)
    {
        int L,R;
        L=read(), R=read();
        gg qwq=f.lower_bound(L-1);
        int pc=-1;
        while(qwq!=f.end()&&(qwq->first)<=R)
        {
            pc=max(pc,qwq->second);
            Q.erase(Q.find(qwq->first-qwq->second));
            f.erase(qwq++);
        }
        if((~pc) && R^w)
        {
            Q.insert(R-pc);
            f[R]=pc;
        }
        if(Q.empty()) puts("-1");
        else printf("%lld\n",i+1+(*Q.begin()));
    }
    return 0;
}

Measured memory_bytes: 25504
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
S = [None]*(H+4)
S[0] = S[1] = S[H+2] = S[H+3] = ["#"]*(W+4)
for i in range(2, H+2):
    S[i] = ["#"] + ["#"] + list(input()) + ["#"] + ["#"]

cost = [[-1 for _ in range(W+3)] for _ in range(H+3)]

Ch += 1
Cw += 1
Dh += 1
Dw += 1

# bfs

warp_times = 0

def warp(i, j, cost, warp_times, q):
    change = 0
    for h in range(i-2, i+3):
        for w in range(j-2, j+3):
            # print(h, w, i, j)
            # print(S[h][w])
            if S[h][w] == "." and cost[h][w] == -1:
                q.append([h, w])
                cost[h][w] = warp_times + 1
                change = 1
    
    return change

q = deque()
q.append([Ch, Cw])

while True:
    

    same_cost = list()
    no_change = 1

    while len(q):
        # print(q)
        now = q.popleft()
        i = now[0]
        j = now[1]

        cost[i][j] = warp_times
        same_cost.append([i, j])

        if S[i][j-1] == "." and cost[i][j-1] == -1:
            q.append([i, j-1])
            cost[i][j-1] = warp_times
        if S[i][j+1] == "." and cost[i][j+1] == -1:
            q.append([i, j+1])
            cost[i][j+1] = warp_times
        if S[i-1][j] == "." and cost[i-1][j] == -1:
            q.append([i-1, j])
            cost[i-1][j] = warp_times
        if S[i+1][j] == "." and cost[i+1][j] == -1:
            q.append([i+1, j])
            cost[i-1][j] = warp_times
    

    for point in same_cost:
        change = warp(point[0], point[1], cost, warp_times, q)
        if change :
            no_change = 0
    
    warp_times += 1
    
    if no_change:
        break

print(cost[Dh][Dw])


Measured memory_bytes: 163124
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,k;
ll S(ll x){return x*x*x;}
int main()
{
	scanf("%lld%lld",&n,&k);
	ll ans=0ll;
	ans+=S(n/k);
	if(k%2==0)ans+=S((n/(k/2))-n/k);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
typedef long long int ll;
int main()
{
	ll a = 0, b = 0, tmp = 0, r = 0, x = 0;
	scanf("%lld %lld", &a, &b);
	x = a * b;
	  if(a<b){
	    tmp = a;
	    a = b;
	    b = tmp;
	  }

	  r = a % b;
	  while(r!=0){
	    a = b;
	    b = r;
	    r = a % b;
	  }
    printf("%lld\n", x/b);
    return 0;
}


Measured memory_bytes: 128
n = int(input())

_a = 0
b_ = 0
b_a = 0

cnt = 0

for i in range(n):
    s = input()

    sa = False
    sb = False
    if s[0] == "B":
        sb = True
    if s[-1] == "A":
        sa = True

    if sa and sb:
        b_a += 1
    elif sa:
        _a += 1
    elif sb:
        b_ += 1

    for j in range(len(s)-1):
        if s[j:j+2] == "AB":
            cnt += 1

if b_a > 0:
    cnt += b_a - 1
    if _a >= 1:
        _a -= 1
        cnt += 1
    if b_ >= 1:
        b_ -= 1
        cnt += 1

cnt += min(_a, b_)
print(cnt)

Measured memory_bytes: 9124
import static java.lang.System.out;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import java.io.File;
import java.util.List;
import java.util.Scanner;

public class Main extends BaseExe {

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

    @Override
    protected void execute() throws Exception {
        List<Integer> nums = asList(nextLine().split(" ")).stream().map(Integer::parseInt)
                .collect(toList());
        if (nums.get(0) < nums.get(1) && nums.get(1) < nums.get(2))
            out.println("Yes");
        else
            out.println("No");
    }

}

abstract class BaseExe {

    private Scanner scan;

    private String inData;

    public void exeSysIn() {
        try (Scanner scan = new Scanner(System.in)) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void exeFileIn(String inDataPath) {
        try (Scanner scan = new Scanner(new File(inDataPath))) {
            exeCtrl(scan);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void exeCtrl(Scanner scan) throws Exception {
        this.scan = scan;
        execute();
    }

    protected abstract void execute() throws Exception;

    protected String nextLine() {
        return scan.nextLine();
    }

    protected boolean judgeInData() {
        return hasNextLine() && isNotEmptyInData();
    }

    protected boolean hasNextLine() {
        return scan.hasNextLine();
    }

    protected boolean isNotEmptyInData() {
        inData = nextLine();
        return !inData.isEmpty();
    }

    protected String getInData() throws Exception {
        if (inData.isEmpty())
            throw new Exception("inData is Empty.");
        return inData;
    }
}

Measured memory_bytes: 32236