akhauriyash/Code-Regression huggingface dataset:
from copy import copy
s = input()
n=len(s)
x, y = map(int, input().split())

d = [len(v) for v in s.split("T")]
x -= d[0]
a = d[2::2]
b = d[1::2]


def c(d, x):
    cur = {0}
    for i in d:
        nxt = set()
        for j in cur:
            nxt.add(j + i)
            nxt.add(j - i)
        cur = copy(nxt)
    return x in cur

print("Yes" if c(a, x) and c(b, y) else "No")

Measured memory_bytes: 83512
from collections import deque

INF=10**20

N,M=map(int,input().split())
G=[[] for _ in range(N+1)]
for i in range(M):
  a,b=map(int,input().split())
  G[a].append(b)
  G[b].append(a)

def bfs(s):
    seen = [0 for i in range(N+1)]
    d = [0 for i in range(N+1)]
    todo = deque()
    seen[s]=1
    todo.append(s)
    while 1:
      if len(todo)==0:break
      a = todo.popleft()
      if d[a] >= 2:continue
      for b in G[a]:
        if seen[b] == 0:
          seen[b] = 1
          todo.append(b)
          d[b] += d[a] + 1
    return d

d = bfs(1)
if d[N] != 0 and d[N] <= 2:print('POSSIBLE')
else:print('IMPOSSIBLE')

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

const int Maxn = 120;
int a[Maxn];
long long res = 0;
int N;

int main() {
	cin >> N;
	for (int i = 1; i <= N; ++i)
		cin >> a[i];
	for (int i = 1; i <= N; ++i) {
		int cnt = 1;
		for (int j = i + 1; j <= N; ++j)
			if (a[i] != a[j]) break;
			else cnt++;
		res += cnt/2;
		i = cnt + i - 1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    x, a = get_li()
    if x < a:
        print(0)
    else:
        print(10)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


Measured memory_bytes: 65516
#include <cmath>
#include <cstdio>
#include <vector>
#include <iterator>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <stdio.h>
#include <functional>
#include <chrono>
#include <random>
#include <time.h>
using namespace std;

#define rep(i,s,n) for(ll i=s;i<(n);++i)
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = (1LL << 60);
constexpr ll MAX_INF = 9223372036854775807;
//constexpr ll MOD = (1e9 + 7);
constexpr ll MOD = (998244353);

using vl = vector<ll>;
using vvl = vector<vector<ll>>;

template<class T>
vector<vector<T>> vvt(T init, ll m, ll n) {
	vector<vector<T>> ans = vector<vector<T>>(m, vector<T>(n, init));
	return move(ans);
}

template<class T>
vector<T> vt(T init, ll n) {
	vector<T> ans = vector<T>(n, init);
	return move(ans);
}

template<class T>
T maxVec(vector<T>& v) {
	T ans = -INF;
	rep(i, 0, v.size()) {
		ans = max(ans, v[i]);
	}
	return ans;
}

// 素数判定
bool judge(ll n) {
	for (ll i = 2; i * i <= n; i++) if (n %= i)return false;
	return true;
}


template <class C>
void print(const C & c, std::ostream & os = std::cout)
{
	std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, ", "));
	os << std::endl;
}
/*
ll count(ll n,ll r) {
	ll ans = 0,check = 1;
	rep(i,0, r) {
		if ((n & check) > 0) {
			ans++;
		}
		check = check << 1;
	}
	return ans;
}
*/
bool sortreverse(ll a, ll b) {
	return a > b;
}


ll kiriage(ll a, ll b) {
	if (a % b == 0)return a / b;
	return a / b + 1;
}

