akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int,input().split()))

counter1 = 0
counter2 = 0
for i in range(N):
    if A[i] % 2 == 0:
        counter1 += 1
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            counter2 += 1
if counter1 == counter2:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
// こだわり者いろはちゃん
#include <iostream>
#include <vector>
using namespace std;

int n,k,x;
bool f[10];

bool ok(int x){
    while(x){
        if(f[x%10]) return false;
        x/=10;
    }
    return true;
}

int main(){
    for(cin>>n>>k;k--;){
        cin>>x;
        f[x]=true;
    }
    while(!ok(n))n++;
    cout<<n<<endl;
}

Measured memory_bytes: 256
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

void solve() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    for (auto &x : a)
        cin >> x;

    int sum = 0;
    sort(all(a));
    FOR(i, 0, k) {
        sum += a[i];
    }
    cout << sum << '\n';
}

int main() {
    io;
    int t = 1;
    //cin >> t;
    tc(t) {
        solve();
    }
}
//check for edge cases in limits
//printing double may print 1.223232e9 like values, beware of that


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

bool is_ss(string s){	// 文字列の長さは偶数でなければならない。
	int n = s.length();

	rep (i, n / 2){
		if (s[i] != s[i + n / 2]){
			return false;
		} //end if
	} // end rep

	return true;
}

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

	string S; cin >> S;

	if ((int)S.length() % 2 != 0){
		S = S.substr(0, (int)S.length() - 1);
	}else{
		S = S.substr(0, (int)S.length() - 2);
	} // end if

	int res = 0;
	while((int)S.length() > 0){
		if (is_ss(S)){
			res = (int)S.length();
			break;
		} // end if
		S = S.substr(0, (int)S.length() - 2);
	} // end while

	cout << res << endl;

	return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;
