akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long x = sc.nextLong();

		String burger = "P";

		len = new long[51];
		len[0] = 1;

		numOfPate = new long[51];
		numOfPate[0] = 1;
		for(int i = 1; i <= 50; i++){
			len[i] = 2*len[i - 1] + 3;
			numOfPate[i] = 2*numOfPate[i - 1] + 1;
		}

//		for(int i = 1; i <= 5; i++){
//			System.out.println("Lebel "+i + " length "+ len[i]+ " pate "+numOfPate[i]);
//
//			burger = "B" + burger + "P" + burger + "B";
//
//			System.out.println(burger);
//		}

		System.out.println(solve(n, x));
	}

	static long len[];
	static long numOfPate[];

	//endを食べた層の直後のindexとする
	static long solve(int level, long end){
		long mid = len[level]/2;

		if(end <= level ){
			return 0;
		}

		if(end >= len[level] - level){
			return numOfPate[level];
		}

		//左半分の区間
		long result = solve(level - 1, end - 1);

		//センター分加算
		if(end > mid){
			result++;

			//右半分加算
			result += solve(level - 1, end - mid - 1);
		}

		return result;
	}

}


Measured memory_bytes: 23124
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	vector<pair<int, pair<int,int>>>v;
	for (int i = 1; i <= 150; i++) {
		for (int j = i + 1; j <= 150; j++) {
			v.push_back({ i*i + j*j ,{i,j} });
		}
	}
	sort(v.begin(), v.end());
	cin >> H >> W;
	while (H) {
		bool flag = false;
		for (auto i : v) {
			if (flag) {
				cout << i.second.first << " " << i.second.second << endl;
				break;
			}
			if (i.second.first == H&&i.second.second == W) {
				flag = true;
			}
		}
		cin >> H >> W;
	}
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


