akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const int MOD = 1e9+7;
const int MAX_N = 100005;
string s;
ll dp[MAX_N][2];

void solve()
{
	const int N = s.length();
	dp[0][0]=1;
	for(int i=0;i<N;++i)for(int j=0;j<2;++j){
		if(!j){
			for(int x=0;x<2;++x)for(int y=0;y<2;++y){
				if(x+y==2)continue;
				int d = s[i]-'0';
				if(x+y>d)continue;
				(dp[i+1][x+y<d]+=dp[i][j])%=MOD;
			}
		}else{ //already smaller
			dp[i+1][1]=(dp[i+1][1]+3*dp[i][1])%MOD;
		}
	}
	cout << (dp[N][0]+dp[N][1])%MOD << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> s;
	solve();
	return 0;
}

Measured memory_bytes: 2000
#include<stdio.h>
#include<math.h>

void Koch(int n,double p1x,double p1y,double p2x,double p2y){
    if(n <= 0)
        return ;

    double sx = (p1x * 2.0 + p2x) / 3.0,sy = (p1y * 2.0 + p2y) / 3.0;
    Koch(n - 1,p1x,p1y,sx,sy);
    printf("%lf %lf\n",sx,sy);
    double tx = (p1x + p2x * 2.0) / 3.0,ty = (p1y + p2y * 2.0) / 3.0;
    double ux = 0.5 * (tx + sx) - sqrt(3) * 0.5 * (ty - sy),uy = sqrt(3) * 0.5 * (tx - sx) + 0.5 * (ty + sy);
    Koch(n - 1,sx,sy,ux,uy);
    printf("%lf %lf\n",ux,uy);
    Koch(n - 1,ux,uy,tx,ty);
    printf("%lf %lf\n",tx,ty);
    Koch(n - 1,tx,ty,p2x,p2y);

}

int main(void){
    int n;
    scanf("%d",&n);
    printf("0.00000000 0.00000000\n");
    Koch(n,0.0,0.0,100.0,0.0);
    printf("100.00000000 0.00000000");
    return 0;
}

Measured memory_bytes: 2688
S = input()

S1 = S[1::2]
S2 = S[::2]
#print(S1)
#print(S2)

for s1 in S1:
	if s1 == "L":
		continue
	elif s1 == "U":
		continue
	elif s1 == "D":
		continue
	else:
		print("No")
		exit()

for s2 in S2:
	if s2 == "R":
		continue
	elif s2 == "U":
		continue
	elif s2 == "D":
		continue
	else:
		print("No")
		exit()
		
print("Yes")

Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[]) {
	int N, L;
	scanf("%d %d", &N, &L);

	string S[100];
	for (int i = 0; i < N; i++)
	{
		cin >> S[i];
	}

	sort(S, S+N, [](string a, string b) {return a < b; });

	string ans;
	for (int i = 0; i < N; i++)
	{
		ans += S[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
//??????????SM??????????

//  -------------Sourav Mondal----------   
//        _____________________________________"GUN IS ON FIRE~SM"
//..._|.._|___________________, ,) ----)           "KILL YOUR headache Shoot iT"
//....../ `---___________----_____|]_____)     ********* 2eZ4@SM
//...../_==o;;;;;;;;_______.:/ 
//.....), ---.(_(__) /                                   ask2sm*********
//....// (.||_.) ), ----" 
//...//___//
//../|___/|                              
//.||___||
//----------------------------------------------------------------------------
#include<bits/stdc++.h>
using namespace std;
#define llt long long int
#define pb(x) push_back(x)

int printNcR(int n, int r) 
{ 
  
    // p holds the value of n*(n-1)*(n-2)..., 
    // k holds the value of r*(r-1)... 
    long long p = 1, k = 1; 
  
    // C(n, r) == C(n, n-r), 
    // choosing the smaller value 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
  
            // gcd of p, k 
            long long m = __gcd(p, k); 
  
            // dividing by gcd, to simplify product 
            // division by their gcd saves from the overflow 
            p /= m; 
            k /= m; 
  
            n--; 
            r--; 
        } 
  
        // k should be simplified to 1 
        // as C(n, r) is a natural number 
        // (denominator should be 1 ) . 
    } 
  
    else
        p = 1; 

        return p;
    }

int main(){
	int n,m;
	cin>>n>>m;
	if(n==1 && m==1){
		cout<<0<<endl;
		return 0;
	}
	if(n<2 &&m>=2){
		cout<<printNcR(m,2)<<endl;
		return 0;
	}	
	else if(m<2 && n>=2){
		cout<<printNcR(n,2)<<endl;
		return 0;
	}
	cout<<printNcR(n,2)+printNcR(m,2)<<endl;
	int count=0;	
}

Measured memory_bytes: 256
gets
a = gets.chomp.split.map(&:to_i)
n = 0

for i in 0..a.size-2
  min = i
  for j in i+1..a.size-1
    min = j if a[min] > a[j]
  end
  if i != min
    a[i],a[min] = a[min],a[i]
    n += 1
  end
end

puts a*" "
puts n

Measured memory_bytes: 6104
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long l = sc.nextLong();

			BigDecimal b = new BigDecimal(l);

			BigDecimal three = b.divide(new BigDecimal(3), 10, RoundingMode.HALF_UP);

			BigDecimal result = three.multiply(three).multiply(three);

			// 出力(整数)
			System.out.println(result.toPlainString());
		}
	}

	/**
	 * 最小公倍数
	 */
	static long lcm(long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return c / b;
	}

	/**
	 * 最大公約数
	 */
	static long gcd(long a, long b) {
		long temp;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return b;
	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define int long long
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define INF (1LL << 30)
#define pii pair<int, int>
#define MOD 1000000007
#define print(x) cout<<(x)<<endl
using namespace std;


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

    cout<<"Christmas";
    while (d <= 24) {
        cout<<" Eve";
        ++d;
    }
    cout<<endl;

    return 0;
}

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

