akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a,const void *b){
  if(*(long long*)a > *(long long*)b) return 1;
  return -1;
}

int main(void){
  int N;
  scanf("%d", &N);

  long long A[N], B;
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    sum += A[i];
  }
  for (int i = 0; i < N; i++) {
    scanf("%lld", &B);
    A[i] -= B;
    sum -= B;
  }
  if(sum < 0){
    printf("-1\n");
    return 0;
  }

  qsort(A, N, sizeof(long long), compare_int);

  int ans = 0;
  sum = 0;
  for (int i = 0; i < N; i++) {
    if(A[i] < 0){
      sum += A[i];
      ans++;
    }
  }
  for (int i = N-1; i >= 0 && sum < 0; i--) {
    sum += A[i];
    ans++;
  }

  printf("%d\n", ans);

  return 0;
}

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

int main() {
  int n;
  cin>>n;
  string s[n];
  for (int i=0; i<n; i++) cin>>s[i];
  int m;
  cin>>m;
  string t[m];
  for (int i=0; i<m; i++) cin>>t[i];

  int ans = 0;
  for (int i=0; i<n; i++) {
    int cnt = 0;
    for (int j=0; j<n; j++) {
      if (s[i] == s[j]) {
        ++cnt;
      }
    }
    for (int j=0; j<m; j++) {
      if (s[i] == t[j]) {
        --cnt;
      }
    }
    ans = max(cnt, ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
use std::io::stdin;

fn main(){
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let n:Vec<i32> = st.trim().split(" ").map(|x| x.parse().unwrap()).collect();
    let x=n[0]+n[1];
    println!("{}", x*(x-1)/2-(n[0]*n[1]));
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define lint long long
#define out(x) cout << (x) << endl

/* ...o(^-^)o... */

lint n,a[3],b;
vector<int> s,res;

int sub(int i){
    int nz=-1; rep(j,3) if(a[j]==b) nz=j;
    if(nz<0) return 2;
    if(nz==s[i]) return 0;
    rep(k,3) if(k==nz) a[k]--; else if(k!=s[i]){ a[k]++; res[i]=k; }
    return 1;
}

bool solve(int i){
    int c=sub(i);
    if(c<2) return c;
    int p=(s[i]+1)%3, q=(s[i]+2)%3;
    int z=-1; rep(j,3) if(a[j]==0) z=j;
    if(b>=3){
        if(z<0||p==z||(z==s[i]&&a[q]!=1)){ a[p]++; a[q]--; res[i]=p; }
        else{ a[p]--; a[q]++; res[i]=q; }
    }
    else if(b==2){
        if(z==s[i]){
            if(i==n-1||s[i+1]==z||s[i+1]==(z+1)%3){ a[p]--; a[q]++; res[i]=q; }
            else { a[p]++; a[q]--; res[i]=p; }
        }else{
            rep(j,3) if(j!=z&&j!=s[i]) a[j]--; a[z]++; res[i]=z;
        }
    }
    else return 0;
    return 1;
}

int main(){
    cin>>n>>a[0]>>a[1]>>a[2];
    rep(i,3) b+=a[i];
    s = vector<int>(n); res = vector<int>(n);
    rep(i,n){ string st; cin>>st; s[i]=(st[0]-'A')?0:((st[1]-'B')?1:2); }

    rep(i,n) if(!solve(i)) { out("No"); return 0; }
    out("Yes");
    rep(i,n) out("ABC"[res[i]]);
}


Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <deque>
#include <math.h>
#include <map>
#include <stack>
#include <list>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <cstring>
#include <climits>
#include <iterator>
#include <cassert>
#include <string>
using namespace std;

template<class T> bool amin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool amax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define REP(i, n) for(int i=0;i<n;i++)
#define REPE(i, n) for(int i=0;i<=n;i++)
#define REP2(i, j, n) for(int i=j;i<n;i++)
#define REP2E(i, j, n) for(int i=j;i<=n;i++)
#define REP3(i, j, n, s) for(int i=j;i<n;i+=s)
#define REP3E(i, j, n, s) for(int i=j;i<=n;i+=s)
#define RREP(i, n) for(int i=n;i>=0;i--)
#define RREP2(i, n, j) for(int i=n;i>=j;i--)
#define MSI unordered_map<string, int>
#define MII unordered_map<int, int>
#define VI vector<int>
#define VL vector<long>
#define PI pair<int, int>
#define VPI vector<PI>
#define VVI vector<VI>
#define VC vector<char>
#define VVL vector<VL>
#define VVPI vector<VPI>
#define MSVI unordered_map<string, VI>
#define MII unordered_map<int, int>
#define TCASES int t; cin>>t; while(t-- > 0)
#define MOD 1000000007


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef LOCAL_TEST
	freopen("input.txt","r",stdin);
	#endif
	int a, b; cin >> a >> b;
	long c = a * pow(10, (floor(log10(b))+1))+b;
	// cout << c << endl;
	long d = sqrt(c);
	cout << (((d*d)==c) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 640
import sys
INPUT = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 9)


def main():
    S = INPUT()

    if S == 'Sunny': print('Cloudy')
    elif S == 'Cloudy': print('Rainy')
    else: print('Sunny')


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int mem[200010][2];
char s[200010];
int dp(int x, int cl){
    if(x==-1)
        return 0;
    if(mem[x][cl]!=-1)
        return mem[x][cl];
    int res;
    if(s[x]=='#'){
        if(cl==0){
            res=1+dp(x-1, 0);
        }
        else{
            res=dp(x-1, 1);
        }
    }
    else{
        if(cl==0){
            res=dp(x-1, 0);
        }
        else{
            res=min(1+dp(x-1, 1), dp(x-1, 0));
        }
    }
    mem[x][cl]=res;
    return res;
}
int main(){
    int n;
    while(cin>>n){
        ll ans=0;
        scanf("%s",s);
        memset(mem, -1, sizeof mem);
        ans=dp(n-1, 1);
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long int
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")

#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 200005;

int n;

int wi[N], ne[N];

ll a[N], b[N];

ll ans;

set < int > S;

bool check (int x){
    if (b[x] <= a[x])
        return 0;
    if (b[x] >= b[wi[x]] && b[x] >= b[ne[x]])
        return 1;
    return 0;
}

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++){
        ne[i] = i % n + 1;
        wi[ne[i]] = i;
    }
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        cin >> b[i];
    for (int i = 1; i <= n; i++){
        if (check (i))
            S.insert (i);
    }
    while (S.size() > 0){
        auto I = S.begin();
        int k = (*I);
        S.erase (I);
        if (check (k) == 0)
            continue;
        ll x = b[wi[k]] + b[ne[k]];
        if (a[k] < x){
            ans += b[k] / x;
            b[k] %= x;
            if (b[k] < a[k]){
                cout << -1 << endl;
                return 0;
            }
            if (check (wi[k]))
                S.insert (wi[k]);
            if (check (ne[k]))
                S.insert (ne[k]);
            continue;
        }
        ll y = b[k] - a[k];
        if (y % x != 0){
            cout << -1 << endl;
            return 0;
        }
        y /= x;
        ans += y;
        b[k] = a[k];
        if (check (wi[k]))
            S.insert (wi[k]);
        if (check (ne[k]))
            S.insert (ne[k]);
    }
    for (int i = 1; i <= n; i++)
    if (a[i] != b[i]){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int n;
  cin >> n;
  int sum = 0;
  rep(i, 1, n+1) {
    sum += i;
  }
  cout << sum << "\n";
}


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

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

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int UI;

using namespace std;

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

    string s;
    cin >> s;

    s[5] = ' ';
    s[13] = ' ';

    cout << s << endl;

    return 0;
}

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

#define ub        upper_bound            // first element >  val(itr)
#define lb        lower_bound            // first element >= val(itr)

#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define bitcount(a) __builtin_popcount(a) // count set bits
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

typedef long long int ll;
const ll MOD = 1e9+7;

template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
/*
inline ll mod(ll x,ll n) {if (x < n) return x; if (x >= n) return x - n;}
string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M)  { return mod(( mod(a,M ) + mod(b,M )),M);     }
ll sub(ll a, ll b,ll M) { return mod((mod(a,M ) + M - mod(b,M )),M);   }
ll mult(ll a,ll b,ll M) { return  mod(( mod(a,M)*mod(b,M) ),M) ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

  
               /* -------------------------------Main Code------------------------------- */						
int  main(){
    FAST
    int n;cin>>n;
    unordered_map<string,int> mt;
    ll ans = 0;
    for(int i=0;i<n;i++){
        string s;cin>>s;
        sort(all(s));
        mt[s]++;
        ans += (mt[s]-1);
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 10660
#include <iostream>
using namespace std;
int main() {
  int N, L;
  cin >> N >> L;
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += L + i - 1;
  }
  if (L == 0 || L + N +1== 0) {
    cout << ans << endl;
  } else if (L < 0 && L + N > 0) {
    cout << ans << endl;
  } else if (L < 0) {
    ans -= L + N - 1;
    cout << ans << endl;
  } else if (L > 0) {
    ans -= L;
    cout << ans << endl;
  }
    return 0;
}

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

int main() {
	// your code goes here
    int k, x;
    cin >> k >> x;
    int s = x - k + 1;
    int e = k + x - 1;
    for(int i = s; i <= e; i++){
        cout << i << " ";
    }
    
    cout << endl;
}


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

typedef long long ll;
using namespace std;

int main(){
  int n,ans=0;
  cin >> n;
  int k[2*n];
  for(int i=0;i<2*n;i++){
  	cin >> k[i];
  }
  sort(k,k+2*n);
  for(int i=0;i<2*n;i+=2){
  	ans+=k[i];
  }
  cout << ans << endl;


  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <limits.h>
#define ll long long
#define xx first
#define yy second

using namespace std;

const int N = 100000 + 5;
int info[N], f[N], n;

int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf ("%d", &info[i]);
	int ans = 0;
	for (int i = n - 1; i >= 1; --i)
		f[i] = info[i] >= info[i + 1] ? f[i + 1] + 1 : 0, ans = max (ans, f[i]);
	printf ("%d\n", ans);
	/*int a, b;
	scanf ("%d%d", &a, &b);
	a--, b--;
	printf ("%d\n", (b - 1) / a + 1);*/
	return 0;
}

Measured memory_bytes: 896
n = int(input())
a_list = list(map(int, input().split()))
a_list = reversed(sorted(a_list))
sum = 0
for index, a in enumerate(a_list):
  sum += pow(0.5, index+1) * a
  if index == n-1:
    sum += pow(0.5, index+1) * a

print(sum)  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define lld         long long int
#define llf         long double
#define pb          push_back
#define mp          make_pair
#define IN          insert
#define loopN(n)    for(lld i=0;i<n;i++)
#define loop(p,n)   for(lld i=p;i<=n;i++)
#define rloop(p,n)  for(lld i=n;i>=p;i--)
#define loop2(p,n)  for(lld j=p;j<=n;j++)
#define all(v)      v.begin(),v.end()
#define F1          first
#define F2          second
#define INF         2e18
#define FILE        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define PI          2*acos(0.0);
#define ISO         ios::sync_with_stdio(false);cin.tie(0)
#define mod         100000007
#define mem(a,b)    memset(a,b,sizeof(a))
using namespace std;

int main()
{
    ISO;
    lld n;
    cin>>n;
    lld a[n];
    map<lld,lld>z;
    loopN(n)
    {
        cin>>a[i];
        z.IN({a[i],0});
    }
    loopN(n)
    {
        z[a[i]]++;
    }
    lld ans=0;
    for(auto it:z)
    {
        if(it.F1!=it.F2)
        {
            if(it.F2>it.F1)
            {
                ans+=it.F2-it.F1;
            }
            else
            {
                ans+=it.F2;
            }
        }
    }
    cout<<ans<<endl;





    return 0;
}


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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


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




/* main */




signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, l; cin >> n >> l;

    vi arr; rep(i,0,n) arr.push_back(input());

    rep(i,0,n - 1){
        if(arr[i] + arr[i + 1] >= l){
            print("Possible");
            rep(j,1,i + 1) print(j);
            revrep(j, n - 1, i) print(j);
            return 0;
        }
    }

    print("Impossible");


    
    

    
    






    




    

    





    

   




    

    

    



    
    



    







    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 1780
H,W,K = map(int,input().split())
C = [input() for i in range(H)]

ans = 0
for i in range(2**H):
    for j in range(2**W):
        tmp = 0
        for ii in range(H):
            for jj in range(W):
                if C[ii][jj] == '#' and (i >> ii) & 1 == 0 and (j >> jj) & 1 == 0:
                    tmp += 1
        if tmp == K:
            ans += 1
            
print(ans)    

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n[10];
	for(int p=0;p<10;p++){
		cin>>n[p];
	}
	sort(n,n+10);
	 cout<<n[9]<<endl;
	 cout<<n[8]<<endl;
	 cout<<n[7]<<endl;
}


Measured memory_bytes: 3160
#include<iostream>
using namespace std;
const int maxn=1e5+10;
int h[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	int t=0,ans=0;
	for(int i=1;i<n;i++)
	{
		if(h[i]<=h[i-1])
		{
			t++;
			ans=max(ans,t);
		}
		else t=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <functional>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;

int main() {
  int n; cin>>n;
  ll a[n];
  for(int i=0;i<n;i++) {
    cin>>a[i];
  }
  ll an=0;
  for(int i=0;i<n;i++) {
    an+=a[i]/2;
    a[i]%=2;
    if (i!=n-1&&a[i]&&a[i+1]) a[i]--, a[i+1]--, an++;
  }
  cout<<an<<endl;
}

Measured memory_bytes: 1024
# 087
def getInt(): return int(input())
A = getInt()
B = getInt()
C = getInt()
X = getInt()
cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X==i*500+j*100+k*50: cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
#define ll long long
#define M 1000000007
using namespace std;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    ll n,count=0;
    cin>>n;
    ll arr[n+1]={ 0 };
    map<ll,ll>jp1,jp2;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
        if(jp1.find(i+arr[i])==jp1.end())
        {
            jp1[i+arr[i]]=1;
        }else
        {
             jp1[i+arr[i]]++;
        }
        if(jp2.find(i-arr[i])==jp2.end())
        {
            jp2[i-arr[i]]=1;
        }else
        {
             jp2[i-arr[i]]++;
        }
    }
    for(auto it=jp1.begin();it!=jp1.end();it++)
    {
        if(jp2.find(it->first)!=jp2.end())
        {
            count+=it->second*jp2[it->first];
        }
    }
    cout<<count;
     

}

Measured memory_bytes: 28268
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define MAXN 100001
#define MOD -1
#define INF 1e9+5
#define FastCin	ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

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

void swap(int *a, int *b){
    int t = *a;
    *a = *b; *b = t;
}

int ativis[3][MAXN];
int maxis[3][MAXN];
int n;

int maxW(int pos, int act){
    if(maxis[act][pos] != INF) return maxis[act][pos];
    if(pos == n-1){
        return ativis[act][pos];
    }
    int mov1 = ativis[act][pos] + maxW(pos+1, (act+1)%3);
    int mov2 = ativis[act][pos] + maxW(pos+1, (act+2)%3);
    return maxis[act][pos] = max(mov1,mov2);
}

int main(){    
    scanf("%d", &n);
    for(int i = 0; i < 3;i++){
        for(int j = 0; j < MAXN; j++){
            maxis[i][j] = INF;
        }
    }
    for(int i = 0; i < n; i++){
        scanf("%d %d %d", &ativis[0][i], &ativis[1][i], &ativis[2][i]);
    }
    int a = maxW(0,0);
    int b = maxW(0,1);
    int c = maxW(0,2);
    cout << max(a,max(b,c)) << endl;
    return 0;
}



Measured memory_bytes: 8832
import java.io.BufferedReader;

import java.lang.Math;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
import java.io.*;

public class Main{
	static int[] v;
	static int[] w;
	static long dp[][];
	public static void main (String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int c = sc.nextInt();
		dp = new long[n+1][c+1];
		for(int i = 0 ; i < n+1 ; i ++)
			for(int j = 0 ; j < c+1 ; j ++)
				dp[i][j]--;

		v = new int[n]; w = new int[n];
		for(int i = 0 ; i < n ; i++) {
			w[i] = sc.nextInt();v[i]=sc.nextInt();
		}
			pw.println((long)dp(0,c,n));
			pw.close();
		}
	static long dp(int idx , int c , int n) {
		if(idx == n)
			return 0;
		if(dp[idx][c]!=-1)
			return dp[idx][c];
		if(c<w[idx])
			return dp[idx][c] = (long)dp(idx+1,c,n);
		long take = v[idx]+ dp(idx+1,c-w[idx],n);
		long leave = dp(idx+1 , c , n);
		return dp[idx][c] = Math.max(take,leave);
	}
		
	}

	


	
	
	
	
	 class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}
	 }
	

Measured memory_bytes: 131748
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    vector<int> a(n);

    for (auto &&i : a)
    {
        cin >> i;
    }

    sort(a.rbegin(), a.rend());

    ll ans = a[0];

    int idx = 1;

    for (int i = 2; i < n; i++)
    {
        ans += a[idx];
        if (i % 2 == 1)
            idx++;
    }
    cout << ans << "\n";
    return 0;

    cout << ans << endl;
}


Measured memory_bytes: 4024
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
k = len(bin(np.max(a)))-2

b = []
c = [0] * k
for aa in a:
    d = bin(aa)[2:]
    e = k-len(d)
    for i in range(len(d)):
        if d[i] == '1':
            c[e+i] += 1

xo = int(''.join(['1' if c[i] % 2 == 1 else '0' for i in range(k)]), 2)

print(' '.join(map(str, (a ^ xo))))


Measured memory_bytes: 49952
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N, K; cin >> N >> K;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int h; cin >> h;
		if (h >= K)ans++;
	}
	cout << ans << endl;
	return 0;
}

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

