akhauriyash/Code-Regression huggingface dataset:
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]
count = 0
for j in range(N):
    answer = 0
    A = [int(k) for k in input().split()]
    for l in range(M):
        answer += A[l] * B[l]
    if answer + C > 0:
        count += 1
print(count)

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

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

typedef complex<double> P;
const double EPS = 1e-8;

double dot(P a, P b) {return real( conj(a)*b);}
double cross(P a, P b) {return imag( conj(a)*b);}

namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

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 on line
  if (norm(b) < norm(c) - EPS) return -2; // a--b--c on line
  return 0;                               // a--c--b on line (or b == c)
}

int WindingNumber (const vector<P>& g, P p) {
  int wn = 0;
  int n = g.size();
  REP(i, n) {
    int j = (i + 1) % n;
    if( g[i].imag() <= p.imag() + EPS ) {
      if( g[j].imag() > p.imag() + EPS && ccw(g[i], g[j], p) > 0 )
        wn++;
    }
    else {
      if( g[j].imag() <= p.imag() + EPS && ccw(g[i], g[j], p) < 0) {
        wn--;
      }
    }
  }
  return wn;
}

bool IsIntersectSP(P a, P b, P c) {
  return (abs(a-c) + abs(c-b) <= abs(a-b) + EPS);
}

enum {OUT, CROSS, IN};
int ContainGS (const vector<P>& g, P p) {
  REP(i, g.size()) {
    if( IsIntersectSP( g[i], g[(i+1) % g.size()], p) )
      return CROSS;
  }
  int wn = WindingNumber(g, p);
  return wn > 0;
}

vector<P> ConvexHull(vector<P> g) {
  int n = g.size();
  if( n <= 1 ) return g;
  sort(g.begin(), g.end());
  vector<P> res(2 * n);
  int k = 0;
  for(int i = 0; i < n; res[k++] = g[i++] )
    while( k >= 2 && ccw( res[k-2], res[k-1], g[i]) <= 0 ) k--;
  for(int i = n - 2, t = k + 1; i >= 0; res[k++] = g[i--] )
    while( k >= t && ccw( res[k-2], res[k-1], g[i]) <= 0 ) k--;
  res.resize(k-1);
  return res;
}

bool IsIntersectSS(P a1, P a2, P b1, P b2) {
  return ccw(a1,a2,b1) * ccw(a1,a2,b2) <= 0 &&
    ccw(b1,b2,a1) * ccw(b1,b2,a2) <= 0;
}

int IsIntersectGG(const vector<P> &g1, const vector<P>& g2) {
  if( g1.size() <= 1 ) {
    if( ContainGS( g2, g1[0] ) ) return IN;
    return OUT;
  }

  if( g2.size() <= 1 ) {
    if( ContainGS( g1, g2[0] ) ) return IN;
    return OUT;
  }

  REP(i, g1.size()) {
    REP(j, g2.size()) {
      if( IsIntersectSS( g1[i], g1[(i+1) % g1.size()],
                         g2[j], g2[(j+1) % g2.size()]) )
        return CROSS;
    }
  }
  if( ContainGS( g1, g2[0] ) || ContainGS( g2, g1[0] )) {
    return IN;
  }
  return OUT;
}

int main() {
  int A, B;
  while( cin >> A >> B ) {
    if( !(A || B) ) break;
    vector<P> a, b;
    REP(i, A) {
      int x, y; cin >> x >> y;
      a.push_back( P(x,y) );
    }
    REP(i, B) {
      int x, y; cin >> x >> y;
      b.push_back( P(x,y) );      
    }
    a = ConvexHull(a);
    b = ConvexHull(b);

    int t = IsIntersectGG(a,b);
    if( t == OUT ) puts("YES");
    else puts("NO");
  }
}

Measured memory_bytes: 912
s = input()

if s[0] != 'k':
    if s[-7:] == 'keyence':
        print('YES')
    else:
        print('NO')
elif s[0] == 'k' and s[1] != 'e':
    if s[-6:] == 'eyence':
        print('YES')
    else:
        print('NO')
elif s[0:2] == 'ke' and s[2] != 'y':
    if s[-5:] == 'yence':
        print('YES')
    else:
        print('NO')
elif s[0:3] == 'key' and s[3] != 'e':
    if s[-4:] == 'ence':
        print('YES')
    else:
        print('NO')
elif s[0:4] == 'keye' and s[4] != 'n':
    if s[-3:] == 'nce':
        print('YES')
    else:
        print('NO')
