akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    vector<int> V(3, 0);
    rep(i, n) {
        int a;
        cin >> a;
        if(a % 4 == 0) V[2]++;
        else if(a % 2 == 0) V[1]++;
        else V[0]++;
    }
    if(V[1] == 0) {
        if(V[0] <= V[2] + 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if(V[0] - V[2] <= 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, s = 0, rest = 0, div = 10;
    cin >> n;
    int nsave = n;
    while(n > 0){
        rest = n % 10;
        n /= 10;
        s += rest;
    }
    if(nsave % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3576
n = int(input())
A = list(map(int, input().split()))
B = sorted(A,reverse=True)

ans1=0
ans2=0
for i in range(n):
    if (i+2)%2==0:
        ans1+=B[i]
    else:
        ans2+=B[i]
print(int(ans1-ans2))


Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  if(a>b){
    d=a;
  a=b;
  b=d;
  }

  if(b>c){
     d=b;
   b=c;
   c=d;}

  if(a>b){
     d=a;
   a=b;
   b=d;
  }
  printf("%d %d %d\n",a,b,c); 


 return 0;
}

Measured memory_bytes: 1024
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			final int w = sc.nextInt();
			final int h = sc.nextInt();
			
			if(w == 0 && h == 0){
				break;
			}
			
			int DP[][][][] = new int[h][w][2][2];
			DP[0][0][0][0] = 1;
			DP[0][0][1][0] = 1;
			
			//0 -> left, 1 -> upper
			
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					for(int dir = 0; dir < 2; dir++){
						for(int can_change = 0; can_change < 2; can_change++){
							if(DP[i][j][dir][can_change] == 0){
								continue;
							}
							
							if(j != w - 1){
								if(dir == 0){							
									DP[i][j+1][0][1] += DP[i][j][dir][can_change];
									DP[i][j+1][0][1] %= 100000;
								}else if(can_change == 1){
									DP[i][j+1][0][0] += DP[i][j][dir][can_change];
									DP[i][j+1][0][0] %= 100000;
								}
							}
							
							if(i != h - 1){
								if(dir == 1){							
									DP[i+1][j][1][1] += DP[i][j][dir][can_change];
									DP[i+1][j][1][1] %= 100000;
								}else if(can_change == 1){
									DP[i+1][j][1][0] += DP[i][j][dir][can_change];
									DP[i+1][j][1][0] %= 100000;
								}
							}
						}
					}
				}
			}
			
			int sum = 0;
			for(int i = 0; i < 2; i++){
				for(int j = 0; j < 2; j++){
					sum += DP[h-1][w-1][i][j];
					sum %= 100000;
				}
			}
			
			System.out.println(sum);
		}
		
	}

}

Measured memory_bytes: 13000
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;



int main(){
	int a,b,n,sum;
	while( scanf("%d %d %d",&a,&b,&n) != EOF){
		a = a%b;
		sum = 0;
		for(int i=0;i<n;i++){
			a *= 10;
			sum += a/b;
			a = a%b;
			if(a==0)break;
		}
		printf("%d\n",sum);
	}
			
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll mod = 1e9+7;
ll const N=1e5+5;
ll fac[N];
ll invfac[N];
ll mul(ll a,ll b){
    ll t=(a*b);
    if(t>=mod)t%=mod;
    return t;
}
ll power(ll a,ll x){
    ll r=1;
    while(x!=0){
        if(x%2==1){
            r=r*a;r%=mod;
        }
        a=a*a;a%=mod;
        x=x/2;
    }
    return r;
}
ll add(ll a,ll b){
    ll t=(a+b);
    if(t>=mod)t-=mod;
        return t;
}
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        int n;cin>>n;
        string a[n];
        int t[n];
        rep(i,n)cin>>a[i]>>t[i];
        string s;cin>>s;
        int ans=0;
        int f=0;
        rep(i,n){
            if(f)ans+=t[i];
            if(s==a[i]){
                f=1;
            }
        }
        cout<<ans;
    }
    return 0;   
}

Measured memory_bytes: 256
N=int(input())
h=[int(i) for i in input().split()]
dp=[0]
for i in range(1,N):
    dp.append(1000000000)
for i in range(0,N):
    for j in range(1,3):
        if(j+i<N):
            dp[j+i]=min(dp[j+i],dp[i]+abs(h[i]-h[j+i]))
#print(dp)
print(dp[N-1])

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

