akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(ll i = f; i < t; i++)

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 998244353;
const ll MAX = 300001;

ll fact[MAX], finv[MAX];

ll n, a, b, k;

ll modpow(ll n, ll p) {
    ll v = 1, q = n;
    for (auto i = 0; MOD >> i > 0; i++) {
        if (((p >> i) & 1) == 1) {
            v *= q;
            v %= MOD;
        }
        q *= q;
        q %= MOD;
    }
    return v;
}

void init() {
    fact[0] = 1;
    finv[0] = 1;
    forin(i, 1, MAX) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    forin(i, 0, MAX) {
        finv[i] = modpow(fact[i], MOD - 2);
    }
}

ll comb(ll n, ll k) {
    return fact[n] * finv[k] % MOD * finv[n - k] % MOD;
}

int main() {
    init();
    
    cin >> n >> a >> b >> k;
//    n = 90081; a = 33447; b = 90629; k = 6391049189;
//    n = 2; a = 5; b = 6; k = 0;
    
    ll pat = 0;
    
    for (ll i = 0; i <= n; i++) {
        auto beauty = a * i;
        if (k < beauty || (k - beauty) % b != 0)
            continue;
        auto j = (k - beauty) / b;
        if (j > n)
            continue;
        pat += comb(n, i) * comb(n, j) % MOD;
        pat %= MOD;
    }
    
    cout << pat << endl;

}



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

int yakusuu(int n){
	int count = 0;
	for (int i = 1; i <= n; ++i) {
		if(n%i == 0){
			count++;
		}
	}
	return count;
}

int main(){
	int N;
	cin >> N;
	
	int ans = 0;
	REP(i,N){
		if(i%2 == 0) continue;
		if(yakusuu(i) == 8) ans++;
	}
	
	cout << ans << endl;
    return 0;
}



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

int main()
{
    long long int N, M, bot = 0, ans = 0;
    cin >> N >> M;
    vector<pair<long long int, long long int>> p(N);

    for (int i = 0; i < N; ++i)
        cin >> p[i].first >> p[i].second;
    sort(p.begin(), p.end());

    for (int i = 0; i < N; ++i)
    {
        bot += p[i].second;
        ans += p[i].first * p[i].second;
        if (bot > M)
        {
            ans -= p[i].first * (bot - M);
            break;
        }
    }
    cout << ans << endl;
}

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


namespace Test1 {

    


    class ClassMain {

       
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                //int n = int.Parse(line);
                //if (n == 0) { break; }
                int[] pasta = new int[3];
                int[] j = new int[2];
                pasta[0] = int.Parse(line);
                for (int i = 1; i < 3; i++) {
                    pasta[i] = int.Parse(Console.ReadLine());
                }
                for (int i = 0; i < 2; i++) {
                    j[i] = int.Parse(Console.ReadLine());
                }
                Array.Sort(pasta);
                Array.Sort(j);
                int minPasta =pasta[0];
                int minJ = j[0];
                Console.WriteLine(minPasta+minJ-50);
                break;
            }
        }

        
    }



    
}

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

int a, b;
int p[11], q[11];
int n;
int cnt = 0;
int ara[11], used[11];

int isAra(int ara[], int p[])
{
    for (int i = 1; i <= n; i++) {
        if (ara[i] != p[i]) {
            return 0;
        }
    }
    return 1;
}

void permutation(int at, int used[], int ara[])
{
    if (at == n + 1) {
        cnt++;
        if (isAra(ara, p) == 1) {
            a = cnt;
        }
        if (isAra(ara, q) == 1) {
            b = cnt;
        }
        return ;
    }
    for (int i = 1; i <= n; i++) {
        if (used[i] == 0) {
            used[i] = 1;
            ara[at] = i;
            permutation(at + 1, used, ara);
            used[i] = 0;
        }
    }
}

int main( )
{
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    for (int i = 1; i <= n; i++) {
        cin >> q[i];
    }
    permutation(1, used, ara);
    cout << abs(a - b) << '\n';
    return 0;
}


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

using namespace std;

int main(){
	string s;
	int n;
	cin >> s;
	n = s.size();
	if((s[0]==s[n-1])^(n%2==1)){
			cout <<"First"<< endl;
		}else{
			cout <<"Second"<<endl;
		}
}
	

Measured memory_bytes: 512
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> ret;
  long long fib[100];

  int n;

  cin >> n;

  fib[0] = 1;
  fib[1] = 1;

  for(ii=2;ii<=n;ii++){
    fib[ii] = fib[ii-1] + fib[ii-2];
  }

  cout << fib[n] << endl;

  
  
  return 0;
}



Measured memory_bytes: 3108
n, m = map(int, input().split())
H = list(map(int, input().split()))
T = [list(map(int, input().split())) for _ in range(m)]

ans = [1] * n

for i in range(m):
    if H[T[i][0] - 1] > H[T[i][1] - 1]:
        ans[T[i][1] - 1] = 0
    elif H[T[i][0] - 1] < H[T[i][1] - 1]:
        ans[T[i][0] - 1] = 0
    else:
        ans[T[i][0] - 1] = 0
        ans[T[i][1] - 1] = 0