ll solve(ll a0, ll b0, ll a1, ll b1, int k);
ll solve(ll a, ll b, int k);

ll A, B;
ll solve(ll a0, ll b0, ll a1, ll b1, int k) {
	ll base = 1ll << k;
	if(b0 + 1 >= a1) return base * 2;
	

	if((a1 & base) != 0 && (b0 & base) == 0) {
		int len = -1;
		while(b0 >= (1ll << (len+1) )) len++;
		return b1 - a1 + 1 + (1ll << (len+1));
	}
	if((a1 & base) == 0) {
		ll z = solve(a0, b0, a1, base-1, k-1);
		ll o = base;
		return z+o;
	}
	//else b0 = 1.... (b0 & base) != 0
	ll z = base;
	ll o = base;
	return z+o;
}
ll solve(ll a, ll b, int k) {
	if(a == b) return 1ll;
	ll base = 1ll << k;
	if((a & base) == 0 && (b & base) == 0) return solve(a, b, k-1);
	if((a & base) != 0 && (b & base) != 0) return solve(a-base, b-base, k-1);
	//else b = 1...., a = 0....
	if(k == 0) return 2;

	return solve(a, base-1, k-1) + solve(0, b-base, a, base-1, k-1);
}
int main() {
	cin >> A >> B;
	printf("%lld\n", solve(A, B, 62));
	return 0;
}

Measured memory_bytes: 384
M, K = map(int, input().split())
if K >= (2 ** M):
  print(-1)
elif M == 0:
  print("0 0")
elif M == 1:
  if K == 0:
    print("0 0 1 1")
  else: print(-1)
else:
  print(" ".join(map(str, [i for i in range(2 ** M) if i != K] + [K] + [i for i in range(2 ** M - 1, -1 , -1) if i != K] + [K])))

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


