akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void open() {
	freopen("datain.txt","r",stdin);
}
long long suml[200005],sumr[200005]; 
long long arr[200005];
int n;
long long dif=1e9+1;

int main() {
	//open();	
	cin>>n;
	for (int i=0;i<n;++i) cin>>arr[i];
	if (n==2) dif=abs(arr[1]-arr[0]);
	else {	
	suml[0]=arr[0];
	for (int i=1;i<n-1;++i) suml[i]=suml[i-1]+arr[i];
	//for (int i=0;i<n;++i) cout<<suml[i]<<endl;
	sumr[0]=arr[n-1];
	for (int i=n-2,j=1;i>0;--i,++j) sumr[j]=arr[i]+sumr[j-1];
	//for (int i=0;i<n;++i) cout<<sumr[i]<<endl;
	for (int i=0,j=n-2;i<n-1;++i,--j) {
		if (dif>abs(suml[i]-sumr[j])) dif=abs(suml[i]-sumr[j]);
		//cout<<suml[i]<<"  "<<sumr[j]<<" "<<dif<<endl;
	}
	}
	cout<<dif<<endl;
	return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[][] arr=new int[s[0]][];
		int[,,] hk=new int[s[0],s[1],2];
		List<int[]> ans=new List<int[]>();
		for(int i=0;i<s[0];i++){
			arr[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			for(int j=0;j<s[1];j++){
				if((j%s[1]==0&&i%2==1)||(j%s[1]==s[1]-1&&i%2==0)){hk[i,j,0]=i==s[0]-1?2:1;}
				else{hk[i,j,1]=i%2==0?1:-1;}
			}
		}
		int a=0,b=0;
		for(int i=0,j=0;hk[i,j,0]!=2;i+=a,j+=b){
			a=hk[i,j,0];
			b=hk[i,j,1];
			if(arr[i][j]%2==1){
				ans.Add(new int[]{i+1,j+1,i+a+1,j+b+1});
				arr[i+a][j+b]++;
			}
		}
		Console.WriteLine("{0}",ans.Count);
		for(int i=0;i<ans.Count;i++){Console.WriteLine("{0} {1} {2} {3}",ans[i][0],ans[i][1],ans[i][2],ans[i][3]);}
		
	}
}

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

using ll = long long;

