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

int main(){
    int x=0,gohyaku=0,goen=0;
    char token[200]={};
    fgets(token, sizeof(token), stdin);x=atoi(token);
    gohyaku=x/500;
    x=x%500;
    goen=x/5;
    printf("%d",(gohyaku*1000)+(goen*5));
    return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;

long kaijou(int n) {
    long WARIZAN = pow(10, 9) + 7;
    long power = 1;
    int i;
    for(i = 1; i <= n; i++){
        power *= i;
        long muda = (power / WARIZAN);
        power -= muda * WARIZAN;
    }
    return power;
}

int main() {
    int N;
    cin >> N;
    long Answer = kaijou(N);
    cout << Answer << endl;
    return 0;
}

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

int main() {
	int n, d;
	cin >> n >> d;
	vector<vector<int>> x(n, vector<int>(d));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < d; j++) cin >> x.at(i).at(j);
	}

	int ans = 0;
	double y;
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			y = 0;
			for(int k = 0; k < d; k++) y += (x.at(i).at(k) - x.at(j).at(k)) * (x.at(i).at(k) - x.at(j).at(k));
			for(int k = 0; k < (int)sqrt(y) + 1; k++) {
				if(y == k * k) ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int i,j,n,m;
int a[300][300];
string str;

bool can(int number){
    vector<int> sport[300];
    int rank[300];
    bool which[300];
    for(i = 0;i < m;i++){
        which[i] = true;
    }
    for(i = 0;i < n;i++){
        rank[i] = 0;
        sport[a[i][0]].push_back(i);
    }
    while(true){
        bool f = true;
        for(i = 0;i < m;i++){
            if(which[i] && sport[i].size() > number){
                which[i] = false;
                for(j = 0;j < sport[i].size();j++){
                    int target = sport[i][j];
                    for(int k = rank[sport[i][j]]+1;true;k++){
                        if(k == m) return false;
                        if(which[a[target][k]]){
                            sport[a[target][k]].push_back(target);
                            rank[target] = k;
                            break;
                        }
                    }
                }
                f = false;
            }
        }
        if(f) break;
    }
    return true;
}

int main(){
    cin >> n >> m;
    for(i = 0;i < n;i++){
        for(j = 0;j < m;j++){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int l = 0,r = n;
    while(r-l > 1){
        int number = (r+l)/2;
        if(can(number)) r = number;
        else l = number;
    }
  long long ans = r;
  cout << ans << endl;
}


Measured memory_bytes: 1248
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x)
#define debug(x)
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)


void mainmain(){
    ll a, b, c;
    cin >> a >> b >> c;

    if (c-a-b >= 0 && 4*a*b < (c-a-b)*(c-a-b)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
//
// FileName : AT2152.cc
// Creator  : GGG1235
// Date     : 2019/11/26
// Comment  :
//

#include <bits/stdc++.h>

#pragma GCC optimize(3)

using namespace std;

typedef long long LL;

int main(int argc,const char **argv,const char **envp)
{
    ios::sync_with_stdio(false);
    cin.tie();

    LL lN;
    LL lX;

    LL lRes = 0;

    while (cin >> lN >> lX)
    {
        lRes = 0;
        vector<LL> kvAi(lN + 2,0);
        for (LL i = 1; i <= lN; i++) 
        {
            cin >> kvAi[i + 1];
        }
        for (LL i = 1; i <= lN; i++)
        {
            if (kvAi[i + 1] + kvAi[i] > lX)
            {
                lRes += kvAi[i + 1] + kvAi[i] - lX;
                kvAi[i + 1] = lX - kvAi[i];
            }
        }
        kvAi.clear();
        cout << lRes << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int n,card[100],math[100],tmp,set,end;
  char s[100],TMP;
  cin >> n;
  for(int t=0;t<n;t++){
    set=0;
    for(int i=0;i<10;i++){
      math[i]=0;
    }


    for(int i=0;i<9;i++){
      cin >> card[i];
    }

    for(int i=0;i<9;i++){
      cin >> s[i];
    }


    for(int i=0;i<9-1;i++){
      for(int j=9-1;j>i;j--){
	if(card[j]<card[j-1]){
	  tmp=card[j];
	  card[j]=card[j-1];
	  card[j-1]=tmp;

	  TMP=s[j];
	  s[j]=s[j-1];
	  s[j-1]=TMP;
	}
      }
    }

    for(int i=0;i<9;i++){
      if(math[i]==0){
	for(int j=i+1;j<9;j++){
	  if(math[j]==0){
	    for(int k=j+1;k<9;k++){
	      if(math[k]==0){
		if(s[i]==s[j] && s[j]==s[k] && card[i]+1==card[j] && card[j]+1==card[k]){

		  math[i]++;
		  math[j]++;
		  math[k]++;
		  set++;
		  i++;
		  j=i+1;
		  k=j+1;
		}
	      }
	    }
	  }
	}
      }
    }
    for(int i=0;i<9;i++){
      if(math[i]==0){
	for(int j=i+1;j<9;j++){
	  if(math[j]==0){
	    for(int k=j+1;k<9;k++){
	      if(math[k]==0){
		if(s[i]==s[j] && s[j]==s[k] && card[i]==card[j] && card[j]==card[k]){

		  math[i]++;
		  math[j]++;
		  math[k]++;
		  set++;
		  i++;
		  j=i+1;
		  k=j+1;
		}
	      }
	    }
	  }
	}
      }
    }


    //cout << set << endl;
    if(set>=3){
      cout << "1" << endl;
    }
    else{
      cout << "0" << endl;
    }
  }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int64_t N, D, ans;
  cin >> N >> D;
  vector<int64_t> X(N);
  vector<int64_t> Y(N);
  for (int64_t i=0; i<N; i++) {
    cin >> X[i] >> Y[i];
  }
  ans=0;
  for (int64_t j=0; j<N; j++) {
    if (X[j]*X[j]+Y[j]*Y[j]<=D*D) {
      ans=ans+1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;
ll dp[100005][4];
vi a(100005),b(100005),c(100005);
ll n;
ll solve(ll taken,ll i,ll j)
{
    if(i>=n)return 0;
    if(dp[i][j]!=-1)return dp[i][j];

    if(taken!=1) dp[i][1]=a[i]+max(solve(1,i+1,2),solve(1,i+1,3));
    if(taken!=2)dp[i][2]=b[i]+max(solve(2,i+1,1),solve(2,i+1,3));
    if(taken!=3)dp[i][3]=c[i]+max(solve(3,i+1,1),solve(3,i+1,2));

    if(taken==1)return max({dp[i][2],dp[i][3]});
    if(taken==2)return max({dp[i][1],dp[i][3]});
    if(taken==3)return max({dp[i][2],dp[i][1]});
    else return max({dp[i][2],dp[i][1],dp[i][3]});
}



int main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    fr(i,0,n)cin>>a[i]>>b[i]>>c[i];

    cout<<solve(0,0,0)<<endl;


   /* fr(i,1,4)
    {
        fr(j,0,n)cout<<dp[j][i]<<" ";
        cout<<endl;
    }
*/

}



























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

int main(){
  int n;
  cin >> n;
  
  map<ll,ll> mp;
  for(int i=0; i<n; i++){
    ll x;
    cin >> x;
    
    mp[x]++;
  }
  
  ll ans = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(itr->second % 2 == 1)
      ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

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

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

signed main() {
  int A, B;
  cin >> A >> B;

  cout << lcm(A, B) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int p[30005]={0},a[30005]={0},b[30005]={0};
int main()
{	
if (0) {}
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&p[i]);
	a[1]=100000;
	for(int i=2;i<=n;i++)a[i]=a[i-1]+30000;
	for(int i=1;i<=n;i++)b[n-i+1]=a[i];
	for(int i=1;i<=n;i++)b[p[i]]+=i;
	for(int i=1;i<=n;i++)cout<<a[i]<<" ";
	cout<<'\n';
	for(int i=1;i<=n;i++)cout<<b[i]<<" ";
	return 0;
}

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

int main()
{
    int W,H,x,y,r;
    cin>>W>>H>>x>>y>>r;
    if(0<=x-r&&x+r<=W){
        if (0<=y-r&&y+r<=H){
            cout<<"Yes"<<endl;}
            else{
                cout<<"No"<<endl;}}
                else{
                    cout<<"No"<<endl;}
                    return 0;
    }


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
   int n,k; cin>>n>>k;
   ll comb[n+1][n+1];
   REP(i,n+1){
    comb[i][0]=1;
    comb[i][i]=1;
   }
  FOR(i,1,n+1){
    FOR(j,1,i){
   comb[i][j]=comb[i-1][j-1] + comb[i-1][j];
   comb[i][j]%=MOD;
    }
  }
   FOR(i,1,k+1){
     ll ans;
     if(n-k+1<i)ans=0;
     else ans=comb[n-k+1][i]*comb[k-1][i-1];
     ans%=MOD;
     cout<<ans<<endl;
   }

}

Measured memory_bytes: 31360
#include<stdio.h>
int main()
{
    int c=0,i;
    char s[4];
    scanf ("%s",s);
    for (i=0;i<4;i++)
    {
        if (s[i]=='7')
        {
            c++;
        }
    }
    if (c>0)
    {
        printf ("Yes\n");
    }
    else
    {
        printf ("No\n");
    }
    return 0;
}


Measured memory_bytes: 1592
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define all(v) v.begin(),v.end()
#define f first
#define s second
#define PB push_back
#define MP make_pair
#define db long double
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define cases int testcases;cin>>testcases; while(testcases--)
#define mod 1000000007


int32_t main()
{
  
    IOS



    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d);






    return 0;


   
}   

Measured memory_bytes: 256
n    = gets.to_i
node = Array.new(n).map{Array.new}
list = []
ans  = Array.new(n)

(n - 1).times do
  a, b = gets.split.map(&:to_i)
  node[a - 1] << b - 1
  node[b - 1] << a - 1
  list << [a - 1, b - 1]
end

aryC = gets.split.map(&:to_i).sort

n.times do |i|
  node[i].unshift(i)
end

top = node.sort_by{|a| a.size}[0][0]

queue = []
queue << top

check = Array.new(n, 0)

while queue.size > 0
  now = queue.shift
  if check[now] == 0
    ans[now] = aryC.pop
    node[now].each do |n|
      queue << n
    end
  check[now] = 1
  end
end

sum = 0
list.each do |ls|
  sum += [ans[ls[0]], ans[ls[1]]].min
end

puts sum, ans.join(" ")


Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

inline ll add(ll x, ll y) {return (x+y)%MOD;}
inline ll mul(ll x, ll y) {return (x*y)%MOD;}
inline ll sub(ll x, ll y) {
    ll res = x - y;
    if(res < 0) res += MOD;
    return res;
}
inline ll modpow(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y&1) res = mul(res,x);
        y >>= 1;
        x = mul(x,x);
    }
    return res;
}

const int MAX = 1000005;

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

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main(){
    COMinit();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    ll a, b; cin >> a >> b;
    ll ans = modpow(2,N);
    ans = sub(ans,1);
    ll nca = 1;
    FOR(i,1,a+1) {
        nca = mul(nca,N-i+1);
        nca = mul(nca,inv[i]);
    }
    ll ncb = 1;
    FOR(i,1,b+1) {
        ncb = mul(ncb,N-i+1);
        ncb = mul(ncb,inv[i]);
    }
    ans = sub(ans, nca); //cout << nca << endl;
    ans = sub(ans, ncb); //cout << ncb << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <vector>

constexpr int N = 900'005;
constexpr int P = 1'000'000'007;

std::vector <int> fac, inv, fnv, pw3;
int n, m, k, sum, ans;

int binom (int x, int y) {
  if (x < y) return 0;
  return 1LL * fac[x] * fnv[y] % P * fnv[x-y] % P;
}

int main () {

  fac.assign (N, 1);
  inv.assign (N, 1);
  fnv.assign (N, 1);
  pw3.assign (N, 1);
  pw3[1] = 3;
  for (int i = 2; i < N; ++i) {
    fac[i] = 1LL * fac[i-1] * i % P;
    inv[i] = 1LL * inv[P%i] * (P-P/i) % P;
    fnv[i] = 1LL * fnv[i-1] * inv[i] % P;
    pw3[i] = 3LL * pw3[i-1] % P;
  }
  std::cin >> n >> m >> k;
  if (m < k) std::swap (m, k);
  sum = 1; ans = 0;
  for (int s = 0; s <= m + k; ++s) {
    ans += 1LL * binom (n - 1 + s, n - 1) * pw3[m + k - s] % P * sum % P;
    ans %= P;
    if (s < k) {
      sum = sum * 2LL % P;
    } else if (s < m) {
      sum = (sum * 2LL - binom (s, k) + P) % P;
    } else {
      sum = (sum * 2LL - binom (s, k) - binom (s, m) + P + P) % P;
    }
  }
  std::cout << ans << "\n";
  return 0;
}

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

int main() {
    while (true) {
        int X, Y;
        cin >> X >> Y;
        
        if (X==0 && Y==0) {
            break;
        }
        
        int c[Y][X];
        
        for (int i=0; i<Y; i++) {
            for (int j=0; j<X; j++) {
                cin >> c[i][j];
            }
        }

        int dp[Y][X];
        
        for (int i=0; i<Y; i++) {
            for (int j=0; j<X; j++) {
                dp[i][j] = 0;
            }
        }
        
        for (int i=0; i<X; i++) {
            if (c[0][i]==0) {
                dp[0][i] = 1;
            }
        }
        
        for (int i=0; i<Y-1; i++) {
            for (int j=0; j<X; j++) {
                if (c[i][j]==0) {
                    if (c[i+1][j]==0 || c[i+1][j]==2) {
                        dp[i+1][j] += dp[i][j];
                    }
                
                    if (j-1>=0) {
                        if (c[i+1][j-1]==0) {
                            dp[i+1][j-1] += dp[i][j];
                        }
                    }
                
                    if (j+1<X) {
                        if (c[i+1][j+1]==0) {
                            dp[i+1][j+1] += dp[i][j];
                        }
                    }
                }
                else if (i<Y-2 && c[i][j]==2) {
                    if (c[i+2][j]!=1) {
                        dp[i+2][j] += dp[i][j];
                    }
                }
            }
        }
        
        int ans = 0;
        
        for (int i=0; i<X; i++) {
            if (c[Y-2][i]==2) {
                ans += dp[Y-2][i];
            }
        }
        
        for (int i=0; i<X; i++) {
            ans += dp[Y-1][i];
        }
        
        cout << ans << endl;
    }
}


Measured memory_bytes: 3120
#include<stdio.h>

int main(void){
  int i,j,n,q,count=0;
  int S[10000],T[500];

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T[i]);
  }

  for(i=0; i<q; i++){
    for(j=0; j<n; j++){
      if(T[i] == S[j]) {
	count++;
	break;
      }
      else continue;
    }
  }

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

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
inline bool eq(char a,char b)
{
	return a=='?'||b=='?'?true:a==b;
}
int dp0[2020][2020];
int dp1[2020][2020];
main()
{
	vector<string>A(3);
	cin>>A[0]>>A[1]>>A[2];
	sort(A.begin(),A.end());
	int ans=A[0].size()+A[1].size()+A[2].size();
	do{
		for(int i=0;i<2020;i++)for(int j=0;j<2020;j++)dp0[i][j]=dp1[i][j]=0;
		for(int i=A[0].size();i--;)for(int j=A[2].size();j--;)
		{
			dp0[i][j]=eq(A[0][i],A[2][j])?dp0[i+1][j+1]+1:0;
		}
		for(int i=A[1].size();i--;)for(int j=A[2].size();j--;)
		{
			dp1[i][j]=eq(A[1][i],A[2][j])?dp1[i+1][j+1]+1:0;
		}
		vector<int>ok;
		for(int i=0;i<=A[0].size();i++)
		{
			bool flag=true;
			for(int j=0;j<A[1].size();j++)
			{
				if(i+j<A[0].size())
				{
					if(!eq(A[0][i+j],A[1][j]))
					{
						flag=false;
						break;
					}
				}
				else break;
			}
			if(flag)ok.push_back(i);
		}
		for(int st:ok)
		{
			int len=st+max((int)A[0].size()-st,(int)A[1].size());
			for(int i=0;i<=len;i++)
			{
				bool flag=true;
				if(i<A[0].size())
				{
					if(dp0[i][0]<min((int)A[0].size()-i,(int)A[2].size()))flag=false;
				}
				if(i<st)
				{
					int z=st-i;
					if(dp1[0][z]<min((int)A[1].size(),(int)A[2].size()-z))flag=false;
				}
				else if(i-st<A[1].size())
				{
					int y=i-st;
					if(dp1[y][0]<min((int)A[1].size()-y,(int)A[2].size()))flag=false;
				}
				if(flag)
				{
					ans=min(ans,len+max(0,(int)A[2].size()-(len-i)));
				}
			}
		}
	}while(next_permutation(A.begin(),A.end()));
	cout<<ans<<endl;
}


Measured memory_bytes: 32128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int N;
    cin >> N;

    vector<int> a;
    inputVector(a, 5);

    int ret = 0;
    rep(i, 5) {
        ret = max(ret, (N + a[i] - 1) / a[i] + 4);
    }

    cout << ret << endl;
}


Measured memory_bytes: 256
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,a[N],ans,vis[N],t;
signed main(){
	n=read();
	F(i,1,n) a[i]=read();
	sort(a+1,a+n+1);
	D(ci,31,0){
		t=1LL<<ci;
		int r=n;
		F(i,1,n){
			while ((a[i]+a[r]>t||vis[r])&&r) r--;
			if (a[i]+a[r]==t&&vis[i]==0&&r>i) vis[i]=vis[r]=1,ans++;
		}
	} 
	wrn(ans);
	return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#include <algorithm>
#include <iomanip>
#define ll long long
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = (0) ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define mod (1000000000 + 7)
#define sz(a) int((a).size())
#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 ss second
#define ff first
using namespace std;


int lg2(ll n)
{
	int res = -1 ;
	while(n)
	{
		n >>= 1;
		res++ ;
	}
	return res ;
}


int main()
{
	// HOW DO I REDUCE THIS TO O(Lg(N)) ???
	// ios::sync_with_stdio(0);	
	string s;
	cin >> s;
	ll ans = 0 ;
	std::vector<int> pos;
	ll n = s.length() ;
	rep(i,s.length())
		if(s[i] == 'W')
			pos.pb(n-i) ;
	sort(all(pos));
	reverse(all(pos));
	/*for(auto it : pos)
		cout << it << " " ;
	cout << endl ;*/
	rep(i,pos.size())
		ans += (n-- - pos[i]) ;
	cout << ans ;

}
			
		
		
			
		
			
			
	


Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b,h,ans;
    cin >> a >> b >> h;
    ans = (a + b) * h / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  double res = 0;
  for (int i = 1; i <= n; ++i) {
    if (i >= k) res += 1;
    else {
      res += pow(0.5, __lg(2 * ((k + i - 1) / i) - 1));
    }
  }
  res /= n;
  cout << fixed << setprecision(15) << res << '\n';
}

Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

//Amidakuji
public class Main{

	class R implements Comparable<R>{
		int height, l, r, sl, sr, lid, rid;
		int L, R;
		public R(int h, int l, int r) {
			this.height = h;
			this.l = l;
			this.r = r;
			sl = sr = -1;
		}
		public int compareTo(R o) {
			return height-o.height;
		}
		int find(boolean isLeft, int K){
			if(isLeft){
				L = K;
				if(rid+1<stick[r].size()){
					R next = stick[r].get(rid+1);
					if(next.l == r)sl = next.find(true, K);
					else sl = next.find(false, K);
				}
				else sl = s[r];
				return sl;
			}
			R = K;
			if(lid+1<stick[l].size()){
				R next = stick[l].get(lid+1);
				if(next.l == l)sr = next.find(true, K);
				else sr = next.find(false, K);
			}
			else sr = s[l];
			return sr;
		}
	}
	
	int[] s;
	int n, m, h, k;
	List<R>[] stick;
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			n = sc.nextInt(); m = sc.nextInt(); h = sc.nextInt(); k = sc.nextInt();
			if((n|m|h|k)==0)break;
			s = new int[n+1];
			for(int i=1;i<=n;i++)s[i] = sc.nextInt();
			stick = new List[n+1];
			for(int i=1;i<=n;i++)stick[i] = new ArrayList<R>();
			for(int i=0;i<m;i++){
				int left = sc.nextInt(), height = sc.nextInt();
				R r = new R(height, left, left+1);
				stick[left].add(r); stick[left+1].add(r);
			}
			for(int i=1;i<=n;i++)Collections.sort(stick[i]);
			for(int i=1;i<=n;i++)for(int j=0;j<stick[i].size();j++){
				if(stick[i].get(j).l==i)stick[i].get(j).lid = j;
				else stick[i].get(j).rid = j;
			}
			int sum = 0;
			int[] p = new int[n+1];
			for(int i=1;i<=n;i++){
				if(stick[i].isEmpty()){
					p[i] = s[i];
					if(i<=k)sum+=s[i];
				}
				else {
					R r = stick[i].get(0);
					if(r.l == i)p[i]= r.find(true, i);
					else p[i] = r.find(false, i);
					if(i<=k)sum += p[i];
				}
			}
			int min = sum;
			for(int i=1;i<=n;i++)for(int j=0;j<stick[i].size();j++){
				R r = stick[i].get(j);
				int dif = sum;
				if(r.L<=k||r.R<=k){
//					System.out.println("Remove!:" + r.height+" "+r.l+"-"+r.r+" L:"+r.L+" R:"+r.R);
					if(r.L<=k){
						int ID = r.L;
						dif-=p[ID];
						if(r.lid+1<stick[r.l].size()){
							R next = stick[r.l].get(r.lid+1);
							if(next.l==r.l)dif += next.sl;
							else dif += next.sr;
						}
						else dif += s[r.l];
					}
					if(r.R<=k){
						int ID = r.R;
						dif-=p[ID];
						if(r.rid+1<stick[r.r].size()){
							R next = stick[r.r].get(r.rid+1);
							if(next.l==r.r)dif+=next.sl;
							else dif+=next.sr;
						}
						else dif+=s[r.r];
					}
				}
//				System.out.println("DIF "+dif);
				min = Math.min(min, dif);
			}
			System.out.println(min);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 19000
inf = 10**15
mod = 10**9+7
n,m = map(int, input().split())
tmp = n//2
for i in range(m):
    if i % 2 == 0:
        print('{} {}'.format(tmp-i//2, tmp+1+i//2))
    else:
        print('{} {}'.format(1+i//2, n-i//2-1))

Measured memory_bytes: 68676
// In the name of God

#include <bits/stdc++.h>

using namespace std;

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

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	int len = 1;
	vector<int> comps;
	vector<bool> tp;
	for(int i = 1; i < n; i++) {
		if(s[i] != s[i-1]) {
			tp.push_back( (s[i]-'0') ^ 1 );
			comps.push_back(len);
			len = 1;
		}
		else len++;
	}

	comps.push_back(len);
	tp.push_back((s[(int)s.length()-1]-'0'));

	int ans = 0;

	int go = 0;
	int ptr = 0;
	int sum = 0;

	for(int i = 0; i < comps.size(); i++) {
		if(tp[i]==0) go++;
		sum += comps[i];
		while(go>k) {
			if(tp[ptr]==0) go--;
			sum -= comps[ptr];
			ptr++;
		}
		if(tp[i]) {
			ans=max(ans, sum);
		}
	}

	if(go<=k) ans=max(ans, sum);

	for(int i = 0; i < tp.size(); i++) tp[i] = !tp[i];

	go = 0;
	ptr = 0;
	sum = 0;
	
	k--;

	if(k==0) {
		for(int i = 0; i < comps.size(); i++) {
			ans=max(ans, comps[i]);
		}
		cout << ans;
		exit(0);
	}

	for(int i = 0; i < comps.size(); i++) {
		if(tp[i]==0) go++;
		sum += comps[i];
		while(go>k) {
			if(tp[ptr]==0) go--;
			sum -= comps[ptr];
			ptr++;
		}
		if(tp[i]) {
			ans=max(ans, sum);
		}
	}

	if(go <= k) ans=max(ans, sum);

	cout << ans;

	return 0;
}


Measured memory_bytes: 1020
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl            '\n'
#define mem(a, n)       memset(a, n, sizeof(a))
#define repeat(i, n)    for(int i=0; i<n; i++)
#define Unique(n)       (n).erase(unique(all(n)), (n).end())
#define isPowerOfTwo(n) (n && !(n & (n - 1)))
#define NumofDigits(n)  ((int)log10(n)+1)
#define all(a)          a.begin(), a.end()

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
    #ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif /*ONLINE_JUDGE*/
}

int main(){
    quicken();

    int n, mini=INT_MAX, maxi=0; cin >> n;
    string str[n];
    map<string, int> s;
    repeat(i, n)
        cin >> str[i], s[str[i]]++;

    for(auto it:s) maxi = max(maxi, it.second);
    for(auto it:s)
        if(it.second==maxi) cout << it.first << endl;

    return 0;
}

unsigned long long pow(long long base, long long power){ /// mod?
    if(power==0) return 1;
    if(power==1) return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1) return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, n+1)
        if(isPrime[i]) c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 25472
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split()))).most_common()
ans=0
for i in range(len(a)):
  if a[i][0]<a[i][1]:
    ans+=a[i][1]-a[i][0]
  elif a[i][0]>a[i][1]:
    ans+=a[i][1]
print(ans)



Measured memory_bytes: 107428
#include<stdio.h>
int main(void)
{
	int a[3],j,temp,i;
	
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<2;i++){
		for(j=2;j>i;j--){
			if(a[j-1]>a[j]){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;
			}
		}
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);
	
	return 0;
}

