akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>


using namespace std;


typedef vector<long long> Vector;
typedef vector<Vector> Matrix;


void input_matrix(Matrix &, int, int);
Matrix & input_matrix(int, int);
void output(Matrix & M, int n, int l);


const int MAX = 101;


int main()
{
    Matrix A, B;
    int n, m, l;
    cin >> n >> m >> l;

    input_matrix(A, n, m);
    input_matrix(B, m, l);


    Matrix C (n, Vector (l));

    for (int i = 0; i < n; i++)
        for (int j = 0; j < l; j++)
            for (int k = 0; k < m; k++)
            C[i][j] += A[i][k] * B[k][j];

    output(C, n, l);
}


Matrix & input_matrix(int n, int m)
{
    //method 1
    static Matrix matrix (n,Vector(m));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> matrix[i][j];
    return matrix;

    //method 2, may cause memory leak
    // Matrix * matrix = new Matrix (n,Vector(m));
    // for (int i = 0; i < n; i++)
    //     for (int j = 0; j < n; j++)
    //         cin >> (*matrix)[i][j];
    // return *matrix;    
}


void input_matrix(Matrix & M, int n, int m)
{

//     //method 1
//     M.resize(n);
//     for (int i = 0; i < n; i++)
//         for (int j = 0; j < m; j++)
//         {
//             int e;
//             cin >> e;
//             M[i].push_back(e);            
//         }


    // method 2
    M.resize(n);

    for (int i = 0; i < n; i++)
        M[i].resize(m);

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cin >> M[i][j];
    

}


void output(Matrix & M, int n, int l)
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < l; j++)
            cout << (j? " ": "") << M[i][j];
        cout << endl;        
    }
}


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>

int main(){
  long  n;unsigned long tmp; long m=0;
  std::vector<std::pair<unsigned long,unsigned long> > ls;
  std::cin >> n;
  std::vector<unsigned long long> ans(n);
  ls.reserve(n+1);
  for(long i=0; i<n; ++i) {std::cin >> tmp;ls.emplace_back(std::make_pair(tmp,i));}
  ls.emplace_back(std::make_pair(0,n));
  std::stable_sort(ls.begin(),ls.end(),[](auto a,auto b){return a.first>b.first;});
  auto target=ls.begin();
  for(auto it=ls.begin();it!=ls.cend()-1;){
    if(target->second>it->second)target=it;
    ans[target->second]+=(it->first-(++it)->first)*(++m);
  }
  for(auto x : ans) std::cout<< x <<'\n';
  std::cout.flush();
  return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main() {
    
    
    int n;
    cin>>n;
    ll ans=0;
    ll bn=0;
    int arr[n];
    int brr[2005][2005]={0};
    for(int i=0;i<n;i++) {
        
        cin>>arr[i];
     //   brr[i][arr[i]]++;
     //   brr[arr[i]]++; crr[arr[i]]++;
    }
      sort(arr,arr+n);
    for(int i=0;i<n;i++) {
        
       // cin>>arr[i];
        brr[i][arr[i]]++;
     //   brr[arr[i]]++; crr[arr[i]]++;
    }
     for(int j=1;j<2005;j++) brr[n-1][j]+=brr[n-1][j-1];
    for(int i=n-2;i>=0;i--) {
        
        for(int j=1;j<2005;j++) brr[i][j]+=brr[i][j-1];
        for(int j=1;j<2005;j++) brr[i][j]+=brr[i+1][j];
        
       // cout<<brr[i][5]<<" ";
    }
 //   for(int i=1;i<1000005;i++) brr[i]+=brr[i-1];
 
  
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n-1;j++) {
            ans+=brr[j+1][arr[i]+arr[j]-1]-brr[j+1][arr[j]-1];
           // cout<<j+1<<endl;
           //cout<<ans<<" "<<brr[j+1][arr[j]+arr[i]-1]<<endl;
/*            if(crr[arr[j]]>1) {
                if(arr[i]!=arr[j]) ans+=crr[arr[j]]-1;
                else ans+=crr[arr[j]]-2;
            }
*/        }
    }cout<<ans<<endl;
    
    
    
}

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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    if(k==0){
        cout << 1LL*n*n << endl;
        return 0;
    }
    long long ans=0;
    for(int i=1;i<=n;i++){  // iterate over divisor
        ans+=max(0LL,1LL*(i-k)*(n/i));
        int rem=n%i;
        ans+=max(0,(rem-k+1));
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

struct Op {
    int y1;
    int x1;
    int yy1;
    int xx1;
};

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    rep(i, H) rep(j, W) cin >> a[i][j];

    int count = 0;
    vector<Op> op;
    rep(i, H) {
        rep(j, W) {
            if (a[i][j] % 2 == 1) {
                int ni = i;
                int nj = j + 1;
                if (nj == W) {
                    ni = i + 1;
                    nj = j;
                }

                if (ni < H) {
                    a[i][j]--;
                    a[ni][nj]++;
                    op.push_back({i, j, ni, nj});
                    count++;
                }
            }
        }
    }

    cout << count << endl;
    for (Op o: op) {
//        cout << o.y1 << " " << o.x1 << " " << o.yy1 << " " << o.xx1 << endl;
        cout << o.y1 + 1 << " " << o.x1 + 1 << " " << o.yy1 + 1 << " " << o.xx1 + 1 << endl;
    }
}