int main(){  
  char c;
  cin >> c;
  if (65<=c&&c<=90){
    cout << "A";
  }else{
    cout << "a";
  }

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N;
    std::cin >> N;

    long double kMax = 1000000000000000000LL;

    std::vector<long double> As;
    for (int64_t i = 0; i < N; ++i) {
        long double A;
        std::cin >> A;
        if (A == 0) {
            std::cout << 0 << std::endl;
            return 0;
        }
        As.push_back(A);
    }

    long double ans = 1;
    for (auto A : As) {
        ans *= A;
        if (ans > kMax) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    std::cout << static_cast<int64_t>(ans) << std::endl;

    return 0;
}

Measured memory_bytes: 5424
while True:
	a,op,b=input().split()
	if op=="?":
		break
	if op=="+":
		print(int(a)+int(b))
	if op=="-":
		print(int(a)-int(b))
	if op=="*":
		print(int(a)*int(b))
	if op=="/":
		print(int(a)//int(b))

Measured memory_bytes: 7604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    llong x, y;
    cin >> x >> y;
    for (int i = 0; ; ++i, x <<= 1) {
        if (x > y) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

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

#define rep(i, n) for (ll i = 0LL; i < n; i++)
#define repext(i, a, b) for (ll i = a; i < b; i++)
#define reprev(i, n) for (ll i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (ll i = b - 1; i >= a; i--)

#define repv(v, values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0LL)
#define srt(vec) sort(vec_all(vec))
#define rev(vec) reverse(vec_all(vec))
#define revsrt(vec) \
    srt(vec);       \
    rev(vec)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

template <typename T, typename S>
void dump_dic(map<T, S> dic)
{
    for (auto v : dic)
    {
        cout << v.first << ": " << v.second << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = (double) w * (double) h;

    cout << fixed << setprecision(10) << s / 2.0 << " ";
    if (w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int l, r, d;
    cin >> l >> r >> d;

    int ans = 0;
    for (int i = l; i <= r; ++i)
    {
        if (i % d == 0) ++ans;
    }

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



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t, flag) int tc = 1; if(flag) cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()

int n;
int cost[20][20];

vin pre;
vin dp;

const int INF = 1e18+5;

void fun(int index, vin& rem, int score, int mask, int group){
    if(index == (int)rem.size()){
        dp[mask] = max(dp[mask], score + pre[group]);
        return;
    }
    else{
        fun(index+1, rem, score, mask, group);
        fun(index+1, rem, score, mask ^ (1 << rem[index]), group ^ (1 << rem[index]));
    }
}

int32_t main(){
    fastio;
    w(t, false){
        
        cin >> n;
        loop(n) 
            Loop(0, n, j) 
                cin >> cost[i][j];

        
        // pre processing
        pre.resize((1 << n), 0);
        for(int mask = 0; mask < (1<<n); ++mask){
            for(int i = 0; i < n; ++i){
                if(mask & (1 << i)){
                    for(int j = i+1; j < n; ++j){
                        if(mask & (1 << j)){
                            pre[mask] += cost[i][j]; 
                        }
                    }
                }
            }
        }

        dp.resize((1 << n), -INF);
        dp[0] = 0;
        for(int mask = 0; mask < (1 << n); ++mask){
            vin rem;
            for(int j = 0; j < n; j++) 
                if(!(mask&(1 << j))) 
                    rem.pb(j);

            fun(0, rem, dp[mask], mask, 0);           
        }
        cout << dp[(1<<n)-1] << endl;
    }
}

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

int main(){
    int N; cin >> N;
    vector<vector<int>> p(N,vector<int>(2));
    for(int i = 0;i < N;++i){
        int x,y;
        cin >> x >> y;
        p[i][0] = x;
        p[i][1] = y;
    }
    double d = 0;
    for(int i = 0;i < N-1;++i){
        for(int j = i+1;j < N;++j){
            int dd = pow(p[i][0]-p[j][0],2.0)+pow(p[i][1]-p[j][1],2.0);
            d += sqrt(dd) * 2.0/N;
        }
    }
    cout << setprecision(16) << d << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

struct edge{
    ll to, cost;
};

int main(){
    ll v, e, r;
    cin>>v>>e>>r;
    vector<edge> g[v];
    for(ll i=0;i<e;++i){
        ll s, t, d;
        cin>>s>>t>>d;
        edge ed_1, ed_2;
        ed_1.to = t; ed_1.cost = d;
        g[s].emplace_back(ed_1);
    }

    priority_queue<pairs, p, greater<pairs>> que;
    vector<ll> d(v, INF);
    d[r] = 0;
    que.push(make_pair(0, r));
    while(!que.empty()){
        pairs p = que.top();
        que.pop();
        ll x = p.second;
        if(d[x] < p.first)continue;
        for(auto val : g[x]){
            if(d[val.to] > d[x] + val.cost){
                d[val.to] = d[x] + val.cost;
                que.push(make_pair(d[val.to], val.to));
                //cout<<d[val.to]<<' '<<val.to<<endl;
            }
        }
    }

    for(ll i=0;i<v;++i){
        if(d[i] == INF){
            cout<<"INF"<<endl;
        }else{
            cout<<d[i]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 21000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

ll N,K;
vector<ll> A;

vector<ll> B,C;
ll zero;

const ll INF=2e18;

bool minusJudge(ll lim){
  ll res=0;
  for(int i=0;i<B.size();i++){
    ll tar=-((-lim+B[i]-1)/B[i]);
    int z=upper_bound(C.begin(),C.end(),tar)-C.begin();
    res+=z;
  }
  if(res>=K) return true;
  else return false;
}

bool plusJudge(ll lim){
  ll res=0;
  for(int i=0;i<B.size();i++){
    ll tar=lim/B[i];
    int z=upper_bound(B.begin(),B.end(),tar)-B.begin();
    res+=z;
  }
  for(int i=0;i<B.size();i++) if(B[i]*B[i]<=lim) res--;
  for(int i=0;i<C.size();i++){
    ll tar=lim/C[i];
    ll z=upper_bound(C.begin(),C.end(),tar)-C.begin();
    res+=z;
  }
  for(int i=0;i<C.size();i++) if(C[i]*C[i]<=lim) res--;

  res/=2;
  if(res>=K) return true;
  else return false;
}

int main(){
  cin>>N>>K;
  A.resize(N);
  rep(i,N) cin>>A[i];

  rep(i,N){
    if(A[i]==0) zero++;
    else if(A[i]>0) B.push_back(A[i]);
    else C.push_back(A[i]);
  }

  if(B.size()>0) sort(B.begin(),B.end());
  if(C.size()>0) sort(C.begin(),C.end());

  ll bn=B.size(),cn=C.size();
  if(bn*cn>=K){//minus
    ll ok=-1,ng=-INF;
    while(abs(ok-ng)>1){
      ll mid=(ok+ng)/2;
      if(minusJudge(mid)) ok=mid;
      else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
  }else if(zero*(zero-1)/2+zero*(N-zero)+bn*cn>=K){//zero
    cout<<0<<endl;
    return 0;
  }else{//plus
    K-=zero*(zero-1)/2;
    K-=zero*(N-zero);
    K-=bn*cn;
    rep(i,C.size()) C[i]=abs(C[i]);
    if(C.size()>0) sort(C.begin(),C.end());

    ll ok=INF,ng=0;
    while(abs(ok-ng)>1){
      ll mid=(ok+ng)/2;
      if(plusJudge(mid)) ok=mid;
      else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
  }

  return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int fact(int n) {
	if (n == 0)return 1;
	return n * fact(n - 1);
}
int dp[114514], a[114514];
signed main() {
	int n, k;
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n)dp[i] = 1e9;
	for (int i = 1; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			dp[0] = 0;
			if (i < j)continue;
			dp[i] = min(dp[i],dp[i - j] + abs(a[i] - a[i - j]));
		}
	}
	cout << dp[n - 1] << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		System.out.println(s.charAt(1)==s.charAt(2)&&(s.charAt(0)==s.charAt(1)||s.charAt(2)==s.charAt(3)) ? "Yes":"No");
	}
}

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

using namespace std;

typedef long long ll;

constexpr int MOD = 1000000007;

int powm(int b, int e) {
	int res = 1;
	while(e) {
		if(e & 1)
			res = (ll)res * b % MOD;
		b = (ll)b * b % MOD;
		e >>= 1;
	}
	return res;
}

int comb(int n, int k) {
	if(k < n / 2) k = n - k;
	int res = 1;
	for(int i = k + 1; i <= n; i++)
		res = (ll)res * i % MOD;
	for(int i = 2; i <= n - k; i++)
		res = (ll)res * powm(i, MOD - 2) % MOD;
	return res;
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = ((ll)powm(2, n) - comb(n, a) - comb(n, b) + 2 * MOD - 1) % MOD;
	cout << ans << '\n';
}


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

int main(){
	string str, order, p;
	int num, a, b;
	cin >> str >> num;
	for(int i = 0; i < num; i++){
		cin >> order >> a >> b;
		if(order == "print"){
			for(int j = a; j <= b; j++){
				cout << str[j];
			}
			cout << endl;
		}
		else if(order == "reverse"){
			for( ; a < b; a++, b--){
				char tmp = str[a];
				str[a] = str[b];
				str[b] = tmp;
			}
		}
		else if(order == "replace"){
			cin >> p;
			for(int j = a; j <= b; j++){
				str[j] = p[j-a];
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3216
// Problem : C - Reconciled?
// Contest : AtCoder - AtCoder Beginner Contest 065
// URL : https://atcoder.jp/contests/abc065/tasks/arc076_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}
int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}
vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}
int ncr(int n,int r){
return (((fact[n]*inv[r])%md)*inv[n-r])%md;
}
void solve()
{
int a,b;cin>>a>>b;
if(abst(a-b)<=1)
{
	factorial(100001);
	if(a==b)
	{
		cout<<(2*fact[a]*fact[b])%md;
	}
	else
	{
		int mx=max2(a,b);
		int mn=a+b-mx;
		cout<<(fact[mx]*fact[mn])%md;
	}
}
else
cout<<0;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3972
// Created by Nandu Vinodan
#include "bits/stdc++.h"

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

struct Node {
	int i, j;
	char c;
	Node(int x, int y, char s) : i(x), j(y), c(s){}
};

void testcase() {

	int h, w;
    cin >> h >> w;

    vector<string> grid(h);
    rep (i, 0, h-1) cin >> grid[i];

    vector<vector<int> > dp(h, vector<int>(w));

    dp[0][0] = (grid[0][0]=='#');
    rep (j, 1, w-1) {
    	dp[0][j] = dp[0][j-1] + (grid[0][j-1]=='.' && grid[0][j]=='#');
    }

    rep (i, 1, h-1) {
    	dp[i][0] = dp[i-1][0] + (grid[i-1][0]=='.' && grid[i][0]=='#');
    }

    rep (i, 1, h-1) {
    	rep (j, 1, w-1) {
    		dp[i][j] = min (dp[i-1][j] + (grid[i-1][j]=='.' && grid[i][j]=='#'),
    						dp[i][j-1] + (grid[i][j-1]=='.' && grid[i][j]=='#'));
    	}
    }

    // rep (i, 0, h-1) {
    // 	rep (j, 0, w-1) {
    // 		cout << dp[i][j] << " ";
    // 	}
    // 	cout << endl;
    // }
    cout << dp[h-1][w-1] << "\n";
 }

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <string.h>
#include <map>
#include <iomanip>
#include <time.h>
using namespace std;
typedef long long ll;

void twin(bool b) {
    cout << (b ? "Yay!" : ":(" ) << endl;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++) {
        if (i * 108 / 100 == n) {
            cout << i << endl;
            return 0;
        }
    }
    twin(0);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    char s1[200001],t1[200001];
    scanf("%s",s1);
    scanf("\r%s",t1);
    int x,sum=0;
    x=strlen(s1);

    for(int i=0;i<x;i++)
    {
        if(s1[i]!=t1[i])
            sum++;
    }
    printf("%d",sum);
}


Measured memory_bytes: 2124
import java.util.*;

class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Float> values = new ArrayList<Float>();
    for (int i = 0; i < n; i++) {
      values.add((float)sc.nextInt());
    }

    while(values.size() > 1) {
      Collections.sort(values);
      float i = values.get(0);
      float j = values.get(1);
      values.remove(0);
      values.remove(0);
      float k = (i+j)/2;
      values.add(k);
    }

    System.out.println(values.get(0));
  }
}

Measured memory_bytes: 22996
N, M = gets.chomp.split(" ").map(&:to_i)
S = []
M.times{
  S << gets.chomp.split(" ").map(&:to_i)
}

A = Array.new(N)
ans = 0
S.each{|s, c|
  if A[s-1].nil? then
    A[s-1] = c
  elsif A[s-1] != c then
    ans = -1
  end
}
if ans == -1 || (A[0] == 0 && N > 1) then
  ans = -1
else
  A.map!{|a| a.nil? ? 0 : a}
  A[0] = 1 if A[0] == 0 && N > 1
  ans = A.join
end

puts ans


Measured memory_bytes: 1916
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std;
int a[1010][1010],f[1010][1010],u[4]={-1,1,0,0},v[4]={0,0,1,-1};
deque<pair<int,int> > q;
int n,m,x1,y1,x2,y2;
char s;
int main()
{
    int i,j,t1,t2,x0,y0;
    cin>>n>>m;
    memset(f,10,sizeof(f));
    cin>>x1>>y1>>x2>>y2;
    for(i=1;i<=n;i++)
     for(j=1;j<=m;j++)
     {
         cin>>s;
         if(s=='#') a[i][j]=1;
     }
    q.push_back(make_pair(x1,y1));
    f[x1][y1]=0;
    do
    {
        t1=q.front().first;
        t2=q.front().second;
        q.pop_front();
        for(i=0;i<4;i++)
        {
            x0=t1+u[i];
            y0=t2+v[i];
            if(x0<1||y0<1||x0>n||y0>m) continue;
            if(a[x0][y0]==1) continue;
            if(f[x0][y0]<=f[t1][t2]) continue;
            q.push_front(make_pair(x0,y0));
            f[x0][y0]=f[t1][t2];
        }
        for(i=-2;i<=2;i++)
         for(j=-2;j<=2;j++)
         {
             x0=t1+i;
             y0=t2+j;
             if(x0<1||y0<1||x0>n||y0>m) continue;
             if(a[x0][y0]==1) continue;
             if(f[x0][y0]<=f[t1][t2]+1) continue;
             q.push_back(make_pair(x0,y0));
             f[x0][y0]=f[t1][t2]+1;
         }
    }
    while(!q.empty()); 
    /*for(i=1;i<=n;i++)
    {
     for(j=1;j<=m;j++)
      cout<<f[i][j]<<" ";
      cout<<endl;
      }*/
    if(f[x2][y2]<999999) cout<<f[x2][y2];
    else cout<<-1;
    system("pause");
}


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

if N == 0:
  print(0)
  exit()

S = ""

cnt = 0
while N != 0:
  if abs(N) % pow(2, cnt + 1) != 0:
    S += "1"
    N -= pow(-2, cnt)
  else:
    S += "0"
  cnt += 1
print(S[::-1])

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
  double r;
  cin >> r;
  cout << fixed;
  cout << setprecision(9) << r*r*M_PI;
  cout <<" ";
  cout << setprecision(9) << r*2*M_PI;
  cout << endl;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    bool ok=false;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){
                ok=true;
            }
        }
    }
    if(ok){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    cout << (N-1)*N/2 << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
ma = max(a)
d = [0 for i in range(ma+1)]
c = 0
for i in a:
    if d[i] == 2 or d[i] == 1:
        d[i] = 1
        continue
    for j in range(2*i, ma+1, i):
        d[j] = 1
    d[i] = 2
for i in a:
    if d[i] != 1:
        #print(i)
        c += 1
print(c)


Measured memory_bytes: 32120
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  int count=0;
  for(int i=0;i<N;i++){
    int a,b;
    cin >> a >> b;
    if(a==b){
      count++;
    }
    else{
      count=0;
    }
    if(count==3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
//#include "../dump.hpp"
using namespace std;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using vi = vector<int>;
using vvi = vector<vi>;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src_, int dst_, Weight weight_) :
    src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void visit(const Graph &g, int v, vvi &scc,
	   stack<int> &S, vector<bool> &inS,
	   vi &low, vi &num, int& time) {
  low[v] = num[v] = ++time;
  S.push(v); inS[v] = true;
  for(auto e : g[v]) {
    int w = e.dst;
    if (num[w] == 0) {
      visit(g, w, scc, S, inS, low, num, time);
      low[v] = min(low[v], low[w]);
    } else if (inS[w])
      low[v] = min(low[v], num[w]);
  }
  if (low[v] == num[v]) {
    scc.push_back(vector<int>());
    while (1) {
      int w = S.top(); S.pop(); inS[w] = false;
      scc.back().push_back(w);
      if (v == w) break;
    }
  }
}

// おそらくトポロジカル順の逆
void stronglyConnectedComponents(const Graph& g, vvi &scc) {
  const int n = g.size();
  vi num(n), low(n);
  stack<int> S;
  vector<bool> inS(n);
  int time = 0;
  rep(u, n) if (num[u] == 0)
    visit(g, u, scc, S, inS, low, num, time);
}

void createContractedGraph(const Graph &g, const vvi &scc, vvi & cg){
  cg.resize(scc.size());
  vi id(g.size()); // 縮約前の頂点が縮約後にどこにいるか
  rep(i,scc.size()) rep(j,scc[i].size()){
    id[scc[i][j]] = i;
  }

  rep(i,scc.size()){
    set<int> to; // 各成分の要素の行き先から自分を引いたものが縮約後の行き先
    rep(j,scc[i].size()){
      int now = scc[i][j];
      rep(k,g[now].size()){
	int next = g[now][k].dst;
	to.insert(id[next]);
      }
    }
    to.erase(i);
    cg[i] = move(vi(to.begin(),to.end()));
  }
}

int main(){
  int n;
  while(cin >> n, n){
    vector<double> p(n);
    Graph g(n);
    rep(i,n){
      cin >> p[i];
      int m; cin >> m;
      rep(j,m){
	int a; cin >> a; a--;
	g[i].push_back(Edge(i,a,0));
      }
    }
    vvi scc;
    stronglyConnectedComponents(g,scc);
    //dump(scc);
    vvi cg;
    createContractedGraph(g,scc,cg);
    //dump(cg);
    vi used(cg.size()); // 入次数が0なら0
    rep(i,cg.size()){
      rep(j,cg[i].size()) used[cg[i][j]] = 1;
    }
    //dump(used);
    
    double tmpa = 1.0; // 全ての成分が起きる
    rep(i,used.size()){
      if(used[i] == 1) continue;
      
      double tmpb = 1.0; // 各成分の全員が寝坊する
      for(auto k : scc[i]){
    	tmpb *= p[k];
      }
      tmpa *= (1.0 - tmpb); // 誰かが起きる
    }
    printf("%.10lf\n",tmpa);
  }
}



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

int main() {
  long long x,k,d;
  cin >> x >> k >> d;
  long long y = abs(x);
  
  
  if (y/k-d>=0) {
    cout << y-k*d << endl;
    return 0;
  }
  else if (y>d) {
    long long syou = y/d;
    if ((k-syou)%2==0) {
      cout << y%d << endl;
      return 0;
    }
    else {
      cout << d-y%d << endl;
      return 0;
    }
  }
  else {
    if (k%2==0) {
      cout << y << endl;
      return 0;
    }
    else {
      cout << d-y << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3636
#include<stdio.h>

int main(void){

    int H,W,a[1000][2],i=0,j=0,x=0,k;

    while(1){
        scanf("%d %d", &a[x][0], &a[x][1]);
        if(a[x][0]==0&&a[x][1]==0)break;
        x++;
    }

    for(i=0;i<x;i++){
        for(j=0;j<a[i][0];j++){
            if(j==0||j==a[i][0]-1){
                for(k=0;k<a[i][1];k++){
                printf("#");
                }
            }else{
                for(k=0;k<a[i][1];k++){
                    if(k==0||k==a[i][1]-1){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2028
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <complex>
#include <cstring>
#include <set>
#include <sstream>
#include <cassert>
using namespace std;

#define loop(i,a,b) for(int i=a;i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back

typedef long long ll;
typedef long double R;
typedef complex<R> P;
R const eps = 1e-10;
//R const eps = 1e-5;
struct Edge {
    int src,dst,cost;
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int N,X,Y;

Graph g;
vector<P> ps;
P p;

string tos(int n){
    stringstream ss;
    return ss<<n, ss.str();
}

string const NA = "You're always welcome!";

string solve(){
    bool flg = false;
    set<int> q;
    int sayat[1010];
    rep(i,N){
        sayat[i] = -1e9;
        R d = abs(ps[i]-p);
        if(d <= 10+eps){
            //cout << i << endl;
            q.insert(i);
            flg = true;
            sayat[i] = X;
        }
    }
    if(!flg) return tos(0);
    int ans = X;
    // assert(ans==X);
    rep(iter,100000){
        if(q.size()==0) break;
        set<int> nxt;
        //for(set<int>::const_iterator it=q.cbegin();it!=q.cend();++it){
        for(set<int>::iterator it=q.begin();it!=q.end();++it){
            int src = *it;
            // cout << src << " ";
            rep(_,g[src].size()){
                Edge & e = g[src][_];
                int dst = e.dst;
                if(sayat[src] > sayat[dst] + Y){
                    nxt.insert(dst);
                    ans = sayat[src] + X;
                    sayat[dst] = sayat[src] + X;
                }
            }
        }
        //cout << endl;
        swap(q,nxt);
    }
    //assert(q.size()>0);
    return q.size() ? NA : tos(ans);
}

int main(){
    int t;
    cin >> t;
    rep(i,t){
        cin >> N >> X >> Y;
        ps.resize(N);
        R x,y;
        cin >> x >> y;
        p = P(x,y);
        rep(i,N){
            cin >> x >> y;
            ps[i] = P(x,y);
        }
        g = Graph(N,Edges());
        rep(i,N)rep(j,i){
            R d = abs(ps[i]-ps[j]);
            if(d <= 50+eps){
                g[i].pb({i,j,0});
                g[j].pb({j,i,0});
                // cout << "edge:" << i << "-" << j << endl;
            }
        }
        cout << solve() << endl;
    }
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> P(n),Q(n);
    for(auto&x:P){
        cin >> x;
    }
    for(auto &x : Q) {
        cin >> x;
    }
    vector<ll> A(n);
    iota(A.begin(),A.end(),1);
    ll retP,retQ,cnt=0;
    do{
        cnt++;
        if(A==P)retP=cnt;
        if(A==Q)retQ=cnt;
    }while(next_permutation(A.begin(),A.end()));
    cout << abs(retP-retQ) << endl;
    return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	string s,w1,w2="";
	cin>>n>>s>>k;
	w1=s.substr(k-1,1);
	for(int i=0;i<s.length();i++){
		if(s.substr(i,1)==w1){
			w2+=s.substr(i,1);
		}else{
			w2+="*";
		}
	}
	cout<<w2<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b,c;
    cin>>a>>b>>c;

    (b-a)==(c-b) ? cout<<"YES"<<endl: cout<<"NO"<<endl;
   
    return 0;
}

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


int main() {
	char* S;
	int N,Ans=0,Frag=0;
	cin >> N;
	S = new char[N];
	cin >> S;
	for (int i = 0; i < N; i++) {

		if ((S[i] == 'C') && (Frag == 2)) {
			Ans++;
			Frag = 0;
		}
		else if(Frag == 2){
			Frag = 0;
		}


		if ((S[i] == 'B') && (Frag == 1)) {
			Frag++;
		}
		else if(Frag ==1){
			Frag = 0;
		}


		if ((S[i] == 'A') && (Frag == 0)) {
			Frag++;
		}
	}

	cout << Ans;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {

	int h,w; cin >> h >> w;

	vector<string> A(h);

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

	vector<int> alp(26,0);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			alp[(int)(A[i][j])-97]++;
		}
	}

	if (h % 2 == 0 and w % 2 == 0) {
		for (int i = 0; i < 26	; i++) {
			if (alp[i] % 4 != 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}else if ((h + w) % 2 == 1) {
		int even_cnt = 0;
		for (int i = 0; i < 26; i++) {
			if (alp[i] % 2 == 1) {
				cout << "No" << endl;
				return 0;
			}
			if ((alp[i]%4) / 2 == 1) {
				even_cnt++;	
			}
		}
		int center;
		if (h % 2 == 0) {
			center = h;	
		}else if (w % 2 == 0) {
			center = w;
		}
		if (even_cnt > (center/2)) {
			cout << "No" << endl;
			return 0;
		}
	}else {
		int even_cnt = 0;
		int odd_cnt = 0;
		for (int i = 0; i < 26; i++) {
			if ((alp[i]%4) / 2 == 1) {
				even_cnt++;	
			}else if (alp[i] % 2 == 1) {
				odd_cnt++;
			}
		}
		if (even_cnt > (h/2) + (w/2)) {
			cout << "No" << endl;
			return 0;
		}else if (odd_cnt != 1) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


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


long long H,W, INF= 1000000000;

vector<string> s;

//縦横の移動
long long dx[4] = { 0, 0, 1, -1 }, dy[4] = { 1, -1, 0, 0 };

//X,Yはスタート位置
long long BFS(long long X,long long Y){
    //キューの宣言(二次元)
    queue<pair<long long,long long>> q;
    //可変長配列の宣言(H×Wの配列)　INFは初期値　訪問用の記録変数
    vector<vector<long long> > Dist(H,vector<long long>(W,INF));

    q.push({X,Y});
    Dist[X][Y] = 0;
    while(!q.empty()){
        pair<long long , long long> P = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            //X座標、Y座標を±1 Pは現在地
            long long NX = P.first + dx[i], NY = P.second + dy[i];

            //次の訪問先が範囲内の場合
            if (0 <= NX && NX < H && 0 <= NY && NY < W) {
                //次の訪問先が移動可能の場合
                if(s[NX][NY] == '.' and Dist[NX][NY] == INF){

                    Dist[NX][NY] = Dist[P.first][P.second] + 1;
                    q.push({NX,NY});
                
                }
            }
        }
    }

    long long MAX = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++)
            if(Dist[i][j] != INF) MAX = max(MAX,Dist[i][j]); 
    }
    return MAX;
}


int main(){
    cin >> H >> W;
    s.resize(H);
	for (int i = 0; i < H; i++) cin >> s[i];
    long long ans = 0;
    for(int i = 0; i < H; i++ ){
        for(int j = 0; j < W; j++ ){
            if(s[i][j] == '.') ans = max(ans,BFS(i,j)); 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

ll c[4];ll n;

int main(){
	fore(i,0,4)scanf("%lld",c+i);
	scanf("%lld",&n);n*=4;
	fore(i,0,3)c[i+1]=min(c[i+1],2*c[i]);
	ll r=c[3]*(n>>3);
	fore(i,0,3)r+=c[i]*((n>>i)&1);
	printf("%lld\n",r);
	return 0;
}

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

size_t solv(size_t N, size_t K) {
  if (K>N*2) return 0;
  if (K==1) return N*N*N;
  if (K==2) {
    size_t half = N/2;
    if (N%2==0)
      return half*half*half*2;
    else
      return half*half*half+(half+1)*(half+1)*(half+1);
  }

  if (K%2==1) return solv(N/K, 1);

  return solv(N/(K/2), 2);
}

int main() {
  size_t N, K;
  std::cin >> N >> K;

  std::cout << solv(N, K) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        n: usize,
        m: usize,
        a: [usize; m],
    }

    let mut floor: Vec<bool> = vec![true; n + 1];
    let mut dp: Vec<i64> = vec![0; n + 1];
    const M: i64 = 1_000_000_007;

    for i in a {
        floor[i] = false;
    }

    dp[0] = 1;
    for i in 1..n + 1 {
        let p1 = if i >= 1 && floor[i - 1] { dp[i - 1] } else { 0 };
        let p2 = if i >= 2 && floor[i - 2] { dp[i - 2] } else { 0 };
        dp[i] = (p1 + p2) % M;
    }

    println!("{}", dp[n]);
}


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

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

int main(){
    int a, b, i;
    vector<int> v;
    cin >> a;
    int x1, x2, x3;
    for(i = 0; i < a; i++){
        cin >> b;
        v.push_back(b);
    }
    double value = 0;
    
    for(i = 0; i < a; i++){
        value += (1.0)/v.at(i);
    }

    cout << setprecision(8) << (1.0)/value << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> a(N);
  rep (i, N) cin >> a[i];

  long ans = 100000000000l;

  for (long x = -100; x <= 100; x++) {
    long tmp = 0;
    rep (i, N) tmp += (a[i] - x) * (a[i] - x);
    ans = min(ans, tmp);
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
print('Yes' if n >= 30 else 'No')

Measured memory_bytes: 72460
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    ll x;
    cin >> x;
    ll out = ((x-1)/11+1)*2;
    if(x-((x-1)/11)*11<=6) out--;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    X, K, D = list(map(int, input().split()))
    X = abs(X)

    syo = X//D
    if syo >= K:
        ans = X - D*K
        print(ans)
        return

    # 負の方にも行くならば
    plus = X - D*syo  # 正側の答え
    minus = plus - D  # 負側の答え
    restK = K - syo - 1

    if restK%2 == 0:
        print(abs(minus))
        return
    print(plus)
    return


if __name__ == "__main__":
    solve()


Measured memory_bytes: 9212