//??????????????????;

Measured memory_bytes: 596
//////// Don't_be_late 
// https://atcoder.jp/contests/abc177/tasks/abc177_a
// date: 2020-08-29T21:00:28.777315
// memo: 

//<editor-fold desc="my macro">

#include<bits/stdc++.h>
#ifdef LOCAL
    #include<my/dump.h>
#else
    #define dump(...) 42 
    #define dumpi(x) 42 
#endif

typedef long long ll;
using namespace std;

#define repe(x, a) for(auto& (x) : (a))
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rep3(i, a, b) for(ll i=a, i##_len=(b);i<i##_len;i++)
#define _rep2(i, n) _rep3(i,0,n)
#define repd(...) _overload3(__VA_ARGS__,_repd3,_repd2,)(__VA_ARGS__)
#define _repd3(i, a, b) for(ll i=b-1, i##_len=(a);i>=i##_len;i--)
#define _repd2(i, n) _repd3(i,0,n)
#define loop(...) _overload3(__VA_ARGS__,,_loop2,_loop1)(__VA_ARGS__)
#define _loop2(i, a) for(ll i=a;; i++)
#define _loop1(i) _loop2(i,0)

#define all(x) x.begin(),x.end()
#define SIZE(x) ((ll)(x).size())

#define F first
#define S second
#define vec vector
#define umap unordered_map
#define uset unordered_set

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

#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define inrange(x,start,stop) ((start) <= (x) && (x) < (stop))
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; }