int main() {
    int N, X;
    cin >> N >> X;
    int minM = 1000;
    for (int i = 0; i < N; i++){
        int m;
        cin >> m;
        minM = min(minM, m);
        X -= m;
    }
    int cnt = N;
    while (X-minM >= 0){
        cnt++;
        X -= minM;
    }
    cout << cnt << endl;
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<int> s(M), c(M);
    for(int i=0; i<M; ++i) cin >> s[i] >> c[i];

    for(int i=0; i<1000; ++i) {
        int k = i, tmp = 0;
        while(k > 0) {++tmp; k /= 10;}
        if(i == 0) tmp = 1;
        if(tmp != N) continue;

        bool ok = true;
        for(int j=0; j<M; ++j) {
            k = i;
            for(int l=0; l<N-s[j]; ++l) k /= 10;
            k %= 10;
            if(k != c[j]) ok = false;
        }
        
        if(ok) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
#include<cstdio>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007

bool comp(const pair<string,int>& p,const pair<string,int>& q){
    return p.second > q.second;
  }

int main(){

    int n;
    while(cin >> n,n){

        
        vector<P> arr;
        int id,m1,s1,m2,s2,m3,s3,m4,s4;
        REP(i,n){
            int tmp = 0;
            cin >> id >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
            tmp = 60*m1 + s1 + 60*m2 + s2 +60*m3 + s3 +60*m4 + s4;
            arr.pb(make_pair(tmp,id));
        }
        VSORT(arr);
        cout << arr[0].second << endl;
        cout << arr[1].second << endl;
        cout << arr[arr.size()-2].second << endl;
    }

    return 0;
}



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

int main() {
    int k, s;
    int cnt;
    
    cin >> k >> s;
    
    cnt = 0;
    for (int i=0; i<=k; i++) {
        if (i>s) {
            break;
        }
        for (int j=0; j<=k; j++) {
            if (i+j>s) {
                break;
            }
            if(s-(i+j)<=k){
                cnt++;
            }
            /*
            for (int l=0; l<=k; l++) {
                if (i+j+l>s) {
                    break;
                }
                if(i+j+l==s){
                    cnt++;
                }
            }
             */
        }
    }
    cout << cnt << endl;
    
    return 0;
}


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

int main()
{
  long long int n , a, b, f, p, balls;
  cin>>n>>a>>b;
  f = n/(a+b);
  balls = f*a;
  balls += min(a, n%(a+b));
  cout<<balls<<endl;
  return 0;
}
  
  
  
  

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

using namespace std;

char g[10][11];
int nl;
string ans;
int H,W;

bool dfs(int py,int px,int dir){
  if(ans.size()==nl-1)return true;
  g[py][px]='.';
  for(int k=0;k<4;k++){
    if(k==(dir^2))continue;
    int y=py,x=px;
    for(;;){
      static const int dy[]={-1,0,1,0};
      static const int dx[]={0,1,0,-1};
      y+=dy[k];
      x+=dx[k];
      if(y<0||H<=y||x<0||W<=x){
	break;
      }else if(g[y][x]!='.'){
	ans+="URDL"[k];
	if(dfs(y,x,k))return true;
	ans.resize(ans.size()-1);
	break;
      }
    }
  }
  g[py][px]='o';
  return false;
}


int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++){
    cin>>g[i];
  }
  int x,y,dir;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(g[i][j]!='.'){
	nl++;
	if(g[i][j]!='o'){
	  y=i;
	  x=j;
	  string D="URDL";
	  dir=find(begin(D),end(D),g[i][j])-begin(D);
	}
      }
    }
  }
  dfs(y,x,dir);
  cout<<ans<<endl;
}

Measured memory_bytes: 1216
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt(), k = sc.nextInt();
        int[] pow = new int[m + 1];
        pow[0] = 1;
        for (int i = 1; i <= m; i++) {
            pow[i] = pow[i - 1] * 2;
        }
        if (k > pow[m] - 1 || (m == 1 && k == 1)) {
            System.out.println(-1);
            return;
        }
        int[] ans = new int[1 << (m + 1)];
        if (k == 0) {

            for (int i = 0; i < (1 << m); i++) {
                ans[i * 2] = ans[i * 2 + 1] = i;
            }
        } else {
            int x = 0;
            for (int i = 1; i < (1 << m); i++, x++) {
                if (x == k) x++;
                ans[i] = ans[2 * (1 << m) - i] = x;
            }
            ans[0] = ans[1 << m] = k;
        }

        PrintWriter out = new PrintWriter(System.out);

        out.print(ans[0]);
        for (int i = 1; i < (1 << (m + 1)); i++) {
            out.print(" " + ans[i]);
        }
        out.println();
        out.flush();
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 41676
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	A := make([]int, M)
	sum := 0
	for i := 0; i < M; i++ {
		fmt.Scan(&A[i])
		sum += A[i]
	}

	if sum <= N {
		fmt.Println(N - sum)
	} else {
		fmt.Println(-1)
	}

}


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

