akhauriyash/Code-Regression huggingface dataset:
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

// i 枚目まで使って j 円にするときの最小枚数
int dp[13][101010];
const vector<int> money = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};

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

  int n; cin >> n;

  for (int i = 0; i < 13; ++i) {
    for (int j = 0; j < 101010; ++j) {
      dp[i][j] = INF;
    }
  }

  for (int i = 0; i < 13; ++i) {
    dp[i][0] = 0;
  }

  for (int i = 0; i < 12; ++i) {
    for (int j = 0; j < 101010; ++j) {
      if (j < money[i]) {
        dp[i + 1][j] = dp[i][j];
      }
      else {
        dp[i + 1][j] = min({dp[i][j], dp[i + 1][j - money[i]] + 1, dp[i][j - money[i]] + 1});
      }
    }
  }

  cout << dp[12][n] << '\n';

  return 0;
}

Measured memory_bytes: 5504
import Data.Bits
import Data.List
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Lazy.Char8 as B

main :: IO ()
main = do
  --s <- readLn :: IO Int
  [a',b'] <- map read.words <$> getLine :: IO [Int]
  let a = min a' b'
      b = max a' b'
  if even $ b - a then print $ a + ((b-a) `div` 2)
    else putStrLn $ "IMPOSSIBLE"


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>

int main(){
    std::string s;
    std::cin >> s;

    bool flg = false;
    std::string strBuf;
    if('A' == *s.begin()){
        strBuf = s.substr(2, s.size() - 3);
        if(std::count(strBuf.begin(), strBuf.end(), 'C')){
            s.erase(s.begin() + s.find('A'));
            s.erase(s.begin() + s.find('C'));
            for(int i = 0; i < s.size(); ++i){
                if('a' <= s.at(i) && s.at(i) <= 'z'){
                    if(i == s.size() - 1){
                        flg = true;
                    }
                }else{
                    break;
                }
            } 
        }
    }
    
    if(flg){
        std::cout << "AC" << std::endl;
    }else{
        std::cout << "WA" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int,readline().split()))
x = 0
for i in a:
  x ^= i
aa = []
for i in a:
  aa.append(x^i)
print(*aa)

Measured memory_bytes: 103396
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e6 + 3;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}

int n;
int val[maxn];
 
void solve()
{
	scanf("%d", &n);
	int maxx=0;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &val[i]);
		val[i]++;
		maxx=max(maxx,val[i]);
	}
	n++;
	val[n]=maxx;
	sort(val + 1, val + n + 1);
	reverse(val + 1, val + n + 1);
	int i, j;
	for(i=n;i>=1;i--)
	{
		if(val[i]>=i)
		{
			int up=val[i]-i;
			int right=0;
			for(j=i+1;j<=n;j++)
			{
				if(val[j]<i)
				{
					break;
				}
				else
				{
					right++;
				}
			}
			//cout<<up<<" "<<right<<endl;
			int res=0;
			if(right%2!=up%2)
			{
				res=1;
			}
			else
			{
				res=up%2;
			}
			puts(res?"First":"Second");
			return;
		}
	}
}
int main()
{
    solve();
	return 0;
}

Measured memory_bytes: 640
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;

ll T[2];
ll A[2];
ll B[2];
ll GetMeet(ll offset) {
   ll ret = 0;
   ll pos[3][2];
   ll dif[3];
   dif[0] = offset;
   dif[1] = dif[0]+(B[0]-A[0])*T[0];
   dif[2] = dif[1]+(B[1]-A[1])*T[1];
   if (dif[0]==0) ret++;
   if (dif[0]<0 && dif[1]>0) ret++;
   if (dif[0]>0 && dif[1]<0) ret++;
   if (dif[1]==0) ret++;
   if (dif[1]<0 && dif[2]>0) ret++;
   if (dif[1]>0 && dif[2]<0) ret++;
   return ret;
}
int main(void) {
   cin>>T[0]>>T[1];
   cin>>A[0]>>A[1];
   cin>>B[0]>>B[1];
   ll step_off = (B[0]*T[0]+B[1]*T[1]) - (A[0]*T[0]+A[1]*T[1]);
   if (step_off==0) {
      cout<<"infinity"<<endl;
      return 0;
   }
   ll ans = 0;
   // rep(i,0,10) {
   ll i = 0;
   ll maxn = max(B[0]*T[0]+B[1]*T[1],A[0]*T[0]+A[1]*T[1])/abs(step_off);
   // cout<<maxn<<endl;

   ll le = (ll)0;
   ll re = (ll)maxn;
   while(1) {
      ll ne = (le+re)/2;
      if (le == ne || re == ne) break;
      if (GetMeet(ne*step_off)==0) re = ne;
    //   if (fcnd(ne)>0) re = ne;
      else le = ne;
   }
   ll min_0 = re;
   if (GetMeet(le*step_off)==0) min_0 = le;

   le = 0;
   re = maxn;
   while(1) {
      ll ne = (le+re)/2;
      if (le == ne || re == ne) break;
      if (GetMeet(ne*step_off)<=1) re = ne;
    //   if (fcnd(ne)>0) re = ne;
      else le = ne;
   }
   ll min_1 = re;
   if (GetMeet(le*step_off)<=1) min_1 = le;
   // cout<<0<<" "<<min_1<<" "<<min_0<<endl;
   ans = 2 * (min_1) + (min_0 - min_1);

   rep(i,0,min_0+1) {
      // cout<<i<<" "<<GetMeet(i*step_off)<<endl;
   }

   // while (1) {
   //    cout<<GetMeet(step_off*i)<<endl;
   //    ans += GetMeet(step_off*i);
   //    if (GetMeet(step_off*i)==0) break;
   //    i++;
   // }
   cout<<ans-1<<endl;









   return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long[] a = new long[n];
        HashMap<Long,Long> map = new HashMap<>();
        for(int i = 0; i<n; i++) {
            a[i] = sc.nextLong();

            map.putIfAbsent(a[i],0L);
            map.put(a[i], map.get(a[i])+1L);
        }

        Arrays.sort(a);
        //for(long i:a) System.out.println(i+" "+map.get(i));

        for(int k = n-1; k>=0; k--) {
            //System.out.println(a[k]+" "+map.get(a[k]));
            if (map.get(a[k]) >= 4) {
                System.out.println(a[k] * a[k]);
                return;
            } else if (map.get(a[k]) >= 2) {
                for (int i = k; i >= 0; i--) {
                    if ((a[i] != a[k]) && (map.get(a[i]) >= 2)) {

                        //System.out.println(a[i]+" "+a[k] +" "+((long)a[i]==(long)a[k]));
                        System.out.println(a[k]*a[i]);
                        return;
                    }
                }

            }
        }
        System.out.println(0);

    }
}


