akhauriyash/Code-Regression huggingface dataset:
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

char stdibuf[2500015];
uint32_t stdibufl;

bool arr[101];

uint32_t nextpint(void){ char c=stdibuf[stdibufl++]; while(c<'0'||'9'<c) c=stdibuf[stdibufl++]; uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=stdibuf[stdibufl++]; } return x; }
void printint(uint32_t x){ if(x<0){x=-x; putchar_unlocked('-');}else if(x==0){putchar_unlocked('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar_unlocked(s[i]); putchar_unlocked('\n'); }

uint32_t h[100000];
uint8_t is[100000];

int main(void){
	read(0, stdibuf, 2500014);
	uint32_t n=nextpint();
	uint32_t m=nextpint();
	for(uint32_t i=0; i<n; i++){
		h[i]=nextpint();
	}
	for(uint32_t i=0; i<m; i++){
		uint32_t a=nextpint()-1;
		uint32_t b=nextpint()-1;
		if(h[a]<=h[b]) is[a]=1;
		if(h[a]>=h[b]) is[b]=1;
	}
	uint32_t ans=0;
	for(uint32_t i=0; i<n; i++){
		ans+=is[i];
	}
	printint(n-ans);
}


Measured memory_bytes: 4112
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <utility>
#include <algorithm>
#include <map>
#include <cassert>
using namespace std;
#define REPP(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,a) for(int i = 0; i < (a); ++i)
#define PER(i,a) for(int i = (a) - 1; i >= 0; --i)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define MP make_pair

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

const int mod = 1e9 + 7;

void add(int& a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}

int mul(int a, int b) {
    return 1LL * a * b % mod;
}

int modpow(int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1) res = mul(res, a);
        a = mul(a, a);
        n >>= 1;
    }
    return res;
}

int comb(int n, int k) {
    int p = 1, q = 1;
    for (int i = 0; i < k; i++) {
        p = mul(p, n - i); // fac[n] / fac[n - k]
        q = mul(q, i + 1); // fac[k]
    }
    return mul(p, modpow(q, mod - 2));
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    int ans = 0;
    // i * (n - i) * m * m
    for (int i = 1; i < n; i++) {
        add(ans, mul(mul(i, n - i), mul(m, m)));
    }
    for (int i = 1; i < m; i++) {
        add(ans, mul(mul(i, m - i), mul(n, n)));
    }
    ans = mul(ans, comb(n * m - 2, k - 2));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll A, B;
ll K = 0;
ll t;
ll ret = 0;
string s;

void input() {
  IN(A);
  IN(B);
}

void solve() {
  // double a = (double)A;
  // double b = (double)B;
  // double l = max(a / 0.08, b / 0.1);
  // double r = min((a + 1.0) / 0.08, (b + 1.0) / 0.08);
  // ll m = (ll)ceil(l);
  // if (m > r) {
  //   PRINT(-1);
  // } else {
  //   PRINT(m);
  // }
  bool ok = false;
  FOR(i, 1, 1001) {
    double v = (double)i;
    if (floor(v * 0.08) == (double)A) {
      if (floor(v * 0.1) == (double)B) {
        PRINT(i);
        ok = true;
        break;
      }
    }
  }
  if (!ok) {
    PRINT(-1);
  }

}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from itertools import accumulate

setrecursionlimit(10 ** 9)
INF = 1 << 60


def input():
    return stdin.readline().strip()


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [1] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)

    return {2} | {2 * i + 1 for i in range(1, m) if p[i]}


def main():
    N = 10 ** 5
    primes = prime_numbers(N)
    a = [1 if n in primes and (n + 1) // 2 in primes else 0 for n in range(N + 1)]
    a = tuple(accumulate(a))

    ans = []
    Q, *LR = map(int, open(0).read().split())
    for l, r in zip(*[iter(LR)] * 2):
        ans.append(a[r] - a[l - 1])

    print('\n'.join(map(str, ans)))


if __name__ == "__main__":
    main()


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

using namespace std;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<ll,int> li;
#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b,c) for(int i=a;i<b;i+=c)
#define REPN(i,a,b,c) for(int i=a;i<=b;i+=c)
#define reset(a,b) memset(a,b,sizeof(a))

int main(void) {
  std::ios::sync_with_stdio(false);
  ll x,y;
  cin >> x >> y;
  int tot = 0;
  while (x < y) {
    x *= 2;
    tot++;
  }

  if (x == y) {
    tot++;
  }

  cout << tot << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 200010


int main(){
	IOS;
	tihs;
	
	ll n;cin>>n;
	if(n&1)n=n/2+1;
	else n/=2;
	cout<<n;


	
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 1e5 + 5;

char s[3005], t[3005];
int dp[3005][3005];
PII go[3005][3005];

int main () {
	scanf("%s", s);
	scanf("%s", t);
	int n = strlen(s);
	int m = strlen(t);
	dp[0][0] = (s[0] == t[0] ? 1 : 0);
	go[0][0] = {-1, -1};
	FOR(j,1,m) {
		dp[0][j] = (s[0] == t[j]) ? 1 : dp[0][j-1];
		go[0][j] = (s[0] == t[j]) ? mp(-1,-1) : mp(0,-1);
	}
	FOR(i,1,n) {
		dp[i][0] = (s[i] == t[0]) ? 1 : dp[i-1][0];
		go[i][0] = (s[i] == t[0]) ? mp(-1,-1) : mp(-1,0);
		FOR(j,1,m) {
			dp[i][j] = (s[i] == t[j]) ? (1 + dp[i-1][j-1]) : max(dp[i-1][j], dp[i][j-1]);
			if (s[i] == t[j]) {
				go[i][j] = {-1,-1};
			} else if (dp[i-1][j] > dp[i][j-1]) {
				go[i][j] = {-1,0};
			} else {
				go[i][j] = {0,-1};
			}
		}
	}
	int x = n-1, y = m-1;
	vector<char> ans;
	while (1) {
		if (x < 0 || y < 0) {
			while (!ans.empty()) {
				putchar(ans.back());
				ans.pop_back();
			}
			putchar('\n');
			return 0;
		}
		if (s[x] == t[y]) {
			ans.pb(s[x]);
			x--; y--;
		} else {
			int dx = go[x][y].st;
			int dy = go[x][y].nd;
			x += dx;
			y += dy;
		}
	}

}	





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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector< vector<int> > cnt(n + 1, vector<int>(10, 0));
    for (int i = 0; i < n; i++) {
        cnt[i + 1] = cnt[i];
        cnt[i + 1][s[i] - '0'] = cnt[i][s[i] - '0'] + 1;
    }

    vector<int> ex(1000, false);
    for (int i = 1; i < n - 1; i++) {
        for (int j = 0; j <= 9; j++) {
            if (cnt[i][j] == 0) continue;
            for (int k = 0; k <= 9; ++k) {
                if (cnt[n][k] - cnt[i + 1][k] == 0) continue;
                ex[100 * j + 10 * (s[i] - '0') + k] = true;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < 1000; ++i) {
        ans += (ex[i]);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>

int main()
{
	char a[3];
	int  count;
	for(int i = 0; i < 3; i++)
	{
		std::cin >> a[i];
		if(a[i] == 'o')
		{
			count++;
		}
	}
	std::cout << 700 + count * 100 << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define boost ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0)
#define vi vector<int>
#define P push_back
#define F first
#define S second
#define debug(x) cout<<(x)<<" "
#define pi vector<pair<int,int> >
#define FOR(i,x,n) for(int i=x;i<n;i++)
#define all(a) a.begin(),a.end()
using namespace std;
int main(){
    boost; 
    int n,a,b;
    cin>>n>>a>>b;
    ll ans=min(n*a,b);
    cout<<ans;



    

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define NUMBER 300
int main(void){
    int H[NUMBER],W[NUMBER],i,j,k,c=0,x=0;
    for(i=0;i<NUMBER;i++){
       scanf("%d %d",&H[i],&W[i]);
       if(H[i]==0&&W[i]==0)
         break;
       c++;
    }
    for(i=0;i<c;i++){
       for(j=0;j<H[i];j++){
          if(j%2==0)
            x=0;
          else
            x=1;
          for(k=0;k<W[i];k++){
             if(x%2==0){
               putchar('#');
               x++;
             }else{
               putchar('.');
               x++;
             }
           }
       putchar('\n');
       }
    putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2068
n,k=map(int,input().split())
h=list(map(int,input().split()))
INF=10**9
dp=[INF for i in range(n)]
dp[0]=0
if k>n-1:
    k=n-1
for i in range(1,n):
    for j in range(1,k+1):
        if i-j<0:
            break
        dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i])
print(dp[-1])

Measured memory_bytes: 56544
from collections import defaultdict
def main():
    N = int(input())
    dd=defaultdict(int)
    for _ in range(N):
        dd[input()]+=1
    dd = sorted(dd.items())
    dd = sorted(dd, reverse=True, key=lambda x: x[1])
    cnt = 0
    while len(dd) > cnt and dd[0][1] == dd[cnt][1] :
        print(dd[cnt][0])
        cnt +=1




if __name__ == '__main__':
    main()

Measured memory_bytes: 42708
import sys

def multiply(M, N, memo):
    for i in range(1, N):
        for l in range(N - i):
            r = l + i
            memo[l][r] = min(memo[l][j] + memo[j + 1][r] + M[l][0] * M[j + 1][0] * M[r][1] for j in range(l, r))

lines = sys.stdin.readlines()
del lines[0]
M = []
for line in lines:
    M.append(map(int, line.split()))
N = len(M)
memo = [[0 for i in range(N)] for j in range(N)]
multiply(M, N, memo)
print memo[0][N - 1]

Measured memory_bytes: 6552
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] split = line.split(" ");
		int a = Integer.parseInt(split[0]);
		int b = Integer.parseInt(split[1]);
		int c = Integer.parseInt(split[2]);
		String output = null;
		if (a < b && b < c) {
			output = "Yes";
		} else {
			output = "No";
		}
		System.out.println(output);
		sc.close();
	}
}

Measured memory_bytes: 26048
# include <bits/stdc++.h>
using namespace std;
# define lli long long int
# define MOD 1000000007


vector<lli> g[100001];
lli dp[100001][2];

lli dfs(lli nd, lli par, lli col){
    if(dp[nd][col] != -1){
        return dp[nd][col];
    }

    lli k1 = 1, k2 = 1;
    bool leaf = true;
    for(auto nbr : g[nd]){
        if(nbr != par){
            leaf = false;
            k1 *= dfs(nbr, nd, 0), k1 %= MOD;
            if(col == 0)
                k2 *= dfs(nbr, nd, 1), k2 %= MOD;
        }
    }

    if(leaf)
        return 2 - col;

    lli ans = k1;
    if(col == 0)
        ans += k2, ans %= MOD;

    return dp[nd][col] = ans;
}

void solve(){
    lli n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for(lli i = 0; i < n - 1; i++){
        lli x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    cout << dfs(1, -1, 0);

}


int main(){
    lli t;
    t = 1;
    while(t--){
        solve();
    }
}


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

using namespace std;




int main()
{
	int a, flag=0;
	cin>>a;
	for (int i = 1; i <=9; ++i)
	{
		for (int j =i; j <=9; ++j)
		{
			if(a==i*j)
			{
				flag=1;
				break;
			}
		}
	} 
	if(flag==1)
	{
		cout<<"Yes";
	}else{
		cout<<"No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int64_t a, b, c, k;
    cin >> a >> b >> c >> k;
    int64_t sum = 0;
    if (a >= k) sum = k;
    else if (a + b >= k) sum = a;
    else {
        int64_t diff = k - (a + b);
        sum = a - diff;
    }
    cout << sum << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N;
    cin >> N;
    int tmp = N / 100;
    int ans;
    ans = tmp * 100 + tmp * 10 + tmp;
    if (N > ans)
        tmp++;

    ans = tmp * 100 + tmp * 10 + tmp;
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n;
  char s[51];
  scanf("%d", &n);
  scanf("%s", s);
  int cnt = 0;
  for (int i = 0; i <= n-3; i++){
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      cnt += 1;
    }
  }
  printf("%d", cnt);
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll res = 0;
vvl adj;
vl val, atnode;

void dfs(ll i, ll p = -1) {
	for (ll j: adj[i]) if (j != p) {
		atnode[j] = val.back();
		res += atnode[j];
		val.pop_back();
		dfs(j,i);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	adj.resize(n);
	FOR(i,1,n) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	
	val.resize(n);
	FOR(i,0,n) cin >> val[i];
	sort(all(val));

	atnode.resize(n);

	atnode[0] = val.back();
	val.pop_back();
	
	dfs(0);
	
	cout << res << endl;
	FOR(i,0,n) cout << atnode[i] << " \n"[i+1==n];

}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int c =0;
  int ans =0;
  for(int i =0; i<3; i++){
    if(s.at(i)=='R') c++;
    else{
      ans = max(c,ans);
      c =0;
    }
  }
      ans = max(c,ans);

  cout<<ans<<endl;
}


Measured memory_bytes: 3628
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    H, W, K = map(int, input().split())
    MOD = 10 ** 9 + 7

    num = [[0] * 9 for _ in range(9)]
    for b in range(2 ** (W - 1)):
        b = bin(b)[2:].zfill(W - 1)
        ok = True
        for i in range(len(b) - 1):
            if b[i] == "1" and b[i + 1] == "1":
                ok = False
        if ok:
            p = list(range(W))
            for i in range(len(b)):
                if b[i] == "1":
                    p[i], p[i + 1] = p[i + 1], p[i]

            for i in range(W):
                num[i][p[i]] += 1

    dp = [[0] * (W + 1) for _ in range(H + 1)]
    dp[0][0] = 1
    for y in range(H):
        for x in range(W):
            for i in range(W):
                dp[y + 1][i] += dp[y][x] * num[x][i]
                dp[y + 1][i] %= MOD

    print(dp[H][K - 1])


if __name__ == '__main__':
    main()


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

using namespace std;

string str;

int main(){
    cin >> str;
    int n = str.length();
    for(int i = 0; i < n; i++){
        if((i & 1) && str[i] == 'R'){
            cout << "No\n";
            return 0;
        }
        if(!(i & 1) && str[i] == 'L'){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 ll N;
   ll K;
    ll Q;
  
cin >>N>>K>>Q;
  
  vector<ll> A(Q);
  rep(i,Q) {
    cin >>A.at(i);
  }
  
  vector<ll> vec(N);
  rep(i,N) {
vec.at(i)=K;
  }
  
  rep(i,Q) {
    vec.at(A.at(i)-1)++;
  }
   rep(i,N) {
if(vec.at(i)>Q) {
cout<<"Yes"<< endl;
}
else {
cout<<"No"<<endl;
}
   }
  
  
}

  
  
  


Measured memory_bytes: 2176
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000
#define PI 3.14159265359

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

int main() {
    ll N, P;
    cin >> N >> P;
    vector<pair<ll, ll>> pri = prime_factorize(P);
    ll ans = 1;
    rep(i, pri.size()) {
        if (pri[i].second < N)
            continue;
        ll temp = pow(pri[i].first, pri[i].second / N);
        ans *= temp;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
s = input()
while 1:
    if len(s) == 0:
        print("YES")
        break
    if s[len(s)-5:] == "dream":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-7:] == "dreamer":
        s = s[:len(s)-7]
        continue
    elif s[len(s)-5:] == "erase":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-6:] == "eraser":
        s = s[:len(s)-6]
        continue
    else:
        print("NO")
        break
    

Measured memory_bytes: 9036
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    set<int> s;
    rep(i,3){
        int a;
        cin >> a;
        s.insert(a);
        }
    if(s.size() == 2){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a[3][3], a2[3][3], b[10];
	int l, m, n, k;
	
	for(l = 0; l < 3; l++){
		for(m = 0; m < 3; m++){
			a2[l][m] = 0;
		}
	}
	
	for(l = 0; l < 3; l++){
		for(m = 0; m < 3; m++){
			scanf("%d", &a[l][m]);
		}
	}
	scanf("%d", &n);
	for(l = 0; l < n; l++){
		scanf("%d", &b[l]);
	}
	
	for(l = 0; l < n; l++){
		for(m = 0; m < 3; m++){
			for(k = 0; k < 3; k++){
				if(b[l] == a[m][k]){
					a2[m][k] = 1;
				}
			}
		}
	}
	
	if((a2[0][0] == 1 && a2[0][1] == 1 && a2[0][2] == 1) ||
	   (a2[1][0] == 1 && a2[1][1] == 1 && a2[1][2] == 1) ||
	   (a2[2][0] == 1 && a2[2][1] == 1 && a2[2][2] == 1) ||
	   (a2[0][0] == 1 && a2[1][0] == 1 && a2[2][0] == 1) ||
	   (a2[0][1] == 1 && a2[1][1] == 1 && a2[2][1] == 1) ||
	   (a2[0][2] == 1 && a2[1][2] == 1 && a2[2][2] == 1) ||
	   (a2[0][0] == 1 && a2[1][1] == 1 && a2[2][2] == 1) ||
	   (a2[0][2] == 1 && a2[1][1] == 1 && a2[2][0] == 1)){
	   	printf("Yes");
	 }
	 else{
	 	printf("No");
	 }
	 
	 return 0;
}

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

int main() {
	char a[3];
	char b[3];
	cin >> a[0] >> a[1] >> a[2];
	cin >> b[0] >> b[1] >> b[2];
	int count = 0;
	rep(i, 3) {
		if (a[i] == b[i]) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

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

void solve()
{
   string s,t;
   cin >> s >> t;
   int m=(int)t.length();
   int n=(int)s.length();
   int ans=mod;
   f(i,n-m+1)
   {
       string x=s.substr(i,m);
       int cnt=0;
       f(j,m)
       {
           cnt+=(x[j]!=t[j]);
       }
       ans=min(ans,cnt);
   }
   cout << ans << '\n';
  return;
} 

signed main()
{
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
int Res,S[300000],n;
signed main()
{
    
    cin>>n;
    Res=1e16;
    for (int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        S[i]=S[i-1]+x;
    }
    for (int i=1;i<n;i++)
        Res=min(Res,abs(S[i]-(S[n]-S[i])));
    cout<<Res;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main() {
    int n, m, l; cin >> n >> m >> l;
    vector<vector<int>> dp(n, vector<int>(n, INF));
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        dp[a][b] = dp[b][a] = c;
    }

    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
            }
        }
    }
    
    vector<vector<int>> dp2(n, vector<int>(n, INF));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if(dp[i][j] <= l) {
                dp2[i][j] = 1;
            }
        }
        
    }
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                dp2[i][j] = min(dp2[i][j], dp2[i][k]+dp2[k][j]);
            }
        }
    }
    
    int q; cin >> q;
    vector<int> ans(q);
    for (int i = 0; i < q; i++)
    {
        int s, t; cin >> s >> t;
        s--; t--;
        ans[i] = dp2[s][t] - 1;
        if(dp2[s][t] == INF) ans[i] = -1;
    }
    for (int i = 0; i < q; i++)
    {
        cout << ans[i] << endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }
int first_fixed_size_subset(int n, int k) { return (1 << k) - 1; }
int next_fixed_size_subset(int n, int k, int& s) {
  if (k == 0) return 0;

  int x = s & -s, y = s + x;
  s = (((s & ~y) / x) >> 1) | y;
  if (s >= (1 << n)) return 0;
  return s;
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  for (int i = 0; i < (int)(N); ++i) cin >> a[i];

  ll ans = 1e18;

  int s = first_fixed_size_subset(N, K);
  do {
    ll cost = 0, prev = 0;
    for (int i = 0; i < (int)(N); ++i) {
      if ((s >> i) & 1) {
        ll h = max(a[i], prev + 1);
        cost += h - a[i];
        prev = h;
      } else {
        chmax(prev, a[i]);
      }
    }
    chmin(ans, cost);
  } while (next_fixed_size_subset(N, K, s));

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int a[205];
int n,min=101,p=0;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[2*i]>>a[2*i+1];
}
for(int j=0;j<n;j++){
for(int i=0;i<2*n;i++){
if(a[i]<min)
min=a[i];
}p+=min;
for(int i=0;i<2*n;i++){
if(a[i]==min){
a[i]=101;
min=101;
break;
}
}
for(int i=0;i<2*n;i++){
if(a[i]<min)
min=a[i];
}
for(int i=0;i<2*n;i++){
if(min==a[i]){
min=101;
a[i]=101;
break;
}
}
}
cout<<p;
}

Measured memory_bytes: 256
// ALDS1_9_C: Priority Queue

use std::collections::BinaryHeap;

fn main() {
    let mut b = BinaryHeap::new();

    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut it = s.split_whitespace();
        let com = it.next().unwrap();
        if com == "end" {
            break;
        } 
        if com == "insert" {
            let x: i64 = it.next().unwrap().parse().ok().unwrap();
            b.push(x);
        } else {
            println!("{}", b.pop().unwrap());
        }
    }
}


Measured memory_bytes: 14048
import java.util.Scanner;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner scan = new Scanner(in);

		while(scan.hasNext()){
			String[] t = scan.next().split(",");
			double[] x = new double[4];
			double[] y = new double[4];
			x[0] = Double.parseDouble(t[0]);
			y[0] = Double.parseDouble(t[1]);
			x[1] = Double.parseDouble(t[2]);
			y[1] = Double.parseDouble(t[3]);
			x[2] = Double.parseDouble(t[4]);
			y[2] = Double.parseDouble(t[5]);
			x[3] = Double.parseDouble(t[6]);
			y[3] = Double.parseDouble(t[7]);

			double[] r = new double[4];

			for(int i=0;i<4;i++){
				double a2 = pow(x[(i+1)%4]-x[i],2)+pow(y[(i+1)%4]-y[i],2);
				double b2 = pow(x[(i+2)%4]-x[(i+1)%4],2)+pow(y[(i+2)%4]-y[(i+1)%4],2);
				double c2 = pow(x[i]-x[(i+2)%4],2)+pow(y[i]-y[(i+2)%4],2);

				r[i] = acos((a2+b2-c2)/(sqrt(a2*b2)*2));
			}

			if((r[0]+r[1]+r[2]+r[3])<PI*2)
				out.println("NO");
			else
				out.println("YES");
		}
	}

}

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

int main() {
	int a,b;
	cin>>a>>b;
	
	if(b>=499){
		cout<<"Yes"<<endl;
		
	}
	else{
		if(a%500>b%500){
			cout<<"No"<<endl;
			
		}
		else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N,cnt=0 ;
	cin >> N;
	for(int i=1;i<=9;i++){
		if(N%i==0){
			if((N/i)%10==N/i) cnt=1;
		}
	}
	if(cnt==1) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n,k,i,j,ret,x;
  char x0,x1,x2,x3,x4;
  int ch[5]={};
  cin >> n >> k;
  int a[10]={};
  for(i=0;i<k;i++){
    cin >> j;
    a[j]=1;
  }
  for(x0='0';x0<='9';x0++){
    ch[4]=0;
    if(x0=='0')ch[4]=1;
    if(a[x0-'0']==1&&ch[4]!=1)continue;
    for(x1='0';x1<='9';x1++){
      ch[3]=0;
      if(x1=='0'&&ch[4])ch[3]=1;
      if(a[x1-'0']==1&&ch[3]!=1)continue;
      for(x2='0';x2<='9';x2++){
        ch[2]=0;
        if(ch[3]&&x2=='0')ch[2]=1;
        if(a[x2-'0']==1&&ch[2]!=1)continue;
        for(x3='0';x3<='9';x3++){
          ch[1]=0;
          if(ch[2]&&x3=='0')ch[1]=1;
          if(a[x3-'0']==1&&ch[1]!=1)continue;
          for(x4='0';x4<='9';x4++){
            if(a[x4-'0'])continue;
            ret = 0;
            int b4,b3,b2,b1,b0;
            b4 = x0-'0';
            b3 = x1-'0';
            b2 = x2-'0';
            b1 = x3-'0';
            b0 = x4-'0';
            ret = b4*10000+b3*1000+b2*100+b1*10+b0;
            if(ret>=n){
              cout << ret << endl;
              return 0;
            }
          }
        }
      }
    }
  }
  return 0;
}
  
    

Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]
for a1 in range(101):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1
    if a2 + b2 == c[1][1] and a2 + b3 == c[1][2] and \
        a3 + b2 == c[2][1] and a3 + b3 == c[2][2]:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int B[105];
int main(){
    int n;
    while(cin>>n){
        for(int i=1;i<n;i++)
            cin>>B[i];
        int ans=0;
        for(int i=2;i<n;i++)
            ans+=min(B[i],B[i-1]);
        printf("%d\n", ans+B[1]+B[n-1]);
    }
    return 0;
}

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


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    int a,b,c;
    cin >> a>>b>>c;
    if(a+b+c<=21)cout<<"win"<<endl;
    else cout<<"bust"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main() {
  int n,q;
  cin >> n >> q;
  string str;
  cin >> str;
  vector<int> s(n+1,0);
  for(int i=0; i<n; i++) {
    if(str[i]=='A'&&str[i+1]=='C'&&i+1<n) {
      s[i+1]=s[i]+1;
    }
    else {
      s[i+1]=s[i];
    }
  }
  for(int i=0; i<q; i++) {
    int l,r;
    cin >> l >> r;
    cout << s[r-1]-s[l-1] << endl;
  }
}


Measured memory_bytes: 1408
N,K,Q=map(int,input().split())
A=list(int(input()) for i in range(Q))

kari = []
count = 0
for j in range(N):
    kari.append(K)

for k in range(Q):
    kari[A[k]-1]+=1
    count += 1
for i in range(N):
    kari[i]-=count
for m in range(N):
    if kari[m]>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 11764
#include<iostream>
#include<vector>
#include <algorithm>
#include <numeric>
using namespace std;
# define maxi 100000
# define maxw 100000
# define maxn 100000
using ll = long long;
int main() {
  ll N,x[5]={0},sum(0);
  string s[maxn];
  cin>>N;
  for (ll i(0);i<N;i++){
    cin>>s[i];
    if (s[i][0]=='M') x[0]+=1;
    else if(s[i][0]=='A')x[1]+=1;
    else if(s[i][0]=='R')x[2]+=1;
    else if(s[i][0]=='C')x[3]+=1;
    else if(s[i][0]=='H')x[4]+=1;
  }

  sum+=x[0]*x[1]*x[2];
  sum+=x[0]*x[1]*x[3];
  sum+=x[0]*x[1]*x[4];
  sum+=x[0]*x[2]*x[3];
  sum+=x[0]*x[2]*x[4];
  sum+=x[0]*x[3]*x[4];
  sum+=x[1]*x[2]*x[3];
  sum+=x[1]*x[2]*x[4];
  sum+=x[1]*x[3]*x[4];
  sum+=x[2]*x[3]*x[4];
  cout<<sum;
  return 0;
}

Measured memory_bytes: 2560
//
//  main.cpp
//  B-one_clue
//
//  Created by david chong on 8/14/19.
//  Copyright © 2019 david chong. All rights reserved.
//

#include <iostream>


using namespace std;


void solve(int k, int x) {
    
    int myMin = x - (k-1);
    int myMax = x + (k-1);
    
    while(myMin <= myMax) {
        cout << myMin << " ";
        myMin++;
    }
    
}

int main(int argc, const char * argv[]) {
    
//    x = 1;
//    y = 100;
    
    int x, y;
    
    cin >> x >> y;
    
    solve(x, y);
    
    return 0;
}


Measured memory_bytes: 256
import Foundation

// １行文字列
func readStr() -> String {
  readLine()!
}

// １行整数
func readInt() -> Int {
  Int(readLine()!)!
}

// 空白文字で分割された文字列
func readSpStrs() -> [String] {
  readLine()!.components(separatedBy: " ")
}

// 空白文字で分割された整数
func readSpInts() -> [Int] {
  readSpStrs().map { Int($0)! }
}

// N行分の整数
func readInt(_ n: Int) -> [Int] {
  (1...n).map { _ in readInt() }
}

let ab = readSpStrs()
let a = Int(ab[0])!
let b = ab[1].components(separatedBy: ".").map(Int.init)

let c = a * b[0]!
let d = a * b[1]! / 100

print(c + d)




Measured memory_bytes: 14192
#include<stdio.h>
#include<math.h>

#define INF -999999999
typedef long int ll;

ll max(ll a, ll b);
ll min(ll a, ll b);

int main()
{
  int n;
  int i;
  int prof[200001];
  ll ans = 0;
  
  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&prof[i]);
  }
  
  ll minv = prof[0];
  ll maxv = INF;
  for(i = 1;i < n;i++){
    maxv = max(maxv, prof[i]-minv);
    minv = min(minv, prof[i]);
  }
  
  printf("%ld\n",maxv);
  return 0;
}