int main() {
	ll N, K;
	cin >> N>>K;

	vector<ll> c(N + 1, 0);

	repn(i, K) {
		ll d;
		cin >> d;
		repn(j, d) {
			ll a;
			cin >> a;
			c[a]++;
		}
	}

	ll ans = 0;
	repn(i, N) {
		if (c[i] == 0) { ans++; }
	}

	cout << ans << endl;
	
	system("PAUSE");
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(10);
    //cout<<fixed;
    //cout.tie(NULL);
    int n,m;
    cin>>n;
    multiset<string>blue,red;
    for(int i=0;i<n;i++)
    {
        string t;
        cin>>t;
        blue.insert(t);
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        string t;
        cin>>t;
        red.insert(t);
    }

   int ans=-inf;

   for(auto i: blue)
   {
       if(red.count(i))
        ans=max(ans,(int)(blue.count(i)-red.count(i)));
       else
        ans=max(ans,(int)(blue.count(i)-0));
   }

   if(ans<0)
    ans=0;

   cout<<ans<<endl;

    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 P = pair<int, int>;
typedef long long ll;

int main() {
  ll n, k;
  cin >> n >> k;
  //コーナーケースk==0
  if(k == 0){
    cout << n * n << endl;
    return 0;
  }
  ll ans = n * n;
  //bを固定
  for (int b = 1; b <= n; b++){
    //kがb以上であればn個全てが該当するのでn個引く
    if(b <= k){
      ans -= n;
    //そうでない場合まずnをbで割った商の数×k個引く
    }else {
      int a = n / b;
      ans -= k * a;
      //nをbで割ったあまりとk-1の小さい方をさらに引く
      ans -= min(n % b, k - 1);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  long double l;
  cin >> l;
  long double temp = l / 3;
  cout << fixed << setprecision(10) << temp * temp * (l - temp * 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x, y;
	while (1){
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0)break;
		if (x <y){
			printf("%d %d\n", x, y);
		}
		else{
			printf("%d %d\n", y, x);
		}

	}
	return 0;
}

Measured memory_bytes: 2592
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int a,b;
  cin>>a>>b;
  if(b%a==0) cout<<a+b<<endl;
  else cout<<b-a<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
    ai = A[i] - 1
    ans += B[ai]
    if i > 0 and ai == A[i - 1] - 1 + 1:
        ans += C[A[i - 1] - 1]
    # print(ans)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  
  int sum=0;
  if(a>b) swap(a, b);
  while(a<0){
    sum+=c;;
    a++;
  }
  if(a==0) sum+=d;
  while(a<b){
    sum+=e;
    a++;
  }
  cout<<sum<<en
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int h, w;
const int N = 2010;
int f[N][N], lst[N], nxt[N], mn[N], mx[N], vis[N], ans;
string st[N];
int get_mn(int t) {return mn[t] = (mn[t] == t? t: get_mn(mn[t]));}
int get_mx(int t) {return mx[t] = (mx[t] == t? t: get_mx(mx[t]));}
int main()
{
    cin >> h >> w;
    for (int i = 0; i < h; ++ i) cin >> st[i];
    for (int i = 1; i < w; ++ i) f[0][i] = 1;
    for (int i = 1; i < h; ++ i)
        for (int j = 1; j < w; ++ j)
            f[i][j] = (((st[i][j] == st[i][j - 1]) ^ (st[i - 1][j] == st[i - 1][j - 1]))? 1: f[i - 1][j] + 1);
    ans = max(ans, max(h, w));
    for (int i = 0; i < h; ++ i)
    {
        for (int j = 0; j <= i + 1; ++ j) lst[j] = -1;
        for (int j = 1; j < w; ++ j) nxt[j] = lst[f[i][j]], lst[f[i][j]] = j;
        for (int j = 1; j < w; ++ j) mn[j] = mx[j] = j, vis[j] = 0;
        for (int j = i + 1; j >= 0; -- j)
        {
            for (int p = lst[j]; ~p; p = nxt[p])
            {
                int l = p, r = p;
                vis[p] = 1;
                if (vis[p - 1])
                {
                    l = get_mn(p - 1);
                    mn[p] = l;
                    mx[p - 1] = p;
                }
                if (vis[p + 1])
                {
                    r = get_mx(p + 1);
                    mx[p] = r;
                    mn[p + 1] = p;
                }
                ans = max(ans, (r - l + 2) * j);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k,a,b;
	cin>>k>>a>>b;
	bool flag=false;
	for(int i=a;i<=b;i++){
		if(i%k==0) flag=true;
	}
	cout<<(flag?"OK":"NG")<<'\n';
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
int DP[100001];
int main(){
  int N;
  cin>>N;
  DP[1]=1;
  DP[2]=2;
  DP[3]=3;
  DP[4]=4;
  DP[5]=5;
  DP[6]=1;
  DP[7]=2;
  DP[8]=3;
  DP[9]=1;
  DP[36]=1;
  DP[216]=1;
  DP[1296]=1;
  DP[7776]=1;
  DP[46656]=1;
  DP[81]=1;
  DP[729]=1;
  DP[6561]=1;
  DP[59049]=1;
  if(1<=N&&N<=9){
    cout<<DP[N]<<endl;
  }else{
    FOR(i,10,N+1){
		if(DP[i]==1){
			continue;
		}
      int mi=INF;
      int now=6;
      while(i-now>0){
        mi=min(mi,DP[i-now]);
        now*=6;
      }
      now=9;
      while(i-now>0){
        mi=min(mi,DP[i-now]);
        now*=9;
      }
      DP[i]=mi+1;
    }
    cout<<DP[N]<<endl;  
  }
  return 0;
}

Measured memory_bytes: 640
a, b , c, d = gets.split.map(&:to_i)

if c - a > 0
  start = c
else
  start = a
end

if d-b > 0
  fin = b
else
  fin = d
end

if fin - start > 0
  win = fin - start
else
  win = 0
end

puts win

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    int sumVote = accumulate(a.begin(), a.end(), 0);
    sort(a.begin(), a.end(), greater<int>());
    int borderline;
    if(sumVote % (4 * m) == 0){
        borderline = sumVote / 4 / m;
    }
    else{
        borderline = sumVote / 4 / m + 1;
    }

    for(int i = 0; i < m; i++){
        if(a[i] < borderline){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()

l = [0] * n
l2 = [0 if s[i]=='o' else 1 for i in range(n)]
def f(x,y):
    l[0]=x
    l[1]=y
    for i in range(2,n):
        l[i]=l[i-2]^l[i-1]^l2[i-1]
    if l[0] == l[n-2]^l[n-1]^l2[n-1] and l[1]==l[n-1]^l[0]^l2[0]:
        return True
    else: return False

if f(0,0):
    print(''.join(['S' if not l[i] else 'W' for i in range(n)]))
elif f(0,1):
    print(''.join(['S' if not l[i] else 'W' for i in range(n)]))
elif f(1,0):
    print(''.join(['S' if not l[i] else 'W' for i in range(n)]))
elif f(1,1):
    print(''.join(['S' if not l[i] else 'W' for i in range(n)]))
else:print(-1)

Measured memory_bytes: 5628
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	
	char S[3];
	scanf("%s", S);

	if (S[0] == S[1] || S[1] == S[2] || S[0] == S[2]) {
		printf("No");
	}
	else printf("Yes");



}

Measured memory_bytes: 128
//Name-Deepesh Bhatt
//Institute-IIT Dhanbad

#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define MOD 1E9+7
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a ,ll b)
{
    return a/gcd(a,b)*b;
}
ll power(ll a, ll n)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2);
    p = (p * p);
    if (n % 2)
        return (p * a);
    else
        return p;
}

int main()
{
    ios_base::sync_with_stdio(false);    //for fast I/O operation
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int sum=0;
    vector<int>v(m);
    for(int i=0;i<m;i++){
        cin>>v[i];
        sum+=v[i];
    }
    if(sum<=n){
        cout<<n-sum;
    } else
        cout<<-1;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int main() {
    int h;
    cin >> h;
    vector<int> a(h+1);
    for (int i=1; i<=h; i++)
        cin >> a[i];

    for (int i=1; i<=h; i++) {
        cout << "node " << i << ": ";
        cout << "key = " << a[i] << ", ";
        if (i != 1) {
            cout << "parent key = " << a[i/2] << ", ";
        }
        if (i * 2 <= h) {
            cout << "left key = " << a[i*2] << ", ";
        }
        if (i * 2 + 1 <= h) {
            cout << "right key = " << a[i*2+1] << ", ";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3124
s = gets.split('')

for i in 0..s.length-1 do
    if s[i] == "?" then
        
        if s[i+1] == "?" || s[i+1] == "D" then
            s[i] = "P"
        else
            s[i] = "D"
        end

        if i-1 >= 0 && s[i-1] == "P" then
            s[i] = "D"
        end
    end
end

puts s.join("")


Measured memory_bytes: 31304
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n;
    cin >> n;
    map<seika, int> mp;
    while (n--)
    {
        seika s;
        cin >> s;
        mp[s]++;
    }
    int maxi = 0;
    set<seika> ans;
    for (auto p : mp)
    {
        if (p.second > maxi)
        {
            ans = {p.first};
            maxi = p.second;
        }
        else if (p.second == maxi)
        {
            ans.insert(p.first);
        }
    }
    for (auto s : ans)
    {
        cout << s << endl;
    }
}

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


Measured memory_bytes: 34560
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


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

	cout << max(c - (a - b), 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n;
    bool flag = false;
    cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    rep(i,n){
        if(a[i]%2==0){
            if(!((int)((a[i]/3.0)*10)%10==0||(int)((a[i]/5.0)*10)%10==0)) flag = true;
        }
    }
    if(flag) cout << "DENIED" << endl;
    else cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
                            Author: Ankit Kaul
*******Code Belongs to Respective Author Only*************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
/*freopen("input.txt", "rt", stdin);
freopen("output.txt", "wt", stdout);
*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
        {   if(n % 2 ==1)
            result=(result * x)%M;
            x=(x*x)%M;
            n=n/2;
        }
    return result%M;
}
bool isPrime(int n)
    {
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
    }
int inv(int a,int m)
{   return power(a,m-2);
}   
int lcm(int a,int b)
{   return a*b/(gcd(a,b));
}
signed main()
{   jaldi  
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*d,b*c,a*c,b*d});
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define ff first
#define ss second
#define pri 1000000007
using namespace std;
void run(){
	ll a;
	cin>>a;
	ll f1=0,f2=0;
	ll d1=a/100;
	ll m1=a%100;
	if(d1<=12&&d1>0){f1=1;}
	if(m1<=12&&m1>0){f2=1;}
	if(f1==1&&f2==1)cout<<"AMBIGUOUS";
	else if(f1==1)cout<<"MMYY";
	else if(f2==1)cout<<"YYMM";
	else cout<<"NA";
		
	
	
}
int main() {
	ll t=1;
	//cin>>t;
	for(ll j=0;j<t;j++)run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

pre = a[0]
count=0
for i in range(n):
  atack = min(a[i+1]+a[i],b[i])
  count += atack
  if atack > a[i]:
    a[i+1] -= atack-a[i]

print(count)  

Measured memory_bytes: 18624
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

enum POSITION{ONLINE_BACK = -2, CCW = -1, ON_SEGMENT = 0,
              CW = 1, ONLINE_FRONT = 2};

struct Point{
    long x;
    long y;
    Point(long x, long y) : x(x), y(y) {}
    Point(){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}

struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2) {}
    Segment(){}
};
typedef vector<Point> Polygon;

POSITION get_position(Segment s, Point p){
    double c = cross(s.p2 - s.p1, p - s.p1);
    if (c > 0) return CCW;
    if (c < 0) return CW;
    double d = dot(s.p2 - s.p1, p - s.p1);
    if (d < 0) return ONLINE_BACK;
    if (d > dot(s.p2 - s.p1, s.p2 - s.p1)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersect(Segment s1, Segment s2){
    if (get_position(s1, s2.p1) * get_position(s1, s2.p2) != -1) {
        return false;
    }
    if (get_position(s2, s1.p1) * get_position(s2, s1.p2) != -1) {
        return false;
    }
    return true;
}

int determine_containment(Point p, Polygon poly){
    Segment s_right(p, Point(p.x + 1e5, p.y));
    int count = 0;
    for (int i = 0, n = poly.size(); i < n; i++) {
        if (get_position(Segment(poly[i], poly[(i+1)%n]), p) == ON_SEGMENT) {
            return 1;
        }
        if (intersect(s_right, Segment(poly[i], poly[(i+1)%n]))) {
            count++;
            continue;
        }
        if (get_position(s_right, poly[i]) == ON_SEGMENT) {
            int i_pre = (i == 0 ? n - 1 : i - 1);
            POSITION pos_pre = get_position(s_right, poly[i_pre]);
            POSITION pos_aft = get_position(s_right, poly[(i+1)%n]);
            while (pos_aft != CCW && pos_aft != CW) {
                i++;
                pos_aft = get_position(s_right, poly[(i+1)%n]);
            }
            if (pos_pre * pos_aft == -1) count++;
        }
    }
    if (count % 2) return 2;
    return 0;
}
int main(){
    int q;
    cin >> q;
    Polygon poly(q);
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        poly[i].x = x;
        poly[i].y = y;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cout << determine_containment(Point(x, y), poly) << endl;
    }
    return 0;
}



Measured memory_bytes: 3120
#深さ優先探索
import sys
import collections

n, m ,k= map(int, input().split())
# 入力値をzero-basedにしつつ格納する
pairs = [tuple(map(lambda x: int(x) - 1, input().split()))
         for _ in range(m)]
node=[[] for _ in range(n)]
block=[[] for _ in range(n)]
for p in pairs:
  node[p[0]].append(p[1])
  node[p[1]].append(p[0])
s=0
seen=[None]*n

sys.setrecursionlimit(10**9)
def dfs(v,c):
  seen[v]=c
  for next_v in node[v]:
    if seen[next_v]!=None:
      continue
    else:
      dfs(next_v,c)
      
for i in range(n):
  if seen[i]!=None:
    continue
  else:
    dfs(i,s)
    s+=1

#ブロックについて
for i in range(k):
  c,d=map(lambda x: int(x) - 1, input().split())
  if seen[c]==seen[d]:
    block[c].append(d)
    block[d].append(c)
  
count=collections.Counter(seen)
for i in range(n):
  print(count[seen[i]]-len(node[i])-1-len(block[i]))
  


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

using namespace std;

struct UnionFind {
    vector<int> parent; // parent[root] is the negative of the size.

    explicit UnionFind(int n) : parent(n, -1) {
    };                                       //初期化

    bool unite(int u, int v) {//ノードx,yが属する木を併合
        u = root(u);
        v = root(v);
        if (u == v) return false;
        if (parent[u] > parent[v]) swap(u, v);
        parent[u] += parent[v];
        parent[v] = u;
        return true;
    }

    bool same(int u, int v) {//ノードx,yが同じ木に属するかどうか
        return root(u) == root(v);
    }

    int root(int u) {//ノードuが属する木の根
        return parent[u] < 0 ? u : parent[u] = root(parent[u]);
    }

    int size(int u) {//ノードiを含む木の大きさ
        return -parent[root(u)];
    }
};


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

    // 自分が属する連結成分から除外する人
    // =(ブロックしている人)+(自分と直結している人)
    vector<set<int> > ex(N);
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        uf.unite(a, b);
        ex[a].insert(b);
        ex[b].insert(a);
    }

    for (int i = 0; i < K; ++i) {
        int c, d;
        cin >> c >> d;
        --c, --d;
        if (!uf.same(c, d)) continue;
        ex[c].insert(d);
        ex[d].insert(c);
    }

    for (int i = 0; i < N; ++i) {
        cout << uf.size(uf.root(i)) - 1 - ex[i].size() << " ";
    }
    cout << endl;
}

Measured memory_bytes: 24704
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    ll ans = 0;
    while (true) {
        ll cnt = 0;
        rep(i, n) {
            cnt += a[i] / n;
        }

        rep(i, n) {
            a[i] = a[i] - (a[i] / n) * n + (cnt - a[i] / n);
        }

        ans += cnt;

        if (cnt == 0) break;
    }

    cout << ans << endl;

    return 0;

}


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

const int INF=0x3f3f3f3f;

char s[2000][2000];
int d[1200][1200];
int dist[32][32];
P pos[32];

P dp[1<<10][32][11];

struct st{
	int i,j,k;
	P cost;
};

bool operator<(P a,P b){
	if(a.first!=b.first)return a.first<b.first;
	return a.second>b.second;
}
bool operator<(st a,st b){
	return a.cost>b.cost;
}

int sc[20][20];

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

bool isUpper(char c){
	return 'A'<=c&&c<='J';
}
bool isLower(char c){
	return 'a'<=c&&c<='j';
}

int get_id(char c){
	if(isdigit(c))return c-'0';
	if(isUpper(c))return c-'A'+10;
	if(isLower(c))return c-'a'+20;
	if(c=='S')return 30;
	if(c=='T')return 31;
	return -1;
}

int main(){
	int w,h;cin>>w>>h;
	rep(i,32)pos[i]=P(-1,-1);
	memset(dist,0x3f,sizeof(dist));
	rep(i,h){
		scanf("%s",s[i]);
		rep(j,w){
			int id=get_id(s[i][j]);
			if(id!=-1)pos[id]=P(i,j);
		}
	}
	rep(i,10)rep(j,10)scanf("%d",&sc[i][j]);
	rep(i,h)rep(j,w){
		if(get_id(s[i][j])==-1)continue;
		int id=get_id(s[i][j]);
		memset(d,0x3f,sizeof(d));
		queue<P>que;
		d[i][j]=0;
		que.push(P(i,j));
		while(!que.empty()){
			P p=que.front();que.pop();
			rep(k,4){
				int nx=p.first+dx[k],ny=p.second+dy[k];
				if(nx<0||nx>=h||ny<0||ny>=w)continue;
				if(s[nx][ny]=='#')continue;
				if(d[nx][ny]!=INF)continue;
				d[nx][ny]=d[p.first][p.second]+1;
				if(!isLower(s[nx][ny])&&!isUpper(s[nx][ny]))que.push(P(nx,ny));
			}
		}
		rep(k,32){
			if(pos[k].first==-1)continue;
			dist[id][k]=d[pos[k].first][pos[k].second];
		}
	}
	rep(i,1<<10)rep(j,32)rep(k,11)dp[i][j][k]=P(INF,0);
	priority_queue<st>que;
	dp[0][30][10]=P(0,0);
	que.push({0,30,10,{0,0}});
	while(!que.empty()){
		st s=que.top();que.pop();
		int i=s.i,j=s.j,k=s.k;
		if(dp[s.i][s.j][s.k]!=s.cost)continue;
		rep(t,32){
			if(t<10&&(i>>t&1))continue;
			if(10<=t&&t<20){
				if(i>>(t-10)&1)continue;
			}
			if(20<=t&&t<30){
				if(!(i>>(t-20)&1))continue;
			}
			if(dist[j][t]==INF)continue;
			int ni=(i|(t<10?1<<t:0));
			int nj=t;
			int nk=(t<10?t:k);
			P np=dp[i][j][k];
			np.first+=dist[j][nj];
			np.second+=sc[k][nk];
			if(np<dp[ni][nj][nk]){
				dp[ni][nj][nk]=np;
				que.push({ni,nj,nk,np});
			}
		}
	}
	P ans(INF,0);
	rep(k,11){
		auto p=dp[(1<<10)-1][31][k];
		if(p<ans)ans=p;
	}
	if(ans.first==INF)puts("-1");
	else cout<<ans.first<<' '<<ans.second<<endl;
}


Measured memory_bytes: 14296
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;
const long long N_MAX = 500;

vector<long long> Decompose(long long m){
    vector<long long> primes;
    primes.push_back(1);
    for(long long i=2;i*i<m;i++){
        if(m % i == 0){
            primes.push_back(i);
            primes.push_back(m / i);
        }
    }
    primes.push_back(m);
    return primes;
}

bool canFlatten(long long* a, long long n, long long line, long long k){
    vector<long long> res;
    long long minus = 0;
    for(long long i = 0; i < n;i++){
        long long r = a[i] % line;
        if(r != 0) res.push_back(r);
        minus += r;
    }
    if(minus <= k) return true;
    sort(res.begin(), res.end());
    long long plus = 0;
    for(long long i = res.size()-1; i >= 0;i--){
        plus += line - res[i];
        minus -= res[i];
        if(max(minus, plus) <= k) return true;
    }
    return false;
}

int main(){
    long long n;
    long k;
    cin >> n >> k;
    long long a[N_MAX];
    long long sum = 0;
    for(long long i = 0; i < n;i++){
        cin >> a[i];
        sum += a[i];
    }
    long long ans = 1;
    vector<long long> primes = Decompose(sum);
    sort(primes.begin(), primes.end(), greater<long long>());
    for(auto i : primes){
        if(canFlatten(a, n, i, k)){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
a = input().split()
ai=np.array(a, dtype=int)

fumi=0
amax=ai[0]
for i in range(1,n):
  if (ai[i] >= amax):
    amax=ai[i]
  else:
    fumidai1=amax-ai[i]
    fumi+=fumidai1

print (fumi)


Measured memory_bytes: 53108
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;

// Eratosthenes
vector<int> eratTable;

vector<ll> eratosthenes(ll n) {
    eratTable.assign(n + 1, 1);
    eratTable[0] = 0;
    eratTable[1] = 0;
    for (ll i = 2; i <= n; i++) {
        if (eratTable[i] == 1) {
            for (ll j = 2; i * j <= n; j++) {
                eratTable[i * j] = 0;
            }
        }
    }

    vector<ll> primes;
    rep(i, eratTable.size()) {
        if (eratTable[i] >= 1) {
            primes.push_back(i);
        }
    }

    return primes;
}

bool check(const vector<ll>& a) {
    for (ll i = 0; i < a.size() - 4; i++) {
        for (ll j = i + 1; j < a.size() - 3; j++) {
            for (ll k = j + 1; k < a.size() - 2; k++) {
                for (ll l = k + 1; l < a.size() - 1; l++) {
                    for (ll m = l + 1; m < a.size(); m++) {
                        ll v = a[i] + a[j] + a[k] + a[l] + a[m];
                        // 1なら素数
                        if (eratTable[v] == 1) {
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}

void Main()
{
    ll n;
    cin >> n;

    vector<ll> res;

    auto primes = eratosthenes(55555);

    rep (i, primes.size()) {
        if (primes[i] % 5 == 1) {
            res.push_back(primes[i]);
        }
    }

    rep(i, n) cout << res[i] << (i == n - 1 ? "" : " ");
    cout << endl;
}

signed main(){ Main();return 0;}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

struct unionfind{
	vector<int> data;
	vector<int> size;
	unionfind(int n){
		for(int i=0;i<n;i++){
			data.push_back(i);
			size.push_back(1);
		}
	}
	
	int find(int x){
		if(data[x]==x)return x;
		return data[x]=find(data[x]);
	}
	
	bool unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return false;
		data[x]=y;
		size[y]+=size[x];
		return true;
	}
	
	bool check(int x,int y){
		return (find(x)==find(y));
	}
	
	int get_size(int x){
		int X = find(x);
		return size[X];
	}
};

int main(){
	
	int N;
	cin>>N;
	
	vector<pair<int,int>> x(N),y(N);
	
	for(int i=0;i<N;i++){
		cin>>x[i].first>>y[i].first;
		x[i].second=i;
		y[i].second=i;
	}
	
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	
	vector<pair<long long,pair<int,int>>> P;
	
	for(int i=0;i<N-1;i++){
		int a = x[i].second;
		int b = x[i+1].second;
		long long c = x[i+1].first-x[i].first;
		P.emplace_back(c,make_pair(a,b));
	}
	
	for(int i=0;i<N-1;i++){
		int a = y[i].second;
		int b = y[i+1].second;
		long long c = y[i+1].first-y[i].first;
		P.emplace_back(c,make_pair(a,b));
	}
	
	sort(P.begin(),P.end());
	
	unionfind uf(N);
	long long ans = 0;
	
	for(int i=0;i<P.size();i++){
		int a = P[i].second.first;
		int b = P[i].second.second;
		long long c = P[i].first;
		if(uf.unite(a,b)){
			ans += c;
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 8048
n = gets.to_i
x = gets.split.map(&:to_i)
def paper(b)
  b.each do |i|
    if i.even?
      unless i % 3 == 0 || i % 5 == 0
        puts "DENIED"
        exit
      end
    end
  end
  puts "APPROVED"
end

paper(x)

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

int groupNum(int num){
    if(num == 1 || num == 3 || num == 5 || num == 7 || num == 8 || num == 10 || num == 12) {
        return 1;
    } else if(num == 4 || num == 6 || num == 9 || num == 11) {
        return 2;
    } else if(num == 2) {
        return 3;
    } else {
        return -1;
    }
}

int main() {
    int x, y;
    cin >> x >> y;

    int xGroup = groupNum(x);
    int yGroup = groupNum(y);

    if(xGroup == yGroup) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
s=list(input())
n=len(s)
s1=s[:int((n-1)/2)]
s2=s[int((n+3)/2-1):]
if s == s[::-1]:
    if s1==s1[::-1]:
        if s2==s2[::-1]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
s = []
for _ in range(h):
    s.append(list(input()))
from collections import deque, defaultdict
def bfs(x, y):
    wp = defaultdict(list)
    d = [[-1] * w for _ in range(h)]
    d[x][y] = 0
    queue = deque([(x, y)])
    while queue:
        u, v = queue.popleft()
        wp[0].append((u, v))
        next_grid = [(u - 1, v), (u + 1, v), (u, v - 1), (u, v + 1)]
        for x, y in next_grid:
            if 0 <= x < h and 0 <= y < w and s[x][y] != '#' and d[x][y] < 0:
                d[x][y] = d[u][v]
                queue.append((x, y))
    for i in range(10**6):
        if len(wp[i]) == 0:
            break
        queue = deque([])
        for x, y in wp[i]:
            for dx in range(-2, 3):
                for dy in range(-2, 3):
                    u, v = x + dx, y + dy
                    if 0 <= u < h and 0 <= v < w and s[u][v] == '.' and d[u][v] < 0:
                        d[u][v] = i + 1
                        queue.append((u, v))
        while queue:
            u, v = queue.popleft()
            wp[i + 1].append((u, v))
            next_grid = [(u - 1, v), (u + 1, v), (u, v - 1), (u, v + 1)]
            for x, y in next_grid:
                if 0 <= x < h and 0 <= y < w and s[x][y] != '#' and d[x][y] < 0:
                    d[x][y] = d[u][v]
                    queue.append((x, y))
    return d

d = bfs(ch, cw)
print(d[dh][dw])


    


Measured memory_bytes: 164964
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
typedef struct {
    int a;
    int b;
} WORK;

int cmp(const void *a, const void *b) {
    return ((WORK*)a)->b - ((WORK*)b)->b;
}

int main()
{
    int i, n;
    WORK w[200000];
    scanf("%d",&n);
    for(i=0; i<n; i++) {
        scanf("%d%d",&w[i].a, &w[i].b);
    }
    qsort(w, n, sizeof(WORK), cmp);
    int time = 0;
    for(i=0; i<n; i++) {
        if(time+w[i].a <= w[i].b) {
            time += w[i].a;
        } else {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 3324
#include <stdio.h>

int main()
{

    int i, n, debt = 100000;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        debt *= 1.05;
        debt = debt % 1000 ? (debt / 1000 + 1) * 1000 : debt;
    }
    printf("%d\n", debt);

    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  ll sum = 0;
  ll minAbs = 1000000005;
  ll nMinus = 0;
  for(int i=0; i<N; i++) {
    cin >> A[i];
    sum += abs(A[i]);
    minAbs = min(minAbs, abs(A[i]));
    if(A[i] < 0)
      nMinus++;
  }
  if(nMinus % 2 == 1) {
    cout << sum - 2 * minAbs << endl;
  } else {
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, N)
  {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  vector<pair<int, string>> ans;
  ans.push_back(make_pair(1, S[0]));
  rep(i, N - 1)
  {
    string name = S[i + 1];
    if (name == ans.back().second)
      ans.back().first++;
    else
    {
      ans.push_back(make_pair(1, name));
    }
  }
  sort(ans.begin(), ans.end());
  int max_count = ans.back().first;
  rep(i, ans.size())
  {
    if (ans[i].first != max_count)
      continue;
    cout << ans[i].second << endl;
  }
  return 0;
}

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

int main() {
	int N, A, dmin = 100;
	bool oddFlag = false;
	vector <int> vec = {};
	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> A;
		int sum = 0;
		while ( A%2 ==0)
		{
			A /= 2;
			sum++;
		}
		dmin = min(dmin, sum);

	}
	cout << dmin << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> sum;
    rep(i, n) {
        ll now = 0;
        for (int j = i; j < n; ++j) {
            now += a[j];
            sum.push_back(now);
        }
    }

    ll ans = 0;
    for (int i = 39; i >= 0; --i) {
        int cnt = 0;
        rep(j, sum.size()) {
            if ((sum[j] & ans) == ans && (sum[j] >> i & 1)) cnt++;
        }
        if (cnt >= k) ans |= 1LL<<i;
    }
    cout << ans << endl;
}


Measured memory_bytes: 7432
#include <cstdio>
#include <cstring>

using namespace std;

char s[1005];
int p[1005];

int main()
{
	int ans = 1;
	scanf("%s",s);
	int len = strlen(s);
	for(int i = 0; i < len; i++){
		if(i == 0 && s[i] == 'B') ;
		else if(s[i] == '0') {
			p[ans] = 0;
			ans++;

		}
		else if(s[i] == '1') {
			p[ans] = 1;
			ans ++;
		}
		else if(s[i] == 'B') {
			if(ans > 1) ans--;
			else if(ans < 1) continue;
		}
	}
	int h = 1;
	for(int i = 0; i < ans - 1; i++){
		printf("%d",p[h]);
		h++;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
#define INF 99999999
typedef std::pair<int,int> pii;

int main(){
    int N;
    std::cin >> N;
    std::vector<int> a(N),b(N),res(N);
    int sum_a=0, sum_b=0,ans=0;
    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }
    
    for (int i = 0; i < N; i++) {
        std::cin >> b[i];
        if (i != N-1) sum_b += b[i];
    }
    res[0] = a[0] + b[N - 1] + sum_b + sum_a;
    for (int i = 1; i < N; i++) {
        sum_a += a[i];
        sum_b -= b[i - 1];
        res[i]=a[0]+b[N-1]+sum_b+sum_a;

    }
    for (int i = 0; i < N; i++) {
        ans = std::max(ans, res[i]);
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 384
// =====================================================================================
//
//       Filename:  res.cpp
//
//        Version:  1.0
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Priyank Kumar Singh (), priyankkumar179@gmail.com
//   Organization:  RVCE Bangalore
//
// =====================================================================================


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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define ct(i) cout<< i << "\n";
#define mod 1000000007
#define M 100005

/*
void dfs(int n,int p){
    vis[n]=1; 
    if(adj[n].size()!=2) f1=1;
    for(int i=0;i<adj[n].size();i++){
        if(vis[adj[n][i]]==0 ) dfs(adj[n][i],n);
        else if(adj[n][i]!=p){ f=1; }
    }
}*/
int c1=0;
void answer(){
    ll n,l,r,f=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0 || i%5==0) continue;
        f+=i;
    }
    cout<<f;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n, k;
  cin >> n >> k;
  ll result = 0;
  ll resulta = 0, resultb = 0;
  if(k % 2 == 1){
    resulta = n / k;
    resulta *= resulta * resulta;
  }
  else{
    resulta = n / k;
    resultb = (n + k / 2) / k;
    resulta *= resulta * resulta;
    resultb *= resultb * resultb;
    
  }
  cout << resulta + resultb << endl;
  

  return 0;
}

Measured memory_bytes: 256
n=int(input())
h=[int(i) for i in input().split()]
h=h[::-1]

maxv=0
minv=h[0]
for i in range(1,n):
    maxv=max(maxv, h[i]-minv)
    minv=min(minv, h[i])
if maxv >= 2:
    print("No")
else:
    print("Yes")

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

#define rep(i,n) for(int i=0;i<(int)(n);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)

#define lf double
#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;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin>>s;
	if (s=="Sunny"){
		cout << "Cloudy\n";
	}else if(s=="Cloudy"){
		cout << "Rainy\n";
	}else{
		cout << "Sunny\n";
	}
	return 0;
}

Measured memory_bytes: 384
s = int(input())

inf = 1
i = 0
list = [s]
while(inf == 1):
    if list[i] % 2 == 1:
        tmp = 3*list[i] + 1
    elif list[i] % 2 == 0:
        tmp = list[i]/2
    for j in list:
        if j == tmp:
            print(i+2)
            inf = 0
            break
    list.append(tmp)
    i += 1


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int M, N, K, a[112345], b[112345], c[112345], d[112345];
std::string field[1123];
int Jcou[1123][1123], Ocou[1123][1123], Icou[1123][1123];

int main()
{
	in >> M >> N >> K;
	rep(i, M) { in >> field[i]; }
	rep(i, K) { in >> a[i] >> b[i] >> c[i] >> d[i]; }

	rep(i, M)
	{
		rep(j, N)
		{
			if (field[i][j] == 'J') { Jcou[i + 1][j + 1] = 1; }
			if (field[i][j] == 'O') { Ocou[i + 1][j + 1] = 1; }
			if (field[i][j] == 'I') { Icou[i + 1][j + 1] = 1; }
		}
	}
	rep(i, M)
	{
		rep(j, N) { Jcou[i + 1][j + 2] += Jcou[i + 1][j + 1]; }
	}
	rep(i, N)
	{
		rep(j, M) { Jcou[j + 2][i + 1] += Jcou[j + 1][i + 1]; }
	}
	rep(i, M)
	{
		rep(j, N) { Ocou[i + 1][j + 2] += Ocou[i + 1][j + 1]; }
	}
	rep(i, N)
	{
		rep(j, M) { Ocou[j + 2][i + 1] += Ocou[j + 1][i + 1]; }
	}
	rep(i, M)
	{
		rep(j, N) { Icou[i + 1][j + 2] += Icou[i + 1][j + 1]; }
	}
	rep(i, N)
	{
		rep(j, M) { Icou[j + 2][i + 1] += Icou[j + 1][i + 1]; }
	}

	rep(i, K)
	{
		int J = Jcou[c[i]][d[i]] - Jcou[c[i]][b[i] - 1] - Jcou[a[i] - 1][d[i]] + Jcou[a[i] - 1][b[i] - 1];
		int O = Ocou[c[i]][d[i]] - Ocou[c[i]][b[i] - 1] - Ocou[a[i] - 1][d[i]] + Ocou[a[i] - 1][b[i] - 1];
		int I = Icou[c[i]][d[i]] - Icou[c[i]][b[i] - 1] - Icou[a[i] - 1][d[i]] + Icou[a[i] - 1][b[i] - 1];
		out << J << " " << O << " " << I << std::endl;
	}
	return 0;
}

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


int main()
{
    int n;
    std::string s;
    std::cin>>n;
    std::cin>>s;
    bool res =true;
    if(n%2==1)res = false;
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[i+n/2])res = false;
    }
    std::cout<<(res?"Yes":"No")<<std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int n, h[100100],ans = 0,count = 0;
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> h[i]; }
	for (int i = 0;i < n - 1; i++)
	{
		if (h[i] >= h[i + 1]) { count++; }
		else { if (count > ans) { ans = count; } count = 0; }
	}
	if (count > ans) { ans = count; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640