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

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        final int N = sc.nextInt();
        boolean flg = true;
        for (int i = 0; i < N; i++) {
            int Ai = sc.nextInt();
            if (Ai % 2 == 0 && Ai % 3 != 0 && Ai % 5 != 0) {
                flg = false;
                break;
            }
        }
        out.println(flg ? "APPROVED" : "DENIED");
        out.flush();
    }
}

// FastScanner start
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
// FastScanner end

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define ll long long int
 
 
int main(){
    int n,a,b;cin>>n>>a>>b;
    int c;c=min(n*a,b);
    cout<<c<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    unsigned N;
    scanf("%u", &N);
    unsigned X[N], _X[N];
    for(int i = 0; i < N; ++i){
        scanf("%u", X + i);
        _X[i] = X[i];
    }
    sort(_X, _X + N);
    for (size_t i = 0; i < N; i++){
        printf("%u\n", (X[i] >= _X[N>>1]) ? _X[(N>>1)-1] : _X[N>>1]);
    }
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std ;
const int N = 1234567;
vector <pair<int,int> > G[N] ;
vector <int> newg[N] ;
queue <int> q ;
int f[N],son[N],id[N],dp[N] ;
bool use[N] ;
int n,m ;
inline void init(int i){
	f[i]=i;son[i]=0;id[i]=-1;use[i]=false ;
}
int find(int x){
	return (x==f[x])?x:f[x]=find(f[x]) ; 
}
inline void merge(int x,int y){
	int X=find(x),Y=find(y) ;
	if (X==Y) return ;
	if (son[X]<son[Y]) f[X]=Y ;//避免被hack 
	else {
		f[Y]=X ;
		if (son[X]==son[Y]) son[X]++ ;
	}
} 
inline int read(){
	char c;int f=1 ;
	while ((c=getchar())<'0' || c>'9') if (c=='-') f=-1 ;
	int res=c-'0' ;
	while ((c=getchar())>='0' && c<='9') res=res*10+c-'0' ;
	return res*f ; 
}
int main(){
	n=read();m=read() ;
	for (int i=1;i<=m;i++){
		int a,b,c ;
		a=read();b=read();c=read() ;
		G[c].push_back(make_pair(a,b)) ;
	}
	int cnt=n; 
	for (int i=1;i<=N;i++){
		if (G[i].empty()) continue ; //无该公司 
		for (int j=0;j<G[i].size();j++){ //初始 
			init(G[i][j].first) ;
			init(G[i][j].second) ;
		}
		for (int j=0;j<G[i].size();j++) merge(G[i][j].first,G[i][j].second) ;
		for (int j=0;j<G[i].size();j++){
			if (!use[G[i][j].first]){
				use[G[i][j].first]=true ;
				int X=find(G[i][j].first) ;
				if (id[X]==-1) id[X]=++cnt ;
				newg[G[i][j].first].push_back(id[X]) ;//该站点与公司建无向边 
				newg[id[X]].push_back(G[i][j].first) ;
			}
			if (!use[G[i][j].second]){ //同样的工作在second上再做一遍 
				use[G[i][j].second]=true ;
				int X=find(G[i][j].second) ;
				if (id[X]==-1) id[X]=++cnt ;
				newg[G[i][j].second].push_back(id[X]) ;
				newg[id[X]].push_back(G[i][j].second) ;
			}
		}
 	}
 	q.push(1) ;
 	memset(dp,-1,sizeof(dp)) ;
 	dp[1]=0; //初始在0号节点
	while(!q.empty()){ //BFS 
		int v=q.front();q.pop() ;
		for (int i=0;i<newg[v].size();i++){
			int to=newg[v][i] ;
			if (dp[to]==-1){ //还没访问 
				dp[to]=dp[v]+1 ;
				q.push(to) ;
			}
		}
	}
//	for (int i=1;i<=n;i++) cout<<dp[i]<<" " ;
	if (dp[n]==-1) cout<<-1 ;
	else cout<<dp[n]/2 ;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A+B > C+D) cout << "Left" << endl;
    else if (A+B < C+D) cout << "Right" << endl;
    else cout << "Balanced" << endl;
    return 0;
}

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

using namespace std;