int item[3010][3010];
ll dp[3010][3010][4];

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int r, c, k;
  cin >> r >> c >> k;
  
  rep(i, 0, 3010){
    rep(j, 0, 3010){
      item[i][j] = -1;
      rep(d, 0, 4){
        dp[i][j][d] = 0;
      }
    }
  }
  
  rep(i, 0, k){
    int x, y;
    cin >> x >> y;
    x--;y--;
    cin >> item[x][y];
  }
 
  rep(i, 0, r){
    rep(j, 0, c){
      rep(d, 0, 4){
        llchmax(dp[i][j+1][d], dp[i][j][d]);
        llchmax(dp[i+1][j][0], dp[i][j][d]);
        
        if(item[i][j] == -1 || d == 3){
          continue;
        }
       
        ll v = item[i][j];
        llchmax(dp[i+1][j][0], dp[i][j][d] + v);
        llchmax(dp[i][j+1][d+1], dp[i][j][d] + v);
        
      }
    }
  }
  
  cout << dp[r][c-1][0] << endl;
  
  return 0;
  
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int,int>>data(N);
  for(int i=0;i<N;i++){
    cin >> data.at(i).first >> data.at(i).second;
  }
  
  vector<int>order(N);
  for(int i=0;i<N;i++){
    order.at(i)=i;
  }
  
  sort(data.begin(),data.end());
  long double ans=0;
  do{
    for(int i=0;i<N-1;i++){
      long double a=sqrt((data.at(i).first-data.at(i+1).first)*(data.at(i).first-data.at(i+1).first)+(data.at(i).second-data.at(i+1).second)*(data.at(i).second-data.at(i+1).second));
      ans+=a;
    }
  }while(next_permutation(data.begin(),data.end()));
  long double waru=1;
  for(long double i=1;i<=N;i++){
    waru*=i;
  }
  cout << setprecision(20) << ans/waru;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> nin(n);
	for(int i=0; i<n; i++){
    	cin >> nin.at(i);
    }
	sort(nin.begin(), nin.end());
	int f = 0;
	long anser = 1;
	if(n%2 == 0){
    	for(int i=0; i<n/2; i++){
        	if(!(nin.at(i*2) == i*2+1 && nin.at(i*2+1) == i*2+1)){
            	f = 1;
            	break;
            }
        }
    	if(f == 0){
        	for(int i=0; i<n/2; i++){
            	anser *= 2;
            	if(anser >= 1000000007){
                	anser = anser%1000000007;
                }
            }
            cout << anser << endl;
        }else{
            cout << 0 << endl;
        }
    }else{
    	if(nin.at(0) != 0){
        	f = 1;
        }
    	for(int i=0; i<(n-1)/2; i++){
        	if(!(nin.at(i*2+1) == i*2+2 && nin.at(i*2+2) == i*2+2)){
            	f = 1;
            	break;
            }
        }
        if(f == 0){
        	for(int i=0; i<(n-1)/2; i++){
            	anser *= 2;
            	if(anser >= 1000000007){
                	anser = anser%1000000007;
                }
            }
            cout << anser << endl;
        }else{
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 640
def buble(C):
	for i in range(len(C)):
		for j in range(len(C)-1,i,-1):
			if int(C[j][-1]) < int(C[j-1][-1]):
				C[j],C[j-1] = C[j-1],C[j]
	return C
	
def selection(C):
	for i in range(len(C)):
		mini = i
		for j in range(i,len(C)):
			if int(C[j][-1]) < int(C[mini][-1]):
				mini = j
		C[i],C[mini] = C[mini],C[i]
	return C

n = int(raw_input())
card = map(str, raw_input().split())
card1 = card[:]
buble(card);selection(card1)
print " ".join(map(str, card))
print "Stable"
print " ".join(map(str, card1))
print "Stable" if card == card1 else "Not stable"

Measured memory_bytes: 4268
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int a[32]={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: 256
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for _ in range(n):
  b=int(input())
  for i in range(3):
    for j in range(3):
      if a[i][j]==b:
        a[i][j]=-1
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==-1:
    print('Yes')
    exit()
  if a[0][i]==a[1][i]==a[2][i]==-1:
    print('Yes')
    exit()
if a[0][0]==a[1][1]==a[2][2]==-1 or a[0][2]==a[1][1]==a[2][0]==-1:
  print('Yes')
  exit()
print('No')

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <iomanip> 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<ull> vul;
typedef vector<pair<ll, ll>> vpl;
typedef pair<ll, ll> pl;
#define For(i, n) for(ll i = 0; i < n; i++)
#define len(n) (ll)(n).size()
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
vector<vl> g;
vb used;
vl ts;
ll dp[(ll)1e5];
void dfs(ll v) {
	used[v] = true;
	for (ll to : g[v]) {
		if (!used[to]) {
			dfs(to);
		}
	}
	ts.push_back(v);
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n, m, a, b;
	cin >> n >> m;
	g.resize(n);
	used.resize(n);
	For(i, m) {
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
	}
	For(i, n) {
		if (!used[i]) {
			dfs(i);
		}
	}
	Reverse(ts);
	ll ans = 0;
	for (ll i : ts) {
		for (ll to : g[i]) {
			dp[to] = max(dp[to], dp[i] + 1);
			ans = max(ans, dp[to]);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 12360
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using Graph = std::vector<std::vector<int>>;

struct UnionFind {
    std::vector<int> par, sz;
    int gnum;

    explicit UnionFind(int n)
        : par(n), sz(n, 1), gnum(n) {
        std::iota(par.begin(), par.end(), 0);
    }

    int find(int v) {
        return (par[v] == v) ? v : (par[v] = find(par[v]));
    }

    void unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return;

        if (sz[u] < sz[v]) std::swap(u, v);
        sz[u] += sz[v];
        par[v] = u;
        --gnum;
    }

    bool same(int u, int v) { return find(u) == find(v); }
    bool ispar(int v) { return v == find(v); }
    int size(int v) { return sz[find(v)]; }
};

using lint = long long;

constexpr int C = 100000;

void solve() {
    int n;
    std::cin >> n;

    std::vector<std::vector<int>> vss(C);
    std::vector<int> cs(n);
    for (int v = 0; v < n; ++v) {
        auto& c = cs[v];
        std::cin >> c;
        vss[--c].push_back(v);
    }

    Graph graph(n);

    int m;
    std::cin >> m;
    while (m--) {
        int u, v;
        std::cin >> u >> v;
        --u, --v;

        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    UnionFind uf(n);
    for (int u = 0; u < n; ++u) {
        auto& es = graph[u];
        std::sort(es.begin(), es.end(),
                  [&](int v, int w) { return cs[v] < cs[w]; });

        for (auto v : es) {
            if (cs[v] == cs[u]) uf.unite(u, v);
        }

        for (int i = 0; i + 1 < (int)es.size(); ++i) {
            int v = es[i], w = es[i + 1];
            if (cs[v] == cs[w]) uf.unite(v, w);
        }
    }

    std::vector<lint> maxs(n, -1), gmax(n, -1), ans(n, 1);
    for (const auto& vs : vss) {
        for (auto v : vs) {
            for (auto u : graph[v]) {
                ans[v] = std::max(ans[v], maxs[u] + 1);
            }
            int gv = uf.find(v);
            gmax[gv] = std::max(gmax[gv], ans[v]);
        }

        for (auto v : vs) {
            ans[v] = std::max(ans[v], gmax[uf.find(v)]);
            maxs[v] = std::max(maxs[v], ans[v]);
            for (auto u : graph[v]) {
                maxs[u] = std::max(maxs[u], ans[v]);
            }
        }
    }

    std::cout << std::accumulate(ans.begin(), ans.end(), 0LL)
              << std::endl;
}

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

    solve();

    return 0;
}



Measured memory_bytes: 17936
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll A, B, C;
	cin >> A >> B >> C;
	cout << B + min(A + B + 1, C) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
vector<vector<char>> Sdata;
int H, W, K;

int MaxVerticalBar (int offset, vector<int> RegionEdge, int BarNumber)
{
	int MAX = offset;
	vector<int> Chocolates (BarNumber+1, 0);
	int ChocoEnd = 0;		

	for (MAX = offset; MAX < W; MAX++)
	{
		for (int i = 0; i <= BarNumber; i++)
			for (int i2 = RegionEdge[i]; i2 < RegionEdge [i+1]; i2++)
			{	
				Chocolates [i] += (int) (Sdata [i2] [MAX] - '0');
				if (Chocolates [i] > K)
				{
					if (MAX != 0)
						return MAX-1;
					else
						return 0;
				}
			}
	}
	return MAX;
};

int main(void)
{
    cin >> H >> W >> K;
    Sdata.resize (H);
    for (auto& e: Sdata)
    {
    	e.resize (W);
    	for (auto& e2: e)
 			cin >> e2;
 	}

	int BarNumber = 0;
	vector<int> RegionEdge (H+1, 0);
	int WorldRecord = H + W;
	for (int UnderBar = 0; UnderBar < (1 << (H-1)); UnderBar++)
	{
		BarNumber = 0;
		for (int i = 0; i < H; i++)
		{
			if (((UnderBar >> i) & 1) != 0)
			{
				RegionEdge [BarNumber+1] = i+1;
				BarNumber++;
			}
		}
		RegionEdge [BarNumber+1] = H;

		if (BarNumber < WorldRecord)
        {
          int answer = BarNumber;
		  for (int offset = 0; offset < W; offset++)
		  {
			  int VerticalBar;
			  VerticalBar = MaxVerticalBar (offset, RegionEdge, BarNumber);
			  if (VerticalBar != W)
			    answer++;
			  if (WorldRecord <= answer)
			    break;
			  offset = VerticalBar;
		  }
		  WorldRecord = answer;
		}
	}
	
	cout << WorldRecord << endl;
}


Measured memory_bytes: 504
using System;


namespace _007_DebtHell
{
	class Program
	{
		static void Main ( string[] args )
		{
			int weekCount = int.Parse (Console.ReadLine ());

			double debt = 100000;

			for (int lp = 0; lp < weekCount; lp++)
			{
				double adddebt = Math.Ceiling (debt * 0.05 / 1000) * 1000;
				debt += adddebt;
			}

			Console.WriteLine (debt);
		}
	}
}

Measured memory_bytes: 9204
/*
 * Created by Dipta Das on 20-04-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

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

    int a, b, c;
    cin >> a >> b >> c;
    int mn = min(a, b);
    int mx = max(a, b);

    if (c >= mn && c <= mx) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    


    return 0;
}



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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
 
 string s,t;
 cin>>s>>t;
 int ans=0;
 rep(i,s.size()){
   if(s[i]!=t[i]) ans++; 
 }
 cout<<ans;
   return 0;
}



Measured memory_bytes: 3856
//Keep Working Hard
  // I__Like__Food
  #include<bits/stdc++.h>
  #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast") 
  #pragma GCC optimize("unroll-loops")
  using namespace std;
  using namespace __gnu_pbds;
  #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 PB push_back
  #define MP make_pair
  #define double 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 998244353
  #define N 305
  #define INF 1e16
  const double PI = acos(-1);

int32_t main()
{



   int n;
   cin >> n;

    map<int,int> mp;
    int arr[n+1];

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


   vector<pair<int,int>> v;

   for(auto i: v)
   {
    v.PB(MP(i.first,i.second));

   }

   int sum = 0;

   for(auto i : mp)
   {
   // cout << i.first << " " << i.second << endl;
    int k = i.second;

    sum += (k)*(k-1)/2;
   }


   

   for(int i = 1; i <= n; i++)
   {
   // cout << arr[i] << endl;
      int k = mp[arr[i]];
    cout <<  sum - k*(k-1)/2 + (k-1)*(k-2)/2 << endl;
   }


  return 0;
} 

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

using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

const ll MAX_V = 1010;
using Pll = pair<ll,ll>;
vector<vector<Pll>> G;

vector<ll> d(MAX_V);
ll V; //number of vertex
ll E; //number of edge

bool bf(){
    for(int i=0;i<=V*2;i++){
        for(int v=0;v<V;v++){
            for(auto e : G[v]){
                if(d[e.first]>d[v]+e.second){
                    d[e.first]=d[v]+e.second;
                    if(i==V*2 && e.first==V-1) return true;
                }
            }
        }
    }
    return false;
}


int main() {
    
    cin >> V >> E;
    fill(d.begin(),d.end(),INF);
    d[0]=0;

    G.assign(V,vector<Pll>());
    for(int i=0;i<E;i++){
        ll x,y,cost;
        cin >> x >> y >> cost;
        x--;y--;
        G[x].push_back(Pll(y,-cost));
    }

    if(bf()){
        cout << "inf" << endl;
    }
    else{
        cout << -d[V-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
  int N,A,res=0;

  scanf("%d",&N);

  scanf("%d",&A);

  res=(N*N)-A;

  printf("%d",res);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
const int M = 1e5;
int n, k;
vii v;
ll dp[100 + 9][M + 9];
ll sol(int i, int w) {
	if (w < 0)
		return -1e9;
	if (i == n)
		return 0;
	ll &ret = dp[i][w];
	if (~ret)
		return ret;
	return ret = max(v[i].second + sol(i + 1, w - v[i].first), sol(i + 1, w));
}
int main() {
	run();
	int w;
	cin >> n >> w;
	v.resize(n);
	lp(i,n)
		cin >> v[i].first >> v[i].second;
	clr(dp, -1);
	cout << sol(0, w);
	return 0;
}



Measured memory_bytes: 85376
aNs = []
3.times do
  aNs << gets.split.map(&:to_i)
end
n=gets.to_i
hitNumbers = n.times.map{gets.to_i}
bingoLists = [aNs[0],aNs[1],aNs[2]]
bingoLists << [aNs[0][2],aNs[1][1],aNs[2][0]]
bingoLists << [aNs[0][0],aNs[1][1],aNs[2][2]]
bingoLists += 3.times.map{|indexX| [aNs[0][indexX],aNs[1][indexX],aNs[2][indexX]] }
bingoLists += 3.times.map{|indexY| [aNs[indexY][0],aNs[indexY][1],aNs[indexY][2]] }
hit = 0
bingoLists.each do |bingo|
  hit = 0
  bingo.each do |number|
    hitNumbers.each do |hitNumber|
      hit += 1 if number == hitNumber
    end
  end
  break if hit == 3
end
puts hit == 3 ? "Yes" : "No"

Measured memory_bytes: 1788
#!/bin/env python
# coding: utf-8

import sys

def main():
    N = int(sys.stdin.readline().strip())
    s = sys.stdin.readline().strip()
    R = s.count('R')
    B = s.count('B')
    if R > B:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 2568
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	Long x = sc.nextLong();
      	long a = x / 500;
      	long b = (x%500)/5;
      	System.out.println(a*1000 + b*5);
    }
}

Measured memory_bytes: 35812
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
x = n // k+1
ans = 0
for i in range(k):
    ph = 0
    for j in range(x):
        if i + j * k >= n:
            break
        nh = t[i + j * k]
        if ph == nh:
            ph = 0
            continue
        elif nh == "r":
            ans += p
        elif nh == "s":
            ans += r
        elif nh == "p":
            ans += s
        ph = nh

print(ans)

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

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

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

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

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

using namespace std;

struct BipartiteMatching {
  vector< vector< int > > graph;
  vector< int > match, alive, used;
  int timestamp;

  BipartiteMatching(int n) : graph(n), alive(n, 1), used(n, 0), match(n, -1), timestamp(0) {}

  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }

  bool dfs(int idx) {
    used[idx] = timestamp;
    for(auto &to : graph[idx]) {
      int to_match = match[to];
      if(alive[to] == 0) continue;
      if(to_match == -1 || (used[to_match] != timestamp && dfs(to_match))) {
        match[idx] = to;
        match[to] = idx;
        return true;
      }
    }
    return false;
  }

  int bipartite_matching() {
    int ret = 0;
    for(int i = 0; i < graph.size(); i++) {
      if(alive[i] == 0) continue;
      if(match[i] == -1) {
        ++timestamp;
        ret += dfs(i);
      }
    }
    return ret;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      if(i < match[i]) {
        cout << i << "-" << match[i] << endl;
      }
    }
  }
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    BipartiteMatching bm(2*n);
    vector<pi> a(n),b(n);
    rep(i,n) cin>>a[i].fi>>a[i].se;
    rep(i,n) cin>>b[i].fi>>b[i].se;
    rep(i,n)rep(j,n){
        if (a[i].fi<b[j].fi && a[i].se<b[j].se){
            bm.add_edge(i,n+j);
        }
    }
    cout<<bm.bipartite_matching()<<"\n";
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    sort(x.rbegin(),x.rend());
    int a = 0,b = 0;
    rep(i,n){
        if(i%2 == 0) a += x[i];
        else b += x[i];
    }
    cout << abs(a-b) << endl;
}

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

// tourist set
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 += "}";
  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 += "}";
  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)) + ")";
}

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 << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")
#define pb(s) push_back(s)
#define SZ(x) ((int)(x).size())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll N, K;
    cin >> N >> K;

    ll cnt=0;
    rep(i, N){
      ll h; cin >> h;
      if(h>=K) cnt++;
    }
    p(cnt);
    
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

type person struct {
	m map[int]int
}

func isok(persons []person, v []int, i int) bool {
	p := &persons[i]
	pv := v[i]
	for j := 0; j < i; j++ {
		if pv > 0 {
			// 正直者と仮定した場合は証言が矛盾しないことをチェック。
			if m, ok := p.m[j]; ok && m != v[j] {
				return false
			}
		}

		if v[j] > 0 {
			q := &persons[j]
			if m, ok := q.m[i]; ok && m != v[i] {
				return false
			}
		}
	}
	return true
}

func resolve(persons []person, v []int, i int) int {
	if i == len(v) {
		ans := 0
		for _, b := range v {
			if b > 0 {
				ans++
			}
		}
		// fmt.Printf("%+v\n", v)
		return ans
	}

	v[i] = 1
	ans0 := 0
	if isok(persons, v, i) {
		ans0 = resolve(persons, v, i+1)
	}

	v[i] = 0
	ans1 := 0
	if isok(persons, v, i) {
		ans1 = resolve(persons, v, i+1)
	}

	if ans0 > ans1 {
		return ans0
	}
	return ans1
}

func main() {
	var np int
	fmt.Scanf("%d\n", &np)

	persons := make([]person, np, np)
	for i := 0; i < np; i++ {
		var nm int
		fmt.Scanf("%d\n", &nm)
		person := &persons[i]
		person.m = make(map[int]int)
		for j := 0; j < nm; j++ {
			var p, m int
			fmt.Scanf("%d %d\n", &p, &m)
			person.m[p-1] = m
		}
	}

	v := make([]int, np, np)
	fmt.Print(resolve(persons, v, 0))
}

Measured memory_bytes: 512
import math

def main():
  pos=0
  n,k=map(int,input().split())
  nmen=1/n

  for i in range(1,n+1):
    ajs=(-(-math.log2(k/i)//1))
    if ajs<=0: ajs=0
    pos+=nmen*0.5**ajs
  #  print(ajs)
  print(pos)
  
if __name__ == "__main__":
  main()
    


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;

  if( a - 2*b > 0)
  {
    cout << a - 2 * b << endl;
  }
  else
  {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "unordered_set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<int,int>

typedef long long ll;
using namespace std;

string s, t;
int S[100001], T[100001], q, a, b, c, d;

int main() {
	cin >> s >> t;
	S[0] = T[0] = false;
	rep(s.size()) {
		S[i + 1] = S[i] + s[i] - 'A' + 1;
	}
	rep(t.size()) {
		T[i + 1] = T[i] + t[i] - 'A' + 1;
	}
	cin >> q;
	rep(q) {
		cin >> a >> b >> c >> d;
		if ((S[b] - S[a - 1]) % 3 == (T[d] - T[c - 1]) % 3)
			cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

long N,L[100],i;
inline void solve(){
  IN(N);
  L[0]=2;
  L[1]=1;
  if(N==1){
    OUT(L[1]);
    return;
  }
  UP(i,2,N){
    L[i]=L[i-1]+L[i-2];
  }
  OUT(L[N]);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


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

using namespace std;

int main()
{
    long long n,n1,ans=0;
    cin>>n;
    n1=n;
    for(long long i=2; i<=sqrt(n1); i++){
        if(n%i==0){
            long long c=0;
            while(n%i==0){
                n/=i;
                c++;
            }
            for(long long j=1;; j++){
                c-=j;
                if(c<0) break;
                ans++;
            }
        }
    }
    if(n!=1) ans++;
    cout<<ans;
}


Measured memory_bytes: 3676
n = int(input())
A = list(map(int, input().split()))
ans = 0
l, r = 0, 0
s = x = A[l]
flg = True
for l in range(n):
    while s == x and flg:
        r += 1
        if r == n:
            flg = False
            break
        s += A[r]; x ^= A[r]
    ans += r-l
    s -= A[l]
    x ^= A[l]
print(ans)

Measured memory_bytes: 24840
#include<iostream>
#include<cstdio>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<assert.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const ll INF=4223372036854775807,max_n=300005,mod=1e9+7;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
string s1,s2;
int count1;
int main()
{
	cin>>s1>>s2;
	for(int i=0;i<s1.size();i++)
	{
		if(s1[i]!=s2[i])
		{
			count1++;
		}
	}
	cout<<count1;
}

Measured memory_bytes: 3800
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <algorithm>
#include <functional>
using namespace std;



int main(){
	

	int i,j;
	int N,K;
	
	
	string S;

	cin >> S;
	if (S[S.size()-1] == '2' || S[S.size()-1] == '4' || S[S.size()-1] == '5' || S[S.size()-1] == '7' || S[S.size()-1] == '9'){
		cout << "hon" << endl;
	}
	if (S[S.size()-1] == '0' || S[S.size()-1] == '1' || S[S.size()-1] == '6' || S[S.size()-1] == '8' ){
		cout << "pon" << endl;
	}
	if (S[S.size()-1] == '3'){
		cout << "bon" << endl;
	}


	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
int main(){
  ll N,h,n;scanf("%lld",&N);
  for(h=1;h<=3500;h++){
    for(n=1;n<=3500;n++){
      if(4*h*n-N*n-N*h == 0) continue;
      if((N*h*n)%(4*h*n-N*n-N*h) == 0 && (N*h*n)/(4*h*n-N*n-N*h) > 0){
        printf("%lld %lld %lld\n",h,n,(N*h*n)/(4*h*n-N*n-N*h));
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3832
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: i128,
        b: i128
    };

    if (a + b).abs() % 2 == 0 {
        println!("{}", (a + b).abs() / 2);
    } else {
        println!("IMPOSSIBLE")
    }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#ifdef LOCAL
    freopen("input.in" , "r" , stdin);
#endif
    int n;
    string s;
    cin >> n >> s;

    int R = 0 , G = 0 , B = 0;
    for (char &c : s) {
        R += c == 'R';
        G += c == 'G';
        B += c == 'B';
    }

    long long ans = 1ll * R * G * B;
    for (int i = 0 ;i < n ;i++) {
        for (int j = i + 1 ;j < n ;j++) {
            if (s[i] == s[j]) continue;
            int d = j - i;
            if (j + d >= n) continue;
            ans -= s[j + d] != s[i] && s[j + d] != s[j];
        }
    }

    cout << ans;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 998244353;

ll N, S;
ll A[4000];
ll dp[3001][3001];

ll solve(){
    dp[0][0] = 1;
    REP(i, N){
        REP(j, 3001){
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 2) % MOD;
            if(j + A[i] <= 3000) dp[i + 1][j + A[i]] = (dp[i + 1][j + A[i]] + dp[i][j]) % MOD;
        }
    }
    return dp[N][S];
}

signed main(){
    cin >> N >> S;
    REP(i, N) cin >> A[i];
    PRINT(solve());
    return 0;
}

Measured memory_bytes: 74000
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

string s;
int x,y;
const int MAXN = 16010;
int dp[2][MAXN][MAXN];
const int BASE = MAXN/2;

int main() {
  IOS;
  cin >> s >> x >> y;

  vector<int> a;
  int cnt = 0;
  REP(i,s.size()) {
    if (s[i] == 'F') { cnt++; continue; }
    a.push_back(cnt);
    cnt = 0;
  }
  a.push_back(cnt);

  dp[0][0][BASE] = 1;
  dp[1][0][BASE] = 1;

  int d = 0; // x: 0, y: 1
  int counter[2] = { 0, 0 };

  REP(i,a.size()) {
    counter[d]++;
    cnt = counter[d];

    REP(j, MAXN) {
      if (dp[d][cnt-1][j]) {
        if (j+a[i] < MAXN) dp[d][cnt][j+a[i]] = 1;
        if (i > 0 && j-a[i] >= 0) dp[d][cnt][j-a[i]] = 1;
      }
    }
    d = !d; // 方向反転
  }

  Yes( dp[0][counter[0]][x+BASE] && dp[1][counter[1]][y+BASE] );
  return 0;
}

Measured memory_bytes: 62956
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<list>

using namespace std;


/*
//1
int main(){
	for(int i=0; i<7;i++){
		int a, b;
		cin >> a >> b;
		cout << a- b << endl;

	}

	return 0;
}
*/


//2
int main(){
	int t[4] = {6000, 4000, 3000, 2000};
	for(int i=0; i<4; i++){
		int T,n;
		cin >> T >> n;
		T--;
		cout << t[T]*n << endl;
	}

	return 0;
}


/*
//3
int main(){


	return 0;
}
*/

/*
//4
int main(){


	return 0;
}
*/

/*
//5
int main(){


	return 0;
}
*/

/*
//6
int main(){


	return 0;
}
*/

/*
//7
int main(){


	return 0;
}
*/

/*
//8
int main(){


	return 0;
}
*/

/*
//9
int main(){


	return 0;
}
*/

/*
//10
int main(){


	return 0;
}
*/




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

using namespace std;

int n, m;
int d[1000];
int c[1000];

int memo[1000][1000];

int rec(int day, int now)
{
	if (now == n) return 0;

	if (memo[day][now] >= 0) return memo[day][now];

	int res;

	if (n - now < m - day) {
		res = min(rec(day + 1, now + 1) + d[now] * c[day], rec(day + 1, now));
	} else {
		res = rec(day + 1, now + 1) + d[now] * c[day];
	}

	return memo[day][now] = res;
}

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

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

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

	memset(memo, -1, sizeof(memo));

	printf("%d\n", rec(0, 0));
}

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

int main(){
  int N,A;
  cin >> N;
  bool approved = true;
  for(int i=0;i<N;i++){
    cin >> A;
    if( A%2==0 && ( A%3!=0 && A%5!=0 ) ) approved = false;
  }
  
  if(approved) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 3584
input = readlines.map(&:to_i)
n, R = input.first, input[1..-1]
minv = R[0]
maxv = R[1] - R[0]

1.upto(n - 1) do |i|
  maxv = [maxv, R[i] - minv].max
  minv = [minv, R[i]].min
end

puts maxv

Measured memory_bytes: 25708
import itertools

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    l = [i for i in range(1, N+1)]
    l = list(itertools.permutations(l))
    
    a = 0
    for k, v in enumerate(l):
        if A == list(v):
            a = k+1
        
    b = 0
    for k, v in enumerate(l):
        if B == list(v):
            b = k+1
    return abs(a-b)

print(solve())

Measured memory_bytes: 8052
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        Strategy strategy = new MyStrategy();
        strategy.solve(out, sc);
        out.flush();
    }
}

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        int N = sc.nextInt();
        int K = sc.nextInt();
        int res = 0;
        for (int i=0; i<N; i++) {
            int h = sc.nextInt();
            if (h >= K) {
                res += 1;
            }
        }
        out.println(res);
    }
}

interface Strategy {
    void solve(PrintWriter out, FastScanner sc);
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 22328
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
long long combi(int n,int k){
    long long combi[100][100];
    combi[0][0]=1;
    for(int i = 1;i<60;i++){
        for(int j = 0;j<=i;j++){
            if(j==0||j==i) combi[i][j] = 1;
            else combi[i][j] = combi[i-1][j-1]+combi[i-1][j];
        }
    }
    return combi[n][k];
}
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    long long v[n];
    map<long long,int> mp;
    rep(i,n){
        cin >> v[i];
        mp[v[i]]++;
    }
    sort(v,v+n,greater<long long>());
    long long t;
    long double sum;
    long double ans=0;
    long long ans2 = 0;
    long double m;
    int cnt = 0;
    for(int i = a;i<=b;i++){
        t = v[i-1];
        sum = 0;
        rep(j,i){
            sum+=v[j];
        }
        m = i;
        if(ans*m<sum){
            ans=(sum/m);
            cnt=0;
            for(int j = i;j<n;j++){
                if(v[j]!=t) break;
                cnt++;
            }
            ans2 = combi(mp[t],cnt);
        }
        else if(ans*m==sum){
            cnt=0;
            for(int j = i;j<n;j++){
                if(v[j]!=t) break;
                cnt++;
            }
            ans2 += combi(mp[t],cnt);
        }
    }
    cout << setprecision(25) << ans << endl;
    cout << ans2 << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=1e9+7;
const int MAXN=1e5+9;
const double eps=1e-8;
const long double pi=3.1415926535897932384626433832795;
const long double e=2.71828182845904523536028747135266;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t=1;
    while(t--){
        string a;
        cin >> a;
        if(a=="AAA"||a=="BBB"){
            cout << "No" << endl;
        }
        else cout << "Yes" << 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 < (n); ++i)

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (auto &i : a) cin >> i;
  map<ll,ll> mp;
  rep (i,n) mp[a[i]]++;
  ll total = 0;
  for (auto i = mp.begin(); i != mp.end(); i++) total += mp[i->first] * (mp[i->first] - 1) / 2;
  rep (i,n) cout << total + 1 - mp[a[i]] << endl;
  return 0;
}

Measured memory_bytes: 11008
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //値を取得
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        
        for (int i = 0; i < S.length(); ++i){
            if (S.equals(T)){   //一致していればそこで終了
                System.out.println("Yes");
                return;
            }
            S = S.substring(S.length()-1, S.length()) + S.substring(0, S.length()-1);
        }

        System.out.println("No");

    }
}


Measured memory_bytes: 39336