Measured memory_bytes: 69168
#include <stdio.h> 

int main()
{
  int n,i,in,j,result=0;

  /*nに要素数を入力*/
  scanf("%d",&n);
  /*配列作成,A[n]値入力*/
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
 
 /*バブルソート*/
  for(i=1;i<n;i++){
    for(j=n-1;j>=i;j--){
      /*変換、変換回数カウント*/
      if(A[j]<A[j-1]){
       in=A[j];
       A[j]=A[j-1];
       A[j-1]=in;
       result++;
      }
    }
  }
  /*出力*/
  for(i=0;i<n;i++){
    if(i==n-1)
      printf("%d\n",A[i]);
    else
      printf("%d ",A[i]);
  }
  printf("%d\n",result);

 return 0;
}


Measured memory_bytes: 2108
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define MOD 1000000007
using namespace std;
typedef long long ll;
const ll i2 = 500000004, i3 = 333333336;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline ll tasu(ll a, const ll &b) {return (a += b) >= MOD ? a - MOD : a;}
inline ll hiku(ll a, const ll &b) {return (a -= b) < 0 ? a + MOD : a;}

inline ll fastpow(ll bas, ll ex){
	register ll res = 1; bas %= MOD;
	for(; ex; ex >>= 1, bas = bas * bas % MOD) if(ex & 1) res = res * bas % MOD;
	return res;
}

ll H, W, K, N, fac[20000005], ifac[20000005], P1, P2, P;

inline ll binom(const int &n, const int &m) {return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;}
inline ll ibinom(const int &n, const int &m) {return ifac[n] * fac[m] % MOD * fac[n - m] % MOD;}

int main(){
	getint(H), getint(W), getint(K), N = H + W, fac[0] = 1;
	for(register int i = 1; i <= N; i++) fac[i] = fac[i - 1] * i % MOD;
	ifac[N] = fastpow(fac[N], MOD - 2);
	for(register int i = N; i >= 1; i--) ifac[i - 1] = ifac[i] * i % MOD;
	P1 = tasu(binom(K, 2) * ibinom(N, 2) % MOD,
	            binom(K, 3) * ibinom(N, 3) % MOD * i3 % MOD * (N - 2) % MOD);  // Not on the edge 
	P2 = tasu(binom(K, 1) * ibinom(N, 1) % MOD,
	            binom(K, 2) * ibinom(N, 2) % MOD * i2 % MOD * (N - 1) % MOD);
	P = tasu(tasu(P1 * H % MOD * W % MOD, P2 * N % MOD), K);
	return printf("%lld\n", binom(N, K) * fac[K] % MOD * P % MOD), 0;
}

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

double A, B, C, D, E, F;
set<double> water;
set<double> sugar;
set<double> suvec;
long long answa;
long long anssu;

bool isbetter(long long wa, long long su){
	if(answa == 0){
		return true;
	}
	double curans;
	if(answa == 0){
		curans = 0;
	}else{
	curans = (double)anssu/(double)(answa + anssu);
	}
	double tmpans;
	if(wa == 0){
		tmpans = 0;
	}else{
	tmpans= (double)su/(double)(wa + su);
	}
	return (curans < tmpans);
}

