akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  vector<string> S(60);
  cin >> n;
  for(int i=0;i<n;i++)cin >> S[i];
  string ans="";
  for(int i=0;i<=25;i++){
    char X='a'+i; int q=50;
    for(int j=0;j<n;j++){
      int count=0;
      for(int k=0;k<S[j].size();k++){
        if(S[j][k]==X){count++;}
      }
      q=min(q,count);
    }
    for(int l=0;l<q;l++)ans+=X;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from copy import deepcopy
N, W = tuple(map(int, input().split()))
items = []
for n in range(N):
    items.append(list(map(int, input().split()))) # value, weight

pre_costs = [0 for _ in range(W+1)]
post_costs = [0 for _ in range(W+1)]

for item in items:
    for w in range(item[1], W+1):
        post_costs[w] = max(pre_costs[w], pre_costs[w-item[1]] + item[0])
    pre_costs = deepcopy(post_costs)

print(post_costs[-1])

Measured memory_bytes: 9024
while True:
    A,B=map(int,raw_input().split())
    if A==B==0:break
    t=B-A
    L=[1000,500,100]
    T=[]
    for i in range(len(L)):
        T.append(t/L[i])
        t%=L[i]
    print "%d %d %d"%(T[2],T[1],T[0])

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, s[110000];
int main() {
    cin >> n;
    REPO(i, 1000){
        REPO(j, 1000){
            if (i * i + j * j > 10000) break;
            REPO(k, 1000){
                ll t = i * i + j * j + k * k + i * j + j * k + i * k;
                if (t <= 10000) s[t]++;
                else
                    break;
            }
        }
    }
    REPO(i, n){
        cout << s[i] << endl;
    }
}

Measured memory_bytes: 3672
void main()
{
    string s = rdStr;

    long g, p;
    long score;
    foreach (x; s)
    {
        if (p < g)
        {
            ++p;
            if (x == 'g') ++score;
        }
        else
        {
            ++g;
            if (x == 'p') --score;
        }
    }

    score.writeln;
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = int(5e5) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

int n, k;
string s;
int main (){
    cin >> n >> s >> k;

    string ans = s;
    for (int i = 0; i < sz(s); ++i)
    {
        if (s[i] != s[k - 1]) ans[i] = '*';
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x;
    cin >> x;
    for (ll t = 1; ; ++t) {
        if (t * (t + 1) >= 2 * x) {
            cout << t << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int ans = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]!= a[j] && a[i]!=a[k] && a[j]!=a[k])
                {
                    if(a[i]>=a[j]+a[k] || a[j]>=a[i]+a[k] || a[k]>=a[i]+a[j])
                    ans += 0;
                    else
                        ans+=1;                    
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i,n)cin >> h[i];

    int dp[n] = {};
    srep(i,1,n)dp[i] = 1001001001;

    rep(i,n){
        if(i + 1 >= n)continue;
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        if(i + 2 >= n)continue;
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }

    cout << dp[n-1] << endl;
    return 0;
}
 
 


Measured memory_bytes: 1024
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> H, W;
  invec<string> s(H);
  
  vector<vector<int>> dp(H, vector<int>(W, 0));
  
  dp[H-1][W-1] = (s[H-1][W-1] == '#') ? 1 : 0;
  for(int j = W-2; j >= 0;j--) {
    int right = dp[H-1][j+1];
    dp[H-1][j] = right + ((s[H-1][j] == '#' && s[H-1][j+1] == '.') ? 1 : 0);
  }
  for (int i = H-2; i >=0;i--) {
    int down = dp[i+1][W-1];
    dp[i][W-1] = down + ((s[i][W-1] == '#' && s[i+1][W-1] == '.') ? 1 : 0);
  }

  for (int i = H-2; i >=0;i--)
    for(int j = W-2; j >= 0;j--) {
    int right = dp[i][j+1];
    int down = dp[i+1][j];
    if (s[i][j] == '#' && s[i][j+1] == '.')
      right++;
    if (s[i][j] == '#' && s[i+1][j] == '.')
      down++;
    dp[i][j] = min(right, down);



    }


  return dp[0][0];
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 256
from math import gcd
from functools import reduce
from itertools import product

def resolve():
  N, K = map(int, input().split(" "))

  a = []
  for k in range(K):
    d = int(input())
    a.extend([int(x) for x in input().split(" ")])

  a = list(set(a))
  print(N-len(a))

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 68296
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int N = one.get(0);
		int K = one.get(1);
		ArrayList<Integer> list = nextIntArray();
		Collections.sort(list, Comparator.reverseOrder());
		int output = 0;
		for(int i = 0; i < K; i++){
			output += list.get(i);
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 25340
object Main extends App {
    val a, b, c, d, e, k = Read.Int
    if( e - a > k ) {
        println( ":(" )
    } else {
        println( "Yay!" )
    }
}

object Read {
    val scanner = new java.util.Scanner( System.in )
    
    def Int() :Int = scanner.nextInt
}

Measured memory_bytes: 25552
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll chk[55];
//ll num[55];
//ll num2[55];
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<long long int> pq;   //big at front
//stack<int> stk;
//vector<pair<ll,ll>> vint;
//vector<ll> vtime;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//map<ll,ll> mp;


int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3,range;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    a=a1=a2=a3=a4=a5=a6=0;
    //float f,g,h;
    //string s,s1;
    //char now,pre,c;
    cin>>n>>m;
    a1=m-n;
    a=(1+a1)*a1/2;
    cout<<a-m;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    public static long gcd(long a, long b) {
        if (a < b) {
            return gcd(b, a);
        } else {
            if (b == 0) {
                return a;
            } else {
                return gcd(b, a % b);
            }
        }
    }
    public static void main(String [] args) {
        final Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        long M = scanner.nextLong();
        String s = scanner.next();
        String t = scanner.next();

        final HashMap<Long, String> mapping = new HashMap<>();

        final long length = N * M / gcd(N, M);
        final long k1 = length / N;
        final long k2 = length / M;

        for (int j = 0; j < M; ++j) {
            mapping.put(j * k2, String.valueOf(t.charAt(j)));
        }

        for (int i = 0; i < N; ++i) {
            long currentPos = i * k1;
            if (!mapping.containsKey(currentPos)) {
                mapping.put(currentPos, String.valueOf(s.charAt(i)));
            } else if (!mapping.get(currentPos).equals(String.valueOf(s.charAt(i)))) {
                System.out.println(-1);
                return;
            }
        }
        System.out.println(length);
    }
}


Measured memory_bytes: 54584
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int P = 1e9 + 7;
int n , m;
int fac(int x){
    int res=1;
    rep(i,1,x+1) res=ll(res)*i%P;
    return res;
}

int main(){
    cin >> n >> m;
    int ans=ll(fac(n))*fac(m)%P;
    if(n==m) ans=ans*2%P;
    else if(abs(n-m)!=1) ans=0;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n, m;

struct edge{
    int from, to, lim;
    double dist;
    edge(int f, int t, double d, int l): from(f), to(t), dist(d), lim(l){}
};

struct state{
    int v, pv, speed;
    double time;
    state(int v, int pv, int s, double t): v(v), pv(pv), speed(s), time(t){}
};

void solve(){
    int s, g;
    scanf("%d%d", &s, &g);
    --s; --g;
    vector<edge> G[n];
    rep(i, m){
        int a, b, c;
        double d;
        scanf("%d%d%lf%d", &a, &b, &d, &c);
        --a; --b;
        G[a].emplace_back(a, b, d, c);
        G[b].emplace_back(b, a, d, c);
    }

    double d[n][n][35]; // v, pv, speed
    rep(i, n)rep(j, n)rep(k, 35) d[i][j][k] = INF;
    auto cmp = [](const state &s1, const state &s2){
        return s1.time > s2.time;
    };
    priority_queue<state, vector<state>, decltype(cmp)> que(cmp);
    d[s][s][0] = 0;
    que.emplace(s, s, 0, 0);
    while(!que.empty()){
        auto now = que.top();
        que.pop();
        if(now.time > d[now.v][now.pv][now.speed]) continue;
        for(auto &e: G[now.v])if(e.to != now.pv){
            for(int i=-1; i<=1; ++i){
                int ns = now.speed + i;
                if(1 <= ns && ns <= e.lim && chmin(d[e.to][now.v][ns], now.time + (double)e.dist / ns)){
                    que.emplace(e.to, now.v, ns, d[e.to][now.v][ns]);
                }
            }
        }
    }
    double ans = INF;
    rep(i, n) chmin(ans, d[g][i][1]);
    if(ans == INF) puts("unreachable");
    else printf("%.10lf\n", ans);
}

int main(){
    while(scanf("%d%d", &n, &m) && n){
        solve();
    }
}


Measured memory_bytes: 3780
N=int(input())
li = list(map(int,input().split()))

while(len(li)>1):
    li=sorted(li)
    min_num=li[0]
    li=[i%min_num for i in li]
    li.append(min_num)
    li=[j for j in li if j !=0]
print(li[0])

Measured memory_bytes: 66840
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
       
        int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int x1 = a[0];
        int y1 = a[1];
        int x2 = a[2];
        int y2 = a[3];
        
    　　int dx = x2 - x1;
    　　int dy = y2 - y1;
    　　int x = x2;
    　　int y = y2;
    　　
    　
        for(int i = 0; i < 2; i++)
        {
            Swap<int>(ref dx, ref dy);
            dx = - dx;
            x += dx;
            y += dy;
            Console.Write(x + " " + y + " ");
        }
    　　
    　　
    }
    
    static void Swap<T>(ref T lhs, ref T rhs)
    {
        T temp;
        temp = lhs;
        lhs = rhs;
        rhs = temp;
    }
    
}

Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<unordered_map>
#include<queue>
#include<functional>

using ull = unsigned long long;
using ll = long long;
using namespace std;

using vt = pair<int, int>;

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

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

    // prepare
    unordered_map<int, int> num2freq;
    for (int i = 0; i < n; ++i) {
        num2freq[a[i]]++;
    }

    if (num2freq.size() <= k) {
        cout << 0 << endl;
        return 0;
    } 

    // solve
    int out = 0;

    priority_queue<vt, vector<vt>, function<bool(vt,vt)>>que([](const vt& a, const vt& b) { return a.second > b.second;});
    for(const auto& p : num2freq) {
        que.push(p);
        // cout << "qsize: " << que.size() <<",p="<< p.first << ":" << p.second << std::endl;
    }

    while(!que.empty()) {

        const auto rewrite_cand = que.top();
        // cout << "del_cand:" << rewrite_cand.first <<"-" << rewrite_cand.second << endl;
        out += rewrite_cand.second;
        que.pop();        
        // cout << "qsize: " << que.size() <<"k="<< k << std::endl;
        // cout << "out: " << out << std::endl;

        if (que.size() <= k) {
            break;
        }
    }

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 12360
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;
const int Mod = 1e9 + 7;
ll lst[Max];
int ls[Max];

int main()
{
	int n;
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		int t;
		scanf("%d", &t);
		lst[t]++;
	}
	ll res = 0;
	for (int i = 1;i <= 1e5;i++)
	{
		res = max(res, lst[i - 1] + lst[i] + lst[i + 1]);
	}
	cout << res;
}

Measured memory_bytes: 3920
from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream
 
 
if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)
 
        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)
 
        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)
 
    input = raw_input
    range = xrange
 
    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip
 
 
