akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numN = nextInt();
		int numA = nextInt();

		out.println(numN * numN - numA);
	}

	private void solveB() {
		int numN = nextInt();
		int numK = nextInt();

		int[] wk = IntStream.range(0, numN).map(i -> nextInt()).toArray();

		int res = Arrays.stream(wk).reduce(0, (sum, num) -> {
			return sum += Math.min(num * 2, (numK - num) * 2);
		});

		out.println(res);

	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

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

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

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

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

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

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

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

using namespace std;

int local;

map<string, int> mp;

void solve(){
    string s; cin>>s;
    mp[s]++;
}

void output(){
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
}

int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    local = 1;

    mp["AC"] = mp["WA"] = mp["TLE"] = mp["RE"] = 0;

    if(local){
        int tc; cin>>tc; while(tc--) solve();
    }
    else solve();

    output();

    return 0;
}




Measured memory_bytes: 3612
#include <iostream>
  #include<cstdio>
    using namespace std;
      int main(){
       int n, min=1000000, max=-1000000;
         cin>>n;
           long long sum=0;
             for(int i=0; i<n; i++){
               int a;
                 cin>>a;
                 sum=sum+a;
                   if(min>a){
                     min=a;
}                      
                       if(max<a){
                       max=a;
}
}
                          cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3104
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)

#define SZ(x)  (ll)(x.size())

#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


int main()
{


    ll c=0,i;

    string s1,s2;

    cin>>s1>>s2;

    rep(i,0,s1.size())
    {
        if(s1[i]!=s2[i])
            ++c;
    }

    cout<<c;

    return 0;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

struct Mod {
    static constexpr auto kMod = 1000003L;
    static constexpr auto kIMod = 1000001L;

    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const {
        return (n * (m.n % kMod)) % kMod;
    }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p/2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kIMod);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const {
        return (n + m.n) % kMod;
    }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

    Mod operator-(Mod m) const {
        return (kMod + n - m.n) % kMod;
    }

    Mod& operator-=(Mod m) {
        *this = *this - m;
        return *this;
    }

    int64_t n;
};

Mod operator/(int64_t lhs, Mod rhs) {
    return Mod(lhs) / rhs;
}

Mod operator*(int64_t lhs, Mod rhs) {
    return Mod(lhs) * rhs;
}

Mod operator+(int64_t lhs, Mod rhs) {
    return Mod(lhs) + rhs;
}

Mod operator-(int64_t lhs, Mod rhs) {
    return Mod(lhs) - rhs;
}

main() {
    auto M = Mod::kMod;

    vector<Mod> fact(M, 1);
    for (auto i : irange(2L, M)) {
        fact[i] = fact[i - 1] * i;
    }

    int64_t q;
    cin >> q;

    for (auto _ : irange(0L, q)) {
        int64_t x, d, n;
        cin >> x >> d >> n;

        if (d == 0) {
            cout << (Mod(x).pow(n)).n << endl;
            continue;
        }

        if (n >= M) {
            cout << 0 << endl;
            continue;
        }

        auto k = (Mod(M - x) / d).n;

        if (k <= n - 1) {
            cout << 0 << endl;
            continue;
        }

        auto a = fact[n - 1 - k + M] / fact[-1 - k + M];

        a *= Mod(d).pow(n);

        cout << a.n << endl;
    }


}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	std::cin >> n;
	std::vector<int>v;
	int num;
	for (int i = 0; i < n; ++i) {
		std::cin >> num;
		v.push_back(num);
	}
	std::sort(v.begin(), v.end());
	int ct=0;
	bool bl=1;
	for (int i = 0; i < v.size(); ++i) {
		if (i > 0 && v[i] == v[i - 1])bl = !bl;
		if (bl)++ct;
		else {
			--ct; if (v[i] != v[i - 1]) {ct+=2; bl = 1; }
		}
	}
	std::cout << ct << std::endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
 
  // ここにプログラムを追記
  int result = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '+') result++;
    else if (S.at(i) == '-') result--;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define ull unsigned long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pul pair<ull,LL> 
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int mod=998244353;
template<typename T> void chkmin(T &x,T y) {if(y<x) x=y;}
template<typename T> void chkmax(T &x,T y) {if(y>x) x=y;}
template<typename T> void upd(T &x,T y) {if((x+=y)>=mod) x-=mod;}
int n,m,K,sl,fh,cnt,ans,c[15],p[1010],a[15][1010],s[15][1010];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void dfs(int S,int k,int lst)
{
	if(S==n)
	{
		cnt=0;int flg;
		for(int i=1;i<=k;++i) c[i]=0;
		for(int i=1;i<=m;++i)
		{
			flg=0;
			for(int j=1;j<=k;++j) c[j]+=s[j][i],flg|=c[j]>K;
			if(flg)
			{
				cnt++;
				for(int j=1;j<=k;++j)
				{
					c[j]=s[j][i];
					if(s[j][i]>K) return ;
				}
			}
		}
		chkmin(ans,k-1+cnt);
		return ;
	}
	if(S+lst>n) return ;
	for(int i=lst;i<=n-S;++i)
	{
		for(int y=1;y<=m;++y)
		{
			s[k+1][y]=0;
			for(int x=S+1;x<=S+i;++x)
				s[k+1][y]+=a[x][y];
		}
		dfs(S+i,k+1,i);
	}
}
int main()
{
	n=rd();m=rd();K=rd();ans=1e9;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
		scanf("%1d",&a[i][j]);
	dfs(0,0,1);
	printf("%d\n",ans);
	return 0;
}

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

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

