akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll dddd[2][300],*dp1=dddd[0],*dp2=dddd[1],*temp;
ll c[20];
ll x[20010];
int main(){
	ll n,m;
	while(scanf("%lld%lld\n",&n,&m),n){
		rep(i,0,m)scanf("%lld",c+i);
		rep(i,0,n)scanf("%lld",x+i);
		rep(i,0,256)dp1[i]=INF;
		dp1[128]=0;
		rep(nnnn,0,n){
			rep(i,0,256)dp2[i]=INF;		
			//配るDP
			rep(i,0,256)rep(j,0,m){
				ll nxt=min(255,max(0,i+c[j]));
				dp2[nxt]=min(dp2[nxt],dp1[i]+(nxt-x[nnnn])*(nxt-x[nnnn]));
			}
			temp=dp1;dp1=dp2;dp2=temp;
		}
		ll ans=INF;
		rep(i,0,256)ans=min(ans,dp1[i]);
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll cnt[13];
ll used[24];

int main(void){
    int n,d;
    int ans=0,num=24;
    cin>>n;
    cnt[0]++;
    for(int i=0;i<n;i++){
        cin>>d;
        cnt[d]++;
    }
    for(int i=0;i<(1<<11);i++){
        num=24;
        for(int j=0;j<24;j++)used[j]=false;
        for(int j=0;j<13;j++){
            if(cnt[j]==0)continue;
            if(j==0 || j==12){
                used[j]=true;
                if(cnt[j]>=2)num=0;
            }
            else{
                if(cnt[j]>=3)num=0;
                else{
                    if(cnt[j]==2){
                        used[j]=true;
                        used[24-j]=true;
                    }
                    else{
                        used[i&(1<<(j-1))?j:24-j]=true;
                    }
                }
            }
        }
        for(int i=0;i<23;i++){
            for(int j=0;j<23;j++){
                if(i==j)continue;
                if(used[i]&used[j]){
                    int x=i-j;
                    if(x<0)x*=-1;
                    num=min(num,min(x,24-x));
                }
            }
        }
        ans=max(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner s = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        long k, n, a0, ai, aj;
        long dist = -1;
        k = s.nextLong();
        n = s.nextLong();
        a0 = s.nextLong();
        aj = s.nextLong();
        dist = Math.max(dist, aj-a0);

        ai = aj;

        for (long i = 2; i < n; i++) {
            aj = s.nextLong();
            dist = Math.max(dist, aj-ai);
            ai = aj;
        }
        dist = Math.max(dist, k - (aj-a0));

        out.println(k - dist);

        out.close();
    }

    static class FastScanner {
		
		BufferedReader br; StringTokenizer st;
		FastScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			st = new StringTokenizer("");
		}
		String next() {
			while(!st.hasMoreElements()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch(Exception e) {}
			}
			return st.nextToken();
		}
		
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() {return Long.parseLong(next()); }
		
	}
}

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

int arr[100010];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1;i <= n;++i)
        scanf("%d", &arr[i]);
    long long ans = 0;
    int price = 1;
    for(int i = 1;i <= n;++i)
    {
        if(arr[i] > price)
        {
            if(arr[i] != price)
            {
                ans += (arr[i] - 1) / price;
                arr[i] = 1;
            }
        }
        price = max(price, arr[i] + 1);
    }
    printf("%lld\n", ans);
    return 0;
}


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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

void solve(int N, int K, vector<int>& a) {
    vector<vector<ll>> dp(N+1, vector<ll>(K+1, 0));

    dp[0][0] = 1;

    REP(i, 1, N+1) {
        vector<ll> prevDpSum(K+1, 0);
        prevDpSum[0] = dp[i-1][0];
        REP(k, 1, K+1) {
            prevDpSum[k] = (prevDpSum[k-1] + dp[i-1][k]) % MOD;
        }

        REP(k, 0, K+1) {
            // If i th child receive j candies, it means k-j candies already used.
            // => dp[i][k] = dp[i-1][max(0,k-a[i-1])] + ... + dp[i-1][k]
//            REP(j, 0, min(a[i-1]+1, k+1)) {
//                dp[i][k] = (dp[i][k] + dp[i-1][k-j]) % MOD;
//            }
            dp[i][k] = prevDpSum[k];
            if (k>a[i-1]) dp[i][k] = (dp[i][k] - prevDpSum[k-a[i-1]-1] + MOD) % MOD;
        }
    }

	ll answer = dp[N][K];
	stringstream ss;
	ss << answer;
	cout << ss.str() << '\n';

    return;
}