ll max(ll a, ll b)
{
  if(a < b) return b;
  else return a;
}
ll min(ll a, ll b)
{
  if(a < b) return a;
  else return b;
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> vs(n), cs(n);
    for (int& v : vs) {
        cin >> v;
    }
    for (int& c : cs) {
        cin >> c;
    }
    int s = 0;
    for (int i = 0; i < n; ++i) {
        s += max(vs[i] - cs[i], 0);
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
s_list = list(s)
minis = []
for k in set(s):
  a = [i for i, x in enumerate(s_list) if x == k]
  mini = max(a[0], 0)
  for m in range(len(a) - 1):
    mini = max(a[m+1] - a[m] - 1, mini)
  mini = max(len(s) - a[-1] - 1, mini)
  minis.append(mini)
print(min(minis))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)ull
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n,x;
  scanf("%d%d",&n,&x);
  vi a(n);
  cin>>a;
  vl dp(2);
  dp[0] = 1;
  rep(i,n) {
    vl p = dp;
    rep(j,2) {
      dp[j] += p[(j+a[i])&1];
    }
  }
  cout<<dp[x]<<endl;
  return 0;
}






















Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U> bool chmax(T &a, U b) { if (a <= b) {a = b; return 1;} return 0; }
template <class T, class U>  bool chmin(T &a, U b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T>  ostream &operator<<(ostream &os, vector<T> &v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; }

// g++ -std=c++11 prac.cpp
// operator << (cout,a);
// chmin(min,a)

int main() {
    ll x=0,y=0,z=0,n,m,ans=0,sum=0,k,h,w,Max=-1,Min=1e9+1;
    bool ok = true;
    string s,t;
    cin >> s;
    if(s[1]=='B')
        cout << "ARC" << endl;
    else
    {
            cout << "ABC" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include<algorithm>
using namespace std;
int n;
int partition(int A[],int p,int r){
    int x=A[r],i=p-1;
    for(int j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            swap(A[i],A[j]);
        }
    }
   swap(A[i+1],A[r]);
    return i+1;
}
int main(){
    cin>>n;
    int A[100001];
    for(int i=0;i<n;i++) cin>>A[i];
    int q=partition(A,0,n-1); 
    for(int i=0;i<n;i++){
        if(i!=0) cout<<" ";
        if(i==q) cout<<"["<<A[i]<<"]";
        else cout<<A[i];
    } 
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3424
N, K = map(int, input().split())
S = input()
L = [0]
X = ['1']
pos = 0
for i in range(N):
  if S[i] != X[pos]:
    L.append(1)
    X.append(S[i])
    pos += 1
  else:
    L[pos] += 1
while pos < 2 * K + 4:
  L.append(0)
  X.append('1')
  pos += 1
L.append(0)
X.append('1')
n = len(L)
for i in range(1, n):
  L[i] += L[i-1]
M = L[2*K]
for i in range(1, n-2*K):
  if X[i] == '1':
    M = max(L[2*K+i] - L[i-1], M)
print(M)

Measured memory_bytes: 18628
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a;
    cin >> a;
    
    cout << (a < 1200 ? "ABC" : "ARC") << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;
char flag[100];

int main()
{
	int n,k,x,y,money;
	cin>>n>>k>>x>>y;
	if(n>k){
		money=k*x+(n-k)*y;
	}
	else{
		money=x*n;	
	}
	cout<<money<<endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int r, c;
    static int s[101][101];
    
    scanf("%d %d", &r, &c);
    
    for(int i=0; i<=r; i++) {
        for(int j=0; j<c; j++) {
            scanf("%d", &s[i][j]);
            printf("%d ", s[i][j]);
            
            s[i][c] += s[i][j];
            s[r][j] += s[i][j];
        }
        printf("%d\n", s[i][c]);
    }
    
    return 0;
}



Measured memory_bytes: 2104
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    ll temp=n;
    ll temp1=m-2*temp;
    if(temp1<0){
        return cout<<m/2<<"\n",0;
    }
    else{
        return cout << temp+temp1/4 << "\n",0;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>
#include <cfloat>
#include <array>


constexpr long long int MOD = 1000000007;
long long int power(long long int base, int exp) {
	switch (exp) {
	case 0: return 1L;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp >> 1) * power(base, exp & 1) % MOD;
	}
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}
int main() {
	int n, k; std::cin >> n >> k;
	std::vector<int> factor_count(k + 1, 0);
	for (auto i = 1; i <= k; ++i) {
		for (auto d = 1; d * d <= i; ++d) {
			if (i % d == 0) {
				factor_count[i] += 2;
				if (d * d == i) factor_count[i]--;
			}
		}
	}
	std::vector<long long int> pure(k + 1, 0);
	long long int result{ 0 };
	for (auto g = k; g >= 1; --g) {
		long long int pattern{ power(k / g, n) };
		for (auto i = 2; g * i <= k; ++i) {
			pattern += MOD - pure[i * g];
			pattern %= MOD;
		}
		pure[g] = pattern;
		result += pattern * g % MOD;
		result %= MOD;
	}
	std::cout << (result % MOD + MOD) % MOD << std::endl;
}

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

int main()
{
    string w;
    cin >> w;
    vector<int> v(27,0);
    for (int i = 0; i < w.size(); ++i){
        v[w[i] - 'a'] += 1;
    }
    bool ans = true;
    for (int i = 0; i < v.size(); ++i)
    {
        if( v[i] %2 == 1){
            ans = false;
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int main(){

	int table[4];

	scanf("%d %d %d %d",&table[0],&table[1],&table[2],&table[3]);

	for(int i = 1; i <= 3; i++){
		for(int k = 3; k >= i; k--){
			if(table[k] < table[k-1])swap(table[k],table[k-1]);
		}
	}

	if(table[0] == table[1] && table[2] ==table[3]){
		printf("yes\n");
	}else{
		printf("no\n");
	}

    return 0;
}

Measured memory_bytes: 2592
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

constexpr int lim = 300, v = 3;
int n, a[lim+1], cnt[v+1];
double dp[lim+1][lim+1][lim+1];

int main(){
  cin >> n;
  REP(i, n){
    cin >> a[i];
    cnt[a[i]]++;
  }

  function<double(int, int, int)> rec = [&](int i, int j, int k){
    if(i + j + k == 0) return 0.0;
    if(dp[i][j][k] > 0) return dp[i][j][k];

    double sum = 0.0;
    if(i > 0) sum += i * rec(i-1, j, k);
    if(j > 0) sum += j * rec(i+1, j-1, k);
    if(k > 0) sum += k * rec(i, j+1, k-1);

    return dp[i][j][k] = (double)(n + sum) / (i + j + k);
  }; 

  //print
  cout << setprecision(10) << rec(cnt[1], cnt[2], cnt[3]) << endl;

  return 0;
}


Measured memory_bytes: 213376