int main(){
	answa = 0;
	anssu = 0;

	cin >> A >> B >> C >> D >> E >> F;
	for(long long i = 0; i * 100 * A <= F; i++){
		long long rest = F - i * 100 * A;
		for(long long j = 0; j * 100 * B <= rest; j++){
			water.insert(i*100*A + j * 100* B);
		}
	}

	for(long long i = 0; i * C <= F; i++){
		long long rest = F - i * C;
		for(long long j = 0; j * D <= rest; j++){
			sugar.insert(-1*(i*C + j*D));
		}
	}

	for(auto wa: water){
		long long su = F - wa;
		su = min(su, (long long)(wa/100 * E));
		long long tmpsu = *sugar.lower_bound(-1*su);
		tmpsu *= -1;
		if(isbetter(wa, tmpsu)){
			answa = wa;
			anssu = tmpsu;
		}
	}
	cout << answa +anssu<< " " << anssu << endl;
}


Measured memory_bytes: 384
def main():
    import numpy as np
    c = [list(map(int, input().split())) for _ in range(3)]
    f = [[x[0] - x[1], x[1] - x[2], x[2] - x[0]] for x in c]
    g = f[0] == f[1] == f[2]
    print('Yes' if g else 'No')


if __name__ == '__main__':
    main()


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

#define int long long
const int MOD=1e9+7;
int pw(int n,int k){
  assert(k>=0);
  int res=1;
  while(k){
    if(k&1)(res*=n)%=MOD;
    (n*=n)%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(5e6),Finverse(5e6);
inline void Cinit(){// limit is 5e6 /// write pw /// this takes 792ms at AtCoder
  Factorial[0]=1;
  for(int i=1;i<5e6;i++)Factorial[i]=(Factorial[i-1]*i)%MOD;
  for(int i=0;i<5e6;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 0;if(k<0)return 0;
  if(!Factorial[0])Cinit();
  int res=Factorial[n];
  (res*=Finverse[k])%=MOD;
  (res*=Finverse[n-k])%=MOD;
  return res;
}
struct wall{int sum,r,c;};
bool cmp(wall a,wall b){return a.sum<b.sum;}
int dp[3001][2];//dp[i][j]:最後に訪れた壁がiで偶奇j個目の時の通り数
void f(int &a){
  if(a>=MOD)a%=MOD;
  if(a<0)a+=MOD;
}
void tasu(int &a,int b){
  f(a);f(b);
  a+=b;
  if(a>=MOD)a-=MOD;
}
int seki(int a,int b){
  f(a);f(b);
  return a*b%MOD;
}


signed main(){
  int h,w,n;cin>>h>>w>>n;
  vector<wall> v(n);
  for(int i=0;i<n;i++){
    int r,c;cin>>r>>c;
    v[i]={r+c,r,c};
  }
  v.push_back({2,1,1});
  sort(v.begin(),v.end(),cmp);
  int ans=nCk(h-1+w-1,h-1);
  dp[0][1]=1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<i;j++){
      if(v[i].r<v[j].r||v[i].c<v[j].c)continue;
      for(int k=0;k<2;k++){
        tasu(dp[i][k^1],seki(dp[j][k],nCk(v[i].r-v[j].r+v[i].c-v[j].c,v[i].r-v[j].r)));
      }
    }
  }
  for(int i=1;i<=n;i++){
    for(int k=0;k<2;k++){
      if(k)tasu(ans,seki(dp[i][k],nCk(h-v[i].r+w-v[i].c,h-v[i].r)));
      else tasu(ans,-seki(dp[i][k],nCk(h-v[i].r+w-v[i].c,h-v[i].r)));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.size();
  int ret = 0;
  int c = 0;
  int f = 0;
  for (int i=0; i<N; i++) {
    int d = S[N-1-i] - '0';
    if (f) {
      if (d == 4) {
        ret += d;
        c = 0;
        f = 0;
      } else if (d == 5) {
        ret += 4;
        c = 1;
        f = 0;
      } else if (d >= 6) {
        ret += 10 - d - 1;
        c = 1;
        f = 0;
      } else {
        ret += d;
        c = 0;
        f = 0;
      }
      continue;
    }
    d += c;
    f = (d == 5);
    if (d == 0) continue;
    if (d > 5) {
      ret += 10 - d;
      f = 0;
      c = 1;
    } else if (d == 5) {
      ret += 5;
      f = 1;
      c = 0;
    } else {
      ret += d;
      f = 0;
      c = 0;
    }
  }
  ret += c;
  cout << ret << endl;
}

Measured memory_bytes: 1948
n,m,x,y=map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))

X.append(x)
Y.append(y)

X.sort()
Y.sort()

if X[-1] >= Y[0]:
    print("War")
else:
    print("No War")

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

/*
  P1(x1, y1) P2(x2, y2) P3(x3, y3) P0(x0, y0)

 <円の中心(x0, y0)>
  2*(x2-x1)*x0 + 2*(y2-y1)*y0 = x2*x2 - x1*x1 + y2*y2 - y1*y1
  2*(x3-x1)*x0 + 2*(y3-y1)*y0 = x3*x3 - x1*x1 + y3*y3 - y1*y1
  x0=((y3-y1)*(x2*x2-x1*x1+y2*y2-y1*y1)+(y1-y2)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))
  y0=((x1-x3)*(x2*x2-x1*x1+y2*y2-y1*y1)+(x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))

 <円の半径R>
  R = a/(2*sqrt(q-cosA*cosA)) 
  a = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) // P2-P3
  b = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) // P1-P3
  c = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) ) // P1-P2
  cosA = (b*b + c*c - a*a)/(2*b*c)
 */

int main()
{
    double x1, x2, x3, y1, y2, y3; // 3角形の3点
    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        double x0=((y3-y1)*(x2*x2-x1*x1+y2*y2-y1*y1)+(y1-y2)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)));
        double y0=((x1-x3)*(x2*x2-x1*x1+y2*y2-y1*y1)+(x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1))/(2*((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1)));
        double a = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) );
        double b = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) );
        double c = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
        double cosA = (b*b + c*c - a*a)/(2*b*c);
        double R = a/(2*sqrt(1-cosA*cosA));

        printf("%.3f %.3f %.3f\n", x0, y0, R);
    }

    return 0;
}

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

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