int main() {
  int x, y, z;
  scanf("%d %d %d", &x, &y, &z);
  multiset<string> chars;
  for (int i = 0; i < x; i++) chars.insert("a");
  for (int i = 0; i < y; i++) chars.insert("b");
  for (int i = 0; i < z; i++) chars.insert("c");
  while (chars.size() > 1) {
    string first = *chars.begin();
    chars.erase(chars.begin());
    string last = *prev(chars.end());
    chars.erase(prev(chars.end()));
    chars.insert(first + last);
  }
  printf("%s\n", chars.begin()->c_str());
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
arr=set([int(input()) for _ in range(m)])
dp=[0]*(n+1)
if 1 not in arr:
  dp[1]=1
if n>=2:
  if 2 not in arr:
    dp[2]=dp[1]+1
for i in range(3,n+1):
  if i not in arr:
    dp[i]=(dp[i-1]+dp[i-2])%1000000007
print(dp[n]%1000000007)

Measured memory_bytes: 13192
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		HashMap<Integer,Integer> map = new HashMap<>();

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

			int num = sc.nextInt();
			Integer cnt = map.get(num);

			if (cnt == null) {
				map.put(num, 1);
			} else {
				map.put(num, cnt + 1);
			}
		}

		ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet());

		int ans = 0;

		for(Entry e: list) {
			if ((int)e.getValue() %2 !=0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 62996
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem141d(n, m, a))
}

fun problem141d(n: Int, m: Int, a: List<Long>): Long {
    val queue: Queue<Long> = PriorityQueue<Long>(n) { i1: Long, i2: Long ->
        return@PriorityQueue if (i2 > i1) 1 else -1
    }
    for (i in 0 until n) {
        queue.add(a[i])
    }
    for (i in 0 until m) {
        queue.add(queue.poll() / 2)
    }
    return queue.sum()
}

Measured memory_bytes: 53392
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val testimony = Array(N) { mutableListOf<Pair<Int, Boolean>>() }
    
    for (i in 0 until N) {
        val A = readInputLine().toInt()
        for (j in 0 until A) {
            val (x, y) = readInputLine().split(" ").map { it.toInt() }
            testimony[i].add(Pair(x - 1, y == 1))
        }
    }
    
    var ans = 0
    
    for (i in 0 until pow2(N)) {
        var ok = true
        for (j in 0 until N) {
            if ((i shr j) % 2 == 0) {
                continue
            }
            for (t in testimony[j]) {
                if ((i shr t.first) % 2 == 1 != t.second) {
                    ok = false
                    break
                }
            }
            if (!ok) {
                break
            }
        }
        if (ok) {
            var tmp = 0
            for (j in 0 until N) {
                if ((i shr j) % 2 == 1) {
                    tmp++
                }
            }
            if (tmp > ans) {
                ans = tmp
            }
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}

fun pow2(x: Int): Int {
    var ret = 1
    for (i in 0 until x) {
        ret *= 2
    }
    return ret
}


Measured memory_bytes: 41056
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
    ll n; cin >> n;
    string s;
    if (n == 0) {
        cout << 0 << endl;
    }
    while (n) {
        
        if (n % 2 == 0){
            s = "0" + s;
            n /= -2;
        } else {
            n -= 1;
            s = "1" + s;
            n /= -2;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define zero(x) x&(-x)
#define int long long
using namespace std;
const int nmax=1e5+3e3+3;
int n,usu[nmax],x,poz[nmax],st1,st2,dr1,dr2,act,st,dr,act2,v[nmax],sol;
void update(int ind)
{
    for(int i=ind;i<=n;i+=zero(i)) ++usu[i];
}
int sum(int x)
{
    int s=0;
    for(int i=x;i>=1;i-=zero(i)) s+=usu[i];
    return s;
}
 main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>x;
        poz[x]=i;
    }
    update(poz[n]);
    for(int i=n-1;i>=1;--i)
    {
        st1=st2=dr1=dr2=-1;
        act=sum(poz[i]);
        if(act>=1)
        {
            st=1;
            dr=poz[i]-1;
            while(st<=dr)
            {
                int mij=(st+dr)/2;
                int pwp=sum(mij);
                if(pwp==act)
                {
                    st1=mij;
                    dr=mij-1;
                    continue;
                }
                if(pwp<act)
                {
                    st=mij+1;
                    continue;
                }
            }
        }

        if(act>=2)
        {
            st=1;
            dr=st1-1;
            while(st<=dr)
            {
                int mij=(st+dr)/2;
                int pwp=sum(mij);
                if(pwp>=act-1)
                {
                    st2=mij;
                    dr=mij-1;
                    continue;
                }
                if(pwp<act-1)
                {
                    st=mij+1;
                    continue;
                }
            }
        }

        act2=sum(n);

        if(act2-act>=1)
        {
            st=poz[i]+1;
            dr=n;
            while(st<=dr)
            {
                int mij=(st+dr)/2;
                int pwp=sum(mij);
                if(pwp>=act+1)
                {
                    dr1=mij;
                    dr=mij-1;
                    continue;
                }
                if(pwp<act+1)
                {
                    st=mij+1;
                    continue;
                }
            }
        }

        if(act2-act>=2)
        {
            st=dr1+1;
            dr=n;
            while(st<=dr)
            {
                int mij=(st+dr)/2;
                int pwp=sum(mij);
                if(pwp>=act+2)
                {
                    dr2=mij;
                    dr=mij-1;
                    continue;
                }
                if(pwp<act+2)
                {
                    st=mij+1;
                    continue;
                }
            }
        }
        if(st2==-1) st2=0;
        if(dr2==-1) dr2=n+1;
       // cout<<i<<' '<<st1<<' '<<st2<<' '<<dr1<<' '<<dr2<<'\n';
        int ant=sol;
        if(st1!=-1)
        {
            int dp=dr1;
            if(dp==-1) dp=n+1;
            sol+=(st1-st2)*(dp-poz[i])*i;
        }
        if(dr1!=-1)
        {
            st1=max(st1,0ll);
            sol+=(poz[i]-st1)*(dr2-dr1)*i;
        }
       // cout<<sol-ant<<'\n';
        update(poz[i]);
    }
    cout<<sol;
}


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

using namespace std;

typedef long long ll;

int main (int argc, char const *argv[]) {
  ll h, w;
  cin >> h >> w;
  ll ans = 1e18 + 10;
  for (ll i = 1; i <= h; ++i) {
    ll a = w * i;
    ll x = h - i, y = w;
    ll b = (x / 2) * y;
    ll c = b + (x % 2) * y;
    ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
    b = x * (y / 2);
    c = b + (y % 2) * x;
    ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
  }
  for (ll i = 1; i <= w; ++i) {
    ll a = h * i;
    ll x = w - i, y = h;
    ll b = (x / 2) * y;
    ll c = b + (x % 2) * y;
    ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
    b = x * (y / 2);
    c = b + (y % 2) * x;
    ans = min(ans, max(a, max(b, c)) - min(a, min(b, c)));
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s,r;
    int cnt=0,len;
    cin>>s;
    len=s.length();
    if((s[0]==s[len-1] && len%2==0) || (s[0]!=s[len-1] && len%2==1))
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
using namespace std;
typedef pair<int,int> P;
vector<P> vec;
int wall[102][102];
int W,H,ans=0;
const int dy[6]={-1,-1,0,0,1,1};
const int dx[2][6]={{-1,0,-1,1,-1,0},{0,1,-1,1,0,1}};
void bfs(){
	queue<P> task;task.push(make_pair(0,0));
	while(!task.empty()){
		int x=task.front().first;
		int y=task.front().second;
		task.pop();
		for(int i=0;i<6;i++){
			int nx=x+dx[y%2][i];
			int ny=y+dy[i];
			if(0<=nx&&nx<=W+1&&0<=ny&&ny<=H+1&&wall[nx][ny]==2){
				task.push(make_pair(nx,ny));
				wall[nx][ny]=0;
			}
		}
	}
	return;
}
void cal(){
	for(int i=0;i<(int)vec.size();i++){
		int x=vec[i].first;
		int y=vec[i].second;
		for(int j=0;j<6;j++){
			int nx=x+dx[y%2][j];
			int ny=y+dy[j];
			if(wall[nx][ny]==0)ans++;
		}		
	}
	return;
}
int main()
{
	cin>>W>>H;
	for(int i=0;i<=H+1;i++)
		for(int j=0;j<=W+1;j++)wall[j][i]=2;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			int tmp;cin>>tmp;
			if(tmp==1){
				wall[j][i]=1;
				vec.push_back(make_pair(j,i));
			}
		}
	}
	bfs();cal();
	printf("%d\n",ans);
}

Measured memory_bytes: 1344
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, len(p)-1):
    if p[i-1] < p[i] and p[i+1] > p[i]:
        cnt += 1
    elif p[i-1] > p[i] and p[i+1] < p[i]:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