template <typename Cont, typename Func>
Cont fmap(const Cont &container, Func functor) {
    Cont result(container.size());
    std::transform(container.begin(), container.end(), result.begin(), functor);// [](int x){return x * 2;}
    return result;
}
template <typename Cont, typename Pred>
Cont filter(const Cont &container, Pred predicate) {
    Cont result;
    std::copy_if(container.begin(), container.end(), std::back_inserter(result), predicate);// [](int x){return x == 2;}
    return result;
}   

template<typename T, typename ...Args>
void ci(T& first, Args&... args) {
    ((cin >> first), ..., (cin >> args)); //C++17
}

template<char Sep, typename T, typename ...Args>
void print_seq(const T& first, const Args&... args) {
    ((cout << first), ..., (cout << Sep << args)); //C++17
}

void co(){ cout << endl; }
template<typename... Words>
void co(Words... words) {
    print_seq<' '>(words...);
    cout << endl;
}
#define coi(x) cout<<(x)<<" "

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define sankou(n,a,b) cout << ((n) ? (a) : (b) ) << endl

#define asrt(expr...) assert((expr))
//</editor-fold>

#define INF 1e19
#define MOD 1e9+7
#define MAXR 1e5

int solve() {
    ll D,T,S;
    ci(D,T,S);
//    co(D <= T * S );
    Yes(D <= T * S );
    return 0;

}