typedef long long ll;
typedef pair<int, int> pi;

int n;
vector<vector<int> > adjList;
map<pair<int, int>, int> mp;
vector<int> edges, dp;
int cnt = 0, counter = 0;
vector<int> start, finish;
bool isCycle;

void mapping(int a, int b){
    pi p1 = make_pair(a, b);
    pi p2 = make_pair(b, a);

    if (mp.count(p1)) edges.emplace_back(mp[p1]);
    else {
        mp[p1] = cnt;
        mp[p2] = cnt;
        cnt;
        edges.emplace_back(cnt);
        cnt++; 
    }
}

int backtrack(int node){

    int &ret = dp[node];
    if (ret != -1) return ret;

    ret = 0;
    start[node] = counter++;
    for (auto child : adjList[node]){
        if (start[child] != -1 && finish[child] == -1){
            isCycle = true;
        }
        ret = max(ret, backtrack(child) + 1);
    }
    finish[node] = counter++;
    return ret;
}

int main() {
    //freopen("in.txt", "r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    
    int e = n*(n-1);
    e /= 2;
    adjList.assign(e, vector<int>());
    dp.assign(e, -1);

    int x;
    for (int i=1;i<=n;++i){
        edges.clear();
        for (int j=0;j<n-1;++j){
            cin>>x;
            mapping(i, x);
        }

        for (int j=n-3;j>=0;j--){
            adjList[edges[j+1]].push_back(edges[j]);
        }
    }

    start.assign(e, -1);
    finish.assign(e, -1);
    isCycle = false;

    int ans = -1;
    for (int i=0;i<e;++i){
        if (dp[i] == -1)
            ans = max(ans, backtrack(i));
        else ans = max(ans, dp[i]);
    }

    if (isCycle) cout<<"-1"<<endl;
    else cout<<ans+1<<endl;
    
    return 0;
}

Measured memory_bytes: 96000
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define pb push_back
#define mp make_pair
#define pl pair<ll, ll>
#define vl vector<ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 100005
vector<ll>a(10000001,0);

int main()
{
    ll n;cin>>n;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=0;j<=n;j+=i)
        {
            a[j]+=1;
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ans+=i*a[i];
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 81240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" -> ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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 (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s;
    cin >> s;
    int x = 0;
    rep(i, s.size()) {
        x += s[i] - '0';
    }
    cout << (x % 9 ? "No" : "Yes") << endl;
}

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

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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());


signed main()
{
    gearup;
    string a,b; cin >> a >> b;
    if(a == b)out("H");
    else out("D");
}

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