a,b = list(map(int,input().split()))
a,b = max(a,b),min(a,b)

if b == 1:
  print(1)
elif a%2==0 :
  print((a//2)*b)
elif b%2 == 0:
  print((b//2)*a)
else :
  print(a*(b//2)+(a//2)+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  p=1e9+7; 

 int main() {
        ff;
       
       ll n,m;
       cin>>n>>m;
       
       ll a[n+1];
       for(ll i=1;i<=n;i++){
           cin>>a[i];
       }
       ll x,y;
       vector<ll> ans[n+1];
       while(m--){
           cin>>x>>y;
           ans[x].push_back(y);
           ans[y].push_back(x);
       }
      ll cnt=0;
      
      for(ll i=1;i<=n;i++){
          ll f=0;
          if(ans[i].size()==0){
              cnt++;
              
          }else{
          set<ll> ansi;
          for(int k=0;k<ans[i].size();k++){
              ansi.insert(ans[i][k]);
          }
          
          for(auto j=ansi.begin();j!=ansi.end();j++){
            
            
            if(a[i]<=a[*j]){
                f=1;
                break;
            }
          }
          
          
          if(f==0){
              cnt++;
          }
          }
      }
       cout<<cnt<<endl;
      
    return 0;
}


Measured memory_bytes: 12012
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint P(int n, int k){
    return fact[n]*ifact[n-k];
  }
}comb(max_n);

int main(){
  ll h,w,n;cin >> h >> w >> n;
  vpl c;c.pb({0,0});
  rep(i,n){
    ll a,b;cin >> a >> b;a--;b--;c.pb({a,b});
  }
  c.pb({h-1,w-1});
  sort(all(c));
  n+=2;
  mint dp[n][2];dp[0][0]=1;
  rep(i,n){
    rep(j,i){
      ll x=c[i].fi-c[j].fi,y=c[i].se-c[j].se;
      dp[i][0]+=dp[j][1]*comb(x+y,x);
      dp[i][1]+=dp[j][0]*comb(x+y,x);
    }
    //rep(j,n)cout << dp[j][0]<<" ";cout << endl;
    //rep(j,n)cout << dp[j][1]<<" ";cout << endl;
    //cout << endl;
  }
  cout << dp[n-1][1]-dp[n-1][0] <<endl;
}

Measured memory_bytes: 6696
import sys


def input():
    return sys.stdin.readline()[:-1]


s = str(input())
ans = 0
for i in range(1 << len(s)-1):
    temp = ''
    for j in range(len(s)-1):
        if (i >> j) & 1:
            temp += s[j] + '+'
        else:
            temp += s[j]
    ans += eval(temp+s[-1])
print(ans)


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


#define long long long int

using namespace std;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef pair<int, int> pi;


int main() {
    std::ios_base::sync_with_stdio(false);
    int s;
    string t;
    cin >> s >> t;
    cout << (s < 3200 ? "red" : t);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

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

    int kaisuu = 0;
    for (int i = 0; i < 100; i++)
    {
        if (a >= b)
        {
            b *= 2;
            kaisuu++;
        }
        if (b >= c)
        {
            c *= 2;
            kaisuu++;
        }
        
    }
    if (kaisuu <= k)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void)
{
	int n,m,a[1001],i,l=0,p=0;
	float u;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		l+=a[i];
	}
	u=(float)l*1/(4*m);
	for(i=0;i<n;i++){
		if(a[i]>=u){
			p++;
		}
	}
	if(p>=m){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
S = list(input())
count = 0
if N == 1:
    print('0')
    exit()
if S[0] == 'R' and S[1] == 'R':
    count += 1
if S[N - 2] == 'L' and S[N - 1] == 'L':
    count += 1
for i in range(1, N-1):
    if [S[i - 1], S[i]] == ['L', 'L'] or [S[i], S[i + 1]] == ['R', 'R']:
        count += 1
print(str(min(N - 1, count + K * 2)))

Measured memory_bytes: 4084
s=input()
i=0
flag=True
while i<len(s):
  if s[i]=="d":

    if s[i:i+7]=="dreamer":
      if i+7<len(s) and s[i+7]!="a":
        i=i+7
      elif i+7==len(s):
        i=i+7
      elif s[i:i+5]=="dream":
        i=i+5
      else:
        flag=False
        break
    elif s[i:i+5]=="dream":
        i=i+5
    else:
      flag=False
      break
      
      
  elif s[i]=="e":
    if s[i:i+6]=="eraser":
      i=i+6
    elif s[i:i+5]=="erase":
      i=i+5
    else:
      flag=False
      break
      
      
  else:
    flag=False
    break
if flag==True:
  print("YES")
else:
  print("NO")
      

Measured memory_bytes: 3188
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int int64;
typedef vector<int64> VI64;
typedef vector<pair<int64,int64>> VII64;
typedef vector<string> VS;
typedef vector<vector<int64>> VVI;

int main()
{
    IOS;
    int64 T=1;
    //cin>>T;
    while(T--)
    {
        int64 n,i;
        cin>>n;
        int64 ans=0;
        int64 a[n];
        for(i=0;i<n;i++)
            cin>>a[i];
        int64 cur=0;
        for(i=0;i<n-1;i++)
        {
            if(a[i+1]>a[i])
                cur=0;
            else
                cur++;
            ans=max(ans,cur);
        }
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <time.h>
#include <stdlib.h>
#include <bitset>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define LL_INF 1e18

#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;

typedef long long int ll;

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

#define nmax (1 << 17) + 5
#define MOD (int)((1e9) + 7)

int n;
ll val[nmax]; // mask (value if we choose to have these rabits in the same group)
ll dp[nmax]; // dp[mask] , mask already grouped rabits
int a[20][20];

bool fr[nmax];

ll back(int mask)
{
    if (fr[mask]) return dp[mask];

    fr[mask] = true;

    vector <int> vc;

    for (int i = 0; i < n; i++)
        if (((mask >> i) & 1)) vc.pb(i);

    int nn = SZ(vc);

    // remove some bits
    for (int i = 0; i < (1 << nn); i++)
    {
        int c_mask = 0;

        for (int j = 0; j < nn; j++)
            if ((i >> j) & 1) c_mask |= (1 << vc[j]);

        // remove c_mask from mask

        dp[mask] = max(dp[mask], back(c_mask) + val[mask ^ c_mask]);
    }

    return dp[mask];
}

int main()
{
    scanf("%d", &n);

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            scanf("%d", &a[i][j]);

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

        ll sum = 0;

        vector <int> vc;

        for (int j = 0; j < n; j++)
            if (((i >> j) & 1) == 1) vc.pb(j + 1);

        for (int j = 0; j < SZ(vc); j++)
            for (int k = j + 1; k < SZ(vc); k++)
                sum = sum + a[vc[j]][vc[k]];

        val[i] = sum;
    }

    fr[0] = true;

    printf("%lld", back((1 << n) - 1));

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

Measured memory_bytes: 1408
N = int(input())
 
link = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    link[u - 1].append((v - 1, w))
    link[v - 1].append((u - 1, w))
 
d = [-1] * N
d[0] = 0
q = [0]
while q:
  i = q.pop(0)
  for n, w in link[i]:
    if d[n] == -1:
      d[n] = d[i] + w
      q.append(n)
 
for i in d:
  print(i % 2)

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

int main() {
  string S;
  cin>>S;
  vector<string>X={"SAT","FRI","THU","WED","TUE","MON","SUN"};
  for(int i=0;i<7;i++){
    if(S==X.at(i)){
      cout<<i+1<< endl;
    }
  }
}
  


Measured memory_bytes: 256
<?php
$house = array();
for ($i = 1; $i <= 4; $i++) {
	for ($j = 1; $j <= 30; $j++) {
		$house[$i][$j] = 0;
	}
}

$n = trim(fgets(STDIN));
for ($k = 0; $k < $n; $k++) {
	list($b, $f, $r, $v) = explode(" ", trim(fgets(STDIN)));
	$house[$b][($f-1)*10+$r] += $v;
}

foreach ($house as $num => $ridge) {
	foreach ($ridge as $key => $room) {
		echo " ".$room;
		if ($key == 10 || $key == 20) echo "\n";
		if ($num < 4 && $key == 30) echo "\n####################\n";
	}
}
echo "\n";

Measured memory_bytes: 15408
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int r, g, b, n;cin>>r>>g>>b>>n;
    vector<int> rgb{r, g, b};
    sort(rgb.begin(), rgb.end());

    int big, mid, small;
    big = rgb[2];
    mid = rgb[1];
    small = rgb[0];

    int acc = 0;
    for (int i=0;i<=n/big;i++){
        int temp_1 = n - big * i;
        for (int j=0;j<=temp_1/mid;j++){
            int temp_2 = temp_1 - mid * j;
            if (temp_2 % small == 0){
                acc++;
            }
        }
    }
    cout << acc << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int h, w, d, res[505][505];
string s = "RGBY";

signed main() {
	cin >> h >> w >> d;
	if (d%2) {
		rep(i,h) rep(j,w) res[i][j] = (i+j)%2;
	}
	else {
		rep(i,h) rep(j,w) {
			int di = i+j+1000, dj = i-j+1000;
			res[i][j] = di/d%2*2 + dj/d%2;
			if ((i+j)%2) res[i][j] ^= 3;
		}
	}
	rep(i,h) {
		rep(j,w) cout << s[res[i][j]];
		cout << endl;
	}
}

Measured memory_bytes: 1536
#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>
using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, 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 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 ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


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

int gcd(int a, int b)
{
    if (a < b) swap(a, b);
    while (true)
    {
        if (b == 0) break;
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main()
{
    int N;
    cin >> N;
    int A[N];
    REP(i, N) cin >> A[i];
    REP(i, N - 1)
    {
        A[i + 1] = gcd(A[i], A[i + 1]);
    }
    cout << A[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (a, v) = readLine()!!.split(' ').map { it.toLong() }
    val (b, w) = readLine()!!.split(' ').map { it.toLong() }
    val t = readLine()!!.toLong()

    val distance = if (b > a) {
        b - a
    } else {
        a - b
    }
    
    if (distance <= (v - w) * t) {
        println("YES")
    } else {
        println("NO")
    }
}


Measured memory_bytes: 36304
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>s;
        if(s=="RRR")
            ans=3;
        else if(s=="RRS" || s=="SRR")
            ans = 2;
        else if(s=="SSS")
            ans=0;
        else ans =1;
        cout<<ans<<endl;
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3556
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var s = o.getValue(0);
    var t = o.getValue(1);

    var result = 0;
    for (let i = 0; i < s.length; i++) {
        if (s[i] !== t[i]) result++;
    }

    return result;
}

Measured memory_bytes: 32984
n=int(input())
A=list(map(int,input().split()))
o,e_4=0,0
for i in range(n):
    if A[i]%2:
        o+=1
    elif not A[i]%4:
        e_4+=1
if o<=e_4:
    print('Yes')
elif o==e_4+1:
    print('Yes' if o+e_4==n else 'No')
else:
    print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<typename T> vector<T> tensor(int n, T v){ return vector<T>(n, v); }
template<typename... Ts> auto tensor(int n, Ts... ts) {
    return vector<decltype(tensor(ts...))>(n, tensor(ts...));
}

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

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    map<lint, lint> next;
    auto dub = tensor(60, n, 0LL);
    for(lint i=n+n-1; i>=0; i--) {
        if(i<n) dub[0][i] = next[a[i]] - i + 1;
        next[a[i%n]] = i;
    }

    for(lint c=0; c+1<60; c++)
    for(lint i=0; i<n; i++) {
        lint mid = (i + dub[c][i]) % n;
        dub[c+1][i] = min(1LL<<60, dub[c][i] + dub[c][mid]);
    }

    lint reach = 0;
    for(lint c=59; c>=0; c--) {
        lint len = dub[c][reach%n];
        if(reach + len <= n*k) reach += len;
    }

    vector<lint> b(a.begin() + reach%n, a.end());
    map<lint, bool> exist;
    vector<lint> ans;
    for(auto num : b) {
        if(exist[num]) {
            while(exist[num]) {
                exist[ans.back()] = false;
                ans.pop_back();
            }
        } else {
            exist[num] = true;
            ans.push_back(num);
        }
    }

    for(auto& e : ans)  cout << e << " \n"[&e == &ans.back()];
}

Measured memory_bytes: 125028
#include<iostream>
using namespace std;
int I;
int t[9][9];
bool flg[9][9];
int main(){
  cin>>I;
  while(I--){
    for(int i=0;i<9;i++)for(int j=0;j<9;j++){cin>>t[i][j];flg[i][j]=false;}

    for(int i=0;i<9;i++){      
      for(int j=0;j<9;j++){
	for(int k=0;k<9;k++){
	  if(j==k)continue;
	  if(t[i][j]==t[i][k]){
	    flg[i][j]=true;
	  }
	}//k
      }//j
    }//i

    for(int j=0;j<9;j++){      
      for(int i=0;i<9;i++){
	for(int k=0;k<9;k++){
	  if(i==k)continue;
	  if(t[i][j]==t[k][j]){
	    flg[i][j]=true;
	  }
	}//k
      }//i
    }//j

    for(int i=0;i<9;i+=3){
      for(int j=0;j<9;j+=3){

	for(int k=i;k<i+3;k++){
	  for(int l=j;l<j+3;l++){

	    for(int m=i;m<i+3;m++){
	      for(int n=j;n<j+3;n++){
		if(m==k&&n==l)continue;
		if(t[k][l]==t[m][n])flg[k][l]=true;
	      }//n
	    }//m

	  }//l
	}//k

      }//j
    }//i


    for(int i=0;i<9;i++){
      for(int j=0;j<9;j++){
	cout<<(flg[i][j]?'*':' ')<<t[i][j];
      }
      cout<<endl;
    }
    if(I>0)cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 300123
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define oo 1000000123
#define sz(x) ((int)((x).size()))
#define OUT -oo
#define left(x) (x << 1)
#define right(x) ((x << 1) | 1)
#define mid(a, b) ((a + b) >> 1)

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    for(char c : s){
        if(c == '7') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, m;
   cin >> n >> m;
   vector<int> l(m + 1, 0), r(m + 1, 0);
   for (int i = 1; i <= m; i++)
      cin >> l[i] >> r[i];
   l[0] = *max_element(++l.begin(), l.end());
   r[0] = *min_element(++r.begin(), r.end());
   cout << max(r[0] - l[0] + 1, 0) << endl;
   return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100100;
int n,m,a[MAXN<<1],l,r,pos,ans;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(register int i=1;i<=(n<<1);i++) cin>>a[i];
	sort(a+1,a+(n<<1)+1);
	l=0,r=n;
	while(l<r)
	{
		register int mid=(l+r)>>1,f=1;
		for(register int i=(mid<<1|1);i<=(n<<1);i++)
			if(a[i]+a[(n<<1)+(mid<<1|1)-i]<m) {f=0; break;}
		if(f) r=mid;
		else l=mid+1;
	}
	pos=r<<1;
	for(register int i=1;i<=pos;i++) ans=max(ans,a[i]+a[pos-i+1]);
	for(register int i=pos+1;i<=(n<<1);i++) ans=max(ans,a[i]+a[(n<<1)+pos-i+1]-m);
	cout<<ans<<endl;
	return 0;
}

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

char a[22][22];
//char s[10]="China";   
//s=['C','h',i,n,a,\0,\0,\0,\0,\0]

int n,m;

struct pos{
	int x;
	int y;
	int step;
};

pos make_pos(int a,int b,int c){
	pos ret;
	
	ret.x=a;
	ret.y=b;
	ret.step=c;
	
	return ret;
}

int bfs(int sx,int sy,int ex,int ey){
	bool vis[n+2][m+2];
	
	for(int i=0;i<=n+1;++i)
		for(int j=0;j<=m+1;++j)
			if(a[i][j]=='#')
				vis[i][j]=true;
			else
				vis[i][j]=false;
	
	queue<pos> q;
	q.push(make_pos(sx,sy,0));
	vis[sx][sy]=true;
	int move[2][4]={{0,0,-1,1},{-1,1,0,0}};
	
	while(!q.empty()){
		pos fr=q.front();
		q.pop();
		if(fr.x==ex&&fr.y==ey)
			return fr.step;
			
		pos newpo;
		for(int i=0;i<4;++i){
			int nx=fr.x+move[0][i];
			int ny=fr.y+move[1][i];
			if(vis[nx][ny])
				continue;
			vis[nx][ny]=true;
			newpo=make_pos(nx,ny,fr.step+1);
			q.push(newpo);
		}
	}
	return 0;
}

int main(){
	for(int i=0;i<22;++i)
		for(int j=0;j<22;++j)
			a[i][j]='#';
	
	cin>>n>>m;
	
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			cin>>a[i][j];
	
	int maxv=0;
	
	for(int i1=1;i1<=n;++i1)
		for(int j1=1;j1<=m;++j1){
			if(a[i1][j1]=='#')
				continue;
			for(int i2=1;i2<=n;++i2)
				for(int j2=1;j2<=m;++j2){
					if(a[i2][j2]=='#')
						continue;
					if(i1==i2&&j1==j2)
						continue;
					
					maxv=max(maxv,bfs(i1,j1,i2,j2));
				}
		}
	
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc110b()
}

fun abc110b() {
    val (n, m, x, y) = readLine()!!.split(" ").map { it.toInt() }
    val xList = readLine()!!.split(" ").map { it.toInt() }
    val yList = readLine()!!.split(" ").map { it.toInt() }

    val capitalDistance = (-100..100).filter { it in (x + 1)..y }
    val territoryDistance = (-100..100).filter { it in ((xList.max()!! + 1)..yList.min()!!) }

    val intersected = capitalDistance.intersect(territoryDistance)

    val answer = if (intersected.isNotEmpty()) "No War" else "War"

    println(answer)
}


Measured memory_bytes: 37996
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
typedef long long ll;
const ll N=1e5+5;
const double eps=1e-6;
const int mod=1e9+7;
ll a[90];
void init()
{
    a[0]=2,a[1]=1;
    for(int i=2; i<=86; i++)
        a[i]=a[i-1]+a[i-2];
}
int main()
{
    char a,b,c,d;
    int t[10];
    while(cin>>a>>b>>c>>d)
    {
        a=a-'0';
        b-='0';
        c-='0';
        d-='0';
        t[1]=a+b+c+d;
        if(t[1]==7) {printf("%d+%d+%d+%d=7\n",a,b,c,d);continue;}
        t[2]=a+b+c-d;
        if(t[2]==7) {printf("%d+%d+%d-%d=7\n",a,b,c,d);continue;}
        t[3]=a+b-c+d;
        if(t[3]==7) {printf("%d+%d-%d+%d=7\n",a,b,c,d);continue;}
        t[4]=a+b-c-d;
        if(t[4]==7) {printf("%d+%d-%d-%d=7\n",a,b,c,d);continue;}
        t[5]=a-b+c+d;
        if(t[5]==7) {printf("%d-%d+%d+%d=7\n",a,b,c,d);continue;}
        t[6]=a-b+c-d;
        if(t[6]==7) {printf("%d-%d+%d-%d=7\n",a,b,c,d);continue;}
        t[7]=a-b-c+d;
        if(t[7]==7) {printf("%d-%d-%d+%d=7\n",a,b,c,d);continue;}
        t[8]=a-b-c-d;
        if(t[8]==7) {printf("%d-%d-%d-%d=7\n",a,b,c,d);continue;}
    }
    return 0;
}



Measured memory_bytes: 256
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))


N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

fact = [1]
for i in range(1, N+10):
    fact.append(fact[-1] * i % MOD)
def rev(x):
    return pow(x, MOD-2, MOD)
def cmb(i, k):
    if(i < k): return 0
    return fact[i] * rev(fact[k]) * rev(fact[i-k]) % MOD

minus = 0
plus = 0

for i, a in enu(A):
    mval = cmb(N-i-1, K-1)
    pval = cmb(i, K-1)
    if i<=K-2:
        pval = 0
    if N-K+1<=i:
        mval = 0
#    print(mval, pval)
    minus -= a*mval
    plus += a*pval

print((plus+minus)%MOD)

 


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

using namespace std;
typedef long long ll;

const ll mod=1000000007;

ll fpow(ll b,ll e)
{
    ll res=1;
    while(e)
    {
        if(e&1) res=(res*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    ll m=h+w;
    vector<ll> f(m+1,1);
    for(ll i=1;i<=m;i++) f[i]=(f[i-1]*i)%mod;
    vector<ll> finv(m+1,1);
    finv[m]=fpow(f[m],mod-2);
    for(ll i=m-1;i>=0;i--) finv[i]=(finv[i+1]*(i+1))%mod;
    auto ch=[&](ll n,ll k)->ll
    {
        ll res=f[n];
        res=(res*finv[k])%mod;
        res=(res*finv[n-k])%mod;
        return res;
    };
    ll res=0;
    for(int o=1;o<=h-a;o++) res=(res+ch(o+b-2,b-1)*ch(h+w-o-(b+1),w-(b+1)))%mod;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3328
def m():
    def cost(x,y):
        return (x-y) ** 2
    n = int(input())
    a = list(map(int, input().split()))
    ans = 99999999
    for y in range(-100, 101):
        c = 0
        for x in a:
            c += cost(x,y)
        ans = min(ans, c)
    return ans

print(m())

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

string S, T;

int main() {
    cin >> S >> T;
    int count = 0;
    REP (i, 3) {
        if (S[i] == T[i]) count++;
    }
    cout << count << endl;
}

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

int main(){
	long long a,b,n,x,y;
	cin>>a>>b>>n;
	if(n>=b){
		x=(n+1)/b;
		y=(x*b)-1;
		cout<<(a*y)/b-a*(y/b);
	}
	else{
		cout<<(a*n)/b;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

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

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.length() - 8; i++){
    cout << s[i];
  }
  cout << endl;
  return 0;
}


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

using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using D = double;
using uint = unsigned int;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

const int maxn = 1000006;

char s[maxn];
int n;

bool can(int mxb)
{
	//cout << "can " << mxb << endl;
	for (int par = 0; par < 2; par++)
	{
		int low = par;
		int high = (mxb % 2 == par ? mxb : mxb - 1);
		if (low > high) continue;
		assert(low % 2 == high % 2);
		bool ok = true;
		for (int i = 0; i < n; i++)
		{
			if (s[i] == '0')
			{
				if (low == 0) low = 1;
				else low--;
				high--;
			} else if (s[i] == '1')
			{
				if (high == mxb) high = mxb - 1;
				else high++;
				low++;
			} else if (s[i] == '?')
			{
				if (low == 0) low = 1;
				else low--;
				if (high == mxb) high = mxb - 1;
				else high++;
			} else assert(false);
			//cout << i << ' ' << low << ' ' << high << endl;
			if (low > high)
			{
				ok = false;
				break;
			}
		}
		if (ok) return true;
	}
	return false;
}

int main()
{
	scanf("%s", s);
	n = strlen(s);
	int l = 0;
	int r = n;
	while (r - l > 1)
	{
		int m = (l + r) / 2;
		if (can(m)) r = m;
		else l = m;
	}
	printf("%d\n", r);
    return 0;
}


Measured memory_bytes: 4800
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>

using ll = long long;

using namespace std;

long long x = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= x;
	if (n % 2 == 1)t *= a;
	return t % x;
}

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			if (!(a[i] % 3 == 0 || a[i] % 5 == 0)) {
				ok = false;
				break;
			}
		}
	}
		if (ok)cout << "APPROVED" << endl;
		else cout << "DENIED" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin >> n;
	cin >> s;
	int sum = 0,t,z,q;
	for(int i = 0; i <= 9; i++){
		t = 0;
		while(s[t] - '0' != i && t < s.length()){
			t++;
		}
		for(int j = 0; j <= 9; j++){
			if(t == s.length())	break;
			z = t + 1;
			while(s[z] - '0' != j && z < s.length()){
				z++;
			}
			for(int k = 0; k <= 9; k++){
				if(t == s.length())	break;
				q = z + 1;
				while(s[q] - '0' != k && q < s.length()){
					q++;
				}
				if(q < s.length()){
					sum++;
				}
			}
		}
	}
	cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
    int n,k=0,d[100];
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
        scanf("%d",&d[i]);
    
    for(int i=0;i<n;i++)
        for(int j=n-1;j>i;j--)
            if(d[j]<d[j-1]){
                swap(d[j],d[j-1]);
                k++;
            }
    
    for(int i=0;i<n;i++)
        printf(i<n-1 ? "%d " : "%d\n",d[i]);
    
    printf("%d\n",k);
    
    return 0;
}

Measured memory_bytes: 1028