akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,x,n) for (int i = x; i < n; i++)
using ll = long long int;
int main() {
    int N,M,K;
    cin >> N >> M >> K;
    vector<int> A(N),B(M);
    rep(i,N) cin >> A.at(i);
    rep(i,M) cin >> B.at(i);
    vector<ll> SA(N+1),SB(M+1);
    rep(i,N) SA.at(i+1) = SA.at(i)+A.at(i);
    rep(i,M) SB.at(i+1) = SB.at(i)+B.at(i);
    int ans=0,j=M;
    rep(i,N+1) {
        if(SA.at(i)>K) break;
        while(SB.at(j)>K-SA.at(i)) j--;
    ans=max(ans,i+j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7936
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
    template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
    template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
    template<typename T> void chadd(T& a, T b) { a = a + b; }

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t sz;
        inp(std::size_t _sz = 1) : sz(_sz) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
        template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
    };

    inp inp1; // input one
}

int main() {

    double r = inp1;

    cout << fixed << setprecision(7) << r * 2.0 * acos(-1) << endl;

    return 0;
}


Measured memory_bytes: 3752
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	rep(i, n){
		int hh;
		cin >> hh;
		h.at(i) = hh;
	}
	vector<vector<int>> mp(n);
	rep(i, m){
		int a,b;
		cin>> a >> b;
		a--;
		b--;
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	int ans =0;
	rep(i, n){
		if(mp.at(i).size() == 0){
			ans++;

		}else{
		rep(j, mp.at(i).size()){
			if(h[i] <= h.at(mp[i][j])){

				break;

			}

			if(j + 1 == mp.at(i).size()){
				ans++;

			}
		}
		}
	}

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


Measured memory_bytes: 8800
#include<stdio.h>

int GCD(int x, int y);

int main(void)
{
  int x[100], y[100], z, gcd[100], lcm[100]={0};
  int i=0;

  while(scanf("%d %d", &x[i], &y[i])!=EOF){

      if(x[i] <= y[i]){
	z = y[i];
	y[i] = x[i];
	x[i] = z;
      }
      
      gcd[i] = GCD(x[i], y[i]);
      lcm[i] = (x[i])*((y[i])/gcd[i]);

      i++;   
  }
    
  for(z=0; z<i; z++){
    printf("%d %d\n", gcd[z], lcm[z]);
  } 
   
 return 0;
}

int GCD(int x, int y)
{
  int z;
  
  while(x % y != 0){
      z = x % y;
      x = y;
      y = z;
    }

  return y;
}

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

int main(){
    int a,b;
    b=0;
    cin>>a;
    while(a>0){
    if(a%10==0){
        a=a/10;
    }
    else{
        b+=1;
        a=(a-1)/10;
    }
    }
    cout<< b <<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,i;
    int l[11];
    int mlen=0,slen=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&l[i]);
        slen+=l[i];
        if(l[i]>mlen)mlen=l[i];
    }
    slen-=mlen;
    printf("%s\n",(mlen<slen)?"Yes":"No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    string a;
    int i,j,b;
    b=0;
    cin>>a;
    for (i=0;i<a.size();i++){
        if (i%2==1){
            if (a[i]=='L'||a[i]=='U'||a[i]=='D'){
                b=b+1;
            }
        }
        else{
            if (a[i]=='R'||a[i]=='U'||a[i]=='D'){
                b=b+1;
            }
        }
    }
    if (b==a.size()){
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n + 1 - i): 
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y and i + j + k == n:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Measured memory_bytes: 3060
from copy import deepcopy as copy

n, c = map(int, input().split())
sushi = [[0, 0]]+[[int(x) for x in input().split()] for _ in range(n)]

order = [0]*(n+1)
reverse = [0]*(n+1)

for i in range(n):
  order[i+1] = order[i]+sushi[i+1][1]
  reverse[i+1] = reverse[i]+sushi[n-i][1]

order_index = [i for i in range(n+1)]
reverse_index = [-i for i in range(n+1)]
for i in range(n):
  order[i+1] -= sushi[i+1][0]
  if order[i+1] <= order[i]:
    order[i+1] = order[i]
    order_index[i+1] = order_index[i]
  reverse[i+1] -= c-sushi[n-i][0]
  if reverse[i+1] <= reverse[i]:
    reverse[i+1] = reverse[i]
    reverse_index[i+1] = reverse_index[i]

order_back = copy(order)
reverse_back = copy(reverse)
for i in range(n+1):
  order_back[i] -= sushi[order_index[i]][0]
  if i != 0 and order_back[i] < order_back[i-1]:
    order_back[i] = order_back[i-1]
  reverse_back[i] -= (c-sushi[reverse_index[i]][0])%c
  if i != 0 and reverse_back[i] < reverse_back[i-1]:
    reverse_back[i] < reverse_back[i-1]

ans = 0
for i in range(n+1):
  sub = max(order[i]+reverse_back[n-i], order_back[i]+reverse[n-i])
  if ans < sub:
    ans = sub

print(ans)

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<60);

int main() {
  int n; cin >> n;
  int ans = 0;
  vector<string> s(n);
  vl t(n);
  rep(i,n) {
    cin >> s[i] >> t[i];
  }
  string X; cin >> X;
  bool flag = false;
  rep(i,n) {
    if (flag) ans += t[i];
    if (s[i] == X) flag = true;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#高速素因数分解  osa_k法 
def osa_k(a):
    tmp = set()
    while a > 1:
        tmp.add(sieve[a])
        a //= sieve[a]
    return tmp

    # 初期入力
import math
import sys
from bisect import bisect_left
from functools import reduce
input = sys.stdin.readline  #文字列では使わない
N = int(input())
A = list(map(int, input().split()))
used =set()

#not coprimeの判定
gcd_a =reduce(math.gcd,A)
if gcd_a !=1:
    ans ="not coprime"

#pairwise coprimeの判定
else:
    MAXN =10**6 +10
    #osa_k法
    sieve = [i for i in range(MAXN+1)]
    p = 2
    while p*p <= MAXN:
        if sieve[p] == p:
            for q in range(2*p,MAXN+1,p):
                if sieve[q] == q:
                    sieve[q] = p
        p += 1
    
    ans ="pairwise coprime"
    for a in A:
        aa =osa_k(a)
        if used & aa:
            ans ="setwise coprime"
            break #共通要素があったらpair_wではない→set_w
        used |=aa
    
print(ans)

Measured memory_bytes: 217220
MOD = 10 **9 + 7
INF = 10 ** 10
from collections import Counter
from copy import deepcopy

def main():
    N = int(input())
    D = Counter(map(int,input().split()))
    l = 0
    time = [0]
    either = []
    for k,v in D.items():
        if v == 1:
            l += 1
            either.append(k)
        elif v == 2:
            if k == 12:
                print(0)
                return
            time.extend((k,24 - k))
        else:
            print(0)
            return
    
    if l == 0:
        gap = INF
        for t in time:
            for s in time:
                if s == t:
                    continue
                gap = min(gap,min(abs(s - t),24 - abs(s - t)))
        print(gap)
        return
    
    ans = 0
    for bit in range(1<<l):
        T = deepcopy(time)
        gap = INF
        for i in range(l):
            if (bit>>i)&1:
                t = either[i]
            else:
                t = 24 - either[i]
            for x in T:
                gap = min(gap,min(abs(t - x),24 - abs(t - x)))
            T.append(t)
        ans = max(ans,gap)
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "-1" << endl;return 0
#define MM <<" "<<
#define Endl endl

int Ans[514][514];

int E(int l,int r,int k){
    if(r-l==0){
        return 0;
    }
    if(r-l==1){
        Ans[l][r]=k;
        return 0;
    }
    int m=(l+r+2)/2;
    for(int j=l;j<=r;j++){
        for(int i=l;i<=r;i++){
            if(i<m && m<=j){
                Ans[i][j]=k;
            }
        }
    }
    int f;
    f=E(l,m-1,k+1);
    f=E(m,r,k+1);
    return 0;
}


signed main(){
    int N;
    cin >> N;
    int f;
    f=E(1,N,1);
    REP(i,N){
        REP(j,N){
            if(i<j){
                cout << Ans[i+1][j+1] << " ";
            }
        }cout << endl;
    }
    return 0;
}   


Measured memory_bytes: 2560
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2019-04-30
 */
public class Main {

    private int arrayLen;
    private int arr[];

    private void init(Scanner sc) {
        arrayLen = sc.nextInt();
        arr = new int[arrayLen];
        for (int idx = 0; idx < arrayLen; idx++) {
            arr[idx] = sc.nextInt();
        }
    }

    private void printArray() {
        for (int idx = 0; idx < arrayLen-1; idx++) {
            System.out.print(arr[idx] + " ");
        }
        System.out.println(arr[arrayLen-1]);
    }

    private int bubbleSort() {
        int count = 0;

        boolean flag = true;
        for (int iter = 0; iter < arrayLen-1; iter+=1) {
            if (!flag) break;
            flag = false;

            for (int idx = 0; idx < arrayLen-1-iter; idx+=1) {
                if (arr[idx] > arr[idx+1]) {
                    count += 1;

                    // swap arr[idx] and arr[idx+1]
                    int tmp = arr[idx];
                    arr[idx] = arr[idx+1];
                    arr[idx+1] = tmp;
                    flag = true;
                }
            }

        }

        printArray();

        return count;
    }

    public static void main(String[] args) {
        Main bubbleSort = new Main();
        Scanner sc = new Scanner(System.in);
        bubbleSort.init(sc);
        int res = bubbleSort.bubbleSort();
        System.out.println(res);
    }
}



Measured memory_bytes: 26224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

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

    cout << a + a * a + a * a * a << endl;

    return 0;
    
}

Measured memory_bytes: 3616
fun main(args: Array<String>) {
    var (N, D, A) = listOfInt()
    var XH = Array(N) {
        var (x, h)= listOfLong()
        x to h
    }.sortedBy { it.first }
    val a = A.toLong()
    val d = 2L * D
    val q = Queue<Pair<Long, Long>>()
    var ans = 0L
    var total = 0L
    repeat (N) {
        var (x, h) = XH[it]
        while (q.count() > 0 && q.first().first < x) {
            total -= q.dequeue()!!.second
        }
        h -= total
        if (h > 0) {
            val num = (h + a - 1) / a
            ans += num
            val dmg = num * a
            total += dmg
            q.enqueue(x + d to dmg)
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt() = listOfString().map(String::toInt)
class Queue<T> {
    val elements = mutableListOf<T>()
    fun count() = elements.size
    fun isEmpty() = elements.isEmpty()
    fun first() = elements[0]
    fun enqueue(item: T) = elements.add(item)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int mod = 10;
/*

typedef vector<vi> M;
inline M operator*(const M & a, const M &b){
	M c(a.size(), vi(b[0].size()));
	rep(i, c.size()) rep(j, c[0].size()){
		ll s = 0;
		rep(k, a[0].size()) s += (ll)a[i][k] * b[k][j] % mod;
		c[i][j] = s % mod;
	}
	return c;
}
inline M pow(M a, ll m){
	M res(a.size(), vi(a.size()));
	rep(i, a.size()) res[i][i] = 1;
	for(; m; m /= 2){
		if(m & 1) res = res * a;
		a = a * a;
	}
	return res;
}
*/
ll pw(ll n, ll m){
	ll res = 1;
	for(n %= mod; m; m /= 2){
		if(m & 1) res = res * n % mod;
		n = n * n % mod;
	}
	return res;
}
int main(){
	
	ll n, m, k;
	cin >> n >> m >> k;
	n %= 10;
	
	
	ll N = pw(n, m);
	ll ans = 0;
	map<ll, pair<ll, int> > memo;
	
	ll cur = n;
	
	rep(i, k){
		
		ans += cur;
		
		if(memo.count(cur)){
			
			ll pans = memo[cur].first;
			int prev = memo[cur].second;
			
			int t = (k - i - 1) / (i - prev);
			
			ans += (ans - pans) * t;
			i += t * (i - prev);
		}
		
		memo[cur] = mp(ans, i);
		cur = cur * N % 10;
	}
	cout << ans << endl;
	
	/*
	ll N = pw(n, m); cerr<<n<<" "<<m<<"?"<<N<<endl; dbg(k);
	
	M A(2, vi(2));
	M b(2, vi(1));
	
	A[0][0] = N;
	A[1][0] = A[1][1] = 1;
	
	b[0][0] = 1;
	
	A = pow(A, k) * b;
	
	ll ans = A[1][0];
	ans = ans * n % mod;
	
	cout << ans << endl;
	*/
	return 0;
}


Measured memory_bytes: 1196
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using ll = long long;
using namespace std;        
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define ar array

const int N=2e5+9;
vector<int> g[N];
bool used[N];
int val[N];
int n,m;

int dfs(int u){
	used[u]=1;
	int y=1;
	for(auto x:g[u]){
		if(used[x]) continue;
		y+=dfs(x);
	}
	return y;
}

void solve(){
			memset(used,0,sizeof(used));
			cin>>n>>m;
			while(m--){
				int a,b;
				cin>>a>>b;
				a--;
				b--;
				g[a].pb(b);
				g[b].pb(a);
			}		
			int ans=-1e9;
			for(int i=0;i<n;i++){
				if(!used[i]){
					int y=dfs(i);
					ans=max(ans,y);
				}
			}	
			cout<<ans<<endl;





	

}

int main(){
	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);
//	freopen("input.txt",r,"stdin");
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}





Measured memory_bytes: 24036
# 篩を埋めながら解く方法と(NlogN), 公式解説の方法(N)
# 公式解説のO(N)で解く
N = int(input())
ans = 0
for x in range(1, N+1):
    y = N // x
    ans += y*(y+1)*x // 2
print(ans)


Measured memory_bytes: 63268
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    L = [None] * M
    R = [None] * M
    for i in range(M):
        L[i], R[i] = map(int, input().split())

    L_max = max(L)
    R_min = min(R)
    if L_max > R_min:
        print(0)
    else:
        print(R_min - L_max + 1)


if __name__ == "__main__":
    main()


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

int main(void){
    int n;
    cin >> n;
    
    int input;
    int a2 = 0;
    int a4 = 0;
    int i;
    for(i = 1; i <= n; i++){
        cin >> input;
        if(input % 4 == 0){
            a4++;
        }else if(input % 2 == 0){
            a2++;
        }
    }
    
    if(max(a2 - 1, 0) + (a4 * 2 + 1) >= n){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int n,c,k;
    cin>>n>>c>>k;
    vector<int> t(n);
    for(int i=0;i<n;i++) cin>>t[i];
    sort(t.begin(),t.end());
    int ans=0,cnt=1,time=t[0]+k;
    for(int i=1;i<n;i++){
        if(cnt==c || t[i]>time){
            ans++;
            cnt=1;
            time=t[i]+k;
        }
        else cnt++;
        if(i==n-1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){


    int n;
    cin>>n;
    int cou=0;
    int ans=0;
    for(int i=1;i<n+1;i++){
        cou=0;
        for(int j=1;j<i+1;j++){
            
        if(i%j==0&&i%2==1){
            cou++;
        }
        
        }
        if(cou==8){
            ans=ans+1;        }
    }
    
    cout<<ans;



return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple{
    private int x;
    void Solve(){
        //input
        x = io.Int;
        //cal
        var isABC = x < 1200;
        //ret
        Console.WriteLine(isABC?"ABC":"ARC");
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream(){
        Solve();
        io.writeFlush();
    }
}
class SimpleIO{
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[]{' '};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
    public SimpleIO(){
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next(){
        if(BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

/*bool IsPrime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) { // 素数ではない
			return false;
		}
	}
	// 素数である
	return true;
}*/
/*ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/
/*ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}*/
/*ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}*/
/*ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}*/
//printf("%.10f\n", n);

signed main() {
	string s, t;
	ll n, m, k, a = 0, b = 0, c = 0, cnt = 0;
	cin >> a >> b >> c >> k;
	while (a >= b) { b *= 2; cnt++; }
	while (b >= c) { c *= 2; cnt++; }
	if (cnt <= k) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
set<int> s;
int main()
{
	int n,m;
	cin>>n;
	while(n--)
	{
		cin>>m;
		if(s.find(m)!=s.end())
		s.erase(m);
		else
		s.insert(m);
		
	}
	cout<<s.size()<<endl;
	return 0;
	
	
}


Measured memory_bytes: 4864
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 20;

int n, a[20], x[20][20], y[20][20];

int main() {
	scanf("%d", &n);
	rep(i, 1, n) {
		scanf("%d", a + i);
		rep(j, 1, a[i]) scanf("%d %d", &x[i][j], &y[i][j]);
	}
	int lim = (1 << n) - 1;
	// printf("lim = %d\n", lim);
	int ans = 0;
	rep(s, 0, lim) {
		int num = 0;
		rep(i, 0, n - 1) num += ((s >> i) & 1);
		// printf("i = %d, num = %d\n", s, num);
		bool flag = 1;
		rep(i, 0, n - 1) {
			if (((s >> i) & 1)) {
				rep(j, 1, a[i + 1]) {
					if (((s >> x[i + 1][j] - 1) & 1) != y[i + 1][j]) {
						flag = 0;
						break;
					}
				}
			}
			if (!flag) break;
		}
		if (flag) ans = std::max(ans, num);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	input = parseInt(input, 10) ;
	

	console.log(input*input*input);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        m: usize,
        n: usize,
        a: [usize; n],
    }
    if m == 2 {
        let mut ans = n;
        for d in 1..3 {
            let mut v = d;
            let mut cost = 0;
            for a in a.iter() {
                if *a != v {
                    cost += 1;
                }
                v ^= 1 ^ 2;
            }
            ans = std::cmp::min(ans, cost);
        }
        println!("{}", ans);
        return;
    }
    let mut a = a;
    let mut ans = 0;
    for i in 1..n {
        if a[i] == a[i - 1] {
            ans += 1;
            a[i] = m + 1;
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 7080
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
        TIME_START = System.currentTimeMillis();
        solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        pw.close();
        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");

    }

    static void solve(Scanner sc, PrintWriter pw) throws IOException {
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++)
            a[i] = sc.nextInt();

        // 5 10 15
        // 20-15 + 5 , 5 , 5
        // 0 5 15
        // 20-15 + 0 5 10

        int[] diff = new int[n];
        diff[0] = k - a[n - 1] + a[0];
        for (int i = 1; i < n; i++)
            diff[i] = a[i] - a[i - 1];

        Arrays.sort(diff);
        int sum = 0;
        for (int i = 0; i < n - 1; i++)
            sum += diff[i];

        pw.println(sum);

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}


Measured memory_bytes: 46340
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  vi as;
  ll bs = 0;
  priority_queue<int,vector<int>,greater<int> > p;
  priority_queue<int> n;
  ll nsum = 0,psum=0;
  int m = -1;
  int cu = 0;
  REP(i,q){
    int d;
    cin >> d;
    if(d==1){
      int a,b;
      cin >> a >> b;
      if(m==-1) m=a;
      else if(a<m) n.push(a),cu--,nsum+=a;
      else p.push(a),cu++,psum+=a;
      if(cu==-1){
        cu=1;
        p.push(m);
        psum += m;
        m = n.top();
        nsum -= m;
        n.pop();
      }else if(cu==2){
        cu=0;
        n.push(m);
        nsum+=m;
        m = p.top();
        psum-=m;
        p.pop();
      }
      bs += b;
    }else{
      cout << m << " " << psum-nsum+((ll)n.size()-(ll)p.size())*m+bs << endl;
    }
  }
}



Measured memory_bytes: 3452
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  101LL
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

bool A[1000011LL];
int C[1000011LL];

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l,r,a=0,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=0;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    memset(A,true,sizeof(A));
    cin >> n;
    m = 10;
    vector<int> V(n);
    for(i=0;i<n;i++) {cin >> V[i]; C[V[i]]++; if(m<V[i]) m = V[i];}
    sort(all(V));
    for(i=0;i<n;i++)
    {
        if(A[V[i]])
            for(j=2*V[i];j<=m;j+=V[i]) A[j] = false;
    }
    ll ans  = 0;
    for(i=0;i<n;i++)
    {
        if(A[V[i]] and C[V[i]]<=1) ans++;
    }
    cout << ans ;
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 8936
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};
 
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b>c*d){
    cout<<a*b<<endl;
  }else{
    cout<<c*d<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;  

int n, k;
int a[N];

int32_t main()
{
	IOS;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1, a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]>k)
		{
			cout<<i-1;
			return 0;
		}
		k-=a[i];
	}
	if(k==0)
		cout<<n;
	else
		cout<<n-1;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int n = int.Parse(Console.ReadLine());
		// 文字列の入力
		string s = Console.ReadLine();
		string mae = s.Substring(0,n/2);
		//出力
		if(s.Equals(mae + mae)){
			Console.WriteLine("Yes");
		}
		else{
			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 11092
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int n;
    cin >> n;
    string s[n];
    rep(i, n) { cin >> s[i]; }
    map<char, int> m;
    string march = "MARCH";
    rep(i, 5) { m[march[i]] = 0; }

    rep(i, n) {
        rep(j, 5) {
            if (s[i][0] == march[j]) {
                if (m[s[i][0]] == 0) {
                    m[s[i][0]] = 1;
                } else {
                    m[s[i][0]] += 1;
                }
            }
        }
    }

    ll ans = 0;

    for (int i = 0; i < 32; i++) {
        ll temp = 1;
        bool judge[5] = {};
        int num = 0;
        rep(l0, 5) {
            if (i & (1 << l0)) {
                judge[l0] = true;
                num++;
            }
        }
        if (num != 3) {
            continue;
        }

        rep(l0, 5) {
            if (judge[l0]) {
                temp *= m[march[l0]];
            }
        }

        ans += temp;
    }

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

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


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

  int N;
  cin >> N;
  int A[N];
  rep(i,N) cin >> A[i];
  sort(A,A+N);
  bool ok = true;
  if(N % 2 == 1){
    if(A[0] != 0){
      ok = false;
    }
    for(int i=1;i<N;i+=2){
      if(A[i] != i+1 || A[i+1] != i+1){
        ok = false;
      }
    }
  }
  else{
    for(int i=0;i<N;i+=2){
      if(A[i] != i+1 || A[i+1] != i+1){
        ok = false;
      }
    }
  }
  int ans = 1;
  if(ok){
    rep(i,N/2){
      ans *= 2;
      ans %= MOD;
    }
    cout << ans << endl;
  }
  else cout << 0 << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

const int N = 100;

int main() {
    int M[N][N] = {};
    int n, u, k, v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (j) cout << ' ';
            cout << M[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define ul unsigned long long
#define ll long long
#define ld long double

const ld eps = 1.0e-10;

int main()
{
  ul a, b, c;

  cin >> a >> b >> c;

  ul cj1=4*a*b,cj2=(c-a-b)*(c-a-b);

  if (cj1>=cj2 || (a>=c||b>=c))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;

  return 0;
}

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

int main() {
  ll l, r;
  cin >> l >> r;
  int mod = 2019;
  r = min(r, l + mod);
  ll ans = mod;
  for (ll i = l; i < r; i++) {
    for (ll j = l + 1; j <= r; j++) {
      ans = min(ans, (i * j) % mod);
      if (ans == 0) {
        cout << ans << endl;
        return 0;
      };
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */

  for(i=0;i<VMAX+1;i++)
    C[i] = 0;
  

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    
  }

  for(j=1;j<=n;j++)
    C[A[j]]++;

  for(i=1;i<VMAX+1;i++)
    C[i] = C[i] + C[i-1];

  for(j=n;j>0;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i!=1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vector<mint> f2;
  f2.push_back(2);
  ll num = 2;
  while(num <= n) {
    mint x = f2.back().pow(2);
    f2.push_back(x);
    num *= 2;
  }
  mint ans = 1;
  rep(i, f2.size()) if(n >> i & 1) ans *= f2[i];
  ans -= 1;
  mint nca = 1, ncb = 1;
  rep(i, a) {
    nca *= (n - i);
    nca /= (a - i);
  }
  rep(i, b) {
    ncb *= (n - i);
    ncb /= (b - i);
  }
  ans -= nca;
  ans -= ncb;
  cout << ans.x << endl;
}


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

long bfs(long q,vector<bool> sta,vector<long> k,vector<vector<long>> s,vector<long> p,long N,long M){
    if(q==N){
        bool ok=true;
        for(int m=0;m<M;m++){
            long count=0;
            for(int i=0;i<k.at(m);i++){
                if(sta.at(s.at(m).at(i)-1)) count++;
            }
            if(count%2!=p.at(m)) ok=false;
        }
        
        if(ok) return 1;
        else return 0;
    }else{
        long result=0;
        sta.at(q)=false;
        result+=bfs(q+1,sta,k,s,p,N,M);
        sta.at(q)=true;
        result+=bfs(q+1,sta,k,s,p,N,M);
        return result;
    }
}

//main関数
int main() {
    //入力
    long N,M;
    cin>>N>>M;
    vector<long> k(M);
    vector<vector<long>> s(M,vector<long>(0));
    for(int i=0;i<M;i++){
        cin>>k.at(i);
        for(int j=0;j<k.at(i);j++){
            long ps;
            cin>>ps;
            s.at(i).push_back(ps);
        }
    }
    vector<long> p(M);
    for(int i=0;i<M;i++){
        cin>>p.at(i);
    }
    
    //計算
    
    //出力
    vector<bool> sta(N,0);
    cout<<bfs(0,sta,k,s,p,N,M)<<endl;
    
}

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

int main(){
  long n, a, b;
  cin >> n >> a >> b;
  if(a>b){
    cout << 0;
    return 0;
  }
  long ret=(b-a)*(n-2)+1;
  cout << (ret>0 ? ret : 0);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }
int main() {
  string S;
  cin >>S;
  ll a=0;
  ll b=0;
  
  rep(i,3) {
    if(S.at(i)=='A') {
a++;
    }
else if(S.at(i)=='B') {
b++;
}
  }
  
  
  
  if((a!=0) &&(b!=0)) {
cout<<"Yes"<<endl;
  }
else {
cout<<"No"<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);
class mint{
    public:
        ll x;
        static unsigned long long mod;
        static unsigned long long mod_plus;
        mint(){x = 0;}
        mint(ll _x) : x((_x < 0 ? ((_x += mod_plus) < 0 ? _x + mod_plus : _x) : _x)%mod){}
        /*mint& operator=(const ll &a){
            x = a;
            return *this;
        }*/

        mint operator-(){
            return x == 0 ? 0 : mod - x;
        }
        mint& operator+=(const mint& a){
            if((x += a.x) >= mod) x -= mod;
            return *this;
        }
        mint operator+(const mint& a) const{
            mint res(*this);
            return res += a;
        }
        mint& operator-=(const mint& a){
            if((x -= a.x) < 0) x += mod;
            return *this;
        }
        mint operator-(const mint& a) const{
            mint res(*this);
            return res -= a;
        }
        mint& operator*=(const mint& a){
            (x *= a.x)%=mod;
            return *this;
        }
        /*mint& operator*=(const ll& a){
            mint temp(a);
            return *this *= temp;
        }*/
        mint operator*(const mint& a) const{
            mint res(*this);
            return res *= a;
        }
        /*mint operator*(const ll& a) const{
            mint res(*this);
            return res *= a;
        }*/
        mint pow(unsigned long long pw) const{
            mint res(1), comp(*this);
            while(pw){
                if(pw&1) res *= comp;
                comp *= comp;
                pw >>= 1;
            }
            return res;
        }
        //以下、modが素数のときのみ
        mint inv() const{
            mint res(*this);
            return res.pow(mod - 2);
        }
        mint& operator/=(const mint &a){
            (x *= a.inv().x)%=mod;
            return *this;
        }
        mint operator/(const mint &a) const{
            mint res(*this);
            return res /= a;
        }
};
ostream& operator<<(ostream& os, const mint& a){
    os << a.x;
    return os;
}
unsigned long long mint::mod = 998244353;
unsigned long long mint::mod_plus = (LLONG_MAX / mint::mod) * mint::mod;
typedef vector<mint> vm;

vm fact(int(3e+5), 1);
mint nCm(ll n , ll m){
    return fact[n] / (fact[n-m] * fact[m]);
}

int main() {
    reps(i,2,int(3e+5)) fact[i] = fact[i-1] * i;
    cin>>N>>M>>K;
    mint ans(0);
    rep(k,K + 1){
        if(N - k - 1 < 0) break;
        mint temp(M - 1);
        ans += temp.pow(N - k - 1) * M * nCm(N - 1, k);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5452