akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
//
//const int MAXN = 1000010;
//
//vector<bool> isp(MAXN + 1, true);
//
//void sieve() {
//	isp[0] = false;
//	isp[1] = false;
//	for (int i = 2; pow(i, 2) <= MAXN; i++) {
//		if (isp[i]) for (int j = 2; i*j <= MAXN; j++) isp[i*j] = false;
//	}
//}

bool isPrime(ll p) {
	if (p == 1)return false;
	for (ll i = 2; i*i <= p; ++i)
		if (p%i == 0)return false;
	return true;
}

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

	int A, B;
	cin >> A >> B;

	map<int, int> dmap;
	rep(i, 1, sqrt(A) + 1)
	{
		if (A%i == 0)
		{
			dmap[i]++;
			if (i < (A / i))dmap[A / i]++;
		}
	}
	rep(i, 1, sqrt(B) + 1)
	{
		if (B%i == 0)
		{
			dmap[i]++;
			if (i < (B / i))dmap[B / i]++;
		}
	}

	int ans = 1;
	for (auto p : dmap)
	{
		if (p.second == 2 && isPrime(p.first))
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

typedef long long int ll;


using namespace std;

string a;

int main(){
	int cnt=0;
	while(cin>>a){
		for(int i=0; i<a.size(); i++){
			if(a[i]>='0'&&a[i]<='9'){
				//printf("%c\n", a[i]);
				string b;
				while((a[i]>='0'&&a[i]<='9')){
					b+=a[i];
					i++;
				}
				cnt+=atoi(b.c_str());
			}
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

ll rec(ll h){
  if(h==1) return 1;
  return 2*rec(h/2)+1;
}

int main(){
  ll h;
  cin>>h;
  cout<< rec(h) <<endl;
}


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

int MX = 1000000;
vector<int> polo;
vector<int> dp0(MX+1,-1);
vector<int> dp1(MX+1,-1);

int dfs0(int x = MX){
        if(dp0.at(x) >= 0) return dp0.at(x);
        int res = INF;
        for(auto p:polo){
                if(x-p < 0) break;
                res = min(res,dfs0(x-p)+1);
        }
        return dp0.at(x) = res;
}

int dfs1(int x = MX){
        if(dp1.at(x) >= 0) return dp1.at(x);
        int res = INF;
        for(auto p:polo){ 
                if(p%2 == 0) continue;
                if(x-p < 0) break;
                res = min(res,dfs1(x-p)+1);
        }
        return dp1.at(x) = res;
}


int main() {
        int i = 1;
        while(1){
                int x = i*(i+1)*(i+2)/6;
                if(x > MX) break;
                polo.push_back(x);
                i++;
        }
        
        dp0.at(0) = 0;
        dp1.at(0) = 0;
        
        dfs0();
        dfs1();
        
        while(1){
                int p;
                cin >> p;
                if(p==0) break;
                cout << dp0.at(p) << " " << dp1.at(p) << endl;
        }
    
        return 0;
}




Measured memory_bytes: 72884
W,H,N = map(int,input().split())
LIX = []
LIY = []
LIA = []
for i in range(N):
    A,B,C = map(int,input().split())
    LIX.append(A)
    LIY.append(B)
    LIA.append(C)
    
NUMX = []
NUMY = []
for i in range(W):
    NUMX += [i+1]
for i in range(H):
    NUMY += [i+1]
    
for i in range(N):
    if LIA[i] == 1:
        for j in range(LIX[i]):
            if j+1 in NUMX:
                NUMX.remove(j+1)
    if LIA[i] == 3:
        for j in range(LIY[i]):
            if j+1 in NUMY:
                NUMY.remove(j+1)
    if LIA[i] == 2:
        for j in range(LIX[i]+1, W+1):
            if j in NUMX:
                NUMX.remove(j)
    if LIA[i] == 4:
        for j in range(LIY[i]+1, H+1):
            if j in NUMY:
                NUMY.remove(j)
print(len(NUMX)*len(NUMY))

Measured memory_bytes: 3064
h, n = map(int, input().split())
dp = [0] + [10**10] * (h+1)

for _ in range(n):
    a, b = map(int, input().split())
    for i in range(h):
        dp[min(i+a,h)] = min(dp[i]+b, dp[min(i+a,h)])
print(dp[h])

Measured memory_bytes: 44252
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
#define m(a,b) memset(a,b,sizeof(a));
const int maxn = 1e5;
typedef long long LL;
int main(){
	int a,b;
	cin >> a >>b;
	cout << max(a+b,max(a-b,a*b)) << endl;
	return 0;
}

Measured memory_bytes: 256
// start 20:09
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

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

using namespace std;

int main() {
    int n;
    vector<int> nums(5001);
    
    while(cin >> n, n) {
        int max_n;

        REP(i, n) cin >> nums[i];

        // cout << nums[0] << " " << nums[1] << " " << nums[2] << endl;        
        max_n = nums[0];

        // cout << "m:" << max_n << endl;

        REP(oft, n) {
            int sum = 0;
            for ( int i = oft; i < n; i++ ) {
                sum += nums[i];
                max_n = max(max_n, sum);
            }
        }
        cout << max_n << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
	int r, g, b;
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void){
    char W[10],T[1000];
    int i,j,count=0;
    scanf("%s",W);
    for(;;){
        scanf("%s",T);
        if(strcmp(T,"END_OF_TEXT")==0) break;
        for(i=0;T[i]!='\0';i++) T[i]=tolower(T[i]);
        if(strcmp(W,T)==0) count++;
    }
    printf("%d\n",count);
    return 0;
}


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


int main() {
    const int MAX_N = 1e5 + 10;
    int N, A[MAX_N], B[MAX_N], C[MAX_N], dp[MAX_N][3];
	cin >> N;
    for (int i = 0; i < N; ++i){
        cin >> A[i] >> B[i] >> C[i];
    }

    dp[0][0] = A[0];
    dp[0][1] = B[0];
    dp[0][2] = C[0];
    for (int i = 1; i < N; ++i){
        dp[i][0] = A[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = B[i] + max(dp[i-1][2], dp[i-1][0]);
        dp[i][2] = C[i] + max(dp[i-1][0], dp[i-1][1]);
    }

    int ans = 0;
    for (int i = 0; i < 3; ++i){
        ans = max(ans, dp[N-1][i]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 2560
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,m,a[max_n];
ll lcm(ll x,ll y){
    return min(x/__gcd(x,y)*y,(ll)inf);
}
int main(){
    //cout<<(ll)inf<<endl;
    scanf("%d%d",&n,&m);
    ll x=1;
    for(int i=1;i<=n;i++)scanf("%d",a+i),a[i]/=2,x=lcm(x,a[i]);
    if(x==inf)printf("0\n");
    else{
        bool f=true;
        for(int i=1;i<=n;i++)if(x/a[i]%2==0)f=false;
        if(f==false)printf("0\n");
        else{
            m/=x;
            printf("%d\n",(m+1)/2);
        }
    }
    return 0;
}

Measured memory_bytes: 640
/*B - Palindrome-philia*/
#include <bits/stdc++.h>

using namespace std;

int main(){
	
	string cad;
	int ans = 0;

	cin >> cad;

	int j = cad.size() - 1;

	for (int i = 0; i < cad.size() / 2 ; ++i)
	{
		if(cad[i] != cad[j])
			ans++;
		j--;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
L.sort()
import bisect
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        c = a+b
        n = bisect.bisect_left(L,c)
        ans += n-j-1	
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const int INF = 1e9;
const ll MAXN = 1e9;

int N,A,B,C;
vector<int> x;

int dfs(int now,int a,int b,int c){
	if(now == N){
		if(min(min(a,b),c)>0){
			return abs(A-a)+abs(B-b)+abs(C-c)-30;
		}else{
			return INF;
		}
	}else{
		int res0 = dfs(now+1,a,b,c);
		int res1 = dfs(now+1,a+x[now],b,c)+10;
		int res2 = dfs(now+1,a,b+x[now],c)+10;
		int res3 = dfs(now+1,a,b,c+x[now])+10;

		return min(min(res0,res1),min(res2,res3));
	}


}

int main()
{
	cin >>N>>A>>B>>C;
	x.resize(N,0);
	for(int i = 0; i < N; i++){
		cin>>x[i];
	}
	cout << dfs(0,0,0,0)<<endl;

	return 0;
}

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

int main(){
  vector<int> a={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};
  int k;
  cin>>k;
  cout<<a[k-1]<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=505;
vi v[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,m,q;
  cin>>n>>m>>q;
  rep(i,1,m+1)
    {
      int x,y;
      cin>>x>>y;
      v[x].pb(y);
    }
  rep(i,1,n+1) sort(all(v[i]));
  while(q--)
    {
      int x,y;
      cin>>x>>y;
      int ans=0;
      rep(i,x,y+1)
	{
	  int ind=upper_bound(all(v[i]),y)-v[i].begin();
	  ans+=ind;
	}
      cout<<ans<<endl;
    }
  return 0 ;
}


Measured memory_bytes: 2176
program ABC174D
    implicit none
    integer(8)::N,i,Wc(0:200000),Rc(0:200000),ans=2000000
    character(200000)::C
    read*,N,C
    Wc(0)=0
    Rc(0)=0
    do i=1,N
        if(C(i:i)=="R")then
            Rc(i)=Rc(i-1)+1
            Wc(i)=Wc(i-1)
        else
            Rc(i)=Rc(i-1)
            Wc(i)=Wc(i-1)+1
        end if
    end do

    do i=0,N
        ans=min(ans,max(Wc(i)-Wc(0),Rc(N)-Rc(i+1)))
    end do
    print'(i0)',ans
end program ABC174D

Measured memory_bytes: 6340
A,B = map(int,input().split())                                    

def f(X):
    ans = (X&1)^((X>>1)&1)
    for i in range(1,48):
        if (X&1==0) and (X&(1<<i)!=0):
            ans += 1<<i
    return(ans)
     
print(f(max(A-1,0))^f(B))    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())


int main(){
  int n,ans;
  cin >>n;
  vector<int>w;
  vector<vector<int>>v1(100);
  vector<vector<int>>v2(100);
  rep(i,n){
    int x;cin>>x;
    w.pb(x);
  }
  ans = INF;
  rep(i,n){
    rep(j,n){
      int x = w[j];
      if(j>=i) v1.at(i).pb(x);
      else v2.at(i).pb(x);
    }
    int wa1=0,wa2=0;
    rep(k,v1.at(i).size()){wa1+=v1.at(i).at(k);}
    rep(l,v2.at(i).size()){wa2+=v2.at(i).at(l);}
    int ansx = abs(wa1-wa2);
    ans = min(ansx,ans);
    
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  if(a == b && a != c){
    cout << "Yes" << endl;}
  else if(a == c && a != b){
    cout << "Yes" << endl;}
  else if(b == c && a != b){
    cout << "Yes" << endl;}
  else {
    cout << "No" << endl;}
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(M)]

res = []
st = 10**(N-1)
if N == 1:
    st = 0

for i in range(st, 10**N):
    nm = str(i)
    is_n = True
    for s, c in A:
        if not nm[s-1] == str(c):
            is_n = False
            break
    if is_n:
        res.append(i)

if res:
    print(min(res))
else:
    print(-1)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

void solve() {
    bool st[81][81][12801];
    ll n,m,i,j,k,a[81][81],x;
    fo(i,81)fo(j,81)fo(k,12801)st[i][j][k]=false;
    cin>>n>>m;
    fo(i,n)fo(j,m)cin>>a[i][j];
    fo(i,n)fo(j,m){cin>>k;a[i][j]=abs(a[i][j]-k);}
    st[0][0][a[0][0]+6400]=true;
    st[0][0][6400-1ll*a[0][0]];
    Fo(i,1,m) {
        fo(j,12801) {
            if(st[0][i-1][j]==1) {
                if(j+a[0][i]<=12800)st[0][i][j+a[0][i]]=true;
                if(j-a[0][i]>=0)st[0][i][j-a[0][i]]=true;
            }
        }
    }
    Fo(i,1,m) {
        fo(j,12801) {
            if(st[i-1][0][j]==1) {
                if(j+a[i][0]<=12800)st[0][i][j+a[i][0]]=true;
                if(j-a[i][0]>=0)st[0][i][j-a[i][0]]=true;
            }
        }
    }
    Fo(i,1,n)Fo(j,1,m) {
        fo(x,12801) {
            if(st[i-1][j][x]) {
                if(x+a[i][j]<=12800)st[i][j][x+a[i][j]]=true;
                if(x-a[i][j]>=0)st[i][j][x-a[i][j]]=true;
            }
        }
        fo(x,12801) {
            if(st[i][j-1][x]) {
                if(x+a[i][j]<=12800)st[i][j][x+a[i][j]]=true;
                if(x-a[i][j]>=0)st[i][j][x-a[i][j]]=true;
            }
        }
    }
    ll ans = 1e9+7;
    fo(i,12801)if(st[n-1][m-1][i])ans = min(ans, (ll)abs(i-6400));
    cout<<ans;
}

int main()
{
    fastIO;ll t=1;
    // cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 82304
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Throwable {
		Scanner sc = new Scanner(System.in);
//		Scanner sc = new Scanner(new File("test_1.txt"));
		List<Integer> a = new ArrayList<Integer>();
		int N = sc.nextInt();
		for (int i = 0; i < N; i++)
			a.add(sc.nextInt());
		sc.close();
		
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			// 0..i-1??????????????????
			int a_i = a.get(i);
			int j = i - 1;
			while (j >= 0 && a.get(j) > a_i) {
				a.set(j + 1, a.get(j));
				j--;
			}
			a.set(j + 1, a_i);
			
			// ??????
			for (int k = 0; k < a.size(); k++) {
				sb.append(a.get(k));
				if (k != a.size() - 1)
					sb.append(' ');
			}
			sb.append('\n');
		}
		
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 23220
def projecter(x, y, xp, yp)
  return (xp * x + yp * y) / (x ** 2 + y ** 2)
end
def main(input = STDIN)
  x1, y1, x2, y2 = input.gets.split(" ").map(&:to_r)
  q = input.gets.to_i
  x, y = (x2 - x1), (y2 - y1)
  q.times do
    xp, yp = input.gets.split(" ").map(&:to_r)
    a = projecter(x, y, xp - x1, yp - y1)
    puts "#{(x1 + a * x).to_f} #{(y1 + a * y).to_f}"
  end
end
main

Measured memory_bytes: 6164
n, m = map(int, input().split())
mod = 10 ** 9 + 7
d = abs(n-m)
if(d>1):
    print(0)
else:
    factList = [None] * (max(n, m) + 1)
    for i in range(len(factList)):
        if(i==0):
            factList[i] = 1
            continue
        factList[i] = factList[i-1] * i % mod

    if(d==1):
        print(factList[n]*factList[m] % mod)
    else:
        print(factList[n]*factList[m]*2 % mod)


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

int n,k;
int arr[107];
ll dp[107][100007];

int rec( int i, int x )
{
    if( x>k )
        return 0;

    if( i>n )
    {
        if(x==k)
            return 1;
        return 0;
    }
    int ret= 0;

    for( int j=0; j<=arr[i]; j++ )
        ret= ( ret+rec( i+1, x+j ) )%mod;

    return ret;
}

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

    for( int i=1; i<=n; i++ )
        cin>>arr[i];

    vector<ll>sum;
    for( int i=0; i<k; i++ )
        sum.push_back(0);
    sum.push_back(1);


    for( int peep=n; peep>=1; peep-- )
    {
        vector<ll>now;

        for( int total=0; total<=k; total++ )
        {
            if(total)
                dp[peep][total]= (sum[ min(k,total+arr[peep]) ]-sum[total-1]+mod)%mod;
            else
                dp[peep][total]= sum[ min(k,total+arr[peep]) ];

            if(total)
                now.push_back( (now.back()+dp[peep][total])%mod );
            else
                now.push_back( dp[peep][total] );

//            cout<<peep<<" "<<total<<" "<< dp[peep][total] <<" "<<rec( peep, total ) <<endl;
        }

        sum.swap(now);
    }

    cout<< dp[1][0] <<endl;
}


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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll s = 0, w = 0;
    cin >> s >> w;

    if(w >= s) cout << "unsafe\n";
    else cout << "safe\n";

    return 0;
}

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

int main() {
	int n;cin>>n;
	int a[114514];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	vector<int>v;
	for(int i=1;i<=a[n-1];i++)if(a[n-1]%i==0)v.push_back(i);
	int ans=0;
	for(int i=0;i<n-1;i++){
		for(int j=0;j<v.size();j++){
			if(v[j]>=a[i]){
				ans+=v[j]-a[i];
				goto heaven;
			}
		}heaven:;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m,q;
    cin >> n >> m >> q;
    vector<ll> a(q);
    vector<ll> b(q);
    vector<ll> c(q);
    vector<ll> d(q);
    for(i = 0;i < q;++i){
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    }
    queue<vector<ll>> que;
    for(i = 1;i <= m;++i){
        que.push({i});
    }
    queue<vector<ll>> tamesu;
    while(!que.empty()){
        auto top = que.front();
        que.pop();
        ll last = top.back();
        for(i = last;i <= m;++i){
            auto tmp = top;
            tmp.push_back(i);
            if(tmp.size() == n){
                tamesu.push(tmp);
            }else{
                que.push(tmp);
            }
        }
    }
    ll ans = 0;
    while(!tamesu.empty()){
        ll tmp = 0;
        auto top = tamesu.front();
        tamesu.pop();
        for(i = 0;i < q;++i){
            if(top.at(b.at(i)-1) - top.at(a.at(i)-1) == c.at(i)) tmp += d.at(i);   
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
	int b1,b2,b3;
	cin >> b1 >> b2 >> b3;
	if(b1==1 && b2==0 && b3==0){
	cout << "Close" << "\n";
	}else if(b1==0 && b2==1 && b3==0){
	cout << "Close" << "\n";
	}else if(b1==1 && b2==1 && b3==0){
	cout << "Open" << "\n";
	}else if(b1==0 && b2==0 && b3==1){
	cout << "Open"<< "\n";
	}else if(b1==0 && b2==0 && b3==0){
	cout << "Close" << "\n";
	}
	return 0;
}

Measured memory_bytes: 1124
S=input()
ans=0
for i in range(len(S)):
    x=0
    for j in range(i+1,len(S)+1):
        if S[j-1]=="A" or S[j-1]=="C" or S[j-1]=="G" or S[j-1]=="T":
            x+=1
            if j==len(S):
                if ans<x:
                    ans=x
                x=0
        else:
            if ans<x:
                ans=x
            x=0
        #print(S[i:j])
            
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
int n,m,c,ans=0;
int a[40][40],b[40],sum[40];
signed main(){
    cin>>n>>m>>c;
    rep(i,m)cin>>b[i];
    rep(i,n){
        sum[i]=c;
        rep(j,m){
            cin>>a[i][j];
            sum[i]+=a[i][j]*b[j];
        }
    }
    rep(i,n){
        if(sum[i]>0)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n, q, b, e, k, t, r;
    vector<ll> v;
    scanf("%lld", &n);
    for (ll i = 0; i< n; i++){
        scanf("%lld", &t);
        v.push_back(t);
    }
    auto itr = v.begin();
    scanf("%lld", &q);
    for(ll i = 0; i < q; i++){
        scanf("%lld %lld %lld", &b, &e, &k);
        r = count(itr+b, itr+e, k);
        printf("%lld\n", r);
    }
    return 0;
}


Measured memory_bytes: 3268
<?php
fscanf(STDIN,"%d %d %d %d",$sx,$sy,$tx,$ty);
$result = "";
//点s上と点t左のX座標の差
$ULX = ($tx-1)-$sx;
//点s上と点t左のY座標の差
$ULY = $ty-($sy+1);
//点s左と点t上のX座標の差
$LUX = $tx-($sx-1);
//点s左と点t上のX座標の差
$LUY = ($ty+1)-$sy;

//初期移動(点s上)
$result .= "U";
for($i=0;$i<$ULY;$i++){
  $result .= "U";
}
for($i=0;$i<$ULX;$i++){
  $result .= "R";
}
//移動(点t左から点t下)
$result .= "RD";
for($i=0;$i<$ULY;$i++){
  $result .= "D";
}
for($i=0;$i<$ULX;$i++){
  $result .= "L";
}
//移動(点s右から点s左)
$result .= "LL";
for($i=0;$i<$LUY;$i++){
  $result .= "U";
}
for($i=0;$i<$LUX;$i++){
  $result .= "R";
}
//移動(点t上から点t右)
$result .= "DR";
for($i=0;$i<$LUY;$i++){
  $result .= "D";
}
for($i=0;$i<$LUX;$i++){
  $result .= "L";
}
//移動(点s下から点s)
$result .= "U";

echo $result;


Measured memory_bytes: 3828
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			System.out.println(x + (y / 2));
		}
	}
}

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

ll pow3(ll x) { return x * x * x; }

int main() {
  ll n, k;
  cin >> n >> k;
  cout << pow3(n / k) + (k % 2 ? 0 : pow3((n + k / 2) / k)) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt(), b = scan.nextInt() , c = scan.nextInt();
        int count = 0;
        for(int i = 1; i <= c; i++) {
            if(a <= i && i <= b) {
                if(c % i == 0) {
                count++ ;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 26212
N,Q = map(int,input().split())
S = input()

list = [0]*N

for i in range(N-1):
    list[i+1] = list[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l,r = map(int,input().split())
    print(list[r-1]-list[l-1])

Measured memory_bytes: 9668
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


std::vector<mint> construct_comb(int n) {
	std::vector<mint> c(n+1);
	mint a = 1;
	c[0] = a;
	for(int i=1;i<=n;i++) {
		a = a*mint(n+1-i)/i;
		c[i] = a;
	}
	return c;
}


signed main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::sort(all(a));
	mint sum=0;
	std::vector<mint> revC(n+1);
	revC[k-1]=1;
	for(int i=k-1;i<n;i++) {
		revC[i+1]=revC[i]*mint(i+1)/mint(i-k+2);
	}
	// count how many times a[i] will be min
	rep(i,n) {
		if(n-1-i>=k-1) sum-=mint(a[i])*revC[n-1-i]; //n-1-iCk-1
		if(i>=k-1) sum+=mint(a[i])*revC[i];
	}
	print(sum);
	return 0;
}


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

num_four = 0
num_two = 0
num_odd = 0
for i in range(N):
    if A[i] % 4 == 0:
        num_four += 1
    elif A[i] % 2 == 0:
        num_two += 1
    else:
        num_odd += 1

# print(num_four, num_two, num_odd)

if num_two != 0:
    ans = 'Yes' if num_four + 1 >= num_odd + 1 else 'No'
else:
    ans = 'Yes' if num_four + 1 >= num_odd else 'No'
print(ans)


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

int main(){
    long long h;
    cin >> h;
    int ct=0;
    while(h/2 >= 1){
        ct++;
        h /= 2;
    }
    long long sum;
    sum = pow(2,ct+1) - 1;
    cout << sum << endl;
}

Measured memory_bytes: 256
N = int(input())

a=0;b=0;c=0
L = list(map(int,input().split()))
for i in range(N):
  if L[i]%4 == 0:
    c += 1
  elif L[i]%2 == 0:
    b += 1
  else:
    a += 1
t = a+b+c
#print(a,b,c)
ans = "No"
if a == 0:
  ans = "Yes"
elif c >= a:
  ans = "Yes"
elif b == 0 and a == c+1:
  ans ="Yes"
print(ans)

Measured memory_bytes: 14480
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let s=s.as_bytes();
    println!("{}",if s[2]==s[3] && s[4]==s[5] {"Yes"} else {"No"});
}

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 100010

int n,k;

LL tab[MAXSIZE];
LL dp[105][MAXSIZE];

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n>>k;
	
	FOR(i,1,n)
		cin>>tab[i];
	
	
	dp[0][0]=1;
	
	FOR(i,1,n){
		LL temp=0;
		 
		FOR(j,0,k){
			temp=(temp+dp[i-1][j])%MOD;
			dp[i][j]=(dp[i][j]+temp)%MOD;
			
			if(j-tab[i]>=0)
				temp=((temp-dp[i-1][j-tab[i]])%MOD+MOD)%MOD;
		}
	}
	
	cout<<dp[n][k];
	
	
	return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> W(N+1);
	int sum = 0;
	for (int i = 1; i <= N; i++)
	{
		cin >> W[i];
		sum += W[i];
	}
	int ans = sum;
	for (int i = 2; i < N; i++)
	{
		int S1 = 0;
		for (int j = 0; j <= i ; j++)
		{
			S1 += W[j];
		}
		int S2 = sum - S1;
		if (abs(S2-S1)<ans)
		{
			ans = abs(S2 - S1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m, X, Y;
	cin>>n>>m>>X>>Y;
	int x[100], y[100];
	for(int i=0; i<n; i++) cin>>x[i];
	for(int i=0; i<m; i++) cin>>y[i];
	sort(x, x+n);
	sort(y, y+m);
	if(X+1>Y){
      cout<<"War"<<endl;
      return 0;
    }
  for(int z=X+1; z<=Y; z++){
    if(x[n-1]<z && z<=y[0]){
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if(a < b){
        printf("a < b\n");
    }
    
    else if(a > b){
        printf("a > b\n");
    }
    
    else {
        printf("a == b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2052
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define pb push_back

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;
using db = double;

int N, W;
vector<int> w, v;
vector<vector<llong>> dp;
llong dfs(int index, int left) {
	if (left < 0) return -LLINF;
	if (index == N) return 0;
	llong& ret = dp[index][left];
	if (ret != -1) return ret;
	return ret = max(dfs(index + 1, left), dfs(index + 1, left - w[index]) + v[index]);
}

int main() {
	cin >> N >> W;
	w=v=vector<int>(N);
	dp = vector<vector<llong>>(N, vector<llong>(W + 1, -1));
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
	cout << dfs(0, W);
}

Measured memory_bytes: 82312
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define repd(i,a,b) for (int i=a;i<int(b);i++)
#define rep(i,n) repd(i,0,n)
#define VARNAME(v) #v
using P = pair<int,int>;


int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int BEAM = 320;
  int d;vector<int> c(26);cin>>d;rep(i,26)cin>>c[i];
  vector<array<int, 26>> s(d);
  rep(i,d)rep(j,26)cin>>s[i][j];
  vector<int> curs = {0};
  vector<array<int, 26>> curl(1);
  vector<vector<int>> cura(1);
  rep(i,d){
    int len = int(curs.size()) * 26, ind = 0;
    vector<P> nxs(len);
    vector<array<int, 26>> nxl(len);
    vector<vector<int>> nxa(len);
    rep(j, curs.size()){
      rep(t, 26){
        int score = curs[j];
        array<int, 26> last = curl[j];
        vector<int> ans = cura[j];
        score += s[i][t];
        last[t] = i+1;
        rep(k,26)score -= c[k]*(i+1 - last[k]);
        ans.emplace_back(t);
        nxs[ind] = P(score, ind);
        nxl[ind] = last;
        nxa[ind] = ans;
        ind++;
      }
    }
    sort(nxs.rbegin(), nxs.rend());
    len = min(len, BEAM);
    curs.resize(len);curl.resize(len);cura.resize(len);
    rep(j,len){
      curs[j] = nxs[j].first;
      curl[j] = nxl[nxs[j].second];
      cura[j] = nxa[nxs[j].second];
    }
    if(i % 73 == 0)BEAM += 90;
  }
  int ans = 0;
  rep(i,min(int(curs.size()), BEAM)){
    if(curs[ans] < curs[i])ans = i;
  }

  for(auto x : cura[ans]){
    cout << x+1 << endl;
  }
}


Measured memory_bytes: 36528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e9 + 7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
using Point = complex<double>;
double dot(Point a, Point b) {return real(conj(a) * b);}
double cross(Point a, Point b) {return imag(conj(a) * b);}
const double eps = 1e-10;
int main() {
    double xa, ya, xb, yb, xc, yc, xp, yp;
    while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xp >> yp) {
        double tmp = abs(cross(Point(xb - xa, yb - ya), Point(xc - xa, yc - ya)));
        double sum = 0;
        sum += abs(cross(Point(xb - xp, yb - yp), Point(xc - xp, yc - yp)));
        sum += abs(cross(Point(xa - xp, ya - yp), Point(xc - xp, yc - yp)));
        sum += abs(cross(Point(xa - xp, ya - yp), Point(xb - xp, yb - yp)));
        if (abs(tmp - sum) < eps) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

const int mxn = 310;
double dp[mxn][mxn][mxn];
bool c[mxn][mxn][mxn];
int n;
int a[mxn];

double f(int one, int two, int three)
{
	if(c[one][two][three])
		return dp[one][two][three];
	if(!one && !two && !three)
		dp[one][two][three] = 0;
	else
	{
		dp[one][two][three] = (double)n;
		if(one)
			dp[one][two][three] += (double)one * f(one - 1, two, three);
		if(two)
			dp[one][two][three] += (double)two * f(one + 1, two - 1, three);
		if(three)
			dp[one][two][three] += (double)three * f(one, two + 1, three - 1);
		dp[one][two][three] /= (double)(one + two + three);
	}
	c[one][two][three] = 1;
	return dp[one][two][three];
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	int one = 0, two = 0, three = 0;
	FOR(i,1,n)
	{
		cin >> a[i];
		if(a[i] == 1)
			one++;
		else if(a[i] == 2)
			two++;
		else if(a[i] == 3)
			three++;
	}
	memset(c,0,sizeof(c));
	cout << fixed << setprecision(12) << f(one,two,three);

	return 0;
}

Measured memory_bytes: 143444
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll x, ans, res;
	cin>>x;
	//11 2 0
	//12 3 1
	//13 3 2
	//14 3 3
	//15 3 4
	//16 3 5
	//17 3 6
	//18 4 7
	//19 4 8
	//20 4 9
	//21 4 10
	//22 4 0
	res = x%11;
	x /= 11;
	if(res>0&&res<=6){
		ans=2*x+1;
	}else if(res>=7&&res<=10){
		ans=2*x+2;		
	}else{
		ans=2*x;
	}
	cout<<ans<<endl;
	return 0;
}














Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool> vec(N, true);
    rep(i, K) {
        int d;
        cin >> d;
        rep(j, d) {
            int A;
            cin >> A;
            vec[A - 1] = false;
        }
    }
    int ans = 0;
    rep(i, N) if (vec[i]) ans += 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const ll MOD = 998244353;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
ll tree[MAX];
ll query(int idx)
{
    ll sum=0;
    while(idx>0)
    {
        sum+=tree[idx];
        idx -= idx & (-idx);
    }
    return sum;
}
void update(int idx, int x, int n) //n is the size of the array, x is the number to add
{
    while(idx<=n)
    {
        tree[idx]+=x;
        idx += idx & (-idx);
    }
}
int x[20],y[20];
ll dp[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin>>n>>k;
    for(int i=0; i<k; i++)
        cin>>x[i]>>y[i];
    dp[n]=1;
    update(n,1,n);
    for(int i=n-1; i>0; i--)
    {
        for(int j=0; j<k; j++)
        {

            int l=i+x[j];
            int r=i+y[j];
            if(l>n)
                continue;
            r=min(r,n);
            ll ways=query(r)-query(l-1);
            //cout<<i<<" "<<ways<<endl;
            dp[i]=MODADD(dp[i],ways);
        }
        update(i,dp[i],n);
    }
    cout<<dp[1]<<endl;


    return 0;
}


Measured memory_bytes: 6772
A, B, C, k = gets.split.map(&:to_i)
ans = [[A, 1], [B, 0], [C, -1]].inject(0) do |r, (n, p)|
  if k > 0
    t = [n, k].min
    k -= t
    r += t * p
  end
  r
end
puts ans

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

typedef long long ll;

typedef pair<ll, pair<int, int> > p;

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

    int N;
    string S;

    cin >> N >> S;

    int left, right;

    left = 0;
    right = 0;

    int la = 0;

    for(int i = 0; i < N; i++) {
        if(S[i] == '(') left++;
        else {
            if(left > 0) left--;
            else la++;
        }
    }

    string ans = "";

    for(int i = 0; i < la; i++) ans += '(';

    ans += S;

    for(int i = 0; i < left; i++) ans += ')';

    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

typedef string::const_iterator State;
class ParseError {};
void sp(State&);
int expr(State&);
int term(State&);
int number(State&);

string s;
int expr(State &begin) {
	int ret = term(begin);
	while(s.end()-begin>=2) {
		//cout << *begin << " " << begin-s.begin() << " " << ret << endl;
		if(*begin == '>' && *(begin+1) == '>' && *(begin+2) != '>') {
			begin++; // >
			begin++; // >
			ret >>= min(term(begin), 31);
		} else {
			break;
		}
	}
	//cout << "expr:" << ret << endl;
	return ret;
}

int term(State &begin) {
	if(*begin == 'S') {
		begin++;
		begin++;
		//cout << "s " << *begin << " " << begin-s.begin() << endl;
		ll ret = expr(begin);
		ret = (ret*ret) % MOD;
		begin++;
		//cout << "te:" << ret << endl;
		return ret;
	} else {
		//cout << "tn:" << *begin << " " << begin - s.begin() << endl;
		int ret = number(begin);
		//cout << "tenum:" << ret << endl;
		return ret;
	}
}

int number(State &begin) {
	int ret = 0;
	while(isdigit(*begin)) {
		ret *= 10;
		ret += *begin - '0';
		begin++;
	}
	return ret;
}

signed main(void)
{
	while(true) {
		string t;
		getline(cin, t);
		if(t == "#") break;

		s = "";
		REP(i, t.size()) if(t[i] != ' ') s += t[i];
		//cout << s << endl;
		State begin = s.begin();
		cout << expr(begin) << endl;
	}

	return 0;
}

Measured memory_bytes: 4808
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<int> A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
    A = fetch_vec<int>(N);
}

int solve(){ 
    int all = accumulate(A.begin(),A.end(),0);
    int cnt = 0;
    for(auto a:A){
        if(4*M*a>=all) cnt++;
    }
    cout <<  (cnt>=M?"Yes":"No") << endl;
    return 0;
}   

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


Measured memory_bytes: 256