int main(){

  int N;
  cin >> N;

  vector<ll> num(N+1);
  ll ans=0;
  for(ll i=1;i<=N;i++){
    for(ll j=i;j<=N;j=j+i){
      num[j]++;
    }
    ans+=i*num[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 81372
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll n;
	cin>>n;
	vector< pair<ll,ll> > vec;
	for(ll i=0;i<n;i++){
		ll a,b;
		cin>>a>>b;
		vec.push_back({a,b});
	}

	bool bb=0;
	for(ll i=0;i<n-2;i++){
		if(vec[i].first==vec[i].second&&vec[i+1].first==vec[i+1].second&&vec[i+2].first==vec[i+2].second) bb=1;
	}
	if(bb) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  rep(i, 0, 7) {
    int a, b;
    cin >> a >> b;
    cout << abs(a - b) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3160
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

int d;
ll ans=0;
int c[26]; // 満足度の下がりやすさ、（d-最終日）* cだけその日の終わりに引かれる。

int s[365][26]; // d日目にタイプiのコンテストを開いた時の上昇量
int t[365];

ll solve(){
    ll tmp_ans=0;
    int day=1;
    vint last[26];
    int last_num[26] = {0};
    rep(i,26) last[i].pb(0);
    rep(i,d){
        tmp_ans += s[i][t[i]];
        last[t[i]].pb(day);
        last_num[t[i]]++;
        rep(j,26){
            tmp_ans -= c[j] * (day - last[j][last_num[j]]);
        }
        day++;
    }
    return tmp_ans;
}

int main(){
    time_t start = time(NULL);
    cin >> d;
    rep(i, 26) cin >> c[i];
    rep(i,d){
        int max_s =0;
        rep(j,26){
            cin >> s[i][j];
            if(max_s < s[i][j]){
                max_s = s[i][j];
                t[i] = j;
            }
        }
    }
    // cout << start << endl;
    int count=0;
    while(count < 100000){
        count++;
        int md = rand()%365;
        int mq = rand()%26;
        int old = t[md];
        t[md] = mq;
        ll tmp_ans = solve();
        if(ans < tmp_ans){
            ans = tmp_ans;
        }else{
            t[md] = old;
        }
        // time_t end = time(NULL);
        // if(end - start > 1900) break;
    }
    // cout << "count = " << count << endl;
    rep(i,d){
        cout << t[i]+1 << endl;
    }
    // cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using vec = std::vector<unsigned long>;

unsigned long
differ(unsigned long begin,
       unsigned long cut,
       unsigned long  end) {
  unsigned long sum_l = cut - begin;
  unsigned long sum_r = end - cut;
  long diff = sum_r - sum_l;

  return std::abs(diff);
}

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

  vec Sum(N+1);

  unsigned long sum = 0;
  Sum[0] = sum;

  for (size_t i=1; i<N+1; i++) {
    unsigned long a;
    std::cin >> a;

    sum += a;

    Sum[i] = sum;
  }

  std::vector<vec::const_iterator> splits_l(N+1);
  vec::const_iterator cut_l = Sum.cbegin() + 1;

  for (auto end=Sum.cbegin()+2;
       end != Sum.cend()-2;
       std::advance(end, 1)) {
    unsigned long prediff = differ(*Sum.cbegin(), *cut_l, *end);
    for (;
         cut_l != end;
         std::advance(cut_l, 1)) {
      unsigned long diff = differ(*Sum.cbegin(), *cut_l, *end);
      if (prediff < diff) break;
      prediff = diff;
    }

    std::advance(cut_l, -1);
    splits_l[std::distance(Sum.cbegin(), end)] = cut_l;
  }

  std::vector<vec::const_iterator> splits_r(N+1);
  auto cut_r = Sum.crbegin() + 1;

  for (auto begin=Sum.crbegin()+2;
       begin != Sum.crend()-2;
       std::advance(begin, 1)) {
    unsigned long prediff = differ(*begin, *cut_r, *Sum.crbegin());
    for (;
         cut_r != begin;
         std::advance(cut_r, 1)) {
      unsigned long diff = differ(*begin, *cut_r, *Sum.crbegin());
      if (prediff < diff) break;
      prediff = diff;
    }

    std::advance(cut_r, -1);
    splits_r[std::distance(Sum.cbegin(), begin.base())-1] =
      cut_r.base() - 1;
  }

  unsigned long ans = sum;

  for (size_t i=2; i<N-1; i++) {
    unsigned long p = *splits_l[i];
    unsigned long q = Sum[i] - p;
    unsigned long r = *splits_r[i] - Sum[i];
    unsigned long s = sum - *splits_r[i];

    ans = std::min(ans,
                   std::max({p, q, r, s}) - std::min({p, q, r, s}));
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int main() {
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	ll l = lcm(n, m);
	ll g = gcd(n, m);
	n /= g;
	m /= g;
	bool flag = true;
	rep(i, g) {
		if (s[i * n] != t[i * m]) {
			flag = false;
		}
	}
	if (flag) {
		cout << l << endl;
	}
	else{
		cout << -1 << endl;
	}
	return 0;
}

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

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

	// F[0] から F[n] までの分のメモリを確保
	vector<long long> dp(n + 1, 0);

	// 初期条件
	dp[0] = 1;
	dp[1] = 1;

	// DP の遷移を行う
	for (int i = 2; i <= n; ++i) {
		dp[i] += dp[i - 1];
		dp[i] += dp[i - 2];
	}

	// 答え
	cout << dp[n] << endl;
}


Measured memory_bytes: 3120
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
int N=scan.nextInt();
int u1=0;
        int u2=0;
        int u3=0;

for(int i=0;i<N;i++) {
    int a = scan.nextInt();
    int b = scan.nextInt();
    if (a == b && u1 == 1 && u2 == 1) {
        u3 = 1; }
    else if(a == b && u1 == 1) {u2=1;
    }
else if(a == b){u1=1;}
if(a!=b){u1=0;
u2=0;
}
}
if(u3==1){System.out.println("Yes");}

else{System.out.println("No");}
    }
}

Measured memory_bytes: 27348
a, b, c, d = gets.chomp.split(" ").map{|i| i.to_i}
x = Array.new(1000){0}
for i in a...b
  x[i] += 1
end
for i in c...d
  x[i] += 1
end
ans = 0
for i in 0...1000
  if x[i] == 2
    ans += 1
  end
end
puts ans


Measured memory_bytes: 1788
import functools
import fractions

MOD = 10**9 + 7
N = int(input())
A = [int(i) for i in input().split()]

L = functools.reduce(lambda a, b: a // fractions.gcd(a, b) * b, A) % MOD
ans = 0

for a in A:
    ans += L * pow(a, MOD - 2, MOD)
    ans %= MOD

print(ans)


Measured memory_bytes: 67560
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 1000000007
#define eps 1e-8
#define bas 2200
int n,a[200200],b[200200];
ll fac[100100],invfac[100100],dp[4500][4500];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

ll qpow(ll x,int y)
{
    ll ans=1;
    while (y)
    {
        if (y&1) ans=ans*x%maxd;
        y>>=1;x=x*x%maxd;
    }
    return ans;
}

ll C(int n,int m)
{
    if ((n<m) || (n<0) || (m<0)) return 0;
    return fac[n]*invfac[m]%maxd*invfac[n-m]%maxd;
}

int main()
{
    n=read();ll ans=0;
    fac[0]=invfac[0]=1;
    rep(i,1,N) fac[i]=fac[i-1]*i%maxd;
    invfac[N]=qpow(fac[N],maxd-2);
    per(i,N-1,1) invfac[i]=invfac[i+1]*(i+1)%maxd;
    rep(i,1,n)
    {
        a[i]=read();b[i]=read();
        dp[bas-a[i]][bas-b[i]]++;
        ans=(ans+C(2*(a[i]+b[i]),a[i]+a[i]));
    }
    rep(i,1,bas*2)
        rep(j,1,bas*2) dp[i][j]=(dp[i][j]+dp[i][j-1]+dp[i-1][j])%maxd;
    ans=(maxd-ans)%maxd;
    rep(i,1,n) ans=(ans+dp[bas+a[i]][bas+b[i]])%maxd;
    ans=ans*qpow(2,maxd-2)%maxd;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 159488
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int p[10],ans,l=0;
  for(int n=0;n<2;n++){
    for(int i=0;i<10;i++) cin >> p[i];
    sort(p,p+10,greater<int>());
    ans = p[0]+p[1]+p[2];
    cout << ans;
    if(l==0) cout << ' ';
    else cout << endl;
    l++;
  }
  return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

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

using namespace std;


int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	string ans = "Balanced";

	if(A + B > C + D){
		ans = "Left";
	} else if(A + B < C + D){
		ans = "Right";
	}

	cout << ans << endl;
}

	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long ans = 1;
		int count[] = new int[26];
		int odd = 0;
		for(int i=0;i<s.length();i++){
			count[s.charAt(i)-'a']++;
			if(count[s.charAt(i)-'a']%2 == 1){
				odd++;
			}else{
				odd--;
			}
		}
		if(odd >= 2){
			System.out.println("0");
			return;
		}else{
			if(s.length() != 40){
				ans = fact((s.length()-odd)/2);
				for(int i=0;i<count.length;i++){
					if(count[i]%2 == 0){
						ans /= fact(count[i]/2);
					}else{
						ans /= fact((count[i]-1)/2);
					}
				}
			}else{
				double ansp = fact(19);

				for(int i=0;i<count.length;i++){
					if(count[i]%2 == 0){
						ansp /= fact(count[i]/2);
					}
				}

				ans = (long)ansp*20;
			}
		}
		System.out.println(ans);
	}

	static long fact(int n){
		if(n == 0)
			return 1;
		else
			return n * fact(n-1);
	}
}

Measured memory_bytes: 26228
n = int(input())
D = [input() for _ in range(n)]
han=0
for a in range(len(D)-2):
    if D[a][0]==D[a][2] and D[a+1][0]==D[a+1][2] and D[a+2][0]==D[a+2][2]:
        han=1
if han==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5+5;

char g[6][6];
int h,w,k,black;

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    run();
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> g[i][j];
        }
    }
    ll ans = 0;
    for (int i = 0; i < (1 << h); ++i) {
        for (int j = 0; j < (1 << w); ++j) {
            black = 0;
            for (int r = 0; r < h; ++r)
                for (int c = 0; c < w; ++c)
                    black += (((1 << r) & i) == 0 && ((1 << c) & j) == 0 && g[r][c] == '#');

            ans += black == k;
        }
    }
    cout << ans;

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define OUT(x) cout<<(x)<<"\n"
#define SZ(x) (int)(x).size()
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)