int gcd(int n, int m){
    if(n % m == 0) return m;
    return gcd(m, n % m);
}

vector<int> enum_prime(int n){   // containing n
    vector<int> res;
    if (n <= 1) return res;
    vector<bool> p(n + 1);
    fill(p.begin() + 2, p.end(), true);
    for(int i = 2; i <= n; i++){
        if(p[i]){
            res.push_back(i);
            for(int j = i * 2; j <= n; j += i) p[j] = false;
        }
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    int a[1000006];
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<int> prime = enum_prime(1000);
    int g = 0;
    for(int i = 0; i < n; i++) g = gcd(g, a[i]);
    if(g > 1){
        cout << "not coprime" << endl;
        return 0;
    }
    bool b[1000004]{0};
    for(int i = 0; i < n; i++){
        for(int p : prime){
            if(a[i] % p == 0){
                if(b[p]){
                    cout << "setwise coprime" << endl;
                    return 0;
                }
                while(a[i] % p == 0) a[i] /= p;
                b[p] = true;
            }
        }
        if(a[i] != 1 && b[a[i]]){
            cout << "setwise coprime" << endl;
            return 0;
        }
        b[a[i]] = true;
    }
    cout << "pairwise coprime" << endl;
}


Measured memory_bytes: 8352
import Data.List

main = do
  _ <- getLine
  ds <- sort . map read . words <$> getLine :: IO [Int]
  let ts = sort $ 0 : map (\(d,i) -> if d==0 then 0 else if even i then d else 24-d) (zip ds [0..])
  let ans = minimum (zipWith (-) (tail ts) ts)
  print ans

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  vector<llvec> a(2, llvec(N));
  rep(i, 2){
    rep(j, N)cin >> a[i][j];
  }
  vector<llvec> dp(2, llvec(N, 0));
  dp[0][0] = a[0][0];
  dp[1][0] = dp[0][0] + a[1][0];
  rep(i, N-1){
    dp[0][i+1]=dp[0][i] + a[0][i+1];
    dp[1][i+1]=max(dp[0][i+1], dp[1][i]) + a[1][i+1];
  }
  cout << dp[1][N-1]<<endl;
  return 0;
}


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

int main()
{
  string s, t;
  int i, ans=0;
  cin>>s>>t;
  for(i=0; i<s.size(); i++)
  {
    if(s[i]!=t[i]) ans++;
  }
  cout<<ans;
  return 0;
}


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

int main() {
	int dice[6];
	for (int i = 0;i != 6;++i) {
		cin >> dice[i];
	}
	string cmd;
	cin >> cmd;
	for (char c : cmd) {
		int temp = dice[0];
		switch (c) {
		case 'S':
			dice[0] = dice[4];
			dice[4] = dice[5];
			dice[5] = dice[1];
			dice[1] = temp;
			break;
		case 'N':
			dice[0] = dice[1];
			dice[1] = dice[5];
			dice[5] = dice[4];
			dice[4] = temp;
			break;
		case 'E':
			dice[0] = dice[3];
			dice[3] = dice[5];
			dice[5] = dice[2];
			dice[2] = temp;
			break;
		default: // 'W'
			dice[0] = dice[2];
			dice[2] = dice[5];
			dice[5] = dice[3];
			dice[3] = temp;
		}
	}
	cout << dice[0] << endl;
}

Measured memory_bytes: 3184
n = int(input())
h = list(map(int, input().split()))
ans = 0
num = 0
math = 0

for i in range(n):
    if h[i]<=num:
        math += 1
    else:
        ans = max(ans, math)
        math = 0
    ans = max(ans, math)
    num = h[i]

print(ans)

Measured memory_bytes: 14252
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
#define print(s) cout << (s) << endl
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    ll N, x;
    cin >> N >> x;
    ll a[N], b[N];
    rep(i, 0, N) {
        cin >> a[i];
        b[i] = a[i];
    }

    ll rsl = 1e18;
    rep(k, 0, N) {
        ll tmp = 0;
        rep(i, 0, N) {
            b[i] = min(b[i], a[(i - k + N) % N]);
            tmp += b[i];
        }
        tmp += k * x;
        rsl = min(rsl, tmp);
    }

    cout << rsl << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100