def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.
 
    Args:
        sync (bool, optional): The new synchronization setting.
 
    """
    global input, flush
 
    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')
 
        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    # sys.stdin  = open("input.txt")
    x=int(input())
    if x==0:
        print("1")
    else:
        print("0")
    

if __name__ == '__main__':
    sync_with_stdio(False)
    main()

Measured memory_bytes: 65732
fn main() {
    let (n,m) = {
        let s=rv::<usize>();
        (s[0],s[1])
    };
    let mut ab=Vec::with_capacity(m);
    for _ in 0..m {
        let s=rv::<usize>();
        ab.push((s[0]-1,s[1]-1));
    }
    let mut v=n*(n-1)/2;
    let mut uf=vec![-1;n];
    let mut r=vec![0;m];
    for (i,(a,b)) in ab.into_iter().enumerate().rev() {
        r[i]=v;
        if find(&mut uf, a)!=find(&mut uf, b) {
            v-=count(&mut uf, a)*count(&mut uf, b);
            unite(&mut uf, a, b);
        }
    }
    for r in r {
        println!("{}",r);
    }
}
fn find(uf: &mut Vec<i32>, i: usize) -> usize {
    if uf[i]<0 {
        i
    }
    else {
        let j=uf[i]as usize;
        uf[i]=find(uf, j)as i32;
        uf[i] as usize
    }
}
fn count(uf: &mut Vec<i32>, i: usize) -> usize {
    let j=find(uf,i);
    -uf[j] as usize
}
fn unite(uf: &mut Vec<i32>, mut i: usize, mut j: usize) {
    i=find(uf,i);
    j=find(uf,j);
    if i==j {
        return;
    }
    if uf[i]<uf[j] {
        std::mem::swap(&mut i, &mut j);
    }
    uf[i]+=uf[j];
    uf[j]=i as i32;
}
fn rl() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s
}
fn rv<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug, {
    rl().split_whitespace().map(|x|x.parse::<T>().unwrap()).collect()
}

Measured memory_bytes: 8572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
	int a,b;

	std::cin >> a >> b;
	/*
	vector<int> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	*/
	if ((a - b) % 2 == 0)
			cout << a - ((a - b) / 2) << endl;

	else
		cout << "IMPOSSIBLE" << endl;

	return 0;
}

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

using namespace std;

int n;
long long k;
int main()
{
    cin >> n >> k;
    vector<int> a(n), b(n);

    for(auto &x: a) cin >> x;
    for(auto &x: b) cin >> x;

    sort(a.begin(), a.end());
    sort(b.rbegin(), b.rend());

    long long l = 0;
    long long r = 1e12;
    while(l < r){
        long long sum = 0;
        long long m = (l + r) / 2;
        for(int i = 0; i < n; i ++){
            /// a[i] * b[i] <= m

            long long x = m / b[i];
            if(a[i] > x){
                sum += a[i] - x;
            }
        }
        if(sum <= k) r = m;
        else l = m + 1;
    }
    cout << l << "\n";
}


Measured memory_bytes: 1792
import Data.List ((\\))

data Card = Card Pict Int
          deriving Eq

data Pict = S | H | C | D
          deriving (Read, Show, Eq)

instance Show Card where
    show (Card p n) = show p ++ " " ++ show n

main :: IO ()
main = getLine >> getContents >>= mapM_ print . (allCards \\) . map toCard . lines

toCard :: String -> Card
toCard str = Card (read p :: Pict) (read n :: Int)
    where [p,n] = words str

allCards :: [Card]
allCards = zipWith Card picts nums
    where picts = concatMap (replicate 13) [S,H,C,D]
          nums  = take 52 $ cycle [1..13]

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

int main(){
  int i,j,cnt=0;
  int c[4][4];
  for(i=1;i<=3;i++){
    for(j=1;j<=3;j++){
      cin>>c[i][j];
    }
  }
  if((c[1][1]-c[2][1]==c[1][2]-c[2][2] && c[1][1]-c[2][1]==c[1][3]-c[2][3]) && (c[1][1]-c[3][1]==c[1][2]-c[3][2] && c[1][1]-c[3][1]==c[1][3]-c[3][3])){
    cout<<"Yes"<<endl;
  }else cout<<"No"<<endl;
}

Measured memory_bytes: 256
class Unionfind:

    __slots__ = ['nodes']

    def __init__(self, n):
        self.nodes = [-1]*n

    def root(self, x):
        if self.nodes[x] < 0:
            return x
        else:
            root_x = self.root(self.nodes[x])
            self.nodes[x] = root_x
            return root_x

    def unite(self, x, y):
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        rank_x = -self.nodes[x]; rank_y = -self.nodes[y]
        if rank_x < rank_y:
            x, y = y, x
        if rank_x == rank_y:
            self.nodes[x] -= 1
        self.nodes[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def rank(self, x):
        return -self.nodes[self.root(x)]

N,M = map(int,input().split())
info = [list(map(int,input().split())) for i in range(M)]

def bridge(k):
    uf = Unionfind(N)
    for i,pair in enumerate(info):
        if i == k: continue
        a = pair[0] - 1; b = pair[1] - 1
        uf.unite(a,b)
    s = {uf.root(i) for i in range(N)}
    if len(s) != 1:
        return True
    return False

cnt = 0
for k in range(M):
    if bridge(k):
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
n = int(input())
points = []
for i in range(n):
  points.append(list(map(int, input().split())))

flg = False
for point in points:
  flg = (point[0] >= (point[1] + point[2])) and ((point[0] % 2 == 1) and ((point[1] + point[2]) % 2 == 1) or (point[0] % 2 == 0) and ((point[1] + point[2]) % 2 == 0))
  if not flg:
    break
print('Yes') if flg else print('No')


Measured memory_bytes: 27300
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> T keta(T num){ T k=0; while(num>0){ num/=10; k++; } return k; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    double maxdense = -1;
    ll water=0, suger=0;
    reps(i, 0, f/a){
        if(i*a*100 > f) break;
        reps(j, 0, f/b){
            if(i==0 && j==0) continue;
            ll w = i*a*100 + j*b*100;
            if(w > f) break;

            reps(k, 0, w/100*e){
                reps(l, 0, w/100*e){
                    ll s = k*c + d*l;
                    if(s > w/100.0*e) break;
                    if(w + s > f) break;

                    if(maxdense < double(100.0*s / (s+w))){
                        maxdense = double(100.0*s / (s+w));
                        water = w;
                        suger = s;
                    }
                }
            }
        }
    }

    cout << water+suger sp suger << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a = sc.nextInt();
    if (n % 500 <= a) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35512
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int k,n;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int b=n-1;
    int c=k-1;
    cout << (b+c-1)/c  << endl;
}



Measured memory_bytes: 640
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N= 2e6 + 5;
const int MOD = 1e9 + 7;

int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		precompute();
		int k;
		cin >> k;
		string s;
		cin >> s;
		int n = sz(s);
		int ans = 0;
		int tot = n+k;
		rep(i,n,tot)
		{
			int cur1 = nCr(tot,i);
			int cur2 = pow(25,tot-i,MOD);
			int f = (cur1*cur2)%MOD;
			ans = (ans + f)%MOD;
		}
		cout << ans;
	}
}



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int l[2000][2000];
int r[2000][2000];
int u[2000][2000];
int d[2000][2000];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) {
    cin >> s[i];
  }
  // for (int i = 0; i < h; i++) {
  //   for (int j = 0; j < w; j++) {
  //     if (s[i][j] == '#') {
  //       l[i][j] = 0;
  //     } else if (j == 0) {
  //       l[i][j] = 1;
  //     } else {
  //       l[i][j] = l[i][j - 1] + 1;
  //     }

  //     if (s[i][w - j - 1] == '#') {
  //       r[i][w - j - 1] = 0;
  //     } else if (j == w - 1) {
  //       r[i][w - j - 1] = 1;
  //     } else {
  //       r[i][w - j - 1] = r[i][w - j - 1 + 1] + 1;
  //     }

  //     if (s[i][j] == '#') {
  //       d[i][j] = 0;
  //     } else if (i == 0) {
  //       d[i][j] = 1;
  //     } else {
  //       d[i][j] = d[i - 1][j] + 1;
  //     }

  //     if (s[h - i - 1][j] == '#') {
  //       u[h - i - 1][j] = 0;
  //     } else if (i == h - 1) {
  //       u[h - i - 1][j] = 1;
  //     } else {
  //       u[h - i - 1][j] = u[h - i - 1 + 1][j] + 1;
  //     }
  //   }
  // }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        l[i][j] = 0;
      } else if (j == 0) {
        l[i][j] = 1;
      } else {
        l[i][j] = l[i][j - 1] + 1;
      }
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = w - 1; j >= 0; j--) {
      if (s[i][j] == '#') {
        r[i][j] = 0;
      } else if (j == w - 1) {
        r[i][j] = 1;
      } else {
        r[i][j] = r[i][j + 1] + 1;
      }
    }
  }

  for (int j = 0; j < w; j++) {
    for (int i = 0; i < h; i++) {
      if (s[i][j] == '#') {
        d[i][j] = 0;
      } else if (i == 0) {
        d[i][j] = 1;
      } else {
        d[i][j] = d[i - 1][j] + 1;
      }
    }
  }

  for (int j = 0; j < w; j++) {
    for (int i = h - 1; i >= 0; i--) {
      if (s[i][j] == '#') {
        u[i][j] = 0;
      } else if (i == h - 1) {
        u[i][j] = 1;
      } else {
        u[i][j] = u[i + 1][j] + 1;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        continue;
      }
      ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);
    }
  }

  cout << ans << endl;

  return 0;
}


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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

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

Measured memory_bytes: 256
def find_pos(board, n)
  @h.times do |y|
    @w.times do |x|
      return [x, y] if board[y][x] == n
    end
  end
end

def in_check(x, y)
  0 <= x && x < @w && 0 <= y && y < @h
end

def can_visit(cx, cy, mx, my, board)
  visited = @h.times.map{ [false] * @w }
  visited[my][mx] = true
  queue = [[mx, my]]
  until queue.empty?
    x, y = queue.shift
    @dir.each do |dx, dy|
      xx = x + dx; yy = y + dy
      if in_check(xx, yy) && !visited[yy][xx] &&
        board[yy][xx] != 1 && !(cx == xx && cy == yy)
        queue << [xx, yy]
        visited[yy][xx] = true
      end
    end
  end
  visited
end

def move(cx, cy, mx, my, board)
  ret = []
  move_pos = can_visit(cx, cy, mx, my, board)
  @dir.each_with_index do |(dx, dy), i|
    x = cx + dx; y = cy + dy
    if in_check(x, y) && move_pos[y][x]
      ret << i
    end
  end
  ret
end

def solve(cx, cy, mx, my, board)
  used = @h.times.map{ @w.times.map{ [false] * 4 } }
  queue = []
  move(cx, cy, mx, my, board).each do |i|
    queue << [cx, cy, i, 0]
    used[cy][cx][i] = true
  end
  until queue.empty?
    x, y, i, n = queue.shift
    return n if x == @gx && y == @gy
    move(x, y, x + @dir[i][0], y + @dir[i][1], board).each do |ii|
      xx = x + @dir[(ii + 2) % 4][0]
      yy = y + @dir[(ii + 2) % 4][1]
      if in_check(xx, yy) && !used[yy][xx][ii] && board[yy][xx] != 1
        queue << [xx, yy, ii, n + 1]
        used[yy][xx][ii] = true
      end
    end
  end
  -1
end

@dir = [[-1, 0], [0, 1], [1, 0], [0, -1]]
loop do
  @w, @h = gets.split.map(&:to_i)
  break if @w == 0
  board = @h.times.map{ gets.split.map(&:to_i) }

  cx, cy = find_pos(board, 2)
  @gx, @gy = find_pos(board, 3)
  mx, my = find_pos(board, 4)

  puts solve(cx, cy, mx, my, board)
end

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

w = [0]*(n + 1)
e = [0]*(n + 1)

for i in range(n):
    if s[i] == 'W':
        w[i + 1] = w[i] + 1
        e[i + 1] = e[i]
    else:
        e[i + 1] = e[i] + 1
        w[i + 1] = w[i]

del w[0]
del e[0]



l = [0]*n
r = [0]*n

for i in range(n):
    if i != 0:
        l[i] = w[i - 1]
        r[i] = e[n - 1] - e[i]
    else:
        r[0] = e[n-1]


ans = [(l[i] + r[i]) for i in range(n)]

print(min(ans))

Measured memory_bytes: 44068
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    ll a,b;
    string s;
    cin>>a>>s>>b;
    if(s=="+") cout<<a+b<<endl;
    else cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
// 二分探索木：探索
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

Node *find(Node *u, int k) {
    while (u != NIL && k != u->key) {
        if(k < u->key) 
            u = u->left;
        else
            u = u->right;
    }
    return u;
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inoder(Node *u) {
    if (u == NIL) return;
    inoder(u->left);
    printf(" %d", u->key);
    inoder(u->right);
}

void preoder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preoder(u->left);
    preoder(u->right);
}

int main() {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        cin >> com;
        if(com == "insert") {
            scanf("%d", &x);
            insert(x);
        }

        else if (com == "print") {
            inoder(root);
            printf("\n");
            preoder(root);
            printf("\n");
        }

        else if (com == "find") {
            scanf("%d", &x);
            Node *t = find(root, x);
            if (t != NIL) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}



Measured memory_bytes: 22060
a,b,c=map(int,input().split())
ct=0
h=0
while 1:
    if (a%2==1)or(b%2==1)or(c%2==1):
        break
    if ct==100000:
        h=1
        break
    a2=a//2
    b2=b//2
    c2=c//2
    a=b2+c2
    b=c2+a2
    c=a2+b2
    ct+=1
if h==1:
    print(-1)
else:
    print(ct)

Measured memory_bytes: 38640
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = il()

    for n in range(1, 1010):
        if int(n * 0.08) == A and int(n * 0.1) == B:
            print(n)
            exit()

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;
#define REP(i,a,n) for(int i = a; i < (int)n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#endif

int N;
int A[100001];
int four = 0;
int two = 0;
bool ok = false;

void input() {
	cin >> N;
	REP(i, 0, N) {
		cin >> A[i];
		if (A[i] % 4 == 0) {
			four++;
		} else if (A[i] % 2 == 0) {
			two++;
		}
	}
	return;
}

void solve() {
	if (four * 2 + two >= N) {
		ok = true;
	}
	if (N % 2 == 1 && four * 2 + 1 >= N) {
		ok = true;
	}
	return;
}

void output() {
	cout << (ok ? "Yes" : "No") << endl;
	return;
}

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

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(8 + 5);

int n;
double x[MAX_N];
double y[MAX_N];

double calc(double last_x, double last_y, double cur_x, double cur_y) {
  double first = (cur_x - last_x) * (cur_x - last_x);
  double second = (cur_y - last_y) * (cur_y - last_y);
  return sqrt(first + second);
}

double path(vector<int>& v) {
  double ret = 0.0;

  double last_x = x[v[0]];
  double last_y = y[v[0]];

  for (int i = 1; i < v.size(); ++i) {
    double cur_x = x[v[i]];
    double cur_y = y[v[i]];

    ret += calc(last_x, last_y, cur_x, cur_y);
  }

  return ret;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%lf %lf", &(x[i]), &(y[i]));
  }

  vector<int> v;

  for (int i = 0; i < n; ++i) {
    v.push_back(i);
  }

  double whole = 0.0;

  do {
    whole += path(v);
  } while (next_permutation(v.begin(), v.end()));

  double under = 1.0;

  for (int i = 1; i <= n; ++i) {
    under *= (double)(i);
  }

  double ans = whole / under;

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

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    LL N,A,B; cin >> N >> A >> B;
    if(N == 1){
        if(A != B){
            cout << 0 << endl;
        }else{
            cout << 1 << endl;
        }
    }else{
        if(A > B){
            cout << 0 << endl;
        }else{
            LL MAX = A + B * (N-1);
            LL MIN = A * (N-1) + B;
            cout << MAX-MIN+1 << endl;
        }

    }

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
long x,p,s;
scanf("%ld",&x);
for(p=x;;p++){
for(s=2;s<p;s++){
 if(p%s==0)
  break;
}
if(p>=x&&p==s)
break;//忘れてた
}
printf("%ld",p);
return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int cnt=0;
void insertion_sort(int *a,int n, int g) {
    for(int i=g;i<n;i++) {
        int v=a[i];
        int j=i-g;
        while(j>=0&&a[j]>v) {
            a[j+g]=a[j];
            j-=g;
            cnt++;
        }
        a[j+g]=v;
    }
}

vector<int> G;
void shell_sort(int *a,int n) {
    int h=1;
    while(h<=n) {
        G.pb(h);
        h=3*h+1;
    }

    reverse(all(G));
    rep(i,G.size()) insertion_sort(a,n,G[i]);

}

int n;
int a[1000006];

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

    shell_sort(a,n);
    cout<<G.size()<<endl;
    rep(i,G.size()) cout<<(i==0?"":" ")<<G[i];
    if(G.size()) cout<<endl;
    cout<<cnt<<endl;
    rep(i,n) cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	int A,B;
	cin >> A >> B ;
	cout <<6-A-B;
    return 0;
}


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

res = 0
prev = -1
for i in range(n):
    res += b[a[i]-1]
    if prev+1 == a[i]:
        res += c[prev-1]
    prev = a[i]

print(res)


Measured memory_bytes: 38384