elif s[0:5] == 'keyen' and s[5] != 'c':
    if s[-2:] == 'ce':
        print('YES')
    else:
        print('NO')
elif s[0:6] == 'keyenc' and s[5] != 'e':
    if s[-1] == 'e':
        print('YES')
    else:
        print('NO')
elif s[0:7] == 'keyence':
    print('YES')

Measured memory_bytes: 3064
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n,k = map(int,input().split())
  cnt = 1
  while n//k != 0:
    cnt += 1
    n //= k
  print(cnt)
if __name__ == '__main__':
  main()

Measured memory_bytes: 2940
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			int e = sc.nextInt();
			int f = sc.nextInt();
			
			f -= c;
			if(f<0){
				f += 60;
				e--;
			}
			e -= b;
			if(e<0){
				e += 60;
				d--;
			}
			d -= a;
			System.out.println(d + " " + e + " " + f);
		}
	
	}	
}

Measured memory_bytes: 17320
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final int K = sc.nextInt();
			
			int[] arr = new int[N];
			for(int i = 0; i < N; i++) { arr[i] = sc.nextInt(); }
			
			int min = Integer.MAX_VALUE;
			int min_pos = -1;
			
			for(int i = 0; i < N; i++) {
				if(arr[i] < min) { min = arr[i]; min_pos = i; }
			}
			
			int answer = Integer.MAX_VALUE;
			for(int left = Math.max(0, min_pos - (K - 1)); (left + K) <= N; left++) {
				final int right = left + K;
				
				final int left_count  = (left + (K - 2)) / (K - 1);
				final int right_count = ((N - right) + (K - 2)) / (K - 1);
				
				//System.out.println(left_count + " " + right_count);
				answer = Math.min(answer, left_count + right_count + 1);
				//System.out.println("(" + left + ")" + " " + "("  + right + ")");
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 31388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) {
    cin >> v.at(i);
    v.at(i) -= i+1;
  }
  ll res = 0;
  sort(v.begin(), v.end());
  if (n%2) {
    rep(i, n) res += abs(v.at(i)-v.at(n/2));
  } else {
    ll res1 = 0, res2 = 0;
    rep(i, n) {
      res1 += abs(v.at(i)-v.at(n/2-1));
      res2 += abs(v.at(i)-v.at(n/2));
    }
    res = min(res1, res2);
  }
  cout << res << endl;
}

Measured memory_bytes: 1792
primes = []
flag = [0 for i in range(1121)]

for i in range(2, 1121):
    if flag[i] == 0:
        primes.append(i)
    count = 2
    while i * count < 1121:
        flag[i * count] = 1
        count += 1

dp = [[0 for i in range(15)] for j in range(1121)]
dp[0][0] = 1

for p in primes:
    for k in range(13, -1, -1):
        for n in range(1121):
            if n + p < 1121:
                dp[n + p][k + 1] += dp[n][k]
            else:
                break

while True:
    N, K = map(int, input().split())
    if(N | K == 0):
        break
    print(dp[N][K])


Measured memory_bytes: 6128
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