int main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    
    solve();
    return 0;
}


Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		ArrayList<Integer> lifeList = new ArrayList<>();
		long ans = 0;
		
		for(int i = 0; i < N; i++) {
			lifeList.add(sc.nextInt());
		}

		lifeList.sort(Comparator.reverseOrder());
		int attackTimes = Math.min(K, N); 
		
		for(int i = attackTimes; i < lifeList.size(); i++) {
			ans += lifeList.get(i);
		}

		System.out.println(ans);
		sc.close();
	}
	
}

Measured memory_bytes: 92228
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
void reverse(char A[],int left,int right)
{
	char signal;
	for(int i=left;i<left+(right-left)/2;i++)
{
	signal=A[i];
	A[i]=A[right+left-i-1];
	A[right+left-i-1]=signal;
}
}
int main()
{
	char S[100];
	char T[100];
	char cmp[100];
	char sign;
	scanf("%s",&S);
	scanf("%s",&T);
	int len1=strlen(S);
	int len2=strlen(T); 
	reverse(S,0,len1);
    for(int i=1;i<=len1;i++)
   {
	reverse(S,i,len1);
    reverse(S,0,i);
	if(!strcmp(S,T))
	{
	cout<<"Yes";
	return 0;
}
     reverse(S,i,len1);
     reverse(S,0,i);
    
}
	cout<<"No";
}

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

