akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>

#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 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef pair<ll,int> LL_IP;


int main(){

    ll a,b,c,ans = 0;
    cin >> a >> b >> c;
    ll maxi = max(a,max(b,c));
    ll mini = min(a,min(b,c));
    ll middle = a+b+c-maxi-mini;
  
    if(middle % 2 == mini % 2){
        ans += (middle-mini)/2;
        ans += (maxi-middle);
    }else{

        while(middle % 2 != mini % 2){
            middle++;
            maxi++;
            ans++;
        }
        ans += (middle-mini)/2;
        ans += (maxi-middle);
    }
    cout << ans << endl;




    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string s;
  cin >> s;
  cin >> s;
  cout << "A" << s[0] << "C" << endl;
  return 0;
}


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

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> c(N);
    int size = 0;
    for(int i=0; i<N; ++i) {
        cin >> c[i];
        size = max(size, c[i]);
    }
    size += 1;
    vector<int> ma(size+1);
    for(int i=0; i<N; ++i) {
        ma[c[i]+1] = c[i];
    }
    for(int i=1; i<size; ++i) {
        ma[i] = max(ma[i], ma[i-1]);
    }
    for(int i=0; i<Q; ++i) {
        int q;
        cin >> q;
        int res = 0;
        for(int now=size-1; now != 0;) {
            res = max(res, now%q);
            now = ma[now - now%q];
        }
        cout << res << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  int p[n];
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  int res=0;
  for(int i=1;i<n-1;i++){
    if((p[i+1]-p[i])*(p[i-1]-p[i])<0)res++;
  }
  cout << res <<endl ;
  return 0;
}


Measured memory_bytes: 256
def Lucas(L1,L2,n,end):
   if(n==end):
      print(L1+L2)
   else:
      Lucas(L1+L2,L1,n+1,end)
def myAnswer(N:int) -> None:
   if(N == 0):
      print(2)
   elif(N == 1):
      print(1)
   else:
      Lucas(1,2,2,N)
   

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   myAnswer(N)