const int mod = int(1e9) + 7;
ll n, m;

int main() {
    cin >> n >> m;
    if(abs(n - m) >= 2) {
        OUT(0);
        return 0;
    }

    ll ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
        ans %= mod;
    }
    FOR(i, 1, m + 1) {
        ans *= i;
        ans %= mod;
    }

    OUT(abs(n - m) == 1 ? ans : (2 * ans) % mod);


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b){
    a %= MOD;
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % MOD;
    if(b % 2 == 1){
        ans = ans * a % MOD;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % MOD;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], MOD - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % MOD;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % MOD;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ret = 1;
    for(ll i = 0; i < b; i++) {
        ret *= (a - i);
        ret %= MOD;
        ret *= beki(i + 1, MOD - 2);
        ret %= MOD;
    }
    return ret;
}

int main(int argc, char const *argv[]) {
  init_combination();
  ll a, b, n;
  cin >> n >> a >> b;
  ll ans = beki(2, n) - 1;
  cout << (2*MOD + ans - combination(n, a) - combination(n, b)) % MOD << endl;
  return 0;
}

Measured memory_bytes: 237960
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 998244353; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


void solve() {
	ll A, B, K; cin >> A >> B >> K;
	if (K >= A + B) { A = 0; B = 0; }
	else if (K >= A) {

		B = A + B - K;
		A = 0;
	}
	else {
		A = A - K;
	}
	pe(A); print(B);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;cin>>q;
	//while(q--)
	solve();
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int h,w;
           cin>>h>>w;
           rep(i,0,h){
            rep(j,0,w){
             string s;
              cin>>s;
              if(s=="snuke"){
               cout<<char(j+'A')<<i+1<<endl;
                
              }
            }
           }
}

