akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N, T;
  cin >> N >> T;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  vector<ll> M(N);
  M.back() = A.back();
  for (ll i = N - 2; i >= 0; i--)
  {
    M.at(i) = max(M.at(i + 1), A.at(i));
  }

  ll ans = 0, m = 0;
  for (ll i = 0; i < N - 1; i++)
  {
    if (chmax(m, M.at(i + 1) - A.at(i)))
      ans = 0;
    if (m == M.at(i + 1) - A.at(i))
      ans++;
  }

  cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    int ans[10001] = {0};

    for (int i = 1; i < 105; i++) {
        for (int j = 1; j < 105; j++) {
            for (int k = 1; k < 105; k++) {
                int h = i * i + j * j + k * k + i * j + j * k + k * i;
                if (h <= 10000) ans[h]++;
            }
        }
    }
    for (int c = 0; c < n; c++) {
        cout << ans[c + 1] << endl;
    }

    return 0;
}


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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

/*int ter_search(int l,int r)
{
    while((r-l)>0)
    {
        int m1=l+(r-l)/3;
        int m2=r-(r-l)/3;
        int f1=f(m1);
        int f2=f(m2);
        if(f1>f2)
         l=m1+1;
         else
          r=m2-1;
    }
    return f(l);
}*/

int32_t main()
{
    int x;
    cin>>x;
    cout<<(1-x)<<"\n";
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdio>
using namespace std;
long long dp[100][100][5000]; long long n, k, x[100];
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> x[i]; dp[0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < 5000; k++) {
				if (dp[i][j][k] == 0)continue;
				dp[i + 1][j+1][k + x[i]] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}
	long long sum = 0;
	for (int i = 1; i <= n; i++)sum += dp[n][i][k*i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 9600
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[][] pl=new int[n][3];
		for(int i=0;i<n;i++){
			for(int j=0;j<3;j++){
				pl[i][j]=sc.nextInt();
			}
		}
		for(int h=0;h<3;h++){
			for(int i=0;i<n-1;i++){
				for(int j=i+1;j<n;j++){
					if(Math.abs(pl[i][h])==Math.abs(pl[j][h])){
						if(pl[j][h]<0){
							break;
						}
						pl[i][h]=-1*Math.abs(pl[i][h]);
						pl[j][h]=-1*Math.abs(pl[j][h]);
					}
				}
			}
		}
		for(int i=0;i<n;i++){
			int tmp=0;
			for(int j=0;j<3;j++){
				if(pl[i][j]>0){
					tmp+=pl[i][j];
				}
			}
			System.out.println(tmp);
		}
	}
}

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

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll n, m; cin >> n >> m;
	ll a[100005];
	priority_queue<ll> pq;
	for(ll i=0;i<n;i++){
		cin >> a[i];
		pq.push(a[i]);
	}
	for(ll i=0;i<m;i++){
		ll r = pq.top()/2;
		pq.pop();
		pq.push(r);
	}
	ll ans = 0LL;
	while(!pq.empty()){
		ans += pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}

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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string s; cin >> s;

  int ans = 1000;
  for (char c = 'a'; c <= 'z'; c++) {
    int des = 0;
    int l = 0;
    for (int i = 0; i < (int)s.size(); i++) {
      if (s.at(i) == c) {
	des = max(des, l);
	l = 0;
      }else {
	l++;
      }
    }
    des = max(des, l);
    ans = min(ans, des);
  }
  cout << ans << endl;

  return 0;
}



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