//~ const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> dp(3);
    // dp[i] - the total cost such that we did activity i on the last considered day
    for(int day = 0; day < n; ++day) {
        vector<int> new_dp(3, 0);
        vector<int> c(3);
        for(int i = 0; i < 3; ++i) {
            scanf("%d", &c[i]);
        }
        // int a, b, c - a lot of implementation
        for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                if(i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
    printf("%d\n", max({dp[0], dp[1], dp[2]}));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int x,a,b;

long long int power(int x){
	long long int m=1;
	m=m*x*x*x*x*x;
	return m;
}
int main(){
	cin>>x;
	for(int i=0;i<1000;i++){
		a=power(i);
		for(int j=0;j<1000;j++){
			b=power(j);
			//cout<<a<<" "<<b<<" "<<a+b<<" "<<a-b<<endl;
			if(a-b==x){
				cout<<i<<" "<<j;
				return 0;
			}
			if(a+b==x){
				cout<<i<<" "<<-j;
				return 0;
			}
		}
	}
	
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  
  vector<int> x(n);
  for(int i=0; i<n; i++) {
    if(i%2 ==0)
      x.at(i) = 1;
    else
      x.at(i) = -1;
  }
  
  long answer = 0;
  for(int i=0; i<n; i++) {
    answer += x.at(i) * a.at(i);
  }
  
  for(int i=0; i<n; i++) {
    cout << answer << endl;
    answer = 2 * (a.at(i) - answer / 2);
  }
}

Measured memory_bytes: 2048
/*
*@Author  Chand Vachhani
*/
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define vi          vector<int>
#define vii         vector<vector<int>>
#define pii         pair<int,int>
#define pb          push_back
#define pf          push_front
#define vpii        vector<pair<int,int>>
#define fo(i,l,n)   for(int i{l}; i<n; i++)
#define rf(s)       for(auto &c : s)
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define PI          3.141592653589
#define sz(x)       (int)x.size()
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007  
 
using namespace std;

signed main(){
    tezz
 
    string s;
    cin >> s;
    vi a(s.length()+1);
    int n=s.length();
    a[n]=0;
    for(int i=n-1; i>=0; i--){
        if(s[i]=='<'){
            a[i]=0;
        }
        else{
            a[i]=a[i+1]+1;
        }
    }
    // fo(i,0,n){
    //     cout << s[i] << " ";
    // }
    // cout << endl;
    // fo(i,0,n+1){
    //     cout << a[i] << " ";
    // }
    // cout << endl;
    n=a.size();
    fo(i,0,n-1){
        if(s[i]=='<'){
            if(a[i]>=a[i+1]){
                a[i+1]=a[i]+1;
            }
        }
    }
    
    int sum=0;
     fo(i,0,a.size()){
         sum+=a[i];
     }
     cout << sum << endl;
    //cout << accumulate(all(a),0);
  
    return 0;
}
 
 
 


Measured memory_bytes: 4764
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

ans1 = 0
ans2 = 0

if N<2:
    ans1 = 0
else:
    ans1 = cmb(N,2)

if M<2:
    ans2 = 0
else:
    ans2 = cmb(M,2)

ans = ans1 + ans2
print(ans)

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)

using namespace std;
typedef long long int ll;
const ll INF = 20000000000;

int main(){
    int A,B,Q;
    vector<ll> s,t,st,ts;
    cin>>A>>B>>Q;
    s.resize(A),st.resize(A,INF),t.resize(B,INF),ts.resize(B,INF);
    rep(i,A){cin>>s[i];}
    rep(j,B){cin>>t[j];}
    int i,j;
    j=0;
    rep(i,A){
        while(i<A&&t[j]>s[i])i++;
        if(i==A)break;
        while(j+1<B&&t[j+1]<=s[i])j++;
        st[i]=min(st[i],s[i]-t[j]);
    }
    j=B-1;
    for(int i = A-1;i >= 0;i--){
        while(i>=0&&t[j]<s[i])i--;
        if(i<0)break;
        while(j-1>=0&&t[j-1]>=s[i])j--;
        st[i]=min(st[i],t[j]-s[i]);
    }
    i=0;
    rep(j,B){
        while(j<B&&s[i]>t[j])j++;
        if(j==B)break;
        while(i+1<A&&s[i+1]<=t[j])i++;
        ts[j]=min(ts[j],t[j]-s[i]);
    }
    i=A-1;
    for(int j = B-1;j >= 0;j--){
        while(j>=0&&s[i]<t[j])j--;
        if(j<0)break;
        while(i-1>=0&&s[i-1]>=t[j])i--;
        ts[j]=min(ts[j],s[i]-t[j]);
    }

    rep(qqqq,Q){
        ll x,ans=INF;
        cin>>x;
        int ids = lower_bound(s.begin(),s.end(),x)-s.begin();
        if(ids!=A){
            ans = min(ans,(s[ids]-x)+st[ids]);
        }
        if(ids>0){
            ids--;
            ans = min(ans,(x-s[ids])+st[ids]);
        }
        int idt = lower_bound(t.begin(),t.end(),x)-t.begin();
        if(idt!=B){
            ans = min(ans,(t[idt]-x)+ts[idt]);
        }
        if(idt>0){
            idt--;
            ans = min(ans,(x-t[idt])+ts[idt]);
        }
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l;
  scanf("%d %d", &n, &l);
  vector<string> str(n);
  for(int i = 0; i < n; i++) cin >> str.at(i);
  sort(str.begin(), str.end());
  for(int i = 0; i < n; i++) cout << str.at(i);
  cout << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >>s;
    int a=0,b=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A')a++;
        else b++;
    }
    if(a==0 || b==0)cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;




int main() {
    int N,W;
    cin>>N>>W;
    vector<int>v(N);
    vector<int>w(N);
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }

    vector<vector<int>>dp(N+1,vector<int>(W+1,-1));

    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(dp[i][j-w[i]]!=-1 && j-w[i]>=0){
                dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]);
            }
            if(dp[i+1][j-w[i]]!=-1 && j-w[i]>=0){
                dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
            }
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
        }
    }
    int ans=0;
    for(int i=0;i<=W;i++){
        ans=max(ans,dp[N][i]);
    }
    cout<<ans<<endl;

    // for(int i=0;i<=N;i++){
    //     for(int j=0;j<=W;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }


    return 0;
}



