akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
//const long long int pl=1000000;

long long int C[100][100]={};
long long int N,res=0,a,b,c,d,sum=0,cou=0,cou2=0;
bool AllSame=true;

string S[105];
int main(){
    cout << fixed << setprecision(18);
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
}



Measured memory_bytes: 3632
#include<iostream>
static const int NMAX = 100;

void PrintArray(const int* A, int N);
int BubbleSort(int* A, int N);

int main() {
    int A[NMAX], n, swapNr;

    std::cin >> n;

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

    swapNr = BubbleSort(A, n);
    PrintArray(A, n);

    std::cout << swapNr << std::endl;

    return 0;
}

void PrintArray(const int* A, int N) {
    for (int i = 0; i < N; i++)
    {
        if (i > 0) {
            std::cout << " ";
        }
        std::cout << A[i];
    }
    std::cout << std::endl;
}

int BubbleSort(int* A, int N) {
    int swapNr;
    bool flag;

    swapNr = 0;
    flag = 1;

    int i = 0;
    while (flag) {
        flag = 0;
        for (int j = N - 1; j > i; j--) {
            if (A[j] < A[j - 1]) {
                int tmp;
                tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                flag = 1;
                swapNr++;
            }
        }
        i++;
    }
    return swapNr;
}


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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define repl(n) for (int l = 0; l < (n); l++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
ll modpow(ll a, ll b, ll m) {
  ll re = 1, k = 1;
  while (k <= b) {
    if (b & k) {
      re *= a;
      re %= m;
    }
    k = k << 1;
    a *= a;
    a %= m;
  }
  return re;
}
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

const ll P = 1e9 + 7;
ll bi(int n, int k) {
  if (n < 0 || k < 0) return 0;
  if (n - k < k) return bi(n, n - k);
  ll re = 1;
  repi(k) {
    re *= n - k + 1 + i;
    re %= P;
    re *= modinv(i + 1, P);
    re %= P;
  }
  return re;
}
int main() {
  int a, b;
  cin >> a >> b;
  cout << (a * b % 2 ? "Yes" : "No") << endl;
}


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

namespace abc140_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var b = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            var sum = 0;
            var x0 = -1;

            foreach (var bx in b)
            {
                if (x0 == -1 || bx < x0)
                {
                    x0 = bx;
                }

                sum += x0;
                x0 = bx;
            }

            sum += b.Last();
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>

using namespace std;

int main() {
	string str;
	cin >> str;

	int N = str.length();

	long long ans = 0;
	long long tmp = 0;
	for (int i = 0; i < (1 << N - 1); i++) {
		tmp = str.at(0) - '0';
		for (int j = 0; j < N - 1; j++) {
			if (i & (1 << j)) {
				ans += tmp;
				tmp = 0;
			}
			tmp = tmp * 10 + str.at(j + 1) - '0';
		}
		ans += tmp;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
a,b,c,x,y=[int(i) for i in input().split()]

if x>=y:
    print( min(y*2*c+a*(x-y), x*a+y*b, 2*c*x) )

else:
    print( min(x*2*c+b*(y-x), x*a+y*b, 2*c*y) )    

Measured memory_bytes: 3060
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll i,j,k,l,m,n,a[100400];
        cin>>n;
        for(i=0;i<n;i++)
            cin>>a[i];
        sort(a,a+n);
        cout<<a[n/2]-a[n/2-1];
        // ll ans=0;
    }
    return 0;
}

Measured memory_bytes: 1024
def modinv2(a,m):
    return pow(a,m-2,m)

def modcomn(n,r,m):
    modcom = [0 for _ in range(n)]
    for i in range(n):
        if i < r-1:
            continue
        if i == r-1:
            modcom[i] = 1
        elif i == r:
            modcom[i] = (i+1)%m
        else:
            div = modinv2(i-r+1,m)
            modcom[i] = (modcom[i-1]*div%m)*(i+1)%m
    return modcom

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
P = 10**9+7

com = modcomn(N-1,K-1,P)

ans = 0

for i in range(N):
    if i >= K-1:
        ans = (ans+A[i]*com[i-1]%P)%P

A.sort(reverse=True)
for i in range(N):
    if i >= K-1:
        ans = (ans-A[i]*com[i-1]%P)%P

print(ans)


Measured memory_bytes: 14416
#include <iostream>
#include <stdio.h>
using namespace std ;

int d ;				// 入力を受ける
int total = 0 ;		// 合計

int main()
{
	while( cin >> d )
	{
		for( int i = 1 ; i < (600/d) ; i ++ )
		{
			total += ( (d*i) * (d*i) * d ) ;
		}

		cout << total << endl ;
		total = 0 ;
	}

	return 0 ;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
template<class OperatorMonoid,
         class Merge = function<OperatorMonoid(OperatorMonoid, OperatorMonoid)> >
struct DualSegmentTree {
    int sz, height;
    const OperatorMonoid e;
    const Merge merge_operator;
    vector<OperatorMonoid> lazy;
 
    DualSegmentTree(OperatorMonoid e, const Merge &h):
        e(e), merge_operator(h) {};
    void init(int nmemb) {
        sz = nmemb;
        lazy.assign(sz << 1, e);

        height = -1;
        while (nmemb) nmemb >>= 1, height++;
    };
 
    inline void propagate(int k) {
        if (k >= sz || lazy[k] == e) return;
        lazy[(k << 1) | 0] = merge_operator(lazy[(k << 1) | 0], lazy[k]);
        lazy[(k << 1) | 1] = merge_operator(lazy[(k << 1) | 1], lazy[k]);
        lazy[k] = e;
    };
    void push_down(int k) {
        for (int i = height; i > 0; i--) {
            propagate(k >> i);
        }
    };
 
    // [l, r)
    void update(int l, int r, OperatorMonoid op) {
        l += sz; r += sz;
        push_down(l);
        push_down(r - 1);
         
        while (l < r) {
            if (l & 1) lazy[l] = merge_operator(lazy[l], op), l++;
            if (r & 1) --r, lazy[r] = merge_operator(lazy[r], op);
 
            l >>= 1;
            r >>= 1;
        }
    };
 
    OperatorMonoid operator [] (int k) {
        k += sz;
        push_down(k);
        return lazy[k];
    };
};
//===

vector<llong> p;
llong n, q;
llong s[200005];
llong t[200005];
llong x[200005];
llong d[200005];
auto f = [](llong l, llong r){return min(l, r);};
DualSegmentTree<llong, decltype(f)> seg(1ll << 60ll, f);

void build() {
    sort(p.begin(), p.end());
    p.erase(unique(p.begin(), p.end()), p.end());
    seg.init(p.size() + 1);
}

llong get_idx(llong x) {
    return lower_bound(p.begin(), p.end(), x) - p.begin();
}

int main() {
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        cin >> s[i] >> t[i] >> x[i];
        p.push_back(s[i] - x[i]);
        p.push_back(t[i] - x[i]);
    }

    for (int i = 0; i < q; i++) {
        cin >> d[i];
        p.push_back(d[i]);
    }

    build();
    for (int i = 0; i < n; i++) {
        llong l = get_idx(s[i] - x[i]);
        llong r = get_idx(t[i] - x[i]);
        seg.update(l, r, x[i]);
    }

    for (int i = 0; i < q; i++) {
        auto a = seg[get_idx(d[i])];
        if (a == (1ll << 60ll)) cout << -1 << '\n';
        else cout << a << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 21992
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    int n;
    cin>>n;
    vector<ll> v(n,0);
    ll sum = 0;
    rep(i,n){
        cin>>v[i];
        sum^=v[i];
    }
    
    vector<ll> ans(n,0);
    rep(i,n){
        ans[i]=v[i]^sum;
    }

    rep(i,n){
        cout<<ans[i]<<" ";
    }
    cout<<endl;




    
return 0;
}


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


namespace Test1 {

    


    class ClassMain {

       
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int L = int.Parse(line);
                int A = int.Parse(Console.ReadLine());
                int B = int.Parse(Console.ReadLine());
                int C = int.Parse(Console.ReadLine());
                int D = int.Parse(Console.ReadLine());

                int day = Math.Max(((A - 1) / C) + 1, ((B - 1) / D) + 1);



                Console.WriteLine(L-day);
            }
        }

        
    }



    
}

Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n-1; i >= 0; i--)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd2(i, s, n) for (ll i = n-1; i >= (s); i--)