int main() {
	int sum; cin >> sum;
	while (1) {
		char c; cin >> c;
		if (c == '=')break;
		int a; cin >> a;
		switch (c) {
		case '+':sum += a; break;
		case '-':sum -= a; break;
		case '*':sum *= a; break;
		case '/':sum /= a; break;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
int n,ans;
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
		for(int j=1;j*j<=i;j++)
		{
			if (i%j==0)
				ans+=2;
			if (i==j*j)
				ans--;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int n,m;
char s[100][100];
bool vis[100][100];
bool dfs(int x,int y){
	vis[x][y]=1;
	if(x==n-1&&y==m-1)
		return 1;
	if(x+1<n&&s[x+1][y]=='#')
		return dfs(x+1,y);
	if(y+1<m&&s[x][y+1]=='#')
		return dfs(x,y+1);
	return 0;
}
bool check(){
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(s[i][j]=='#'&&vis[i][j]==0)
				return 0;
	return 1;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%s",s[i]);
	if(s[0][0]!='#'||s[n-1][m-1]!='#'||!dfs(0,0))
		puts("Impossible");
	else if(!check()){
		puts("Impossible");
	}
	else{
		puts("Possible");
	}
	//system("pause");
	return 0;
}

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

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

    vector<int> v(n);
    
    for(int i=0; i<n; i++){
        cin >> v[i];
    }

    long long int max = -1000000000;

    for(int a=0; a<=min(n,k); a++){
        for(int b=0; b<=min(n,k)-a; b++){

            /* initialize */
            long long int value = 0;
            deque<int> dq;// given
            priority_queue<int> pq;// at hand
            for(int l=0; l<n; l++){
                dq.push_back(v[l]);
            }

            for(int i=0; i<a; i++){
                if(!dq.empty()){
                    value += dq.front();
                    pq.push(-dq.front());
                    dq.pop_front();
                }
            }
            for(int j=0; j<b; j++){
                if(!dq.empty()){
                    value += dq.back();
                    pq.push(-dq.back());
                    dq.pop_back();
                }
            }
            if(max < value) max = value;
            for(int m=0; m<k-a-b; m++){
                if(!pq.empty()){
                    value += pq.top();
                    pq.pop();
                    if(max < value) max = value;
                }
            }
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define A 0
#define B 1
#define C 2
int n;
long long dp[2][3];

inline long long maks(long long a, long long b){
	return a>b?a:b;
}

void move(){
	dp[1][A]=dp[0][A];
	dp[1][B]=dp[0][B];
	dp[1][C]=dp[0][C];
}

int main(){

	scanf("%d", &n);
	for(int i=0;i<n;i++){
		int a,b,c;
		scanf("%d %d %d", &a, &b, &c);
		dp[0][A] = a + maks(dp[1][B], dp[1][C]);
		dp[0][B] = b + maks(dp[1][A], dp[1][C]);
		dp[0][C] = c + maks(dp[1][A], dp[1][B]);
		move();
	}
	printf("%lld", maks(maks(dp[1][A], dp[1][B]), dp[1][C]));
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <queue>
#include <functional>
#include <map>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using pii  = pair<int,int>;
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

bool c[100007];
vector<vector<pii>> G;

void dfs(int p=-1,int k=0){
    for(const auto &d : G[k]){
        int j = d.first;
        int w = d.second;
        if(p==j)
            continue;        
        if(w%2==0)
            c[j]=c[k];
        else c[j]=!c[k];   

        dfs(k,j);     
    }
}

int main(){
    ll N,u,v,w;cin>>N;
    c[0]=true;
    G.resize(N);
    rep(i,N-1){
        cin >> u >> v >> w;
        --u;
        --v;
        G[u].emplace_back(v,w);
        G[v].emplace_back(u,w);  // =G[a].push_back(make_pair(b,w))
    }
    dfs();
    rep(i,N){
        cout << c[i] << endl;
    }
}

Measured memory_bytes: 7936
#include <iostream>
 
int main () {
	int a,b,c;
  
  std::cin >> a >> b >> c;
  std::string res;
  
  if (c-b == b-a) {
  	res = "YES";
  } else {
  	res = "NO";
  }
  
  std::cout << res << std::endl;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>a;
  int ans=10-a/200;
  cout <<ans;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;


int main(){
  int N;
  bool can = true;
  cin >> N;
  ll a[N];
  rep(i, N){
    cin >> a[i];
  }
  rep(i, N-1){
    if(a[i]>a[i+1]){
      ll x=a[i];
      while(a[i]>=a[i+1]){
        if(a[i+1]<=x-2){
          can = false;
          break;
        }
        i++;
      }
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  string s, t;
  cin >> s >> t;

  long count = 0;
  for (long i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i)) {
      count++;
    }
  }

  cout << count << endl;
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int calcpoint(vi cards, bool *useace) {
  int point = 0;
  bool hasace = false;
  REP(i, cards.size()){
    if (cards[i] == 1 && ! hasace){
      hasace = true;
    }else{
      point += cards[i];
    }
  }

  *useace = false;
  if(hasace){
    if(point <= 10){
      *useace = true;
      point += 11;
    }else{
      point ++;
    }
  }
  return point;
}

int main() {
  int n;
  cin >> n;
  REP(i, n){
    vi cards;
    queue<int> deck;
    REP(j, 2){
      char c;
      cin >> c;
      if(isdigit(c)){
        cards.push_back(c - '0');
      }else if(c == 'A'){
        cards.push_back(1);
      }else{
        cards.push_back(10);
      }
    }
    REP(j, 8){
      char c;
      cin >> c;
      if(isdigit(c)){
        deck.push(c - '0');
      }else if(c == 'A'){
        deck.push(1);
      }else{
        deck.push(10);
      }
    }

    bool useace = false;
    int point = calcpoint(cards, &useace);
    if(point == 21){
      cout << "blackjack" << endl;
      continue;
    }

    while(point <= 16 || (point == 17 && useace)){
      cards.push_back(deck.front()); deck.pop();
      point = calcpoint(cards, &useace);
    }

    if (point > 21){
      cout << "bust" << endl;
    } else{
      cout << point << endl;
    }
  }
}

Measured memory_bytes: 1216
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int,input().split()))

n_c4 = 0
n_c2 = 0
n_c0 = 0

for ai in a:
    if ai%4 ==0:
        n_c4 += 1
    elif ai%2 ==0:
        n_c2 += 1
    else:
        n_c0 += 1
if n_c4>=n_c0 or (n_c4 == n_c0-1 and n_c4+n_c0 == N) :
    print('Yes')
else:
    print('No')


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

int main(){
    while(1){
        int a,b;
        char op;
        cin>>a>>op>>b;
        if(op=='?') break;
        if(op=='+') cout<<a+b<<endl;
        else if(op=='-')cout<<a-b<<endl;
        else if(op=='*')cout<<a*b<<endl;
        else cout<<a/b<<endl;
    }
    return 0;
}


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

using namespace std;
int timetime = 0;

void dfs(int cur, vector<vector <int> > &list, vector<int> &d, vector<int> &f) {
		d[cur] =timetime;
		timetime +=1;
    for(int i = 0; i < list.size();i++){
      vector<int>::iterator n1end = list[cur].end();
	  vector<int>::iterator n1sres = find(list[cur].begin(),list[cur].end(),i);
      if(d[i] == -1 &&  n1end != n1sres  ){
        dfs(i,list,d,f);
      }
    }
    f[cur] = timetime;
    timetime +=1;
}

int main() {
  int np;
  int k,t,x;
  cin >> np ;
 
  vector <vector <int> > list(np);
  for(int i = 0;i<np;i++) {
    cin >> k;
    cin >> t;
    for(int j = 0; j < t ;j++) {
      cin >>x;
      list[k-1].push_back(x-1);
    }
  }
  for(int i = 0 ; i< np;i++){
	sort(list[i].begin(),list[i].end());
  }
  vector <int> d(np,-1);
  vector <int> f(np,0);
  dfs(0,list,d,f);
  	  int flag =0;
  do {
	  flag = 0;
	  for(int i = 0; i< np ;i++) {
		if(d[i] == -1){
				  dfs(i,list,d,f);
				  flag = 1;
				  break;
		}
	  }

  }while(flag ==1);
  for(int i = 0;i < np; i++){
    cout << i+1 <<" "<<d[i]+1 <<" "<<f[i]+1<<endl;
  }


  return 0;
}

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

const int INF = 1 << 30;

int main() {
	int n;
	cin >> n;
	
	int tmp_cnt[26], min_cnt[26];
	for (int i = 0; i < 26; i++) {
		tmp_cnt[i] = 0;
		min_cnt[i] = INF;
	}

	string S;
	for (int i = 0; i < n; i++) {
		cin >> S;
		for (auto c : S) tmp_cnt[c - 'a']++;
		for (int i = 0; i < 26; i++) {
			min_cnt[i] = min(min_cnt[i], tmp_cnt[i]);
			tmp_cnt[i] = 0;
		}
	}
	
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < min_cnt[i]; j++) {
			cout << (char)('a'+i);
		}
	}
	cout << endl;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
uf = UnionFind(N)
for i in range(M):
    A,B = map(int,input().split())
    uf.union(A-1,B-1)
maxsize = 0
for i in range(N):
    size = uf.size(i)
    if size > maxsize:
        maxsize = size
print(maxsize)

Measured memory_bytes: 14384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <set>

using namespace std;

int main(void) {
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> sum_row(h, 0), sum_col(w, 0);
    set<pair<int, int>> t;
    for (int i = 0; i < m; i++) {
        int h, w;
        cin >> h >> w;
        h--, w--;
        sum_row[h] += 1;
        sum_col[w] += 1;
        t.emplace(h, w);
    }
    int max_row = *max_element(sum_row.begin(), sum_row.end());
    int max_col = *max_element(sum_col.begin(), sum_col.end());
    vector<int> row_idx;
    vector<int> col_idx;
    for (int i = 0; i < sum_row.size(); i++) {
        if (sum_row[i] == max_row)
            row_idx.push_back(i);
    }
    for (int i = 0; i < sum_col.size(); i++) {
        if (sum_col[i] == max_col)
            col_idx.push_back(i);
    }

    int ans = max_row + max_col;
    for (auto row : row_idx) {
        for (auto col : col_idx) {
            if (t.count(pair<int, int>(row, col))) continue;
            cout << ans << endl;
            return 0;
        }
    }
    ans--;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 23756
import numpy as np
a = input()
n, l = [int(i) for i in a.split(" ")]
apples = np.array([i for i in range(n)])
aji = apples + l
abss = [np.abs(aji[apples != i].sum() - aji.sum()) for i in range(n)]
i = abss.index(np.min(abss))
print(aji[apples != i].sum())

Measured memory_bytes: 12452
#include<iostream>
using namespace std;
#define loop(i,a,b) for(int i=a;i<(int)b;i++)
int main() 
{
    long long int w,a,b;
    cin>>w>>a>>b;
    cout<<max(0LL,max(b-a-w,a-b-w));
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

x = sum(B)-sum(A)
if x<0:
  #print(sum(B), sum(A), x)
  print('No')
  exit()
  
C = [b-a for a, b in zip(A,B)]
#a
if sum([(c+1)//2 if c>0 else 0 for c in C]) >x:
  #print(C)
  #print([(c+1)//2 if c>0 else 0 for c in C])
  print('No')
  exit()

#b
if sum([-c if c<=0 else c%2 for c in C]) >x:
  #print('b')
  #print(C)
  #print([-c if c<=0 else c%2 for c in C])
  print('No')
  exit()
print('Yes')


Measured memory_bytes: 4852
n, q = map(int,input().split())

class UnionFind:
	"""
	class UnionFind
	https://note.nkmk.me/python-union-find/
	
	order O(log(n))
	
	n = the number of elements
	parents = the list that contains "parents" of x. be careful that it doesn't contain "root" of x.
	"""
	def __init__(self, n):
		"""
		make UnionFind
		:param n: the number of elements
		"""
		self.n = n
		self.parents = [-1] * n
	
	def find(self, x):
		"""
		:param x: an element
		:return: the root containing x
		"""
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]
	
	def union(self, x, y):
		"""
		:param x, y: an element
		"""
		# root
		x = self.find(x)
		y = self.find(y)
		if x == y:
			# already same group so do nothing
			return
		if self.parents[x] > self.parents[y]:
			# the root should be min of group
			x, y = y, x
		# remind that x, y is the root, x < y, then, y unions to x.
		self.parents[x] += self.parents[y]
		# and then y's parent is x.
		self.parents[y] = x
	def size(self, x):
		# return the size of group
		return -self.parents[self.find(x)]
	
	def same(self, x, y):
		# return whether the x, y are in same group
		return self.find(x) == self.find(y)
	
	def members(self, x):
		# return members of group
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]
	
	def roots(self):
		# return all roots
		return [i for i, x in enumerate(self.parents) if x < 0]
	
	def group_count(self):
		# return how many groups
		return len(self.roots())
	
	def all_group_members(self):
		# return all members of all groups
		return {r: self.members(r) for r in self.roots()}

targ = UnionFind(n)

for i in range(q):
	t, u, v = map(int,input().split())
	if t == 0:
		targ.union(u, v)
	else:
		if targ.same(u, v):
			print(1)
		else:
			print(0)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n = s.size();
    ll ans=0;
    rep(i,1<<n-1){
        int I = i|(1<<n-1);
        ll now=0;
        rep(j,n){
            int c = s[j]-'0';
            now = now*10+c;
            if (I>>j&1) ans+=now, now=0;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int v[1007];

int main(){
int n; cin >> n;
double  t, a ;cin >> t >> a;
for(int i = 0; i< n; i++){
	cin >> v[i];
}
double ans = 1e9;
int res = 0;
for(int i = 0; i< n ; i++){
	if(abs(a - (t - v[i] * 0.006)) < ans){
		res = i + 1;
		ans = abs(a - (t - v[i] * 0.006));
	}
}
cout << res;
	return 0;
}


Measured memory_bytes: 256
sen1=input()
sen2=input()

possible_start=[]

for i in range(len(sen1)):
    if sen2[0]==sen1[i]:
        possible_start.append(i)

if len(possible_start)==0:
    print("No")

for i in range(len(possible_start)):
    sen1_new=sen1[possible_start[i]:]+sen1[:possible_start[i]]
    if sen2 in sen1_new:
        print("Yes")
        break
    else:
        if i==len(possible_start)-1:
            print("No")




Measured memory_bytes: 5564
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 1 << 18, mod = 998244353;
int n, len, sum, p[N], A[N];
inline int kasumi(int a, int b){
	int res = 1;
	while(b){
		if(b & 1) res = (LL) res * a % mod;
		a = (LL) a * a % mod;
		b >>= 1;
	}
	return res;
}
inline int add(int a, int b){int c = a + b; if(c >= mod) c -= mod; return c;}
inline int sub(int a, int b){int c = a - b; if(c < 0) c += mod; return c;}
inline void div2(int &x){if(x & 1) x += mod; x >>= 1;}
inline void FWT(int *A, int type){
	for(Rint mid = 1;mid < len;mid <<= 1)
		for(Rint j = 0;j < len;j += (mid << 1))
			for(Rint k = 0;k < mid;k ++){
				int x = A[j + k], y = A[j + k + mid];
				A[j + k] = add(x, y); A[j + k + mid] = sub(x, y);
				if(type) div2(A[j + k]), div2(A[j + k + mid]);
			}
}
int main(){
	scanf("%d", &n); len = 1 << n;
	for(Rint i = 0;i < len;i ++) scanf("%d", p + i), sum += p[i];
	sum = kasumi(sum, mod - 2);
	for(Rint i = 0;i < len;i ++) p[i] = (LL) p[i] * sum % mod; -- p[0];
	A[0] = len - 1;
	for(Rint i = 1;i < len;i ++) A[i] = mod - 1;
	FWT(A, 0); FWT(p, 0);
	for(Rint i = 0;i < len;i ++)
		A[i] = (LL) A[i] * kasumi(p[i], mod - 2) % mod;
	FWT(A, 1);
	for(Rint i = 0;i < len;i ++)
		printf("%d\n", sub(A[i], A[0]));
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int n,k;
LL dp[105][100005],sum[100005];
int mod = 1e9+7;

int main() {
	scanf("%d%d",&n,&k);
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;
	for (int i=1; i<=n; i++) {
		int a;
		scanf("%d",&a);
		sum[0] = dp[i-1][0];
        for (int j=1; j<=k; j++) {
			sum[j] = sum[j-1]+dp[i-1][j];
			sum[j] %= mod;
        }
        for (int j=0; j<=k; j++) {
        	dp[i][j] = sum[j];
        	if (j-a-1 >= 0) dp[i][j] -= sum[j-a-1];
			dp[i][j] = (dp[i][j]%mod+mod)%mod;
        }
	}

	printf("%d\n",dp[n][k]);
	return 0;
}


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

int main(){
    int N, L;
    cin >> N >> L;

    int sum = 0;
    if(L >= 0){
        for(int i = 2; i <= N; i++){
            sum += L + i - 1;
        }
    }else{
        if(N > abs(L)){
            for(int i = 1; i <= N; i++){
                sum += L + i - 1;
            }
        }else{
            for(int i = 1; i < N; i++){
                sum += L + i - 1;
            }
        }

    }
    cout << sum << endl;
}

Measured memory_bytes: 256
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

// Main Code
int k, n;
vector<int> ans;

void dec(int d = n - 1) {
    if (ans[n - 1]) {
        --ans[n - 1];
    } else {
        if (ans[d - 1]) {
            --ans[d - 1];
            if (ans[d - 1]) rng(i, d, n) ans[i] = k;
        } else {
            dec(d - 1);
        }
    }
}

void solve() {
    cin >> k >> n;
    
    if (!(k & 1)) {
        rep(i, n) cout << (i ? k : k / 2) << " \n"[i == n - 1];
        return;
    }
    if (k == 1) {
        rep(i, (n + 1) / 2) cout << k << " \n"[i == (n - 1) / 2];
        return;
    }
    
    ans.resize(n, (k + 1) / 2);
    rep(i, n / 2) dec();
    int cnt = 0;
    rep(i, n) {
        if (ans[i]) ++cnt;
    }
    rep(i, cnt) cout << ans[i] << " \n"[i == cnt - 1];
    return;
}


Measured memory_bytes: 4428
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint comb(int n, int r) {
  mint x = 1, y = 1;
  rep (i, r) {
    x *= (n - i);
    y *= (i + 1);
  }
  return x / y;
}


int main() {
  int n;
  cin >> n;
  mint ans;
  ans = mint(2).pow(n);
  ans -= 1;

  int a, b;
  cin >> a >> b;

  ans = ans - comb(n, a) - comb(n, b);
  cout << ans.x << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int N=2e5+7;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans;
    ll a1=b/c,a2=b/d,a3=b/(c*d/gcd(c,d));
    ll b1=a/c,b2=a/d,b3=a/(c*d/gcd(c,d));
    ll x1=(a1-b1),x2=(a2-b2),x3=(a3-b3);
    ans=b-a+1-x1-x2+x3;
    if(a%c==0) ans--;
    if(a%d==0) ans--;
    if(a%(c*d)==0) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
    char tcard[101], hcard[101];
    int n, h = 0, t = 0; 
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {   
        int tnum = 0, hnum = 0;
        scanf("%s %s", tcard, hcard);
        if (strcmp(tcard, hcard) > 0)
        {
            t = t + 3;
        }else if (strcmp(tcard, hcard) < 0)
        {
            h = h + 3;
        }else
        {
            t = t + 1;
            h = h + 1;
        }
    }
    printf("%d %d\n", t, h);
    return 0;
}



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

int main() {

    int N, Y;
    cin >> N >> Y;

    for (int x = 0; x <= N; ++x) {
        for (int y = 0; y <= N; ++y) {
            int z = N - x - y;
            if (10000*x + 5000*y + 1000*z == Y and z >= 0) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 3580
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum mod = 10L^^9 + 7;
enum inf = 10^^9;

void main() {
    int n, ma, mb;
    scan(n, ma, mb);
    auto a = new int[](n);
    auto b = new int[](n);
    auto c = new int[](n);
    foreach (i ; 0 .. n) {
        scan(a[i], b[i], c[i]);
    }
    auto dp = new int[][][](n + 1, 401, 401);
    fillAll(dp, inf);
    dp[0][0][0] = 0;

    foreach (i ; 1 .. n + 1) {
        foreach (ag ; 0 .. 401) {
            foreach (bg ; 0 .. 401) {
                dp[i][ag][bg] = dp[i-1][ag][bg];
                if (ag - a[i-1] >= 0 && bg - b[i-1] >= 0) {
                    dp[i][ag][bg] = min(dp[i][ag][bg],
                        dp[i-1][ag - a[i-1]][bg - b[i-1]] + c[i-1]);
                }
            }
        }
    }

    long ans = inf;
    int aa = ma, bb = mb;

    while (aa <= 400 && bb <= 400) {
        debug {
            writeln(dp[n][aa][bb]);
        }
        ans = min(ans, dp[n][aa][bb]);
        aa += ma;
        bb += mb;
    }

    writeln(ans < inf ? ans : -1);
}























void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 38012
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


# 1, 2, 4, 8
amount = [4 * x for x in LI()]
n = I() * 4

performance = [(amount[i] // (2 ** i), i) for i in range(4)]
performance.sort()

bought_tea, fee = 0, 0
for i in range(4):
    tea = performance[i][1]
    litre = 2 ** tea
    q = (n - bought_tea) // litre
    bought_tea += q * litre
    fee += q * amount[tea]

print(fee // 4)


Measured memory_bytes: 3064
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var m = parseInt(input[0].split(" ")[1]);
  var s = input[1];
  var t = input[2];
  var ans = getLCM(n,m);
  var gcd = getGCD(n,m);
  for(i=0;i<gcd;i++){
    if(s.substr(i*n/gcd,1)!=t.substr(i*m/gcd,1)){
      ans=-1;
      break;
    }
  }
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

// numを素因数分解し結果を因数と指数のオブジェクト配列として返す
function getPrimeList(num) {

	var list = new Array();

	if (num < 1) {
		return null;
	}

	var i;

	// 平方根を素因数候補の最大値とする
	var r = Math.floor(Math.sqrt(num));

	for (i = 2;i <= r;i++) {

		// 候補で割り切れたら素因数として追加
		if ((num % i) == 0) {

			var n = 0;

			// 割り切れる回数を指数として記録
			do {

				n++;

				num = num / i;

			} while ((num % i) == 0);

			// 素因数オブジェクト作成
			var item = new Object();

			// 値と指数をプロパティとして記録
			item.num = i;
			item.r = n;

			// 配列にオブジェクトを記録
			list.push(item);

		}

	}

	// 最後に残った素因数を追加
	if (num > r) {

		var item = new Object();

		item.num = num;
		item.r = 1;

		list.push(item);

	}

	// 結果を返す
	return list;

}
// 整数aと整数bの最小公倍数を求める
function getLCM(a, b) {

	// aの素因数リストを取得
	var aPrimeList = getPrimeList(a);

	// bの素因数リストを取得
	var bPrimeList = getPrimeList(b);

	// 最小公倍数を保存する変数
	var lcm = 1;

	var i, j;

	// 共通の因数を保存する配列
	var list = new Array();

	// 共通の因数を保存し、掛け合わせる
	for (i = 0;i < aPrimeList.length;i++) {

		// bの因数リストを走査
		for (j = 0;j < bPrimeList.length;j++) {

			// aの因数がbにも含まれていたら共通因数の処理
			if (aPrimeList[i].num == bPrimeList[j].num) {

				// 因数の指数のうち大きな方を掛け合わせる
				if (aPrimeList[i].r > bPrimeList[j].r) {
					for (k = 0;k < aPrimeList[i].r;k++) {
						lcm *= aPrimeList[i].num;
					}
				} else {
					for (k = 0;k < bPrimeList[j].r;k++) {
						lcm *= aPrimeList[i].num;
					}
				}

				// 共通因数配列に追加
				list.push(aPrimeList[i].num);

			}
		}

	}

	// aの素因数分解リストから共通因数でない因数を抽出し掛け合わせる
	for (i = 0;i < aPrimeList.length;i++) {

		var flg = false;

		for (j = 0;j < list.length;j++) {
			if (aPrimeList[i].num == list[j]) {
				flg = true;
			}
		}

		if (!flg) {
			for (k = 0;k < aPrimeList[i].r;k++) {
				lcm *= aPrimeList[i].num;
			}
		}

	}

	// bの素因数分解リストから共通因数でない因数を抽出し掛け合わせる
	for (i = 0;i < bPrimeList.length;i++) {

		var flg = false;

		for (j = 0;j < list.length;j++) {
			if (bPrimeList[i].num == list[j]) {
				flg = true;
			}
		}

		if (!flg) {
			for (k = 0;k < bPrimeList[i].r;k++) {
				lcm *= bPrimeList[i].num;
			}
		}

	}

	return lcm;

}
function getGCD(m, n) {
  // 剰余
  var r;

  if(m < n) {  // m >= nにする
    r = m;  //一時退避
    m = n;
    n = r;
  }

  while ((r = m % n) != 0) {
    m = n;
    n = r;
  }

  return n;
}

Measured memory_bytes: 21572
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 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(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,x,t;
    cin >> n >> x >> t;
    cout << (n+x-1)/x * t << endl;


}


Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (c <= (a + b)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> va(n);
  for (int i = 0; i < n; i++) {
    cin >> va[i];
    va[i]--;
  }

  int cur = 0, cnt = 0;
  while (cnt < n && cur != 1) {
    cur = va[cur];
    cnt++;
  }

  if (cur == 1) {
    cout << cnt << '\n';
  } else {
    cout << -1 << '\n';
  }

  return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;
int n,a[100002],l[100002],r[100002],res=1;
int gcd(int a,int b) {return (b==0)?a:gcd(b,a%b);}
int main()
{
    //freopen("C.INP","r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n;
    for (int i=1;i<=n;i++) cin >> a[i];
    int li=1,ri=n;
    l[0]=r[n+1]=0;
    while (li<=n&&ri>=1)
    {
        l[li]=gcd(l[li-1],a[li]);
        r[ri]=gcd(r[ri+1],a[ri]);
        li++;ri--;
    }
    for (int i=1;i<=n;i++) res=max(res,gcd(l[i-1],r[i+1]));
    cout << res;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

void usaco(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main()
{
    usaco();
    int n;
    cin >> n;
    if (n >= 30) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 3648
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(N)]
ans=0
cnt=C
for i in range(N):
  for j in range(M):
    cnt+=B[j]*A[i][j]
  if cnt>0:
    ans+=1
  cnt=C
print(ans)

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	vector<ll> b(n);
	b[0]=a[0];
	rep(i,n-1){
		b[i+1]=b[i]+a[i+1];
	}
	ll ans=1000000000000000000;
	rep(i,n-1){
		ans=min(ans,abs(b[i]-(b[n-1]-b[i])));
	}
	cout << ans << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define INF 1001

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v1(n, vector<int>(n, INF));
  vector<vector<int>> v2(n, vector<int>(n, INF));
  for(int i=0;i<m;i++){
    int a, b, c;
    cin >> a >> b >> c;
    v1[a-1][b-1]=v1[b-1][a-1]=c;
    v2[a-1][b-1]=c;
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if (v1[i][j] > v1[i][k]+v1[k][j]){
          v1[i][j]=v1[i][k]+v1[k][j];
        }
      }
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v2[i][j]==INF){
        continue;
      }else{
        if(v2[i][j] > v1[i][j]){
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  long double n, k; cin >> n >> k;
  long double ans = 0;
  
  for(long double i = 1; i <= n; ++i) {
    for(long double j = 0; ; ++j) {
      if(i * pow(2, j) >= k) {
	ans += (1/n) * pow(0.5, j);
	break;
      }
    }
  }
  printf("%.10Lf", ans);
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main{
  public static void main(String[] args) {
    
	  Scanner sc = new Scanner(System.in);
	  
	  int a = sc.nextInt();
	  int b = sc.nextInt();
	  
	  double doublea = a;
	  double doubleb = b;
	  
	  int d = a/b;
	  int r = a%b;
	  double f = doublea / doubleb;
	  
	  String f2 = String.format("%.5f", f);
	  
	  System.out.println(d+" "+r+" "+f2);
  }
}

Measured memory_bytes: 26484
def popc(x):
    acc = 0
    while x > 0:
        acc += x&1
        x >>= 1
    return acc

def fn(x):
    if x == 0:
        return 0
    return fn(x % popc(x)) + 1

n = int(input())
s = input()
o = s.count("1")
x = int(s, 2)
mp = x % (o+1)
mn = 0
if o > 1:
    mn = x % (o-1)
for i in range(n-1, -1, -1):
    if s[n-i-1] == "1":
        if o == 1:
            print(0)
            continue
        print(fn((mn - pow(2, i, o-1)) % (o-1)) + 1)
    else:
        print(fn((mp + pow(2, i, o+1)) % (o+1)) + 1)

Measured memory_bytes: 77504
def main():
    N, K = (int(i) for i in input().split())
    A = []
    B = []
    from bisect import bisect_left
    AB = [[int(i) for i in input().split()] for j in range(N)]
    AB.sort()
    A = [a[0] for a in AB]
    B = [a[1] for a in AB]
    from itertools import accumulate
    B = list(accumulate(B))
    idx = bisect_left(B, K)
    # print(A, B, idx)
    print(A[idx])


if __name__ == '__main__':
    main()


Measured memory_bytes: 68312
#include<iostream>
#include<string>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

string func(long long n){
	string res;
	int size=log(n)/log(8);
	for(int i=size;i>=0;i--){
		char ch=(char)((n/(int)pow(8,i))+'0');
		if(ch=='4')ch='5';
		else if(ch=='5')ch='7';
		else if(ch=='6')ch='8';
		else if(ch=='7')ch='9';
		res+=ch;
		n%=(int)pow(8,i);
	}
	return res;
}
int main(){
	long long n;
	while(cin>>n,n){
		cout<<func(n)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e5+10;
struct point{
	ll x;
	int id;
	bool operator <(const point &rhs) const{
		return x<rhs.x || (x==rhs.x && id<rhs.id);
	}
}a[maxn];
ll sum;
int fa[maxn],sz[maxn];
int main(){
	int n=read();
	REP(i,1,n) a[i].x=readll(),a[i].id=i;
	sort(a+1,a+n+1);
	DREP(i,n,2){
		sz[i]++;
		ll Nxt=a[i].x-n+sz[i]*2;
		int u=lower_bound(a+1,a+n+1,(point){Nxt,0})-a;
		if(a[u].x!=Nxt) return printf("-1\n"),0;
		sz[u]+=sz[i],fa[a[i].id]=a[u].id;
	}
	REP(i,2,n) sum+=sz[i];
	if(sum!=a[1].x) return printf("-1\n"),0;
	REP(i,1,n) if(fa[i]) printf("%d %d\n",fa[i],i);
	return 0;
}


Measured memory_bytes: 3712
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  ll n; cin >> n;
  ll ans=n-1;
  for (ll i=2; i<=sqrt(n); i++){
    if (n%i==0){ans=min(ans,i+n/i-2);}
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int joi2num(char c)
{
if(c == 'J') return 0;
if(c == 'O') return 1;
return 2;
}

int main()
{
int m, n, k;
static char fld[1024][1024];
static int sum[1024][1024][3] = {0};
scanf("%d%d%d", &m, &n, &k);
for(int x = 0; x < m; ++x)
scanf("%s", fld[x]);
for(int i = 0; i < 3; ++i)
sum[0][0][i] = (i == joi2num(fld[0][0]));
for(int x = 1; x < m; ++x) {
for(int i = 0; i < 3; ++i)
sum[x][0][i] = sum[x - 1][0][i] + (i == joi2num(fld[x][0]));
}
for(int y = 1; y < n; ++y) {
for(int i = 0; i < 3; ++i)
sum[0][y][i] = sum[0][y - 1][i] + (i == joi2num(fld[0][y]));
}
for(int x = 1; x < m; ++x) {
for(int y = 1; y < n; ++y) {
for(int i = 0; i < 3; ++i) {
int temp = 0;
temp += sum[x - 1][y][i];
temp += sum[x][y - 1][i];
temp -= sum[x - 1][y - 1][i];
sum[x][y][i] = temp + (i == joi2num(fld[x][y]));
}
}
}
for(int i = 0; i < k; ++i) {
int ax, ay, bx, by;
scanf("%d%d%d%d", &ax, &ay, &bx, &by);
ax -= 1, ay -= 1, bx -= 1, by -= 1;
int ans[3] = {0};
for(int  j = 0; j < 3; ++j) {
ans[j] += sum[bx][by][j];
ans[j] -= ax > 0 ? sum[ax - 1][by][j] : 0;
ans[j] -= ay > 0 ? sum[bx][ay - 1][j] : 0;
ans[j] += ax > 0 && ay > 0 ? sum[ax - 1][ay - 1][j] : 0;
}
printf("%d %d %d\n", ans[0], ans[1], ans[2]);
}
return 0;
}

Measured memory_bytes: 13904