akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

ll LCM (ll a, ll b) {
    ll g = GCD (a, b);
    return a * b / g;
}

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

    ll T;
    cin >> T;
    while (T--) {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;
        bool ans;
        if (A < B) ans = false;
        else if (B > D) ans = false;
        else if (C >= B) ans = true;
        else if (B - GCD(B, D) + A % GCD(B, D) > C) ans = false;
        else ans = true;

        if (ans) cout << "Yes\n";
        else cout << "No\n"; 
    }
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  ll N, A, B;
  while (cin >> N >> A >> B) {
    ll C = A + B;
    ll res = (N / C) * A + min(A, N % C);
    cout << res << endl;
  }
  return 0;
}


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

long long kai;
long long r[N];
long long xx[30];
int yy[30];

void kaiz(long long n){
	kai = 1;
	f(i, n){
		kai = kai*(i + 1);
		kai = kai%MOD;
	}
	int x = MOD - 2;
	f(i, 30){
		if (x % 2 == 1)yy[i] = 1;
		else yy[i] = 0;
		x = x / 2;
	}
	f(i, N){
		if (i > 0){
			xx[0] = i;
			f(j, 29){
				xx[j + 1] = xx[j] * xx[j];
				xx[j + 1] = xx[j + 1] % MOD;
			}
			r[i] = kai;
			f(j, 30){
				if (yy[j] == 1){
					r[i] = r[i] * xx[j];
					r[i] = r[i] % MOD;
				}
			}
		}
	}
	return;
}



int main(){
	long long a[N];
	long long q, n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%lld", &n);
	f(i, n){
		scanf("%lld", &a[i]);
	}
	kaiz(n);
	s = 0;
	f(i, n){
		s += r[i + 1];
		s = s%MOD;
	}
	f(i, n){
		x = s*a[i];
		x = x%MOD;
		ans += x;
		ans = ans%MOD;
		if(i < n - 1){
			s += r[i + 2];
			s = s%MOD;
			s -= r[n - i];
			s = (s + MOD) % MOD;
		}
	}
  ans=ans%MOD;
	printf("%lld\n", ans);



	return 0;
}

Measured memory_bytes: 2560
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!(int);

void scan(Args...)(ref Args args) {
    import std.conv : parse;
    string[] ss = readln.split;
    int i;
    foreach (ref arg ; args)
        arg = ss[i++].parse!int;
}

bool f(string s) {
    int[] cnt = new int[26];
    foreach(c;s) cnt[c - 'A']++;
    return cnt.count(2) == 2;
}

