akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] A = new long[N];
    for (int i=0; i<N; i++) {
      A[i] = sc.nextLong();
    }
    long ans = 0;
    for (int i=0; i<N; i++) {
      while (A[i] % 2 == 0) {
        A[i] = A[i]/2;
        ans++;
      }
    }
    System.out.println(ans);
  }

  private static final long MOD = 998244353;
  private static long FACT[];
  private static long IFACT[];

  // Pre-calculate factorial and its mod_inverse for calculate nCr in O(1)
  private static void create_fact(int N) {
    FACT = new long[N+1];
    IFACT = new long[N+1];
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i=1; i<=N; i++) {
      FACT[i] = FACT[i-1] * i % MOD;
      IFACT[i] = mod_inverse(FACT[i]);
    }
  }

  // Return nCr
  private static long comb(int n, int r) {
    if (n < 0 || r < 0 || n < r) {
      return 0;
    }
    if (r > n/2) {
      r = n - r;
    }
    return FACT[n]*IFACT[n-r]%MOD*IFACT[r]%MOD;
  }

  // Fast mod inverse
  private static long mod_inverse(long a) {
    long b = MOD;
    long p = 1, q = 0;
    while (b > 0) {
      long c = a / b;
      long d;
      d = a;
      a = b;
      b = d % b;
      d = p;
      p = q;
      q = d - c * q;
    }
    return p < 0 ? p + MOD : p;
  }
}


Measured memory_bytes: 35920
#include <bits/stdc++.h>
using namespace std;
   