Measured memory_bytes: 5232
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];

void solve() {
  int a,b,c; cin >> a >> b >> c;
  if (a == b) cout << c << endl;
  else if (a == c) cout << b << endl;
  else cout << a << endl;
}


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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
    int h, n;
    cin >> h >> n;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        h -= a;
        if(h <= 0){
          cout << "Yes";
          return 0;
        }
    }

    cout << "No";
    return 0;
}


Measured memory_bytes: 384
using System;

public class C
{
    public const int INF = 999999999;
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var e = int.Parse(line[0]);
            var n = int.Parse(line[1]);
            if (e == 0 && n == 0) break;
            var dp0 = new int[n, n];   //cost
            var dp1 = new int[n, n];   //time
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    if (i != j) { dp0[i, j] = C.INF; dp1[i, j] = C.INF; }
            for (int i = 0; i < e; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var a = int.Parse(line2[0]) - 1;
                var b = int.Parse(line2[1]) - 1;
                var c = int.Parse(line2[2]);
                var t = int.Parse(line2[3]);
                dp0[a, b] = c; dp0[b, a] = c;
                dp1[a, b] = t; dp1[b, a] = t;
            }
            goWarshall(dp0);
            goWarshall(dp1);
            var k = int.Parse(Console.ReadLine().Trim());
            for (int i = 0; i < k; i++)
            {
                string[] line3 = Console.ReadLine().Trim().Split(' ');
                var p = int.Parse(line3[0]) - 1;
                var q = int.Parse(line3[1]) - 1;
                var r = int.Parse(line3[2]);
                Console.WriteLine(r == 0 ? dp0[p, q] : dp1[p, q]);
            }
        }
    }
    public static void goWarshall(int[,] dp)
    {
        var n = dp.GetLength(0);
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k < n; k++)
                    dp[j, k] = Math.Min(dp[j, k], dp[j, i] + dp[i, k]);
    }
}

Measured memory_bytes: 9648
t,_,s=open(0).read().partition('\n')
h,w=map(int,t.split())
a=h//2*(w//2)
c=h%2and w%2
b=(h*w-a*4-c)//2
l=[]
for i in set(s.replace('\n','')):
    l.append(s.count(i))
for i in l:
    if i>3:
        while i>3and a:
            i-=4
            a-=1
    if i>1:
        while i>1and b:
            i-=2
            b-=1
    if i and c:
        i-=1
        c-=1
if all(not t for t in(a,b,c)):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int a,b; cin >> a >> b;
  int c[1][1];
  c[0][11] = a;
  cout << max(a - 2*b, 0) << "\n";
  return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B

main = do
  getLine
  input <- B.getContents
  let as = map readI . B.words $ input
  mapM_ print (solve as)

readI :: B.ByteString -> Int
readI s = case B.readInt s of Just (n,_) -> n