if __name__ == '__main__':
   main()

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

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

	if (n > 81) {
		cout << "No";
		return 0;
	}

	for (int i = 1; i <= 9; i++) {
		if (n % i == 0 && n / i <= 9) {
			cout << "Yes";
			return 0;
		}
	}
	
	cout << "No";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define repe1(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int a,b;
  cin >> a >> b;
  if ((a==1 || b==1) && (a==2 || b==2)) {
    cout << 3 << "\n";
  } else if ((a==1 || b==1) && (a==3 || b==3)) {
    cout << 2 << "\n";
  } else {
    cout << 1 << "\n";
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        int d=gi();
        int n=gi();


        if (n<100) {
	       System.out.println((int)Math.pow(100, d)*n);
        } else {
        	System.out.println((int)Math.pow(100, d)*(n+1));
        }

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35548
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, m; cin >> n >> m;
    vector<string> a(n), b(m);
    for(auto& e : a) cin >> e;
    for(auto& e : b) cin >> e;

    string res = "No";

    rep(i, n - m + 1){
        rep(j, n - m + 1){
            bool ok = [&]{
                rep(ik, m){
                    rep(jk, m){
                        if(b[ik][jk] != a[i + ik][j + jk]) return false;
                    }
                }
                return true;
            }();
            if(ok) res = "Yes";
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 156 -B
int main(void) {
	int  n,k,a=0;

	scanf("%d %d", &n,&k);

	while (n>0) {
		n /= k;
		a++;
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 128
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N, K;
    cin >> N >> K;

    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int res = 0;
    REV(d, 50, -1) {
        if (d >= 0 && ((1LL << d) & K) == 0) continue;

        int tmp = 0;
        REV(k, 50, 0) {
            if (k > d) {
                tmp += ((1LL << k) & K);
            } else if (k < d) {
                int cnt = 0;
                REP(i, A.size()) {
                    if ((A[i] >> k) & 1LL) cnt++;
                }
                if (cnt * 2LL < A.size()) {
                    tmp += (1LL << k);
                }
            }
        }
        int ans = 0;
        REP(i, A.size()) {
            ans += (tmp ^ A[i]);
        }
        res = max(res, ans);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
def com(n,r,m):
 f=[1,1]
 for i in range(2,n+1):
  f.append(f[i-1]*i%m)
 return f[n]*pow(f[r]*f[n-r]%m,m-2,m)%m
 
mod=10**9+7
x,y=map(int,input().split())
z=(x+y)//3
if (x+y)%3 or abs(x-y)>z:
 ans=0
else:
    ans=com(z,x-z,mod)
print(ans)

Measured memory_bytes: 35296
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

template <class T, class U>
ll euclid_gcd(T a, U b){
    if(a < b)return euclid_gcd(b,a);
    if(a == 0 || b == 0)return 1;
    ll r;
    while((r = a%b)){
        a = b;
        b = r;
    }
    return b;
}
template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
int main(){
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    ll ma = 0;
    rep(i,n) {cin >> a[i]; chmax(ma,a[i]);}

    ll g = euclid_gcd(a[0], a[1]);
    for(int i = 2; i < n; i++){
        g = euclid_gcd(g,a[i]);
        if(g == 1)break;
    }

    cout << ((k%g == 0) && (k <= ma) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 1024
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()

using LL = long long;
int vis[100005];
vector <int> ans;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
	return getchar();
//    if (ib == ie) {
//        ib = ibuf;
//        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
//    }
//    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

using P = pair<int,int> ;
vector<vector<P> > g(100005 + 1);
int b[100005];
#define fi first
#define se second

void dfs(int x)
{
	vis[x]=1;
	for(auto u:g[x])
	{
		if(vis[u.first]) continue;
		dfs(u.first);
		if(b[u.first])
		{
			ans.push_back(u.second);
			b[u.first]^=1;
			b[x]^=1;
		}
	}
}

int main() {
    int n = read();
    int m = read();
    vector<P> bomb;
    for (int i = 0; i < n; ++i) {
        int a = read(), b = read();
        bomb.emplace_back(a, b);
    }
    sort(begin(bomb), end(bomb));
    int lst = 0;
    for (int i = 0; i < n; ++i) {
        lst ^= b[i] = bomb[i].se ^ lst;
    }
    b[n] = lst;
    for (int i = 1; i <= m; ++i) {
        int l = read(), r = read();
        int ll = lower_bound(begin(bomb), end(bomb), P(l, 0)) - begin(bomb);
        int rr = upper_bound(begin(bomb), end(bomb), P(r, 1)) - begin(bomb);
        g[ll].emplace_back(rr, i);
        g[rr].emplace_back(ll, i);
    }
    
	for(int i=n;i>=0;i--)
	{
		if(vis[i]) continue;
		dfs(i);
		if(b[i])
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	sort(all(ans));
	cout<<ans.size()<<endl;
	for(auto x:ans)
	{
		printf("%d ",x);
	}
	cout<<endl;
    return 0;
}


Measured memory_bytes: 14580
N, M = gets.split.map(&:to_i)
x = Array.new(N+5, 0)
M.times {l, r = gets.split.map(&:to_i);x[l]+=1; x[r+1]-=1}
ans = 0
for i in 1..N
  x[i] += x[i-1]
  ans += x[i]==M ? 1 : 0
end
p ans

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

int main(){
	int N;
	cin >> N;
	int max_p = 0;
	int max_i = 1;
	
	for(int i = 1; i <= N; i++){
		int tmp = i;
		int a = 0;
		while(tmp > 3 || tmp % 2 == 0){
			tmp = tmp/2;
			a ++;
		}
		if(a > max_p) { max_p = a; max_i = i;}
	}
	cout << max_i << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int a = 1, b = 2, c = 3;

    if(x == 2) {
      x = a;
    } else if(x == 4 || x == 6 || x == 9 || x == 11) {
      x = b;
    } else {
      x = c;
    }
    if(y == 2) {
      y = a;
    } else if(y == 4 || y == 6 || y == 9 || y == 11) {
      y = b;
    } else {
      y = c;
    }

    if(x == y) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}


Measured memory_bytes: 21332
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a, b, c, d, e, X, Y ,r;
//  unsigned long long  a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d %d", &a, &b);
  
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
    sum=sum+A[i];
  } 

  qsort(A, a, sizeof(int), compare_int);
  for(i=0;i<a;i++){
//    printf("%d ",A[i]);
    
  } 
  for(i=a-1;i>=a-b;i--){
//      printf("%d %lf\n",A[i],(double)sum/(4*b));
    if(A[i]<((double)sum/(4*b))){
      printf("No\n");
      return 0;
    }
  } 
  
  
  printf("Yes\n");
  
return 0;
}


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

using namespace std;

int gcd(int a, int b) {  // a < b
  return b == 0 ? a : gcd(b, a % b);
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> L(n + 1);
  vector<int> R(n + 1);
  for (int i = 0; i < n - 1; i++) {
    L[i + 1] = gcd(L[i], a[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    R[i] = gcd(R[i + 1], a[i]);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, gcd(L[i], R[i + 1]));
  }
  cout << ans << endl;

  return 0;
}


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

#define pb push_back
#define mp make_pair
#define fs first
#define se second

typedef long long LL;

int n ;
int odd,cnt4,cnt2;

int main() {
 //   freopen("test.txt","r",stdin);
    cin >> n;
    for (int i =1 ; i <= n ; i++) {
        int x;
        cin >> x;
        if ( x % 4 == 0 ) cnt4++;
        if ( x % 2 == 0 && x % 4 != 0) cnt2++;
        if ( x % 2 != 0 ) odd++;
    }
    if ( cnt2 == 0 ) {
        if ( cnt4 < n/2) cout << "No";
        else cout << "Yes";
    } else {
        if ( cnt4 < odd) cout << "No";
        else cout << "Yes";
    }
}


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


int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        ll n;
        cin>>n;

        vector<ll> arr(n);
        map<ll,bool> ch;

        for(ll i=0;i<n;i++)
            cin>>arr[i] , ch[arr[i]] = 0;

        sort(arr.begin() , arr.end());

        for(ll i=0;i<n;i++)
        {
            if(ch[arr[i]])
                continue;

            for(ll j=2;arr[i]*j<=arr[n-1];j++)
                ch[arr[i] * j] = 1;
        }

        ll ans = 0;

        for(int i=0;i<n;i++)
        {
            if(ch[arr[i]])
                continue;
            if(i>0 && arr[i-1]==arr[i])
                continue;
            if(i<n-1 && arr[i+1]==arr[i])
                continue;
            ans++;
        }

        cout<<ans;
    }
    return 0;
}


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

int main(){
	long long H, W;
  	cin >> H >> W;
  	long long ans = 0;
  
	if(H == 1 || W == 1){
      	ans = 1;
    } else ans = H * W / 2 + (H * W % 2);
  
  	cout << ans << endl;
}

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

int main(int argc, char *argv[])
{
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  long sum = 0;
  if((A+B) > 2 * C){ // ABピザを買った方がAとBをばらばらに買うより安い場合．
    int n = max(X,Y) - abs(X - Y);
    X -= n;
    Y -= n;
    sum += 2 * n * C;
  }
  if(A > 2*C){ //Aピザを買うより，ABピザからAピザだけを作った方が安い場合
    sum += 2*C*X;
  }else{
    sum += A*X;
  }

  if(B > 2*C){// Bピザを買うより，ABピザからBピザだけを作った方が安い場合．
    sum += 2*C*Y;
  }else{
    sum += B*Y;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
x, n = map(int, input(). split())
m = [0]*200
ans = 0
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  quit()
for i in range(n):
  l = abs(x-p[i])
  m[l] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] < 2:
      a = x-j
      A = x+j
      if a not in p:
        ans = a
      else:
        ans = A
      break
  print(ans)


Measured memory_bytes: 62024
n,m,k=map(int,input().split())
mod = 998244353

f= [0]*(n+1)
p= [0]*(n+1)

f[0]=1
p[0]=1
for i in range(1,n+1):
    f[i] = f[i-1]*i%mod
    p[i] = pow(f[i],mod-2,mod)

def nCk(n,k):
    return f[n]*p[k]*p[n-k]%mod

ans = 0
for i in range(k+1):
    if i == 0:
        ans += m*pow(m-1,n-1-i,mod)
    else:
        ans += m*pow(m-1,n-1-i,mod)*nCk(n-1,i)
    ans %= mod
print(ans)



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

const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    int n,k;cin>>n>>k;
    vector<int> a(n),b(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    b.erase(unique(b.begin(),b.end()),b.end());
    long long ans=0;
    for(int i=1;i<b.size();++i){
        int r=upper_bound(a.begin(),a.end(),b[i])-a.begin();
        int l=upper_bound(a.begin(),a.end(),b[i-1])-a.begin();
        ans+=(COM(r,k)-COM(l,k)-COM((r-l),k))*b[i];
        ans%=MOD;
        while(ans<0)ans+=MOD;
    }
    for(int i=0;i<b.size()-1;++i){
        int r=a.end()-lower_bound(a.begin(),a.end(),b[i+1]);
        int l=a.end()-lower_bound(a.begin(),a.end(),b[i]);
        ans-=(COM(l,k)-COM(r,k)-COM((l-r),k))*b[i];
        ans%=MOD;
        while(ans<0)ans+=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 12928
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
using namespace std;
 
//num
const double EPS = 1e-10;
const double INF = 1e12;
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
 
// point, line, circle
typedef complex<double> P;
typedef vector<P> VP;
struct C{
    P p;
    double r;
    C(const P& p, const double& r) : p(p), r(r) {}
};
namespace std{
    bool operator < (const P& a, const P& b){
        return (a.X != b.X)? a.X < b.X : a.Y < b.Y;
    }
}
 
// vector operation
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
 
//utility
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //counter clockwise
    if(cross(b,c) <-EPS) return -1; //clockwise
    if(dot(b,c) < EPS) return +2; //c-a-b
    if(norm(b) < norm(c)) return -2; //a-b-c
    return 0; //a-c-b
}

int main(){
  vector<P> v(3);
  for(int i=0; i<3; i++){
    double x,y;
    cin >> x >> y;
    v[i] = complex<double>(x,y);
  }

  vector<double> len(3);
  vector<double> angle(3);
  for(int i=0; i<3; i++){
    len[i] = abs(v[(i+1)%3]-v[(i+2)%3]);
    P e1 = v[(i+1)%3]-v[i];
    P e2 = v[(i+2)%3]-v[i];
    angle[i] = tan( acos( dot(e1,e2)/(abs(e1)*abs(e2)) ) *0.5 );
  }
  
  double ans=0;
  for(int i=0; i<3; i++){
    ans = max(ans, len[i]/(2.0 +(1/angle[(i+1)%3]) +(1/angle[(i+2)%3])) );
  }

  cout << fixed;
  cout << setprecision(11);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define pf pop_front
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=305;
const ll inf=1e9+7;
double dp[maxn][maxn][maxn];
double p[maxn];
ll n;
map<int,int> m;
int main()
{
    while(cin>>n)
    {
        m.clear();
        rep(i,n)
        {
            ll tmp;
            cin>>tmp;
            m[tmp]++;
        }
        memset(dp,0,sizeof(dp));
        rep(k,n+1)
        rep(j,n+1)
        rep(i,n+1)
        {
            if(i||j||k)
            {
                if(i) dp[i][j][k]+=dp[i-1][j][k]*i/(i+j+k);
                if(j) dp[i][j][k]+=dp[i+1][j-1][k]*j/(i+j+k);
                if(k) dp[i][j][k]+=dp[i][j+1][k-1]*k/(i+j+k);
                dp[i][j][k]+=(double)n/(i+j+k);
            }
            //dp[i][j][k]+=(double)n/(i+j+k);
        }
        //cout<<dp[0][0][1]<<"\n";
        cout<<fixed<<setprecision(9)<<dp[m[1]][m[2]][m[3]]<<"\n";
    }
}


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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N);
    vi d(N);VCIN(d);
    sort(all(d));
    int ans=d[N/2]-d[N/2-1];
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <queue>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

void solve(int n, vector<int> p) {
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if ((p[i] < p[i - 1] && p[i] > p[i + 1]) ||
        (p[i] > p[i - 1] && p[i] < p[i + 1])) {
      ans += 1;
    }
  }
  cout << ans << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  solve(n, p);
  return 0;
}

Measured memory_bytes: 888
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    String S = sc.next();

    int step = 0, cur = N;
    List<Integer> outList = new ArrayList<Integer>();
    while (true) {
      if (cur <= M) {
        outList.add(cur);
        StringBuilder out = new StringBuilder();
        out.append(outList.get(outList.size()-1));
        for (int i = outList.size() - 2; i >= 0; i--) {
          out.append(" ");
          out.append(outList.get(i));
        }
        System.out.println(out);
        return;
      }

      for (int i = M; i >= 0; i--) {
        if (i == 0) {
          System.out.println("-1");
          return;
        }
        if (S.charAt(cur-i) != '1') {
          outList.add(i);
          cur -= i;
          break;
        }
      }
    }
  }
}

Measured memory_bytes: 31136
#include <stdio.h>
#include <string.h>

int main() {

	char S[10];

	scanf("%s", S);

	if (strcmp(S, "SUN") == 0) {
		printf("7");
	}
	else if (strcmp(S, "MON") == 0)
	{
		printf("6");
	}
	else if (strcmp(S, "TUE") == 0)
	{
		printf("5");
	}
	else if (strcmp(S, "WED") == 0)
	{
		printf("4");
	}
	else if (strcmp(S, "THU") == 0)
	{
		printf("3");
	}
	else if (strcmp(S, "FRI") == 0)
	{
		printf("2");
	}
	else if (strcmp(S, "SAT") == 0)
	{
		printf("1");
	}

	return 0;
}

Measured memory_bytes: 128
while true
    n = gets.to_i
    break if n == 0

    arr = gets.chomp.split
    status = [[false, false], [true, true]]
    count = 0
    arr.each{|step|
        case step
        when "lu" then status[0][0] = true
        when "ru" then status[0][1] = true
        when "ld" then status[0][0] = false
        when "rd" then status[0][1] = false
        end
        if status[0] == status[1]
            count += 1
            status[1] = [!status[1][0], !status[1][1]]
        end
    }
    puts count
end


Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define pf printf
#define sf scanf
#define pb push_back
#define MAX5 100005
#define MAX6 1000005
#define MAX7 10000005
#define FOR(i,n) for(i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define mod7 1000000007
typedef long long int ll;
typedef long double lld;
const double PI=2*acos(0.0);
int CASE=1,TEST=0;
ll n,m,x,c,w=0,ans=0,a=0,b=0,k=0;
string s;
int main(void){
    getline(cin,s);
    n=s.size();
    if(s[0]=='9'){
        for(int i=0;i<n;i++){
            if(s[i]=='9')ans+=s[i]-'0';
            else{
                a=1;
                break;
            }
        }
        if(a==0){cout<<ans<<endl;return 0;}
        ans=s[0]-'0';
        ans--;
        for(int i=1;i<n;i++){
            ans+=9;
        }
        cout<<ans<<endl;
    }else{
        for(int i=1;i<n;i++){
            if(s[i]=='9')ans+=s[i]-'0';
            else{
                a=1;
                break;
            }
        }
        if(a==0){
            ans+=s[0]-'0';
            cout<<ans<<endl;
            return 0;
        }
        ans=s[0]-'0';
        ans--;
        for(int i=1;i<n;i++){
            ans+=9;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> K(N);
  for(int i = 0; i < N; i ++)
    cin >> K[i];
  sort(K.begin(), K.end(), greater<int>());
  
  int maxSub = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++){
      if ( K[i] - K[j] > maxSub) {
        maxSub = K[i] - K[j];
      }                
    }
  }
                          
  cout << maxSub << endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};
use std::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut res = 1000;
    for i in 0..n - 1 {
        if a[i] < a[i + 1] {
            let stock = res / a[i];
            res += stock * (a[i + 1] - a[i]);
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2196
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;

        while ((line = br.readLine()) != null) {
            String[] input = line.split(" ");

            double x1 = Double.parseDouble(input[0]);
            double y1 = Double.parseDouble(input[1]);
            double x2 = Double.parseDouble(input[2]);
            double y2 = Double.parseDouble(input[3]);
            double x3 = Double.parseDouble(input[4]);
            double y3 = Double.parseDouble(input[5]);
            double xp = Double.parseDouble(input[6]);
            double yp = Double.parseDouble(input[7]);

            double z1 = (x2 - x1) * (yp - y2) - (y2 - y1) * (xp - x2);
            double z2 = (x3 - x2) * (yp - y3) - (y3 - y2) * (xp - x3);
            double z3 = (x1 - x3) * (yp - y1) - (y1 - y3) * (xp - x1);

            if ((z1 > 0 && z2 > 0 && z3 > 0) || (z1 < 0 && z2 < 0 && z3 < 0)) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
}


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

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

const long long INF = 1LL << 60;
long long dp[100100];

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    
    int minj;
    int cnt = 0;
    for(int i = 0; i < N-1; i++) {
        minj = i;
        for(int j = i; j < N; j++) {
            if(A[j] < A[minj]) minj = j;
        }
        swap(A[i], A[minj]);
        if(i != minj) cnt++;
    }

    for(int i = 0; i < N; i++) {
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3084
n, k = map(int, input().split())

a = list(map(int, input().split()))
count = 0
m = -1
for i in range(n):
    if a[i] == 1:
        m = i
        break

if k >= m+1:
    n = n - k
    count += 1
    while n > 0:
        n = n - k + 1
        count += 1
elif k >= n - m:
    n = n - k
    count += 1
    while n > 0:
        n = n - k + 1
        count += 1
else:
    n = n - k
    count += 1
    while n > 0:
        n = n - k + 1
        count += 1

print(count)

Measured memory_bytes: 14008
#include "bits/stdc++.h"

using namespace std;

void solve(void)
{
	int n, l;
	cin >> n >> l;
	int sum = 0, m = 1<<10;
	for (int i = 0; i < n; i++)
	{
		int x = i + l;
		if (abs(x) < abs(m))
		{
			m = x;
		}
		sum += x;
	}
	cout << sum - m << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    set<int> A;
    for(int i=0;i<N;i++){
        int num;
        cin >> num;
        if(A.find(num)==A.end()){
            A.insert(num);
        }else{
            A.erase(num);
        }
    }
    cout << A.size() << endl;
    return 0;
}

Measured memory_bytes: 4864
// Abhishek Chaturvedi- abhishekchaturvedi10oct //

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define endl            "\n"
#define inf             2e18+1
#define ninf            -2e18+1
#define mod             1000000007
#define eps             1e-9
#define ff              first
#define ss              second
#define int             long long 
#define ld              long double
#define str             string 
#define pb              emplace_back
#define mp              make_pair
#define vi              vector<int>
#define si              set<int>
#define pii             pair<int,int>
#define psi             pair<str,int>
#define mii             map<int,int>
#define msi             map<str,int>
#define maxheap         priority_queue<int>
#define minheap         priority_queue<int,vi,greater<int>>
#define sz(x)           (int)x.size()
#define all(x)          x.begin(),x.end()
#define allr(x)         x.rbegin(),x.rend()
#define gcd(x,y)        __gcd(x, y)
#define arrsz(x)        sizeof(x)/sizeof(x[0])
#define sp(x,y)         fixed<<setprecision(y)<<x
#define tc(x)           int x; cin>>x; while(x--)
#define loopf(i,x,y)    for(int i=x;i<=y;i++)
#define loopb(i,x,y)    for(int i=x;i>=y;i--)
#define in(x,n)         int x[n];loopf(i,0,n-1) cin>>x[i];
#define out(x)          for(auto i:x) cout<<i<<" "; cout<<endl;
#define init(x,n,y)     int x[n];loopf(i,0,n-1) x[i]=y;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

bool isPowerOfTwo(int x){
   return x&&(!(x&(x-1)));
}

int takemod(int x){ 
    return (x%mod + mod) % mod; 
}

int lcm(int x,int y) {
    return (x/gcd(x,y)) * y;
}

int fpow(int base,int power,int MOD) {
    int result = 1;
    base=base%MOD;
    while(power){
        if(power&1) 
            result = (result*base) % MOD;
        base = (base*base) % MOD;
        power = power>>1;
    }
    return result;
}

int modinv(int x){return fpow(x,mod-2,mod);}

void fastIO(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

void solve(){  
}

int32_t main(){
    
    fastIO();

    //tc(t){
        solve();
    //}
    int n,w; cin>>n>>w;
    init(dp,n*1000+1,inf); //the total min weight of items with value i
    dp[0]=0;
    loopf(i,0,n-1){
        int wt,cost; cin>>wt>>cost;
        loopb(j,n*1000,1){
            if(j>=cost)
                dp[j]=min(dp[j],dp[j-cost]+wt);
        }
    }
    int ans=0;
    loopf(i,0,n*1000){
        if(dp[i]<=w)
            ans=max(ans,i);
    }
    cout<<ans; 
    return 0;
}

Measured memory_bytes: 1024
N,M = map(int,input().split())
K = []
S = []
for _ in range(M):
    x = input().split()
    k = int(x[0])
    K.append(k)
    S.append([int(x[i]) for i in range(1,k+1)])

p = input().split()
p = [int(x) for x in p]

c = 0
for i in range(2 ** N):
    L = [((i >> j) & 1) for j in range(N)]
    T = "y"
    for j in range(M):
        s = 0
        for k in range(K[j]):
            s += L[S[j][k]-1]
        if s%2 != p[j]:
            T = "n"
            break
    if T == "y":
        c +=1
        
print(c)

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const ll INF = 1000000007;

vector< vector<ll> > M(110, vector<ll>(110, 0));
vector<ll> P(110);
int N;

ll multiplication(){
    for(int l = 2; l <= N; l++){
        for(int i = 1; i <= N - l + 1; i++){
            int j = i + l - 1;
            M[i][j] = INF * INF;
            for(int k = i; k < j; k++){
                M[i][j] = min(M[i][j], M[i][k] + M[k+1][j] + P[i-1] * P[k] * P[j]);
            }
        }
    }
    return M[1][N];
}

int main(){
    cin >> N;
    rep(i, N){
        cin >> P[i] >> P[i+1];
    }
    cout << multiplication() << endl;
}


Measured memory_bytes: 3260
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> h(n);
	rep(i,n) std::cin >> h[i];
	std::vector<int> d(n);
	rep(i,n-1) d[i] = (h[i+1]<=h[i]);
	d[n-1] = 0;
	int max = 0;
	int count = 0;
	rep(i,n) {
		if(d[i]) count++;
		else {
			max = std::max(max, count);
			count = 0;
		}
	}
	print(max);

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <climits>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,n,s) for(int i=(int)(s);i<(int)(n);++i)
#define RREP(i,n,s) for(int i=(int)(s);i>=(int)(n);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()


int main() {
    int n, m; cin >> n >> m;
    ll x[n], y[n], z[n];
    REP(i, n) {
        cin >> x[i] >> y[i] >> z[i];
    }

    ll dp[n+1][m+1][8];
    fill(dp[0][0], dp[n+1][0], -(ll)LLONG_MAX/2);
    REP(i, n+1) fill(dp[i][0], dp[i][1], 0);

    REP(i, n) {
        REP(j, m) {
            if (j > i) break;
            dp[i+1][j+1][0] = max(dp[i][j+1][0], dp[i][j][0] + x[i] + y[i] + z[i]);
            dp[i+1][j+1][1] = max(dp[i][j+1][1], dp[i][j][1] + x[i] + y[i] - z[i]);
            dp[i+1][j+1][2] = max(dp[i][j+1][2], dp[i][j][2] + x[i] - y[i] + z[i]);
            dp[i+1][j+1][3] = max(dp[i][j+1][3], dp[i][j][3] + x[i] - y[i] - z[i]);
            dp[i+1][j+1][4] = max(dp[i][j+1][4], dp[i][j][4] - x[i] + y[i] + z[i]);
            dp[i+1][j+1][5] = max(dp[i][j+1][5], dp[i][j][5] - x[i] + y[i] - z[i]);
            dp[i+1][j+1][6] = max(dp[i][j+1][6], dp[i][j][6] - x[i] - y[i] + z[i]);
            dp[i+1][j+1][7] = max(dp[i][j+1][7], dp[i][j][7] - x[i] - y[i] - z[i]);
        }
    }

    ll max = -1;
    REP(i, 8) {
        if (dp[n][m][i] > max) {
            max = dp[n][m][i];
        }
    }

    cout << max << endl;
}


Measured memory_bytes: 62848
#include <stdio.h>
#include <stdlib.h>

#define ARRAY_INIT 0
#define DIV_INIT 0
#define LOOP_INIT 0
#define G_MAX 12
#define FIRST_ITEM 0
#define EXIT_SUCCESS 0

int main( void )
{
	unsigned long ulW_Dtc_cnt;
	int *aulW_Dtestcase;
	unsigned long ulW_Cloop_cnt;
	unsigned long ulW_Cloop_sub_cnt;
	unsigned long ulW_Csort_cnt = DIV_INIT;
	unsigned long ulW_Dm = 1;//?????????????????????????????°
	unsigned long aulW_DG[ G_MAX ];//?????????????????????
	unsigned long ulW_Dv;
	signed long slW_Dk;
	unsigned long ulW_Dcalc;

	scanf( "%d", &ulW_Dtc_cnt );
	aulW_Dtestcase = malloc ( sizeof( int ) * ulW_Dtc_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		scanf( "%d", &aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	aulW_DG[ FIRST_ITEM ] = 1;
	ulW_Dcalc = 3 * aulW_DG[ ulW_Dm - 1 ] + 1;
	while( ulW_Dcalc < ulW_Dtc_cnt ){
		aulW_DG[ ulW_Dm ] = 3 * aulW_DG[ ulW_Dm - 1 ] + 1;
		ulW_Dm++;
		ulW_Dcalc = 3 * aulW_DG[ ulW_Dm - 1 ] + 1;
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm / 2; ulW_Cloop_cnt++ ){
		ulW_Dv = aulW_DG[ ulW_Cloop_cnt ];
		aulW_DG[ ulW_Cloop_cnt ] = aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ];
		aulW_DG[ ulW_Dm - 1 - ulW_Cloop_cnt ] = ulW_Dv;
	}

	printf( "%d\n", ulW_Dm );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++ ){
		if( ulW_Cloop_cnt == ulW_Dm - 1 ){
			printf( "%d\n", aulW_DG[ ulW_Cloop_cnt ] );
		}
		else{
			printf( "%d ", aulW_DG[ ulW_Cloop_cnt ] );
		}
	}

	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dm; ulW_Cloop_cnt++){
		for( ulW_Cloop_sub_cnt = aulW_DG[ ulW_Cloop_cnt ]; ulW_Cloop_sub_cnt < ulW_Dtc_cnt; ulW_Cloop_sub_cnt++ ){
			ulW_Dv = aulW_Dtestcase[ ulW_Cloop_sub_cnt ];
			slW_Dk = ulW_Cloop_sub_cnt - aulW_DG[ ulW_Cloop_cnt ];
			while( ( slW_Dk >= 0 ) && ( aulW_Dtestcase[ slW_Dk ] > ulW_Dv ) ){
				aulW_Dtestcase[ slW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = aulW_Dtestcase[ slW_Dk ];
				slW_Dk -= aulW_DG[ ulW_Cloop_cnt ];
				ulW_Csort_cnt++;
			}
			aulW_Dtestcase[ slW_Dk + aulW_DG[ ulW_Cloop_cnt ] ] = ulW_Dv;
		}
	}

	printf( "%d\n", ulW_Csort_cnt );
	for( ulW_Cloop_cnt = LOOP_INIT; ulW_Cloop_cnt < ulW_Dtc_cnt; ulW_Cloop_cnt++ ){
		printf( "%d\n", aulW_Dtestcase[ ulW_Cloop_cnt ] );
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 4508
#include<set>
#include<string>
#include<iostream>
#define F(A, B) for(int A=0; A<B; A++)
using namespace std;

string enc(string str){
	for(char ch='b'; ch<='z'; ch++){
		F(i, str.length() ){
			if(str[i] == ch){
				str[i] -= 1;
				break;
			}
		}
	}
	return str;
}

/*string enc(string str){
	int enc_log[30]={0};
	for(int i=0; i<str.length(); i++){
		if(enc_log[str[i]-'a']==0 && str[i]!='a'){
			enc_log[str[i]-'a'] = 1;
			str[i]--;
		}
	}
	return str;
}*/

void rec(set<string>& ans, const string& ori, string str, int& cnt){
	if(str.length() == ori.length() ){
		ans.insert(str);
		cnt++;
		if(ans.size() == 11){
			set<string>::iterator it=ans.begin();
			F(i, 5)it++;
			ans.erase(it);
		}
		return;
	}
	//for(int i=pos; i<ori.length(); i++){
	if(str.length() != ori.length() ){
		char tmp=ori[str.length()];
		if(ori.substr(0, str.length()+1) == enc(str+tmp) ){
			rec(ans, ori, str+tmp, cnt);
		}
		tmp++;
		if(tmp != 'z'+1 && ori.substr(0, str.length()+1) == enc(str+tmp) ){
			rec(ans, ori, str+tmp, cnt);
		}
	}
	return;
}

int main(){
	string str;
	cin >> str;
	while(str != "#"){
		int cnt=0, pos=0;
		set<string> ans;
		rec(ans, str, "", cnt);
		cout << cnt << endl;
		for(set<string>::iterator it=ans.begin(); it!=ans.end(); it++){
			cout << *it << endl; 
		}
		cin >> str;
	}
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  cout << "square1001" << endl;
}



Measured memory_bytes: 3028