Measured memory_bytes: 3608
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int h,i,j,k;
  int a[1000],m,n;
  while(cin>>m>>n&&m+n){
    for(i=0;i<m;i++)
      a[i]=i+1;
    j=0;
    for(i=1;i<n+1;i++){
      string s;
      cin>>s;
      if(i%3==0&&i%5==0)
	h=s=="FizzBuzz";
      else if(i%3==0)
	h=s=="Fizz";
      else if(i%5==0)
	h=s=="Buzz";
      else
	h=atoi(s.c_str())==i;
      if(m!=1&&h==0){
	for(k=0;k<m-j-1;k++)
	  a[j+k]=a[j+k+1];
	j--;
	m--;
      }
      j=(j+1)%m;
    }
    for(i=0;i<m-1;i++)
      cout<<a[i]<<" ";
    cout<<a[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 936
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;

  rep(i, k+1){
    rep(j, k+1){
      int n = s - (i + j);
      if(n < 0 ||  n > k) continue;
      ans++;
    }
  }
  print(ans);
}


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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& it : a)
        cin >> it;
    for (int i = k; i < n; i++)
        cout << (a[i] > a[i - k] ? "Yes\n" : "No\n");
    return 0;
}


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

using namespace std;

#define frei(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define fred(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define fri(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define frd(i,n) for (int i = (n) - 1; i >= 0; i--)
#define foreach(it, ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )

#define uint64 unsigned long long
#define int64 long long
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
#define pr pair

#define BIT(n) (1<<(n))
#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a) | (b))
#define XOR(a,b) ((a) ^ (b))
#define sqr(x) ((x) * (x))

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<pii> vii;
typedef vector<int> vi;

#define PI 3.1415926535897932385
#define INF 1000111222
#define eps 1e-7
#define maxN 5005



int main(int argc, char const *argv[])
{
    /* code */
    int n;
    cin >> n;
    double p[n+1];
    for(int i = 1; i<= n; i++) cin >> p[i];
    double dp[n+1][n+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        double tail = (1 - p[i]);
        double head = p[i];
        dp[0][i] = dp[0][i-1]*tail;
        for(int h = 1; h <= i; h++) {
            dp[h][i] = dp[h-1][i-1]*head + dp[h][i-1]*tail; 
        }
    }
    double ans = 0.0;
    for(int i = n/2 + 1; i <= n; i++) {
        ans += dp[i][n];
    }
    cout << setprecision(9) << ans << endl;
    return 0;
}


