akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

struct edge{int to,cost;};
struct State
{
    int pos,rem,temp;
    bool operator<(const State &r) const {
        if(pos == r.pos)
        {
            if(rem == r.rem) return temp<r.temp;
            else return rem<r.rem;
        }
        else return pos<r.pos;
    }
};

using P = pair<int,State>;

const int V=10000;
const int INF=123456789;

vector<edge> G[V];
int d[V][201][3];

int main()
{
    int N,M,X;
    scanf(" %d %d %d", &N, &M, &X);
    vector<int> T(N);
    rep(i,N) scanf(" %d", &T[i]);
    rep(i,M)
    {
        int a,b,c;
        scanf(" %d %d %d", &a, &b, &c);
        --a;
        --b;
        G[a].pb({b,c});
        G[b].pb({a,c});
    }

    fill_n((int*)d, V*201*3, INF);
    d[0][X][0] = 0;
    priority_queue<P,vector<P>,greater<P>> pq;
    pq.push(P(0,{0,X,0}));
    while(!pq.empty())
    {
        P p = pq.top();
        pq.pop();
        State s = p.se;
        if(p.fi>d[s.pos][s.rem][s.temp]) continue;

        for(const auto &e:G[s.pos])
        {
            int nr = max(0, s.rem-e.cost);
            int nt = s.temp;
            if(nr==0) nt=1;

            if(T[e.to]!=1)
            {
                int ban = (T[e.to]==0)?2:0;
                if(nt==ban) continue;
                nr = X;
                nt = T[e.to];
            }

            if(d[e.to][nr][nt] > d[s.pos][s.rem][s.temp]+e.cost)
            {
                d[e.to][nr][nt] = d[s.pos][s.rem][s.temp]+e.cost;
                pq.push(P(d[e.to][nr][nt],{e.to,nr,nt}));
            }
        }
    }

    int ans=INF;
    rep(i,3)rep(j,X+1) ans = min(ans,d[N-1][j][i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 27844
defmodule Main do
  def main do
    IO.stream(:stdio, :line)
    |> Enum.take(4)
    |> Enum.map(&String.trim/1)
    |> Enum.map(&String.to_integer/1)
    |> process(0)
    |> IO.inspect()
  end
  
  def process([0, _k, _x, _y], acc), do: acc
  
  def process([n, k, x, y], acc) when n > k, do: process([n-1, k, x, y], acc + y)
  def process([n, k, x, y], acc), do: process([n-1, k, x, y], acc + x)
end

Measured memory_bytes: 30932
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a=0, b=101, x=0;
  int c=0;
  cin >> a >> b;
  if(a<1||100<b) cout << "入力エラー(制約 : 1≦a, b≦100)" << endl;
  else{
    c = (a+b)%2;
    x = (a+b)/2;
    if(0<c) x = x+1;
    cout << x << endl;
  }
}


Measured memory_bytes: 3588
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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



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

	int ans = 1;
	for(int i = 2; i <= x; i++){
		int m[1005] = {};
		int t = i;
		for(int j = 2; j <= 1000; j++){
			while(t % j == 0){
				t /= j;
				m[j]++;
			}
			if(t == 1)break;
		}
		int j, k = -1;
		for(j = 2; j < 1001; j++){
			if(m[j] == 1){
				break;
			}
			if(m[j] >= 2){
				if(k == -1){
					k = m[j];
				}
				else{
					if(k != m[j]){
						break;
					}
				}
			}
		}
		if(j == 1001){
			ans = i;
		}
	}
	cout << ans << endl;
}

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

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

using namespace std;

int main(){
	int x,y; scanf("%d%d",&x,&y);
	rep(i,x+1) if(2*i+4*(x-i)==y) return puts("Yes"),0;
	puts("No");
	return 0;
}


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

int main(){
    char c[3][3];
    rep(i,3)rep(j,3) cin >> c[i][j];
    rep(i,3) cout << c[i][i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val t = sc.nextLong()
  val tlist = (1..n).map { sc.nextLong() }.toLongArray()

  var sum = 0L
  for (i in 0 until n - 1) {
    val ti0 = tlist[i]
    val ti1 = tlist[i+1]
    if (ti0 + t < ti1) {
      sum += t
    } else {
      sum += ti1 - ti0
    }
  }
  sum += t

  println(sum)

}


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

int main(){
    int n;
    cin >> n;
    const double PI=3.14159265358979323846;
    double l =  2.0 * n * PI;
    cout << std::fixed << std::setprecision(10) << l << endl;


}

Measured memory_bytes: 3748
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var s = next(1);
  var q = next();
  var rev = 0;
  var a = [];
  s = s.split("");
  for(var i = 0; i < q; i++){
    if(next() === 1)rev ^= 1;
    else{
      var f = next(), c = next(1);
      if(rev)f = 3-f;
      if(f === 1)a.push(c);
      else s.push(c);
    }
  }
  if(rev)s = s.reverse().concat(a);
  else s = a.reverse().concat(s);
  return s.join("");
}

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

int main(){
    int A, B, x[5], C, k=10000, count=0, sum=0;
    cin >> A >> B;
    
    
    for(int i=A; i<=B; i++){
        C = i;
        for(int j=0; j<5; j++){
            x[j] = C / k;
            C = C - x[j]*k;
            k /= 10;
        }
        for(int m=0; m<3; m++){
            if(x[m] == x[4-m]) count++;
        }
        if(count == 3) sum++;
        count = 0;
        k = 10000;
    }
    cout << sum << endl;
}

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

int main(void) {
    string s, t, c;
    int q, a, b;
    cin >> s >> q;
    for (int i = 0; i < q; i++) {
        cin >> c >> a >> b;
        if (c == "replace") {
            cin >> t;
            s.replace(a, b - a + 1, t);
        }
        if (c == "reverse") {
            t = s.substr(a, b - a + 1);
            reverse(t.begin(), t.end());
            s.replace(a, b - a + 1, t);
        }
        if (c == "print") {
            cout << s.substr(a, b - a + 1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
import collections

def main():
    N = int(input())
    A = list(map(int, input().split()))
    rankA = list(set(A))
    rankA.sort(reverse=True)
    Acounter = collections.Counter(A)
    res = 4
    ans = []
    for a in rankA:
        count = Acounter[a]
        if count >= 2:
            ans.append(a)
            res = res - 2
            count = count - 2
            if len(ans) == 2:
                break
            if count >= 2:
                ans.append(a)
                break

    if len(ans) < 2:
        print(0)
        return

    a1 = ans.pop()
    a2 = ans.pop()
    ans = a1*a2
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 24228
#include<stdio.h>

int main(){
	char ch,str[100];
	int i=0,j;

	while(1){
		ch=getchar();
		if(ch==EOF)break;
		str[i]=ch;
		i++;
	}
	for(j=0;j<i;j++){
		if('a'<=str[j]&&str[j]<='z')
			str[j]-='a'-'A';
		printf("%c",str[j]);
	}

	return 0;
}

Measured memory_bytes: 524
s = input()
cnt = 0
for i in range(3):
    if s[i] == "a":
        cnt += 1
    elif s[i] == "b":
        cnt += 2
    elif s[i] == "c":
        cnt += 4

if cnt == 7:
    ans = "Yes"
else:
    ans = "No"

print(ans)


Measured memory_bytes: 2940
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn main() {
    input! { m, dc: [(usize, usize); m] };
    let mut ans = 0;
    let mut x = vec![0; 10];
    for &(d, c) in &dc {
        x[d] += c;
    }
    loop {
        let mut sum = 0;
        let mut sc = 0;
        for i in 0..10 {
            sc += x[i];
            sum += i * x[i];
        }
        let st = format!("{}", sum).chars().collect::<Vec<char>>();
        ans += sc - st.len();
        while sum >= 10 {
            sum /= 10;
            ans += sum;
        }
        if st.len() <= 1 {
            break;
        }
        x = vec![0; 10];
        for s in st.into_iter() {
            let i = (s as u8 - '0' as u8) as usize;
            x[i] += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 13560
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    sc.nextLine
    val s = sc.nextLine.toCharArray

    var count = 0
    var currentChar = '@'
    for (i <- 0 until n) {
      if (s(i) != currentChar) {
        currentChar = s(i)
        count += 1
      }
    }
    println(count)
  }
}


Measured memory_bytes: 31600
#include<stdio.h>
#include<string.h>
int time[300000];
char name[300000][11];
int main(){

  int i,j,n,q,len;
  scanf("%d %d", &n, &q );

  int head,tail,cnt;
  char S[11];

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

    scanf("%s", S );

    len = strlen(S);
    
    for ( j = 0 ; j < len ; j++ ){
      name[i][j] = S[j];
    }

    scanf("%d", &time[i] );

  }

  head = 0;
  tail = n;
  cnt = 0;
  
  while( tail > head ){

    if ( time[head] > q ){

      time[tail] = time[head] - q;

      for ( i = 0 ; i < len ; i++ ){
	name[tail][i] = name[head][i];
      }

      head += 1;
      tail += 1;
      cnt += q;

    } else {

      cnt = cnt + time[head];
      
      printf("%s", name[head] );

      printf(" %d\n", cnt );

      head += 1;

    }

  }

  return 0;
  
}

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

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

    int vmin = max(-1000000, x-k+1);
    int vmax = min(1000001, x+k);

    for(int i=vmin; i<vmax; i++){
      cout << i;
      if(i != vmax-1){
        cout << " ";
      }else{
        cout << endl;;
      }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	long long A; string B; 
	cin >> A >> B; 
	long long C = 100 * (B.at(0) - '0') + 10 * (B.at(2) - '0') + (B.at(3) - '0'); 
	cout << A * C / 100 << endl; 
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const int MAX = 100001;

int N;
vector<P> G[MAX];
ll cost[MAX];
void bfs(int k);

int main() {

    cin >> N;

    ll a, b, c;
    for (int i = 0; i < N-1; i++) {
        cin >> a >> b >> c;
        G[a].push_back(make_pair(b, c));
        G[b].push_back(make_pair(a, c));
    }

    int Q, K;
    cin >> Q >> K;

    bfs(K);

    int x, y;
    for (int i = 0; i < Q; i++) {
        cin >> x >> y;
        cout << cost[x] + cost[y] << '\n';
    }
}

void bfs(int k) {

    queue<int> q;
    q.push(k);
    ll u;
    cost[k] = 0;
    while (!q.empty()) {
        u = q.front(); q.pop();
        for (int v = 0; v < G[u].size(); v++) {
            P p = G[u][v];
            int next_node = p.first, next_cost = p.second;
            if (cost[next_node] != 0) continue;
            cost[next_node] += cost[u] + next_cost;
            q.push(next_node);
        }
    }
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    vector<ll> arr(n, 0);
    ll money = 1000;
    for(auto& val: arr)
        cin >> val;
    vector<vector<ll>> trans;
    vector<ll> tmp = {arr[0]};
    for(int i = 1; i < n; i++) {
        if (arr[i] < tmp.back()) {
            trans.push_back(tmp);
            tmp = {arr[i]};
        } else {
            tmp.push_back(arr[i]);
        }
    }
    trans.push_back(tmp);
    for(int i = 0; i < trans.size(); i++) {        
        //for(auto val: trans[i])
        //    cout << val << " ";
        //cout << endl;
        ll stock = money / trans[i][0];
        // money -= stock * trans[i][0];
        for(int j = 1; j < trans[i].size(); j++) {
            money += stock * (trans[i][j]-trans[i][j-1]);
            stock = money / trans[i][j];
        }
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
    int N, A[200], i;
    int num = 1;

    scanf("%d", &N);
    for(i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
    }

    for(i = 1; i <= N; i++) {
        if (A[i] % 2) 
            ;
        else if (A[i] % 3 == 0 || A[i] % 5 == 0)
            ;
        else 
            num = 0;
    }       

    if (num)
        printf("APPROVED");
    else
        printf("DENIED");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define M 200005
#define ll long long
int read() {
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
	return s*w;
}
ll min(ll x,ll y) {return x<y?x:y;}
int n,q,p1,p2;
ll ans;
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
struct segment_tree{
	ll f[M*4],g[M*4],tag[M*4];
	void build(int p,int l,int r)
	{
		f[p]=g[p]=1e18;
		if(l==r) return ;
		int mid=(l+r)>>1;
		build(ls(p),l,mid);
		build(rs(p),mid+1,r);
	}
	void pushup(int p)
	{
		f[p]=min(f[ls(p)],f[rs(p)]);
		g[p]=min(g[ls(p)],g[rs(p)]);
	}
	void Do(int p,ll k)
	{
		f[p]+=k,g[p]+=k;
		tag[p]+=k;
	}
	void pushdown(int p)
	{
		Do(ls(p),tag[p]);
		Do(rs(p),tag[p]);
		tag[p]=0;
	}
	void change(int p,int l,int r,int x,ll k,int tp)
	{
		if(l==r)
		{
			f[p]=min(f[p],k),g[p]=min(g[p],k-tp*l);
			return ;
		}
		int mid=(l+r)>>1;
		if(tag[p]) pushdown(p);
		if(x<=mid) change(ls(p),l,mid,x,k,tp);
		else change(rs(p),mid+1,r,x,k,tp);
		pushup(p);
	}
	ll ask(int p,int l,int r,int x,int y)
	{
		if(x<=l&&r<=y) return g[p];
		int mid=(l+r)>>1;
		if(tag[p]) pushdown(p);
		ll ans=1e18;
		if(x<=mid) ans=min(ans,ask(ls(p),l,mid,x,y));
		if(y>mid) ans=min(ans,ask(rs(p),mid+1,r,x,y));
		pushup(p);
		return ans;
	}
}T1,T2;
void work() {
	int p=read(),last;
	if(q==1)
	{
		cout<<min(abs(p1-p),abs(p2-p))<<'\n';
		return ;
	}
	T1.build(1,1,n),T2.build(1,1,n);
	T1.change(1,1,n,p1,abs(p-p2),1);
	T1.change(1,1,n,p2,abs(p-p1),1);
	T2.change(1,1,n,p1,abs(p-p2),-1);
	T2.change(1,1,n,p2,abs(p-p1),-1);
	last=p;
	for(int t=1,p;t<q;t++)
	{
		p=read();
		ll res=min(T1.ask(1,1,n,1,p)+p,T2.ask(1,1,n,p,n)-p);
		T1.f[1]+=abs(last-p),T1.g[1]+=abs(last-p),T1.tag[1]+=abs(last-p);
		T2.f[1]+=abs(last-p),T2.g[1]+=abs(last-p),T2.tag[1]+=abs(last-p);
		T1.change(1,1,n,last,res,1);
		T2.change(1,1,n,last,res,-1);
		ans=T1.f[1],last=p;
	}
	cout<<ans<<'\n';
}
int main()
{
	//freopen("1.in","r",stdin);
	n=read();q=read();p1=read();p2=read();
	work();
	return 0;
}

Measured memory_bytes: 37120
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n, k, s = list(map(int, input().strip().split()))
    ans = [str(s)] * k
    for i in range(n-k):
        if s != 10**9:
            ans.append(str(10**9))
        else:
            ans.append(str(1))
    for i in range(n):
        print(ans[i])

if __name__ == '__main__':
    main()


Measured memory_bytes: 51312
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**/int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};


int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	map<int,int> ma;
	for(int i=1;i<=100;i++)for(int j=1;j<=100;j++)for(int k=1;k<=100;k++)ma[i*i+j*j+k*k+i*j+j*k+k*i]+=1;
	int n;
	in(n);
	arep(i,1,n+1)out(ma[i]);
	return 0;
}


Measured memory_bytes: 5372
#coding:utf-8

def main():
    N = int(input())
    money = []
    for i in range(N):
        x, u = input().split()

        if u == 'BTC':
            x = float(x) * 380000
        money.append(float(x))

    moneysum = float(sum(money))
    print(moneysum)


if __name__ == "__main__":
    main()

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

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int main()
{
	// freopen("input.in", "r", stdin);

	int m, d; scanf("%d %d", &m, &d);

	int res = 0;
	for(int i = 2; i <= 9; i++)
	{
		for(int j = 2; j <= 9; j++)
		{
			if(i*10+j <= d && i*j <= m)
				res++;
		}
	}
	printf("%d\n", res);
}

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

using namespace std;

int main() {
  int N, M;
  int *T, *P, *X;
  int i, sum=0; 
  //  std::string s;
  
  cin >> N;
  T = new int[N];
  for(i=0;i<N;i++)
    cin >> T[i];

  cin >> M;
  P = new int[M];
  X = new int[M];
  
  for(i=0;i<M;i++){
    cin >> P[i] >> X[i];
  }  

  for(i=0;i<N;i++)
    sum += T[i];

  //  cout <<"SUM = "<<sum<<endl; 
  
  for(i=0;i<M;i++)
    cout << sum-T[P[i]-1]+X[i] << endl;
  
  return 0;
}


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

int main(void) {
  string s; int n;
  cin >> n >> s;
  int cnt = 0;
  int max = 0;
  rep(i,n) {
    if(s[i] == 'I') cnt++;
    else cnt--;
    if(max < cnt) max = cnt;
  }
  cout << max << endl;
}

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

int main()
{
  int X,Y;
  cin >> X >> Y ;
  
  if( 2*X <= Y  && Y <= 4*X)
  {
   if(Y%2==0) 
   {
     cout << "Yes" << endl;
     return 0;
   }
  }

  cout << "No" << endl;
   
  return 0;

  return 0; 
}

Measured memory_bytes: 3628
n = int(input()) 
b = list(map(int, input().split()))
s  = b[0]
if n == 2:
    s = 2 * b[0]
else:
    for i in range(1, n - 1):
        s += min(b[i - 1], b[i])
    s += b[-1]
print(s)

Measured memory_bytes: 3064
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;
ll po(ll a, ll b){
    ll res = 1;
    while(b){
        if(b & 1) res = res * a;
        a = a * a;
        b >>= 1LL;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n, k;
    cin >> n >> k;
    ll ans = k * po(k - 1, n - 1);
    cout << ans;
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0], k = tmp[1];
        int kMax = (n-1)*(n-2)/2;
        if (k > kMax){ WriteLine(-1); return; }

        int m = (n - 1) + (kMax - k);
        WriteLine(m);

        for (int i = 2; i <= n; i++)
        {
            WriteLine($"{1} {i}");
        }

        if (k == kMax) return;

        int ct = 0;
        while (true)
        {
            for (int i = 2; i <= n - 1; i++)
            {
                for (int j = i + 1; j <= n; j++)
                {
                    WriteLine($"{i} {j}");
                    if (++ct >= kMax - k) return;
                }
            }
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string s; cin >>s;
    string t; cin >>t;

    int start = s.length();
    for (int i = 0; i < s.length() - t.length() + 1; i++) {
        bool flag = true;
        for (int j = 0; j < t.length(); j++) {
            if (t[j] != s[i+j] && s[i+j] != '?') {
                flag = false;
            } 
        }
        if (flag) {
            start = i;
        } 
    }
    
    if (start == s.length()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    } 

    for (int i = 0; i < t.length(); i++) {
        s[start+i] = t[i];
    }

    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '?') {
            s[i] = 'a';
        } 
    }

    cout << s << endl;
    return 0;
}


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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 A, P;
	cin >> A >> P;
	cout << (3 * A + P) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			String str = stdIn.next();
			if(str.equals("#"))
			{
				break;
			}
			boolean flag;
			if(str.charAt(0) == 'y' || str.charAt(0) == 'u' || str.charAt(0) == 'i' || str.charAt(0) == 'o' || 
			   str.charAt(0) == 'p' || str.charAt(0) == 'h' || str.charAt(0) == 'j' || str.charAt(0) == 'k' || 
			   str.charAt(0) == 'l' || str.charAt(0) == 'n' || str.charAt(0) == 'm')
			{
				flag = true;
			}
			else
			{
				flag = false;
			}
			int count = 0;
			for(int i = 0; i < str.length(); ++i)
			{
				if(!flag)
				{
					if(str.charAt(i) == 'y' || str.charAt(i) == 'u' || str.charAt(i) == 'i' || str.charAt(i) == 'o' || 
					   str.charAt(i) == 'p' || str.charAt(i) == 'h' || str.charAt(i) == 'j' || str.charAt(i) == 'k' || 
					   str.charAt(i) == 'l' || str.charAt(i) == 'n' || str.charAt(i) == 'm')
					{
						flag = !flag;
						++count;
					}
				}
				else
				{
					if(!(str.charAt(i) == 'y' || str.charAt(i) == 'u' || str.charAt(i) == 'i' || str.charAt(i) == 'o' || 
					   str.charAt(i) == 'p' || str.charAt(i) == 'h' || str.charAt(i) == 'j' || str.charAt(i) == 'k' || 
					   str.charAt(i) == 'l' || str.charAt(i) == 'n' || str.charAt(i) == 'm'))
					{
						flag = !flag;
						++count;
					}
				}
			}
			System.out.println(count);
			
		}
	}
}

Measured memory_bytes: 12000
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long n = sc.nextLong();
		long s = sc.nextLong();

		if (n < s) {
			pr.println(-1);
			return;
		}
		if (n == s) {
			pr.println(n + 1);
			return;
		}

		long ans = INF;
		for (int b = 2; b < Math.min(n, 1_000_000); b++) {
			if (f(n, b) == s) {
				ans = Math.min(ans, b);
			}
		}

		for (int p = 1; p < Math.min(n, 1_000_000); p++) {
			long b = (n - s)  / p + 1;
			if (p < b && f(n, b) == s) {
				ans = Math.min(ans, b);
			}
		}

		if (ans == INF) {
			pr.println(-1);
		} else {
			pr.println(ans);
		}

	}
	
	static final long INF = Long.MAX_VALUE;

	private static long f(long n, long b) {
		long sum = 0;
		while (n > 0) {
			sum += n % b;
			n /= b;
		}
		
		return sum;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

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

  vector<int> broken(n+1);
  rep(i,m) {
    int a;
    cin >> a;
    broken[a] = 1;
  }

  ll dp[100010];
  const ll mod = 1000000007;
  dp[0] = 1;
  if(broken[1]) dp[1] = 0;
  else dp[1] = 1;

  for(int i = 2; i <= n; i++) {
    if(broken[i]) {
      dp[i] = 0;
      continue;
    }
    dp[i] = (dp[i-2] + dp[i-1]) % mod;
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h> 
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const LL N=600005,mo=998244353;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
LL n,a,b,K,fac[N+2],inv[N+2],ans;
LL qpow(LL x,LL k)
{
	LL ret=1;
	while(k){
		if(k&1) ret*=x,ret%=mo;
		x*=x;x%=mo;k>>=1;
	}
	return ret;
}
LL C(LL x,LL y)
{
	return fac[x]*inv[y]%mo*inv[x-y]%mo;
}
int main()
{
	cin>>n>>a>>b>>K;
	fac[0]=1;
	for(int i=1;i<=N;i++) fac[i]=(fac[i-1]*i)%mo;
	inv[N]=qpow(fac[N],mo-2);
	for(int i=N-1;i>=0;i--) inv[i]=(inv[i+1]*(i+1))%mo;
	for(LL i=0;i<=n;i++)
	{
		LL x=K-a*i;
		if(x<0) break;
		LL j=x/b;
		if(x%b!=0||j>n) continue;
//		cout<<i<<' '<<j<<endl;
		ans+=C(n,i)*C(n,j)%mo;
		ans%=mo;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> num(n,0);
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        cin >> num.at(i);
        ans+=num.at(i);
    }
    sort(num.begin(),num.end());
    cout << num.at(0) << " ";
    reverse(num.begin(),num.end());
    cout << num.at(0) << " ";
    cout << ans << endl;
    return(0);

}


Measured memory_bytes: 3228
n, m = map(int, input().split())
a = []
for i in range(n):
    a.append(input())
# [d1, d2, d3, ..., dN]
b = []
for i in range(m):
    b.append(input())
# [d1, d2, d3, ..., dN]
for s in range(n - m + 1):
    for t in range(n - m + 1):
        for i in range(s, m + s):
            for j in range(t, m + t):
                if a[i][j] != b[i - s][j - t]:
                    break
            else:  # 内側のforのelse節は内側ループが全部まわり切ったら実行される、つまり前の行のbreakで抜けた場合ここは実行されない
                if i == m + s - 1 and j == m + t - 1:
                    print("Yes")
                    exit()
                continue  # 外側のforに対応するcontinue文、ここが実行されたら次の行のbreakには処理がいかず、外側のforの次のループにジャンプする
            break  # 外側のforを抜ける
print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int dp[100009][4],h[100009][4];
int solve(int i,int j)
{
	if(i==1)
		return h[1][j];
	if(dp[i][j]!=-1)
		return dp[i][j];
	else
	{
		int temp=0;
		for(int x=1;x<=3;x++)
		{
			if(x!=j)
				temp=max(temp,h[i][j]+solve(i-1,x));
		}
		dp[i][j]=temp;
	}
	return dp[i][j];
}
int main()
{
	int n,i,x,y,z;
	cin>>n;
/*	for(i=1;i<=n;i++)
		cin>>h[i][1];
	for(i=1;i<=n;i++)
		cin>>h[i][2];
	for(i=1;i<=n;i++)
		cin>>h[i][3];*/
	for(i=1;i<=n;i++)
	{
		cin>>x>>y>>z;
		h[i][1]=x;h[i][2]=y;h[i][3]=z;
	}
	memset(dp,-1,sizeof dp);

	cout<<max(solve(n,1),max(solve(n,2),solve(n,3)))<<endl;
	//cout<<solve(n,3)<<endl;
	/*for(i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
			cout<<dp[i][j]<<" ";
		cout<<endl;
	}*/
	
	return 0;

}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main()
{
    int A,B;
    cin >> A >> B;
    for(int i = 1; i <= 1000; i++)
    {
        if(i*8/100 == A && i*10/100 == B)
        {
            cout << i << endl;
            return(0);
        }
    }
    cout << "-1" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005

struct Info{

	bool operator<(const struct Info &arg) const{
		return value*arg.max_weight > arg.value*max_weight; //重さ当たりの価値の降順
	}
	ll value,max_weight;
};

int N;
double W;
Info info[NUM];

int main(){

	scanf("%d %lf",&N,&W);

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

		scanf("%lld %lld",&info[i].value,&info[i].max_weight);
	}
	sort(info,info+N);

	double ans = 0;

	for(int i = 0; i < N; i++){ //重さ当たりの価値が高いものから、重さの上限まで選んでいけば良い

		if(W >= (double)info[i].max_weight){

			ans += info[i].value;
			W -= info[i].max_weight;

			if(fabs(W) < EPS)break;

		}else{

			ans += info[i].value*(W/info[i].max_weight);
			break;
		}
	}

	printf("%.10lf\n",ans);

	return 0;
}



Measured memory_bytes: 4820
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author dilip
 */

/*
*   author : dilip
*   time : 23-06-2019 22:11
*/

#include <iostream>
#include <fstream>

#include <iostream>
#include<stdio.h>
#include<bits/stdc++.h>
#define ll long long

//#define N 10000

using namespace std;
class CVacation {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
		ll n;
        in >> n;
		vector<ll> a(n ),b(n),c(n);
		//ll dp[n][n];
        for(int i=0;i<n;i++) in >> a[i] >> b[i] >> c[i];
		vector<int> v(3,0);
		vector<vector<int>> dp(n,v);
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];

		for(int i=1;i<n;i++){
			dp[i][0] = max(dp[i-1][1]+a[i] , dp[i-1][2]+a[i]);
			dp[i][1] = max(dp[i-1][0]+b[i] , dp[i-1][2]+b[i]);
			dp[i][2] = max(dp[i-1][0]+c[i] , dp[i-1][1]+c[i]);
		}

		out << max({dp[n-1][0],dp[n-1][1] , dp[n-1][2]}) << endl;

	}
};


int main() {
	CVacation solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 8064
p = [input().split() for i in range(3)]
N = int(input())
bs = [input() for i in range(N)]

flag = False
if p[0][0] in bs and p[0][1] in bs and p[0][2] in bs:
  flag = True
if p[1][0] in bs and p[1][1] in bs and p[1][2] in bs:
  flag = True
if p[2][0] in bs and p[2][1] in bs and p[2][2] in bs:
  flag = True
if p[0][0] in bs and p[1][0] in bs and p[2][0] in bs:
  flag = True
if p[0][1] in bs and p[1][1] in bs and p[2][1] in bs:
  flag = True
if p[0][2] in bs and p[1][2] in bs and p[2][2] in bs:
  flag = True
if p[0][0] in bs and p[1][1] in bs and p[2][2] in bs:
  flag = True
if p[0][2] in bs and p[1][1] in bs and p[2][0] in bs:
  flag = True

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

int main() {
	int n=read(),c1=0,c2=0,c4=0;
	for (int i=1;i<=n;++i) {
		int w=read();
		if (w%4==0) ++c4;
		else if (w%2==0) ++c2;
		else ++c1;
	}
	if (!c2&&c1<=c4+1) puts("Yes");
	else if (c1<=c4) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int ans=0,n,a[10005],k;
	cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	for(int i=n-1;i>=n-k;i--) ans+=a[i];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int primeNumber(const int n) {
	//上から確認する
	for (int N = n; N >= 1; N--) {

		bool isPrime = true;
		//素数判定 i < sqrt(N)+1
		for (int i = 2; i * i <= N; i++) {
			if (N % i == 0) {
				isPrime = false;
				break;
			}
		}
		//もし素数なら
		if (isPrime) {
			return N;
		}
	}
}


int main() {
	int i, j, k;

	int N, M, K;
	int H, W;
	cin >> H >> W >> K;

	int A[6][6] = { {0} };
	rep(i, 0, H) {
		string S;
		cin >> S;
		rep(j, 0, W) {
			if (S[j] == '.')
				A[i][j] = 0;
			else
				A[i][j] = 1;
		}
	}
	ll ans = 0;
	N = pow(2, H);
	M = pow(2, W);
	ll tmp = 0;
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++)
		{
			int B[6][6] = { {0} };
			int p, q;
			rep(p, 0, H) {
				rep(q, 0, W) {
					B[p][q] = A[p][q];
				}
			}

			rep(p, 0, H) {
				if (i & (1 << p)) {
					rep(q, 0, 6)
						B[p][q] = 0;
				}
			}
			rep(q, 0, W) {
				if (j & (1 << q)) {
					rep(p, 0, 6)
						B[p][q] = 0;
				}
			}

			ll sum = 0;
			rep(p, 0, 6)
				rep(q, 0, 6)
					sum += B[p][q];
			
			if (sum == K) {
				ans++;
			}

		}
		tmp++;
	}
//	cout << tmp << endl;
	cout << ans;
	return 0;
}


Measured memory_bytes: 4100
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



int main()
{
  ll N; cin>>N;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  vector<ll> vec(0);
  rep(i,N) vec.push_back(i-A[i]);
  sort(vec.begin(),vec.end());
  
  ll ans=0;
  rep(i,N){
    
    ll ok=N,ng=-1,low,up;
    while(abs(ok-ng)>1){
      ll mid=(ok+ng)/2;
      if(A[i]+i<=vec[mid]) ok=mid;
      else ng=mid;
    }
    low=ok;
    
    ok=N,ng=-1;
    while(abs(ok-ng)>1){
      ll mid=(ok+ng)/2;
      if(A[i]+i<vec[mid]) ok=mid;
      else ng=mid;
    }
    up=ok;
    
    ans+=up-low;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6968
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

func main() {
	sc = initScanner(os.Stdin)
	n, m := scanInt(sc), scanInt(sc)
	fmt.Println(resolve(n, m))
}

func resolve(n, m int) int {
	menu := make([]int, m)

	for i := 0; i < n; i++ {
		a := scanInt(sc)

		for j := 0; j < a; j++ {
			menu[scanInt(sc)-1]++
		}
	}

	count := 0
	for _, v := range menu {
		if v == n {
			count++
		}
	}

	return count
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStringSlice(sc *bufio.Scanner, n int) []string {
	ss := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		ss[i] = sc.Text()
	}

	return ss
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

ll sum(int l, int r, vector<ll> &pref)
{
    return (l ? pref[r] - pref[l - 1] : pref[r]);
}

void cp()
{
    int n, k;
    cin >> n >> k;
    vector<ll> less, more;
    bool has_zero = false;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if(x < 0)
            less.pb(x);
        else if(x > 0)
            more.pb(x);
        else
            has_zero = true;
    }

    int pos_zero = 0;
    vector<ll> diff;

    // If originally did not have zero, we add one. Increase window length
    if(!has_zero)
        k++;

    // Find distances for negative numbers
    for(int i = 1; i < sz(less); i++)
    {
        diff.pb(abs(less[i] - less[i - 1]));
    }
    if(sz(less))
        diff.pb(abs(less.back()));

    // Add zero
    pos_zero = sz(diff);
    diff.pb(0);


    // Find distances for positive numbers
    if(sz(more))
        diff.pb(abs(more[0]));

    for(int i = 1; i < sz(more); i++)
    {
        diff.pb(abs(more[i] - more[i - 1]));
    }
    // Forming Prefix Array
    for(int i = 1; i < sz(diff); i++)
        diff[i] += diff[i - 1];
    // Get window of size k
    int i = 0, j = 0;
    while(j - i + 1 < k && j < sz(diff))
        j++;

    // Move window to include zero
    while(j < pos_zero)
        i++, j++;

    ll ans = INT_MAX;

    while(i <= pos_zero && j < sz(diff))
    {
    	// Numbers on the Left of zero
        ll left = sum(i, pos_zero, diff);
        // Numbers on the right of zero
        ll right = sum(pos_zero, j, diff);

    	// Either you visit some numbers on right twice and on left once
    	// Or you visit some numbers on left twice and on right once
        ans = min({ans, left * 2 + right, right * 2 + left});

        // Next window
        i++, j++;
    }
    cout << ans;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 5664
#include <stdio.h>

int main()
{
    long int a, b, k;
    scanf("%ld %ld %ld", &a, &b, &k);
    a-=k;
    if(a<=0)
    {
        b+=a;
        a=0;
    }
    if(b<0)
        b=0;
    printf("%ld %ld\n", a, b);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;
int main()
{
    int n, s = 0, m = -1;
    cin >> n;
    rep(i, n)
    {
        int t;
        cin >> t;
        m = max(m, t);
        s += t;
    }
    cout << (s - m / 2) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N,M = map(int,input().split())
to = [[] for i in range(N)]
for i in range(N-1) :
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    to[u].append(v)
    to[v].append(u)

ans = [0]*N

for i in range(M) :
    p,x = map(int,input().split())
    p -= 1
    ans[p] += x

q = deque([0])
par = [-1]*N
while q :
    u = q.popleft()
    for v in to[u] :
        if v == par[u] :
            continue
        ans[v] += ans[u]
        par[v] = u
        q.append(v)
print(*ans)


Measured memory_bytes: 93972