Measured memory_bytes: 6868
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>
#include <map>   
#include <stdio.h>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}



int main() {
	string S;
	int MIN=999,N;
	cin >> S;
	int i;
	REP(i, S.size()-2) {
		N = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0');
		MIN = min(MIN, abs(N - 753));
	}
	cout << MIN << endl;
}

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

using namespace std;

int main()
{
    int n, h, w;
    int ans = 0;

    cin >> n >> h >> w;

    int hs[1001], ws[1001];

    for (int i = 0; i < n; i++) {
        cin >> hs[i] >> ws[i];
        if (hs[i] >= h && ws[i] >= w) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;

int combination(int n, int r){
    if(r==0){
        return 1;
    }else{
        return combination(n,r-1)*(n-r+1)/r;
    }
}

int main(){
    int N;
    cin >> N;
    int P;
    cin >> P;
    
    int A[N];
    int odd=0;
    int even=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i]%=2;
        
        if(A[i]==0){
            even++;
        }else{
            odd++;
        }
    }
    
    
    long long ans=0;
    if(P==0){
        for(int i=0; i*2<=odd; i++){
            ans+=combination(odd,i*2);
        }
    }else{
        for(int i=0; i*2+1<=odd; i++){
            ans+=combination(odd,i*2+1);
        }
    }
    
    
    for(int i=0; i<even; i++){
        ans*=2;
    }
    
    
    cout<<ans<<endl;
    
    
    
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;

int main(void) {
	stack <int>s1;
	stack <pair<int, int> >s2;
	stack <pair<int, int> >s3;
	string m;
	cin >> m;
	int all = 0;
	for (int i = 0; i < m.size(); i++) {
		if (m[i] == '\\') {
			s1.push(i);
		}
		else if (m[i] == '/' && s1.size() !=0 ){
			int j = s1.top(); s1.pop();
			all += i - j;
			int k = i - j;
			while (s2.size()!=0 && j<s2.top().first)
			{
				k += s2.top().second;
				s2.pop();
			}
			s2.push(make_pair(j, k));
		}
	}
	cout << all << endl;
	cout << s2.size();
	while (!s2.empty())
	{
		s3.push(s2.top());
		s2.pop();
	}
	while (!s3.empty())
	{
		cout << " " << s3.top().second;
		s3.pop();
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3280
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#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>
#include<stdio.h>
#include<cstring>
//namespace
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)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース
  累乗和で解く

  ・総和を求める
  ・取り消すところの一つ先を見る
*/
//main.cpp----------------------------
#define max_n 100000

void solve();
int func(int, int);

ll n, m;

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

  solve();

  return 0;
}

void solve() {
  ll cnt = 0;
  if(n==1||m==1) {
    if(n==1&&m==1) cnt += 1;
    else if(n==1) cnt += (m-2);
    else if(m==1) cnt += (n-2);
  }else {
    cnt += (m-2)*(n-2);
  }

  cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int[] result = new int[4];//ac,wa,tle,re
      	for(int i = 0; i < n; i++){
        	String s = sc.next();
          	switch(s){
              case "AC":
                result[0]++;
				break;
              case "WA":
                result[1]++;
                break;
              case "TLE":
                result[2]++;
				break;
              case "RE":
                result[3]++;
                break;              
            }
        }
      	System.out.println("AC x " + result[0]);
      	System.out.println("WA x " + result[1]);
      	System.out.println("TLE x " + result[2]);
      	System.out.println("RE x " + result[3]);
    }
}

Measured memory_bytes: 58784
#include <bits/stdc++.h>
using namespace std;
int arr[1000005];
int dp[1000005];
int N;
int dpa(int curN){
//  int mal = abs(arr[lInd]-arr[curN]);
  if (curN <= 1) return 0;
if (curN == 2) return abs(arr[2]-arr[1]);
  if(dp[curN]!=-1) return dp[curN];

  return dp[curN]= min (dpa(curN-1)+abs(arr[curN]-arr[curN-1]) ,   dpa(curN-2)+abs(arr[curN]-arr[curN-2]));
    }