Measured memory_bytes: 70528
using System;
using System.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long ans = 0;

            for(int i = 0; i < n - 1; i++)
            {
                if(a[i] <= a[i + 1])
                {
                    continue;
                }
                else
                {
                    ans += a[i] - a[i + 1];
                    a[i + 1] = a[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 47928
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

int f(int n) {
  if (n % 2 == 0) {
    return n / 2;
  } else {
    return 3 * n + 1;
  }
}

void solve(int s) {
  vector<bool> v(1e6 + 1, false);
  vector<int> a(1e6 + 1);
  a[1] = s;
  v[a[1]] = true;
  for (int i = 2;; i++) {
    int x = f(a[i - 1]);
    a[i] = x;
    if (v[x]) {
      printf("%d\n", i);
      break;
    } else {
      v[x] = true;
    }
  }
}

int main() {
  int s;
  cin >> s;
  solve(s);
  return 0;
}

Measured memory_bytes: 1016
# -*- coding: utf-8 -*-
"""
A - Tenki
https://atcoder.jp/contests/abc139/tasks/abc139_a

"""
import sys


def solve(S, T):
    return sum(a == b for a, b in zip(S, T))


def main(args):
    S = input()
    T = input()
    ans = solve(S, T)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
/* Code by pedroslrey *
 *     march 7        *
 *    Starurday       */

#include <bits/stdc++.h>

using namespace std;

using lli = long long int;

const int INF = 1000000007;
const lli LLINF = 9223372036854775800;

#define debug(args...) fprintf(stderr, args)
#define show(x) fprintf(stderr, "[DEBUG] -> %d\n", x)

deque<char> d;

int main() {
	bool reverse = false;
	string s;
	cin >> s;
	for (char c: s)
		d.push_back(c);
	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; ++i) {
		int t;
		scanf("%d", &t);
		if (t == 1) {
			reverse = !reverse;
			continue;
		}
		int f;
		char c;
		scanf("%d %c", &f, &c);
		if (f == 1 && !reverse) d.push_front(c);
		else if (f == 2 && !reverse) d.push_back(c);
		else if (f == 1 && reverse) d.push_back(c);
		else if (f == 2 && reverse) d.push_front(c);
	}
	if (!reverse) {
		for (char c: d)
			printf("%c", c);
		printf("\n");
	}
	else {
		for (auto i = d.rbegin(); i != d.rend(); ++i) {
			printf("%c", *i);
		}
		printf("\n");
	}
}

Measured memory_bytes: 896
w = list(input())
alphabet = ["a","b","c","d","e","f","g","h","i","j","k",\
    "l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
i = 0
while i <= 25:
    if w.count(alphabet[i]) % 2 == 1:
        print("No")
        break
    i += 1
else:
    print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <assert.h>
using namespace std;
#define ll long long


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

	ll n;
	cin >> n;
	vector<ll> H(n), B(n);
	
	ll base = 1;
	while (base <= n){
		base *= 2;
	}
	
	vector<ll> dp(n + 1);
	vector<ll> tree(2 * base);

	for (auto &a : H){
		cin >> a;
	}
	for (auto &a : B){
		cin >> a;
	}

	for (ll flower = 0; flower < n; ++flower){
		ll h = H[flower];
		ll b = B[flower];

		ll best = 0;

		ll l = base + 1;
		ll r = base + h;

		while (l <= r){
			if (l & 1){
				best = max(best, tree[l]);
				l++;
			}
			if ((r & 1) == 0){
				best = max(best, tree[r]);
				r--;
			}
			l /= 2;
			r /= 2;
		}

		dp[h] = best + b;
		tree[base + h] = best + b;

		for (ll index = (base + h) / 2; index >= 1; index /= 2){
			tree[index] = max(tree[2 * index], tree[2 * index + 1]);
		}
	}
	ll best = 0;
	for (ll x : dp){
		best = max(best, x);
	}
	cout << best << endl;
}

Measured memory_bytes: 9088
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    k = i_input()
    q = deque([1,2,3,4,5,6,7,8,9])
    for _ in range(k):
        ans = x = q.popleft()
        x0 = x%10
        if x0 >= 1:
            q.append(x*10 + x0 - 1)
        q.append(x*10 + x0)
        if x0 <= 8:
            q.append(x*10 + x0 + 1)
    print(ans)


if __name__=="__main__":
    main()


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

int main(){
    int n;
    cin >> n;
    int ar[n];
    for(int i=0; i<n; i++){
        cin >> ar[i];
    }
    sort(ar, ar+n);
    cout << ar[n-1] - ar[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<cstring>
#include<algorithm>
#define ll long long
#define Max(x,y) ((x) > (y) ? (x) : (y))
#define Min(x,y) ((x) < (y) ? (x) : (y))
#define Abs(x) ((x) > 0 ? (x) : -(x))
#define mod 1000000007
#define N 200010
using namespace std;
inline ll read(){
	ll x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}

ll a[N];
ll l[N],r[N];
ll n,ans = 1e18;

signed main(){
	n = read();
	for(ll i = 1;i <= n;i++)
		a[i] = read();
	for(ll i = 1;i <= n;i++)
		l[i] = l[i-1]+a[i];
	for(ll i = n;i >= 1;i--)
		r[i] = r[i+1]+a[i];
	for(ll i = 1;i < n;i++)
		ans = min(ans,Abs(l[i]-r[i+1]));
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4864
n,k,l=gets.split.map(&:to_i)
c1=[]
c2=[]
e1,e2=[k,l].map{|i|
  i.times.with_object([]){|i,obj|
    x,y=gets.split.map(&:to_i)
    (obj[x-1]||=[]).push(y-1)
    (obj[y-1]||=[]).push(x-1)
  }
}
n.times{|i|
  next if c1[i]
  q=[i]
  until q.empty?
    j=q.pop
    next if c1[j]
    c1[j]=i
    q.push(*e1[j])
  end
}
n.times{|i|
  next if c2[i]
  q=[i]
  until q.empty?
    j=q.pop
    next if c2[j]
    c2[j]=i
    q.push(*e2[j])
  end
}
c3=[]
h={}
n.times{|i|
  c3.push(x=c1[i]*n+c2[i])
  h[x]=(h[x]||0)+1
}
puts c3.map{|x|h[x]}*?\s


Measured memory_bytes: 43772
A=[int(i)*500 for i in range(0,int(input())+1)]
B=[int(i)*100 for i in range(0,int(input())+1)]
C=[int(i)*50 for i in range(0,int(input())+1)]
X=int(input())  
l=[]
for a in A:
  for b in B:
    for c in C:
      l.append(a+b+c)
print(l.count(X))

Measured memory_bytes: 8344
/*
t.me/ivanesipovvpered
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;

const double EPS = 1e-5;
const int mod = 1e9 + 7;
const ll INFLL = 1e18;
const int INF = 1e9;
const int maxn = 1e6 + 3;

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

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

bool is_prime(ll a){
    if (a == 2 | a == 3 || a == 5 || a == 7) return true;
    if (a % 2 == 0 || a%3 == 0 || a%5 == 0 || a%7 == 0)
        return false;
    for (ll i = 11; i * i <= a; i += 2){
        if (a % i == 0)
            return false;
    }
    return true;
}

ll binpow(ll a, int n){
    if (a == 0)
        return 1;
    if (a % 2 == 0){
        ll q = binpow(a, n / 2);
        return (q * q)  ;
    }else return (a * binpow(a, n - 1) ) ;
}





















main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n)
        cin >> a[i];
    vi dp(n);
    for (int i = n - 2; i > -1; i--){
        dp[i] = INF;
        for (int j = i + 1; j < min(n, i + k + 1); j++)
            dp[i] = min (dp[i], dp[j] + abs(a[j] - a[i]));
    }
    cout << dp[0];




}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   int d,g;
   cin>>d>>g;
   int p[d],c[d];
   for(int i=0;i<d;i++){
      cin>>p[i]>>c[i];
   }
   int ans=INF;
   for(int mask=0;mask<(1<<d);mask++){
      int s=0,num=0,restmax=-1;
      for(int i=0;i<d;i++){
         if(mask>>i &1){
            s+=100*(i+1)*p[i]+c[i];
            num+=p[i];
         }else{
            restmax=i;
         }
      }
      if(g>s){
         int s1=100*(restmax+1);
         int need=(g-s+s1-1)/s1;
         if(need>=p[restmax]){
            continue;
         }else{
            num+=need;
         }
      }
      ans=min(ans,num);
   }
   cout<<ans<<endl;
   return 0;
}

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

int main(){
    int a, b, c;
    while(cin >> a >> b >> c, a > 0){
        int p, q, r, s;
        bool found = false;
        for(p = a; p*p >= a; p--){
            if(a%p) continue;
            r = a/p;
            for(q = -abs(c); q <= abs(c); q++){
                if(q == 0){
                    if(c != 0)  continue;
                    if(b%p == 0){
                        found = true;
                        s = b/p;
                        break;
                    }
                    if(b%r == 0){
                        found = true;
                        s = 0;
                        q = b/r;
                        break;
                    }
                }
                if(c%abs(q))    continue;
                s = c/q;
                if(p*s+q*r == b){
                    found = true;
                    break;
                }
            }
            if(found)   break;
        }
        if(found){
            if(p == r && q < s) swap(q, s);
            cout << p << " " << q << " " << r << " " << s << endl;
        }else{
            cout << "Impossible" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3044
import java.util.*;

class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      
      	String a = sc.next();
      	String s = sc.next();
     	String c = sc.next();
      
      	String x = a.substring(0,1) + s.substring(0,1) + c.substring(0,1);
      
      	System.out.println(x);
    }
}

Measured memory_bytes: 21972
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(s: "List[str]"):
    print("".join(si[0].upper() for si in s))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = [next(tokens) for _ in range(3)]  # type: "List[str]"
    solve(s)


if __name__ == '__main__':
    main()


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

int main() {
  int A;
  int B;
  int C;
  int D;
  cin >> A >> B >> C >> D;
  if ( ( A + B ) > ( C + D ) ){
    cout << "Left" << endl;
  }else if ( ( A + B ) == ( C + D ) ){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s1[110],s2[110];

bool judge(int len)
{
    bool flag=false;
    for (int i=0;i<len;i++)
        if (s2[i]==s1[0])
        {
            flag=true;
            for (int j=0;j<len;j++)
                if (s2[(i+j)%len]!=s1[j])
                {
                    flag=false;
                    break;
                }
            if (flag) break;
        }
    return flag;
}

int main()
{
    while (scanf("%s%s",s1,s2)!=EOF)
    {
        int len=strlen(s1);
        printf("%s\n", judge(len)?"Yes":"No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
	}

	bool output = true;

	for (int i = 0; i < N - 1; i++) {
		//差が2以上
		if (H.at(i) - H.at(i + 1) > 1) {
			output = false;
			break;
		}
		//差が1
		else if (H.at(i) - H.at(i + 1) == 1) {
			if (i == 0) {
				H.at(i)--;
			}
			else {
				if (H.at(i) > H.at(i - 1)) {
					H.at(i)--;
				}
				else {
					output = false;
					break;
				}
			}
		}
		else {
			if (i == 0) {
				H.at(i)--;
			}
			else {
				if (H.at(i) > H.at(i - 1)) {
					H.at(i)--;
				}
			}
		}
	}

	if (output) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 640
n=int(input())
arr=[int(input()) for _ in range(n)]
ans=True
checked=[0]*n
num=0
for i in range(30,-1,-1):
  cnt=0
  pos=-1
  for j in range(n):
    if (arr[j])&(2**i)!=0:
      cnt+=1
      if arr[j]==2**i:
        pos=j
    arr[j]&=2**i-1
  if i!=0:
    if cnt%2==0:
      continue
    else:
      if pos==-1:
        ans=False
        break
      else:
        arr[pos]=2**i-1
        checked[pos]=1
        num+=1
        continue
  if i==0:
    if cnt%2==0:
      continue
    else:
      for j in range(n):
        if checked[j]==0:
          arr[j]-=1
          num+=1
          break
      else:
        ans=False
if ans==True:
  print(num)
else:
  print(-1)


Measured memory_bytes: 52312
n,*z=`dd`.split.map &:to_i;t=*0...n;*e=t;a=z.shift n+1;n.downto(1){|i|a[i]-=a[i-1]};k,*z=z;z.map{|x|t[x-2,2]=t[x-1],t[x-2]};60.times{|i|k[i]>0&&e.map!{|q|t[q]};t=t.map{|q|t[q]}};k,*a=a;n.times{|i|p k;k+=a[e[i]]}

Measured memory_bytes: 57056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//		String in = sc.next();
//		String nkq[] = in.split(" ");
		int n = Integer.parseInt(sc.next());
		int kR = Integer.parseInt(sc.next());
		int q = Integer.parseInt(sc.next());
		int[] np = new int[n];

		for(int i=0; i<q; i++) {
			int a = Integer.parseInt(sc.next());
			np[a-1]++;
		}

		for(int j=0; j<n; j++) {
			if(kR - q + np[j] > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 58332
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
 
using namespace std;
 
const ll N = 5e6+100;
const ll MOD = 1e9+7;
 
bool tree[N][26];
string s;
void build(ll node,ll l,ll r)
{
    if(l==r)
    {
        for(char a = 'a';a<='z';a++)
        {
            if(s[l]==a)
            {
                tree[node][a-'a']=true;
            }
        }
    }
    else
    {
        ll mid =(l+r)/2;
        build(2*node,l,mid);
        build(2*node+1,mid+1,r);
        for(int i =0;i<26;i++)
        {
            tree[node][i] = (tree[node*2][i]|tree[node*2+1][i]);
        }
    }
}
 
void update(ll node,ll l,ll r,ll idx,bool val,ll i)
{
    if(l==r)
    {
        tree[node][i]=val;
    }
    else
    {
        ll mid =(l+r)/2;
        if(idx<=mid) 
        {
            update(2*node,l,mid,idx,val,i);
        }
        else
        {
            update(2*node+1,mid+1,r,idx,val,i);
        }
        tree[node][i] = (tree[node*2][i]|tree[node*2+1][i]);
    }
}
bool query(ll node,ll st,ll en,ll l,ll r,ll i)
{
    if(en <l || st > r) 
    {
        return false;
    }
    if(st>=l&&en<=r) 
    {
        return tree[node][i];
    }
    ll mid =(st+en)/2;
    bool p1 = query(node*2,st,mid,l,r,i);
    bool p2 = query(node*2+1,mid+1,en,l,r,i);
    return (p1|p2);
}  
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    cin >> s;
    
    build(1,0,n-1);
    ll q;
    cin >> q;
    while(q--)
    {
        ll ty;
        cin >> ty;
        if(ty==1)
        {
            ll idx;
            char c;
            cin >> idx >> c;
            ll id = c-'a';
            update(1,0,n-1,idx-1,false,s[idx-1]-'a');
            update(1,0,n-1,idx-1,true,c-'a');
            s[idx-1]=c;
        }
        else
        {
            ll l,r;
            cin >> l >> r;
            l--;
            r--;
            ll co =0;
            for(int i = 0; i < 26; i++) co+=query(1,0,n-1,l,r,i);
            cout << co << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 29596
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]


N, M, K = map(int, input().split())

#初期化
#根なら-size,子なら親の頂点
par = [-1]*N

G = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    unite(a-1, b-1)

ans = [size(v) - len(G[v]) - 1 for v in range(N)]

H = [[] for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    if same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1
    
print(' '.join(map(str, ans)))

Measured memory_bytes: 106812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000000000000
int main(){
	ll r,d;cin>>r>>d;
	vector<ll> x(11,0);
	cin>>x[0];

	for(ll i=0;i<=9;i++){
		x[i+1]=r*x[i]-d;
		cout<<x[i+1]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double rad;
    double lon,sho;
    lon = 6*m;
    sho = m/2 + 30*h;
    double deg;
    if(lon>sho)deg = lon-sho;
    else deg = sho-lon;
    deg = min(360-deg,deg);
    
    rad = deg*PI/180;
    double x;
    
    
    x = pow(a,2) + pow(b,2) -(2*a*b*cos(rad));
    
    x = pow(x,0.5);
    cout << std::fixed << std::setprecision(10) << x << endl;
	return 0;
}



Measured memory_bytes: 4356
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
    int h, w, n;
    cin >> h >> w >> n;

    int res = h * w;
    for (int i = 0; i <= h; i++) {
        for (int j = 0; j <= w; j++) {
            if (h * w - (h - i) * (w - j) >= n) {
                res = min(res, i + j);
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int h,m,s;
    
    cin >> s;
    
    m = s/60;
    h = m/60;
    m -= h*60;
    s -= (m*60+h*3600);
    cout << h << ":" << m << ":" << s << endl;
    
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 987654321
#define PI 3.1415926535

ll gcd(ll a, ll b) {
    return a%b? gcd(b,a%b):b;
}

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

    ll a, b;
    cin >> a >> b;

    cout << a*b/gcd(a, b);
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var ans = 0.0;
        var x = new int[N];
        var y = new int[N];
        for (int i = 0; i < N; i++)
        {
            var xy = ReadLine().Split().Select(int.Parse).ToArray();
            x[i] = xy[0];
            y[i] = xy[1];
        }
        var np = new NextPermutation(N);
        do
        {
            var d = 0.0;
            for (int i = 1; i < N; i++)
            {
                var xx = x[np[i - 1]] - x[np[i]];
                var yy = y[np[i - 1]] - y[np[i]];
                d += Sqrt(xx * xx + yy * yy);
            }
            ans += d;
        } while (np.Next());
        var div = 1;
        for (int i = 1; i <= N; i++)
        {
            div *= i;
        }
        WriteLine(ans / div);
    }
}

public class NextPermutation
{
    int[] perm;
    public int Length => perm.Length;

    public NextPermutation(int N)
    {
        perm = new int[N];
        for (int i = 0; i < perm.Length; i++)
        {
            perm[i] = i;
        }
    }

    public NextPermutation(int[] init)
    {
        perm = init;
    }

    public int this[int i]
    {
        get
        {
            return perm[i];
        }
    }

    public bool Next()
    {
        var l = 0;
        for (int i = perm.Length - 2; i >= 0; i--)
        {
            if (perm[i] < perm[i + 1])
            {
                l = i;
                break;
            }
        }

        var v = perm[l];
        var r = 0;
        for (int i = perm.Length - 1; i >= 0; i--)
        {
            if (perm[i] > v)
            {
                r = i;
                break;
            }
        }

        if (l == 0 && r == 0) return false;
        Swap(ref perm[l++], ref perm[r]);
        Array.Reverse(perm, l, perm.Length - l);
        return true;
    }

    static void Swap<T>(ref T l, ref T r)
    {
        var t = l;
        l = r;
        r = t;
    }
}

Measured memory_bytes: 13396
/* ********************************* JAI SAI RAM ************************************* */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lb;
#define endl "\n"
ll P=1000000007;
ll MAX=(P-7)*(P-7);
int main()
{
    ll i,j,k,l,m,n,o,p,q,r,s,t;
    cin>>n;
    ll ans=1;
    ll flag=0;
    vector<ll> v;
    for(i=1;i<=n;i++)
    {

        cin>>j;
        v.push_back(j);
    }
    sort(v.begin(),v.end());
    for(i=0;i<n;i++)
    {
        j=v[i];
        if((MAX/ans)>=j)
        ans*=j;
        else 
        {
           flag=1;
           break;
        }
        if(j==0)
        {
            ans=0;
            flag=0;
            break;
        }
    }
    if(flag==1)
    cout<<"-1";
    else 
    cout<<ans;
    return 0;
}


Measured memory_bytes: 4316