signed main() {
    int N, K;
    cin >> N >> K;
    
    vector<int> A(N);
    REP(i,0,N) cin >> A[i];
    
    solve(N, K, A);
    
    return 0;
}



Measured memory_bytes: 80256
# -*- coding: utf-8 -*-

N, M = [int(n) for n in input().split()]
islands = {n:[] for n in range(1, N+1)}
result = "IMPOSSIBLE"

for m in range(M):
    a, b = [int(n) for n in input().split()]
    islands[a].append(b)
    islands[b].append(a)

ok_isl = set()
search_isl = [1]
next_isl = set()

loop = True
for x in range(2):
    for i in search_isl:
        if N in islands[i]:
            loop = False
            result = "POSSIBLE"            
        else:
            next_isl.update(islands[i])
    
    ok_isl = ok_isl.union(search_isl)
    
    search_isl = next_isl.difference(ok_isl)
    if len(search_isl) == 0:
        break

print(result)

Measured memory_bytes: 69984
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        k: usize
    }
    let d = 1000000007;
    let mut stairs: Vec<usize> = vec![1; n * m];
    for i in 1..n * m {
        stairs[i] = stairs[i - 1] * i % d;
    }
    let stairs_i: Vec<usize> = stairs.iter().map(|x| inv_m(*x, d)).collect();
    let mut ans = n * m % d * ((n - 1) % d * (n + 1) % d * m % d + (m - 1) % d * (m + 1) % d * n % d) % d;
    ans = ans * inv_m(6, d) % d * stairs[n * m - 2] % d * stairs_i[k - 2] % d * stairs_i[n * m - k] % d;
    println!("{}", ans);
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // code:
    
    int r,g,b,k;
    cin >> r >> g >> b >> k;
    
    // R G B
    // A B C
    // R<G<B
    
    bool ok=false;
    while(k--){
        if(g<=r) g*=2;
        else if(b<=g) b*=2;
        if(b>g && g>r) ok=true;
        
    }
    if(ok) cout << "Yes\n";
    else cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S;
	cin >> S;
	for (int i = 0; i < S.size() / 2; i++) {
		if (S[i] != S[S.size() - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < ((S.size() - 1) / 2) / 2; i++) {
		if (S[i] != S[(S.size() - 1) / 2 - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = ((S.size() + 3) / 2) - 1; i < S.size(); i++) {
		if (S[i] != S[S.size() - 1 - i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> xx(n);
  vector<int> yy(m);
  bool flag = true;
  for (int i = 0; i < n; i++) cin >> xx[i];
  for (int i = 0; i < m; i++) cin >> yy[i];
  sort(xx.begin(), xx.end());
  sort(yy.begin(), yy.end());
  if (xx[n - 1] >= yy[0] || yy[0] <= x || xx[n - 1] >= y) flag = false;
  if (flag) cout << "No War" << endl;
  else cout << "War" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int x,y,ama;
  scanf("%d %d",&x,&y);
  while((x%y)!=0)
    {
      ama=x%y;
      x=y;
      y=ama;
    }
  printf("%d\n",y);
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define MOD 1000000007

using namespace std;

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

int ar[11];

int main()
{
    int n,l;
    cin>>n>>l;
    vector<string> str;
    string t;
    for(int ctr1=0;ctr1<n;ctr1++)
        cin>>t,str.push_back(t);
    sort(str.begin(),str.end());
    for(int ctr1=0;ctr1<n;ctr1++)
        cout<<str[ctr1];
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())

arr = [0]*(k);

for i in range(1,n+1):

	arr[i%k] += 1;

#print(*arr)
counter = 0;

for i in range(k):

	if 2*i % k == 0:

		if i==0:
			counter += pow(arr[0],3);

		else:
			if i!=k-i:
				counter += pow(arr[i],3)
				counter += 3*( pow(arr[i],2) * arr[k-i] )
			else:
				counter += pow(arr[i],3)
	#print(counter,i)

print(counter)

Measured memory_bytes: 4596
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<char> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= sqrt(lim); i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    // int q; cin >> q;
    int q = buf.next();
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        cout << accs[r] - accs[l - 1] << '\n';
    }
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s[55];
    int n,k;
    cin>>n>>k;
    scanf("%s",s+1);
    s[k]+='a'-'A';
    for(int i=1;i<=n;i++){
        printf("%c",s[i]);
    }
    return 0;
}

Measured memory_bytes: 256
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

//int n,m,k,a[N],b[N];
signed main(){
    FastIO;
    int n;
    cin>>n;
    ll ans=1,f[n+5]{0};
    rep(i,1,n) f[i]=i;
    rep(i,2,sqrt(n)) if(f[i]==i){
        for(ll j=1ll*i*i;j<=n;j+=i) if(f[j]==j) f[j]=i;
    }
    rep(i,2,n){
        ll tp=i,tans=1;
        while(tp>1){
            int cnt=0,fac=f[tp];
            while(tp%fac==0) cnt++,tp/=fac;
            tans*=(cnt+1);
        }
        ans+=i*tans;
    }
    cout<<ans;

//    cin>>n>>m>>k;
//    rep(i,1,n) cin>>a[i];
//    rep(i,1,m) cin>>b[i];
//    reverse(a+1,a+n+1);
//    reverse(b+1,b+m+1);
//    int ans=0,curr=0,rem=k,l=n,r=m;
//    repb(i,n,1) if(rem>=a[i]){
//        rem-=a[i];
//        l=i;
//        curr++;
//    }
//    repb(i,m,1) if(rem>=b[i]){
//        rem-=b[i];
//        r=i-1;
//        curr++;
//    }
//    ans=curr;
//    rep(j,l,n){
//        rem+=a[j];
//        curr--;
//        while(r and rem>=b[r]){
//            rem-=b[r];
//            curr++;
//            r--;
//        }
//        ans=max(ans,curr);
//    }
//    cout<<ans;
    return 0;
}


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

using namespace std;

int main()
{
	int n,h,w;
	cin>>n>>h>>w;
	int cnt = 0;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(a>=h&&b>=w){
			cnt++;
		}
	}
	cout<<cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, int>;

ll solve() {
    ll N, a,b;
    cin >> N;
    vector<ll> A(N), B(N);
    vector<pii> v;
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i] >> B[i];
        v.push_back(pii(-A[i]-B[i], i));
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        int k = v[i].second;
        if ( i & 1 ) ans -= B[k];
        else ans += A[k];
    }

    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int r, g;
  cin >> r >> g;
  double ans = 2*g - r;
  cout << ans << endl;
  
  return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> v(N);
  for(int i = 0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  
  int min = v[K-1] - v[0];
  for(int i = 0; i<=N-K;i++){
    if((v[K - 1 + i] - v[i])<min){
      min = (v[K - 1 + i] - v[i]);
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <cmath>
#define PI 3.14159265359
using namespace std;

int main()
{
	int n;
	cin >> n;
	cout << n * 800 - n / 15 * 200 << endl;

	return 0;
}

Measured memory_bytes: 256
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n;
cin>>n;
vector<int> v(n+1);
FOR(i,1,n+1) cin>>v[i];
int cnt = 0;
FOR(i,1,n) {
    if(v[i] == i) {
        int temp = v[i+1];
        v[i+1] = i;
        v[i] = temp;
        cnt++;
    }
}
if(v[n] == n) cnt++;
cout<<cnt;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 1024
#%%
import itertools

#%%

N, A, B, C = map(int, input().split())
materials = [int(input()) for _ in range(N)]



iterobj = itertools.product(range(4),repeat=N)

ans = 10**8

for use in iterobj:

    if 1 in use and 2 in use and 3 in use:

        synth = [0,0,0,0]

        for m, u in  zip(materials, use):
            synth[u] += m

        mp = 10 * (use.count(1) + use.count(2) + use.count(3) - 3)

        mp += abs(A-synth[1]) + abs(B-synth[2]) + abs(C-synth[3])

        ans = min(ans, mp)

print(ans)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int x,a,b;
    cin>>x>>a>>b;
    x-=a;
    cout<<x%b<<endl;
    return 0;
}


Measured memory_bytes: 256
def chmax(a, b) a > b ? a : b end

n = gets.strip.to_i
a = gets.strip.split.map(&:to_i)

ls = Array.new(n + 1){0}
rs = Array.new(n + 1){0}

n.times do |i| 
  j = (n - 1) - i
  ls[i + 1] = ls[i].gcd(a[i])
  rs[j] = rs[j + 1].gcd(a[j])
end

ans = 0
n.times do |i|
  ans = chmax(ls[i].gcd(rs[i + 1]), ans)
end

puts ans


Measured memory_bytes: 11276
n = int(input())
a = [int(input()) for i in range(n)]
a_sorted = sorted(a)
a_max = a_sorted[-1]
a_sec = a_sorted[-2]
for i in range(n):
    if a_max == a[i]:
        print(a_sec)
    else:
        print(a_max)

Measured memory_bytes: 14112
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<pair<int, int>>;
using VTIII = vector<tuple<int, int, int>>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> inline bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int K;


signed main(){
    cin >> K;

    int s  = 0;
    repe(i, 1, K) repe(j, 1, K) repe(k, 1, K) s += gcd(i, gcd(j, k));

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
int main(void){
  int n,i,f[26];
  char s[1025],tmp[1025],ans[1025];
  scanf("%d",&n);
  while(n--){
    memset(f,0,sizeof(f));
    memset(ans,0,sizeof(ans));
    scanf("%s",s);
    ans[0]=s[0];
    f[s[0]-'a']=1;
    for(i=1;i<strlen(s);i++){
      if(s[i]=='>'){
	if(f[s[++i]-'a']==0){
	  f[s[i]-'a']=1;
	  sprintf(ans,"%s%c",ans,s[i]);
	}
      }
      else if(s[i]=='<'){
	i=i+2;
	if(f[s[i]-'a']==0){
	  f[s[i]-'a']=1;
	  sprintf(tmp,"%c%s",s[i],ans);
	  sprintf(ans,"%s",tmp);
	}
      }
    }
    printf("%s\n",ans);
  }
  return 0;
}

Measured memory_bytes: 628
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, b, f, r ,v int
	fmt.Scan(&n)
	building1 := make([][]int, 3)
	building2 := make([][]int, 3)
	building3 := make([][]int, 3)
	building4 := make([][]int, 3)
	for i := 0; i < 3; i++ {
		building1[i] = make([]int, 10)
		building2[i] = make([]int, 10)
		building3[i] = make([]int, 10)
		building4[i] = make([]int, 10)
	}
	// fmt.Println(building1)


	for i := 0; i < n; i++ {
		fmt.Scan(&b, &f, &r, &v)
		switch b {
		case 1: building1[f-1][r-1] += v
		case 2: building2[f-1][r-1] += v
		case 3: building3[f-1][r-1] += v
		case 4: building4[f-1][r-1] += v
		}
	}

	for i := 0; i < 3; i ++ {
		for j := 0; j < 10; j++ {
			fmt.Printf(" %d", building1[i][j])
		}
		fmt.Println()

	}
	fmt.Println(strings.Repeat("#", 20))
	for i := 0; i < 3; i ++ {
		for j := 0; j < 10; j++ {
			fmt.Printf(" %d", building2[i][j])
		}
		fmt.Println()

	}
	fmt.Println(strings.Repeat("#", 20))
	for i := 0; i < 3; i ++ {
		for j := 0; j < 10; j++ {
			fmt.Printf(" %d", building3[i][j])
		}
		fmt.Println()

	}
	fmt.Println(strings.Repeat("#", 20))
	for i := 0; i < 3; i ++ {
		for j := 0; j < 10; j++ {
			fmt.Printf(" %d", building4[i][j])
		}
		fmt.Println()

	}
}


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

void main()
{
    auto S = readln.chomp;
    auto K = readln.chomp.to!long;
    foreach (i; 0..K) {
        if (S[i] != '1' || i == K-1) {
            writeln(S[i]);
            return;
        }
    }
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=INF,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k,fu[ohara],sei[ohara];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>k;
      ll seii=0,fuu=0;
      rep(i,n){
        cin>>a;
        if(a<0)fu[fuu++]=a*-1;
        else sei[seii++]=a;
      }
      reverse(fu,fu+fuu);
      if(seii>=k)ans=min(ans,sei[k-1]);
      if(fuu>=k)ans=min(ans,fu[k-1]);
      rep(i,seii){
        pos=sei[i];
        cmp=k-i-1;
        if(cmp<0)continue;
        if(fuu<cmp)continue;
        pos*=2;
        pos+=fu[cmp-1];
        ans=min(ans,pos);
      }
       rep(i,fuu){
        pos=fu[i];
        cmp=k-i-1;
        if(cmp<0)continue;
        if(seii<cmp)continue;
        pos*=2;
        pos+=sei[cmp-1];
        ans=min(ans,pos);
      }
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

int main()
{
    int N;
    cin >> N;
    int A[N], B[N], C[N];
    REP(i, N) cin >> A[i] >> B[i] >> C[i];

    int ret[N][3];
    ret[0][0] = A[0];
    ret[0][1] = B[0];
    ret[0][2] = C[0];

    FOR(i, 1, N)
    {
        ret[i][0] = A[i] + max(ret[i-1][1], ret[i-1][2]);
        ret[i][1] = B[i] + max(ret[i-1][0], ret[i-1][2]);
        ret[i][2] = C[i] + max(ret[i-1][0], ret[i-1][1]);
    }

    cout << max(ret[N-1][0], max(ret[N-1][1], ret[N-1][2])) << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;
	cin>>N;
	vint A(N),B(N);
	rep(i,N)cin>>A[i]>>B[i];
	vint ord(N);iota(all(ord),0);
	sort(all(ord),[&](int i,int j){
		return B[i]<B[j];
	});

	int t=0;
	for(auto i:ord){
		t+=A[i];
		if(t>B[i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 4992
n, m = map(int, input().split())
if abs(n - m) > 1:
    print(0)
    import sys
    sys.exit()


nn = 1
for i in range(1, n + 1):
    nn *= i
    nn %= 10**9+7
mm = 1
for i in range(1, m + 1):
    mm *= i
    mm %= 10**9+7
if n==m:
    print(2*nn*mm%(10**9+7))
else:
    print(nn*mm%(10**9+7))


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    ll X;
    cin >> X;
    ll tmp = 100;
    ll num = 0;
    while (tmp < X) {
        tmp = tmp + tmp*0.01;
        num++;
    }
    cout << num << endl;
}


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

signed main() {
    int x,y,z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z << endl;
}
    



Measured memory_bytes: 764
def main():
    s = input()
    k = int(input())
    d = len(s)
    m = set()
    for i in range(d):
        for j in range(1, k + 1):
            m.add(s[i:i + j])

    m = list(m)
    m.sort()
    print(m[k - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 4464
N = int(input())

C = input().split()

B = C[:]
S = C[:]

# bubble sort
flag = 1
while(flag):
    flag = 0
    for x in range(1, N):
        if B[x][1:] < B[x-1][1:]:
            B[x], B[x-1] = B[x-1], B[x]
            flag = 1

# sectionSot
for x in range(0,N):
    minj = x
    for j in range(x,N):
        if S[j][1:] < S[minj][1:]:
            minj = j
    if minj != x:
        S[x], S[minj] = S[minj], S[x]



print(" ".join(b for b in B))
print("Stable")


if(B == S):
    print(" ".join(b for b in S))
    print("Stable")
else:
    print(" ".join(b for b in S))
    print("Not stable")

Measured memory_bytes: 7772
// luogu-judger-enable-o2
#include<iostream>
using namespace std;
int main()
{
	char k;
	cin>>k;
	if(k=='a'||k=='e'||k=='i'||k=='o'||k=='u')
	{
		cout<<"vowel"<<endl;
	}
	else 
	cout<<"consonant"<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793


int main(){
  int N; cin >> N;
  double p[N];
  rep(i, N) cin >> p[i];
  double dp[N+1][N+1];
  dp[0][0]=1.0; 
  rep(i, N){
    rep(j, N){
      dp[i+1][0] = (1-p[i])*dp[i][0];
      dp[i+1][j+1]=p[i]*(dp[i][j])+(1-p[i])*(dp[i][j+1]);
    }
  }
  double ans = 0;
  for(int i=(N+2)/2; i<=N; i++){
    ans += dp[N][i];
  }
  printf("%.12lf\n", ans);
}

Measured memory_bytes: 70528
#include <stdio.h>

int max(int x, int y)
{
	if(x>y) return x;
	else if(y>x) return y;
	else if(x==y) return x;
}

int min(int x, int y)
{
	if(x<y) return x;
	else if(y<x) return y;
	else if(x==y) return y;
}


int main(void)
{
	int i;
	int N;
	int a_max, a_min;

	scanf("%d", &N);

	int a[N];
	int b[N];

	for(i=0; i<N; i++) scanf("%d", &a[i]);
	for(i=0; i<N; i++) b[i] = a[i];

	for(i=0; i<N-1; i++)
	{
		a[i+1] = max(a[i], a[i+1]);
	}

	a_max = a[N-1];

	for(i=0; i<N; i++) a[i] = b[i];

	for(i=0; i<N-1; i++)
	{
		a[i+1] = min(a[i], a[i+1]);
	}

	a_min = a[N-1];

	printf("%d", a_max -a_min);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  const int MAXN = 10000010;
  vector<int> cnt(MAXN);
  for(int i = 1; i <= n; ++i) {
    for (int j = i; j <= n ; j += i) {
      cnt[j]++;
    }
  }
  for (ll i = 1; i <= n; ++i) {
    int value = cnt[i];
    ans += i * (ll)value;
  }
  cout << ans << endl;
}

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

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

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

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

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

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

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

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

signed solve()
{
	int n;
	cin >> n;
	deque<i64> dq;
	REP(i, n)
	{
		i64 a;
		cin >> a;

		if (n % 2 == 0)
		{
			if (i % 2 == 0)
				dq.push_back(a);
			else
				dq.push_front(a);
		}
		else
		{
			if (i % 2 == 0)
				dq.push_front(a);
			else
				dq.push_back(a);
		}
	}
	REPIT(dq)
	{
		if (it != dq.begin())
			cout << " ";
		cout << *it;
	}
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 3840
//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright Â© 2016 Abdellah. All rights reserved.
//


#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>




#define f first
#define s second
#define pb push_back
#define sz(a) (int)(a).size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 4000000000000000005ll
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef complex<long double> point;
//typedef pair<point, point> line;
typedef pair<double , point> Circle;






const int N = 10005;

int n,a[N],b[N];


int main(){
    
    scanf("%d",&n);
    lp(i,1,n) scanf("%d",&a[i]);
    lp(i,1,n) scanf("%d",&b[i]);
    ll sum1 = 0, sum2 = 0;
    lp(i,1,n) {
        if(a[i] > b[i]) sum1 += a[i]-b[i];
        else sum2 += ceil((b[i]-a[i])/2.0), sum1 += (a[i]-b[i])&1;
    }
    
    if(sum2 < sum1) printf("No\n");
    else printf("Yes\n");
    
    return 0;
}

/*
 
 5 4
 1 2
 2 3
 3 4
 3 5
 
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);


Measured memory_bytes: 384
from scipy.sparse.csgraph import floyd_warshall

N, M, L, *I = map(int, open(0).read().split())
ABC, ST = I[:3 * M], I[3 * M + 1:]

E = [[0] * N for _ in range(N)]
for a, b, c in zip(*[iter(ABC)] * 3):
    E[a - 1][b - 1] = E[b - 1][a - 1] = c

E = floyd_warshall(E)

for i in range(N):
    for j in range(N):
        E[i][j] = (E[i][j] <= L)

E = floyd_warshall(E)

INF = float("inf")

A = []
for s, t in zip(*[iter(ST)] * 2):
    a = E[s - 1][t - 1] - 1
    A.append("-1" if a == INF else str(int(a)))

print("\n".join(A))

Measured memory_bytes: 40776
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s[1003];
//vector<int>v;
//map<int,int>mp;
ll M=1e9+7;
ll a[1002][1002];
int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
    }
    l=0;
    for(i=0;i<n;i++)
    {
        if(s[i][0]=='#')
        {
            l=1;
        }
        if(l==0)
        {
            a[i][0]=1;
        }
        else
        {
            a[i][0]=0;
        }
    }
    l=0;
    for(i=0;i<m;i++)
    {
        if(s[0][i]=='#')
        {
            l=1;
        }
        if(l==0)
        {
            a[0][i]=1;
        }
        else
        {
            a[0][i]=0;
        }
    }
    for(i=1;i<n;i++)
    {
        for(j=1;j<m;j++)
        {
            if(s[i][j]=='#')
            {
                a[i][j]=0;
            }
            else
            {
                a[i][j]=(a[i-1][j]+a[i][j-1])%M;
            }
        }
    }
    cout<<a[n-1][m-1]<<"\n";
    return 0;
}



Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef unsigned long long word;
typedef pair<int, int> pi;
const int MAXN = 2005;

map<word, int> mp;

struct bs{
	word WRD[32];
	void set(int x, int v){
		if(v == 0) WRD[x >> 6] &= ((~0ull) ^ (1ull << (x & 63)));
		else WRD[x >> 6] |= (1ull << (x & 63));
	}
	void clear(){
		memset(WRD, 0, sizeof(WRD));
	}
	vector<int> toVect(){
		vector<int> ret;
		for(int i=0; i<32; i++){
			if(WRD[i]){
				auto ans = WRD[i];
				while(ans){
					int tmp = __builtin_ctzll(ans);
					ret.push_back(tmp + 64 * i);
					ans ^= (1ull << tmp);
				}
			}
		}
		return ret;
	}
	void doOr(bs &b){
		for(int i=0; i<32; i++) WRD[i] |= b.WRD[i];
	}
	bs operator&(bs y){
		bs z;
		for(int i=0; i<32; i++) z.WRD[i] = WRD[i] & y.WRD[i];
		return z;
	}
	bs operator|(bs y){
		bs z;
		for(int i=0; i<32; i++) z.WRD[i] = WRD[i] | y.WRD[i];
		return z;

	}
	bs negate(){
		bs ans;
		for(int i=0; i<32; i++) ans.WRD[i] = ~WRD[i];
		return ans;
	}
};

int n, m;
int par[MAXN];

vector<int> gph[MAXN];
bs Has[MAXN], msk[MAXN];
bs Good[2050000];

int idx[MAXN][MAXN];
vector<int> dfn;
queue<pi> que;

void dfs1(int x, int p){
	par[x] = p;
	dfn.push_back(x);
	for(auto &i : gph[x]){
		if(i != p){
			dfs1(i, x);
		}
	}
}

void dfs2(int x, int p, bs &ms){
	msk[x].doOr(ms);
	ms.set(x, 1);
	for(auto &i : gph[x]){
		if(i != p){
			dfs2(i, x, ms);
		}
	}
	ms.set(x, 0);
}

void Do(int x, int y){
	vector<int> tmp = (Has[x] & Has[y].negate() & Good[idx[x][y]]).toVect();
	for(auto &i : tmp){
		if(i == y) continue;
		Has[i].set(y, 1);
		Has[y].set(i, 1);
		que.emplace(y, i);
	}
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i=0; i<n-1; i++){
		int s = i + 1;
		int e = i + 2;
		scanf("%d %d",&s,&e);
		s--, e--;
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	int cnt = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			idx[i][j] = ++cnt;
			idx[j][i] = idx[i][j];
		}
	}
	for(int i=0; i<n; i++){
		bs aux;
		aux.clear();
		for(int j=0; j<n; j++) msk[j].clear();
		dfn.clear();
		dfs1(i, -1);
		reverse(dfn.begin(), dfn.end());
		for(auto &j : dfn){
			msk[j].set(j, 1);
			for(auto &k : gph[j]){
				if(par[j] == k) continue;
				msk[j].doOr(msk[k]);
			}
			if(par[j] == i) aux.doOr(msk[j]);
		}
		for(auto &j : gph[i]){
			bs nxt = aux & msk[j].negate();
			dfs2(j, i, nxt);
		}
		for(int j=0; j<n; j++){
			if(i < j) Good[idx[i][j]] = msk[j];
		}
	}
	for(int i=0; i<m; i++){
		int x, y;
	x = i + 1, y = i + 2;
		scanf("%d %d",&x,&y);
		x--, y--;
		Has[x].set(y, 1);
		Has[y].set(x, 1);
		que.emplace(x, y);
	}
	while(!que.empty()){
		auto x = que.front();
		que.pop();
		//printf("%d %d\n", x.first, x.second);
		Do(x.first, x.second);
		Do(x.second, x.first);
	}
	int dap = 0;
	for(int i=0; i<n; i++){
		for(int j=0; j<32; j++){
			for(int k=0; k<64; k++){
				if((Has[i].WRD[j] >> k) & 1) dap++;
			}
		}
	}
	cout << dap / 2 << endl;
}


Measured memory_bytes: 537144
#include<bits/stdc++.h>
#define EPS (1e-10)
#define equals(a,b)(fabs((a)-(b))<EPS)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

struct Point {
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) {}
	Point operator*(double a) { return Point(a*x, a*y); }
	Point operator-(Point p) { return Point(x - p.x, y - p.y); }
	Point operator+(Point p) { return Point(x + p.x, y + p.y); }
	double norm() { return x*x + y*y; }
};
typedef vector<Point>Polygon;
struct Segment {
	Point p1, p2;
};
double cross(Point a, Point b) {
	return a.x*b.y - a.y*b.x;
}
double dot(Point a, Point b) {
	return a.x*b.x + a.y*b.y;
}
bool isPrallel(Segment s1, Segment s2) {
	return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
bool isOrthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}
int contains(Polygon g, Point p) {
	int n = g.size();
	bool x = false;
	rep(i, n) {
		Point a = g[i] - p, b = g[(i + 1) % n] - p;
		if (abs(cross(a, b)) < EPS&&dot(a, b) < EPS)return 1;
		if (a.y > b.y)swap(a, b);
		if (a.y < EPS&&EPS<b.y&&cross(a, b)>EPS)x = !x;
	}
	return x ? 2 : 0;
}
int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0;
	Point b = p2 - p0;
	if (cross(a, b) > EPS)return 1;
	if (cross(a, b) < -EPS)return -1;
	if (dot(a, b) < -EPS)return 2;
	if (a.norm() < b.norm())return -2;
	return 0;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
	return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 &&
		ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0);
}
bool intersect(Segment s1, Segment s2) {
	return intersect(s1.p1, s1.p2, s2.p1, s2.p2);
}
Point project(Segment s, Point p) {
	Point base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base*r;
}
Point reflect(Segment s, Point p) {
	return p + (project(s, p) - p)*2.0;
}
bool isconvex(Polygon g) {
	int back = 3;
	rep(i, g.size()) {
		int d = ccw(g[(i + g.size() - 1) % g.size()], g[i], g[(i + 1) % g.size()]);
		if (back != 3 && d != back)
			return false;
		else back = d;
	}
	return true;
}
int main() {
	double xa, ya, xb, yb, xc, yc, xd, yd;
	while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd)) {
		Polygon g = { {xa,ya},{xb,yb},{xc,yc},{xd,yd} };
		puts(isconvex(g) ? "YES" : "NO");
	}
}

Measured memory_bytes: 3240