//   if(dp[curN]!=-1) dp[curN]=min(dp[curN],dp[lInd]+mal);
// else { dpa(curN-1,curN);
//       dpa(curN-2,curN);}
//



int main() {


int aN =N-1;
memset(dp,-1,sizeof(dp));
scanf("%d", &N);
//cout<<N<<"asd\n";
for (size_t i = 0; i < N; i++) {
//cout<<N<<"as43d\n";
cin>> arr[i+1];
//cout<<endl<<arr[i];
}
int mal=0;int curN=1;
cout<< dpa(N)<<endl;

  return 0;
}


Measured memory_bytes: 7936
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)
 
func main() {
	N := nextInt()
	A := make([]int, N)
	B := make([]int, N)
	C := make([]pair, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
		B[i] = nextInt()
		C[i] = pair{A[i] + B[i], i}
	}
	sort.Sort(pairs(C))
	// log.Println(C)
	t := 0
	a := 0
	for i := 0; i < N; i++ {
		if i%2 == 0 {
			t += A[C[i].b]
		} else {
			a += B[C[i].b]
		}
	}
	fmt.Println(t - a)
}
 
var dy = []int{1, 0, -1, 0, 0}
var dx = []int{0, 1, 0, -1, 0}
var intmax = int(1e9)
 
func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}
 
func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
 
type pair struct {
	a, b int
}
 
type pairs []pair
 
func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}
 
func (p pairs) Less(i, j int) bool {
	return p[i].a > p[j].a
}
 
var nextReader func() string
 
func init() {
	nextReader = newScanner()
	log.SetFlags(log.Lshortfile)
}
 
func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
typedef long long ll;
using namespace std;
 
 
int main(){
  int n;
  cin >> n;
  vector<ll> a(n, 0);
  rep(i, n)cin>>a[i];
  vector<ll> c_sum(n+1, 0);
  rep(i, n){
      c_sum[i+1]=(c_sum[i]+a[i])%(1000000007);
  }
  
  ll ans = 0;
  rep(i, n){
     ll sum = (c_sum[n]-c_sum[i+1]);
     if(sum<0)sum+=1000000007;
     
     ans += sum*a[i];
     ans = ans%(1000000007);
 } 
 
 
 cout << ans << endl;
}

Measured memory_bytes: 6344
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int size = S.size();
  if (S[size-1] == 's'){
    cout << S << "es" << endl;
  } else {
    cout << S << "s" << endl;
  }
  return 0;

}


Measured memory_bytes: 3648
//Volume1-0149
import java.util.Scanner;

class Main {

	public static void main(String[] arg){

		int     rl  = 0;
		int[][] eye = new int[2][4];
		double	n;

		Scanner sc = new Scanner(System.in);

		while(sc.hasNext()){
			n = sc.nextDouble();
			if(n >= 1.1){
				eye[rl][0]++;
			} else if(n < 1.1 && n >=0.6){
				eye[rl][1]++;
			} else if(n < 0.6 && n >=0.2){
				eye[rl][2]++;
			} else {
				eye[rl][3]++;
			}
			rl = 1 - rl;
		}

		for(int i=0;i<4;i++){
			System.out.println(eye[0][i] + " " + eye[1][i]);
		}
	}
}

Measured memory_bytes: 20688
def calc(i, j, B1, len_b):
    extra = 0
    d = j - i

    # i < j < k
    k1 = d + j
    if k1 < len_b:
        extra += B1[k1]

    # k < i < j
    k2 = i - d
    if 0 <= k2 and k2 < len_b:
        extra += B1[k2]

    # i < k < j
    s = i + j
    if s % 2 == 0:
        k3 = s // 2
        if k3 < len_b:
            extra += B1[k3]
    return extra