print(ans.count(1))

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

int main() {
  int n;
  cin >> n;
  
  int* ar = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }

  int min;
  bool init = true;
  for (int p = 0; p < 101; p++) {
    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += (ar[i] - p) * (ar[i] - p);
    }
    if (init) {
      min = sum;
      init = false;
    } else {
      min = min > sum ? sum : min;
    }
  }
  cout << min;
  delete[] ar;
  return 0;
}

Measured memory_bytes: 256
while True:
    m,r,f = map(int, input().split()) 
    result = ''
    if m == -1 and r == -1 and f == -1:
        break
    if m == -1 or r == -1:
        result = 'F'
    elif m + r >= 80:
        result = 'A'
    elif  m + r >= 65 and m + r < 80:
        result = 'B'
    elif  m + r >= 50 and m + r < 65:
        result = 'C'
    elif  m + r >= 30 and m + r < 50:
        if f >= 50:
            result = 'C'
        else:
            result = 'D'
    else:
        result = 'F'
    print(result)



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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>> &pq) {return (ll)pq.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>, greater<T>> &pq) {return (ll)pq.size(); }
ll sz(string &s) {return (ll)s.size(); } 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }



int main(){
    ll n,t;
    cin >> n >> t;
    ll a[n],b[n];
    rep(i,0,n) cin >> a[i] >> b[i];
    ll dp[2][n+1][t];
    rep(i,0,2) rep(j,0,n+1) rep(k,0,t) dp[i][j][k] = 0;

    rep(i,0,n){
        rep(j,0,t){
            // 0 -> 0
            dp[0][i+1][j] = max(dp[0][i+1][j],dp[0][i][j]);
            if(j+a[i] < t) dp[0][i+1][j+a[i]] = max(dp[0][i+1][j+a[i]],dp[0][i][j]+b[i]); 

            // 1 -> 1
            dp[1][i+1][j] = max(dp[1][i+1][j],dp[1][i][j]);
            if(j+a[i] < t) dp[1][i+1][j+a[i]] = max(dp[1][i+1][j+a[i]],dp[1][i][j]+b[i]); 

            // 0 -> 1
            dp[1][i+1][j] = max(dp[1][i+1][j],dp[0][i][j]+b[i]);
        }
    }

    ll ans = 0;
    rep(i,0,t){
        ans = max(ans,dp[1][n][i]);
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 144352
Scanf.scanf "%d %d" @@ fun n m ->
let lr = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun l r -> l, r)) in
let lM = Array.fold_left (fun lM (l, _) -> max lM l) 0 lr in
let rm = Array.fold_left (fun rm (_, r) -> min rm r) n lr in
Printf.printf "%d\n" (max 0 (rm - lM + 1))


Measured memory_bytes: 7552
#include <stdio.h>

int calc(int x,int y){
	if(y == 0){
		return x;
	}else{
		return calc(y,x%y);
	}
}

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	if(x >= y)
		printf("%d\n",calc(x,y));
	else{
		printf("%d\n",calc(y,x));
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <string> vs;

const int INF = (int) 1E9 + 5;
const ll LINF = (ll) 4E18 + 5;


#define F first
#define S second
#define si size()
#define le length()
#define be begin()
#define en end()
#define mp make_pair
#define mt make_tupple

#define forz(i,n) for(int i=(0);i<(n);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define rforz(i,n) for(int i=(n-1);i>=(0);i++)
#define rfore(i,a,b) for(int i=(a);i>=(b);i--)
	

#define pb push_back
#define pof pop_front
#define pf push_front
#define pob pop_back

#define Mod 1000000007

#define ALL(v) (v).begin(), (v).end()
#define SET(a, x) memset((a), (x), sizeof(a))

#define SORT(x) sort(ALL(x))
#define GSORT(x) sort(ALL(x), greater<typeof(*((x).begin()))>())

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<endl
#define o2(a,b) cout<<a<<" "<<b<<endl

#define test int t; cin>>t; while(t--)

#define mod(a) max(a,-a)

template<typename T> T gcd(T a, T b) { return (b == 0) ? abs(a) : gcd(b, a % b); }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a, b) * b; }

/*calling template
cout<<gcd<int>(2,5);
cout<<gcd<ll>(234,5432);*/



int main(){
	FASTIO;
	
	string s;
	int k;
	cin>>k;
	cin>>s;
	
	if(s.size()<=k){cout<<s<<'\n';}
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"...\n";
	}
	
	return 0;
}

Measured memory_bytes: 3612
import numpy as np

N = int(input())
s = [input() for _ in range(N)]


ABarray = np.zeros((N, 2), dtype=int)
count = 0
for i, alp in enumerate(s):
    ABarray[i, 0] = 1 if (alp[-1] == 'A') else 0
    ABarray[i, 1] = 1 if (alp[0] == 'B') else 0
    count += alp.count('AB')

both = np.count_nonzero(np.all(ABarray == 1, axis=1))
ABsum = np.sum(ABarray, axis=0)
Aonly = ABsum[0] - both
Bonly = ABsum[1] - both