int main() {
    int n,  q, sum = 0;
    cin >> n;
    vector<int> S(n);
    rep(i, n) cin >> S[i];
    cin >> q;
    rep(i, q) {
        int key;
        cin >> key;
        rep(i, n) {
            if (S[i] == key) {
                sum++;
                break;
            }
        }

    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+5;
typedef long long LL;
LL f[N][N];
//f[l][r] indicate for the top l+r largest points the maximum total happiness that the number of the points move to left is l
struct Node{
	int a,x;
	bool operator < (const Node &b)const{return a>b.a;} 
}a[N];
int main(){
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i].a),a[i].x=i;
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		for(int j=0;j<i;j++){
			int k=i-j-1;
			f[j+1][k]=max(f[j+1][k],f[j][k]+1ll*a[i].a*abs(a[i].x-j-1));
			f[j][k+1]=max(f[j][k+1],f[j][k]+1ll*a[i].a*abs(a[i].x-(n-k)));
		}
	}
	LL ans=0;
	for(int i=0;i<=n;i++)ans=max(ans,f[i][n-i]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 26432
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {

			int m = sc.nextInt();
			int nMin = sc.nextInt();
			int nMax = sc.nextInt();

			if(m == 0 && nMin == 0 && nMax ==0) {
				break;
			}
			int[] x = new int[m];
			int [] gaps = new int[m-1];

			for(int i = 0; i < m; i++) {
				x[i] = sc.nextInt();
			}
			Arrays.sort(x);

			for(int i = 0; i < m-1; i++) {
				gaps[i] = x[i+1] - x[i];
			}
			int maxIdx = m-nMin-1;
			for(int i = m-nMin-1; i >= m-nMax-1; i--) {
				if(gaps[i] >= gaps[maxIdx]) {
					maxIdx = i;
				}
			}
			System.out.println(m-maxIdx-1);
		}
	}
}