solve :: [Int] -> [Int]
solve as =
  [total+dt | dt<-map f $ zip bs (zip (tail bs) (tail (tail bs)))]
  where
    bs = 0:as++[0]
    total = sum[ abs(a1-a2) | (a1,a2)<-zip bs (tail bs)]
    f (a1,(a2,a3))  = abs(a1-a3)-abs(a1-a2)-abs(a2-a3)

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  ll n,m;cin>>n>>m;
  vector<vector<ll> >knap(10);
  ll w;cin>>w;
  ll v;cin>>v;
  knap[0].pb(v);
  for(int i=1;i<n;i++){
    ll W,V;cin>>W>>V;
    knap[W-w].pb(V);
  }
  for(int i=0;i<4;i++){
    sort(knap[i].begin(),knap[i].end(),greater<ll>());
  }
  ll sum[4][500]={};
  for(int i=0;i<4;i++){
    for(int j=1;j<=knap[i].size();j++){
      sum[i][j]=sum[i][j-1]+knap[i][j-1];    
    }
  }
  ll ans=0;
  for(int i=0;i<=knap[0].size();i++){
    for(int j=0;j<=knap[1].size();j++){
      for(int k=0;k<=knap[2].size();k++){
	for(int l=0;l<=knap[3].size();l++){
	  if(((i+j+k+l)*w+j+k*2+3*l)<=m){
	    ans=max(ans,sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l]);
	  }
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<ll> l(0), r(0);

  rep(i,n) {
    int a;
    cin >> a;
    r.push_back(a);
    swap(l,r);
  }

  int nl = l.size();
  int nr = r.size();
  for(int i = nl-1; i >=0; i--){
    cout << l[i] << " ";
  }
  for(int i = 0; i < nr; i++){
    cout << r[i] << " ";
  }
  cout << endl;
  
}


Measured memory_bytes: 4968
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  int c[2][3],r,r_;
  double d;
  cin>>c[0][0]>>c[0][1]>>c[0][2];
  cin>>c[1][0]>>c[1][1]>>c[1][2];
  d = pow(pow((c[0][0]-c[1][0]),2) + pow(c[0][1]-c[1][1],2),0.5);
  r = c[0][2]+c[1][2];
  r_ = abs(c[0][2]-c[1][2]);
  //cout <<d<<" "<<r<<" "<<r_<<endl;
  if(d>r) cout<<"4"<<endl;
  else if (d == r) cout<<"3"<<endl;
  else if (r_ == d) cout<<"1"<<endl;
  else if (r_ < d && d < r) cout<<"2"<<endl;
  else if (r_ > d) cout<<"0"<<endl;
  //cout <<d<<" "<<r<<" "<<r_<<endl;
  return 0;
}



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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
ll h,n;
const int maxn=1e4+4;
ll dp[maxn];
ll a[maxn],b[maxn];
const ll inf=1e9;
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>h>>n;
    repA(i,1,n)
    {
      cin>>a[i]>>b[i];
    }
    dp[0]=0ll;
    for(ll i=1;i<=h;i++)
    {
      ll ans=inf;
      for(ll k=1;k<=n;k++)
      {
        if(i-a[k]<=0) ans=min(ans,b[k]);
        else ans=min(ans,b[k]+dp[i-a[k]]);
      }
      dp[i]=ans;
    }
    cout<<dp[h]<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3724
X, N = map(int, input().split())

p = list(map(int, input().split()))

p_none = [i for i in range(110) if i not in p]
p_none_sa = [abs(p_none[i]-X) for i in range(len(p_none))]

import sys

min_p_none = min(p_none_sa)
for i in range(len(p_none_sa)):
    if p_none_sa[i] == min_p_none:
        print(p_none[i])
        sys.exit()

Measured memory_bytes: 9204
import java.util.Scanner;

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

        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] check = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
        boolean[][] mass = new boolean[h][w];

        for (int i = 0; i < h; i++) {
            String s = sc.next();
            for (int j = 0; j < w; j++) {
                mass[i][j] = s.charAt(j) == '#';
            }
        }

        boolean isAns = true;
        label: for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (mass[i][j]) {
                    boolean isCheck = false;
                    for (int z = 0; z < check.length; z++) {
                        int y = i+check[z][0];
                        int x = j+check[z][1];
                        if (y >= h || y < 0 || x >= w || x < 0)
                            continue;

                        if(mass[y][x]) {
                            isCheck = true;
                            break;
                        }
                    }
                    if (!(isCheck)) {
                        isAns = false;
                        break label;
                    }
                }
            }
        }

        System.out.println(isAns ? "Yes" : "No");
    }
}


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

int n;
pair<int,int> a[200005];
int had[100005];

int id(int i) { return abs(a[i].second); }

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d %d", &a[i].first, &a[i + n].first);
		a[i].second = i;
		a[i + n].second = -i;
	}
	sort(a + 1, a + n + n + 1);
	long long res = 0;
	for (int i = 1; i <= n; ++i) res += a[i].first;
	int had_a = 0, had_b = 0;
	for (int i = 1; i <= n; ++i) {
		had[id(i)] = 1;
		if (a[i].second < 0) had_b++;
		else had_a++;
	}
	int nhad = 0;
	for (int i = 1; i <= n; ++i) nhad += had[i];
	if (had_a == n || had_b == n || nhad < n) return cout << res << '\n',0;
	if (id(n) != id(n + 1) 
	|| (had_a - (a[n].second > 0) + (a[n + 1].second > 0) == 0)
	|| (had_b - (a[n].second < 0) + (a[n + 1].second < 0) == 0) 
	) return cout << res + a[n + 1].first - a[n].first << '\n',0;
	cout << res + min(a[n + 2].first - a[n].first, a[n + 1].first - a[n - 1].first) << '\n';
	
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    while (true) {
        cin >> n >> m;
        if (n == 0 && m == 0) break;

        int cnt = 0;
        REP2(i, 1, n+1) REP2(j, i+1, n+1) REP2(k, j+1, n+1) {
            if (i+j+k == m) cnt++;
        }

        std::cout << cnt << '\n';
    }

    return 0;
}



Measured memory_bytes: 3152
#include<string>
#include <iostream>
#include<vector>
#define T long long

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

int main(void){
	T result=0;
	T n;
	std::string str;
	
	std::cin >> n;
	std::cin >> str;
	std::vector<int> memo[3];
	std::vector<int> s;
	for(int i=0;i<3;i++){
		memo[i].resize(n);
	}
	s.resize(n);
	for(int i=0;i<n;i++){
		int tmp;
		switch(str[i]){
			case 'R':
				tmp=0;
				break;
			case 'G':
				tmp=1;
				break;
			case 'B':
				tmp=2;
				break;
		}
		s[i]=tmp;
	}
	for(int j=0;j<3;j++){
		if(s[n-1]==j){
			memo[j][n-1] = 1;
			}else{
			memo[j][n-1] = 0;
		}
	}
	for(int i=n-2;i>=0;i--){
		for(int j=0;j<3;j++){
			if(s[i]==j){
				memo[j][i] = memo[j][i+1]+1;
			}else{
				memo[j][i] = memo[j][i+1];
			}
		}
	}
	int first,second;
	for(int i=0;i<n-2;i++){
		first = s[i];
		for(int j=i+1;j<n-1;j++){
			second=s[j];
			if(first != second){
				int other = 3-first-second;
				result += memo[other][j+1];
				int diff = j -i;
				if((j+diff)<n){
					if(s[j+diff]==other){
						result-=1;
					}
				}
			}
		}
	}
	std::cout << result <<std::endl;
}