if Aonly == 0 and Bonly == 0 and both >= 1:
    count += both - 1
else:
    count += min(Aonly, Bonly) + both
print(count)


Measured memory_bytes: 12768
#include<iostream>

using namespace std;

int main() {
	int N, A, B, Asum, Bsum, min=1999999;

	cin >> N;

	for (int i = 1; i <= N; i++) {
		A = i;
		B = N - A;
		if (B > 0) {
			Asum = A % 10 + A / 10 % 10 + A / 100 % 10 + A / 1000 % 10 + A / 10000 % 10 + A / 100000 % 10;
			Bsum = B % 10 + B / 10 % 10 + B / 100 % 10 + B / 1000 % 10 + B / 10000 % 10 + B / 100000 % 10;
			if (min > Asum + Bsum) {
				min = Asum + Bsum;
			}
		}
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int h = sc.nextInt();
    int w = sc.nextInt();
    int n = sc.nextInt();

    int a[] = new int[n];

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

    List<Integer> list = new ArrayList<>(w * h);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < a[i]; j++) {
        list.add(i + 1);
      }
    }

    boolean reverse = false;
    List<String> lines = new ArrayList<>(h);
    for (int i = 0; i < h; i++) {
      List<Integer> line = list.subList(i * w, (i + 1) * w);
      if (reverse)
        Collections.reverse(line);
      lines.add(line.stream().map(String::valueOf).collect(Collectors.joining(" ")));
      reverse = !reverse;
    }
    os.println(String.join(System.lineSeparator(), lines));
  }
}


Measured memory_bytes: 35708
s[9],c[9];main(n,m){for(;scanf("%d%d",&m,&n)*m;puts("")){int q[1024]={0},i,t,p=m;for(t=i=1;n--;i++){scanf("%s",s,*c=0);i%3||strcat(c,"Fizz");i%5||strcat(c,"Buzz");*c||sprintf(c,"%d",i);for(strcmp(s,c)&&p>1&&(q[t]=p--);q[t=t%m+1];);}for(t=i=0;m--;q[++i]||(t=printf(" %d"+!t,i)));}}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int N=2e5+5;
int t[2][4*N],n,lazy[2][4*N];
bool marked[2][4*N];

void push(int v,int i) {
    if (marked[v]) {
        t[i][v*2]=max(t[i][v*2],lazy[i][v]);
        t[i][v*2 +1]=max(t[i][v*2 +1],lazy[i][v]);
        lazy[i][v*2]=max(lazy[i][v*2],lazy[i][v]);
        lazy[i][v*2 +1]=max(lazy[i][v*2 +1],lazy[i][v]);
        lazy[i][v]=0;
        marked[i][v*2] = marked[i][v*2+1] = true;
        marked[i][v] = false;
    }
}

void update(int v, int tl, int tr, int l, int r, int new_val,int i) {
    if (l > r) 
        return;
    if (l == tl && tr == r) {
    	// push(v,i);
        lazy[i][v]=max(lazy[i][v],new_val);
        t[i][v]=max(t[i][v],new_val);
        marked[i][v] = true;
    } else {
        push(v,i);
        int tm = (tl + tr) / 2;
        update(v*2, tl, tm, l, min(r, tm), new_val,i);
        update(v*2+1, tm+1, tr, max(l, tm+1), r, new_val,i);
        t[i][v]=max(t[i][v*2],t[i][v*2 +1]);
    }
}

int get(int v, int tl, int tr, int pos,int i) {
    if (tl == tr) {
        return t[i][v];
    }
    push(v,i);
    int tm = (tl + tr) / 2;
    if (pos <= tm) 
        return get(v*2, tl, tm, pos,i);
    else
        return get(v*2+1, tm+1, tr, pos,i);
}

void solve(){
	fr(i,0,2){
		fr(j,0,4*N){
			t[i][j]=1;
		}
	}
	int n,q;
	cin>>n>>q;
	ll ans=0;
	while(q--){
		int i,y;
		cin>>i>>y;
		i--;
		int mn=get(1,1,n,y,i);
		// cout<<mn<<endl;
		ans+=(n-1LL-mn);
		if(i==0)
		update(1,1,n,1,n-mn,n-y+1,i^1);
		else
		update(1,1,n,1,n-mn,n-y+1,i^1);
	}
	// cout<<ans<<endl;
	ans=((n-2)*1LL*(n-2) - ans);
	cout<<ans<<endl;
	return;
}

int main()
{
	boost();
	
	int tc=1;
	//cin>>tc;
	while(tc--)
		solve();
	return 0;
}

Measured memory_bytes: 14976
import numpy as np
N, D = list(map(int, input().split()))

X = []

for n in range(N):
    X.append(np.array(list(map(int, input().split()))))


count = 0
for i in range(N-1):
    for j in range(i + 1, N):
        d = np.linalg.norm(X[i]-X[j])
        if int(d) == d:
            count += 1
print(count)