void warshall_floyd(ll v_num,vector<vector<long long>> &d) {
	for (long long k = 0; k < v_num; k++) {       // 経由する頂点
		for (long long i = 0; i < v_num; i++) {    // 始点
			for (long long j = 0; j < v_num; j++) {  // 終点
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

uniform_real_distribution<> dist(0.0, 1.0);

float judge(float p, mt19937& engine) {
	float f = dist(engine);
	return p >= f;
}

float prob(float delta, float tmp) {
	return exp(delta / tmp);
}


int cost(vector<vector<int>>& s, vector<int>& c, vector<int>& ls) {
	int result = 0;
	vector<int> prev(26,-1);
	rep(i, 0, ls.size()) {
		prev[ls[i]] = i;
		result += s[i][ls[i]];
		rep(j, 0, 26) {
			result -= c[j] * (i - prev[j]);
		}
	}
	return result;
}


int main() {
	// ↓この２行が追加部分
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	random_device seed_gen;
	mt19937 engine(seed_gen());

	int d;
	cin >> d;
	int con = 0;
	vector<int> c(26);
	vector<vector<int>> s(d, vector<int>(26));
	rep(i, 0, 26) {
		cin >> c[i];
	}
	rep(i, 0, d) {
		rep(j, 0, 26) {
			cin >> s[i][j];
		}
	}

	// 初期化
	vector<int> ls(d);
	rep(i, 0, d) {
		ls[i] = con;
		++con;
		con %= 26;
	}
	
	
	int now_cost = cost(s,c,ls);

	for (int tmp = 20000; tmp > 10; tmp -= 100) {
		rep(j, 0, d) {
			int ra = rand() % 24 + 1,val = ls[j];
			ls[j] = (ls[j] + ra) % 26;
			int cos = cost(s, c, ls);
			float p = prob(cos - now_cost, tmp);
			if (judge(p,engine)) {
				now_cost = cos;
			}
			else {
				ls[j] = val;
			}
		}
	}

	rep(i, 0, d) {
		printf("%d\n", ls[i] + 1);
	}
}

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


//It’s just pathetic to give up on something before you even give it a shot.
//Knowing you’re different is only the beginning. If you accept these differences you’ll be able to get past them and grow even closer.
//You can die anytime, but living takes true courage.
//Every journey begins with a single step. We just have to have patience.
//Life is not a game of luck. If you wanna win, work hard.
//It’s more important to master the cards you’re holding 
//than to complain about the ones your opponent was dealt.
//If you just submit yourself to fate, then that’s the end of it.
//Whatever you do, enjoy it to the fullest. That is the secret of life.
//I too will obtain everything that I desire. Not because someone asked me to do it, 
//but because I know in my heart that I have something worth fighting for.


#define ps push_back
#define le length
#define in insert
#define vint vector<int>
#define vlld vector<long long int>
#define pii pair<int,int>
#define mk make_pair
#define vst vector<string>
#define lld long long int 
#define FAST ios_base::sync_with_stdio(false),cin.tie(NULL)

int main()
{
	// unordered_map<lld,lld>mp,mp2;
	long long int t,tmp,n,res,l,tmp2;
	cin>>n;
	vlld v,v1(n),v2(n);
	set<lld>st;
	for(int i = 0 ; i<n ; i++){
		cin>>tmp;
		v.ps(tmp);
		st.insert(tmp-1);
		v1[tmp-1]++;
	}
	res = 0ll;
	for(auto it = st.begin() ; it != st.end() ; it++){
		res += max(0ll , ( v1[*it] * (v1[*it] - 1 ) )/2);
	}
	for(int i = 0 ; i<n ; i++){
		tmp = max(0ll ,((v1[v[i]-1])*(v1[v[i] - 1] - 1))/2);
		tmp2 = max(0ll ,((v1[v[i]-1] - 1)*(v1[v[i] - 1] - 2))/2); 
		cout<<(res + tmp2) - tmp<<endl;
	}
	return 0;
}

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

int main()
{
    ll h;
    cin >> h;
    if (h == 1)
        cout << 1 << endl;
    else
    {
        ll ans = 0;
        ll t = 1;
        while (h > 1)
        {
            h /= 2;
            t *= 2;
            ans += t;
        }
        cout << ans + 1 << endl;
    }
    return 0;
}

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

const int N = 10004;
int n, fp[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	for(int x = 1; x <= 100; ++x) {
		for(int y = 1; y <= 100; ++y) {
			for(int z = 1; z <= 100; ++z) {
				int a = x * x + y * y + z * z + x * y + x * z + y * z;
				if(a < N) ++fp[a];
			}
		}
	}
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cout << fp[i] << "\n";
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 3616
var fs = require('fs')
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');

function main(){
    i=input[0]>>0;
    h=i/3600|0;
    m=i%3600/60|0;
    s=i%60;
    console.log(`${h}:${m}:${s}`);
}

main();


Measured memory_bytes: 15124
//https://atcoder.jp/contests/abc125/tasks/abc125_a

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>


using namespace std;
int main(){
	int a,b,t,ans;
	cin>>a>>b>>t;
	ans=(t/a)*b;
	cout<<ans<<endl;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200100


int main() {
	char a[N + 1];
	f(i, N + 1)a[i] = 0;
	int n, b, c, d, e;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d %d %d %d", &n, &b, &c, &d, &e);
	b--;
	c--;
	d--;
	e--;
	scanf("%s", a);
	if (d < e) {
		for (int i = c; i < e; i++) {
			if (a[i] == '#'&&a[i + 1] == '#')v = false;
		}
		for (int i = b; i < d; i++) {
			if (a[i] == '#'&&a[i + 1] == '#')v = false;
		}
	}
	else if (d > e) {
		v = false;
		for (int i = c; i <= e; i++) {
			if (a[i - 1] == '.'&&a[i] == '.'&&a[i + 1] == '.')v = true;
		}
		for (int i = c; i < e; i++) {
			if (a[i] == '#'&&a[i + 1] == '#')v = false;
		}
		for (int i = b; i < d; i++) {
			if (a[i] == '#'&&a[i + 1] == '#')v = false;
		}
	}
	else {
		printf("No\n");
		return 0;
	}

	if(v)printf("Yes\n");
	else printf("No\n");


	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
bool isPrime(ll n) {
    for(ll i = 2; i * i <= n; ++i)
        if(n % i == 0)
            return 0;
    return 1;
}
void solve(){
    vector <int> pr;
    int n;
    cin >> n;
    ll ans = 1;;
    for(int i = 2; i <= n; ++i)
        if(isPrime(i))
            pr.pb(i);
    
    for(int g : pr) {
        ll cnt = 0;
        int x = n;
        while(x) {
            cnt += x / g;
            x /= g;
        }
        ans = (ans * (cnt + 1)) % MOD;
    }
    cout << ans;

}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define printarray(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl;
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b)/gcd(a, b)
#define int long long int
#define ull unsigned long long

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;

int fastexpo(int b, int exp){
    if(exp == 0) return 1;
    if(exp == 1) return b;
    int ans = (fastexpo(b,exp/2) % MOD);
    ans *= ans;
    ans %= MOD;
    if(exp % 2 == 1){
        ans *= b;
    }
    ans %= MOD;
    return ans;
}

int dp[105][MAXN];



signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int n, m;
	cin>>n>>m;
	pair<int, int> a[n+2];
	for(int i= 0;i<n;i++){
		cin>>a[i+1].fr>>a[i+1].sc;
	}
	for(int i =0;i<=n;i++){
		for(int j = 0;j<MAXN;j++){
			dp[i][j]= MOD;
		}
	}
	dp[0][0] = 0;

	for(int i =1;i<=n;i++){
		for(int j = 0;j<MAXN;j++){
			if(a[i].sc <= j){
				dp[i][j] = min(dp[i][j], a[i].fr + dp[i-1][j-a[i].sc]);
			}
			dp[i][j] = min(dp[i][j], dp[i-1][j]);
		}
	}
	int ans = 0;
	for(int i= 0;i<MAXN;i++){
		if(dp[n][i] <= m){
			ans = max(ans, i);
		}
	}
	cout<<ans<<endl;
    return 0;
}





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


int main(){
    string s;
    cin >> s;
    if(s=="AAA"||s=="BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> lP;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int n; cin>>n;
    vector<int> a;
    rep(i,n){
        int v;
        cin>>v;
        a.push_back(v);
    }

    vector<ll> prime(1000010,0);
    rep(i,n){
        for(int j=2; j*j<=a[i]; j++){
            if(a[i]%j!=0) continue;
            while(a[i]%j==0){
                a[i]/=j;
            }
            prime[j]++;
        }
        if(a[i]!=1) prime[a[i]]++;
    }

    bool judge1=true;
    bool judge2=true;
    rep(i,1000010){
        if(prime[i]>1) judge1=false;
        if(prime[i]>=n) judge2=false;
    }
    if(judge1&&judge2) cout<<"pairwise coprime"<<endl;
    else if(judge2) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;


}

Measured memory_bytes: 15060
package main

import (
    "fmt"
    "os"
    "bufio"
    "strings"
    "strconv"
  	"sort"
)

var sc = bufio.NewScanner(os.Stdin)

func StrStdin() (stringInput string){
  sc.Scan()
  OneLineString := sc.Text()
  stringInput = strings.TrimSpace(OneLineString)
  return 
}

func IntStdin() (int, error){
  stringInput := StrStdin()
  return strconv.Atoi(stringInput)
}

// ?????????????l??????????Split()
func SplitWithoutEmpty(stringTargeted string, delim string) (stringReturned []string) {
    stringSplited := strings.Split(stringTargeted, delim)

    for _, str := range stringSplited {
        if str != "" {
            stringReturned = append(stringReturned, str)
        }
    }

    return
}

// ?f???~?^??????????????X???C?X???��
func SplitStrStdin(delim string) (stringReturned []string) {
    // ???????1?s?��
    stringInput := StrStdin()
  
    // ???????
    // stringSplited := strings.Split(stringInput, delim)
    stringReturned = SplitWithoutEmpty(stringInput, delim)

    return
}

// ?f???~?^?????????????l?X???C?X???��
func SplitIntStdin(delim string) (intSlices []int, err error) {
    // ??????X???C?X???��
    stringSplited := SplitStrStdin(delim)
	
    // ?????X???C?X????
    for i := range stringSplited {
        var iparam int
        iparam, err = strconv.Atoi(stringSplited[i])
        if err != nil {
            return
        }
        intSlices = append(intSlices, iparam)
    }
    return
}

func main(){
  num, _ := IntStdin()
  values, _ := SplitIntStdin(" ")
  
  sort.Sort(sort.Reverse(sort.IntSlice(values)))
  
  result1, result2 := 0, 0
  
  for i:=0; i<num; i++{
    if i%2 == 0 {
    	result1 += values[i]
    }else{
    	result2 += values[i]
    }
  }
  
  fmt.Println(result1 - result2)
}

Measured memory_bytes: 640
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const double PI = acos(-1);
typedef long long ll;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }


typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

void solve() {
    cini(a);    
    cini(b);
    cini(c);

    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    
}

signed main() {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
        solve();
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;


int main()
{
    int n,k;
    cin >> n >> k;
    
    int bin[22];
    bin[0] = 1;
    for (int i = 1;i <= 21;i++){
        bin[i] = bin[i-1]*2;
    }
    
    long double pre = 0.0;
    if (n < k){
        for (int i = 1;i <= n;i++){
            int left = 0;
            int right = 20;
            int mid = 0;
            while (left < right){
                mid = (left+right)/2;
                if (i*bin[mid] < k && i*bin[mid+1] >= k){
                    mid = mid+1;
                    break;
                }
                else if (i*bin[mid] < k){
                    left = mid+1;
                }
                else {
                    right = mid;
                }
            }
            pre += (long double) 1/bin[mid];
        }
        double ans = (double) pre/n;
        printf("%.12lf\n",ans);
    }
    
    else {
        for (int i = 1;i < k;i++){
            int left = 0;
            int right = 20;
            int mid = 0;
            while (left < right){
                mid = (left+right)/2;
                if (i*bin[mid] < k && i*bin[mid+1] >= k){
                    mid = mid+1;
                    break;
                }
                else if (i*bin[mid] < k){
                    left = mid+1;
                }
                else {
                    right = mid;
                }
            }
            pre += (long double) 1/bin[mid];
        }
        pre += (long double) (n-k+1);
        double ans = pre/n;
        printf("%.12lf\n",ans);
    }
}


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

int main() {
  int N,K;
  int64_t ans=0;
  cin >> N >> K;
  vector<int>H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  sort(H.begin(),H.end());
  for(int i=0;i<N-K;i++){
    ans+=H.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n;

int main() {
	fastio; cin >> n;
  int x = n % 10;
  if (x == 2 or x == 4 or x == 5 or x == 7 or x == 9) cout << "hon";
  else if (x == 0 or x == 1 or x == 6 or x == 8) cout << "pon";
  else cout << "bon";
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
 
int main(){
  long long N,M;
  cin >> N >> M;
  if(N == 1 && M == 1){
    cout << 1 << endl;
  }else if(N == 2 && M == 2){
      cout << 0 << endl;
    }else if(N == 1 && M != 1){
      cout << M - 2 << endl;  
    }else if(M == 1 && N > 1){
    	cout << N - 2 << endl;
	}else if(N > 1)
      cout << (N - 2) * (M - 2) << endl;
 
  return 0;
 
}

Measured memory_bytes: 256
N, M = input().split()
A = list(map(int, input().split()))
A.sort(reverse = True)

# 得票総数
Sum = sum(A)

# M位の商品の得票数
if A[int(M)-1] < Sum / (4 * int(M)):
  print('No')
else:
  print('Yes')

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    int n2 = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ++n2;
        }
    }
    cout << n2 << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3620
using System;
using System.Linq;
using System.Collections.Generic;

namespace abc088b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().ToArray();
            var a = Console.ReadLine().Split().Select(b => int.Parse(b)).ToArray();
            var u = Console.ReadLine();
            if(s.All(name => name == u))
            {
                Console.WriteLine(a[0]);
                Console.WriteLine(a[1]);
            }
            else
            {
                if (u == s[0])
                {
                    a[0] = a[0] - 1;
                    Console.Write($"{a[0]} {a[1]}");
                }
                else
                {
                    a[1] = a[1] - 1;
                    Console.Write($"{a[0]} {a[1]}");

                }

            }
        }
    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,t;
	cin>>a>>b>>c;
	t=a;
	a=b;
	b=t;
	t=a;
	a=c;
	c=t;
	cout<<a<<" "<<b<<" "<<c;
}

Measured memory_bytes: 3588
#include <cstdio>

typedef long long LL;
const int Mod = 1000000007, Inv2 = (Mod + 1) / 2;
const int MN = 200005, C = 2000, O = C + 1, MS = O + C + 1;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int N, A[MN], B[MN];
int Fac[MS * 2], iFac[MS * 2];
int S[MS][MS];
int Ans;

int main() {
	scanf("%d", &N);
	Fac[0] = 1;
	for (int i = 1; i <= 4 * C; ++i) Fac[i] = (LL)Fac[i - 1] * i % Mod;
	iFac[4 * C] = qPow(Fac[4 * C], Mod - 2);
	for (int i = 4 * C; i >= 1; --i) iFac[i - 1] = (LL)iFac[i] * i % Mod;
	for (int i = 1; i <= N; ++i) {
		scanf("%d%d", &A[i], &B[i]);
		++S[O - A[i]][O - B[i]];
		Ans = (Ans - (LL)Fac[2 * (A[i] + B[i])] * iFac[2 * A[i]] % Mod * iFac[2 * B[i]]) % Mod;
	}
	for (int i = O - C; i <= O + C; ++i)
		for (int j = O - C; j <= O + C; ++j)
			S[i][j] = (S[i][j] + S[i - 1][j] + S[i][j - 1]) % Mod;
	for (int i = 1; i <= N; ++i)
		Ans = (Ans + S[O + A[i]][O + B[i]]) % Mod;
	Ans = (LL)Ans * Inv2 % Mod;
	printf("%d\n", (Ans + Mod) % Mod);
	return 0;
}

Measured memory_bytes: 64384
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = []
    l = [0]*(n + 1)
    cnt = 0
    now = 1

    for i in range(n):
        a.append(int(input()))

    for i in range(n):
        cnt += 1
        now = a[now - 1]
        if now == 2:
            print(cnt)
            exit()
    print(-1)

main()

Measured memory_bytes: 7852
#include <iostream>

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;
	while (x>0 & y>0) {
		if (x >= y) x %= y;
		else if (x < y) y %= x;
	}
	if (x == 0) cout << y << endl;
	else if (y == 0) cout << x << endl;
}

Measured memory_bytes: 1160
s = input()
n = len(s)
f = True
if s != s[::-1]:
    f = False

s1 = s[:(n-1)//2]
if s1 != s1[::-1]:
    f = False


s2 = s[(n+3)//2 -1:]
if s2 != s2[::-1]:
    f = False

print("Yes" if f else "No")

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

int main(void){
  long N,M,ans;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atol(p);
  p=strtok(NULL," \n");
  M=atol(p);
  
  if(N==1 && M==1){
    printf("1");
    return 0;
  }else if(N==1 || M==1){
    ans=N*M-2;
    printf("%ld\n",ans);
    return 0;
  }
  
  
  ans=N*M-2*N-2*M+4;
  
  printf("%ld\n",ans);
  
  return 0;
}

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

int main()
{
    ll n,a,i,j,k;
    cin>>n>>a;
    ll x[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>x[i];
    }
    ll dp[51][51][2501];
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=n;j++)
        {
            for(k=0;k<=2500;k++)
            {
                dp[i][j][k] = 0;
            }
        }
    }
    for(i=1;i<=n;i++)
    {
        for(k=0;k<=2500;k++)
        {
            ll count = 0;
            for(j=1;j<=i;j++)
            {
                if(x[j]==k)
                    count++;
            }
            dp[i][1][k] = count;
        }
    }
    for(i=2;i<=n;i++)
    {
        for(j=2;j<=i;j++)
        {
            for(k=0;k<=2500;k++)
            {
                dp[i][j][k] = max(dp[i][j][k],dp[i-1][j][k]+dp[i-1][j-1][max(0ULL,k-x[i])]);
                /*if(dp[i][j][k]>0 && i==j)
                {
                    cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
                }*/
            }
        }
    }
    ll ans = 0;
    for(i=1;i<=n;i++)
    {
        ans += dp[n][i][a*i];
        // cout<<dp[n][i][a*i]<<" ";
    }
    // cout<<setprecision(0)<<fixed<<pow(2,50)<<" ";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 51072
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n, m, x, a,l=0,r=0;
    cin >> n >> m >> x;
    for (int i = 0; i < m;i++) {
        cin >> a;
        if (a <= x) l++;
        else r++;
    }
    cout << min(l, r) << endl;
}


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

public class Main{
  public static void main(String[] args)throws IOException{
    //BufferedReader br = new BufferedReader(System.in);
    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    
    int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		int b=0, w=0;
		for(int i=0;i<n;i++)
			if(s[i]=='.')
				w++;
		
		int min = w;
		for(int i=0;i<n;i++){
			if(s[i]=='#')
				b++;
			else
				w--;
 
			min = Math.min(min, w + b);
		}
		out.println(min);
    
    out.flush();
  }
}

Measured memory_bytes: 26580
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using Pl = pair<ll, int>;

void Main() {
    string s;
	cin >> s;
    int n = s.size();
    bool allnine = true;
    
    rep(i, n){
        if(i == 0) continue;
        if(s[i] - '0' != 9) {
            allnine = false;
            break;
        }
    }
    
    int ans;
    if(allnine){
        ans = s[0] - '0';
        ans += 9*(n-1);
    }else{
        ans = s[0] - '0' - 1;
        ans += 9*(n-1);
    }
    
    cout << ans << endl;
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
using System;

namespace abc124_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] AB = Console.ReadLine().Split(' ');
            int A = Convert.ToInt32(AB[0]);
            int B = Convert.ToInt32(AB[1]);
            int sum = 0;
            for (int i = 0; i < 2; i++)
            {
                if (A > B)
                {
                    sum = sum + A;
                    A--;
                }
                else
                {
                    sum = sum + B;
                    B--;
                }
            }
            Console.WriteLine(sum);
            Console.ReadLine();
        }
    }
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

double N, a[105];

int main(){
    cin >> N;
    double t=0;
    REP(i,N){cin >> a[i];t+=a[i];}
    t/=N;
    double min=INF;
    int ans=-1;
    REP(i,N)
    {
        if(abs(a[i]-t) < min)
        {
            min = abs(a[i]-t);
            ans=i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	
	int N,K;
	char tmp;
	vector<char> D;

	string s;
	bool flg=true;
	cin>>N>>K;

	for(int i=0;i<K;i++){
		cin>>tmp;
		D.push_back(tmp);
	}

	for(int i=N;i<N*10;i++){
		stringstream ss;
		ss<<i;
		s=ss.str();
		flg=true;
		for(int j=0;j<s.size();j++){
			for(int k=0;k<K;k++){
				if(s[j]==D[k]){
					flg=false;
					break;
				}
			}
			if(!flg) break;
		}
		if(flg){
			cout<<i<<endl;
			return 0;
		}
	}
		
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] d = new int[n];
		
		List<Integer> list = new ArrayList<>();
		int cnt = 0;
		
		for(int i = 0; i < n; i++) {
			int a = stdIn.nextInt();
			if(!list.contains(a)){
				list.add(a);
				cnt++;
			}
		}
		
		System.out.println(cnt);
	}

}


Measured memory_bytes: 21844
//   PIGMEISTER™   //

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

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    string s;
    cin >> s;
    if (s == "RRS" or s == "SRR") cout << 2;
    else if (s == "RRR") cout << 3;
    else if (s == "SSS") cout << 0;
    else cout << 1;
    
    return 0;
}


Measured memory_bytes: 3668
//https://atcoder.jp/contests/abc124/tasks/abc124_b
#include <iostream>
using namespace std;

int main(){
    int N;

    cin >> N;

    int *H = new int[N];
    for(int i=0;i<N;i++){
        cin>>H[i];
    }

    int count=1;
    int Hill=H[0];
    for(int i=1;i<N;i++){
        if(Hill<=H[i]){
            count++;
            Hill=H[i];
        }
    }
    cout << count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1023456789
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long long ll;

vi adj[100000+5];
int n,m;
int vis[100000+5];
int cc = 1;
void bfs(int i){
    queue<int> q;
    q.push(i);
    vis[i] = -1;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for (auto v: adj[u]){
            if (!vis[v]){
                cc++;
                vis[v] = u;
                q.push(v);
            }
        }
    }
}
int main(){
    scanf("%d %d",&n,&m);
    int a,b;
    rep(i,0,m){
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    memset(vis,0,sizeof vis);
    bfs(1);
    if (cc < n){
        printf("No");
    } else{
        printf("Yes\n");
        rep(i,2,n+1){
            printf("%d\n",vis[i]);
        }
    }



}


Measured memory_bytes: 10552
#include <bits/stdc++.h>
using namespace std;
#define MAX_P 10005
#define MAX_T 1000005

char T[MAX_T], P[MAX_P];
int nx[MAX_P];

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int i, j;

	cin.getline(T, MAX_T);
	int T_len = cin.gcount() - 1;
	cin.getline(P, MAX_P);
	int P_len = cin.gcount() - 1;

	nx[0] = -1;
	nx[1] = 0;
	for (i = 1; i < P_len; i++) {
		int k = i;
		while (nx[k] != -1) {
			if (P[nx[k]] == P[i]) {
				break;
			}
			k = nx[k];
		}
		nx[i + 1] = nx[k] + 1;
	}
	i = 0;
	j = 0;
	while (i < T_len) {
		if (T[i] == P[j]) {
			i++;
			j++;
			if (j == P_len) {
				cout << i - j << endl;
				j = nx[j]; // j在++之后不会为0
			}
		} else {
			j = nx[j];
			if (j == -1) {
				i++;
				j++;
			}
		}
	}
}


Measured memory_bytes: 4188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ldb;
typedef pair<ll,ll> pll;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define V vector
#define endl "\n"
#define CLEAR(a) memset(a,0,sizeof(a))
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ios_tie() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(nullptr)
#define trace1(a)             cout <<#a<<":"<<a<< endl;
#define trace2(a,b)           cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<< endl;
#define trace3(a,b,c)         cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<endl;
#define trace4(a,b,c,d)       cout <<#a<<":"<<a<<" | "<<#b<<":"<<b<<" | "<<#c<<":"<<c<<" | "<<#d<<":"<<d<<endl;

const ll inf = 1e18;
const ll mod = 1e9+7;
const ll maxn = 1e5+10;
const ldb PI = acos(-1);

void lol(ll s) {cerr<<"check........................................... "<<s<<endl;}
ll power(ll x,ll y) {ll res=1; x%=mod; while(y) {if(y&1) res=(res*x)%mod; y>>=1LL; x=(x*x)%mod; }return res;}
ll inv(ll x) {return power(x,mod-2);}//(1/x)%y = x^(y-2) % y;   // pow(x,y)%m = pow(x,y%(m-1))%m
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// I can solve mirror cube in 2 mins but can't solve div2 C in 1hr.
void solve()
{
    ll x, y;
    cin>>x>>y;
    if(y&1) {
        cout<<"No\n";
        return;
    }
    ll res = 2*x-y/2;
    if(res<0 or x-res<0) {
        cout<<"No\n";
    }
    else {
        cout<<"Yes\n";
    }
}
int main()
{
    ios_tie();
    // freopen("input.txt", "r", stdin);
    // freopen("myOut.txt", "w", stdout);
    ll _ = 1;
    // cin>>_;
    rep1(i,_)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

ll gcd(int x, int y) {

	if (y>x) {
		int k = y;
		y = x;
		x = k;
	}

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

}

int main()
{
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	ll E = gcd(C, D);
	ll F = C*D / E;

	ll ans1 = B / C;
	ll ans2 = B / D;
	ll ans3 = B / F;
	ll ans4 = (A -1 ) / C;
	ll ans5 = (A -1 ) / D;
	ll ans6 = (A -1 ) / F;

	ll ans7 = B - ans1 - ans2 + ans3;
	ll ans8 = A - 1 - ans4 - ans5 + ans6;
	ce( ans7-ans8)

    return 0;
}



Measured memory_bytes: 384
def euclid(a,b):
    max_v=max(a,b)
    min_v=min(a,b)
    while 1:
        if max_v%min_v==0:
            return min_v
        tmp=max_v%min_v
        max_v=min_v
        min_v=tmp

        
    
if __name__=='__main__':
    n=int(input())
    hp=[int(i) for i in input().split()]
    cd=hp[0]
    for i in range(1,n):
        cd=euclid(cd,hp[i])
    print(cd)


Measured memory_bytes: 14252
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
string a1,b1;
char a[2000005];
char b[2000005];
int main()
{
	getline(cin,a1);
	getline(cin,b1);
	int len1=a1.length();
	int len2=b1.length();
	int flag=0;
	for(int i=0;i<len1;i++)
	a[i]=a1[i];
	for(int i=0;i<len2;i++)
	b[i]=b1[i];
	sort(a,a+len1);
	sort(b,b+len2);
	reverse(b,b+len2);
	for(int i=0;i<=min(len1,len2)-1;i++)
	{
		if(a[i]<b[i])
		{
			flag=1;
			break;
		}
		else
		if(a[i]>b[i])
		{
			flag=2;
			break;
		}
	}
	if(flag==0 && len1<len2)
	flag=1;
	if(flag==1)
	{
		printf("Yes\n");
		return 0;
	}
	else
	printf("No\n");
	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;



string s, t;
int n, a[26], b[26];

signed main() {
	cin >> s >> t;
	memset(a,-1,sizeof(a)), memset(b,-1,sizeof(b));
	n = s.size();
	rep(i,n) {
		if (a[s[i]-'a']==-1) a[s[i]-'a'] = t[i]-'a';
		else if (a[s[i]-'a']!=t[i]-'a') return cout << "No" << endl, 0;
		if (b[t[i]-'a']==-1) b[t[i]-'a'] = s[i]-'a';
		else if (b[t[i]-'a']!=s[i]-'a') return cout << "No" << endl, 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;


int32_t main(){
    vaibhavv06;
	int n,k; cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int dp[k+1]={0};
    for(int i=0;i<=k;i++){
        for(int x:arr){
            if(i>=x && dp[i-x]==0){
                dp[i]=1;
            }
        }
    }
    if(dp[k]==1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader(); 
        int N = r.i();
        int[] a = r.ii();
        int odd = 0;
        int four = 0;
        for(int b : a)
            if(b%2 == 1)
                odd++;
            else if(b%4 == 0)
                four++;
        int two = N-four-odd;
        boolean flag;
        if(two == 0)
            flag = odd-1 <= four;
        else 
            flag = odd <= four;
        println(flag ? "Yes" : "No");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 37900
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

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

    ll a;
    ll ans = 1;
    ll MAX = 1e18;
    bool flag = 0;
    bool zero = 0;

    rep(i, n) {
        cin >> a;
        if (a==0) zero = 1;
        else if (ans > MAX/a) flag = 1;
        // if (ans!=0 && a > MAX/ans) flag = 1;
        // if (ans != 0) if (a > MAX/ans) flag = 1;
        ans *= a;
        // cout << ans << endl;
    }

    if (zero) cout << 0 << endl;
    else if (flag) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
//#include"atcoder/all"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
//using namespace atcoder;
typedef long long ll;
int main(){
  int N,i;scanf("%d",&N);
  int now = 0,upper = 0;
  while(now < N){
    upper++;now += upper;
  }
  for(i=upper;i>=1;i--){
    if(i <= N){
      printf("%d\n",i);
      N -= i;
    }
  }
}

Measured memory_bytes: 3780
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int h=a-b;
    if(h<=0)
        printf("0\n");
    else
        printf("%d\n",h);

}

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

int main(void){
    
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i]=='1')ans++;

    }
    cout << ans <<endl;
}

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

namespace ITP1_5_D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            List<int> rlt = new List<int>();

            for(int i = 1; i <= n; i++)
            {
                if (i % 3 == 0 || i.ToString().IndexOf('3') >= 0) rlt.Add(i);
            }

            Console.WriteLine(" " + string.Join(" ",rlt.Select(x => x.ToString()).ToArray()));
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 18192
N = int(input())
T,A = map(int,input().split(" "))
h = input().split(" ")
H_ = [abs(T-0.006*int(k)-A) for k in h]
     
m = float("inf")
arg = 0
for i in range(N):
  if H_[i] < m:
    arg = i+1
    m = H_[i]
     
print(arg)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw"<<endl;
    }
    else{
        if(a==1 && b>a){
            cout<<"Alice"<<endl;
        }
        else if(b==1 && a>b){
            cout<<"Bob"<<endl;
        }
        else{
            if(a>b){
                cout<<"Alice"<<endl;
            }
            else if(b>a){
                cout<<"Bob"<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3592