int main(void){
    string s; cin >> s;
    string ans;
    rep(i, s.size()){
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else{
            if(!ans.empty()) ans.pop_back();//空文字でなければ
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll base = (N / (A + B)) * A;
    ll res = N % (A + B);
    if (res >= A) {
        cout << base + A << endl;
    } else {
        cout << base + res << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

ll n,s;
ll res = -1;
void solve()
{
    ll sum = 0;
    ll tmp = 0;
    for(ll b = 2;b<=(ll)(sqrt(n));b++){
        sum = 0;
        tmp = n;
        while(tmp!=0){
            sum+=tmp%b;
            tmp/=b;
        }
        if(sum==s){
            res = b;
            return;
        }
    }
    if(n == s){
        res = n+1;
        return;
    }
    if(n < s){
        return ;
    }
    else{
        //find all factors of (n-s)
        ll b;
        for(ll f=(ll)(sqrt(n-s));f>=1;f--){
            if((n-s)%f)continue;
            //f is b-1
            //f is q, (n-s)//f is (b-1)
            b = (n-s)/f+1;
            if(n%b+n/b==s && b>(ll)(sqrt(n))){
                res = b;
                return;
            }
        }
    }
}


int main()
{
    cin>>n>>s;
    solve();
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;

    VL dp(N+1, 0), rec(N+1, 0);
    for(ll i = N-1; i >= 0; i--){
        if(S[i] == 'x'){
            rec[i] = rec[i+1];
            continue;
        }
        if(i >= N - C - 1){
            dp[i] = 1;
            rec[i] = max(rec[i+1], dp[i]);
        }else{
            dp[i] = rec[i+C+1] + 1;
            rec[i] = max(rec[i+1], dp[i]);
        }
    }

    if(rec[0] > K){
        return 0;
    }

    ll i = 0, k = K;
    VL ans;
    while(true){
        //cerr << i << endl;
        ll j = i;
        while(true){
            if(dp[j] == k) break;
            j++;
        }
        //cerr << j << endl;
        ll x = j+1;
        bool f = true;
        while(true){
            if(dp[x] == k){
                f = false;
            }
            if(rec[x] == k-1){
                break;
            }
            x++;
        }
        //cerr << x << endl;
        if(f) ans.push_back(j+1);
        i = j + C + 1; 
        k--;
        if(k == 0) break;
    }   

    for(auto as : ans) cout << as << endl;
    //rep(i, 0, N+1) cerr << i << " " << dp[i] << " " << rec[i] << endl;
    return 0;
}

Measured memory_bytes: 6516
#include <iostream>
#include <math.h>
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using namespace std;
using ll = long long;
int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (a * b * 4 < (c - a - b) * (c - a - b) && (c - a - b) > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(1,n):
    s1 = set(s[:i])
    s2 = set(s[i:])
    s_intersection = s1 & s2
    if len(s_intersection) > ans:
        ans = len(s_intersection)
        
print(ans)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
#include<stdio.h>
#include<string.h>
using namespace __gnu_pbds;
using namespace std;

template <typename T>  using orderedSet =
       tree<T, null_type, less<T>,
       rb_tree_tag, tree_order_statistics_node_update>;

/*

orderedSet os;

os.insert(5);
os.insert(2);
os.insert(6);

cout << *os.find_by_order(0)<<endl; // 2

cout << os.order_of_key(5) << endl;  // 2
*/
typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define pr pair<int, int>
#define graph vector< vector<int> >
#define vs vector<string>
#define mn -
#define pls +
#define mod %
#define E =
#define EE ==
#define pls +
#define le <=
#define ge <=
//int mx=9999999;
/**  '' "\n" x ^ **/
void YES()
{
    cout<<"YES\n";
}

void NO()
{
    cout<<"NO\n";
}
void yes()
{
    cout<<"Yes\n";
}

void no()
{
    cout<<"No\n";
}
int main() {
    /**  '' "\n" x ^ **/
    /** printf("\n") */
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;
    sf(n);sf(k);
    if(n%k==0){
        cout<<0<<endl;
        return 0;
    }
    else
    {
        if(n<k)
        {
            ll y=abs( n mn k);
            n=abs( n mn k);
            n=abs( n mn k);
            if(y<n)
            cout<<y;
            else cout<<n;
        }
        else
        {
            n=n%k;
            //cout<<abs( n mn k);

            ll y=abs( n mn k);
            n=abs( n mn k);
            n=abs( n mn k);
            if(y<n)
            cout<<y;
            else cout<<n;
        }
    }
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
f=True

for i in range(1,n):
	if h[-i]>=h[-i-1]:
		pass
	else:
		h[-i-1]-=1

for i in range(1,n):
	if h[i]>=h[i-1]:
		f=True
	else:
		f=False
		break

if f:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 20772
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;
#define MOD 1000000007

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<vector<int>> v = vector<vector<int>>(9, vector<int>(10, 0));
    for(int i = 1; i <= n; i++) {
        int num = i;
        int matsubi = num % 10;
        
        while(num >= 10) {
            num /= 10;
        }
        int front = num - 1;
        
        v[front][matsubi]++;
    }
    
    ll ans = 0;
    for(int i = 0; i < 9; i++) {
        for(int j = 1; j < 10; j++) {
            // cout << "(i, j) = " << i + 1 << ", " << j << " : " << v[i][j] << " " <<  v[j - 1][i] << endl;
            ans += v[i][j] * v[j - 1][i + 1];
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[5005],B[5005],n,m,here,ans;

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

    for(int i=0;i<n;i++)cin >> A[i];
    for(int i=0;i<m;i++)cin >> B[i];

    for(int i=0;i<m-ans;i++){
        for(int j=0;j<n;j++){
            if(B[i+here]==A[j]){
                here++;
            }
        }
        ans=max(ans,here);
        here=0;
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3128
#include <stdio.h>
 int main(void){
  char s[100000];
  int len=0,count=0;
  int i;
  scanf("%s",s);
  while(s[len])
   len++;
  for(i=0;i<len;i++){
   if(s[i]==s[i+1]){
    if(s[i]=='0'){
      s[i+1]='1'; count++;
    }
    else{
     s[i+1]='0';count++;
   }
   }

 }
 printf("%d",count);

   return 0;
 }


Measured memory_bytes: 256
(declaim (optimize (speed 3) (debug 0) (safety 0)))
(defvar n (read))
(defvar a (make-array (1+ n) :element-type 'fixnum))
(defvar x 0)
(defvar y 0)
(loop for i from 0 below n
      do (setf (aref a i) (read)))
(sort a #'<)
(loop for i from 0 below n 
      do (setq x (+ x (aref a i)))
      when (> (aref a (1+ i)) (* x 2))
      do (setq y i))
(format t "~A~%" (- n y))

Measured memory_bytes: 57704
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, R;
  cin >> N >> R;
  int ans = 0;
  if (N >= 10) {
    ans = R;
  } else {
    ans = (10 - N) * 100 + R;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scn = new Scanner(System.in);
        String str = scn.nextLine();
        Boolean a = str.charAt(2) == (str.charAt(3));
        Boolean b = str.charAt(4) == (str.charAt(5));
        if(a && b) System.out.println("Yes");
        else System.out.println("No");
    }
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int x;
	cin>>x;
	if(x >= 30){printf("Yes\n");}
	else{printf("No\n");}
	
	return 0;
};

Measured memory_bytes: 3632
n = gets.chomp.to_i
t, a = gets.chomp.split(' ').map(&:to_i)
hs = gets.chomp.split(' ').map(&:to_i)

INF = 100_000_000

idx = -1
diff = INF
hs.each.with_index(1) do |x, i|
  tp = t - x  * 0.006
  c_diff = (a - tp).abs
  if c_diff < diff
    diff = c_diff
    idx = i
  end
end
puts idx


Measured memory_bytes: 1788
package main

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

func main() {
	scan_init()
	var s,t string
	fmt.Scan(&s,&t)
	spilits := strings.Split(s,"")
	spilitt := strings.Split(t,"")
	count := 0
	for i:= 0; i<len(s); i++ {
		if spilits[i] != spilitt[i] {
			count ++
		}
	}
	fmt.Println(count)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}


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

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pll;

#define mp make_pair
#define pb push_back
#define fir first
#define sec second

#define fo0(i,a,b) for(int i=(a);i<(b);i++)
#define fo1(i,a,b) for(int i=(a);i<=(b);i++)
#define fd0(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define fd1(i,a,b) for(int i=(a);i>=(b);i--)
#define mset(a,b) memset(a,(b),sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))

template<typename T> inline void in(T &x){x=0;int fl=1;char ch=getchar();while(ch<'0'||ch>'9')
{if(ch=='-')fl=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}x*=fl;}
template<typename T> void out(T x){if(x<0){putchar('-');x=-x;}if(x/10)out(x/10);putchar(x%10+'0');}
template<typename T> inline void outln(T x){out(x);putchar(10);}
template<typename T> inline void outsp(T x){out(x);putchar(' ');}
template<typename T> inline T gcd(T a, T b){T t;if(a>b){while(b){
t=b;b=a%b;a=t;}return a;}else{while(a){t=a;a=b%a;b=t;}return b;}}
template<typename T> inline T lcm(T a, T b){return a/gcd(a,b)*b;}

const int N = 100005;

int n, X, x, g;

int main(){
	in(n); in(X);
	fo1(i, 1, n){
		in(x);
		if(!g)	g = abs(x-X);
		else	g = gcd(g, abs(X-x));
	}
	outln(g);
	return 0;
}

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

using namespace std;
#define lint long long

signed main() {
    int N;
    cin >> N;
    
    vector<lint> A(N);
    map<lint, int> used;
    
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        ++used[A[i]];
    }
    
    vector<lint> pow_2;
    lint num = 1;
    while(num <= pow(10, 10)){
        pow_2.push_back(num);
        num *= 2;
    }    
    sort(A.begin(), A.end());
    
    int cnt = 0;
    
    for(int i = N - 1; i >= 0; --i){
        int pos = 0;
        if(used[A[i]] == 0){
            continue;
        }
        while(pow_2[pos] <= A[i]){
            ++pos;
        }
        
        if(used[pow_2[pos] - A[i]] > 0){
            if(2 * A[i] != pow_2[pos]){
                ++cnt;
                --used[pow_2[pos] - A[i]];
                --used[A[i]];
            } else {
                if(used[A[i]] > 1){
                    ++cnt;
                    used[A[i]] -= 2;
                }
            }
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 26752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            int N;int K;
            Multi(out N, out K);
            var p = GetIntArray();

            var sum = Enumerable.Repeat(0, N+K+1).ToArray();
            for(int i = 1; i < N+1; i++)
            {
                sum[i] = sum[i] + sum[i - 1] + p[i - 1];
                sum[i + K] -= p[i-1];
            }
            int max = int.MinValue;
            int maxn = 0;
            for(int i = 0; i < N - K + 1; i++)
            {
                if (sum[i + K] > max)
                {
                    max = sum[i + K];
                    maxn = i;
                }
            }
            double ans = 0;
            for(int i = 0; i < K; i++)
            {
                ans += (p[maxn + i] + 1.0) / 2;
            }

            Console.WriteLine(ans);
        }

        


        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

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

int main(){
	int x, y;
	unsigned long long int W, H;
	cin >> W >> H >> x >> y;

	printf("%.5lf ", W*H / 2.0);

	if ((double)W / 2 == x&&(double)H / 2 == y)
		cout << 1 << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
class UnionFind():
  def __init__(self,n):
    self.parents = [-1]*n
  
  def find(self,x):
    if self.parents[x] < 0:
      return x
	
    self.parents[x] = self.find(self.parents[x])
    return self.parents[x]
  
  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)
    
    if x==y:
      return
    
    if self.parents[x]>self.parents[y]:
      x,y=y,x
	
    self.parents[x]+=self.parents[y]
    self.parents[y] = x
  
  def same(self,x,y):
    return self.find(x) == self.find(y)
  
  def size(self,x):
    return abs(self.parents[self.find(x)])


N,M=map(int,input().split())
uf = UnionFind(N+1)

cnt=(N)*(N-1)//2
L=[[int(x) for x in input().split()] for _ in range(M)]
ans=[]

for a,b in L[::-1]:
  ans.append(cnt)
  if not uf.same(a,b):
    cnt -= uf.size(a)*uf.size(b)
    uf.union(a,b)

for x in ans[::-1]:
  print(x)

Measured memory_bytes: 31156
s = input()
K = int(input())
subs = []
for i in range(0, len(s)):
    for j in range(i+1, i+K+1):
        if i == j:
            subs.append(s[i])
        else:
            subs.append(s[i:j])
subs = list(set(subs))
subs.sort()
print(subs[K-1])


Measured memory_bytes: 5068
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const double pi=acos(-1);
const ll P = 998244353, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n){ll r=1%P;for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
const double eps=1e-5;
const ll maxn=3e5+10;
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll pos[maxn];
ll head[maxn],_next[2*maxn],to[2*maxn],w[2*maxn];
ll cnt,tot;
void add(ll x,ll y,ll ww)
{
   cnt++,_next[cnt]=head[x],head[x]=cnt,to[cnt]=y,w[cnt]=ww;
   cnt++,_next[cnt]=head[y],head[y]=cnt,to[cnt]=x;w[cnt]=ww;
}
int a[maxn];
int summ0[maxn],summ1[maxn],sum1[maxn],sum0[maxn];
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
  char x;
  cin>>x;
  if(x=='W')
    
    {
      a[i]=0;
      sum0[i]=sum0[i-1]+1;
      sum1[i]=sum1[i-1];
    }
  else {
    a[i]=1;
     sum0[i]=sum0[i-1];
      sum1[i]=sum1[i-1]+1;
  }
}
  for(int i=n;i>=1;i--)
  {
      if(a[i]==0)
      {
        summ0[i]=summ0[i+1]+1;
        summ1[i]=summ1[i+1];
      }
      else

      {
        summ0[i]=summ0[i+1];
        summ1[i]=summ1[i+1]+1;
      } 
  }
int _min=1e8;
  for(int i=1;i<=n;i++)
  {
   _min=min(_min,sum0[i-1]+summ1[i+1]);
  }
  /*for(int i=1;i<=n;i++)
  {
    cout<<sum0[i]<<' ';
  }
  cout<<endl;
   for(int i=1;i<=n;i++)
  {
    cout<<summ1[i]<<' ';
  }
  cout<<endl;*/
  cout<<_min<<endl;

  
}

Measured memory_bytes: 9464
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
int n;
char s[500005],t[500005];
int fail[500005],Fail[500005];
inline void getfailS(){
	fail[1]=0;int j=0;
	for (int i=2;i<=n;++i){
		while(j&&s[j+1]!=s[i]) j=fail[j];
		if (s[j+1]==s[i]) ++j;
		fail[i]=j;
	}
}
inline void getfailT(){
	Fail[1]=0;int j=0;
	for (int i=2;i<=n;++i){
		while(j&&t[j+1]!=t[i]) j=Fail[j];
		if (t[j+1]==t[i]) ++j;
		Fail[i]=j;
	}
}
int ans=0;
int main(){
	ios::sync_with_stdio(false);
	scanf("%s",s+1);
	n=1;
	while(s[n+1]!='\0') ++n;
	for (int i=1;i<=n;++i) t[i]=s[n-i+1];//reversed
	getfailS();getfailT();int len=n-fail[n];
	if (len==1){
		cout<<n<<endl<<1<<endl;return 0; 
	}
	if (len==n){
		cout<<1<<endl<<1<<endl;return 0;
	}
	if (n%len){
		cout<<1<<endl<<1<<endl;return 0;
	}
	for (int i=1;i<n;++i){// cut between i and i+1
		int j=n-i;
		if ((fail[i]==0||i%(i-fail[i]))&&(Fail[j]==0||j%(j-Fail[j]))) ++ans;
	}
	cout<<2<<endl<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5248
h,w,k=map(int,input().split())
x=[list(input()) for i in range(h)]
a=[['*']*w]+[[0]*w for i in range(h)]
n=0
for i in range(1,h+1):
  f=False
  if '#' in x[i-1]:
    n+=1
    for j in range(w):
      if x[i-1][j]=='#':
        if f:
          n+=1
        else:
          f=True
      a[i][j]=n
  else:
    for j in range(w):
      a[i][j]=a[i-1][j]
if '#' not in x[0]:
  c=['*']*w
  for j in range(1,h+1):
    if a[j]!=c:
      for k in range(j-1,0,-1):
        for i in range(w):
          a[k][i]=a[k+1][i]
      break
for i in range(1,h+1):
  print(*a[i]) 

Measured memory_bytes: 8264
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	t := make([]int, n+1)
	x := make([]int, n+1)
	y := make([]int, n+1)
	t[0] = 0
	x[0] = 0
	y[0] = 0
	check := true
	for i := 1; i <= n ; i++ {
		fmt.Scan(&t[i],&x[i],&y[i])
		dis := math.Abs(float64(x[i-1]-x[i])) + math.Abs(float64(y[i-1]-y[i]))
		idis := int(dis)
		if (t[i]-t[i-1]) < idis || (t[i]-t[i-1]) % 2 != idis%2 {
			check = false
		}
	}
	if check {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 5504
#include <iostream>

using namespace std;

const int MOD = 1000000007;
const int MAX = 210000;

long long finv[MAX], inv[MAX];

void invInit() {
	inv[1] = finv[0] = finv[1] = 1;
	for (int i = 2; i < MAX; ++i) {
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long nCr(int n, int r) {
	if (n < r || n < 0 || r < 0) return 0;
	long long res = 1;
	for (int i = n; i > n - r; --i) (res *= i) %= MOD;
	return res * finv[r] % MOD;
}

long long poww(long long x, long long n) {
	if (n == 0) return 1;
	if (n & 1) return (x * poww(x * x % MOD, n >> 1)) % MOD;
	return poww(x * x % MOD, n >> 1) % MOD;
}

int main() {
	invInit();
	long long n, a, b; cin >> n >> a >> b;
	long long ans = poww(2, n) - 1;
	ans -= nCr(n, a) + nCr(n, b);
	ans = (ans % MOD + MOD) % MOD;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>

int main(void)
{
    int n, k;
    scanf("%d%d", &n, &k);
    int num = 1;

    int i;
    for (i = 1; i <= n; i++) {
        if ((num + k) > (num * 2))
            num *= 2;
        else
            break;
    }
    for (; i <= n; i++)
        num += k;
    
    printf("%d\n", num);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int p, q;
 
    while (cin >> p >> q) { 
	int Quo[100], Rem[100];    
	bool flg = false;
	int begin, end, t = 0;
 
	for (int i = 0; i < 100; i++, t++) {
	    p *= 10;
	    Quo[i] = p / q;
	    Rem[i] = p % q;
	    p %= q;
 
	    for (int j = 0; j < i; j++) {
		if (Quo[i] == Quo[j] && Rem[i] == Rem[j]) {
		    begin = j;
		    end = i;
		    goto end;
		}
	    }
       
	    if (!p) {
		flg = true;
		break;
	    }
	}
    end:
	if (flg) {
	    for (int i = 0; i <= t; i++) {
		cout << Quo[i];
	    }
	    cout << endl;
	} else {
	    for (int i = 0; i < t; i++) {
		cout << Quo[i];
	    }
	    cout << endl;
    
	    for (int i = 0; i < begin; i++) cout << " ";
	    for (int i = begin; i < end; i++) cout << "^"; 
	    cout << endl;
	}    
    }
    return 0;
}

Measured memory_bytes: 2996
import java.util.Scanner;
class Main{
    int a,b,c;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        if (a < b){
            if (b < c){
                System.out.println(a + " " + b + " " + c);
            }else if(a < c){
                    System.out.println(a + " " + c + " " + b);
            }else{
                System.out.println(c + " " + a + " " + b);
            }
        }else if(b < a){
            if(a < c){
                System.out.println(b + " " + a + " " + c);
            }else if(b < c){
                System.out.println(b + " " + c + " " + a);
            }else{
                System.out.println(c + " " + b + " " + a);
            }
        }
    }
    public static void main(String[] args){
        new Main().solve();     
    }
 
}

Measured memory_bytes: 17224
#include <bits/stdc++.h>
using namespace std;
int n;
int a[31];
int main()
{
	a[0]=1;
	a[1]=1;
	a[2]=a[0]+a[1];
	for(int i=3; i<31; i++)
	{
		a[i]=a[i-1]+a[i-2]+a[i-3];
	}
	while(cin >> n && n>0)
	{
		cout << (((a[n]+9)/10)+364)/365 << endl;
	}
	return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
#define int long long
int a[114];
using namespace std;
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        a[i]=a[i]/400;
    }
    sort(a,a+n);
    int sum1=0;
    int sum2=0;
    for(int i=0;i<n;i++){
        if(a[i]<=7&&a[i]!=a[i+1]){
            sum1++;
        }
        if(a[i]>=8){
            sum2++;
        }
    }
    if(sum1==0){
        cout<<sum1+1<<" "<<sum1+sum2<<endl;
    }
    else{
        cout<<sum1<<" "<<sum1+sum2<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	string s;
	cin>>s;
	// cout<<s<<endl;
	s[s.find(",")] = ' ';
	s[s.find(",")] = ' ';
	cout<<s<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<unordered_map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<bitset>
#include<fstream>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
#include<fstream>
const ll INF=9223372036854775807;
const ll mod=1000000007;
int  MOD(int  a, int  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b, ll  c)
{
    return max(c,max(a,b));
}
ll min3(ll  a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y,ll mod1)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod1;
        y = y>>1;
        x = (x*x)%mod1;
    }
    return res;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x,ll p)
{
    return power(x,p-2,p);
}
int main()
{
    fastio;
    string str;
    cin>>str;
    int n=str.length();
    vi f_l(n+1,-1),l_r(n+1,n+1);
    for(int j=n-1;j>=0;j--)
    {
        if(str[j]=='L')
        {
            f_l[j]=j;
        }
        else
        {
            f_l[j]=f_l[j+1];
        }
    }
    for(int j=0;j<n;j++)
    {
        if(str[j]=='R')
        {
            l_r[j]=j;
        }
        else
        {
            if(j!=0)
            {
                l_r[j]=l_r[j-1];
            }
        }
    }
    vi ans(n);
    for(int i=0;i<n;i++)
    {
        if(str[i]=='L')
        {
            int dist=i-l_r[i];
            if(dist%2==1)
            {
                ans[l_r[i]+1]++;
            }
            else
            {
                ans[l_r[i]]++;
            }
        }
        else
        {
            int dist=f_l[i]-i;
            if(dist%2==0)
            {
                ans[f_l[i]]++;
            }
            else
            {
                ans[f_l[i]-1]++;
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        cout<<ans[i]<<' ';
    }
}



Measured memory_bytes: 1872
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;

struct apair {
	string first;
	int second;
	int id;
};

int N, t2;
string t;
vector<struct apair> rest;

bool cmp(struct apair first, struct apair second);

int main(void)
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		cin >> t >> t2;
		rest.push_back((struct apair){t, t2, i});
	}
	sort(rest.begin(), rest.end(), &cmp);
	for (int i = 0; i < rest.size(); ++i)
		printf("%d\n", rest[i].id + 1);
	return 0;
}

bool cmp(struct apair first, struct apair second)
{
	if (first.first != second.first)
		return first.first < second.first;
	return first.second > second.second;
}


Measured memory_bytes: 256