Measured memory_bytes: 21548
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 405;
int N, a[maxn];
long long  s[maxn],dp[maxn][maxn];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    

    cin>>N;
    for(int i = 0; i<N; i++){
        cin>>a[i];
        if(i==0)s[i] = a[i];
        else s[i] = s[i-1]+a[i];
    }
    
    
    //dp[i][i]， 区间长度从2遍历默认是0
    for(int l = 2; l<= N; l++){
        for(int i = 0, j = l-1; j < N; i++,j++){
            dp[i][j] = dp[i+1][j];
            for(int k = i+1; k <j; k++){
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j]);
            }
            dp[i][j] += s[j] - (i>0?s[i-1]:0);
        }
    }
    cout<<dp[0][N-1]<<endl;


    
    return 0;
}



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

long long solve(const vector<int> &as, int sign){
    long long cost = 0;
    long long cum = 0;
    for (auto a : as){
        cum += a;
        if (cum * sign <= 0){
            cost += abs(cum - sign);
            cum = sign;
        }
        sign = -sign;
    }
    return cost;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> as(n);
    for (auto & a : as) cin >> a;
    long long score0 = solve(as, 1);
    long long score1 = solve(as, -1);
    cout << min(score0, score1) << endl;
    return 0;
}

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

using namespace std;