Measured memory_bytes: 3708
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;

const int maxn = 110000;

struct rec
{
	int a, b;
};

priority_queue<int,vector<int>,greater<int> > q1, q2;
ll sy[maxn], sx[maxn];
rec a[maxn];

bool comp(const rec & a, const rec & b)
{
	return a.a - a.b < b.a - b.b;
}

int main(int argc, char * argv[])
{
	int x, y, z;
	ll ans = 0;
	scanf("%d%d%d", &x, &y, &z);
	for (int i = 1;i <= x + y + z;++i)
	{
		int t1, t2, t3;
		scanf("%d%d%d", &t1, &t2, &t3);
		ans += t3;
		a[i].a = t1 - t3;
		a[i].b = t2 - t3;
	}
	sort(a + 1, a + x + y + z + 1, comp);
	ll cur = 0;
	for (int i = 1;i <= y;++i)
	{
		cur += a[i].b;
		q1.push(a[i].b);
	}
	sy[y] = cur;
	for (int i = y + 1;i <= x + y + z;++i)
	{
		if (a[i].b > q1.top())
		{
			cur -= q1.top();
			q1.pop();
			cur += a[i].b;
			q1.push(a[i].b);
		}
		sy[i] = cur;
	}
	cur = 0;
	for (int i = x + y + z;i >= y + z + 1;--i)
	{
		cur += a[i].a;
		q2.push(a[i].a);
	}
	sx[y + z + 1] = cur;
	for (int i = y + z;i >= 1;--i)
	{
		if (a[i].a > q2.top())
		{
			cur -= q2.top();
			q2.pop();
			cur += a[i].a;
			q2.push(a[i].a);
		}
		sx[i] = cur;
	}
	ll ret = -(1ll<<60);
	for (int i = y;i <= y + z;++i)
	{
		ret = max(ret, sy[i] + sx[i+1]);
	}
	printf("%lld\n", ans+ret);
	return 0;
}


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

int main() {
  int X, Y;
  cin >> X >> Y;
  double t = 0.5 * Y - X;
  double c = 2 * X - 0.5 * Y;
  if (t < 0 || c < 0 || (int)t != t || (int)c != c)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 200005
using namespace std;
int n,r,res=-1,tot,len,flag;
int head[maxn],nex[maxn],to[maxn];
int q[maxn],pa[maxn],dep[maxn],vis[maxn];
void add(int x,int y)
{
	to[++tot]=y; nex[tot]=head[x]; head[x]=tot;
}
void dfs(int now,int fa)
{
	if(dep[now]>res)
	{
		res=dep[now];
		r=now;
	}

	for(int i=head[now];i;i=nex[i])
	{
		if(to[i]!=fa)
		{
			if(flag)
			pa[to[i]]=now;
			dep[to[i]]=dep[now]+1;
			dfs(to[i],now);
		}
	}
}
int ans1[maxn],ans2[maxn];
int solve(int *a)
{
	int sz=0;
	for(int i=1;i<=tot;i++)
	{
		int now=q[i],temp=0;
		for(int j=head[now];j;j=nex[j])
			if(!vis[to[j]])
				temp++;
		int s=sz;
		for(int j=1;j<=temp;j++)
		{
			a[++sz]=s+j+1;
		}
		a[++sz]=s+1;
	}
	return sz;
}
int judge()
{
	for(int i=1;i<=n;i++)
	{
		if(ans1[i]<ans2[i])
			return true;
		if(ans1[i]>ans2[i])
			return false;
	}
	return true;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}

	dfs(1,-1); res=-1; dep[r]=0; flag=1;
	dfs(r,-1);

//	cerr<<r<<endl;

	tot=0;

	while(r!=0)
	{
		q[++tot]=r;
		vis[r]=1;
		r=pa[r];
	}

	if(solve(ans1)<n)
	{
		printf("-1\n");
		return 0;
	}

	for(int i=1;i<=tot/2;i++)
		swap(q[i],q[tot-i+1]);

	solve(ans2);

	if(judge())
	{
		for(int i=1;i<=n;i++)
			printf("%d ",ans1[i]);
	}
	else
	{
		for(int i=1;i<=n;i++)
			printf("%d ",ans2[i]);
	}
	printf("\n");
}


Measured memory_bytes: 11264
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] inputs = new String[N];
        Map<String, Integer> treeMap = new TreeMap<>();
        int max = 0;

        for(int i = 0; i < N; i++) {
            inputs[i] = sc.next();
        }

        for(String input: inputs) {
            if(treeMap.containsKey(input)) {
                treeMap.put(input, treeMap.get(input)+1);
                max = Math.max(max,treeMap.get(input));
            } else {
                treeMap.put(input, 1);
                max = Math.max(max,treeMap.get(input));
            }
        }

        for(Map.Entry<String, Integer> entry:treeMap.entrySet()) {
            if(entry.getValue() == max) {
                System.out.println(entry.getKey());
            }
        }

    }
}