void main() {
    string s = readln.chomp;
    writeln(f(s) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    int n;
    scanf("%d",&n);
    int i,j;
    int max=0;
    for(i=0;i<=n;i++)
        for(j=2;j<9;j++){
            if(pow(i,j)<=n)
               if(pow(i,j)>max)
                   max=pow(i,j);
               }
    printf("%d",max);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string a, b, c; cin >> a >> b >> c;
	
	printf("%c%c%c\n", a.front() - ('a' - 'A'), b.front() - ('a' - 'A'), c.front() - ('a' - 'A'));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{char a[100001];
 int x=0,y=0,ans=0;
 cin>>a;
 for(int i=0;i<strlen(a);i++)
    if(x==y) {x++;if(a[i]=='p')ans--;}
    else {y++;if(a[i]=='g')ans++;}
 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>//atcoder.112.1
using namespace std;
int main(){
	string s;
	getline(cin,s);
	if(s=="A")cout<<"T";
	if(s=="T")cout<<"A";
	if(s=="C")cout<<"G";
	if(s=="G")cout<<"C";
	return 0;
}

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

int main() {
  int a,b;
  while (cin >> a >> b) {
    int sum = a+b;
    int count = 0;
    while (1) {
      ++count;
      sum /= 10;
      if (sum == 0) {
	cout << count << endl;
	break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3080
/*
 * 1_1.c
 *
 *  Created on: 2018/11/20
 *      Author: masato
 */
#include <stdio.h>

int main(void){
	int n,i,x,y,max;
	scanf("%d", &n);
	scanf("%d", &x);
	max = -2147483648;
	for(i=0;i<n-1;i++){
		scanf("%d", &y);
		if(max < y - x) {
			max = y - x;
		}
		if(x > y){
			x = y;
		}
	}
	printf("%d\n", max);
}




Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

int A,B,C; cin >> A >> B >> C ;

string ans="No";

if(A==B&&B!=C) ans="Yes";

else if(A==C&&B!=C) ans="Yes";

else if(B==C&&A!=C) ans="Yes";

cout << ans << endl; 

return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

const int maxn = 1e5 + 5;
int fac[maxn];

int fpow(int a, int b) {
  if(b == 0) return 1;
  int ret = fpow(a, b / 2);
  if(b % 2) return mul(ret, mul(ret, a));
  return mul(ret, ret);
}

int inv(int x) {
  return fpow(x, mod - 2);
}

int nck(int n, int k) {
  if(n < k) return 0;
  return mul(fac[n], inv(mul(fac[k], fac[n - k])));
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif


  fac[0] = 1;
  for(int i = 1; i < maxn; i++) {
    fac[i] = mul(i, fac[i - 1]);
  }
  int n;
  cin >> n;
  vi v(n + 1);
  vi cnt(n + 1);
  int l = 0;
  for(int i = 0; i < n + 1; i++) {
    cin >> v[i];
    if(cnt[v[i]] > 0) {
      l = i + 1 - cnt[v[i]];
      //cout << v[i] << " !" << endl;
    }
    cnt[v[i]] = i + 1;
  }
  //cout << l << " " << n - l << endl;
  for(int i = 0; i < n + 1; i++) {
    cout << sub(nck(n + 1, i + 1), nck(n - l, i)) << "\n";
  }
}

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

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

using namespace std;
using lint=long long;

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

	int odd=0;
	rep(i,n){
		int a; scanf("%d",&a);
		if(a%2) odd++;
	}

	lint ans;
	if(odd==0) ans=(p==1?0:1LL<<n);
	else       ans=1LL<<(n-1);
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
    using namespace std;
    //#define MOD 1000000007
    //#define MOD 998244353
    #define MOD 2019
    const double EPS = 1e-9;
    #define INF (1LL<<60)
    #define D double
    #define fs first
    #define sc second
    #define int long long
    #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
    #define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
    #define REP(i,n)  FOR(i,0,(n))
    #define RREP(i,n) RFOR(i,0,(n))
    #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
    #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
    #define range(i,a,b) ((a)<=(i) && (i)<(b))
    #define debug(x)  cout << #x << " = " << (x) << endl;
    #define SP << " " << 
    typedef pair<int,int> P;
    typedef vector<int> vec;
    typedef vector<vector<int>> mat;
     
    signed main(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout.precision(20);
     
      int h, w;
      cin >> h >> w;
      
      vector<string> a(h);
      REP(i, h){
        cin >> a[i];
      }

      vector<string> s(h + 2, "");
      REP(i, w + 2){
        s[0] += "#";
        s[h + 1] += "#";
      }

      FOR(i, 1, h + 1) {
        s[i] += "#";
        s[i] += a[i - 1];
        s[i] += "#";
      }

      REP(i, s.size()){
        cout << s[i] << endl;
      }

      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    const long long mod = 1000000007;
    long long n, k;
    cin >> n >> k;
    vector< int > a(n);
    for (long long i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
        for (long long j = i + 1; j < n; j++) {
            if (a[i] < a[j]) {
                ans += ((k * (k - 1)) / 2) % mod;
            } else if (a[i] > a[j]) {
                ans += ((k * (k + 1)) / 2) % mod;
            } else {
                ;
            }
        }
    }
    cout << ans % mod << endl;
    return 0;
}


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

int main(){
  long long a[2],b[2],i,j;
    
  for(i=0;i<2;i++)
    cin >> a[i];
  for(i=0;i<2;i++)
    cin >> b[i];
  
  vector<long long>v;
  for(i=0;i<2;i++)
    for(j=0;j<2;j++)
      v.push_back(a[i]*b[j]);
  
  sort(v.begin(),v.end());
  cout << v[v.size()-1] <<"\n";
  
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())


typedef struct{
  ll pos;
  ll depth;
} data;
//
// struct Node{
//
// }



int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// nの約数のうち2n未満のもの内、n/i-1の和を返す。
ll divisor(ll n){
  ll val = 0;

  for(ll i=1; i*i < n ; i++){
    // cout << i*i << endl;
    // if(i>2*n) break;
    if(n%i==0 && n > i*(i+1)){
      // cout << i << " " << (n/i-1) << endl;
      val += (n/i-1);
    }
  }

  return val;

}



int main() {

  ll N;
  cin >> N;
  ll ans=0;

  // ll n = 1;
  // while(N>2*n){
  //   if((N-n)%n==0){
  //     ans+=(N-n)/n;
  //   }
  //
  //   n++;
  // }

  ans = divisor(N);

  cout << ans << endl;
}

















//


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
///////////////////////////////////////////////


int main() {
    ll n, d, a; cin >> n >> d >> a;
    vector<pair<ll,ll>> xh(n);
    rep(i,n) {
        ll x, h; cin >> x >> h;
        xh[i] = make_pair(x,h);
    }
    sort(xh.begin(), xh.end());

    queue<pair<ll,ll>> que;
    ll sum = 0;
    ll ans = 0;

    rep(i,n) {
        ll x = xh[i].first, h = xh[i].second;
        while (!que.empty() && que.front().first < x) {
            sum += que.front().second;
            que.pop();
        }

        h += sum;
        if (h > 0) {
            sum -= (h+a-1)/a*a;
            que.emplace(x+d*2, (h+a-1)/a*a);
            // cout << que.back().first << ' ' << que.back().second << endl;
            ans += (h+a-1)/a;
        }
        // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto xy = readln.split.to!(long[]);
    auto X = xy[0];
    auto Y = xy[1];

    writeln(abs(X - Y) <= 1 ? "Brown" : "Alice");
}

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

typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007

void solve(){
    string s,t;
    cin>>s>>t;
    bool flag=1;
    if(t.length()-s.length()==1){
        rep(i,0,s.length()){
            if(s[i]!=t[i]){
                flag=0;
                break;
            }
        }
        if(flag)cout<<"Yes";
        else cout<<"No";
    }
    else cout<<"No";


return ;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
   int t=1;
   //cin>>t;
   rep(i,0,t){
     solve();
  }
return 0;
}

Measured memory_bytes: 3608
object Main extends App {
  import scala.io.StdIn.readLine
  import scala.math.sqrt
  import scala.math.floor

	val state = readLine.split(" ")
  	val num = (state(0)+ "" +state(1)).toInt
  	if(sqrt(num) == floor(sqrt(num)) ){println("Yes")}
  	else println("No")

}

Measured memory_bytes: 54740
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdint>
#include <utility>
#include <cstring>
using namespace std;

int main() {
    int n,k;
    string s;
    cin >> n >> k >> s;
    s[k-1] += 0x20;
    cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();

        System.out.println(H*W-h*W-w*(H-h));
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#define MAX 500000
#define END 1000000000

int L[MAX/2+2];
int R[MAX/2+2];
int cnt = 0;

void merge(int A[], int n, int left, int mid, int right);
void mergeSort(int A[], int n, int left, int right);

int main(){
  int A[MAX], n, i;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &A[i]);
    if (A[i] >= END ){
      return 1;
    }
  }
  mergeSort(A, n, 0, n);

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

  return 0;
}

void merge(int A[], int n, int left, int mid, int right){
  int i, j, k;

  int n1 = mid - left;
  int n2 = right - mid;
  
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = END;
  i = j = 0;
  for (k = left;k < right;k++){
    cnt++;
    if ( L[i] <= R[j] ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right ){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}



Measured memory_bytes: 5592
N , K = map(int,input().split())

M = N - K

fact = [1] * (N+1)

for i in range(1,N+1) :
    fact[i] = fact[i-1] * i

def p(n,r) :
    return fact[n] // fact[n-r]

def combi(n,r) :
    return p(n,r) // fact[r]

for i in range(1,K+1) :
    if i-1 > N-K :
        print(0)
        continue

    blue = max(combi(K-1,i-1),1)
    red = max(combi(M+1,i),1)

    print(red * blue % (10**9 + 7))



Measured memory_bytes: 5748
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int main() {
    int n;
    cin >> n;
    cout << n / 3 << endl;


    return 0;
}

Measured memory_bytes: 256
import sys

def main():
    N = int(sys.stdin.readline().rstrip())

    cnt = 0
    ans = "No"
    for i in range(N):
        a,b = map(int, sys.stdin.readline().rstrip().split())
        if a == b:
            cnt += 1
        else:
            cnt =0
        
        if cnt == 3:
            ans = "Yes"

    print(ans)


main()

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

int main(){

    int n, m;
    cin >> n >> m;

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

    pair<int, int> cb[m];
    for(int i=0; i<m; i++){
        cin >> cb[i].second >> cb[i].first;
    }

    sort(cb, cb+m, greater<pair<int,int>>());

    int k = 0;
    int count = 0;
    bool flagN = false;
    vector<int> cN;
    for(int i=0; i<m; i++){
        for(int j=0; j<cb[k].second; j++){
            cN.push_back(cb[k].first);
            count++;
            if(count == n){
                flagN = true;
                break;
            }
        }
        if(flagN == true){
            break;
        }
        k++;
    }

    sort(a, a+n);

    for(int i=0; i<cN.size(); i++){
        if(cN[i] > a[i]){
            a[i] = cN[i];
        }
    }

    // for(int i=0; i<cN.size(); i++){
    //     cout << cN[i] << endl;
    // }

    cout << accumulate(a, a+n, 0LL) << endl;

    return 0;
}

Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;



ll ans,mx,mn=1e8,sum;
int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	for(ll i=n-1; i>=0; i -= 2){
		cout<<a[i]<<" ";
		a[i] =-1;
	}
	for(ll i=0; i <n; i++){
		if(a[i]!=-1) cout<<a[i]<<" ";
	}
}


Measured memory_bytes: 3712
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n = ii()
    if n % 1000 == 0:
        print(0)
    else:
        print(1000 - (n % 1000))


main()


Measured memory_bytes: 9996
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

    private void solveA() {

        List<Integer> list = new ArrayList<>();
        try (Scanner sc = new Scanner(System.in);) {
            list.add(sc.nextInt());
            list.add(sc.nextInt());
            list.add(sc.nextInt());
        }
        Collections.sort(list);
        int min = list.get(0);
        int middle = list.get(1);
        int max = list.get(2);
        int count = 0;

        while (min != middle || middle != max) {
            for (int i = 0; i < 2; i++) {
                min++;
                if (min > middle) {
                    int tmp = middle;
                    middle = min;
                    min = tmp;
                }
                if (min > max) {
                    int tmp = max;
                    max = min;
                    min = tmp;
                }
            }
            count++;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<VL> VVL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

ll Max=-1000000000,Min=1e9+1;
       
int main(){
    int a,b,x=0,y=0,z=0,n,m,h,k,w,sum2=0,ans=0;
    string s,t;
    bool f=true;
    cin >> a >> b >> x >> y;
    int dx = x-a;
    int dy = y-b;
    m = y + dx;
    n = x - dy;
    k = b + dx;
    h = a - dy; 
    cout << n << " " << m << " " << h << " " << k << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll H, W;
    cin >> H >> W;
    vec A(H * W);
    map<char, ll> C;
    rep(i, H){
        string S;
        cin >> S;
        for(auto s : S) ++C[s];
    }
    bool flag = true;

    vec ct(4), tt(4);
    for(auto c : C){
        ll now = c.second % 4;
        ++ct[now];
        tt[now] += c.second;
    }


    if(H % 2 == 0 and W % 2 == 0){
        if(tt[0] != H * W){ flag = false;}
    }
    else if(H % 2 == 1 and W % 2 == 1){
        if(ct[1] + ct[3] != 1) flag = false;
        if(ct[2] * 2 > (H + W - 2)) flag = false;
    }else{
        if(W % 2 == 1) swap(H, W);
        if(ct[1] + ct[3] != 0) flag = false;
        if(ct[2] > W / 2) flag = false;
    }


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



    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>

using namespace std;
#define PI 3.14159265359

// 約数の数
int divisor_count(int n)
{
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(n % i == 0) ans++;
    }

    return ans;
}

// 公約数
void common_divisor(int a, int b, int *array)
{
    int k = 0;
    for(int i = min(a, b); i >= 1; i--){
        if(a % i == 0 && b % i == 0){
            array[k] = i;
            k++;
        }
    }
}

// 桁数
int digit_count(long long n)
{
    int ans = 0;
    while(1){
        n /= 10;
        ans++;
        if(n == 0) break;
    }

    return ans;
}



int main()
{
    int N, ans = 0;
    string S;
    cin >> N >> S;

    for(char i = '0'; i <= '9'; i++){
        for(char j = '0'; j <= '9'; j++){
            for(char k = '0'; k <= '9'; k++){
                bool flagi = false, flagj = false, flagk = false;
                for(int l = 0; l < N; l++){
                    if(!flagi){
                        if(S[l] == i) flagi = true;
                    }else if(!flagj){
                        if(S[l] == j) flagj = true;
                    }else{
                        if(S[l] == k) flagk = true;
                    }
                }
                if(flagk) ans++;
            }
        }
    }

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())
    a = sorted([int(ai) for ai in input().split()], reverse=True)

    sol = a[0]
    for i in range(n - 2):
        sol += a[(i // 2) + 1]

    print(sol)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 96152
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

  int P = (A1 - B1) * T1, Q = (A2 - B2) * T2;

  if (P > 0) {
    P *= -1;
    Q *= -1;
  }

  if (P + Q < 0) {
    cout << 0 << endl;
  } else if (P + Q == 0) {
    cout << "infinity" << endl;
  } else if (P + Q > 0) {
    int S = abs(P) / abs(P + Q), T = abs(P) % abs(P + Q);
    if (T != 0) {
      cout << 2 * S + 1 << endl;
    } else {
      cout << 2 * S << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cerr << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll f[10005],tmp[10005],prime[10005];
vector<ll> check;

int main()
{jizz
	ll n,x=0;
	cin >> n;
	for(int i=n;i>=0;--i)
		cin >> f[i],x=__gcd(x,abs(f[i]));
	for(int i=2;i<=n;++i)
		if(!prime[i])
			for(int j=(check.pb(i),i*i);j<=n;j+=i)
				prime[j]=1;
	for(ll i=2;i*i<=x;++i)
		if(x%i==0)
			for(check.pb(i);x%i==0;) 
				x/=i;
	if(x>1) check.pb(x);
	sort(ALL(check)),check.resize(unique(ALL(check))-check.begin());
	for(ll i:check)
	{
		for(int j=n;j>=0;--j) tmp[j]=f[j];
		for(int j=n;j>=i;--j)
			tmp[j-i+1]+=tmp[j];
		int flag=1;
		for(int j=min(i-1,n);j>=0;--j)
			if(tmp[j]%i!=0) flag=0;
		if(flag)
			cout << i << "\n";
	}
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

class UnionFind
{
public:
  int n;
  vector<int> par, rnk;

  UnionFind(int n_)
  {
    n = n_;
    par.resize(n);
    rnk.resize(n);
    for(int i = 0; i < n; i++){
      par[i] = i;
      rnk[i] = 0;
    }
  }

  int find(int x)
  {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y)
  {
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]){
      par[x] = y;
    }else{
      par[y] = x; 
      if(rnk[x] == rnk[y]) rnk[x]++;
    }
  }

  bool same(int x, int y)
  {
    return find(x) == find(y);
  }
};

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

  vi a(n);
  rep(i, 0, n) cin >> a[i];

  UnionFind uf(n);
  rep(i, 0, m){
    int x, y;
    cin >> x >> y;
    uf.unite(x, y);
  }

  set<int> st;
  rep(i, 0, n) st.insert(uf.find(i));

  int siz = sz(st);
  if(siz == 1){
    cout << 0 << endl;
  }else{
    int ans = 0;
    priority_queue<int, vi, greater<int>> que[n];
    rep(i, 0, n) que[uf.find(i)].push(a[i]);
    rep(i, 0, n){
      if(sz(que[i]) == 0) continue;
      ans += que[i].top();
      que[i].pop();
    }

    priority_queue<int, vi, greater<int>> que2;
    rep(i, 0, n){
      while(!que[i].empty()){
        que2.push(que[i].top());
        que[i].pop();
      }
    }

    if(sz(que2) < siz-2){
      cout << "Impossible" << endl;
    }else{
      rep(i, 0, siz-2){
        ans += que2.top();
        que2.pop();
      }
      
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int n, m;
	cin >> n >> m;
	string s,ans="Yes";
	cin >> s;
	rep(i, n) {
		if (s[i] == *"-") {
			ans = "No";
		}
	}
	if(s[n]!=*"-"){
		ans = "No";
	}
	rep(i, m) {
		if (s[n + 1 + i] == *"-") {
			ans = "No";
		}
	}
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn func(sum: i64, n: i64, x: i64) -> i64 {
    if n == 1 {
        //println!("{}", x);
        match x {
            4 | 5 => return 3,
            3 => return 2,
            2 => return 1,
            _ => return 0,
        }
    }
    if x == sum {
        return (sum + 1) / 2;
    }
    let sum = (sum - 1) / 2;
    let mut res = 0;
    if x > sum {
        res += func(sum - 1, n - 1, x - sum - 1);
        res += 1;
        res += sum / 2;
    } else {
        res += func(sum - 1, n - 1, x - 1);
    }
    //println!("{} {} {} {}", sum, n, x, res);
    res
}

fn main() {
    let n: i64 = read();
    let x: i64 = read();
    let sum = (1_i64 << n + 1) - 1;
    println!("{}", func(sum * 2 - 1, n, x));
}


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(void){
int N,a;
scanf("%d",&N);
if(N==100000)
 a=90909;
else if(N>=10000&&N<100000)
 a=(N-9999)+909;
else if(N>=1000&&N<10000)
 a=909;
else if(N>=100&&N<1000)
 a=(N-99)+9;
else if(N>=10&&N<100)
 a=9;
else
 a=N;

printf("%d",a);
return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int a[5001];
int b[5001];
int c,d,i,j,k,ans=0;
int main(){
	scanf("%d %d",&c,&d);
	for(i=0;i<c;i++){
		scanf("%d",&a[i]);
	}
	for(j=0;j<d;j++){
		scanf("%d",&b[j]);
	}
	for(int now=0;now<d;now++){
		int rr=now;
	for(i=0;i<c;i++){
		if(a[i]==b[rr]){
			rr++;
			if(rr==d){
				break;
			}
		}
	}
	ans=max(rr-now,ans);
	}
	printf("%d\n",ans);
	scanf("%d",&i);
	return 0;
}

Measured memory_bytes: 1064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
const ll inf=1e18;

int main() {
  ll h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(ll i=0;i<h;i++) {
    cin >> s[i];
  }
  set<ll> nh;
  for(ll i=0;i<h;i++) {
    bool flag=true;
    for(ll j=0;j<w;j++) {
      if(s[i][j]=='#') {
        flag=false;
        break;
      }
    }
    if(flag) {
      nh.insert(i);
    }
  }

  set<ll> nw;
  for(ll i=0;i<w;i++) {
    bool flag=true;
    for(ll j=0;j<h;j++) {
      if(s[j][i]=='#') {
        flag=false;
        break;
      }
    }
    if(flag) {
      nw.insert(i);
    }
  }

  for(ll i=0;i<h;i++) {
    if(nh.count(i)) continue;
    for(ll j=0;j<w;j++) {
      if(nw.count(j)) continue;
      cout << s[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const* argv[])
{
    int a, b, result = 0;
    std::cin >> a >> b;

    if(a > b)
    {
        result += a--;
    }
    else
    {
        result += b--;
    }

    if(a > b)
    {
        result += a--;
    }
    else
    {
        result += b--;
    }
    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,n,m,k,l,sum,flag=0,cnt=0,minn,maxn,ans,ans1,ans2,p=0,q=0,r;
    string s;
    char ch;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define RST(a) memset(a, 0, sizeof(a))
#define RSTV(a, v) memset(a, v, sizeof(a))
#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
const int INF = 0x3f3f3f3f;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(a * b, c);
}


Measured memory_bytes: 256
def examB(inf):
    N = I()
    A = LI()
    sumA = sum(A)
    cur = 0
    need = inf
    for i in range(N):
        need = min(need,abs(cur*2-sumA))
        cur += A[i]
    print(need)

def examC():
    return

def examD():
    return

def examE():
    return

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB(inf)

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

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

int main()
{
    vector<int> sum(100000, 0);
    for (int i = 1; i < 100000; i++)
    {
        sum[i] = sum[i - 1];
        if ((i + 1) / 2 > 1 && is_prime(i) && is_prime((i + 1) / 2))
            sum[i]++;
    }
    int q;
    cin >> q;
    rep (i, q)
    {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
def e_red_scarf():
    from functools import reduce
    N = int(input())
    A = [int(i) for i in input().split()]

    total = reduce(lambda x, y: x ^ y, A)
    ans = [a ^ total for a in A]
    return ' '.join(map(str, ans))

print(e_red_scarf())

Measured memory_bytes: 42028
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long A, B;
    cin >> A >> B;
    long long Asum, Bsum;
    if(A%2==1){
        Asum = (A / 2 + 1) % 2;
    }else{
        Asum = ((A + 1)/ 2 + 1) % 2;
        Asum = Asum ^ (A + 1);
    }
    if (B % 2 == 1)
    {
        Bsum = (B / 2 + 1) % 2;
    }
    else
    {
        Bsum = ((B + 1) / 2 + 1) % 2;
        Bsum = Bsum ^ (B + 1);
    }
    cout << ((Asum ^ Bsum) ^ A) << endl;
}

Measured memory_bytes: 384
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int N=sc.nextInt();
		int a[]=new int[N];
		int t=0;
		int t2=0;
		int t3=0;
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
			if(a[i]%4==0) {
				t++;
			}else if(a[i]%2==0) {
				t3++;
			}else {
				t2++;			}
		}
		if(t>=t2) {
			p("Yes");
		}else if(t3==0) {
			if(t+1>=t2) {
				p("Yes");
			}else p("No");
		}else p("No");
		
		
	}
	
		
	
	
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 49836
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias P = Tuple!(int, "to", int, "d");

void main()
{
    auto ve = readln.split.to!(int[]);
    auto V = ve[0];
    auto E = ve[1];

    P[][] ps;
    ps.length = V;
    foreach (_; 0..E) {
        auto std = readln.split.to!(int[]);
        auto s = std[0];
        auto t = std[1];
        auto d = std[2];
        ps[s] ~= P(t, d);
    }

    auto DP = new int[][][](V, V, 1<<V);
    foreach (ref dp; DP) foreach (ref dp2; dp) dp2[] = -1;

    int solve(int i, int f, uint s) {
        if (s == (1<<V)-1) {
            foreach (n; ps[i]) if (n.to == f) return n.d;
            return int.max/3;
        }
        if (DP[i][f][s] == -1) {
            auto r = int.max/2;
            foreach (n; ps[i]) if (!(s & (1<<n.to))) {
                r = min(r, solve(n.to, f, s | (1<<n.to)) + n.d);
            }
            DP[i][f][s] = r;
        }
        return DP[i][f][s];
    }
    auto r = int.max;
    foreach (i; 0..V) r = min(r, solve(i, i, 1<<i));
    if (r > 15000) r = -1;
    writeln(r);
}


Measured memory_bytes: 32012
n = int(input())
xyl = []
for _ in range(n):
    x,y = map(int,input().split())
    xyl.append((x,y))


import itertools
ans = 0
for xyl2 in itertools.permutations(xyl):
    x0 = xyl2[0][0]
    y0 = xyl2[0][1]
    tmp = 0
    for x, y in xyl2:
        tmp += ((x-x0) ** 2 + (y-y0) ** 2) ** (1/2)
        x0 = x
        y0 = y
    ans += tmp

print(ans / len(list(itertools.permutations(xyl))))


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

using namespace std;

int main()
{
   long long int n,k;
   cin>>n>>k;
   long long int r;
   if(n<k)
   {
       r=k-n;
   }
   else
   {
     r=n%k;
   }

   if(r==0)
   {
       cout<<r;

   }
   else
   {
       cout<<min((k-r),r);
   }
   return 0;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            int n = ReadAndParseInt();
            int[,] f = new int[n,10];
            int[,] p = new int[n,11];
            for(int i=0;i<n;++i)

            {
                var o = ReadAndParseIntArr();
                for(int j=0;j<o.Length;++j)
                {
                    f[i,j] = o[j];
                }
            }
            for(int i=0;i<n;++i)
            {
                var o = ReadAndParseIntArr();
                for(int j=0;j<o.Length;++j)
                {
                    p[i, j] = o[j];
                }
            }

            int maxProfit = int.MinValue;
            for(int i = 1;i<1024;++i)
            {
                maxProfit = Math.Max(maxProfit, CalcProfit(n, f, p, i));
            }
            Console.WriteLine(maxProfit);
        }
        private static int CalcProfit(int n, int[,] f, int[,] p, int joisino)
        {
            int profit = 0;
            for(int shop=0;shop<n;++shop)
            {
                int c = 0;
                for(int time=0;time<10;++time)
                {
                    if( f[shop, time] == 1 && (joisino & (1 << time)) != 0) { c++; }
                }
                profit += p[shop, c];
            }
            return profit;
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
import java.io.*;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws IOException {
		String input = (new BufferedReader(new InputStreamReader(System.in))).readLine();
		int[] highs = Arrays.stream(input.split(" ")).mapToInt(Integer::parseInt).toArray();
		int diff = highs[1] - highs[0];
		int higher = IntStream.rangeClosed(1, diff).sum();
		System.out.println(higher - highs[1]);
	}

}

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

int main(){
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  double ans;
  ans = double(W)*double(H)/2;
  cout << ans << endl;
  if(double(W)/2==x && double(H)/2==y) cout << 1 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char a[110];
	int b, flag=1;
	scanf("%d", &b);
	scanf("%s", a);
	
	if (b%2==1){
		printf("No\n");
	} else{
		for (int i=0 ; i<(b/2) ; i++){
			if (a[i]!=a[i+(b/2)]){
				flag=0;
				break;
			}
		}
		if(flag==0){
			printf("No\n");
		} else if (flag==1){
			printf("Yes\n");
		}
	}
	
}

Measured memory_bytes: 1612