Measured memory_bytes: 56912
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s, t;
    cin >> s >> t;
    t += t;
    int yo = SZ(s);
    int n = SZ(t);
    for(int i = 0; i + yo - 1 < n; i++){
        if(s == t.substr(i, yo)){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> v(n);
    rep(i, 0, n) cin >> v[i].first >> v[i].second;
    sort(all(v));
    ll ans = 0, j = 0;
    priority_queue<ll> q;
    rep(i, 1, m + 1)
    {
        while (v[j].first <= i && j < n)
        {
            q.push(v[j].second);
            j++;
        }
        if (q.empty())
            continue;
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 5792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;

const int N = 1010;

int h, w, a, b, mat[N][N];
ii arr[N];

bool can(int c1, int c2){
	for(int i=0 ; i<c2 ; i++)
		arr[i] = ii(b, i);
	for(int i=c2 ; i<w ; i++)
		arr[i] = ii(h-b, i);
	sort(arr, arr+w);
	memset(mat, 0, sizeof mat);
	for(int i=h-1 ; i>=0 ; i--){
		int cur = (i >= c1 ? w-a : a);
		for(int j=w-1 ; cur>0 && j>=0 ; j --, cur --){
			arr[j].first --;
			if(arr[j].first<0)
				return false;
			mat[i][ arr[j].second ] = 1;
		}
		sort(arr, arr+w);
	}
	for(int i=0 ; i<h ; i++){
		for(int j=0 ; j<w ; j++)
			cout << mat[i][j];
		cout << "\n";
	}
	return true;
}

signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> h >> w >> a >> b;
	for(int i=0 ; i<=h ; i++)
		for(int j=0 ; j<=w ; j++){
			int f1 = i*a + (h-i)*(w-a);
			int f2 = j*b + (w-j)*(h-b);
			if(f1 == f2 && can(i, j))
				return 0;
		}
	cout << "-1\n";
}
















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

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);
	int a, b;
	cin >> a >> b;
	int ans = a + b;
	if (ans % 2 == 0) cout << ans / 2 << "\n";
	else cout << "IMPOSSIBLE" << "\n";
	return 0;
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    string A, B;
    cin >> A;
    cin >> B;

    if(A.size() < B.size()) {
        cout << "LESS" << endl;
        return 0;
    }
    if(A.size() > B.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    REP(i, A.size()) {
        if(A[i] < B[i]) {
            cout << "LESS" << endl;
            return 0;
        }
        if(A[i] > B[i]) {
            cout << "GREATER" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}



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

int main(){
  int n;
  cin >> n;
  int so[n] = {2,11,31,41,61};

  int sonow = 71;
  int i = 5;
  int j;
  while(i < n){
    for(j = 3;j < sonow;j+=2){
      if(sonow%j == 0){
        break;
      }
    }
    if(j >= sonow){
      so[i] = sonow;
      i++;
    }
    sonow += 10;
  }

  for(int i = 0;i < n;i++){
    cout << so[i];
    if(i < n-1){
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}



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


using namespace std;
typedef long long LL;
const int N = 2e5 + 7;
const LL Inf = 1e10;
struct Node{
	LL a,b;	
}st[N << 2];
LL tag;
LL tmp;
LL ans = Inf;
int n,q,A,B;
#define ls (rt << 1)
#define rs (rt << 1 | 1)
#define Mid (L + R >> 1)
void Up(int rt){
	st[rt].a = min(st[ls].a,st[rs].a);
	st[rt].b = min(st[ls].b,st[rs].b);
}
void Build(int L = 1,int R = n,int rt = 1){
	if(L == R){
		st[rt].a = Inf;
		st[rt].b = Inf;
		if(L == A)st[rt].a = -L,st[rt].b = L;
		return;
	}
	Build(L,Mid,ls);
	Build(Mid + 1,R,rs);
	Up(rt);
}
void Qa(int r,int L = 1,int R = n,int rt = 1){
	if(L > r || st[rt].a >= tmp)return;
	if(R <= r)return tmp = st[rt].a,void();
	Qa(r,L,Mid,ls);Qa(r,Mid + 1,R,rs);
}
void Qb(int l,int L = 1,int R = n,int rt = 1){
	if(R < l || st[rt].b >= tmp)return;
	if(L >= l)return tmp = st[rt].b,void();
	Qb(l,L,Mid,ls);Qb(l,Mid + 1,R,rs);
}
void Modify(int x,LL k,int L = 1,int R = n,int rt = 1){
	if(L == R){
		st[rt].a = min(st[rt].a,k - L);
		st[rt].b = min(st[rt].b,k + L);
		return;
	}
	if(x <= Mid)Modify(x,k,L,Mid,ls);
	else Modify(x,k,Mid + 1,R,rs);
	Up(rt);
}
void Get(int L = 1,int R = n,int rt = 1){
	if(L == R)return ans = min(ans,st[rt].a + L),void();
	Get(L,Mid,ls);Get(Mid + 1,R,rs);
}
int main(){
#ifdef WTY
	freopen("in","r",stdin);
#endif
	cin >> n >> q >> A >> B;
	Build();
	for(int i = 1,last = B,x; i <= q; i++){
		scanf("%d",&x);
		LL val = 0;
		tmp = Inf;
		Qa(x);
		val = tmp + x;
		tmp = Inf;
		Qb(x + 1);
		val = min(val,tmp - x) + tag;
		tag += abs(x - last);
		Modify(last,val - tag);
		last = x;
	}
	Get();
	cout << ans + tag << endl;
	return 0;
}


Measured memory_bytes: 10496
#include <bits/stdc++.h>
// C - Exam and Wizard

using namespace std;

vector<int> big;
int A[100001],B[100001];

int main() {
    int N,i,cnt3;
    long long cnt1,cnt2;

    scanf("%d",&N);

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

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

    cnt1 = 0;
    cnt3 = 0;
    for (i = 0;i < N;i++) {
        if (A[i] < B[i]) {
            cnt1 += (B[i] - A[i]);
            cnt3++;
        }
        else if (A[i] > B[i])
            big.push_back(A[i] - B[i]);
    }

    sort(big.rbegin(),big.rend());

    cnt2 = 0;
    for (i = 0;i < big.size();i++) {
        if (cnt2 >= cnt1)
            break;

        cnt2 += big[i];
    }

    if (cnt2 >= cnt1)
        printf("%d\n",cnt3 + i);
    else
        printf("-1\n");

    return 0;
}


Measured memory_bytes: 1408
#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 = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    pair<pair<int, int>, int> cities[M];
    rep(i, M){
        int p, y; cin >> p >> y;
        cities[i] = make_pair(make_pair(p, y), i);
    }
    sort(cities, cities+M);

    pair<int, int> ans[M];
    ans[cities[0].second] = make_pair(cities[0].first.first, 1);
    for(int i = 1; i < M; i++){
        if(cities[i-1].first.first == cities[i].first.first){
            ans[cities[i].second] = make_pair(cities[i].first.first, ans[cities[i-1].second].second + 1);
        }
        else{
            ans[cities[i].second] = make_pair(cities[i].first.first, 1);
        }
    }
    rep(i, M){
        printf("%06d%06d\n", ans[i].first, ans[i].second);
    }
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  double N, T, A, a, b = 0;
  cin >> N >> T >> A;
  vector<int> H(N),array(N),marray(N);
  for (int i = 0; i < N; i++) cin >> H[i];
 
  int answer = 1;
  for (int i = 0; i < N; i++) {
    a = T-H[i]*0.006-A;
    if (a < 0) a = -a;
    if (i == 0) b = a;
    if (a < b) {
      b = a;
      answer = i + 1;
    }
  }
  cout << answer << endl;
}

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

using namespace std;

int n, m;
map<string, int> mp;

int main(void)
{
	cin >> n;
	string s;
	for(int i = 0; i < n; i++){
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	for(int i = 0; i < m; i++){
		cin >> s;
		mp[s]--;
	}
	int ans = 0;
	for(auto it = mp.begin(); it != mp.end(); it++){
		ans = max(ans, it->second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    REP(i, S.size()) {
        if (S[i] == '9') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll k, q;
  cin >> k >> q;
  vector<ll> d(k);
  rep(i, k) cin >> d[i];
  vector<ll> n(q), x(q), m(q);
  rep(i, q) cin >> n[i] >> x[i] >> m[i];

  rep(i, q) {
    vector<ll> dd = d;
    rep(j, k) {
      dd[j] %= m[i];
      if (dd[j] == 0) dd[j] = m[i];
      if (j) dd[j] += dd[j - 1];
    }
    x[i] %= m[i];
    ll sum = x[i] + dd[k - 1] * ((n[i] - 1) / k);
    if ((n[i] - 1) % k != 0) sum += dd[(n[i] - 1) % k - 1];
    cout << n[i] - 1 - sum / m[i] << endl;
  }




  
  return 0;
}

Measured memory_bytes: 512
import sys
input=sys.stdin.readline
    
def main():
    n,m=map(int,input().split())
    H=list(map(int,input().split()))
    Edges=[[] for _ in range(n)]
    for _ in range(m):
        a,b=map(int,input().split())
        a-=1; b-=1
        Edges[a].append(b)
        Edges[b].append(a)
    #print(Edges)
    ans=0
    for i,h in enumerate(H):
        for to in Edges[i]:
            if H[to]>=h:
                break
        else:
            #print(i)
            ans+=1
    print(ans)
    
if __name__=='__main__':
    main()

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

using namespace std;

typedef long long LL;
typedef unsigned long UL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)

int main()
{
    int a, b, c, d;
    string str;
    cin >> str;
    a = str[0] - '0';
    b = str[1] - '0';
    c = str[2] - '0';
    d = str[3] - '0';

    if (a + b + c + d == 7) 
    {
        cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
        return 0;
    }
    if (a - b + c + d == 7) 
    {
        cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
        return 0;
    }
    if (a + b - c + d == 7)
    {
        cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
        return 0;
    }
    if (a + b + c - d == 7)
    {
        cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
        return 0;
    }
    if (a - b - c + d == 7)
    {
        cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
        return 0;
    }
    if (a + b - c - d == 7)
    {
        cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
        return 0;
    }
    if (a - b + c - d == 7)
    {
        cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
        return 0;
    }

    return 0;
}

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

typedef long long ll;

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

  vector<int> a(5);
  for (auto& x : a) cin >> x;
  sort(a.begin(), a.end());
  int ans = 1000000;
  do {
    int tmp = 0;
    for (int i = 0; i < 5; i++) {
      while (tmp % 10 != 0) ++tmp;
      tmp += a[i];
    }
    ans = min(ans, tmp);
  } while (next_permutation(a.begin(), a.end()));
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	string s;
	cin >> s;
	map<char, bool> M;
	for (auto o : s)
	{
		if(M[o])
		{
			cout << "no" << endl;
			return 0;
		}
		M[o] = 1;
	}
	cout << "yes" << endl;
	return 0;
}

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

int main() {
  int N,M; cin >> N >> M;
  vector<int> p(M); vector<string> S(M);
  for (int i =0; i<M; i++) cin >> p.at(i) >> S.at(i);
  
  vector<int> count(N,0);
  for (int i =M-1; i>=0; i--) {
    if (S.at(i) == "AC") {
      count.at(p.at(i)-1) =1;
    } else if(S.at(i) == "WA" && count.at(p.at(i)-1) != 0) {
      count.at(p.at(i)-1)++;
    }
  }
  
  int correct =0, penalty =0;
  for (int i =0; i<N; i++) {
    if (count.at(i) != 0) {
      penalty += count.at(i) -1;
      correct++;
    }
  }
  cout << correct << " " << penalty << endl;
}

Measured memory_bytes: 7232
/*
  Contest 113
  A - Discount Fare
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    int x = 0, y = 0;
    std::cin >> x >> y;
    std::cout << x + (y >> 1) << std::endl;

    return 0;
}


Measured memory_bytes: 3588
nk = input().split()
n = int(nk[0])
k = int(nk[1])
t = [0]*n

for i in range(k):
    d = int(input())
    a = input().split()
    a = [int(x) for x in a]
    for j in range(d):
        t[a[j]-1] +=1
    
res= 0
for i in range(n):
    if t[i] == 0:
        res += 1
    
print(res)

    

Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int height = scanner.nextInt();
		int width = scanner.nextInt();
		int area = height*width;
		int perimeter = 2*(height+width);
		System.out.println(area + " " + perimeter);
		scanner.close();
	}
}



Measured memory_bytes: 26104
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
 
int n,m,r;
const int INF=1e7;
int d[3][200][200];
int dp[1001][200];
 
int main(){
 
 
	while(scanf("%d %d",&n,&m),n){

		fill(&d[0][0][0],&d[3][0][0],INF);
		
		for(int i=0;i<n;i++) d[0][i][i]=d[1][i][i]=0;
/*		
	   for(int i=0;i<n;i++){
		  for(int j=0;j<n;j++) d[0][i][j]=d[1][i][j]=INF;
		  d[0][i][i]=d[1][i][i]=0;
	   }
*/	


	   for(int i=0;i<m;i++){
		  int x,y,t;
		  char c;
		  scanf("%d %d %d %c",&x,&y,&t,&c);
		  x--; y--;
		  
		  d[c=='L'][x][y]=min(d[c=='L'][x][y],t);
		  d[c=='L'][y][x]=min(d[c=='L'][y][x],t);
	   }
		
	   for(int k=0;k<n;k++){
		  for(int i=0;i<n;i++){
			 for(int j=0;j<n;j++){
				d[0][i][j]=min(d[0][i][j],d[0][i][k]+d[0][k][j]);
				d[1][i][j]=min(d[1][i][j],d[1][i][k]+d[1][k][j]);
			 }
		  }
	   }
	   
	   int now,z;
	   scanf("%d",&r);
	   scanf("%d",&now); now--;

	   fill(&dp[0][0],&dp[1001][0],INF);
	   dp[0][now]=0;
		
	   for(int i=0;i<r-1;i++){
		   scanf("%d",&z); z--;
		   
		   for(int j=0;j<n;j++){
			   dp[i+1][j]=min(dp[i+1][j],dp[i][j]+d[1][now][z]);
			   for(int k=0;k<n;k++){
				   // 
				   dp[i+1][k]=min(dp[i+1][k],dp[i][j]+d[1][now][j]+d[0][j][k]+d[1][k][z]);
			   }
			   
			   
		   }
		   now=z;
	   }


/*
	   //int res=INF;
	   for(int i=1;i<r;i++){
		  for(int j=0;j<n;j++){
							
			 for(int k=0;k<n;k++){
				dp[i][k]=min(dp[i][k],dp[i-1][j]+d[1][z[i-1]][j]+d[0][j][k]+d[1][k][z[i]]);
				//if(i==r-1 && res>dp[i][k]) res=dp[i][k];
			 }
			 dp[i][j]=min(dp[i][j],dp[i-1][j]+d[1][z[i-1]][z[i]]);
			 //if(i==r-1 && res>dp[i][j]) res=dp[i][j];
		  }
	   }
*/
	   printf("%d\n",*min_element(dp[r-1],dp[r]));
		
	}
}

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

int main() {
  int N; cin >> N;
  int C[N+10]; REP(i,N) cin >> C[i];
  sort(C,C+N);
  cout << C[N-1]-C[0] << endl;

  return 0;
}

Measured memory_bytes: 256
/**
 *  author: ivanzuki   
 *  created: Sun Sep 13 2020
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int r, c, n;
  cin >> r >> c >> n;
  vector<pair<int, int>> up, down, left, right;
  for (int i = 0; i < n; i++) {
    vector<int> x(2), y(2);
    int bordering = 0;
    for (int j = 0; j < 2; j++) {
      cin >> x[j] >> y[j];
    }
    for (int j = 0; j < 2; j++) {
      if (x[j] == 0 || x[j] == r || y[j] == 0 || y[j] == c) {
        bordering += 1;
      }
    }
    if (bordering == 2) {
      for (int j = 0; j < 2; j++) {
        if (x[j] == 0) {
          up.push_back(make_pair(y[j], i));
        } else if (x[j] == r) {
          down.push_back(make_pair(y[j], i));
        } else if (y[j] == 0) {
          left.push_back(make_pair(x[j], i));
        } else if (y[j] == c) {
          right.push_back(make_pair(x[j], i));
        }
      }
    }
  }
  // counterclockwise
  sort(up.rbegin(), up.rend());
  sort(left.begin(), left.end());
  sort(down.begin(), down.end());
  sort(right.rbegin(), right.rend());
  vector<int> s;
  for (auto& p : up) {
    int id = p.second;
    if (!s.empty() && s.back() == id) {
      s.pop_back();
    } else {
      s.push_back(id);
    }
  }
  for (auto& p : left) {
    int id = p.second;
    if (!s.empty() && s.back() == id) {
      s.pop_back();
    } else {
      s.push_back(id);
    }
  }
  for (auto& p : down) {
    int id = p.second;
    if (!s.empty() && s.back() == id) {
      s.pop_back();
    } else {
      s.push_back(id);
    }
  }
  for (auto& p : right) {
    int id = p.second;
    if (!s.empty() && s.back() == id) {
      s.pop_back();
    } else {
      s.push_back(id);
    }
  }
  cout << (s.empty() ? "YES" : "NO") << '\n';
  return 0;
}

Measured memory_bytes: 5560
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

char s[10000];
int main() {
  int n;
  scanf("%d", &n);
  vector<int> ret(26, INF);
  while (n--) {
    scanf("%s", s);
    vector<int> cnt(26);
    for (int i = 0; s[i]; ++i) {
      cnt[s[i] - 'a']++;
    }
    for (int k = 0; k < 26; ++k) ret[k] = min(ret[k], cnt[k]);
  }
  string ans;
  for (int k = 0; k < 26; ++k) {
    if (ret[k] == INF) continue;
    while (ret[k]--) ans += (char)('a' + k);
  }
  puts(ans.c_str());
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int x;
  cin>>x;

  int i,k=0;
  for(i=1;k<x;i++) k+=i;
  cout<<i-1<<endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DMakeThemEven solver = new DMakeThemEven();
        solver.solve(1, in, out);
        out.close();
    }

    static class DMakeThemEven {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            /* == 入力部       開始 == */
            int h = in.nextInt();                           // 盤面の横幅
            int w = in.nextInt();                           // 盤面の縦幅
            List<DMakeThemEven.Operation> operations = new ArrayList<>(); // 解答
            /* == 入力部       開始 == */

            /* == 計算部(1)    開始 == */
            /* vParity[i] = (i + 1,1)要素から(i + 1,y + 1)要素までの和が奇数ならtrue -> コインを下に押し付けます */
            boolean[] vParity = new boolean[w];
            for (int y = 0; y < h - 1; y++) {   // 上から下へ(最終行を除く)
                for (int x = 0; x < w; x++) {   // 左から右へ
                    vParity[x] ^= in.nextInt() % 2 == 1; // 偶奇の和はXORで求まります
                    if (vParity[x]) { // 奇数ならば下の行にコインを押し付けます
                        operations.add(new DMakeThemEven.Operation(x + 1, y + 1, x + 1, y + 2));
                    }
                }
            }
            /* == 計算部(1)    終了 == */


            /* == 計算部(2)    開始 == */
            /* hParity = (x + 1, h)要素が奇数ならtrue -> コインを右に押し付ける */
            boolean hParity = false;
            for (int x = 0; x < w - 1; x++) {   // 左から右へ
                // (x + 1, h)要素の偶奇性は [もともとその場所にあるコイン] XOR [上から押し付けられたコイン]
                //                                                   XOR [左から押し付けられたコイン]
                hParity ^= vParity[x];
                hParity ^= in.nextInt() % 2 == 1;
                if (hParity) { // 奇数ならば右の列にコインを押し付けます
                    operations.add(new DMakeThemEven.Operation(x + 1, h, x + 2, h));
                }
            }
            /* == 計算部(2)    終了 == */


            /* == 出力部    開始 == */
            out.println(operations.size());
            for (DMakeThemEven.Operation operation : operations) {
                out.print(operation.y1);
                out.print(' ');
                out.print(operation.x1);
                out.print(' ');
                out.print(operation.y2);
                out.print(' ');
                out.println(operation.x2);
            }
            /* == 出力部    終了 == */
        }

        public static class Operation {
            int x1;
            int y1;
            int x2;
            int y2;

            public Operation(int a, int b, int c, int d) {
                this.x1 = a;
                this.y1 = b;
                this.x2 = c;
                this.y2 = d;
            }

        }

    }
}



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

int H,W;
auto g = make_vec<char>(401,401);
auto visited = make_vec<char>(401,401);
int w_visited=0;
int b_visited=0;

int di[] = {1,-1,0,0};
int dj[] = {0,0,1,-1};
void dfs(int i,int j){
    visited[i][j]=true;

    if(g[i][j]=='.') w_visited++;
    else b_visited++;

    REP(k,4){
        int ni = i + di[k];
        int nj = j + dj[k];
        if(ni < 0 || nj < 0 || ni >= H || nj >= W || g[i][j] == g[ni][nj]) continue;
        if(visited[ni][nj]) continue;
        dfs(ni,nj);
    }    
}

int main() {
    cin >> H >> W ;

    REP(i,H) REP(j,W) cin >> g[i][j];

    vector<P_ii> v;
    v.push_back({w_visited,b_visited});
    REP(i,H) REP(j,W){
        if(visited[i][j]) continue;
        dfs(i,j);
        v.push_back({w_visited,b_visited});
    }

    ll ans=0;
    for(int i=1;i<v.size();i++){
        ans += (v[i].first - v[i-1].first)*(v[i].second - v[i-1].second);
    }

    pl(ans)

    return 0;
}

Measured memory_bytes: 8064
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	string N; cin >> N;
	int K; cin >> K;
	vector<vector<vector<ll>>> dp(
		N.length() + 1, vector<vector<ll>>(
			K + 1, vector<ll>(2, 0)
			)
	);
	dp[0][0][0] = 1;
	for (int i = 1; i <= N.length(); ++i) {
		int d = N[i - 1] - '0';
		for (int j = 0; j <= K; ++j) {
			if (j < K)
				dp[i][j + 1][1] += 9 * dp[i - 1][j][1];
			dp[i][j][1] += dp[i - 1][j][1];
			if (d) {
				if (j < K) {
					dp[i][j + 1][1] += (d - 1LL) * dp[i - 1][j][0];
					dp[i][j + 1][0] += dp[i - 1][j][0];
				}
				dp[i][j][1] += dp[i - 1][j][0];
			}
			else
				dp[i][j][0] += dp[i - 1][j][0];
		}
	}
	cout << (dp[N.length()][K][0] + dp[N.length()][K][1]) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define A 100
int main(){
  int i,j,n,flag=0,hozon;
  int sort[A];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&sort[i]);
  }
  
  for(i=0;i<=n-1;i++){
     for(j=n-1;j>=i+1;j--){
       if(sort[j]<sort[j-1]){
	 hozon = sort[j];
	 sort[j] = sort[j-1];
	 sort[j-1] = hozon;
	 flag++;
       }
     }
  }

  for(i=0;i<=n-1;i++){
    if(i==n-1){
      printf("%d",sort[i]);
    }
    else printf("%d ",sort[i]);
  }
  printf("\n%d\n",flag);

  return 0;
}
  
	 
	 



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