int main() {
  ll n; cin >> n;
  priority_queue <pair <ll, ll>> pq;
  rep(i, n) {
    ll a; cin >> a;
    pq.push(make_pair(a, 0));
  }
  ll res = 0;
  rep(i, n-1) {
    pair <ll, ll> p = pq.top(); pq.pop();
    if (res == 0) {
      res += p.first;
      continue;
    }
    res += p.first;
    p.second++;
    if (p.second == 2) continue;
    else pq.push(p);
  }
  cout << res << endl;
}

Measured memory_bytes: 7464
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N=100001;

vector<ll> fact;

void init(ll N){
  fact.resize(N+1);
  fact[0]=1;
  rep(i,N)  fact[i+1]=((i+1)*fact[i])%mod;
}

ll pow(ll a,ll b){
  // aのb乗を求める
  ll res = 1;
  while(b){
    if(b%2) res=(res*a)%mod;
    a=(a*a)%mod;
    b>>=1;
  }
  return res;
}

ll imod(ll n){
  // nのmodの逆元を求める
  ll P=mod;
  return pow(n,P-2);
}

ll comb_mod(ll n,ll k){
  return (fact[n] * imod(fact[k]) % mod) * imod(fact[n-k]) % mod ;
  //nCk % mod を返す
}

int main(){
  ll N,M;
  cin >> N >> M ;
  init(N+M+2);
  if(abs(N-M)>1){
    cout << "0" << endl;
  }else if(abs(N-M)==1){
    cout << (fact[N]*fact[M])%mod << endl;
  }else{
    cout << ((fact[N]*fact[M])%mod)*2%mod << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
void solve(){
	int n,K,x,y,p,q;
	cin>>n>>K;
	vector<int>A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	vector<bool>dp(K+1);
	for(int k=1;k<=K;k++){
		for(int i=0;i<n;i++){
			if(A[i]>k) break;
			dp[k]=1-dp[k-A[i]];
			if(dp[k]) break;
		}
	}
	if(dp[K]) cout<<"First";
	else cout<<"Second";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace  std;
#define f(i,n) 		for(i=0;i<n;i++)
#define fr(i,n,a) 	for(i=n;i>=a;i--)
#define fa(i,a,n) 	for(i=a;i<n;i++)
#define deb(x)		cout<<#x<<" "<<x<<endl;
#define deb2(x,y)	cout<<#x<<","<<#y<<" "<<x<<","<<y<<endl;
#define buf(x)		cout<<"Check"<<x<<endl;
#define ll			long long int 
#define ft			first
#define s			second
#define pb			push_back
#define mp			make_pair
#define do			double
#define all(v)		v.begin(),v.end()	
#define et(v)		for(auto itr:v)
#define mod			1000000007
inline void p(vector<ll> x,int n)	{	int i;f(i,n)cout<<x[i]<<" ";cout<<endl; }
 

 
void solve()
{  	
	ll N,M,i,j,sum=1,pos,neg=0,z=0;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll res;
	if(b<0&&d<0)
	{
		res=(a*c);
	}
	else if(a>=0&&c>=0)
		res=(b*d);	
	else
	{
		res=LLONG_MIN;
		res=max(res,(a*c));
		res=max(res,(a*d));
		res=max(res,(b*c));
		res=max(res,(b*d));
	}


	cout<<res;

	
}
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	ll t=1,c=1;
	//cin>>t;
	while(t--)
	{
		
 
		//cout<<"Case #"<<c++<<": "<<endl;
		solve();
		cout<<"\n";
		
	}
	return 0;
}

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

void main_()
{
    string O, E;
    cin >> O >> E;
    for (size_t i = 0; i < E.size(); i++) {
        cout << O[i] << E[i];
    }
    if (O.size() != E.size()) {
        cout << O.back();
    }
    cout << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

const ll V = 100005;
ll dp[105][V];

int main(void){
  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  REP(i, N) cin >> w[i] >> v[i];
  REP(i, N+1) REP(j, V) dp[i][j] = INF;
  dp[0][0] = 0;
  REP(i, N){
    REP(j, V){
      chmin(dp[i+1][j], dp[i][j]);
      if(j+v[i] < V) chmin(dp[i+1][j+v[i]], dp[i][j]+w[i]);
    }
  }
  ll ans;
  REP(i, V) if(dp[N][i] <= W) ans = i;
  cout << ans << endl;
  return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt(),a=sc.nextInt();
        for(int i=1;i<n;i++){
            int b=sc.nextInt();
            a=a*b/gcd(a,b);
        }
        System.out.println(a);
    }
    
    static int gcd(int a,int b){
        if(a<b) return gcd(b,a);
        if(b==0) return a;
        return gcd(b,a%b);
    }
}



Measured memory_bytes: 26232
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-24 21:18:00
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

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

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int64 k, a, b; cin >> k >> a >> b;

  if (k + 1 > a) {
    int64 ans = 1;
    k -= (a - 1);
    ans += (a - 1);
    cout << max(ans + k, ans + (b - a) * (k / 2) + (k & 1)) << endl;
  } else {
    cout << k + 1 << endl;
  }

  return 0;
}

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

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

char X, Y;
int main() {
    std::cin >> X >> Y;
    std::cout << (X > Y ? ">" : X < Y ? "<" : "=") << std::endl;
}

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

void solve(){
	int a, b;
	cin >> a >> b;
	cout << a * b;
}

main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

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

int main(void)
{
  string s;
  cin >> s;

  int count=0;
  char c;
  for(auto i=s.begin(); i!=s.end(); i++){
      if(i==s.begin())
        c=*i;
      else{
          if(*i!=c){
              c=*i;
              count++;
          }
      }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,a,x;
    int in;
    double r,c,mi;
    cin>>n;
    cin>>t>>a;
    mi=1000000.0;
    for(int i=0; i<n; i++)
        {
        cin>>x;
        r=t-(x*0.006);
        c=abs(a-r);
        if(mi>c)
        {
            mi=c;
            in=i;
        }
}
    cout<<in+1<<endl;
}

Measured memory_bytes: 256
a = list(input())
b = list(input())
c = list(input())

cards = {'a':a, 'b':b, 'c':c}
turn = 'a'
while True:
    #print(cards[turn])
    if len(cards[turn]) == 0:
        print(turn.upper())
        break
    turn = cards[turn].pop(0)

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

#define el '\n'
#define MOD 1000000007

int n;
pair<int,int> arr[200005];

bool cmp(pair<int,int> a, pair<int,int> b){
    if(a.second==b.second){
        return a.first < b.first;
    } else {
        return a.second < b.second;
    }
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i=1;i<=n;i++){
        int a,b;
        cin >> a >> b;
        arr[i] = make_pair(a, b);
    }
    sort(arr+1,arr+1+n, cmp);

    bool can=true;
    if(n==1){
        if(arr[1].first > arr[1].second){
            can=false;
        }
    } else {
        int spent=0;
        for(int i=1;i<=n;i++){
            if(spent+arr[i].first <= arr[i].second){
                spent += arr[i].first;
            } else {
                can=false;
                break;
            }
        }
    }
    string res = (can) ? "Yes" : "No";
    cout << res << el;
    return 0;
}

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

int main(){
    string s;
    cin>>s;
  if((s[2]==s[3])&&(s[4]==s[5])){
    	cout<<"Yes"<<endl;
  }
 else{
   cout<<"No"<<endl;
 }
}

Measured memory_bytes: 256