int main() {
    
    vector<int> num2017 = vector<int>(100001, 0);
    vector<bool> check = vector<bool>(100001, 1);
    for (int i = 2; i < 100001; ++i)
    {
        if (check[i])
        {
            for (int j = i * 2; j < 100001; j += i)
            {
                check[j] = 0;
            }
        }
    }
    vector<bool> check2017 = check;
    for (int i = 2; i < 100001; ++i)
    {
        if (check[i])
        {
            if (!check[((i + 1) / 2)])
            {
                check2017[i] = 0;
            }
        }
    }
    int no = 0;
    check2017[2] = 0;
    
    for (int i = 2; i < 100001; ++i)
    {
        if (check2017[i])
        {
            no++;
        }
        num2017[i] = no;
    }
    
    int q;
    cin >> q;
    
    int l, r;
    while (q--)
    {
        cin >> l >> r;
        cout << num2017[r] - num2017[l - 1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int main(){
    long long x;
    cin >> x;

    long long ans = x / 11 * 2;
    x%=11;

    if(x == 0){
        ;
    }else if(x <= 6) ans++;
    else ans += 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
main() {
  int N,Q; cin>>N>>Q;
  string S; cin>>S;
  vector<int> xs(S.size());
  for(int i=1; i<S.size(); ++i)
    if(S[i-1]=='A' && S[i]=='C') xs[i]=1;
  for(int i=1; i<xs.size(); ++i) xs[i]+=xs[i-1];
  for(int q=1; q<=Q; ++q) {
    int l,r; cin>>l>>r; --l; --r;
    cout<< xs[r]-xs[l] <<endl;
  }
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

int main() {
	SS(double,R);
	p(R*2*3.1415926535897932);
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int T, k, n, a, b, c, d;
int main(){
	cin>>T;
	while(T--){
		cin>>a>>b>>c>>d;
		n = a + b;
		int l = 0, r = n, pos = n;
		k = (max(a, b) - 1) / (min(a, b) + 1) + 1;
		while(l <= r){
			int mid = l + r >> 1;
			int A = a - mid / (k + 1) * k - mid % (k + 1), B = b - mid / (k + 1);
			if(B <= 1LL * k * A)l = mid + 1;
			else r = mid - 1, pos = mid;
		}
//		printf("pos=%d\n", pos);
		int A = a - pos / (k + 1) * k - pos % (k + 1), B = b - pos / (k + 1), tmp = l + B - k * A + 1;
		for(int i = c;i <= min(d, pos); i++)putchar(i % (k + 1) ? 'A' : 'B');
		for(int i = max(pos + 1, c);i <= d; i++)putchar((i - tmp) % (k + 1) ? 'B' : 'A');
		puts("");
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	char a[4][4];

	int i, j;

	for (i = 0; i < 3; i++){
		for (j = 0; j < 4; j++){
			scanf("%c", &a[i][j]);
		}
	}

	printf("%c%c%c\n", a[0][0], a[1][1], a[2][2]);
	return 0;
}


Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,k=MI()
    hh=LI()
    hh.sort()
    if k>=n:
        print(0)
        exit()
    if k==0:
        print(sum(hh))
        exit()
    print(sum(hh[:-k]))

main()

Measured memory_bytes: 25744
//Problem Y

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl "\n"

const ll mx = 1000000000000001;
 
int main ()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #define int ll
  
  int n;
  cin >> n;
  //n--;
  string answer = "";
  
  while (n > 0){
    n--;
    int digit = n%26;
    n/=26;
    answer += (digit + 'a');
    
  }

  reverse(answer.begin(), answer.end());
  cout << answer << endl;

  
  return 0;
  
}


Measured memory_bytes: 3660
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#define ll long long
using namespace std;
//ll k[100004];
////ll j[100004];
//
//int main()
//{
// 	ll n;
// 	ll m;
// 	ll y=0;
//	 ll ans=1e9;
// 	scanf("%lld%lld",&n,&m);
//	ll p=m;
// 	for(ll i=1;i<=n;i++)
// 	{
// 		scanf("%lld",&k[i]);
//	}
//	sort(k+1,k+n+1);
//	for(ll i=1;i<=n-m+1;i++)
//	{
//		ans=min(k[p]-k[i],ans);
//		p=m+1;
//	}
//	printf("%lld\n",ans);
//	return 0;
//}
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    int h[100005];
    for(int i = 1; i <=n; i++)
        scanf("%d", &h[i]);
    sort(h+1, h + n+1);
    int ans = 1e9;
    for(int i = 1; i <= n - k+1; i++)
        ans = min(ans, h[i+k-1] - h[i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int A, B, C, X, Y;
        A = fs.nextInt();
        B = fs.nextInt();
        C = fs.nextInt();
        X = fs.nextInt();
        Y = fs.nextInt();

        int price = 0;
        while (X != 0 || Y != 0) {
            if (C*2 <= A+B && X >=1 && Y >= 1) {
                price += C*2;
                --X; --Y;
            }
            else if (X > 0 && C*2 <= A) {
                price += C*2;
                --X;
            }
            else if (X > 0 && C*2 > A) {
                price += A;
                --X;
            }
            else if (Y > 0 && C*2 <= B) {
                price += C*2;
                --Y;
            }
            else {
                price += B;
                --Y;
            }
        }

        System.out.println(price);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

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




Measured memory_bytes: 32380
#include<stdio.h>
int main(){
    long H;
    long mem = 1;
    long times = 0;
    scanf("%ld",&H);
    
    while(1){
        H /= 2;
        if(H <= 0){
            times += mem;
            break;
        }else{
            times += mem;
            mem *= 2;
        }
    }
    printf("%ld\n",times);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=1000;
const int MOD=1000000007;

int n,mnsz,mxsz,mncnt,mxcnt;

int dp[MAXN+1][MAXN+2];
int C[MAXN+1][MAXN+1];
int F[MAXN+1];
int inv[MAXN+1];
int Finv[MAXN+1];
int Finvp[MAXN+1][MAXN+1];

void run() {
	scanf("%d%d%d%d%d",&n,&mnsz,&mxsz,&mncnt,&mxcnt);
	
	REPE(i,n) { C[i][0]=C[i][i]=1; FOR(j,1,i) C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD; }
	F[0]=1; FORE(i,1,n) F[i]=(ll)F[i-1]*i%MOD;
	inv[1]=1; FORE(i,2,n) inv[i]=(ll)(MOD-(MOD/i))*inv[MOD%i]%MOD;
	Finv[0]=1; FORE(i,1,n) Finv[i]=(ll)Finv[i-1]*inv[i]%MOD;
	REPE(i,n) Finvp[i][0]=1; REPE(i,n) FORE(j,1,n) Finvp[i][j]=(ll)Finvp[i][j-1]*Finv[i]%MOD;
	
	REPE(i,n) dp[i][mxsz+1]=i==0?1:0;
	for(int sz=mxsz;sz>=0;--sz) REPE(i,n) {
		dp[i][sz]=dp[i][sz+1];
		if(sz>=mnsz) for(int cnt=mncnt;cnt<=mxcnt&&cnt*sz<=i;++cnt) {
			dp[i][sz]=(dp[i][sz]+(ll)C[i][cnt*sz]*F[cnt*sz]%MOD*Finvp[sz][cnt]%MOD*Finv[cnt]%MOD*dp[i-cnt*sz][sz+1])%MOD;
		}
	}
	printf("%d\n",dp[n][0]);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define int long long
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;

signed main(){
    speed;
    int n; cin >> n;
    int ans = 0;
    map<pair<int,int>, int> cnt, cnt2;
    for(int i = 1; i <= n; i++) {
        if(i % 10 == 0) continue;
        int s = i % 10;
        int f = s;
        int k = i;
        while(k != 0) {
            f = k % 10;
            k /= 10;
        }
        cnt[{f, s}]++;
    }
    for(int i = 1; i <= n; i++) {
        if(i % 10 == 0) continue;
        int s = i % 10;
        int f = s;
        int k = i;
        while(k != 0) {
            f = k % 10;
            k /= 10;
        }
        if(s == f) {
            k = cnt[{f, s}];
            ans += k * k;
            cnt[{f, s}] = 0;
            cnt[{s, f}] = 0;
        }
        ans += cnt[{s, f}] * cnt[{f, s}] * 2;
        cnt[{f, s}] = 0;
        cnt[{s, f}] = 0;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define in(n)  int n; cin>>n;
#define loop for(int i=0;i<n;i++)
#define pb push_back
#define pf push_front
using namespace std;
int  main()
{
string n;
cin>>n;
cout<<n[0]<<n.length()-2<<n[n.length()-1];

}	

	


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

int main()
{
  int N, K;
  int val = 1;
  
  cin >> N >> K;
  
  for(int i=0; i<N; i++)
  {
    if(val + K > val * 2)
    {
      val *= 2;
    }
    else
    {
      val += K;
    }
  }
  cout << val << endl;
}


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

int main()
{
    int x,y;
    cin >> x >> y;

    if(x == y) cout << "Draw" << endl;
    else if(x>y && y != 1) cout << "Alice" << endl;
    else if(x>y && y == 1) cout << "Bob" << endl;
    else if(y>x && x != 1) cout << "Bob" << endl;
    else if(y>x && x == 1) cout << "Alice" << endl;

    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

int main(){
   char b;
   cin >> b;
   if(b == 'A'){
      cout << 'T' << endl;
   }
   if(b == 'T'){
      cout << 'A' << endl;
   }
   if(b == 'G'){
      cout << 'C' << endl;
   }
   if(b == 'C'){
      cout << 'G' << endl;
   }
   return 0;
}

Measured memory_bytes: 256
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

const ll MAX = 1e9+5;


int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    int n;
    cin>>n;

    double prob[n+1];
    for(int i=1; i<=n; i++){
        cin>>prob[i];
    }

    double dp[n+1][n+1];
    dp[0][0] = 1.0;
    for(int j=1; j<=n; j++){
        dp[0][j] = 0;
    }

    for(int i=1; i<=n; i++){
        dp[i][0] = (1 - prob[i])*dp[i-1][0];
    }

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            dp[i][j] = prob[i]*dp[i-1][j-1] + (1 - prob[i])*dp[i-1][j];
        }
    }

    double ans = 0;
    for(int j=n; j>n/2; j--){
        ans += dp[n][j];
    }

    cout<<setprecision(10)<<ans<<endl;

    return 0;
}


Measured memory_bytes: 70528
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>
#include <memory.h>
#include <ctime>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <fstream>
#include <cassert>

using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, b, a) for(int i = b - 1; i >= a; --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)

#define ALL(V) V.begin(), V.end()
#define SIZE(V) (int)V.size()
#define pb push_back
#define mp make_pair
#define EPS 1e-7
#define Pi 3.14159265358979
#define FILL(a,v) memset(a,v,sizeof(a))

using namespace std;


typedef long long Long;
typedef unsigned long long ULong;
typedef unsigned int Uint;
typedef unsigned char Uchar;
typedef vector <int> VI;
typedef pair <int, int> PII;


const int M = 1000000007;
const int MAXN = 107;

Long binpow(Long b, int p) {
    Long res = 1;
    while (p > 0) {
        if (p&1)
            res *= b;
        b*=b;
        b%=M;
        res %= M;
        p >>= 1;
    }
    return res;
}


Long col(int h) {
    return binpow(2,h);
}
int n;

Long dps[MAXN];
Long dpd[MAXN];
Long dpc[MAXN][MAXN];


Long solve(VI h) {
    int n = h.size();
    if (n == 0)
        return 1;

    dps[0] = dpd[0] = (2*col(h[0]-2))%M;
    REP(i,n) {
        if (h[i] <= h[0])
            dpc[0][i] = (2*col(h[0]-h[i]))%M;
    }

    FOR(i,1,n) {
        dps[i] = dps[i-1]*col(h[i]-h[i-1])%M;
        dpd[i] = dpd[i-1]*col(h[i]-h[i-1])%M;
        if (h[i] <= h[i-1])
            dpd[i] += dpc[i-1][i];
        else
            dpd[i] += dpc[i-1][i-1]*col(h[i]-h[i-1])%M;
        dps[i] %= M;
        dpd[i] %= M;


        FOR(j, i, n) {
            if (h[j] > h[i])
                continue;

            if (h[j] >= h[i-1]) {
                dpc[i][j] = 2*dpc[i-1][i-1]*col(h[i]-h[j]);
                continue;
            }

            if (h[i] >= h[i-1])
                dpc[i][j] = (dpc[i-1][j] + dpc[i-1][i-1])*col(h[i] - h[i-1]);
            else {
                dpc[i][j] = dpc[i-1][j] + dpc[i-1][i];
            }
        }
        REP(j,n)
            dpc[i][j] %= M;

    }
//
//    REP(i,n) {
//        cout << dps[i] << "\t" << dpd[i] << "\t";
//        REP(j,n)
//            cout << dpc[i][j] << "\t";
//        cout << endl;
//    }

//    cout << dps[n-1] + dpd[n-1] << endl;

    return (dps[n-1] + dpd[n-1])%M;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;

    Long res = 1;

    int t;
    VI h;


    REP(i,n) {
        cin >> t;
        if (t == 1) {
            res *= solve(h);
            res %= M;
            res *= 2;
            res %= M;
            h.clear();
        } else {
            h.pb(t);
        }
    }

    res *= solve(h);

    cout << res%M << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>

using namespace std;

int main(){
  string str;

  cin >> str;
  int a[26] = {0};
  for(int i = 0;i < str.length() ; i++){
    a[str[i]%26]++;
  }
  int flag = 0,b = 19,j = 0;
  while(flag == 0){
    if(a[b] == 0){
      flag = 1;
    }
    else{
      b++;
      j++;
      b = b%26;
    }
    if(j > 25){
      break;
    }
  }
  char c = 'a'+j;
  if(flag == 1){
    cout << c << endl;
  }
  else{
    cout << "None" << endl;
  }

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;

const int N=1e5+10;
const int INF=1e9+10;
pii dat[N];

bool cmp(const pii& rh1, const pii& rh2) {
    return rh1.second < rh2.second;
}

int getMax(const multiset<int>& st){
    assert(st.size());
    return *(--st.end());
}

int l1,l2,r1,r2;
int getAns(){
    return max(0,r1-l1+1)+max(0,r2-l2+1);
}

void solve(){
    int n;
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++){
        scanf("%d%d",&dat[i].first,&dat[i].second);
        ans=max(ans,dat[i].second-dat[i].first+1);
    }
    sort(dat+1,dat+n+1,cmp);

    multiset<int>lst,rst;
    for(int i=1;i<=n;i++) rst.insert(dat[i].first);

    for(int l=1,r=1;l<=n;l=r+1,r=l){
        while(r+1<=n && dat[r+1].second==dat[l].second) r++;
        int mi=INF,ma=0;
        for(int i=l;i<=r;i++){
            rst.erase(rst.lower_bound(dat[i].first));
            mi=min(mi,dat[i].first);
            ma=max(ma,dat[i].first);
        }
        r1=dat[1].second,r2=dat[l].second;
        if(l==1 && r==n){
            l1=mi,l2=ma;
            ans=max(ans,getAns());
        }
        else if(l==1){
            if(r-l+1==1) {}
            else{
                l1=mi,r2=max(ma,getMax(rst));
                ans=max(ans,getAns());

                l1=ma,r2=max(mi,getMax(rst));
                ans=max(ans,getAns());
            }
        }
        else if(r==n){
            l1=getMax(lst),l2=ma;
            ans=max(ans,getAns());
            if(r-l+1==1) {}
            else{
                l1=max(getMax(lst),ma),r2=mi;
                ans=max(ans,getAns());

                l1=max(getMax(lst),mi),r2=ma;
                ans=max(ans,getAns());
            }
        }
        else{
            l1=getMax(lst),l2=max(getMax(rst),ma);
            ans=max(ans,getAns());
            if(r-l+1==1) {}
            else{
                l1=max(getMax(lst),mi),l2=max(getMax(rst),ma);
                ans=max(ans,getAns());
                l1=max(getMax(lst),ma),l2=max(getMax(rst),mi);
                ans=max(ans,getAns());
            }
        }
        for(int i=l;i<=r;i++) lst.insert(dat[i].first);
    }

    lst.clear(),rst.clear();
    for(int i=1;i<=n;i++) lst.insert(dat[i].first),rst.insert(dat[i].second);
    for(int i=1;i<=n;i++){
        lst.erase(lst.lower_bound(dat[i].first));
        rst.erase(rst.lower_bound(dat[i].second));
        ans=max(ans,max(0,(*rst.begin())-(*(--lst.end()))+1)+dat[i].second-dat[i].first+1);
        lst.insert(dat[i].first);
        rst.insert(dat[i].second);
    }

    printf("%d\n",ans);
}

int main(){

    solve();
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> p;

int main(){
    int A, B, K;
    cin >> K >> A >> B;
    
    for(int i = A; i<=B; i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    
}


Measured memory_bytes: 3616
#include <sstream>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int bubble_sort(vector<int> &list) {
  int count = 0;
  for (int i = 0; i < list.size(); ++i) {
    for (int j = list.size() - 1; j > i; --j) {
      if (list[j] < list[j-1]) {
        int tmp = list[j];
        list[j] = list[j-1];
        list[j-1] = tmp;
        count++;
      }
    }
  }
  return count;
}

int main() {
  int N;
  cin >> N;
  cin.ignore();
  string str;
  getline(cin, str);
  string tmp;
  vector<int> v;
  istringstream istr(str);
  while (getline(istr, tmp, ' ')) {
    v.push_back(stoi(tmp));
  }
  int count = bubble_sort(v);
  for (auto iter = v.begin(); iter != v.end() - 1; ++iter) {
    cout << *iter << " ";
  }
  cout << v.back() << endl;
  cout << count << endl;
}

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

int main() {
  long long N;
  cin >> N;
  int c = N / 15;
  int e = N % 15;
  long long d = c * 60;
  long long k=0;
  for(int i = 0; i<e+1; i++){
    if((i % 3) != 0 && (i % 5) != 0){
      k += i + (15 * c);
    }
  }
  cout << d * c + k << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <cstdio>

using namespace std;

int cards[200];
int N, K;

int getMax() {
  int mx = 0;
  for (int i = 0; i < N - K + 1; i++) {
	int t = 1;
	for (int j = 0; j < K; j++) {
	  t *= cards[i + j];
	}
	mx = max(t, mx);
  }
  return mx;
}

void solve() {
  int tmax = getMax();
  int smax = 0;
  for (int i = 0; i < N; i++) {
	for (int j = i + 1; j < N; j++) {
	  swap(cards[i], cards[j]);
	  smax = max(getMax(), smax);
	  swap(cards[i], cards[j]);
	}
  }
  if (tmax > smax) {
	cout << "NO GAME" << endl;
  } else {
	cout << smax - tmax << endl;
  }
}

int main() {
  while (cin >> N >> K) {
	if (N == 0 && K == 0) {
	  break;
	}

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

	solve();
  }
}

Measured memory_bytes: 864
#include <iostream>

using namespace std;

const int w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

int main(){
  int n;
  while (cin >> n) {
    for (int i = 0; n > 0; i++) {
      if (n % 2)
        (n < 2) ? cout << w[i] << endl : cout << w[i] << " ";
      n = n / 2;
    }
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int q;

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

    void run() {
        FastReader sc = new FastReader();
        q = sc.nextInt();
        Primes p = new Primes();
        boolean[] isPrimes = p.primeSieve(100000);
        int[] likeNums = new int[100001];
        for (int i = 1; i < 100001; i += 2) {
            if (isPrimes[i] && isPrimes[(i + 1) / 2]) {
                likeNums[i] = 1;
            }
        }
        for (int i = 1; i < 100001; i++) {
            likeNums[i] = likeNums[i - 1] + likeNums[i];
        }
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(likeNums[r + 1] - likeNums[l - 1]);
        }
    }

    class Primes {
        boolean[] primeSieve(int n) {
            boolean[] isPrime = new boolean[n+1];
            for (int i = 2; i <= n; i++) {
                isPrime[i] = true;
            }

            // mark non-primes <= n using Sieve of Eratosthenes
            for (int factor = 2; factor*factor <= n; factor++) {

                // if factor is prime, then mark multiples of factor as nonprime
                // suffices to consider mutiples factor, factor+1, ...,  n/factor
                if (isPrime[factor]) {
                    for (int j = factor; factor*j <= n; j++) {
                        isPrime[factor*j] = false;
                    }
                }
            }
            return isPrime;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 69896
#include <iostream>

using namespace std;

int main()
{
    int M,N;
    cin>>N>>M;
    int *A = new int[N];
    float sum = 0;
    for(int i =0;i < N;i++){
        cin>>A[i];
        sum+=A[i];
    }
    int temp = 0;
    for(int i = 0;i<N;i++){
        if(A[i] >= (sum / (4 * M))){
            temp++;
        }
        if(temp >= M){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.BitSet;
import java.util.Scanner;
 
public class Main {
 
    static Scanner sc = new Scanner(System.in);
 
    static BitSet primes() {
        int SIZE = 1 << 15;
        BitSet ret = new BitSet(SIZE);
        ret.set(2, SIZE);
        for (int i = 2; i < SIZE; ++i) {
            if (!ret.get(i)) continue;
            for (int j = i * i; j < SIZE; j += i) {
                ret.clear(j);
            }
        }
        return ret;
    }
 
    public static void main(String[] args) {
        BitSet psset = primes();
        int[] ps = new int[psset.cardinality()];
        int idx = 0;
        for (int i = 0; i < psset.size(); ++i) {
            if (psset.get(i)) ps[idx++] = i;
        }
        while (true) {
            int N = sc.nextInt();
            if (N == 0) break;
            int ans = 0;
            for (int i = 0; i < ps.length && ps[i] <= N / 2; ++i) {
                if (psset.get(N - ps[i])) ++ans;
            }
            System.out.println(ans);
        }
    }
 
}

Measured memory_bytes: 17880
import itertools

N, M, K = map(int, input().split())
A = list(map(int, input().split()))  # (N,)
B = list(map(int, input().split()))  # (M,)


A_accum = [0] + list(itertools.accumulate(A))
B_accum = [0] + list(itertools.accumulate(B))

book_num = 0

b_best = M
for n in range(N + 1):
    for m in range(b_best, -1, -1):
        if A_accum[n] + B_accum[m] <= K:
            b_best = m
            if book_num < n + m:
                book_num = n + m
            break

print(book_num)


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

int main() {

  while(1) {

    int H, W;
    cin >> H >> W;

    if (H == 0 && W == 0) {
      return 0;
    }

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (i % 2 == 0) {
          if (j % 2 == 0) {
            cout << "#";
          } else {
            cout << ".";
          }
        } else {
          if (j % 2 == 0) {
            cout << ".";
          } else {
            cout << "#";
          }
        }
      }
      cout << endl;
    }
    cout << endl;

  }

  return 0;

}


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int cnt=0;
    for(int i=a;i<=b;++i){
        if(c%i==0) cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
const int maxn = 300001;
string w;
int bc[maxn];
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> w;
	int n = w.size();
	if(n < 3)puts("0");
	else{
		long long ans = 0;
		bc[n - 2] = w[n - 2] == 'B' and w[n - 1] == 'C';
		for(int i = n - 3;i > -1;--i){
			if(w[i] == 'A' and w[i + 1] == 'B' and w[i + 2] == 'C'){
				ans += bc[i + 3] + 1;
				bc[i] = bc[i + 3] + 1;
				bc[i + 1] = 0;
				bc[i + 2] = bc[i + 3];
				w[i] = 'B';w[i + 1] = 'C';w[i + 2] = 'A';
			}
			else if(w[i] == 'B'){
				if(w[i + 1] == 'C')bc[i] = bc[i + 2] + 1;
			}
		}
		cout << ans << '\n';
	}
}


Measured memory_bytes: 1300