def main():
    N = int(input())
    S = input()
    R, G, B = [], [], []
    num_r, num_g, num_b = 0, 0, 0
    for i in range(N):
        s = S[i]
        if s == 'R':
            R.append(i)
            num_r += 1
        elif s == 'G':
            G.append(i)
            num_g += 1
        elif s == 'B':
            B.append(i)
            num_b += 1
    if len(R) == 0 or len(G) == 0 or len(B) == 0:
        print(0)
        return
    len_b = (B[-1] + 1)
    B1 = [0]*len_b
    for b in B:
        B1[b] = 1
    # print(R, G, B)
    ans = 0
    for i in R:
        for j in G:
            ans += num_b
            if i < j:
                ans -= calc(i, j, B1, len_b)
            else:
                ans -= calc(j, i, B1, len_b)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69176
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <string.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const double pi=acos(-1.0);
int main()
{
  fio;
  int n;
  cin>>n;
  int t = n/1000;
  int d = n % 1000;
  if (d!=0)
  {
    cout<<1000-d<<endl;
  }
  else
  {
    cout<<d<<endl;
  }
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 10005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int sumE,head[MAXN],N;
int c[MAXN],ans;
int p[MAXN],tot;
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int u,int fa) {
    p[u] = c[tot--];
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa) {
            dfs(v,u);
        }
    }
}
void Solve() {
    read(N);
    int a,b;
    for(int i = 1 ; i < N ; ++i) {
        read(a);read(b);add(a,b);add(b,a);
    }
    for(int i = 1 ; i <= N ; ++i) read(c[i]);
    sort(c + 1,c + N + 1);
    for(int i = 1 ; i < N ; ++i) ans += c[i];
    tot = N;
    dfs(1,0);
    out(ans);enter;
    for(int i = 1 ; i <= N ; ++i) {
        out(p[i]);space;
    }
    enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}

Measured memory_bytes: 4128
#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<ll,ll>;

int main() {
    int n;
    char c[200000];
    cin>>n;
    cin>>c;
    int rs=0,ws=0;
    rep(i,n)
    {
      if(c[i]=='R')rs++;
      else ws++;
    }
    int diff =0;
    for(int i=0;i<rs;i++)
    {
      if(c[i]!='R')diff++;
    }
    
    for(int i=rs;i<n;i++)
    {
      if(c[i]!='W')diff++;
    }
    cout<<diff/2<<endl;
    return 0;
}

