akhauriyash/Code-Regression huggingface dataset:
n, m, x, y = list(map(int, input().split()))
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))
xmax = max(x_list)
ymin = min(y_list)
irange = y - x
for i in range(irange):
    if xmax < x+i+1 and x+i+1 <= ymin:
        print("No War")
        exit()
print("War")


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

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

int main(int argc, char const *argv[]) {
  ll n,X;
  cin >> n >> X;
  vector<ll> x(n);
  for (ll i = 0; i < n; i++) cin >> x[i];
  x.push_back(X);
  sort(x.begin(), x.end());
  vector<ll> def;
  for (ll i = 1; i < x.size(); i++) {
    def.push_back(x[i]-x[i-1]);
  }
  ll ans = def[0];

  for (ll i = 1; i < def.size(); i++) {
    ans = gcd(def[i], ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2800
using System;

namespace Atc_0019
{
    class Program
    {
        static void Main(string[] args)
        {
            string  N = Console.ReadLine();
            if (N.Contains("7"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 25844
import math
def isprime(n):
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True
n=int(input())
sosuu=[]
for j in range(n):
    m=int(input())
    if isprime(m):
        sosuu.append(m)
print(len(sosuu))


Measured memory_bytes: 5676
#include <stdio.h>
#include <math.h>

#define EPS 1e-10
#define rep(i,n) for(i=0;i<n;i++)

typedef struct{
	double x,y,z;
}P;

double dot(P a,P b){
	return a.x * b.x + a.y * b.y + a.z * b.z;
}

double dist(P a){
	return sqrt(a.x*a.x + a.y*a.y + a.z*a.z);
}

double getTheta(P a,P b){
	return acos(dot(a,b) / (dist(a) * dist(b)));
}

int main(void){
	int i,j;
	int n,m,ans;
	double phi[50];
	P s[500],t[50];

	while(scanf("%d",&n) && n){
		rep(i,n) scanf("%lf%lf%lf",&s[i].x,&s[i].y,&s[i].z);
		scanf("%d",&m);
		rep(i,m) scanf("%lf%lf%lf%lf",&t[i].x,&t[i].y,&t[i].z,&phi[i]);

		ans = 0;
		rep(i,n)rep(j,m){
			if(getTheta(s[i],t[j]) < phi[j] + EPS){
				ans++;
				break;
			}
		}

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

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
int main()
{
    int N;
    int count=0;
    int ans=0;
    cin>>N;
    
    for(int i=1;i<=N;i+=2)
    {
        count=0;
        for(int j=1;j<=i;j++)
        {
            if(i%j==0)
            {
                count++;

            }
        }
        if(count==8)
        {
            ans++;
            
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    llong dp[64][64][3000];
    int x[64];
    int n, a;

    llong dfs ( int pos, int cnt, int sum ) {
        if ( ~dp[pos][cnt][sum] ) return dp[pos][cnt][sum];
        int rec = 0;
        if ( cnt && a*cnt == sum ) rec++;
        if ( pos == n ) return rec;
        return dp[pos][cnt][sum] = dfs(pos+1, cnt, sum)
            + dfs ( pos+1, cnt+1, sum+x[pos] );
    }

    signed call_of_Cthulhu( signed datum ) {

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

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

        echo dfs ( 0, 0, 0 ) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); echo std::fixed << std::setprecision(8); int main_result = Rlyeh::call_of_Cthulhu(114514); return main_result;}


Measured memory_bytes: 96384
#include <stdio.h>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
    int n, A[200000];
    scanf("%i", &n);
    for (int i = 0; i < n; i++) {
        scanf("%i", A + i);
    }
    sort(A, A + n, greater<int>());
    long long ans = A[0];
    n -= 2;
    for (int i = 1; n; i++) {
        if (n == 1) {
            ans += A[i];
            n = 0;
        }
        else {
            ans += A[i] << 1ll;
            n -= 2;
        }
    }
    printf("%lli", ans);
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

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

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

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}

constexpr ll MAX_D = 50;
ll dp[100][2];

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> A(N); REP(i, N) cin >> A[i];
	memset(dp, -1, sizeof dp);
	**dp = 0;

	for (ll bits = 0; bits < MAX_D; ++bits)
	{
		ll mask = 1ll << (MAX_D - bits - 1);

		ll cnt1{0}, cnt0{0};
		
		REP(i, N)
		{
			if (A[i] & mask) ++cnt1;
			else ++cnt0;
		}

		ll cost0 = mask * cnt1;
		ll cost1 = mask * cnt0;

		if (dp[bits][true] != -1)
		{
			chmax(dp[bits+1][true], dp[bits][true] + cost0);
			chmax(dp[bits+1][true], dp[bits][true] + cost1);
		}

		if (dp[bits][false] != -1)
			if (K & mask)
				chmax(dp[bits+1][true], dp[bits][false] + cost0);

		if (dp[bits][false] != -1)
		{
			if (K & mask)
				chmax(dp[bits+1][false], dp[bits][false] + cost1);
			else
				chmax(dp[bits+1][false], dp[bits][false] + cost0);
		}
	}

	std::cout << max(dp[MAX_D][0], dp[MAX_D][1]) << std::endl;
}


Measured memory_bytes: 1024
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=4005,M=1000;
char s[N][N];int n,m,l,r,ans,mid,mp[N][N];
inline int calc(R int x,R int y){
	R int dx=x,dy=y,xx,yy;x=dx+dy+M,y=dx-dy+M;
	dx=x+mid,dy=y+mid,xx=x-mid,yy=y-mid;
	xx=max(xx,2+M),yy=max(yy,1-m+M),dx=min(dx,n+m+M),dy=min(dy,n-1+M);
//	puts("qwq");
//	printf("%d %d %d %d %d %d\n",x-M,y-M,xx-M,yy-M,dx-M,dy-M);
	return mp[dx][dy]-mp[dx][yy-1]-mp[xx-1][dy]+mp[xx-1][yy-1];
}
bool ck(){
	fp(i,1,n)fp(j,1,m)if(s[i][j]=='.'&&!calc(i,j))return false;
	return true;
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&m),l=0,r=n+m,ans=0;
	fp(i,1,n)scanf("%s",s[i]+1);
	fp(i,1,n)fp(j,1,m)mp[i+j+M][i-j+M]=(s[i][j]=='#');
	fp(i,2+M,n+m+M)fp(j,1-m+M,n-1+M)mp[i][j]+=mp[i-1][j]+mp[i][j-1]-mp[i-1][j-1];
//	mid=1,printf("%d\n",ck());
	while(l<=r){
		mid=(l+r)>>1;
		ck()?(ans=mid,r=mid-1):l=mid+1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 39168
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  if(n == 1 && m == 1){
    cout << 1 << endl;
    return 0;
  }
  if(n == 1 || m == 1){
    cout << max(n, m) - 2 << endl;
    return 0;
  }
  cout << (n - 2) * (m - 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <sstream>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

int main(int argc, char* argv[])
{
	int			nNumberA;
	int			nNumberB;

	cin >> nNumberA >> nNumberB;

	cout << ceil((nNumberA + nNumberB) / 2.0) << endl;
	return 0;
}

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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i)
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i)

#define DEBUG(...) fprintf(stderr , __VA_ARGS__)

template<typename T>inline int chkmin(T &x , const T &y){ return x > y ? x = y , 1 : 0; }
template<typename T>inline int chkmax(T &x , const T &y){ return x < y ? x = y , 1 : 0; }

template<typename T>inline T read(T &f)
{
	f = 0 ; int x = 1 ; char c = getchar();
	while(!isdigit(c)) x = c == '-' ? -1 : 1 , c = getchar();
	while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
	return f *= x;
}

using int64 = long long;
using uint64 = unsigned long long;

const int N = 100000 + 5;

int n , k , cnt , col[N] , sz[N] ; char S[N];

int main()
{
	read(n) , read(k) , scanf("%s" , S + 1);
	col[0] = -1;
	rep(i , 1 , n)
	{
		int c = S[i] == 'L' ? 0 : 1;
		if(col[cnt] != c)
		{
			col[++cnt] = c;
			sz[cnt] = 1;
		}
		else sz[cnt] += 1;
	}
	if(cnt == 1)
	{
		printf("%d\n" , sz[cnt] - 1);
		return 0;
	}
	int ret = 0;
	rep(i , 1 , cnt) ret += sz[i] - 1;
	int ct1 = 0 , ct2 = 0;
	rep(i , 1 , cnt)
	{
		if(col[i] == 1)
		{
			if(i == 1 || i == cnt) ct2++;
			else ct1++;
		}
	}
	int ans = 0;
	if(ct1 <= k)
	{
		chkmax(ans , ret + 2 * ct1 + min(k - ct1 , ct2));
	}
	else
	{
		chkmax(ans , ret + 2 * min(ct1 , k));
	}
	ct1 = 0 , ct2 = 0;
	rep(i , 1 , cnt)
	{
		if(col[i] == 0)
		{
			if(i == 1 || i == cnt) ct2++;
			else ct1++;
		}
	}
	if(ct1 <= k)
	{
		chkmax(ans , ret + 2 * ct1 + min(k - ct1 , ct2));
	}
	else
	{
		chkmax(ans , ret + 2 * min(ct1 , k));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;
 
  int sz;
  vector< Monoid > seg;
 
  const F f;
  const Monoid M1;
 
  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }
 
  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }
 
  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
 
  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }


//
  void add(int k, const Monoid &x) {
    k += sz;
    seg[k] += x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }
//
 
  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }
 
  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

int main(){
    int i,j;
    int n,q;
    cin>>n>>q;
    SegmentTree<int> seg(n,[](int a,int b){return a+b;},0);
    while(q--){
        int t,x,y;
        cin>>t>>x>>y;
        if(t==0) seg.add(x,y);
        else cout<<seg.query(x,y+1)<<endl;
    }
}



Measured memory_bytes: 3800
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.
	int a, b;
	cin >> a >> b;
	int ans = a*b;
	if (ans % 2 == 0) {
		cout << "Even";
	}
	else {
		cout << "Odd";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
map<string, bool> m;
int n;
string s;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	while (n--)
	{
		cin >> s;
		m[s] = 1;
	}
	cout << m.size();
	return 0;
}

Measured memory_bytes: 19284
from itertools import product

n, m = map(int, input().split())
s = []
for i in range(m):
    s.append(list(map(int, input().split()[1:])))
p = list(map(int, input().split()))

# print(n, m, s, p)

ans = 0

for tpl in product([0, 1], repeat=n):
    # print(tpl)
    bl = True

    for j in range(m):
        cnt_on = sum(tpl[k - 1] for k in s[j])
        if cnt_on % 2 != p[j]:
            bl = False
            break
    if bl:
        ans += 1

print(ans)


Measured memory_bytes: 3064
d, g = map(int, input().split())
p_and_c = [list(map(int, input().split())) for _ in range(d)]
min_number = 1000
for i in range(2**d):
    score = 0
    number = 0
    p_and_c_copy = p_and_c.copy()
    rest_num = set(range(1, d+1))
    for j in range(d):
        if i & (1 << j):
            number += p_and_c_copy[j-d][0]
            score += p_and_c_copy[j-d][1] + 100 * (j+1) * p_and_c_copy.pop(j-d)[0]
            rest_num.discard(j+1)
    if p_and_c_copy:
        for k in range(p_and_c_copy[-1][0]):
            if score >= g:
                break
            score += 100 * max(rest_num)
            number += 1
        else:
            continue
    min_number = min(min_number, number)
print(min_number)

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

int main(){
    
    int n, m, l;
    cin >> n >> m >> l;
    long A[n][m] = {0};
    long B[m][l] = {0};
    
    for ( int i = 0 ; i < n ; i++ ){
        for ( int j = 0 ; j < m ; j++ ){
            cin >> A[i][j];
        }
    }
    for ( int i = 0 ; i < m ; i++ ){
        for ( int j = 0 ; j < l ; j++ ){
            cin >> B[i][j];
        }
    }
    long c = 0;
    for ( int i = 0 ; i < n ; i++ ){
        for ( int k = 0 ; k < l ; k++ ){
            for ( int j = 0 ; j < m ; j++ ){
                c += A[i][j] * B[j][k];
            }
            cout << c;
            c = 0;
            if ( k == l - 1 ) continue;
            cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3232
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

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

    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<int> A(X), B(Y), C(Z);
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];

    priority_queue<int> pq1;
    REP(i, X) {
        REP(j, Y) {
            pq1.push(A[i] + B[j]);
        }
    }

    priority_queue<int> pq2;
    int cnt = 0;
    while (cnt < K && !pq1.empty()) {
        int n = pq1.top();
        pq1.pop();

        REP(i, Z) {
            pq2.push(C[i] + n);
        }

        cnt++;
    }

    cnt = 0;
    while (cnt < K && !pq2.empty()) {
        int n = pq2.top();
        pq2.pop();
        cout << n << endl;

        cnt++;
    }

    return 0;
}


Measured memory_bytes: 43368
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dcm(a) setprecision(a)<<fixed
#define MOD 1000000007
#define clr(memo, a) memset(memo,a,sizeof(memo))
#define PI acos(-1)
int const N=55;
pair<string,int> a[N];
void solve(){
string x;
int n;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i].first;
    cin>>a[i].second;
}

cin>>x;
bool flage=false;
int ans=0;
for(int i=0;i<n;i++){
    if(flage)
        ans+=a[i].second;
    if(a[i].first==x)
        flage=true;

}
cout<<ans<<endl;
}

int main(){
    fast;

    solve();
}


Measured memory_bytes: 256
x, y, z, k = [int(n) for n in input().split()]
va = sorted([int(n) for n in input().split()], reverse=True)
vb = sorted([int(n) for n in input().split()], reverse=True)
xy = min(x*y, k)
vab = (sorted([a + b for a in va for b in vb], reverse=True))[:xy]
vc = sorted([int(n) for n in input().split()], reverse=True)
xyz = min(x*y*z, k)
print(*((sorted([ab + c for ab in vab for c in vc], reverse=True))[:xyz]), sep="\n")

Measured memory_bytes: 186136
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>

using namespace std;

int main() {
    int n;
    set<string> lot;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        lot.insert(s);
    }
    cout << lot.size() << endl;
}

Measured memory_bytes: 15664
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,b) for (ll i=a;i<=ll(b);i++)
using namespace std;
ll ctoi(const char c){if('0'<=c&&c<='9') return (c-'0');return -1;}
#define ALL(x) begin(x),end(x)
  
int main(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  bool flag = false;
  for(ll i=0;i<k;i++){
      if(c<=b){
        c*=2;
        continue;
      }
      if(b<=a){
        b*=2;
        continue;
      }
  }
  if(c>b&&b>a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3648
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

flag = [False for _ in range(q)]
value_dict = {}

for i in range(2 ** n):
    a = 0
    for j in range(n):
        if i >> j & 1:
            a += A[j]
            value_dict[a] = 1
    
for b in M:
    if b in value_dict:
        print("yes")
    else:
        print("no")




Measured memory_bytes: 5652
#include <stdio.h>
#include <iostream>
#include <string.h>

int a;
int person[100000 + 1];

int main() {

	int n, k, q;

	scanf("%d %d %d", &n, &k, &q);
	memset(person, 0, sizeof(person));

	for (int i = 0; i < q; ++i) {

		scanf("%d", &a);
		person[a - 1]++;

	}

	for (int i = 0; i < n; ++i) {

		if ((person[i] + k - q) > 0) std::cout << "Yes\n";
		else std::cout << "No\n";

	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef unsigned long long ull;

int main() {
    int k,x;
    cin>>k>>x;
    if (k * 500 >= x) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int N, i, count, min;
  count = 1;
  scanf("%d", &N);
  int P[N];
  for (i = 0; i < N; ++i) {
    scanf("%d", &P[i]);
  }
  min = P[0];
  for (i = 1; i < N; ++i) {
    if (min >= P[i]) {
      min = P[i];
      ++count;
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
int dp[2010][2010];
int a[2010];
struct node
{
    int first;
    int second;
}c[5001];


bool cmp(node p1,node p2)
{
    return p1.second>p2.second;
}

int work(int now,int l,int r)
{
	if (l>r)  return c[now].second;
	if (dp[l][r]!= -1)  return dp[l][r];

	int f=work(now+1,l+1,r)+c[now].second*abs(c[now].first-l);
	int s=work(now+1,l,r-1)+c[now].second*abs(c[now].first-r);
	dp[l][r]=max(dp[l][r], max(f,s) );

	return dp[l][r];
}
signed main()
{
    int n;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        c[i].second = a[i];
        c[i].first = i;
    }
    sort(c+1,c+1+n,cmp);
    cout<<work(1,1,n);
    /*
    for(int l=1;l<=n;l++)
    {
        for(int r=1;r<=n;r++)
        {
            if(l+r==n+1)
            {
                ans=max(ans,dp[l][r]);
            }
            cnt=l+r-1;
            dp[l+1][r]= max(dp[l+1][r],dp[l][r]+abs(c[cnt].first-l)*c[cnt].second);
            dp[l][r-1]= max(dp[l][r-1],dp[l][r]+abs(r - c[cnt].first)*c[cnt].second);
        }
    }*/
    //cout<<ans<<endl;
}

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

namespace IO {
	inline char gc(){
		static char buf[1<<20],*p1=buf,*p2=buf;
		if(p1==p2){
			p2=(p1=buf)+fread(buf,1,1<<20,stdin);
			if(p1==p2) return EOF;
		}
		return *p1++;
	}

	#define gc getchar
	
	inline int read(){
		int x=0;bool f=0;char p=gc();
		while(!isdigit(p)) f|=(p=='-'),p=gc();
		while(isdigit(p)) x=x*10+p-'0',p=gc();
		return (f)?-x:x;
	}

}

int n;
const int N=1e5+5;
int a[N];

bool cmp(int a,int b){
	return a>b;
}

int main(){
//	freopen("t1.in","r",stdin);
//	freopen("t1.out","w",stdout);
//	int T=IO::read();
	int T=1;
	while(T--){
		n=IO::read();
		for(int i=1;i<=n;++i) 
			a[i]=IO::read();
		sort(a+1,a+n+1,cmp);
		for(int i=1;i<=n;++i)
			if(a[i+1]<i+1){
				int r=i+1;
				while(a[r]==i) r++;
				if(((r-i+1)&1) || ((a[i]-i)&1)) puts("First");
				else puts("Second");
				break;
			}
	}
	return 0;
}
/*
1
2
1 3
*/

Measured memory_bytes: 640
// checklist
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n,k;
	cin >> n >> k;
	ll cur = 1;
	ll ans = 0;
	while(cur<=n){
		ans++;
		cur *= k;
	}
	cout << ans << endl;
}	


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int exeCounter = 0;
            bool isOdd = false;
            int N = cin.ReadInt;
            var a = cin.ReadIntArray(N);

            do
            {
                foreach (int i in a)
                {
                    if (i % 2 == 0)
                    {
                        continue;
                    }
                    else
                    {
                        isOdd = true;
                        break;
                    }
                }

                if (isOdd)
                {
                    break;
                }

                a = a.Select(i => i / 2).ToArray();
                exeCounter++;

            }
            while (!isOdd);

            Console.WriteLine(exeCounter);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

int main(void){
    int N, K;
    cin >> N >> K;
    int A[N], sum;
    
    for (int i = 0; i < K; i++){
        int d;
        cin >> d;
        
        for (int j = 0; j < d; j++){
            int a;
            cin >> a;
            
            if (A[a-1] != 1) A[a-1] = 1;
        }
    }
    
    sum = 0;
    for (int i = 0; i < N; i++){
        if (A[i] != 1) sum++;
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,M;
  cin >> N >> M;
  string A[N], B[M];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  for (int i = 0; i <= N-M; i++) {
    for (int j = 0; j <= N-M; j++) {
      bool valid = true;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (A[i+k][j+l] != B[k][l]) {
            valid = false;
          }
        }
      }
      if (valid) {
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

#define N 100

int main(){
  int kazu,i,j,m[N],l,x[N][N],q,n[N],k;

  scanf("%d",&kazu);

  for(i=1;i<=kazu;i++){
    scanf("%d%d",&n[i],&m[i]);
  }

  m[0]=n[1];

  for(i=1;i<=kazu;i++){
    x[i][i]=0;
  }

  for(l=2;l<=kazu;l++){
    for(i=1;i<=kazu-l+1;i++){
      j=i+l-1;
      x[i][j]=2147483645;
      for(k=i;k<j;k++){
	q=x[i][k]+x[k+1][j]+m[i-1]*m[k]*m[j];
	if(q<x[i][j]) x[i][j]=q;
      }
    }
  }

  printf("%d\n",x[1][j]);

  return 0;
}



Measured memory_bytes: 2148
#include <stdio.h>
#include <algorithm>

using namespace std;

//long long
const long long NN = 120000;
struct point {
	long long x , y , i;
} s[NN];
struct edge {
	long long x , y , c;
} e[NN*2];
long long n;
long long c[NN];
long long ans;
bool cmp1 ( point x1 , point x2 ) {
	return x1.x < x2.x;
}
bool cmp2 ( point x1 , point x2 ) {
	return x1.y < x2.y;
}
bool cmp3 ( edge x1 , edge x2 ) {
	return x1.c < x2.c;
}
long long find ( long long x ) {
	long long i , t;
	for ( i = x ; c[i] > 0 ; i = c[i] ) ;
	while ( c[x] > 0 ) {
		t = c[x];
		c[x] = i;
		x = t;
	}
	return i;
}
void Union ( long long x , long long y ) {
	c[x] = y;
}
void work () {
	long long i;
	scanf ( "%lld" , &n );
	for ( i = 1 ; i <= n ; i++ ) c[i] = -1;
	for ( i = 1 ; i <= n ; i++ ) {
		scanf ( "%lld%lld" , &s[i].x , &s[i].y );
		s[i].i = i;
	}
	sort ( s + 1 , s + 1 + n , cmp1 );
	for ( i = 1 ; i < n ; i++ ) {
		e[i].x = s[i].i;
		e[i].y = s[i+1].i;
		e[i].c = s[i+1].x - s[i].x;
	}
	sort ( s + 1 , s + 1 + n , cmp2 );
	for ( i = 1 ; i < n ; i++ ) {
		e[n-1+i].x = s[i].i;
		e[n-1+i].y = s[i+1].i;
		e[n-1+i].c = s[i+1].y - s[i].y;
	}
	sort ( e + 1 , e + 1 + n - 1 + n - 1 , cmp3 );
	for ( i = 1 ; i <= n - 1 + n - 1 ; i++ ) {
		if ( find ( e[i].x ) != find ( e[i].y ) ) {
			ans += e[i].c;
			Union ( find ( e[i].x ) , find ( e[i].y ) );
		}
	}
	printf ( "%lld\n" , ans );
}
int main () {
	work ();
	return 0;
}

Measured memory_bytes: 8960
n=int(input())
s=[int(input()) for i in range(n)]
m=sum(s)
lst=[]
for u in s:
    if u%10!=0:
        lst.append(u)
lst.sort()
if lst:
    if m%10==0:
        print(m-lst[0])
    else:
        print(m)
else:
    print(0)

Measured memory_bytes: 3064
N=int(input())
ans={'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(N):
    S=input()
    ans[S]+=1
AC=str(ans['AC'])
WA=str(ans['WA'])
TLE=str(ans['TLE'])
RE=str(ans['RE'])

print('AC x '+AC)
print('WA x '+WA)
print('TLE x '+TLE)
print('RE x '+RE)

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

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

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

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

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

const LL INF = 1LL << 59;

vector<LL> func(int n, vector<LL> &v, LL sig){
	vector<LL> ret;
	priority_queue<LL> pq;
	LL sum = 0;
	for(int i = 0; i < 2 * n; ++i){
		LL x = v[i] * sig;
		sum += x;
		pq.push(-x);
		if(i >= n){
			sum += pq.top();
			pq.pop();
		}
		if(i >= n - 1){
			ret.push_back(sum);
		}
	}
	return ret;
}

void mainmain(){
	int n;
	scanf("%d", &n);
	vector<LL> as(3 * n);
	for(int i = 0; i < 3 * n; ++i){
		scanf("%lld", &as[i]);
	}
	vector<LL> v1 = func(n, as, 1);
	reverse(ALL(as));
	vector<LL> v2 = func(n, as, -1);

	LL ans = -INF;
	int sz = v1.size();
	for(int i = 0; i < sz; ++i){
		LL t = v1[i] + v2[sz - 1 - i];
		chmax(ans, t);
	}
	printf("%lld\n", ans);
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 5992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pair<int,int>>

int main(){
    ios::sync_with_stdio(0);
    int h, w, ans = 0;
    cin >> h >> w;
    char maze[h][w];
    for (int i = 0 ; i < h ; ++i)
        cin >> maze[i];
    int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
    for (int si = 0 ; si < h ; ++si){
        for (int sj = 0 ; sj < w ; ++sj){
            if (maze[si][sj] == '#')
                continue;
            queue<pair<pii,int>> Q;
            bool vis[h][w] = {false};
            for (int i = 0 ; i < h ; ++i){
                for (int j = 0 ; j < w ; ++j)
                    vis[i][j] = false;
            }
            Q.push({{si,sj},0});
            while(!Q.empty()){
                int x = Q.front().first.first, y = Q.front().first.second, l = Q.front().second;
                Q.pop();
                if (vis[x][y])
                    continue;
                vis[x][y] = true;
                ans = max(ans, l);
                for (int i = 0 ; i < 4 ; ++i){
                    if (x+dx[i] >= 0 && x+dx[i] < h && y+dy[i] >= 0 && y+dy[i] < w && !vis[x+dx[i]][y+dy[i]] && maze[x+dx[i]][y+dy[i]] == '.')
                        Q.push({{x+dx[i],y+dy[i]},l+1});
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = [int(_) for _ in input().split()]
cnt = 0

for p1, p2, p3 in zip(p, p[1:], p[2:]):
    if (p1 < p2 and p2 < p3) or (p1 > p2 and p2 > p3):
        cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    vector<int> t(n+1),x(n+1),y(n+1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    rep(n){
        cin >> t[i+1] >> x[i+1] >> y[i+1];
        int diff = (t[i+1]-t[i]) - (abs(x[i+1]-x[i])+abs(y[i+1]-y[i]));
        if(diff >= 0 && diff % 2 == 0){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
long long column;
cin>>column;
string ans="";
while(column>26){
            long long mod=column%26;
            if(mod==0){
                mod=26;
                column--;
            }
            ans+=('a'+(mod-1));
            column/=26;
        }
        ans+='a'+(column-1);
reverse(ans.begin(),ans.end());
cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3608
n = int(input())
s = list(input())
r = s.count("R")
w = s.count("W")
p, q = 0, 0
for i in range(r):
    if s[i] == "W":
        p += 1

for i in range(r, n):
    if s[i] == "R":
        q += 1

print(min(p, q))

Measured memory_bytes: 10636
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int d = sc.nextInt();
        int g = sc.nextInt();
        int[][] scoreList = new int[d][3];

        for (int i = 0; i < d; i++) {
            scoreList[i][0] = sc.nextInt();
            scoreList[i][1] = sc.nextInt();
            scoreList[i][2] = scoreList[i][0] * (100 * (i + 1)) + scoreList[i][1];
        }

        int ans = Integer.MAX_VALUE;

        for (int i = 0; i < Math.pow(2, d); i++) {
            int nowBit = i;
            int index = Integer.highestOneBit(nowBit);
            int pointSum = 0;
            int count = 0;
            while (index > 0) {
                nowBit -= index;
                index = (int)(Math.log(index) / Math.log(2));
                pointSum += scoreList[index][2];
                count += scoreList[index][0];
                index = Integer.highestOneBit(nowBit);
            }
            if (pointSum < g) {
                int amari = g - pointSum;
                int maxIndex = (int)(Math.log(Integer.highestOneBit(~i & ((int) Math.pow(2, d) - 1))) / Math.log(2));
                int value =  (maxIndex + 1) * 100;
                if (amari <= (scoreList[maxIndex][0] - 1) * value) {
                    count += Math.ceil((double)amari / value);
                } else {
                    continue;
                }
            }
            ans = Math.min(ans, count);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23508
#include <iostream>
using namespace std;
int main(){
int a,b,n;
int sum = 0;
  cin >> a >> b;
  for(int i = 0;i<a;i++){
    cin >> n;
    if(n>=b-n){
    sum += 2*(b-n);
    }else{
    sum += 2*n;
    }
  }
  cout << sum << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M,X,Y;
  cin>>N>>M>>X>>Y;
  vector<int>x(N),y(M);
  for(int i=0;i<N;i++)cin>>x[i];
  for(int i=0;i<M;i++)cin>>y[i];
  for(int z=X+1;z<=Y;z++){
    bool war=false;
    for(int i=0;i<N;i++)if(x[i]>=z)war=true;
    for(int i=0;i<M;i++)if(y[i]<z)war=true;
    if(!war){
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
using namespace std;


class PMA{//Aho-Corasick
	int id;
	bool match;
	PMA *failure;
	PMA *next[256];
public:
	PMA(int id=0):id(id),match(false),failure(0){
		memset(next,0,sizeof(next));
	}
	~PMA(){
		for(int i=0;i<256;i++){
			if(next[i]&&next[i]!=this)delete next[i];
		}
	}
	int getID()const{return id;}
	bool matched()const{return match;}
	void build(const vector<string> &p){
		int num=1;
		for(int i=0;i<(int)p.size();i++){
			const string &s=p[i];
			PMA *t=this;
			for(int j=0;j<(int)s.size();j++){
				if(!t->next[s[j]])t->next[s[j]]=new PMA(num++);
				t=t->next[s[j]];
			}
			t->match=true;
		}
		queue<PMA*> q;
		for(int i=0;i<256;i++){
			if(next[i]){
				q.push(next[i]);
				next[i]->failure=this;
			}else next[i]=this;
		}
		while(!q.empty()){
			PMA *t=q.front();q.pop();
			for(int i=0;i<256;i++){
				if(t->next[i]){
					q.push(t->next[i]);
					PMA *r=t->failure;
					while(!r->next[i])r=r->failure;
					t->next[i]->failure=r=r->next[i];
					t->next[i]->match |= r->match;
				}
			}
		}
	}
	PMA *step(char c)const{
		const PMA *t=this;
		while(!t->next[c])t=t->failure;
		return t->next[c];
	}
};

string ch("DRUL");
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

int h,w;
char m[52][52];
int dp[51][51][102];

struct Node{
	int y,x;
	PMA *p;
};
int bfs(PMA &pma){
	memset(dp,-1,sizeof(dp));
	Node a,b;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)if(m[i][j]=='S'){
		a.y=i;
		a.x=j;
		a.p=&pma;
	}
	queue<Node> q;
	dp[a.y][a.x][a.p->getID()]=0;
	q.push(a);
	while(!q.empty()){
		a=q.front();q.pop();
		int d=dp[a.y][a.x][a.p->getID()];
		for(int i=0;i<4;i++){
			b.y=a.y+dy[i];
			b.x=a.x+dx[i];
			if(m[b.y][b.x]=='#')continue;
			b.p=a.p->step(ch[i]);
			if(b.p->matched())continue;
			if(m[b.y][b.x]=='G')return d+1;
			if(dp[b.y][b.x][b.p->getID()]==-1){
				dp[b.y][b.x][b.p->getID()] = d+1;
				q.push(b);
			}
		}
	}
	return -1;
}

int main(){
	while(cin>>h>>w&&(h||w)){
		memset(m,'#',sizeof(m));
		for(int i=1;i<=h;i++)
			for(int j=1;j<=w;j++)
				cin>>m[i][j];
		int n;
		cin>>n;
		vector<string> p(n);
		for(int i=0;i<n;i++){
			cin>>p[i];
		}
		PMA pma;
		pma.build(p);
		cout<<bfs(pma)<<endl;
	}
	return 0;
}

Measured memory_bytes: 2448
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll y;
    cin >> y;
    prt(x+y/2)
    return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;

void main()
{
    auto input = readln.chomp.split.to!(int[]);
    auto H = input[0];
    auto W = input[1];

    auto S = new string[H];
    foreach(ref i ; S)
        i = readln.chomp.to!string;
    
    int[8] dx = [-1, 1, 0, 0, -1, -1, 1, 1];
    int[8] dy = [0, 0, -1, 1, -1, 1, -1, 1];
    foreach(i ; 0..H){
        foreach(int j ; 0..W){
            if(S[i][j] == '.'){
                int count = 0;
                foreach(k ; 0..8){
                    int nx = j + dx[k];
                    int ny = i + dy[k];
                    if(0 <= nx && nx < W && 0 <= ny && ny < H && S[ny][nx] == '#'){
                        count++;
                    }
                }
                count.write;
            }
            else S[i][j].write;
        }
        writeln;
    }
}

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

const int N = 1e5 + 5;
const int mod = (int) 1e9 + 7;

ll f[N], inv[N], finv[N];

void init() {
	f[0] = f[1] = inv[0] = inv[1] = finv[0] = finv[1] = 1;
	for (int i = 2; i < N; i++) {
		f[i] = (f[i - 1] * i) % mod;
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
		finv[i] = (finv[i - 1] * inv[i]) % mod;
	}
}

ll nCr(ll n, ll r) {
	return (f[n] * ((finv[r] * finv[n - r]) % mod)) % mod;
}

int n, k;
ll a[N], c[N], s[N];

int main() {
	std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	init();
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i >= k - 2) {
			c[i] = nCr(i, k - 2);
			(s[i] = s[i - 1] + c[i]) %= mod;
		}
	}
	sort(a, a + n);
	ll res = 0;
	for (int i = n - k, r = k - 2; i >= 0; i--, r++) {
		((res -= a[i] * s[r] % mod) += mod) %= mod;
	}
	for (int j = k - 1, r = k - 2; j <= n - 1; j++, r++) {
		(res += a[j] * s[r] % mod) %= mod;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 4224
N = int(input())
p = list(map(int,input().split()))

q = p.copy()
q.sort()

#pとqを比較
notequal = 0

for i,v in enumerate(p):
    if v != q[i]:
        notequal += 1

if notequal == 0 or notequal == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
from itertools import groupby
n = int(input())
h = list(map(int,input().split()))

h_diff = []
for i in range(len(h)-1):
    h_diff.append(h[i+1] - h[i])
    
result = [sum(item) for val, item in groupby([1 if x > 0 else -1 for x in h_diff])] + [0]
print(-min(result))

Measured memory_bytes: 14528
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int a, b;
	cin >> a >> b;
	string ans;
	if (a > 0 && b > 0)
		ans = "Positive";
	else if (a <= 0 && b >= 0)
		ans = "Zero";
	else if ((b-a) % 2 == 0)
		ans = "Negative";
	else
		ans = "Positive";
	cout << ans << endl;
}



Measured memory_bytes: 256