const string YES = "yes";
const string NO = "no";

void solve(std::string S){
    vector<ll> record(26,0);
    for(ll i=0; i< S.length(); i++){
        record[S.at(i)-'a']++;
    }
    for(ll i=0; i< 26; i++){
        if(record[i]>1){
            cout << NO << endl;
            return;
        }
    }
    cout << YES << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cctype>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
 
using namespace std;
const int N=17,M=40000,INF=1000000000;
int n,m,f[M],q[M],tot,dis[N][N],u,v,c,g[N][M];
 
int getint()
{
	char ch;
	int f=1;
	while(!isdigit(ch=getchar())) if(ch=='-') f=-1;
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x*f;
}
 
int query1(int x)
{
	int rt=0;
	rep(i,1,n)
		if(x&(1<<i-1))
			rep(j,i+1,n)
				if(x&(1<<j-1) && dis[i][j]!=INF)
					rt+=dis[i][j];
	return rt;
}
 
int query2(int x,int y)
{
	int rt=0,maxn=0;
	rep(i,1,n)
		if(x&(1<<i-1))
			maxn=max(maxn,g[i][y]);
	return maxn;
}

int main()
{
	n=getint(),m=getint();
	rep(i,1,n) rep(j,1,n) dis[i][j]=i==j?0:INF;
	rep(i,1,m) u=getint(),v=getint(),dis[u][v]=dis[v][u]=c=getint(),tot+=c;
 	rep(i,1,n)
		rep(j,0,(1<<n)-1)
			rep(k,1,n)
				if(dis[i][k]!=INF && j&(1<<k-1))
					g[i][j]+=dis[i][k];
	rep(i,1,(1<<n)-1) f[i]=-INF;
	f[1]=0;
	rep(i,1,(1<<n)-2)
		if(f[i]!=-INF)
		{
			rep(j,1,n)
				if(!(i&(1<<j-1)))
				{
					int maxn=0;
					rep(k,1,n)
						if(i&(1<<k-1) && dis[j][k]!=INF)
							maxn=max(maxn,dis[j][k]);
					if(maxn) f[i|(1<<j-1)]=max(f[i|(1<<j-1)],f[i]+maxn);
				}
		}
	
	rep(i,1,(1<<n)-1)
	{
		if(!(i&1) || !(i&(1<<n-1))) f[i]=-INF;
		q[i]=query1(i);
	}
	
	rep(i,1,(1<<n)-1)
		if(f[i]!=-INF)
			for(int j=((1<<n)-1)^i; j; j=(j-1)&(((1<<n)-1)^i))
				f[i|j]=max(f[i|j],f[i]+q[j]+query2(i,j));
 
	printf("%d\n",tot-f[(1<<n)-1]);
	return 0;
}

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

int main() {
    int a,b;
    int ans = -1;
    cin >> a >> b;
    for(int i = b*10; i < (b+1)*10; i++){
        if((int)(i * 0.08) == a){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const ll MOD = 1e9 + 7;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int k; scanf("%d", &k);
	ll ans = 0;
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			for (int c = 1; c <= k; c++) {
				ans += __gcd(a, __gcd(b, c));
			}
		}
	}
	cout << ans << endl;
}


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

int a[4][104]={0},n;
int dp[4][104]={0};
int rec(int i, int j)
{
    if(a[i][j] == 0)
        return a[i][j];
    return  max( rec(i - 1,j), rec(i,j - 1)) + a[i][j];
}


int main()
{
    cin >> n;
    for(int i = 1; i <= 2; i++)
        for(int j = 1; j <= n; j++)
            cin >> a[i][j];
    
    printf("%d",rec(2,n));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
const ull MOD = 998244353;
#ifdef LOCAL
#include "../../pp.hpp"
#define debug pp::debug
#else
#define debug(args...)
#endif

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

    int n; cin >> n;
    vvi happ(3, vi(n));
    for (int i = 0; i < n; ++i) cin >> happ[0][i] >> happ[1][i] >> happ[2][i];
    vvi dp(3, vi(n));
    dp[0][0] = happ[0][0];
    dp[1][0] = happ[1][0];
    dp[2][0] = happ[2][0];
    for (int i = 1; i < n; ++i) {
        for (int k = 0; k < 3; ++k) {
            dp[k][i] = happ[k][i] + max(dp[(k+1)%3][i-1], dp[(k+2)%3][i-1]);
        }
    }

    cout << max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1])) << '\n';
}


Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let mut h = get!([usize]);

    for i in (0..n-1).rev() {
        if h[i] > h[i+1] {
            h[i] -= 1;
        }
    }

    for i in 0..n-1 {
        if h[i] > h[i+1] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

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

  vector<pair<int, int>> b;
  for (int i = 0; i < n; i++){
    int a;
    cin >> a;
    int flag = 0;
    for (int j = 0; j < b.size(); j++){
      if (a == b.at(j).first){
        flag = 1;
        b.at(j).second++;
      }
    }
    if (!flag){
      if (b.size() < 3){
        b.push_back(make_pair(a, 1));
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
  }

  bool psb = false;
  if (b.size() == 3){
    int c = b.at(0).first ^ b.at(1).first ^ b.at(2).first;
    if (c == 0 && b.at(0).second * 3 == n && b.at(1).second * 3 == n){
      psb = true;
    }
  }
  if (b.size() == 2){
    if ((b.at(0).second * 3 == n && b.at(0).first == 0)
    || (b.at(1).second * 3 == n && b.at(1).first == 0)){
      psb = true;
    }
  }
  if (b.size() == 1){
    if (b.at(0).first == 0) psb = true;
  }

  cout << (psb ? "Yes" : "No") << endl;
}

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

int main()
{
 int n,ans=0;
  cin>>n;
  ll a[n];
  for(auto& i:a) cin>>i;
  sort(a,a+n);
  
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
       for(int k=j+1;k<n;k++)
       { if(a[i]!=a[j] && a[j]!=a[k])
       { if(a[i]+a[j]>a[k]) ans++;
       }
       }
  cout<<ans;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200000+10,maxlen=maxn*4,mo=924844033,GG=5;
int size[maxn],h[maxn],go[maxn*2],nxt[maxn*2];
int w[maxlen],a[maxlen],b[maxlen],tt[maxlen],c[maxlen],rev[maxlen],fac[maxn],inv[maxn];
int i,j,k,l,t,n,m,tot,len,ans,ni;
double ce;

void add(int x,int y)
{
    go[++tot]=y;
    nxt[tot]=h[x];
    h[x]=tot;
}
int qsm(int x,int y){
    if (!y) return 1;
    int t=qsm(x,y/2);
    t=(ll)t*t%mo;
    if (y%2) t=(ll)t*x%mo;
    return t;
}
void dfs(int x,int y){
    a[n]++;
    int t=h[x];
    size[x]=1;
    while (t){
        if (go[t]!=y){
            dfs(go[t],x);
            a[size[go[t]]]--;
            size[x]+=size[go[t]];
        }
        t=nxt[t];
    }
    a[n-size[x]]--;
}

void prepare()
{
  w[0]=1; w[1]=qsm(GG,(mo-1)/len);
  for(int i=2; i<=len; i++) w[i]=(ll)w[i-1]*w[1]%mo;
  for(int i=0; i<len; i++)
	{
    int p=0;
    for(int j=0,tp=i;j<ce;j++,tp/=2) p=(p<<1)+(tp%2);
    rev[i]=p;
  }
  ni=qsm(len,mo-2);
}

void DFT(int *a,int sig)
{
  for(int i=0; i<len; i++) tt[rev[i]]=a[i];
  for(int m=2;m<=len;m*=2)
	{
    int half=m/2,bei=len/m;
    for(int i=0; i<half; i++)
		{
      int wi=sig>0?w[i*bei]:w[len-i*bei];
      for(int j=i;j<len;j+=m)
			{
        int u=tt[j],v=(ll)tt[j+half]*wi%mo;
        tt[j]=(u+v)%mo;
        tt[j+half]=(u-v)%mo;
      }
    }
  }
  if (sig==-1)
    for(int i=0; i<len; i++) tt[i]=(ll)tt[i]*ni%mo;
  for(int i=0; i<len; i++) a[i]=tt[i];
}

void NTT()
{
  DFT(a,1); DFT(b,1);
  for(int i=0; i<len; i++) a[i]=(ll)a[i]*b[i]%mo;
  DFT(a,-1);
  for(int i=0; i<len; i++) c[i]=a[i];
}

int main()
{
  scanf("%d",&n);
  for(int i=1; i<n; i++)
	{
    scanf("%d%d",&j,&k); add(j,k); add(k,j);
  }
  dfs(1,0); fac[0]=1;
  for(int i=1; i<=n; i++) fac[i]=(ll)fac[i-1]*i%mo;
  inv[n]=qsm(fac[n],mo-2);
  for(int i=n-1; i>=0; i--) inv[i]=(ll)inv[i+1]*(i+1)%mo;
  for(int i=0; i<=n; i++) a[i]=(ll)a[i]*fac[i]%mo;
  for(int i=0; i<=n; i++) b[i]=inv[i];
  reverse(b,b+n+1);
  len=1;
  while (len<=2*n) len*=2;
  ce=log(len)/log(2);
  prepare(); NTT();
  for(int i=1; i<=n; i++)
	{
    ans=(ll)inv[i]*c[n+i]%mo;
    (ans+=mo)%=mo;
    printf("%d\n",ans);
  }
  return 0;
}


Measured memory_bytes: 35072
#include <stdio.h>

#define MAX 10000
#define NIL -1

struct Node {int p, l, r;};
struct Node T[MAX];
int n;

/* 先行順巡回 */
void preParse(int u) {
  if(u == NIL) return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/* 中間順巡回 */
void inParse(int u) {
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

/* 後方順巡回 */
void postParse(int u) {
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(void) {
  int i, v, l, r, root;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    T[i].p = NIL;
  }
  
  for(i=0; i<n; i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }
  
  for(i=0;i<n;i++) if(T[i].p == NIL) root = i;
  
  printf("Preorder\n");
  preParse(root);
  printf("\n");

  printf("Inorder\n");
  inParse(root);
  printf("\n");

  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

/*
9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1
*/



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

using namespace std;

#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define UNIQUE(v) do{ (v).erase( unique(begin(v), end(v)), end(v) ); } while(0)

namespace std {
	template<class S, class T> pair<S, T> operator + (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first + b.first, a.second + b.second);}
	template<class S, class T> pair<S, T> operator - (const pair<S, T> &a, const pair<S, T> &b) {return mp<S, T>(a.first - b.first, a.second - b.second);}
	template<class S, class T> pair<S, T>& operator += (pair<S, T> &a, const pair<S, T> &other) {return a = a + other;}
	template<class S, class T> pair<S, T>& operator -= (pair<S, T> &a, const pair<S, T> &other) {return a = a - other;}
	template<class S, class T> ostream& operator << (ostream& ost, pair<S, T> p) {ost << "(" << p.first << ", " << p.second << ")";return ost;}
	template<class T> ostream& print_iterable_container(ostream& ost, T& container) {
		for (auto&& iter = begin(container); iter != end(container); ++iter) ost << (iter == begin(container) ? " [ " : ", ") << (*iter);
		return ost << " ]";
	}
#	define APPLY_PRINT_ITERABLE_CONTAINER(container_type)\
	template<class T> ostream& operator << (ostream& ost, container_type<T>& container) {\
		return print_iterable_container(ost, container);\
	}
	APPLY_PRINT_ITERABLE_CONTAINER(vector);
	APPLY_PRINT_ITERABLE_CONTAINER(list);
	APPLY_PRINT_ITERABLE_CONTAINER(deque);
}

template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

using ld = long double;

template<class T> using VV = vector<vector<T> >;
template<class T> using maxPQ = priority_queue<T>;
template<class T> using minPQ = priority_queue<T, vector<T>, greater<T> >;
template<class T, class U> using uomap = unordered_map<T, U>;
template<class T> using uoset = unordered_set<T>;

const ll INF = 1001001001;
const ll INFll = (ll)INF * INF;
const ll MOD = 1000000007;
const ll MOD_FFT = 998244353;
const ld EPS = 1e-15;

//function<void(int,int)> tensi_no_3p=[&](int v,int d){
//};

int main() {
	ios_base::sync_with_stdio(false);
	int N; cin >> N;
	vi A(N + 2);
	repr(i, 1, N) cin >> A[i];
	ll ans = 0;
	repr(i, 1, N + 1) ans += abs(A[i] - A[i - 1]);
	repr(i, 1, N) {
		ll a = A[i] - A[i - 1];
		ll b = A[i + 1] - A[i];
		if (a * b > 0) {
			cout << ans << endl;
		}
		else {
			cout << ans - 2 * min(abs(a), abs(b)) << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<set>

typedef std::pair<int, int> P;

int main(){

	int n, m;
	while (std::cin >> n, n){

		P kyori[200];
		std::set<P>stars;

		P Gmin(10000000, 10000000);
		P def;
		for (int i = 0; i < n; i++){
			P p;
			std::cin >> p.first >> p.second;

			Gmin.first = (Gmin.first, p.first);
			Gmin.second = (Gmin.second, p.second);

			if (i == 0){
				def = p;
				kyori[0] = P(0, 0);
			}
			else{
				kyori[i].first = p.first - def.first;
				kyori[i].second = p.second - def.second;
			}
		}

		std::cin >> m;
		for (int i = 0; i < m; i++){
			P p;
			std::cin >> p.first >> p.second;
			stars.insert(p);
		}

		std::set<P>::iterator it = stars.begin();
		while (it != stars.end()){
			bool flg = true;
			int x = it->first, y = it->second;
			P min(10000000, 10000000);
			for (int i = 0; i < n; i++){
				int nx = x + kyori[i].first, ny = y + kyori[i].second;

				min.first = (min.first, nx);
				min.second = (min.second, ny);

				if (stars.find(P(nx, ny)) == stars.end())flg = false;
			}
			if (flg){
				std::cout << min.first - Gmin.first << " " << min.second - Gmin.second << std::endl;
			}
			it++;
		}

	}

	return 0;
}

Measured memory_bytes: 1240
N, M, X, Y = [int(i) for i in input().split(' ')]
x = [int(i) for i in input().split(' ')] + [X]
y = [int(i) for i in input().split(' ')] + [Y]

if max(x) < min(y):
    print('No War')
else:
    print('War')


Measured memory_bytes: 2940
n,m=map(int,input().split())
k=[]
s=[]
for i in range(m):
    a=list(map(int,input().split()))
    k.append(a[0])
    s.append(a[1:])
ans=0
p=list(map(int,input().split()))

for i in range(2**n):
    num=str(bin(i))[2:]
    num=num.zfill(n)
    num=num[::-1]
    #print(num)
    judge=1
    for j in range(m):
        cnt=0
        #print(num)
        for q in range(len(s[j])):
            if num[s[j][q]-1]=='1':
                cnt+=1
        if cnt%2!=p[j]:
            judge=0
            break
    if judge:
        ans+=1
print(ans)

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

using namespace std;
const int maxn = 110;
const int maxk = 1e5+10;

int n, k;
int niz[maxn];
int dp[maxk];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", niz+i);

    for (int i = 1; i <= k; i++)
        for (int j = 0; j < n; j++)
            if (niz[j] <= i) dp[i] = max(dp[i], (dp[i - niz[j]] + 1) % 2);

    if (dp[k] == 1) printf("First\n");
    else printf("Second\n");
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	string S;
	llong K;
	cin >> S >> K;

	llong ret = inf;
	for (int j = 0; j < 2; ++j) {
		reverse(ALL(S));
		llong res = 0;
		string mask = S, nmaskS = S;
		llong mres = 0, nmres = 0;
		for (int i = 1; mask[i]; ++i) {
			if (mask[i] == mask[i-1]) {
				++mres;
				mask[i] = '-';
			}
		}
		if (nmaskS[0] != mask[mask.size()-1]) {
			res = mres*K;
		} else {
			nmaskS[0] = '-';
			++nmres;
			for (int i = 1; nmaskS[i]; ++i) {
				if (nmaskS[i] == nmaskS[i-1]) {
					++nmres;
					nmaskS[i] = '-';
				}
			}

			if (S[0] == nmaskS[nmaskS.size()-1]) {
				res = mres + nmres*(K-1);
			} else {
				res = (mres + nmres)*(K/2) + mres*(K&1);
			}
		}
		ret = min(ret, res);
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> cnta(n+1, 0);
    vector<int> cntb(n+1, 0);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnta[a[i]]++;
    }
    for(int i = 0; i < n; i++)
    {
        cin >> b[i];
        cntb[b[i]]++;
    }
    for(int i = 0; i <= n; i++)
    {
        if(cnta[i] + cntb[i] > n)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 1; i <= n; i++)
    {
        cnta[i] += cnta[i-1];
        cntb[i] += cntb[i-1];
    }
    cout << "Yes" << endl;
    int x = 0;
    for(int i = 1; i <= n; i++)
    {
        x = max(x, cnta[i] - cntb[i-1]);
    }
    for(int i = 0; i < n; i++)
    {
        cout << b[(i-x+n)%n] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 6392
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,m,q;
    cin>>n>>m>>q;
    vector<string> s(n);
    cin>>s;
    vector<vector<int>> node(n,vector<int>(m,0)), edge_y(n,vector<int>(m,0)), edge_x(n,vector<int>(m,0));
    REP(i,n) {
        REP(j,m) {
            if(s[i][j]=='1') {
                node[i][j]++;
            }
            if(j>0 && s[i][j-1]=='1' && s[i][j]=='1') {
                edge_x[i][j]++;
            }
            if(i>0 && s[i-1][j]=='1' && s[i][j]=='1') {
                edge_y[i][j]++;
            }
        }
    }
    REP(i,n) {
        REPF(j,1,m) {
            node[i][j]+=node[i][j-1];
            edge_x[i][j]+=edge_x[i][j-1];
            edge_y[i][j]+=edge_y[i][j-1];
        }
    }
    REP(j,m) {
        REPF(i,1,n) {
            node[i][j]+=node[i-1][j];
            edge_x[i][j]+=edge_x[i-1][j];
            edge_y[i][j]+=edge_y[i-1][j];
        }
    }
    while(q--) {
        int x1,y1,x2,y2;
        cin>>y1>>x1>>y2>>x2;
        x1--,y1--,x2--,y2--;
        int num_node=node[y2][x2];
        if(y1>0) num_node-=node[y1-1][x2];
        if(x1>0) num_node-=node[y2][x1-1];
        if(x1>0 && y1>0) num_node+=node[y1-1][x1-1];
        int num_edge=edge_x[y2][x2]-edge_x[y2][x1];
        if(y1>0) num_edge-=edge_x[y1-1][x2]-edge_x[y1-1][x1];
        num_edge+=edge_y[y2][x2]-edge_y[y1][x2];
        if(x1>0) num_edge-=edge_y[y2][x1-1]-edge_y[y1][x1-1];
        int ans=num_node-num_edge;
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 100096
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<algorithm>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 3.141592653589793238
typedef long long ll;
using namespace std;
int main()
{
    
    int n,b;
    cin>>n;
    int a[n+1]={0};
    for(int i=1;i<n;i++)
    {
        cin>>b;
        a[b]++;
    }
    for(int i=1;i<=n;i++)
    cout<<a[i]<<"\n";
    return 0;
}

Measured memory_bytes: 4424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>

using namespace std;

int cnt[100100];

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

	int n;
	cin >> n;

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

	int max_cnt = 0;
	for (int x = 0; x <= 100000; x++)
	{
		int cur_cnt = cnt[x] + cnt[x + 1];
		if (x > 0)
			cur_cnt += cnt[x - 1];

		max_cnt = max(max_cnt, cur_cnt);
	}

	cout << max_cnt;
}

Measured memory_bytes: 640
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(lst[k-1])

Measured memory_bytes: 61808