Measured memory_bytes: 3768
(defparameter n (read))
(defparameter s (coerce (read-line) 'list))

(defun f (lst acc# acc)
  (declare (optimize (speed 3) (debug 0) (safety 0)))
  (cond ((or (endp lst)
             (endp (cdr lst)))
         acc)
        ((and (char= #\. (first lst))
              (char= #\# (second lst)))
         (f (cdr lst) acc# (cons acc# acc)))
        ((char= #\# (car lst))
         (f (cdr lst) (1+ acc#) acc))
        (t (f (cdr lst) acc# acc))))
(defun g (lst acc. acc)
  (declare (optimize (speed 3) (debug 0) (safety 0)))
  (cond ((or (endp lst)
             (endp (cdr lst)))
         acc)
        ((and (char= #\# (first lst))
              (char= #\. (second lst)))
         (g (cdr lst) acc. (cons acc. acc)))
        ((char= #\. (car lst))
         (g (cdr lst) (1+ acc.) acc))
        (t (g (cdr lst) acc. acc))))

(format t "~a" (reduce #'min (cons (count #\# s)
                                   (cons (count #\. s)
                                         (mapcar #'+
                                                 (f s 0 '())
                                                 (nreverse (g (reverse s) 0 '())))))))


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

int main(){

  int a[10000];
  int n,m;
  int k,r,z;

  while(true){
    cin >> n >> m;
    if(!n && !m) break;

    memset(a,-1,sizeof(a));
    k = r = z = 1;

    while(true){

      if(k == n) break;
      if(z > n) z  = 1;
      if(r > m) r = 1;

      if(a[z] == -1&& r == m){
	a[z] = 0;
	r++;
	k++;
      }

      if(a[z]) r++;
      z++;

    }

    for(int i=1;i<=n;i++){
      if(a[i]){
	cout << i << endl;
	break;
      }
    }

  }
}

Measured memory_bytes: 1208
line = ('#':'.':line)

ans :: String -> [Int] -> [String]
ans _ (0:_) = []
ans l (x:y:xs) = 
  ( (take y l) : ans (drop 1 l) (x-1:y:xs) )

printRec :: [[String]] -> IO()
printRec [] = return ()
printRec (s:sx) = do
  mapM_ putStrLn s
  putStrLn ""
  printRec sx

main = do
  c <- getContents
  let t = map (map read) $ map words $ lines c :: [[Int]]
      i = takeWhile (/= [0,0]) t
      o = map (ans line) i
  printRec o

Measured memory_bytes: 4392
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    tmp = 1000
    for i in range(N-1):
        if A[i] < A[i+1]:
            s = tmp//A[i]
            tmp %= A[i]
            tmp += s * A[i+1]
    print(tmp)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0){
		c-=b;
		if(c<=0){
			cout<<"Yes\n";return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No\n";return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);		
		String input = scanner.nextLine();
		scanner.close();
		
		String[] arrStr = (input.split(" ",0));
		
		int A, B, C;
		
		int[] arrInt = new int[3];
		int i = 0;
		for (String str : arrStr) {
			arrInt[i] = Integer.parseInt(str);
			i++;
		}
		
		A = arrInt[0];
		B = arrInt[1];
		C = arrInt[2];
		
		int tmp;
		tmp = A;
		A = B;
		B = tmp;
		tmp = A;
		A = C;
		C = tmp;
		
		System.out.println(A + " " + B + " " + C);
	}
}


Measured memory_bytes: 26984
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		long a = inlong(), b = inlong(), k = inlong();
		if (a+b <= k) out.println("0 0");
		else if (a >= k) out.println((a-k) + " " + b);
		else {
			out.println(0 + " " + (a+b-k));
		}
		

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

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

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}
	
	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    string s;
    int q;
    cin >> s >> q;
    string s2;
    int t, f;
    char c;
    rep(i, q) {
        cin >> t;
        if (t == 1) swap(s, s2);
        else {
            cin >> f >> c;
            if (f == 1) s2 += c;
            else s += c;
        }
    }
    
    reverse(s2.begin(), s2.end());
    s2 += s;
    
    cout << s2 << endl;
}

Measured memory_bytes: 1128
s = list(input())
q = int(input())

reverse_flag = False

top = []
last = []
for i in range(q):
  q_list = list(input().split())
  
  if len(q_list) == 1:
    reverse_flag = not reverse_flag
    
  elif q_list[1] == '1' and (not reverse_flag):
    top.append(q_list[2])
    
  elif q_list[1] == '2' and (not reverse_flag):
    last.append(q_list[2])
    
  elif q_list[1] == '1' and reverse_flag:
    last.append(q_list[2])
    
  elif q_list[1] == '2' and reverse_flag:
    top.append(q_list[2])
    
if reverse_flag:
  print(''.join(reversed(last)) + ''.join(reversed(s)) + ''.join(top))
else:
  print(''.join(reversed(top)) + ''.join(s) + ''.join(last))

Measured memory_bytes: 6944
#include<stdio.h>

int main(){
	
int a,b,op,ans=0;
	

while(1){

scanf("%d %c %df",&a,&op,&b);
	
if(op=='+'){
	ans=a+b;
}
else if(op=='-'){
	ans=a-b;
}
else if(op=='*'){
	ans=a*b;
}

else if(op=='/'){
	ans=a/b;
}
else if(op=='?') {
	break;
}
printf("%d\n",ans);


}
	



return 0;

}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n';

typedef long long ll;

using namespace std;

long calcComb(int a, int b);
long modpow(long a, int p);
long mod = 1000000007;

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

    int MNokori = M;
    long ans = 1;
    for (int i = 2; i * i <= MNokori; i++)
    {
        if (MNokori % i == 0)
        {
            int cnt = 0;
            while (MNokori % i == 0)
            {
                cnt++;
                MNokori /= i;
            }
            ans *= calcComb(N + cnt - 1, N - 1);
            ans %= mod;
        }
    }
    if (MNokori != 1)
    {
        ans *= calcComb(N ,1);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

long calcComb(int a, int b)
{
    if (b > a - b)
        return calcComb(a, a - b);
    long ansMul = 1;
    long ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= (a - i);
        ansDiv *= (i + 1);
        ansMul %= mod;
        ansDiv %= mod;
    }

    long ans = ansMul * modpow(ansDiv, mod - 2) % mod;

    return ans;
}

long modpow(long a, int p)
{
    if (p == 0)
        return 1;
    if (p % 2 == 0)
    {
        int halfP = p / 2;
        long half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

Measured memory_bytes: 256
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  first := nextInt()
  second := nextInt()
  if first > second {
    fmt.Println("a > b");
  }else if first < second {
    fmt.Println("a < b");
  } else if first == second {
    fmt.Println("a == b");
  }
}


func nextInt() (int) {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 1120
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

cnt = 0
for i in range(n):
    if i == n - 1:
        if x == a[i]:
            cnt += 1
    elif x >= a[i]:
        x -= a[i]
        cnt += 1
print(cnt)


Measured memory_bytes: 2940
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    x,y,h=[0]*N,[0]*N,[0]*N
    for i in range(N):
        x[i],y[i],h[i]=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            ch=-1
            queue=deque()
            for X,Y,H in zip(x,y,h):
                queue.append((X,Y,H))
            while queue:
                X,Y,H=queue.popleft()
                if ch==-1:
                    if H>0:
                        ch=H+abs(X-cx)+abs(Y-cy)
                    else:
                        queue.append((X,Y,H))
                elif ch!=-1 and ((ch-abs(X-cx)-abs(Y-cy)>0 and H!=ch-abs(X-cx)-abs(Y-cy)) or (ch-abs(X-cx)-abs(Y-cy)<=0 and H!=0)):
                    break
            else:
                print(cx,cy,ch)
                exit()
                    
        

if __name__ == '__main__':
    main()


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

const ll MOD = 1e9+7;
int a[2000];
int b[2000];
int first[2000];

ll kuri2(ll x,int a)
{
	ll ret=1;
	ll tmp=x;
	while(a>0)
	{
		if(a&1)
		{
			ret*=tmp;
			ret%=MOD;
		}
		tmp=tmp*tmp;
		tmp%=MOD;
		a>>=1;
	}
	if(ret<0)
		ret+=MOD;
	return ret;
}
int main()
{
	int n;
	ll k;
	ll ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	fill(first,first+2000,0);
	for(int i=0;i<n;i++)
	{
		for(int j=i;j<n;j++)
		{
			if(a[i]>a[j])
				first[i]++;
		}
	}
	for(int i=0;i<n;i++)
	{
		ans+=first[i];
		ans%=MOD;
	}
	fill(first,first+2000,0);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(a[i]>a[j])
				first[i]++;
		}
	}
	ans*=k;
	ans%=MOD;
	cerr<<ans<<endl;
	ll cnt=0;
	for(int i=0;i<n;i++)
	{
		cnt+=first[i];
		cnt%=MOD;
	}
	cerr<<cnt<<endl;
	ll kasan=cnt*(k-1);
	kasan%=MOD;
	kasan*=k;
	kasan%=MOD;
	kasan*=kuri2(2,MOD-2);
	kasan%=MOD;
	if(kasan<0)
		kasan+=MOD;
	ans+=kasan;
	ans%=MOD;
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  in3(a, b, c);
  out(min(a * b, c));
  memi;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];

    int ans = 0;
    int min = N + 1;
    rep(i, N) {
        if (min > P[i]) {
            ans++;
            min = P[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 1000000


int ar[2][14];
int main(){
	int N;
	
	while(cin>>N&&N){
		CLR(ar);
		REP(i,N)cin>>ar[0][i];
		int pos=0;
		int cnt=0;
		while(1){
			REP(i,N){
				int sum=0;
				REP(j,N){
					if(ar[pos][j]==ar[pos][i]){
						sum++;
					}
				}
				ar[(pos+1)%2][i]=sum;
			}
			bool ch=false;
			REP(i,N)if(ar[0][i]!=ar[1][i])ch=true;
			if(!ch)break;
			cnt++;pos++;
			pos%=2;
		}
		cout<<cnt<<endl;
		REP(i,N){
			cout<<ar[pos][i];
			if(i!=N-1)cout<<" ";
		}
		cout<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1160
#[test]
fn test_solve() {
    assert_eq!(solve("5\n6 7 9 10 31\n"), "APPROVED\n");
    assert_eq!(solve("3\n28 27 24\n"), "DENIED\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let a: Vec<usize> = (0..n).map(|_| sc.read()).collect();

    for a in a {
        if a & 1 == 0 && a % 3 != 0 && a % 5 != 0 {
            return format!("DENIED\n");
        }
    }

    format!("APPROVED\n")
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.get().chars().collect()
    }
}

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

ll power;

int main() {
  int n;
  cin >> n;
  power = 1;
  rep (i, n) {
    power *= i;
    power %= 1000000007;
  }
  cout << power << endl;
  return 0;
}


Measured memory_bytes: 3524
R,G,B,N = map(int, input().split())

ans = 0
for r in range((N//R)+1):
  for g in range((N//G)+1):
    if (N-R*r-G*g) >= 0 and (N-R*r-G*g) % B == 0:
      ans += 1
print(ans)

Measured memory_bytes: 40940
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned long long;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

string s,t;
int n;

void input() {
    cin >> n >> s >> t;
}

void solve() {
    stringstream ss;
    for(int i = 0; i < n; i++) {
        ss << s.at(i) << t.at(i);
    }
    cout << ss.str() << endl;
}



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


Measured memory_bytes: 256