void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}



int main(){
  int n,i,j,k=0,kaunt=0,minj;//k=hozon
  int A[N];

  scanf("%d",&n);
  for(i =0;i<n;i++)scanf("%d",&A[i]);


  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<=n-1;j++){
      if(A[j]<A[minj])minj=j;
    }
    k=A[i];
    A[i]=A[minj];
    A[minj]=k;
    kaunt++;
    if(minj==i)kaunt--;
  }

  

  trace(A,n);
  printf("%d\n",kaunt);
  
  return 0;
}

Measured memory_bytes: 2744
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    string s;
    cin>>s;

    int ans=0;
    for(int i=0;i<s.size();i++){
        for(int j=i;j<s.size();j++){
            bool f=true;
            for(int k=i;k<=j;k++){
                if(s[k]!='A'&&s[k]!='C'&&s[k]!='G'&&s[k]!='T') f=false;
            }
            if(f) ans=max(ans,j-i+1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <stdio.h>

#define LENGTH 1200

main()
{
	int i;
	char c, s[LENGTH];
	for(i = 0; i < LENGTH; i++){
	    scanf("%c", &c);
		if ( c == '\n'){
			s[i] = '\0';
			break;
		}else{
			s[i] = c;
		}
	}
	
	for(i = 0; i < LENGTH; i++){
		if (s[i] == '\0'){
			printf("\n");
			break;
		}else if(s[i] >= 'A' && s[i] <= 'Z'){
			printf("%c", s[i]+0x20);
		}else if(s[i] >= 'a' && s[i] <= 'z'){
			printf("%c", s[i]-0x20);
		}else{
			printf("%c", s[i]);		
		}
	}
		
	return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>

int main()
{
int n,res=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int l,r;
scanf("%d%d",&l,&r);
res+=(r-l+1);
}
printf("%d",res);


return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int h1, h2, m1, m2;
    int k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int dif = h2 * 60 + m2 - h1 * 60 - m1 - k;
    cout << max(0, dif) << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int N;
    cin>>N;
    long long int A[N];
    for(int i=0;i<N;i++)
    {
        cin>>A[i];
    }
long long int sum=0,worst=0;
    for(int i=0;i<N;i++)
    {
        if(A[i]<worst)
        {
            sum += worst-A[i];
            A[i]=worst;
        }     
         worst=max(worst,A[i]);
    }
    cout<<sum;
}

Measured memory_bytes: 5152
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	long long n,max,min;
	cin >> n >> min >> max;
	if(n==1) {
		if(max == min) cout<<1;
		else cout<<0;
		return 0;
	}
	if(min > max) {
		cout<<0;
		return 0;
	}
	long long a,b;
	a = (n-1)*min+max;
	b = (n-1)*max+min;
	cout<<b-a+1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  
  int a,b;
    for(int i=0;i<999999;i++){
        cin >> a >> b;
        if(a==0 && b==0){
            break;
        }
        for(int l=0;l<b;l++){
            cout << "#";
        }
        cout << endl;
        for(int k=0;k<a-2;k++){
            cout << "#";
            for(int j=0;j<b-2;j++){
                cout <<".";
            }
            cout << "#" << endl;
        }
        for(int m=0;m<b;m++){
            cout <<"#";
        }
        cout << endl << endl;
}
}


Measured memory_bytes: 3092
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    long long ans=1;
    for(int i=1;i<N+1;i++){
        ans *= i;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

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

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcountll(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
	fast;
	int n,x,t;cin>>n>>x>>t;
	int val=n/x+bool(n%x);
	cout<<val*t<<endl;
}


Measured memory_bytes: 3636
#pragma optimize("", off)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(i) (int)(i.size())
#define setto(n) cout << fixed << setprecision(n)
#define fi first
#define se second
#define ld long double
#define inf LONG_MAX
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int mod = 1000000007;
using namespace std;

#ifndef ONLINE_JUDGE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
//Check N size twiceeeeeeeeeeeeeeeeee, and verify it

#define int ll
const int N = 1e5 + 10;

int n, m;
string s, t;

int lcm(int a, int b){
	return (a/__gcd(a, b))*b;
}

int32_t main(){_

	cin>>n>>m;
	cin>>s;
	cin>>t;

	int length = lcm(n, m);

	int low = length, high = 1e10, ans = -1;

	std::unordered_map<int, char> tmp;
	while(low <= high){
		int mid = (low + high) >> 1;

		int i = ((mid)/length)*length;
		tmp.clear();

		for (int j = 0; j < n; ++j)
		{
			tmp[(j*(i/n)) + 1] = s[j];
		}
		int f = 0;
		for (int j = 0; j < m; ++j)
		{
			int place = (j*(i/m)) + 1;
			if(tmp.count(place) == 0){
				tmp[place] = t[j];
			}
			else{
				if(tmp[place] != t[j]){
					f = 1;
					break;
				}
			}
		}
		if(f == 0){
			ans = i;
			high = mid - 1;
		}
		else{
			low = mid + 1;
		}
	}

	cout<<ans;
	return 0;
}

Measured memory_bytes: 7624
#include <iostream>

int main()
{
        int d, s;
        while(std::cin >> d)
        {
                s = 0;
                for(int i = 1; i*d < 600; ++i)
                        s += (i*d)*(i*d)*d;
                std::cout << s << std::endl;
        } 
        return 0;
}

Measured memory_bytes: 1160
import java.util.*

fun main(vararg args: String) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val monsters = IntArray(n + 1)
    repeat(n + 1) {
        monsters[it] = scanner.nextInt()
    }
    val bullets = IntArray(n)
    repeat(n) {
        bullets[it] = scanner.nextInt()
    }

    var kills = 0L
    for (i in 0 until n) {
        val m = monsters[i]
        val b = bullets[i]
        kills += Math.min(m, b)
        if (b > m) {
            val nextm = monsters[i + 1]
            val nb = b - m
            kills += Math.min(nextm, nb)
            monsters[i + 1] = Math.max(0, nextm - nb)
        }
    }
    println(kills)
}


Measured memory_bytes: 68556
//BISMILLAHIR RAHMANIR RAHIM
//SOTO MEAW
//SOTO SONDESH
#include<bits/stdc++.h>

#define ls ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define __ <<" "<<
#define case(z) "Case " << z++ << ": "
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define quit return 0

using namespace std;

void showmyDS(set<int> ds)
{
    set<int> ::iterator it;
    for (it=ds.begin();it!=ds.end();it++)
    {
        cout << *it << endl ;
    }
    cout << endl;
}
int main()
{
    ls
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //int t,l=1;cin>>t;while(t>0){
        int n,m,i;
        cin >> n >> m ;
        int p = min(n,m);
        int q = max(n,m);
        for(i=1;i<=q;i++)
            cout << p ;
    //t--;}

    quit;
}


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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for(int i=1;i<s.size()/2;i++){
        string sub1 = s.substr(0,s.size()/2-i);
        string sub2 = s.substr(s.size()/2-i,s.size()/2-i);
        if(sub1 == sub2){
            ans = sub1.size()*2;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  if (n % 2 == 0) {
    ll now = 0;
    for (int i = 0; i < n; i += 2) now += a[i];
    ll maximum = now;
    for (int i = n-2; i >= 0; i -= 2) {
      now += (a[i+1] - a[i]);
      if (now > maximum) maximum = now;
    }

    cout << maximum << endl;
  }
  else {
    vector<vector<ll> > dp(n+2, vector<ll>(3, (ll) -1e18));
    dp[0][0] = a[0];
    dp[1][1] = a[1];
    dp[2][2] = a[2];
    for (int i = 0; i < n; i++) {
      if (i+2 < n) dp[i+2][0] = max(dp[i+2][0], dp[i][0] + a[i+2]);
      if (i+2 < n) dp[i+2][1] = max(dp[i+2][1], dp[i][1] + a[i+2]);
      if (i+2 < n) dp[i+2][2] = max(dp[i+2][2], dp[i][2] + a[i+2]);
      if (i+3 < n) dp[i+3][1] = max(dp[i+3][1], dp[i][0] + a[i+3]);
      if (i+3 < n) dp[i+3][2] = max(dp[i+3][2], dp[i][1] + a[i+3]);
      if (i+4 < n) dp[i+4][2] = max(dp[i+4][2], dp[i][0] + a[i+4]);
    }

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

  return 0;
}


Measured memory_bytes: 15592
#include <iostream>

using namespace std;

int wa[1000553];
bool f[1001011];
int main() {
  int n, m;
  cin >> n >> m;
  int ac = 0, pen = 0;
  for (int i = 0; i < m; i++) {
    int id;
    cin >> id;
    string s;
    cin >> s;
    if (s == "AC" && !f[id]) {
      pen += wa[id];
      f[id] = true;
      ac++;
    } else {
      if (!f[id])
        wa[id]++;
    }
  }
  cout << ac << ' ' << pen << '\n';
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<ll>p(a),q(b);
    vector<ll>r(x+y+c);
    rep(0,i,a)cin>>p[i];
    rep(0,i,b)cin>>q[i];
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    rep(0,i,x)r[i]=p[i];
    rep(0,i,y)r[x+i]=q[i];
    rep(0,i,c)cin>>r[x+y+i];
    sort(r.rbegin(),r.rend());
    ll ans=0;
    rep(0,i,x+y){
        ans+=r[i];
        //cout<<r[i]<<endl;
    }
    cout<<ans;
}

Measured memory_bytes: 6940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
const int inf=1e9+1;
template <class T>
void print(T x){cout << x << '\n';}



void solve(long long N, long long Y){

  int i, j, k;
  for(i=0;i<=N;i++){
    for(j=0;j<=N-i;j++){
      k = N-i-j;
      if(Y==10000*i+5000*j+1000*k)goto ANS;
    }
  }

  print("-1 -1 -1");
  return;

 ANS:
  printf("%d %d %d\n", i, j, k);
  return;


}

int main(){
  long long N;
  scanf("%lld",&N);
  long long Y;
  scanf("%lld",&Y);
  solve(N, Y);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	double v[55];
	for (i = 0; i < n; i++)
		scanf("%lf", &v[i]);
	double x;
	for (i = 0; i < n - 1; i++)
	{
		if (v[i] > v[i + 1])
		{
			x = v[i];
			v[i] = v[i + 1];
			v[i + 1] = x;
			if (i > 0)
				i -= 2;
		}
	}
	double ans = v[0];
	for (i = 1; i < n; i++)
		ans = (ans + v[i]) / 2;
	printf("%.20lf\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>


int main(){
  char s[100001];
  int n,a,b,kokunai = 0,kaigai = 0;
  scanf("%d %d %d %s",&n,&a,&b,s);
  for(int i=0;i<n;i++){
    if(kokunai+kaigai<a+b&&s[i]!='c'){
      if(s[i]=='a'){
        printf("Yes\n");
        kokunai++;
      }else if(s[i]=='b'&&kaigai<b){
        printf("Yes\n");
        kaigai++;
      }else{
        printf("No\n");
      }
    }else{
      printf("No\n");
    }
  }
  return 0;
}


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

int main (void) {
  int N;
  cin >> N;
  
  for (int i = N; i < 1000000; i++) {
    bool isPrime = true;
    for (int j = 2; j*j <= i; j++) {
      //cout << i << ", " << j << ", " << i % j << endl;
      if(i % j == 0) {isPrime = false; break;}
    } 
    if (isPrime) {cout << i << endl; return 0;}
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a =  Integer.parseInt(scan.next());
		int b =  Integer.parseInt(scan.next());
		scan.close();

		if(a*b%2 == 1){
			System.out.print("Odd");
		}else {
			System.out.print("Even");
		}
		return ;
	}
}

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

int main(){
  string s;
  cin>>s;
  
  bool num[26];
  
  for(int i=0;i<26;i++){
    num[i]=false;
  }
  
  for(int i=0;s[i]!='\0';i++){
    num[s[i]-'a']=true;
  }
  
  for(int i=0;i<26;i++){
    if(!num[i]){
      cout<<char('a'+i)<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
  
}


  
  


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
int a[4];
int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		int x=read();
		if(x%4==0) a[1]++;
		else if(x%2==0) a[2]++;
		else a[3]++;
	}
	a[3]-=a[1];
	if(a[3]>1) printf("No\n");
	else if(a[3]==1 && a[2]>0) printf("No\n");
	else printf("Yes\n");
	return 0;
}

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

int main(void){
    int n;
    double t, a;
    cin >> n >> t >> a;
    double h, min = 1e9;
    int ans = 0;
    for(int i=0; i<n; i++){
        cin >> h;
        double sub = fabs(a - (t - h*0.006));
        if(sub < min){
            ans = i+1;
            min = sub;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() { 
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0] + a[1] == a[2]) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int h,w;
  cin >> h >> w;
  REP(i,w+2) cout << "#";
  cout << endl;
  REP(j,h){
    cout << "#";
    REP(i,w){
      char c; cin >> c; cout << c;
    }
    cout << "#" << endl;
  }
  REP(i,w+2) cout << "#";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1), b(n);
  rep(i, n + 1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll cnt = 0;
  for (int i = n; i > 0; i--) {
    if (a[i] >= b[i - 1]) {
      cnt += b[i - 1];
      b[i - 1] = 0;
    } else {
      cnt += a[i];
      b[i - 1] -= a[i];
      if (b[i - 1] <= a[i - 1]) {
        cnt += b[i - 1];
        a[i - 1] -= b[i - 1];
      } else {
        cnt += a[i - 1];
        a[i - 1] = 0;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4840
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.stream.IntStream;

public class Main {

	static void exec(MyScanner in, PrintWriter out) {
		int N = in.nextInt();
		int[] a = IntStream.range(0, N).map(i -> in.nextInt()).toArray();
		Map<Integer, Integer> m = new HashMap<>();
		for (int e : a) {
			m.merge(e, 1, Integer::sum);
			m.merge(e + 1, 1, Integer::sum);
			m.merge(e - 1, 1, Integer::sum);
		}
		List<Integer> values = new ArrayList<>(m.values());
		values.sort(Comparator.reverseOrder());
		out.println(values.get(0));
	}

	public static void main(String[] args) {
		PrintWriter w = new PrintWriter(System.out);
		exec(new MyScanner(System.in), w);
		w.flush();
	}

	static class MyScanner {
		static final int BUFFER_SIZE = 1024;
		private final InputStream in;
		private final byte[] buffer = new byte[BUFFER_SIZE];
		private int point;
		private int readLength;
		MyScanner(InputStream in) {
			this.in = in;
		}
		private int readByte() {
			if (point < readLength) {
				int result = buffer[point];
				point += 1;
				return result;
			}
			try {
				readLength = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (readLength == -1) {
				return -1;
			}
			point = 1;
			return buffer[0];
		}
		static boolean isPrintableCharExceptSpace(int c) {
			return 33 <= c && c <= 126;
		}
		String next() {
			StringBuilder b = new StringBuilder();
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			do {
				b.appendCodePoint(c);
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return b.toString();
		}
		long nextLong() {
			int c = readByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = readByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long result = 0L;
			do {
				if (!('0' <= c && c <= '9')) {
					throw new InputMismatchException();
				}
				result = result * 10L + (c - '0');
				c = readByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return minus ? -result : result;
		}
		int nextInt() {
			long n = nextLong();
			if (Integer.MIN_VALUE <= n && n <= Integer.MAX_VALUE) {
				return (int) n;
			}
			throw new InputMismatchException();
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

}


Measured memory_bytes: 36164
# 小さい方の木を大きい方にくっつける O(logN)
# 経路縮約(メモ化) ならしO(logN)
# 両方やると、ならしO(α(N)) α: カルマン関数

# 実装
# 子: 親のID, 根: -サイズ (非負: 子, 負: 根)
# atcoder ABC 158 解説に詳細
class UnionFind():

    def __init__(self, n=0):
        self.d = [-1 for _ in range(N)] # 経路縮約のためのメモ
    
    def find(self, x): # xが所属するグループの親を返す
        if self.d[x]<0:
            return x
        res = self.find(self.d[x])
        self.d[x] = res # 経路縮約の箇所
        return res
    
    def unite(self, x, y): # x, yが所属するグループを結合する, 結合に成功したらTrue, すでに結合していたらFalse
        # まずx, yをそれぞれの親にする
        x = self.find(x)
        y = self.find(y) 
        if x==y:
            return False
        # xの方が大きい木になるようにする (サイズは負であることに注意)
        if self.d[x] > self.d[y]: 
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
    def same(self, x, y): # 同じ集合に属しているかどうかを判定する
        return self.find(x) == self.find(y)
    
    def size(self, x): # xが所属しているグループのサイズを返す
        return -self.d[self.find(x)]

N, M, K=map(int, input().split())
AB=[list(map(int, input().split())) for _ in range(M)]
CD=[list(map(int, input().split())) for _ in range(K)]

uf = UnionFind(N)
deg = [0 for _ in range(N)] # 友達関係にある人の個数(グラフにおける各頂点の次数)を保持
to = [[] for _ in range(N)] # ブロック関係にある人に枝を張る

# 友達関係
for i in range(M):
    a, b = AB[i]
    a-=1
    b-=1
    deg[a]+=1
    deg[b]+=1
    uf.unite(a, b)
# ブロック関係
for i in range(K):
    c, d = CD[i]
    c-=1
    d-=1
    to[c].append(d)
    to[d].append(c)
# 答え
ans=[0 for _ in range(N)]
for i in range(N):
    # 各人(頂点)の所属するグループのサイズから、自分自身と、直接の友達関係を引く
    ans[i]=uf.size(i)-1-deg[i]
    # 各人のブロック関係にある人が同じグループに所属している場合は、答えを-する
    for u in to[i]:
        if uf.same(i, u):
            ans[i]-=1
print(*ans)

Measured memory_bytes: 125656
program	main
  implicit none
  integer k,s,i,j
  integer,allocatable::a(:,:)
  read*,k,s
  allocate(a(k+1,k+1))
  forall(i=0:k,j=0:k)a(i+1,j+1)=s-i-j


  print*,count(a.ge.0.and.a.le.k)
!  print*,a.ge.0                                                                

     !forall(j=0:k)a(i+1,j+1)=i+j                                               
end program main


Measured memory_bytes: 24704
import java.util.*;

 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for(int i = 0; i < N; i ++){
			A[i] = sc.nextLong();
		}
		long sum = 1L;
		long max = (long)Math.pow(10, 18);
		for(int i = 0; i < N; i ++){
			if(A[i] == 0){
				sum = 0;
				break;
			}else if(A[i] > max / sum){
				sum = -1;
			}else{
			sum *= A[i];
			}
		}
		System.out.println(sum);
		
		
	}
}

Measured memory_bytes: 62140
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    double x1, y1, x2, y2, ans, temp;
    
    cin >> x1 >> y1 >> x2 >> y2;
    temp = pow((x2 - x1), 2.0) + pow((y2 - y1), 2.0);
    
    cout.precision(10);

    ans = sqrt(temp);
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 3288
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: i128,
    }

    let mut sum_10: i128 = 1;
    let mut sum_8: i128 = 1;
    let mut sum_9: i128 = 1;
    for _ in 0..n {
        sum_10 *= 10;
        sum_10 %= 1000000007;
        sum_8 *= 8;
        sum_8 %= 1000000007;
        sum_9 *= 9;
        sum_9 %= 1000000007;
    }

    let mut ans: i128 = sum_10 - sum_9 - sum_9 + sum_8;
    ans %= 1000000007;
    ans = (ans + 1000000007) % 1000000007;
    println!("{}", ans);
}


Measured memory_bytes: 2188