bool isPal (string s) {
	string t = s;
	reverse (t.begin(), t.end());
	return s == t;
}

int main() {
	string s;
	cin >> s;
	bool flag1 = isPal (s);
	string t = s.substr (0, s.length() / 2);
	bool flag2 = isPal (t);
	t = s.substr (s.length() / 2 + 1);
	bool flag3 = isPal (t);
	if (flag1 && flag2 && flag3) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

#define MOD 1000000007
#define MAX 100005
#define ll long long
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define ss(x) scanf("%s",x)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define vpii vector<pii >
#define vll vector<ll>
#define clr(x) memset(x,0,sizeof(x))

#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll power(ll a,ll b,ll m){
	ll x=1%m; a%=m;
	while(b){
		if((1&b)) x = x * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return x;
}

int A[MAX];

int main(){
	int k;sd(k);
	for(int i=1;i<=k;i++) sd(A[i]);
	ll l=2,r=2;
	for(int i=k;i>0;i--){
		ll big = r/A[i];
		ll lo = l/A[i];
		if(l%A[i]!=0) ++lo;
		if(lo>big){
			printf("-1");
			return 0;
		}
		l=A[i]*lo;
		r=(big+1)*A[i]-1;
	}
	printf("%lld %lld",l,r);
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;

    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(a%2==0 && !(a%3==0 || a%5==0)){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256