Measured memory_bytes: 85208
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

ll n, m;
vector<int> g[114514];
int color[114514] = {};
ll b = 0, w = 0;
bool dfs(int i,int c) {
	if (c > 0)b++;
	else w++;
	color[i] = c;
	for (auto a : g[i]) {
		if (color[a] == c)return false;
		if (color[a] == 0 && !dfs(a, -c))return false;
	}
	return true;
}

int main() {
	IOS;
	cin >> n >> m;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cout << (dfs(1, 1) ? b * w - m : n * (n - 1) / 2 - m) << endl;
}



Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll n,x,m;
    cin>>n>>x>>m;
 
    ll id=1;
    vector<ll> a(1000010);
    a[0]=x;
    map<ll,ll> mp;
    mp[x]++;
    ll l,r;
    ll N=n;
    while(1){
        a[id]=(a[id-1]*a[id-1])%m;
        if(mp[a[id]]>0){
            rep(j,id){
                if(a[j]==a[id]){
                    l=j;
                    r=id;
                    break;
                }                
            }
            break;
        }
        mp[a[id]]++;
        id++;
    }
    /*
    rep(i,r) cout<<a[i]<<" ";
    cout<<endl;
    
    cout<<l<<" "<<r<<endl;
    */
    ll ans=0;
    if(n<=r){
        rep(i,n) ans+=a[i];
    }
    else{
        rep(i,l) ans+=a[i];
        ll sum=0;
        for(int i=l;i<r;i++) sum+=a[i];
        n-=l;
        ans+=sum*(n/(r-l));
        ll ama=0;
        ll am=n%(r-l);
        for(int i=l;i<l+am;i++) ama+=a[i];
        ans+=ama;
    }
 
    cout<<ans<<endl;
}

Measured memory_bytes: 14032
// Solution to https://atcoder.jp/contests/dp/tasks/dp_v
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

int N, MOD;
vector<vector<int>> adj;

// down[node] = number of ways to paint node's subtree where node must be painted black.
// up[node] = number of ways to color the subtree of node that its parent is responsible for, empty coloring included.
vector<int> down;
vector<int> up;

void solve_down(int node, int parent) {
    vector<int> &children = adj[node];

    // Erase the edge from node to parent.
    auto parent_it = find(children.begin(), children.end(), parent);

    if (parent_it != children.end())
        children.erase(parent_it);

    down[node] = 1;

    for (int child : children) {
        assert(child != parent);
        solve_down(child, node);
        down[node] = (long long) down[node] * (down[child] + 1) % MOD;
    }
}

void solve_up(int node, int parent) {
    vector<int> &children = adj[node];
    int n = children.size();
    vector<int> prefix(n + 1, 1), suffix(n + 1, 1);

    for (int i = 0; i < n; i++)
        prefix[i + 1] = (long long) prefix[i] * (down[children[i]] + 1) % MOD;

    for (int i = n - 1; i >= 0; i--)
        suffix[i] = (long long) suffix[i + 1] * (down[children[i]] + 1) % MOD;

    for (int i = 0; i < n; i++)
        up[children[i]] = (1 + (long long) prefix[i] * suffix[i + 1] % MOD * up[node]) % MOD;

    for (int child : children) {
        assert(child != parent);
        solve_up(child, node);
    }
}

int main() {
    scanf("%d %d", &N, &MOD);
    adj.assign(N, {});

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    down.resize(N);
    solve_down(0, -1);

    up.resize(N);
    up[0] = 1;
    solve_up(0, -1);

    for (int i = 0; i < N; i++)
        printf("%lld\n", (long long) up[i] * down[i] % MOD);
}


Measured memory_bytes: 18688
#include<stdio.h>

void trace( int *A, int n )
{
	int i=0;
	while( i<n ) {
		printf( "%d\n", A[i++] );
	}
	
	return;
}

int insertionSort( int *A, int n, int g )
{
	int i,j;
	int v;
	int cnt;
	
	cnt=0;
  	for( i=g; i<n; i++ ) {
  		v=A[i];
  		j = i-g;
  		while( 0<=j && v<A[j] ) {
  			A[j+g] = A[j];
  			j=j-g;
  			cnt++;
  		}
  		A[j+g] = v;
   	}
  
	return cnt;
}

void shellSort( int *A, int n )
{
	int cnt;
	int m;
	int i;
	int G[101];

	m=n/3;
	if( m < 1 ) {
		G[0]=1;
		m=1;
	} else {
		G[0]=m*3;
		for( i=1; G[i-1]<=n; i++ ) {
			G[i]=G[i-1]/3;
			if( G[i] <= 1 ) {
				G[i]=1;
				m=i+1;
				break;
			}
		}
	}
  	printf( "%d\n", m );  	
	for( i=0; i<m; i++ ) {
	  	printf( "%d", G[i] );
	  	if( m-1 != i ) {
	  		printf( " " );
	  	}
	}
	printf( "\n" );	

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

	return;
}