int main(){
    double n,m;
    cin >> n >> m;
    vector<int> A(n);
    double total = 0;
    rep(i, n) {
        cin >> A[i];
        total += A[i];
    }
    int count = 0;
    double t = total * (1 / (4 * m));
    rep(i, n) {
        if(A[i] >= t){
            count++;
        }
    }
    if(count >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_124
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] ab = ReadInts();
            WriteLine(Max(Max(ab[0] * 2 - 1, ab[1] * 2 - 1), ab[0] + ab[1]));
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int dp[100010];
int main(){
    int n;
    int k;
    cin >> n >> k;
    Fill(dp,inf);
    vector<int>h(n);
    rep(i,n)cin >> h[i];
    dp[0] = 0;
    rep(i,n){
        rep(j,k+1){
            if(j==0)continue;
            if(i<j)continue;            
            dp[i] = min(dp[i-j]+abs(h[i-j]-h[i]),dp[i]);
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#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() {
    string S;
    cin >> S;
    int N = S.length();

    int ans = 0;
    for (int i = 0; i < N / 2; i++)
    {
        if (S[i] != S[N - 1 - i])
        {
            ans++;
        }
        
    }
    cout << ans << endl;
  return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll cul[100005];
ll just[100005];

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

int main() {
  ll N, K;
  scanf("%lld %lld", &N, &K);

  ll ans = 0;
  for (ll i = K; i >= 1; i--) {
    ll just_count = fastpow(K / i, N);
    for (ll j = i * 2; j <= K; j += i) {
      just_count -= just[j];
    }
    just_count = ((just_count % MOD) + MOD) % MOD;
    ans = (ans + i * just_count) % MOD;
    just[i] = just_count;
  }

  cout << ans << endl;
}

// 3 2
// 9

// 3 200
// 10813692

// 100000 100000
// 742202979


Measured memory_bytes: 4492
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
long long int N;
cin >> N;
string S;
cin >> S;
long long int i;
for(i=0;S[i] != '\0';i++)
{
    if((S[i]+N) > 90)
            S[i]=((S[i]+N)-90)+64;
    else
        S[i]+=N;
}
cout << S;
}


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

const ll mod = 1000000007;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll divide(ll a, ll b, ll m) {
    a %= m;
    return a * modinv(b, m) % m;
}

ll comb(ll n, ll r, ll m) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        n %= m;
        ans *= i;
        ans %= m;
    }
    for (int j = 1; j <= r; ++j) {
        ans = divide(ans, j, m);
    }
    return ans;
}

int main() {
    ll x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll cnt = (x + y) / 3;
    x -= cnt;
    y -= cnt;
    if (x < 0 || y < 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << comb(x + y, x, mod) % mod << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, a, b;
    cin >> n >> a >> b;
    ll diff = abs(b-a);
    if(diff%2 == 0) cout << diff/2 << endl;
    else cout << min(a-1, n-b)+1+(diff-1)/2 << endl;
}

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int n;
	cin >> n;
	if (n / 10 == 9 || n % 10 == 9)
		Yes();
	else
		No();

	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<ll>A(N), B(N);
	ll sum_A = 0, sum_B = 0;
	rep(i, 0, N) {
		cin >> A[i];
		sum_A += A[i];
	}
	rep(i, 0, N) {
		cin >> B[i];
		sum_B += B[i];
	}
	if (sum_A < sum_B)cout << -1 << "\n";
	else {
		vector<ll>vec;
		ll x = sum_A - sum_B;
		bool low = false;
		rep(i, 0, N) {
			if (A[i] < B[i]) {
				low = true;
				continue;
			}
			ll dis = A[i] - B[i];
			vec.push_back(dis);
		}
		sort(all(vec));
		int ans = N;
		rep(i, 0, vec.size()) {
			if (x >= vec[i]) {
				x -= vec[i];
				ans--;
			}
		}
		if (vec.size() == 0 && x > 0) {
			if (!low)++ans;
		}
		cout << ans << "\n";
	}



	return 0;
}


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

int main()
{
	int N;
	cin.sync_with_stdio(false);
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	auto B = A;
	sort(B.begin(), B.end());
	int id = 0;
	long long sum = B[0];
	for (int i = 1; i < N; i++) {
		if (sum * 2 < B[i]) {
			id = i;
		}
		sum += B[i];
	}
	cout << N - id << endl;
	return 0;
}


Measured memory_bytes: 1024
#define __mode_debug__
/*   ξ
     ll
   ＿ll＿
 ／  ∞  ＼
│*  Ａ  *│
│*  Ｃ  *│
│*  祈  *│
│*  願  *│
│*      *│
 ￣￣￣￣￣    */
//C++14 (GCC 5.4.1)
#include <bits/stdc++.h>
using namespace std;
#ifdef __mode_debug__
    #define DBG
#else
    #define DBG if(false)
#endif

#define LLINF (1LL<<60)
using ll = long long;
#define mod  1000000007

#define whole(a) (a).begin(),(a).end()
#define rwhole(a) (a).rbegin(),(a).rend()

#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(ll i=(a);i>=(b);i--)
#define each(itr,ds) for(auto itr=(ds).begin();itr!=(ds).end();itr++)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

//DUMP
//  ostream vector<T> , vector<vector<T>> , set<T> ,queue<T> , priority_queue<T> , pair<T,U> , map<T,U>
template<class T> ostream& operator<<(ostream&os,vector<T>&vec){os<<"{ ";rep(i,vec.size()) os<<((i==0)?"":", ")<<i<<":"<<vec[i];os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,vector<vector<T>>&vec){os<<"{"<<endl;rep(i,vec.size())os<<"\t   "<<i<<":"<<vec[i]<<((i==vec.size()-1)? "":",")<<endl;os<<"\t }";return os;}
template<class T> ostream& operator<<(ostream&os,set<T>&p){os<<"{ ";each(itr,p)  os<<((itr==p.begin())?"":", ")<<*itr;os<<" }";return os;}
template<class T> ostream& operator<<(ostream&os,queue<T>&p){queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.front();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T> ostream& operator<<(ostream&os,priority_queue<T>&p){priority_queue<T> q(p);os<<"[< "<<(q.empty()?" <]":"");while(!q.empty()){os<<q.top();q.pop();os<< (q.empty() ? " <]" : ", ");}return os;}
template<class T,class U> ostream& operator<<(ostream&os,pair<T,U>&p){os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T,class U> ostream& operator<<(ostream&os,map<T,U>&p){os<<"{ ";each(itr,p)os<<((itr==p.begin())?"":", ")<<itr->first<<":"<<itr->second;os<<" }";return os;}
void dump_f(string &nm,char t){cerr<<endl;}
template<class T,class... Ts> void dump_f(string &nm,char t,T &&x,Ts&&... ts){int l=nm.find_first_of(',');string name(nm,0,l),nx(nm,l+1,-1);if(t=='\n') cerr<<"  "<<name<<"\t: "<<x<<t;else cerr << name<<": "<<x<<","<<t;dump_f(nx,t,forward<Ts>(ts)...);}
template<class... Ts> void dump_m(int &&ln,string &&nm,char t,Ts&&... ts){cerr<<"[ln: "<<ln<<"]"<<t;dump_f(nm,t,forward<Ts>(ts)...);}
#define dump(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\n',__VA_ARGS__)
#define dl(...) DBG dump_m(__LINE__,#__VA_ARGS__,'\t',__VA_ARGS__)

#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(whole(V),c))

int main() {
    ios::sync_with_stdio(false);//stdout<=>cout
    cin.tie(nullptr);//cin<=>cout


    int K,A,B;
    cin>>K;
    cin >>A>>B;

    //-----------------------------------
    cout << ((((A+K-1)/K)*K<=B)  ? "OK" : "NG") <<endl;


    return (0);
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define N 1007
using namespace std;
int n,x[N],y[N];
long long a[40],l[40],r[40];
int main(){
    scanf("%d",&n);
    int flag=-1;
    for(int i=1;i<=n;++i){
        scanf("%d%d",&x[i],&y[i]);
        int t=abs(x[i])+abs(y[i]);
        if(flag==-1)flag=t%2;
        else if(t%2!=flag){puts("-1");return 0;}
    }
    if(!flag)printf("40\n1 ");
    else puts("39");
    for(int i=0;i<39;++i){
        cout<<(1LL<<i);
        if(i<38)putchar(' ');
        else puts("");
    }
    for(int i=1;i<=n;++i){
        if(!flag)
            if(x[i]<0)putchar('R'),--x[i];
            else putchar('L'),++x[i];
        long long t=abs(x[i])+abs(y[i]);
        a[39]=1LL<<38;
        for(int j=38;j;--j)
            if(t&(1LL<<j))a[j]=1LL<<(j-1);
            else a[j]=-(1LL<<(j-1));
        long long s=0;
        if(x[i]){
            for(int j=1;j<40;++j){
                l[j]=min(l[j-1]+a[j],l[j-1]);
                r[j]=max(r[j-1]+a[j],r[j-1]);
            }
            t=abs(x[i]);
            for(int j=39;j;--j)
                if(t>=l[j-1]+a[j] && t<=r[j-1]+a[j])s|=1LL<<j,t-=a[j];
        }
        for(int j=1;j<40;++j)
            if(s&(1LL<<j))
                if((x[i]<0)^(a[j]<0))putchar('L');
                else putchar('R');
            else
                if((y[i]<0)^(a[j]<0))putchar('D');
                else putchar('U');
        puts("");
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int i, x, y, temp;

  for( i = 1 ; i <= 3000 ; i++ )
  {
    scanf("%d %d", &x, &y);

    if( x == 0 && y == 0 )
      break;

    if( x > y)
    {
      temp = y;
      y = x;
      x = temp;
    }

    printf("%d %d\n", x, y);
  }
}



Measured memory_bytes: 2040
#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() {
  int W, H, N;
  cin >> W >> H >> N;
  int mx = 0, MX = W;
  int my = 0, MY = H;
  rep(i, N) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) mx = max(x, mx);
    if (a == 2) MX = min(x, MX);
    if (a == 3) my = max(y, my);
    if (a == 4) MY = min(y, MY);
  }
  if (mx >= MX || my >= MY) cout << 0 << endl;
  else cout << (MX - mx) * (MY - my) << endl;
  return 0;
}


Measured memory_bytes: 3616
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dpr(x) cerr<<#x<<": "<<x<<endl;
#define dprc(c) do{cerr<<#c<<":";for(auto&_i:(c)){cerr<<" "<<_i;}cerr<<endl;}while(0)
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
int INF = 1e9+7;
#define all(c) (c).begin(), (c).end()
#define tr(i,c) for(auto i=(c).begin();i!=(c).end();i++)
#define rtr(i,c) for(auto i=(c).rbegin();i!=(c).rend();i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

int n, k;
vi w;

bool check(int p) {
  int l = 0, q = 0;
  for (int i = 0; i < n; i++) {
    if (q < w[i]) {
      q = p;
      l++;
      if (l > k || q < w[i]) return false;
    }
    q -= w[i];
  }
  return true;
}

int search_minp(int minp, int maxp) {
  if (maxp <= minp) {
    for (int i = minp; i < maxp+2; i++) {
      if (check(i)) return i;
    }
    assert(0);
  }
  int med = (minp+maxp)/2;

  if (check(med)) return search_minp(minp, med-1);
  else return search_minp(med+1, maxp);
}

int main(int argc, char **argv)
{
  scanf("%d %d", &n, &k);
  w = vi(n);
  int maxp = -INF, total = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
    maxp = max(maxp, w[i]);
    total += w[i];
  }
  printf("%d\n", search_minp(maxp-1, total));
  return 0;
}

Measured memory_bytes: 3404
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;scanf("%d",&n);
    string s;cin>>s;
    vector<int> r,g;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R')r.push_back(i);
        else if(s[i]=='G')g.push_back(i);
    }
    long long a=n-r.size()-g.size();
    long long ans=a*r.size()*g.size();
    for(auto R:r){
        for(auto G:g){
            int k=R,l=G;
            if(k>l)swap(k,l);
            if(l+(l-k)<n){
                if(s[l+(l-k)]=='B')ans--;
            }
            if((l+k)%2==0){
                if(s[(l+k)/2]=='B')ans--;
            }
            if(k-(l-k)>=0){
                if(s[k-(l-k)]=='B')ans--;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int X;
    cin >> X;
    reps(i,1,1000000) if(360*i%X==0) {cout << 360*i/X << endl; return 0;}
    
    
    

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
using ll = long long;
using namespace std;


int main() {
    int n, temp, s = 0;
    cin >> n;
    int L[n];
    for (int l = 0; l < n; ++l) {
        cin >> L[l];
    }
    bool flag = 1;
    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = n-1 ; j >= i + 1; j--) {
            if ( L[j] < L[j-1]){
                temp = L[j];
                L[j] = L[j-1];
                L[j-1] = temp;
                flag = 1;
                s++;
            }
        }
    }
    for (int k = 0; k < n; ++k) {
        if (k) cout << " ";
        cout << L[k];
    }
    cout << "\n";
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(){
  string n;
  cin >> n;
  long long x=0;
  int i;
  for(i=0;i<n.size();i++){
    int a = n[i] - '0';
    x += a;
  }
  if(x%9==0) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        try(Scanner sc = new Scanner(System.in)){
            while(true){
            int sum=0;
            double sqsum=0;
            int n=sc.nextInt();
            if(n==0) break;
            int[] score = new int[n];
            for(int i=0;i<score.length;i++){
                score[i]=sc.nextInt();
                sum+=score[i];
                }
                double ave=0,bunsan=0;
                ave=(double) sum/n;
                for(int i=0;i<score.length;i++){
                    sqsum+=(score[i]-ave)*(score[i]-ave);
                }
                bunsan=(double) sqsum/n;
                System.out.println(Math.sqrt(bunsan));
            }
        }   
    }
}


Measured memory_bytes: 31384
#include<stdio.h>

#define N_MAX (int) 52
#define AI_MAX (int) 13
#define AI_MIN (int) 1

void SortRank(int *card, int dx);
void PrintCard(int *card, char gara);

int main(void)
{
	char gara;
	int n, rank;
	int SCard[13], HCard[13], CCard[13], DCard[13];
	int dx_s=0, dx_h=0, dx_c=0, dx_d=0;
	
	if( scanf( "%d%*c", &n ) == 1 )
	{
		if( n <= N_MAX )
		{
			for( int i = 0; i < n; i++ )
			{
				if( scanf( "%c %d%*c", &gara, &rank ) == 2 )
				{
					if( ( rank < AI_MIN ) || ( rank > AI_MAX ) )
						{
						return -1;
					}
					else if( gara == 'S' )
					{
						SCard[dx_s] = rank;
						dx_s++;
					}
					else if( gara == 'H' )
					{
						HCard[dx_h] = rank;
						dx_h++;
					}
					else if( gara == 'C' )
					{
						CCard[dx_c] = rank;
						dx_c++;
					}
					else if( gara == 'D' )
					{
						DCard[dx_d] = rank;
						dx_d++;
					}
					else
					{
						return -1;
					}
				}
				else
				{
					return -1;
				}
			}
		}
		else
		{
			return -1;
		}
	}
	else
	{
		return -1;
	}
	
	SortRank( &SCard[0], dx_s );
	SortRank( &HCard[0], dx_h );
	SortRank( &CCard[0], dx_c );
	SortRank( &DCard[0], dx_d );
	
	PrintCard( &SCard[0], 'S');
	PrintCard( &HCard[0], 'H');
	PrintCard( &CCard[0], 'C');
	PrintCard( &DCard[0], 'D');
	
	return 0;
}

void SortRank(int *card, int dx)
{
	int tmp;
	
	for( int i = 0; i-1 < dx; i++ )
	{
		for(int j = i+1; j < dx; j++ )
		{
			if( card[i] > card[j] )
			{
				tmp = card[i];
				card[i] = card[j];
				card[j] = tmp;
			}
		}
	}
	
	return;
}

void PrintCard(int *card, char gara)
{
	int dx=0;
	
	for( int i = AI_MIN; i <= AI_MAX; i++)
	{
		if( i != card[dx] )
		{
			printf( "%c %d\n", gara, i );
		}
		else
		{
			dx++;
		}
	}
	
	return;
}



Measured memory_bytes: 2036
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;

using namespace std;


int main(){ 
    long long S, W;
    cin >> S >> W;

    if(W >= S){
        cout << "unsafe";
    }
    else{
        cout << "safe";
    }
}



Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950



int main() {
	std::string s; std::cin >> s;
	std::vector<long long> NUM(s.size() - 2);
	for (int i = 0; i < s.size() - 2; ++i)
		NUM[i] = ((s[i] - '0') * 100) + ((s[i + 1] - '0') * 10) + (s[i + 2] - '0');
	long long d = 100000000000;
	for (int i = 0; i < NUM.size(); ++i) {
		if (d > std::abs(753 - NUM[i]))
			d = std::abs(753 - NUM[i]);
	}
	std::cout << d << std::endl;

	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,j,c;
    map<string,int> mp;
    string s,a,b,d,e;
    a="AC";b="WA";d="TLE";e="RE";
    cin>>n;
    while(n--)
    {
        cin>>s;
        mp[s]++;
        s.clear();
    }
    cout<<"AC x "<<mp[a]<<endl<<"WA x "<<mp[b]<<endl<<"TLE x "<<mp[d]<<endl<<"RE x "<<mp[e]<<endl;
    return 0;
}


Measured memory_bytes: 3604
n=int(input())
k=int(input())
def k1(n):
    n_l=len(str(n))
    n_0=int(str(n)[0])
    return n_0+9*(n_l-1)
def k2(n):
    n_l=len(str(n))
    if n_l<=1:
        return 0
    n_0=int(str(n)[0])
    return 81*((n_l-1)*(n_l-2)//2)+(n_0-1)*9*(n_l-1)+k1(n%(10**(n_l-1)))
def k3(n):
    n_l=len(str(n))
    if n_l<=2:
        return 0
    n_0=int(str(n)[0])
    return 729*((n_l-1)*(n_l-2)*(n_l-3)//6)+(n_0-1)*81*((n_l-1)*(n_l-2)//2)+k2(n%(10**(n_l-1)))
if k==1:
    print(k1(n))
if k==2:
    print(k2(n))
if k==3:
    print(k3(n))

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
using namespace std;
typedef struct{
  int up;
  int down;
  int mae;
  int usiro;
  int right;
  int left;
}SAIKORO;
main(){
  char meirei[7];
  SAIKORO saikoro;
  while(1){
    int n,sub,goukei=1;
    saikoro.up=1;
    saikoro.down=6;
    saikoro.mae=2;
    saikoro.usiro=5;
    saikoro.right=3;
    saikoro.left=4;
    cin >> n;
    if(n==0)break;
    for (int i=0;i<n;i++){
      cin >> meirei;
      if(strcmp(meirei,"North")==0){
	sub=saikoro.up;
	saikoro.up=saikoro.mae;
	saikoro.mae=saikoro.down;
	saikoro.down=saikoro.usiro;
	saikoro.usiro=sub;
      }
      else if(strcmp(meirei,"East")==0){
	sub=saikoro.up;
	saikoro.up=saikoro.left;
	saikoro.left=saikoro.down;
	saikoro.down=saikoro.right;
	saikoro.right=sub;
      }
      else if(strcmp(meirei,"West")==0){
	sub=saikoro.up;
	saikoro.up=saikoro.right;
	saikoro.right=saikoro.down;
	saikoro.down=saikoro.left;
	saikoro.left=sub;
      }
      else if(strcmp(meirei,"South")==0){
	sub=saikoro.up;
	saikoro.up=saikoro.usiro;
	saikoro.usiro=saikoro.down;
	saikoro.down=saikoro.mae;
	saikoro.mae=sub;
      }
      else if(strcmp(meirei,"Right")==0){
	sub=saikoro.mae;
	saikoro.mae=saikoro.right;
	saikoro.right=saikoro.usiro;
	saikoro.usiro=saikoro.left;
	saikoro.left=sub;
      }
      else if(strcmp(meirei,"Left")==0){
	sub=saikoro.mae;
	saikoro.mae=saikoro.left;
	saikoro.left=saikoro.usiro;
	saikoro.usiro=saikoro.right;
	saikoro.right=sub;
      }
      goukei=goukei+saikoro.up;
    }
    cout << goukei << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n, k; cin >> n >> k; 
  vi v(n); input(v);
  int ans = count_if(all(v), [k](int x){ return x >= k; });
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define itn int
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s;
   cin >> s;
   int n = s.length();
   int l = 0,h = n-1;
   int ans = 0;
   while(l<h){
      if(s[l]!=s[h]){
         ans++;
      }
      l++;
      h--;
   }
   cout << ans << '\n';
   return 0;
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define PRINT(s) cout<<s
#define PRINTS(s) cout<<s<<' '
#define PRINTL(s) cout<<s<<endl
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    int n;
    cin>>n;

    int ans=1;
    int now=1;
    int i=1;
    while(now<=n){
        ans=now;
        i++;
        now=i*i;
    }
    cout<<ans<<endl;

    return 0;
}




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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

/* -----  2017/07/09  Problem: AGC 017 A / Link: http://agc017.contest.atcoder.jp/tasks/agc017_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N;
int P;
int a[51];
ll dp[60][2];
ll ans = 0LL;

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

  cin >> N>>P;
  FOR(i, 0, N) {
	  cin >> a[i];
  }
  dp[0][0] = 1;
  FOR(i, 0, N) {
	  FOR(j, 0, 2) {
		  dp[i + 1][((j + a[i]) % 2)] += dp[i][j];
		  dp[i + 1][((j ) % 2)] += dp[i][j];
	  }
  }
  ans = dp[N][P];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N=parse(Int,readline())
dfs(A,a,b,c)=A>N ? 0 : (a>0&&b>0&&c>0)+dfs(A*10+3,a+1,b,c)+dfs(A*10+5,a,b+1,c)+dfs(A*10+7,a,b,c+1)
println(dfs(0,0,0,0))

Measured memory_bytes: 107992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>
#define Matd vector<vector<ld>>
#define Arrd vector<ld>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    Arr a(n);
    forn(i, n) cin >> a[i];
    sort(allele(a));
    cout << (a[n / 2] - a[n / 2 - 1]) << endl;
    return 0;
}

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

int main() {
  int i, N;
  
  cin >> N;
  vector<int64_t> L(N+1); // int型の配列変数vecを宣言  
  

  L.at(0) = 2;
  L.at(1) = 1;
  
  for(i=2; i<N+1; i++) {
    L.at(i) = L.at(i-1) + L.at(i-2);
  }

  cout << L.at(i-1) << endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cstdlib>

#include <algorithm>
#include <numeric>
#include <limits>
#include <functional>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <queue>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int N = 100010;

int n, m;
char s[N], t[N];

int main() {
#ifdef LBT
	freopen("test.in", "r", stdin);
	int nol_cl = clock();
#endif

	scanf("%d%d%s%s", &n, &m, s, t);
	for (int i = 0; i < n; ++i)
		if (i * (ll)m % n == 0)
			if (s[i] != t[i * (ll)m / n]) {
				puts("-1");
				return 0;
			}
	printf("%lld\n", n * (ll)m / __gcd(n, m));

#ifdef LBT
	LOG("Time: %dms\n", int((clock() - nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) { a_powered *= a;
	}
	return a_powered;
}


int main(int argc, char *argv[]){
	int M, D;
	cin >> M >> D;

	int ans = 0;

	for (int i=1; i<=D; i++){
		int i_tmp = i;
		int d1 = i_tmp%10;
		i_tmp = i/10;
		int d10 = i_tmp%10;

		int multiple = d1 * d10;
		if (multiple <= M && d1 > 1 && d10 > 1){
			ans++;
		}
	}

	cout << ans << endl;
}


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

int main()
{
  int K;
  cin >> K;
  ll ans = 0;
  FOR(i,1,K+1)FOR(j,1,K+1)FOR(k,1,K+1) ans += __gcd(__gcd(i, j), k);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import sys
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
a,b,c=get_ints()
if (a-b)>=c:
  print(0)
else:
  print(c-(a-b))
  

Measured memory_bytes: 3064
# abc119_a
from datetime import datetime
S=input()
to_dt=datetime.strptime(S,'%Y/%m/%d')
# 2019/04/30
from_dt=datetime(2019,4,30)
# 2019/04/30以前であれば、"Heisei"
# 以降は"TBD"
if to_dt <= from_dt:
 print("Heisei")
else:
 print("TBD")


Measured memory_bytes: 4692
#include<iostream>
#include<vector>
#include<algorithm>

#define v first
#define w second

using namespace std;

typedef pair<int,int>pii;

int main(void){

  int n,m;
  cin >> n >> m;
  vector<pii>a(n);

  for(int i=0;i<n;i++)cin >> a[i].v >> a[i].w;

  int dp[10001];
  fill(dp,dp+10001,0);

  for(int i=0;i<n;i++){
    for(int j=0;j+a[i].w<10001;j++){
      dp[j+a[i].w]=max(dp[j+a[i].w],dp[j]+a[i].v);
    }
  }

  cout << dp[m] << endl;

  return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int n;
    cin >> n;
    
    int ans = 0;
    
    for(int i=1; i<n; i++){
        ans += (n-1)/i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
# warshall_floyd法
def warshall_floyd(d,n):
 for k in range(n):
  for i in range(n):
   for j in range(n):
    d[i][j]= min(d[i][j],d[i][k]+d[k][j])
 return d

H,W = map(int,input().split())
# 隣接行列の定義、初期化
# ①コスト(存在しないときはinf)
d = [0 for i in range(10)]
# ②自分自身へのコストは０
for i in range(10):
 d[i] = list(map(int,input().split()))
ct=[0]*11
for i in range(H):
  lst=list(map(int,input().split()))
  for j in range(W):
   ct[lst[j]+1]+=1

A=warshall_floyd(d,10)
ans=0
for i in range(10):
 ans+=ct[(i+1)]*A[i][1]
print(ans)


Measured memory_bytes: 40300
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int mod = (int) 1e9 + 7;

int id(char c) {
  if (c == 'A') return 0;
  if (c == 'C') return 1;
  if (c == 'G') return 2;
  if (c == 'T') return 3;
  return 4;
}

char what(int id) {
  if (id == 0) return 'A';
  if (id == 1) return 'C';
  if (id == 2) return 'G';
  if (id == 3) return 'T';
  return '@';
}

// ACGT@

int n;
int memo[100][6][6][6];

int go(int i, int l1, int l2, int l3) {
  if (i == n) return 1;
  if (memo[i][l1][l2][l3] != -1) return memo[i][l1][l2][l3];
  int ans = 0;
  for (int x = 0; x < 4; x++) {
    if (x == id('C') && l1 == id('G') && l2 == id('A')) continue;
    if (x == id('G') && l1 == id('C') && l2 == id('A')) continue;
    if (x == id('C') && l1 == id('A') && l2 == id('G')) continue;
    if (x == id('C') && l2 == id('G') && l3 == id('A')) continue;
    if (x == id('C') && l1 == id('G') && l3 == id('A')) continue;
    ans = (1ll * ans + go(i + 1, x, l1, l2)) % mod;
  }
  return memo[i][l1][l2][l3] = ans;
}

int main() {
  cin >> n;
  memset(memo, -1, sizeof memo);
  cout << go(0, 4, 4, 4) << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string _S,T;
cin>>_S>>T;
int fit_idx=-1;
if(_S.size()>=T.size()){
    for(int i=0;i<=_S.size()-T.size();i++){
        bool fit=true;
        for(int j=0;j<T.size();j++){
            char c_s=_S[i+j];
            char c_t=T[j];

            if(c_s!=c_t && c_s!='?'){
                fit=false;
                break;
            }
        }
        if(fit){
            fit_idx=i;
        }
    }
}
string S="UNRESTORABLE";
if(fit_idx>-1){
    _S.replace(fit_idx,T.size(),T);
    replace(_S.begin(),_S.end(),'?','a');    
    S=_S;
}

cout<<S<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256