int main() {
int w,h,x,y,r;cin>>w>>h>>x>>y>>r;
if(x<r||y<r)cout<<"No"<<endl;
else if(x+r>w||y+r>h)cout<<"No"<<endl;
else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3112
from collections import defaultdict as d
s=d(int)
s[0]=0
n,w=map(int,input().split())
for i in range(n):
    q,v=map(int,input().split())
    c=s.copy()
    for p,r in c.items():
        if p+q<=w:
            s[p+q]=max(s[p+q],r+v)
print(max(s.values()))

Measured memory_bytes: 4092
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

struct graph_t {
	int n;           // |V|, index begins with 0
	int m;           // |E|
	vector<P> edges; // E
	vector<ll> cost; // cost or distance
	vector<ll> cap;  // capacity
};

class Warshallfloyd {
private:
	int n;
	bool negative_cycle;
	vvll wf_table;
public:
	Warshallfloyd(graph_t G) {
		n = G.n;
		wf_table = vvll(n, vll(n, INFLL));
		Loop(i, G.edges.size()) {
			wf_table[G.edges[i].first][G.edges[i].second] = G.cost[i];
		}
		Loop(i, n) wf_table[i][i] = 0;
		Loop(i, n) {
			Loop(j, n) {
				Loop(k, n) {
					if (wf_table[j][i] == INFLL || wf_table[i][k] == INFLL) continue;
					wf_table[j][k] = min(wf_table[j][k], wf_table[j][i] + wf_table[i][k]);
				}
			}
		}
		Loop(i, n) {
			if (wf_table[i][i] < 0) {
				negative_cycle = true;
				return;
			}
		}
		negative_cycle = false;
		return;
	}
	vvll get_wf_table() {
		return wf_table;
	}
	bool is_negative_cycle() {
		return negative_cycle;
	}
};

// prim sample
int main() {
	graph_t G;
	cin >> G.n >> G.m;
	Loop(i, G.m) {
		int s, t, c; cin >> s >> t >> c;
		G.edges.push_back({ s, t });
		G.cost.push_back(c);
	}
	Warshallfloyd warshallfloyd(G);
	if (warshallfloyd.is_negative_cycle()) cout << "NEGATIVE CYCLE" << endl;
	else {
		vvll result = warshallfloyd.get_wf_table();
		Loop(i, G.n) {
			if (result[i][0] == INFLL) cout << "INF";
			else cout << result[i][0];
			Loop1(j, G.n - 1) {
				if (result[i][j] == INFLL) cout << " INF";
				else cout << " " << result[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int H, W, D;
    cin >> H >> W >> D;

    vector<int> x(H*W+1);
    vector<int> y(H*W+1);
    for(int i = 0; i < H*W; i++){
        int a; cin >> a;
        x[a] = (i%W)+1;
        y[a] = (i/W)+1;
    }

    vector<int> dist(H*W+1, 0);
    for(int i = D+1; i < H*W+1; i++){
        dist[i] = dist[i-D] + abs(x[i-D] - x[i]) + abs(y[i-D] - y[i]);
    }

    int Q; cin >> Q;
    for(int i=0; i<Q; i++){
        int l, r; cin >> l >> r;
      	cout << dist[r]-dist[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
const long long mod = 998244353;
int rev[3000];
int npi1[3000];
int main() {
	int p;
	scanf("%d", &p);
	int *a = new int[p];
	int *b = new int[p];
	for (int i = 0; i < p; i++) {
		scanf("%d", a + i);
		b[i] = 0;
	}
	int n = 1;
	for (int i = 0; i < p; i++) {
		for (int j = 0; j < p; j++) {
			if ((i*j) % p == 1)rev[i] = j;
		}
		npi1[i] = n;
		n *= i + 1;
		n %= p;
	}
	for (int i = 0; i < p; i++) {
		if (a[i]) {
			int in = 1;
			for (int j = 0; j < p; j++) {
				b[p - 1 - j] += p - ((in * npi1[p - 1]) % p)* ((rev[npi1[j]] * rev[npi1[p - 1 - j]]) % p) % p;
				b[p - 1 - j] %= p;
				in = p - (in*i) % p;
			}
			b[0] += 1;
			b[0] %= p;
		}
	}
	for (int i = 0; i < p; i++) {
		printf("%d ", b[i]);
	}
	return 0;
}

Measured memory_bytes: 256
/** @Date    : 2017-05-13 20:40:15
  * @FileName: tmp.cpp
  * @Platform: Windows
  * @Author  : Lweleth (SoundEarlf@gmail.com)
  * @Link    : https://github.com/Lweleth
  * @Version : $Id$
  */
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std;

const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8;

struct yuu
{
	LL x, c;
}a[N];

int cmp(yuu a, yuu b)
{
	return a.x < b.x;
}
int main()
{
	LL n, m;
	while(cin >> n >> m)
	{
		for(int i = 0; i < n; i++)
		{
			scanf("%lld%lld", &a[i].x, &a[i].c);
		}
		sort(a, a + n, cmp);
		for(int i = 0; i < n; i++)
		{
			m -= a[i].c;
			if(m <= 0)
			{
				printf("%lld\n", a[i].x);
				break;
			}

		}
	}
    return 0;
}

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

int main() {
  long long A,B,C,K,ans;
    cin>>A>>B>>C>>K;
  if(A>K){
    cout<<K<<endl;
    return 0;
  }
  if(A+B>=K){
    cout<<A<<endl;
    return 0;
  }
  K-=(A+B);
    
  cout<<A-K<<endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

int main()
{
    int n;
    int a[212345];
    int p[50];
    unordered_map<int, int> mp;
    vector<int> v;

    cin >> n;
    REP(i, n)
    {
        cin >> a[i];
        if (!mp[a[i]])
            v.push_back(a[i]);
        mp[a[i]]++;
    }

    SORT(v);

   // bool used[212345] = {false};

    int res = 0;

    for (int i = v.size() - 1; i >= 0; i--)
    {
        if (!mp[v[i]])
            continue;

        int t = 1;
        while (t <= v[i])
            t *= 2;

        if (!mp[t - v[i]])
            continue;

        if (t - v[i] == v[i])
        {
            res += mp[v[i]] / 2;
        }
        else
        {
            int t_ = min(mp[t - v[i]], mp[v[i]]);
            res += t_;
            mp[t - v[i]] -= t_;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 18408
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
#define MAX 1024
#define INF LLONG_MAX/4
 
ll N, W, memo[MAX];
vector<ll> a;
 
ll solve(int n)
{
    if (n == N) return 0;
    ll &res = memo[n], sum = 0;
    if (res != INF) return res;
    for (int i = n; i < N; i++) {
        sum += a[i];
        res = min(res, solve(i+1) + abs(sum - W));
    }
    res = min(res, solve(N) + max(0LL, sum - W));
    return res;
}
 
int main()
{
    int T = 1;
    while (cin >> N >> W, N) {
        a.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> a[i];
        }
        fill(memo, memo + MAX, INF);
        cout << "Case " << T++ << ": " << solve(0) << endl;
    }    
    return 0;
}

Measured memory_bytes: 3088
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double x1 = scan.nextDouble();
		double y1 = scan.nextDouble();
		double x2 = scan.nextDouble();
		double y2 = scan.nextDouble();
		scan.close();
		double ans = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
		ans = Math.sqrt(ans);
		System.out.println(ans);
	}
}


Measured memory_bytes: 27912
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
ll INF = 1E+18;


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

    ll ans = INF;
    vector<ll> s(n);
    rep(i, n) {
        if (i==0) s[i] = a[i];
        else s[i] = s[i-1] + a[i];
    }

    rep(i, n) {
        if (i==0 || i==n-1 || i==n-2) continue;
        ll s1, s2, s3, s4;
        s2 = s[i];
        s4 = s[n-1];
        auto it1 = upper_bound(s.begin(), s.begin()+i, s[i]/2);
        s1 = *it1;
        if (it1!=s.begin()) {
            it1--;
            if (abs(s2-2*s1)>abs(s2-2*(*it1))) {
                s1 = *it1;
            }
        }
        auto it2 = upper_bound(s.begin()+i+1, s.end()-1, (s4+s[i])/2);
        s3 = *it2;
        if (it2!=s.begin()+i+1) {
            it2--;
            if (abs(s4-2*s3+s2)>abs(s4-(*it2)*2+s2)) {
                s3 = *it2;
            }
        }
        vector<ll> pqrs(4);
        pqrs[0] = s1; pqrs[1] = s2 - s1; pqrs[2] = s3 - s2; pqrs[3] = s4 - s3;
        sort(whole(pqrs));
        ll res = pqrs[3] - pqrs[0];
        
        chmin(ans, res);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp0=[[0]*(s+1) for _ in range(n+1)]
dp1=[[0]*(s+1) for _ in range(n+1)]
dp2=[[0]*(s+1) for _ in range(n+1)]
dp0[0][0]=1
for i in range(n):
	for j in range(s+1):
		dp0[i+1][j]+=dp0[i][j]
		dp1[i+1][j]+=dp0[i][j]+dp1[i][j]
		dp2[i+1][j]+=dp0[i][j]+dp1[i][j]+dp2[i][j]
		dp0[i+1][j]%=mod;dp1[i+1][j]%=mod;dp2[i+1][j]%=mod
		if j+a[i]<=s:
			dp1[i+1][j+a[i]]+=dp1[i][j]+dp0[i][j]
			dp2[i+1][j+a[i]]+=dp1[i][j]+dp0[i][j]
			dp1[i+1][j+a[i]]%=mod;dp2[i+1][j+a[i]]%=mod
print(dp2[n][s])


Measured memory_bytes: 249096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define n 3005
ll mod=1e9+7;
ll N;
ll a[n];
ll dp[n][n];
ll DP(ll i,ll j)
{
	if (j<i)
		return 0;
	if (dp[i][j]!=-1)
		return dp[i][j];
	bool flg=(N-(j-i+1))%2;
	if (flg)
	{
		dp[i][j]= min(DP(i+1,j)-a[i],DP(i,j-1)-a[j]);
	}
	else
	{
		dp[i][j]=max(DP(i+1,j)+a[i],DP(i,j-1)+a[j]);
	}
	return dp[i][j];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>N;
	for(ll i=0;i<N;i++)
		cin>>a[i];
	memset(dp,-1,sizeof(dp));
	cout<<DP(0,N-1);
}

Measured memory_bytes: 70912
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, a + b - n) << endl;
	return 0;
}

Measured memory_bytes: 256
let split str =
  let rec split_inner ct b=
    if String.length str = ct then [b]
    else
      match str.[ct] with
        ' ' -> b::split_inner (ct+1) ""
      | c -> split_inner (ct+1) (b^(Char.escaped c))
  in split_inner 0 "";;

let () =
  let _ = read_line ()
  and s = read_line () in
  let l = split s in
  let result =
    match l with
      h::t -> List.fold_left (fun x y -> y^" "^x ) h t
    | _ -> ""
  in print_endline result;;

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

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(int.Parse).ToList();
            var n = nk[0];
            var k = nk[1];

            var l = Console.ReadLine().Split().Select(int.Parse).ToList();
            l.Sort();
            l.Reverse();

            var ans = 0;

            for(int i = 0; i < k; i++)
            {
                ans += l[i];
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28284
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
struct Fact{
	vector<long> f;
	vector<long> rf;
	long pow(long N,long K){
		if(K == 0){
			return 1;
		}
		else if(K % 2 == 0){
			long t = pow(N,K/2);
			return t*t%mod;
		}
		else{
			return N*pow(N,K-1)%mod;
		}
	}
	Fact(int N):f(N+1),rf(N+1){
		for(int i=0;i<N+1;i++){
			if(i == 0){
				f[i] = 1;
			}
			else{
				f[i] = (f[i-1]*i)%mod;
			}
		}
		for(int i=N;i>=0;i--){
			if(i == N){
				rf[i] = pow(f[N],mod-2);
			}
			else{
				rf[i] = rf[i+1]*(i+1)%mod;
			}
		}
	}
	long GetFact(int N){
		return f[N];
	}
	long GetPerm(int N,int R){
		return f[N] * rf[N-R] % mod;
	}
	long GetConv(int N,int R){
		return ((f[N]*rf[R])%mod*rf[N-R])%mod;
	}
	long GetRev(int N){
		if(N == 0){
			return 1;
		}
		else{
			return rf[N] * f[N-1] % mod;
		}
	}
};
long DP[100000];
vector<int> G[100000];
void Calc(){
	int N = rei();
	int K = rei();
	if(K == 1){
		if(N == 1){
			cout << 1 << endl;
		}
		else{
			cout << 0 << endl;
		}
		return;
	}
	if(K == 2){
		if(N <= 2){
			cout << 2 << endl;
		}
		else{
			cout << 0 << endl;
		}
		return;
	}
	for(int i=0;i<N-1;i++){
		int f = rei()-1;
		int t = rei()-1;
		G[f].push_back(t);
		G[t].push_back(f);
	}
	Fact F(K+N+10);
	stack<pair<int,int>> sp;
	sp.push({0,-1});
	while(!sp.empty()){
		int v = sp.top().first;
		int f = sp.top().second;
		sp.pop();
		if(v >= N){
			v -= N;
			int R = v == 0 ? K-1 : K-2; 
			int c = v == 0 ? G[v].size() : G[v].size()-1; 
			long d = R < c ? 0 : F.GetPerm(R,c);
			for(int i=0;i<G[v].size();i++){
				int t = G[v][i];
				if(t != f){
					d *= DP[t];
					d %= mod;
				}
			}
			DP[v] = d;
		}
		else{
			sp.push({v+N,f});
			for(int i=0;i<G[v].size();i++){
				int t = G[v][i];
				if(t != f){
					sp.push({t,v});
				}
			}
		}
	}
	cout << DP[0]*K%mod << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 10872
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for (i=a; i<=b; i++)
#define ll long long
using namespace std;

const int N=200005;
int n, i, j, k;
ll ans, b[N];

ll min(ll a,ll b) { return a<b?a:b; }
ll max(ll a,ll b) { return a>b?a:b; }

int work(int l,int r)
{
	int k=l, l0=l-1; ll t=b[r]-b[l0]; 
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if ((b[mid]-b[l0])*2<=t) k=mid, l=mid+1; else r=mid-1;
	}
	return k;
}
void get(int i,int j,int k)
{
	//printf("%d %d %d\n",i,j,k);
	ll p=b[i], q=b[j]-b[i], r=b[k]-b[j], s=b[n]-b[k];
	ans=min(ans,max(p,max(q,max(r,s)))-min(p,min(q,min(r,s))));
}

int main()
{
	//freopen("d.in","r",stdin); freopen("d.out","w",stdout);
	
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&k), b[i]=b[i-1]+k;
	j=n, ans=b[n];
	fo(i,2,n-2)
	{
		j=work(1,i), k=work(i+1,n);
		get(j,i,k), get(j+1,i,k), get(j,i,k+1), get(j+1,i,k+1);
		get(j-1,i,k), get(j,i,k-1),get(j-1,i,k-1);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    char S[3], T[3];
    for(int i=0;i<3;i++){
        cin >> S[i];
    }
    for(int i=0;i<3;i++){
        cin >> T[i];
    }
    
    int count = 0;
    for(int i=0;i<3;i++){
        if(S[i] == T[i]) count++;
    }
    cout << count << "\n";
        
}


Measured memory_bytes: 256
import math

N=int(input())
arr=[]
for i in range(math.ceil(math.sqrt(N))):
    #print(i)
    if N%(i+1)==0:
        #print(i+1)
        arr.append(max(math.log10(i+1),math.log10(N//(i+1))))
        #print(arr)
print(math.floor(min(arr))+1)

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

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

    ll a, b;
    cin >> a >> b;

    ll k = (a + b) / 2;

    if (abs(b - k) == abs(a - k))
        cout << k << endl;
    else
        cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#define INF 0x3f3f3f3f
#define NO 30005
#define MO 100005
typedef long long ll;
using namespace std;
inline ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

int n, ans, a[NO], b[NO];
//variable

void init()
{
	n = read();
	for (int i = 1; i <= n; i++)
		a[i] = read();
	for (int i = 1; i <= n; i++)
		b[i] = read();
}
//functions

int main()
{
	init();
	while (n--)
	{
		int x = a[n + 1], y = b[n + 1];
		if (x > y)
			ans += x - y;
	}
	cout << ans << endl;
	return 0;
}
//main

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    ll k = 1;
    int ans = 0;
    rep(i, 30) {
        int cnt = 0;
        vector<int> c(N);
        vector<int> d(N);
        rep(j, N) c[j] = a[j] % (k * 2);
        rep(j, N) d[j] = b[j] % (k * 2);
        sort(c.begin(), c.end());
        sort(d.begin(), d.end());
        vector<int>::iterator itr1, itr2, itr3, itr4;
        rep(j, N) {
            itr1 = lower_bound(d.begin(), d.end(), k-c[j]);
            itr2 = lower_bound(d.begin(), d.end(), (k*2)-c[j]);
            itr3 = lower_bound(d.begin(), d.end(), (k*3)-c[j]);
            itr4 = lower_bound(d.begin(), d.end(), (k*4)-c[j]);
            // dump(*itr1); dump(*itr2); dump(*itr3); cout << endl;
            cnt += (itr2 - itr1) + (itr4 - itr3);
        }
        //dump(cnt);
        ans += (cnt&1) << i;
        //dump(cnt);
        // dump((itr2 - itr1)); dump((d.end() - itr3));
        k *= 2;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3456
def dfs(i,sum1):
    if i == len(s):
        return sum(list(map(int,sum1.split("+"))))
    return dfs(i+1,sum1 + "+" + s[i])+dfs(i+1,sum1 + s[i])
s = input()#一以上9以下
print(dfs(1,s[0]))

Measured memory_bytes: 9096
#include <iostream>

using namespace std;

int main() {
    long long n;
    long long ans = 1e12;

    cin >> n;

    for(long long i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ans = min(ans, (i - 1) + (n / i - 1));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn extended_euclidean(u: i64, v: i64) -> i64 {
    let mut r0 = u;
    let mut r1 = v;
    let mut s0 = 1;
    let mut s1 = 0;
    let mut t0 = 0;
    let mut t1 = 1;
    while r1 != 0 {
        let q = r0 / r1;
        let r = r0 - q * r1;
        let s = s0 - q * s1;
        let t = t0 - q * t1;
        r0 = r1;
        s0 = s1;
        t0 = t1;
        r1 = r;
        s1 = s;
        t1 = t;
    }
    if t0 < 0 {
        t0 + u
    } else {
        t0
    }
}

// nCc mod m を計算します。
fn combination(mut n: i64, c: i64, m: i64) -> i64 {
    let mut upe = 1;
    let mut dow = 1;
    for i in 1..c + 1 {
        upe = upe * n % m;
        dow = dow * i % m;

        n -= 1;
    }
    upe * extended_euclidean(m, dow) % m
}
fn pow_mod(mut a: i64, mut n: i64, m: i64) -> i64 {
    let mut res: i64 = 1;
    while n > 0 {
        if n & 1 == 1 {
            res = res * a % m;
        }
        a = a * a % m;
        n >>= 1;
    }
    res
}

fn main() {
    input!{
        n: i64,
        a: i64,
        b: i64,
    }
    const M:i64 = 1_000_000_007;
    let ans = ((((pow_mod(2, n, M) - 1) % M) + M - combination(n, a, M)) %M + M - combination(n,b,M)) %M;
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d\n", &W,&H,&x,&y,&r);
  if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H){
    printf("Yes\n");
  }else {
    printf("No\n");
  }
  return 0;
}

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

int cal=0;

int counter(int x){

    int result;
    if(x==0){
        result = cal;
        cal=0;
        return result;
    }
    else{
        if(x&1) cal++;
        counter(x>>1);
    }

    //if(x==0) return 0;
    //return counter(x>>1)+(x&1);

}

int main(){
    int n;
    cin>>n;
    int a[n];
    int x[n][n],y[n][n];

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

    int ans=0;

    for(int bits=1;bits<(1<<n);bits++){
        bool ok=true;
        for(int i=0;i<n;i++){
            if(!(bits&(1<<i))) continue;
            for(int j=0;j<a[i];j++){
                if(((bits>>(x[i][j]-1))&1)^y[i][j]) ok=false;
            }
        }
        if(ok) ans=max(ans,counter(bits));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    T = list(map(int,input().split()))
    if T[0]==0 and T[1]==0:
        break

    for i in range(T[0]):
        for j in range(T[1]):
            if 0 < i and i < T[0]-1 and 0 < j and j < T[1]-1:
                print(".",end="")
            else:
                print("#",end="")
        print()

    print()



Measured memory_bytes: 7000
N, K = map(int, input().split())
S = input()
p = 1
l = 0
a = []
for i in S:
    if int(i) != p:
        a.append(l)
        p = 1 - p
        l = 1
    else:
        l += 1
a.append(l)
a.append(0)
s = sum(a[:2 * K + 1])
ans = s
for i in range(0, len(a) - 2 * K - 1, 2):
    if i + 2 * K + 3 > len(a):
        break
    s = s - a[i] - a[i + 1] + a[i + 2 * K + 1] + a[i + 2 * K + 2]
    ans = max(ans, s)
print(ans)

Measured memory_bytes: 44780
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::cmp;
use std::num::Wrapping; // overflowを回避
use std::f64::consts;


fn main() {
    let s: String = read();
    let b = Bit::new(s);
    b.exec();
}


// Bit全探索
struct Bit {
    num: String,
}

impl Bit {
    fn new(num: String) -> Bit {
        Bit {
            num: num,
        }
    }

    fn exec(&self) {
        let vec: Vec<char> = self.num.chars().collect();
        let intNum = self.num.parse::<i64>().unwrap();
        let mut sum: i64 = 0;


        for bit in 0..(1 << (vec.len()-1)) {
            let mut str: String = String::from("");

            for i in 0..vec.len() {
                if (1&bit>>i) == 1 {
                    str = format!("{}{}+", str, vec[i as usize]);
                } else {
                    str = format!("{}{}", str, vec[i as usize]);
                }
            }

            let mut each_sum = 0;
            for a in str.split("+") {
                each_sum += a.parse::<i64>().unwrap();
            }

            sum += each_sum;
        }

        println!("{}", sum);
    }
}

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


Measured memory_bytes: 4352
N = int(input())
if N < 10 :
  print(N)
else :
  L = list(map(int, list(str(N))))
  if (L.count(9) == len(L)) or (L[0] != 9 and L.count(9) == len(L) -1) :
    print(sum(L))
  else :
    print(9 * (len(L) - 1) + int(L[0]) - 1)

Measured memory_bytes: 3060
import collections

N=int(input())
list = list(map(int, input().split()))
c = collections.Counter(list)
m=10**18

if(c[0]!=0):
  print(0)
else:
  i=0
  res=1
  while(i<N):
    res=res*list[i]
    if(m<res):
      res=-1
      break
    i+=1
  print(res)

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

int main() {
  int count=0,ans=0;
  string S,D; cin >> S;
  for(int i=0; i<S.size(); i++) {
    if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T') count++;
    else {
      ans = max(ans,count);
      count=0;
    }
  }
  cout << max(ans,count) << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 2000009
#define MOD 1000000007
#define endl '\n'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    map<string,ll>f;
    ll t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        f[s]++;
    }
    cout<<"AC x "<<f["AC"]<<endl;
    cout<<"WA x "<<f["WA"]<<endl;
    cout<<"TLE x "<<f["TLE"]<<endl;
    cout<<"RE x "<<f["RE"]<<endl;
    return 0;
}

Measured memory_bytes: 3664
from itertools import izip


def sol(n, w, wis, vis):
    rv = 0
    w1 = wis[0]
    coll = [[] for _ in xrange(n)]
    for wi, vi in izip(wis, vis):
        coll[wi - w1].append(vi)
    coll = map(lambda x: sorted(x, reverse=True), coll)
    lis = map(len, coll)
    for k1 in xrange(min(lis[0] + 1, n + 1)):
        for k2 in xrange(min(lis[1] + 1, n + 1 - k1)):
            for k3 in xrange(min(lis[2] + 1, n + 1 - k1 - k2)):
                for k4 in xrange(min(lis[3] + 1, n + 1 - k1 - k2 - k3)):
                    kis = [k1, k2, k3, k4]
                    if sum([(w1 + i) * kis[i] for i in xrange(4)]) > w:
                        continue
                    rv = max(rv, sum([sum(coll[i][:kis[i]]) for i in xrange(4)]))

    return rv


if __name__ == "__main__":
    n, w = map(int, raw_input().strip().split())
    wis, vis = [], []
    for _ in xrange(n):
        wi, vi = map(int, raw_input().strip().split())
        wis.append(wi)
        vis.append(vi)
    print(sol(n, w, wis, vis))



Measured memory_bytes: 2696
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
    dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, k)+1))
print(dp[-1])


Measured memory_bytes: 53344
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
from _collections import defaultdict
from functools import lru_cache

class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def map_int():
        return [int(x) for x in Scanner.string().split()]
    def string_list(n):
        return [input() for i in range(n)]
    def int_list_list(n):
        return [Scanner.mapInt() for i in range(n)]
    def int_cols_list(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    N = Scanner.int()
    A = Scanner.map_int()
    S = sum(A)
    a = A[0]
    ans = abs(S - 2 * a)
    for i in range(1,N - 1):
        a += A[i]
        ans = min(ans,abs(S - 2 * a))
    print(ans)
    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 70940
import java.util.Scanner;

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

    for (int i = 0;; i++) {
      H = sc.nextInt();
      W = sc.nextInt();
      if (H == 0 && W == 0) break;
      for (int h = 0; h < H; h++) {
        if (0 < h && h < H - 1) {
          System.out.printf("#");
          for (int w = 2; w < W; w++) {
            System.out.printf(".");
          }
          System.out.printf("#");
        } else {
          for (int w = 0; w < W; w++) {
            System.out.printf("#");
          }
        }
        System.out.printf("\n");
      }
      System.out.printf("\n");
    }

    sc.close();
  }
}



Measured memory_bytes: 60996
N = gets.to_i
hash = Hash.new
s = gets.split(/\s/)
s.each_with_index do |c,i|
  hash[i+1] = c.to_i
end

cnt = 0
(hash.keys).each do |k|
  c = hash[k]
  if hash.has_key?(c) then
    cc = hash[c]
    if k==cc then
      cnt += 1
    end
  end
end

puts cnt/2

Measured memory_bytes: 14596
#include <stdio.h>
#include <algorithm>
#include <utility>
using namespace std;

int main(void) {
  int i, j, k, n;
  scanf("%d", &n);
  pair<float, int> a[n];
  int ans[n];
  for(i = 0; i < n; ++i) {
    scanf("%f", &a[i].first);
    a[i].second = i;
  }
  sort(a, a + n);
  for(i = 0; i < n; ++i) {
    pair<float, int> p1 = make_pair(a[i].first, 0), p2 = make_pair(a[i].first, 1000000);
    ans[a[i].second] = (lower_bound(a, a + n, p1) - a) * 3 + ((a + i) - lower_bound(a, a + n, p1)) + (upper_bound(a, a + n, p2) - (a + i + 1)); 
  }
  for(i = 0; i < n; ++i) printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 3676
#define onlycc ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;

int k;
string str = "ACL";

int main()
{
    onlycc;
    cin >> k;
    for(int i = 0; i < k; i++)
        cout << str;

    return 0;
}


Measured memory_bytes: 3688
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  long n; rd(n);
  
  long m=1;
  while(m<n){
    if((n&m)!=m){
      writeln(m);
      return;
    }
    m*=2;
  }
  
  writeln(n+1);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 2436
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

s = readChar()
n = len(s)

def z1(st):
	if len(st)%2==1:
		a = (len(st)-1)//2
		#print(st[:a],st[a+1:][::-1])
		if st[:a]==st[a+1:][::-1]:
			return 1
		else:
			return 0
	else:
		a = len(st)//2
		#print(st[a:],st[:a],st[a:][::-1])
		if st[:a]==st[a:][::-1]:
			return 1
		else:
			return 0

def z2(st):
	a = (len(st)-1)//2
	return z1(st[:a])

def z3(st):
	a = (len(st)+3)//2
	return z1(st[a-1:])

def jud(st):
	return z1(st)*z2(st)*z3(st)


if jud(s)==1:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3936
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}

unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

void main(){
    auto n = readLong();

    long[] x, y;
    foreach(i; iota(n)) {
        auto l = readLongs();
        x ~= l[0];
        y ~= l[1];
    }

    auto uft = new UnionFindTree(n);
    size_t[] idx = iota(n.to!size_t).array();

    size_t[][] s;
    sort(zip(x, y, idx));
    foreach(i; iota(n-1)) {
        s ~= [idx[i], idx[i+1]];
    }
    sort(zip(y, x, idx));
    foreach(i; iota(n-1)) {
        s ~= [idx[i], idx[i+1]];
    }

    sort(zip(idx, x, y));
    size_t dist(size_t i, size_t j) {
        return min(abs(x[i] - x[j]), abs(y[i] - y[j]));
    }
    s.sort!((a, b) => dist(a[0], a[1]) < dist(b[0], b[1]))();

    long ans = 0;
    foreach(si; s) {
        auto idx1 = si[0];
        auto idx2 = si[1];
        if(uft.find(idx1) != uft.find(idx2)) {
            uft.unite(idx1, idx2);
            ans += dist(idx1, idx2);
        }
    }
    writeln(ans);
}



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

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

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

    int a, b, c;
    cin >> a >> b >> c;

    bool p = false;
    if (a == b && a != c) {
      p =  true;
    } else if (a == c && a != b) {
      p =  true;
    } else if (b == c && b != a) {
      p =  true;
    }

    if (p) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    
    return 0;
}


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

using namespace std;
using ll = long long;

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

  int h, w;
  cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }

  vector<tuple<int, int, int, int>> ans;

  for (int i = 0; i < h - 1; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] % 2 == 0)
        continue;
      a[i][j]--;
      a[i + 1][j]++;
      ans.push_back({i, j, i + 1, j});
    }
  }

  for (int j = 0; j < w - 1; j++) {
    if (a[h - 1][j] % 2 == 0)
      continue;
    a[h - 1][j]--;
    a[h - 1][j + 1]++;
    ans.push_back({h - 1, j, h - 1, j + 1});
  }

  cout << ans.size() << endl;
  for (auto [y1, x1, y2, x2] : ans) {
    cout << y1 + 1 << " " << x1 + 1 << " " << y2 + 1 << " " << x2 + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 6308
package main

import (
	"fmt"
)

func main() {
	var n int
	var v, c []int
	fmt.Scan(&n)
	v = make([]int, n)
	c = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}
	max := 0
	for i := 0; i < n; i++ {
		tmp := v[i] - c[i]
		if tmp <= 0 {
			continue
		}
		max += tmp
	}
	fmt.Println(max)
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=1010;

int a[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    cout<<accumulate(a+1,a+k+1,0ll);
}


Measured memory_bytes: 3660
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if A>B:
  D=A-B
else:
  D=B-A
if V<=W:
  print("NO")
elif (V-W)*T>=D:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main(void){
    ll n,a[100000];
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    ll L[100000],R[100000];
    L[0]=a[0],R[n-1]=a[n-1];
    for(int i=1;i<n;i++){
        L[i]=gcd(L[i-1],a[i]);
    }
    for(int i=n-2;i>=0;i--){
        R[i]=gcd(R[i+1],a[i]);
    }
    ll ans=max(L[n-2],R[1]);
    for(int i=1;i<n-1;i++){
        ans=max(ans,gcd(L[i-1],R[i+1]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
import java.io.PrintWriter;
import java.util.Scanner;

// MainT1P2018D
public class Main {

	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in);
			 PrintWriter out = new PrintWriter(System.out))
		{
			final int N = in.nextInt();
			int d = 8*N + 1;
			int dr = (int)Math.sqrt(d);
			if (dr * dr != d) {
				out.println("No");
				return;
			}

			final int k = (1 + dr) / 2;

			final int[] startIdx = new int[k - 1];
			{
				int idx = 1;
				for (int i = 0; i < k - 1; ++i) {
					startIdx[i] = idx;
					idx += i + 1;
				}
			}

			out.println("Yes");
			out.println(k);
			{
				out.print(k - 1);
				for (int i = 0; i < k - 1; ++i) {
					out.print(' ');
					out.print(startIdx[i] + i);
				}
				out.println();
			}
			for (int i = 0; i < k - 1; ++i) {
				out.print(k - 1);
				for (int j = 0; j < i; ++j) {
					out.print(' ');
					out.print(startIdx[i] + j);
				}
				for (int j = i; j < k - 1; ++j) {
					out.print(' ');
					out.print(startIdx[j] + i);
				}
				out.println();
			}
		}
	}
}


Measured memory_bytes: 36744
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  n=n%10;
  if(n==2 || n==4 || n==5 || n==7 || n==9)
    cout<<"hon";
  else if(n==3)
    cout<<"bon";
  else
    cout<<"pon";
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n, k;
	cin >> n >> k;
	double p[n];
	double kitai[n];
	double ans = 0;
	double res[n+1];
	for (int i = 0; i < n; i++){
		cin >> p[i];
		kitai[i] = (0.5) * (p[i]+1);
	}
	res[0] = 0;
	for (int i = 1; i < n+1; i++){
		res[i] = res[i-1] + kitai[i-1];
	}
	for (int i = k; i < n+1; i++){
		ans = max(ans, res[i]-res[i-k]);
	}

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


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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  vector<int> T(N);
  int sum = 0;
  for (int i = 0; i < N; ++i) cin >> T[i], sum += T[i];
  int M;
  cin >> M;
  for (int i = 0; i < M; ++i) {
    int P, X;
    cin >> P >> X;
    cout << sum - T[P - 1] + X << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i <= n ; i++)

using namespace std;

int partition(int a[] , int p, int r){
    int x = a[r];
    int index = p-1;

    Rep(i,p,r){
        if(a[i] <= x){
            index++;
            swap(a[index],a[i]);
        }
    }
    swap(a[index+1],a[r]);

    return index + 1;
}

int main(){
    int n; cin >> n;
    int a[n+10];
    rep1(i,n) cin >> a[i];

    int p = partition(a,1,n);

    rep1(i,n){
        if(i == p) printf("[%d]" , a[i]);
        else printf("%d",a[i]);

        cout << (i != n ? ' ' : '\n'); 
    }
}


Measured memory_bytes: 3536
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, d[100];
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &d[i]);
  }

  int temp;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      if(d[i] < d[j]){
	temp = d[i];
	d[i] = d[j];
	d[j] = temp;
      }
    }
  }

  int k = 1;
  for(int x = 0; x < n - 1; x++){
    if(d[x] > d[x + 1]){
      k++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll m=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m = max(a[i],m);
    }
    ll l=1,r=m,cuts,mid,ktemp;
    while(l<r)
    {
        mid = (l+r)/2;
        ktemp=0;
        for(int i=0;i<n;i++)
        {
            if(mid>=a[i])
            cuts = 0;
            else
            {
                if(a[i]%mid==0)
                cuts = (a[i]/mid) - 1;
                else
                cuts = a[i]/mid;
            }
            ktemp += cuts;
        }
        if(ktemp <= k)
        r=mid;
        else
        l=mid+1;
    }
    cout<<l<<endl;
}

Measured memory_bytes: 5228
#include <bits/stdc++.h>
using namespace std;
int main(void){
    vector<vector<int>> A(3,vector<int> (3));
    
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> A.at(i).at(j);
        }
    }
    
    int N;
    cin >> N;
    
    vector<int> b(N);
    for (int k=0; k<N; k++) {
        cin >> b.at(k);
        for(int i=0; i<3; i++) {
            for (int j=0; j<3; j++) {
                if (b.at(k) == A.at(i).at(j))  {
                    A.at(i).at(j) = 0;
                }
            }
        }
    }
    
    int ans = 0;
    if (A.at(0).at(0) == 0 && A.at(1).at(1) == 0 && A.at(2).at(2) == 0) {
        ans = 1;
    }else if (A.at(0).at(2) == 0 && A.at(1).at(1) == 0 && A.at(2).at(0) == 0) {
        ans = 1;
    }
    for (int i=0; i<3; i++) {
        int check = 1;
        for (int j=0; j<3; j++ ) {
            if (A.at(i).at(j) != 0) {
                check = 0;
                break;
            }
        }
        if (check == 1) {
            ans = 1;
        } 
    }

    for (int i=0; i<3; i++) {
        int check = 1;
        for (int j=0; j<3; j++ ) {
            if (A.at(j).at(i) != 0) {
                check = 0;
                break;
            }
        }
        if (check == 1) {
            ans = 1;
        }
    }
    
    if (ans == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
    
    
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  map<char, int> mp;
  for(auto a : s){
    mp[a]++;
  }
  int x = 0;
  for(auto a : mp){
    x += (a.second == 2);
  }
  if(x == 2)cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
 
int main(){
    ll N,count=0;
    cin >> N;
    vector<ll> data(N);
    rep(i,N){
        cin >> data.at(i);
    }
    for(int i=1; i<=N-2; i++){
        ll a=max(data.at(i),max(data.at(i-1),data.at(i+1)));
        ll b=min(data.at(i),min(data.at(i-1),data.at(i+1)));
        if(data.at(i)!=a && data.at(i)!=b) count++;

    }

    cout << count << endl;
}

Measured memory_bytes: 256