int main( void ) 
{
	int n;
	int A[1000001];
	int i;

	scanf( "%d", &n );
	for( i=0; i<n; i++ ) {
		scanf( "%d", &A[i] );
	}
	
	shellSort( A, n );
	trace( A, n );
	
	return 0;
}

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

int main(){
	string S, T, U;
	int A, B;
	
	cin >> S >> T >> A >> B >> U;
	
	if(S==U){
		A -= 1;
	}else{
		B -= 1;
	}
	
	cout << A << " " << B << endl;
	
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  int count =0;
  for(int i=0;i<S.size();i++){
  	if(i%2 == 0 && S.at(i) != 'L'){
  		count++;
  	}
  	else if(i%2 == 1 && S.at(i) != 'R'){
  		count++;
  	}
  	else{
  		cout << "No" <<endl;
  		break;
  	}
  }
  if(count == S.size()){
  	cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class     Main    {
	public static void main(String[] args) 
	{
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		Scanner sc = new Scanner(System.in);
		int n = in.nextInt();
		if(n==1)
			System.out.println("1");
		else
		{
			int count=1;
			while(count<=n)
			{
				count*=2;
			}
			if(count/2==n)
				System.out.println(n);
			else
				System.out.println(count/2);
		}
		//w.println(n);
		w.close();
		sc.close();
	}
	static class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		public InputReader(InputStream st) {
			this.stream = st;
		}
		public int read() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
		
		public int nextInt() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public long nextLong() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
		
		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = nextInt();
			}
			return a;
		}
		
		public String readString() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}
		
		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}
		
		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
		
		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
		
	}
	
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

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

const ll inf = 1LL << 60;

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

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

    ll N, K, S;
    cin >> N >> K >> S;

    vec ans;
    if (S < 1e9) {
        Rep (i, K) {
            ans.push_back(S);
        }

        Rep (i, N-K) {
            ans.push_back(1e9);
        }
    } else {
        Rep (i, K) {
            ans.push_back(S);
        }
        Rep (i, N-K) {
            ans.push_back(1);
        }
    }

    Rep (i, N) {
        cout << ans[i] << " \n"[i==N-1];
    }
}

Measured memory_bytes: 2292
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MOD 1000000007
#define mod(x) ((x % MOD) + MOD) % MOD
#define MAX_N 100001

using namespace std;

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

int main() {
  ll N;
  cin >> N;
  ll cost1 = 0, cost2 = 0;
  ll sum1 = 0, sum2 = 0;
  for (ll i = 0; i < N; i++) {
    ll a;
    cin >> a;
    sum1 += a; sum2 += a;

    if (i % 2 == 0) {
      cost1 += max(sum1 + 1, (ll)0);
      cost2 += max(-sum2 + 1, (ll)0);
      sum1 = min((ll)-1, sum1);
      sum2 = max((ll)1, sum2);
    } else {
      cost1 += max(-sum1 + 1, (ll)0);
      cost2 += max(sum2 + 1, (ll)0);
      sum1 = max((ll)1, sum1);
      sum2 = min((ll)-1, sum2);
    }
  }

  cout << min(cost1, cost2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e5 + 5, mod = 1e9 + 7;

ll add(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (a + b) % mod;
}

ll mul(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return 1ll * a * b % mod;
}

ll x[N], y[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < n; i++) cin >> x[i];
    for(int j = 0; j < m; j++) cin >> y[j];
    ll ans = 0, sum = 0;
    vector<int> v, v2;
    for(int i = 1; i < n; i++){
        ll disx = i, disx2 = n - i;
        ll kamx = mul(disx, disx2);
        kamx = mul(kamx, x[i] - x[i - 1]);
        v.push_back(kamx);
    }
    for(int j = 1; j < m; j++){
        ll disy = j, disy2 = m - j;
        ll kamy = mul(disy, disy2);
        kamy = mul(kamy, y[j] - y[j - 1]);
        sum = add(sum, kamy);
    }
    for(int i = 0; i < v.size(); i++){
        ans = add(ans, mul(v[i], sum));
    }
    cout << ans;


    return 0;

}



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

int main() {

	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (ll i = 0; i < n - k; i++) {
		if (a[i] < a[i + k]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4776
a = int(input())
b = list(map(int, input().split()))

flg = True

for i in range(a):
    if (b[i] % 2) == 0:
        if (b[i] % 3 != 0) and (b[i] % 5 != 0):
            flg = False
            break

if flg == True:
    print('APPROVED')
else:
    print('DENIED')


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

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

    string s; cin >> s;
    int N = s.size();

    ll ans = 0;
    int a = 0;
    int i = 0;
    while (i < N) {
        if (s.compare(i, 1, "A")==0) {
            a++;
            i+=1;
        } else if (s.compare(i, 2, "BC")==0) {
            ans += a;
            i+=2;
        } else {
            a = 0;
            i+=1;
        }
    }

    cout << ans << endl;
}


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

using namespace std;
const int N = 100005;
typedef long long ll;
int a[N];
double b[N];
int main()
{
     int n,maxa=-1;
     cin>>n;
     for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    double mid=1.0*a[n]/2,minb=1000000009.0;
    int ans;
    for(int i=1;i<n;i++){
       // printf("%lf\n",mid-(1.0*a[n]-1.0*a[i]));
        if(fabs(mid-(1.0*a[n]-1.0*a[i]))<minb)
        {
            ans=a[i];
            minb=fabs(mid-(1.0*a[n]-1.0*a[i]));
        }
    }
    printf("%d %d\n",a[n],ans);
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q);
  rep(i, q) {
    cin >> a[i];
    a[i]--;
  }
  // ポイント数(正解した人だけポイントを得ると考える)
  vector<int> ac(n, k - q);
  rep(i, q) {
    ac[a[i]]++;
  }

  rep(i, n) {
    cout << (ac[i] > 0 ? "Yes" : "No") << endl;
  }

  return 0;
}


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

int main() {
    int n;
    cin >> n;
    if (n == 2) {
        cout << -1 << endl;
        return 0;
    }
    if (n == 3) {
        cout << "2 3" << endl;
        cout << "3 1" << endl;
        cout << "1 2" << endl;
        return 0;
    }
    if (!(n & 1)) { // odd
        for (int i = 0; i < n-1; ++i) {
            for (int j = 1; j < n-1; ++j) {  
                if (i == 0 && j == 1) cout << n;
                else cout << (i + j) % (n-1) + 1;
                cout << " ";
            }
            if (i == 0) cout << 2;
            else cout << n;
            cout << endl;
        }
        for (int i = n - 1; i > 0; --i) {
            if (i != n-1) cout << " ";
            cout << i;
        }
        cout << endl;
    } else { // even
        for (int i = 0; i < n; ++i) {
            for (int j = 1; j < n; ++j) {  
                cout << (i + j) % n + 1;
                if (j != n) cout << " ";
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
    int N, max=0, num=0;
    cin >> N;
    
    int L[N];
    
    for(int i=0;i<N;i++)
    {
        cin >> L[i];
    }
    
    for(int i=0;i<N;i++)
    {
        if(max <= L[i])
        {
            max = L[i];
        }
        num = num + L[i];
    }
    
    num = num - max;
    
    if(max < num)
    {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
input_1 = input().split()

h_l = int(input_1[0])
w_l = int(input_1[1])

input_2 = input().split()

h = int(input_2[0])
w = int(input_2[1])

result = h_l * w_l - (h_l * w  + w_l * h) + w * h

print(result)


Measured memory_bytes: 3060
<?php
$n=trim(fgets(STDIN));
list($t,$a)=explode(" ",trim(fgets(STDIN)));
$h=explode(" ",trim(fgets(STDIN)));

$ans=0;
$x=1000000;
$i=0;
while($i<$n){
  $c=abs($t-$h[$i]*0.006-$a);
  if($x>$c){
    $x=$c;
    $ans=$i+1;
  }
  ++$i;
}
echo $ans;

Measured memory_bytes: 4728
#include <queue>
#include<iostream>
using namespace std;
int n,a,s[2];
priority_queue<int> q;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a,q.push(a);
    for(int i=1;i<=n;i++){
        a=q.top();
        q.pop();
        s[i%2]+=a;
    }
    cout<<s[1]-s[0];
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
count = 0
l = []
for i in range(0, n - 1):
    if h[i] >= h[i + 1]:
        count += 1
    else:
        l.append(count)
        count = 0
l.append(count)
print(max(l))

Measured memory_bytes: 14252
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = arr_data[0][0]

#print(n)

cnt=0
cnt+= 1 if n[0]=="1" else 0
cnt+= 1 if n[1]=="1" else 0
cnt+= 1 if n[2]=="1" else 0

print(cnt)
    


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main(void){
    long long int a, b, k, i;
    scanf("%lld %lld %lld", &a, &b, &k);
    for(i=0; i<k; i++){
        if(i%2 == 0){
            if(a%2 == 1) a--;
            a = a/2;
            b += a;
        }
        else{
            if(b%2 == 1) b--;
            b = b/2;
            a += b;
        }
    }
    printf("%lld %lld", a, b);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
// #define m 1003
// #define int long long

// int sol(vector<int> A){


// }


int32_t main(){
  IOS
int n,k;
cin>>n>>k;
int h[n];
for(int i=0;i<n;i++) cin>>h[i];
int t =0;

int ans = 0;
int dp[n+1];
for(int i=0;i<=n;i++) dp[i]= INT_MAX;
dp[1]=0;
  for(int i=1;i<=n;i++){
    for(int j = i+1;j<=n&&j<=i+k;j++){
      dp[j] = min(dp[j],dp[i]+ abs(h[j-1]-h[i-1]));
    }
  }
  cout <<dp[n];


 return 0;
}

 

Measured memory_bytes: 4320
n = int(input())

list_a = list()
list_b = list()
for i in range(n):
  a, b = input().split()
  list_a.append(a)
  list_b.append(b)

result = "No"
for k in range(n-2):
  if list_a[k] == list_b[k] and list_a[k + 1] == list_b[k + 1] and list_a[k + 2] == list_b[k + 2]:
    result = "Yes"
print(result)

    

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

int a[7];

void move(char i){
int b[7];
for(int n=1;n<7;n++){b[n]=a[n];}

if(i=='W'){
a[6]=b[4];
a[4]=b[1];
a[1]=b[3];
a[3]=b[6];
}

if(i=='N'){
a[6]=b[5];
a[5]=b[1];
a[1]=b[2];
a[2]=b[6];
}

if(i=='E'){
a[6]=b[3];
a[3]=b[1];
a[1]=b[4];
a[4]=b[6];
}

if(i=='S'){
a[6]=b[2];
a[2]=b[1];
a[1]=b[5];
a[5]=b[6];
}

if(i=='R'){
a[3]=b[2];
a[2]=b[4];
a[4]=b[5];
a[5]=b[3];
}}



void move2(int m){
if(a[2]==m){move('N');}
if(a[3]==m){move('W');}
if(a[4]==m){move('E');}
if(a[5]==m){move('S');}
if(a[6]==m){move('N'); move('N');}
}

void move3(int l){
if(a[3]==l){move('R'); move('R'); move('R');}
if(a[4]==l){move('R');}
if(a[5]==l){move('R'); move('R');}
}


void move4(int l){
while(1){
if(a[2]!=l){move('R');}
else{break;}
}}




int main(){
int c[1000];
for(int n=1;n<7;n++){cin>>a[n]; c[n]=a[n];}
int x;
cin>>x;

for(int g=0;g<x;g++){
int y,z;
cin>>y>>z;
move2(y);
move3(z);
cout<<a[3]<<endl;
for(int n=1;n<7;n++){a[n]=c[n];}
}


return 0;
}


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

int main(){
	int x,a,b;
  	cin >> x >> a >> b;
  	if (a>=b) cout << "delicious" << endl;
  	else if ((b-a)<=x) cout << "safe" << endl;
  	else cout << "dangerous" << endl;
}

Measured memory_bytes: 256
def main():
    N , M, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))

    al = [0]
    bl = [0]

    for i in range(N) :
        al.append(al[i] + A_list[i])
    for i in range(M) :
        bl.append(bl[i] + B_list[i])
    #print("al = %s" % al)
    #print("bl = %s" % bl)
    book = 0
    re = M

    for i in range(N+1) :
        if al[i] > K :
            break
        for j in bl :
            if bl[re] <= K - al[i] :
                break
            else :
                re -= 1
        #while bl[re] > K - al[i] :
        #    re -= 1

        book = max(book, i + re)

    print(book)


if __name__ == '__main__':
    main()


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

int main() {
  int n,c=0;
  cin >> n;
  vector<int> vec(n);
  for (int i=0; i<n; i++) cin >> vec.at(i);
  vector<int> sorted;
  sorted = vec;
  sort(sorted.begin(),sorted.end());
  for (int i=0; i<n; i++) {
    if (vec.at(i) != sorted.at(i)) c++;
  }
  if (c<3) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int m;
map<string, bitset<256>> mp;
int n;
string e[100];

int main()
{
	cin >> m;
	for (int i = 0; i < m; i++){
		string na;
		int lb, ub;
		cin >> na >> lb >> ub;
		bitset<256> bs;
		for (int i = lb; i <= ub; i++){
			bs.set(i);
		}
		mp[na] = bs;
	}
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> e[i];
	}
	
	stack<bitset<256>> st;
	for (int i = 0; i < n; i++){
		if (mp.count(e[i])){
			st.push(mp[e[i]]);
		}
		else if (isdigit(e[i][0])){
			bitset<256> r;
			r.set(atoi(e[i].c_str()));
			st.push(r);
		}
		else {
			bitset<256> b = st.top(); st.pop();
			bitset<256> a = st.top(); st.pop();
			bitset<256> r;
			for (int j = 0; j < 256; j++){
				for (int k = 0; k < 256; k++){
					if (!a.test(j) || !b.test(k)) continue;
					if (e[i] == "+") r.set((j + k) % 256);
					else if (e[i] == "-") r.set((j - k + 256) % 256);
					else if (e[i] == "*") r.set(j * k % 256);
					else if (e[i] == "/"){
						if (!k){
							cout << "error\n";
							return 0;
						}
						r.set(j / k);
					}
				}
			}
			st.push(r);
		}
	}
	
	bitset<256> bs = st.top();
	cout << "correct\n";
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<vector<int>>x(n,vector<int>(3));
  for(int i=0; i<n; i++){
    for(int j=0; j<3; j++){
      cin >>x[i][j];
    }
  }
  
  bool judge=true;
  for(int i=0; i<n; i++){
    int a=x[i][1]+x[i][2];
    int b=x[i][0];
    if(a%2==1 && b%2==1 && a<=b){
      judge=true;
    }
    else if(a%2==0 && b%2==0 && a<=b){
     judge=true;
    }
    else{
      judge=false;
      break;
    }
  }
  if(judge){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 5760
import numpy as np

N, L = list(map(int, input().split()))
taste = np.array([L + i for i in range(N)])
total = sum(taste)
abs_ta = abs(taste)
smallest = abs_ta[0]
smallest_i = 0
for i in range(1, N):
    if abs_ta[i] < smallest:
        smallest = abs_ta[i]
        smallest_i = i
print(total - taste[smallest_i])


Measured memory_bytes: 21164