akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

/*
セグメント木を利用したRMQ
初期化 O(N)
クエリ O(log(N))

*/
template<class Val, class Cmp>
class DynamicRMQ {
    int n;
    Val init;
    vector<Val> dat;
    Cmp cmp;
    inline Val query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return init;
        if (a <= l&&r <= b) return dat[k];
        else {
            Val vl, vr;
            vl = query(a, b, k << 1, l, (l + r) >> 1);
            vr = query(a, b, (k << 1) | 1, (l + r) >> 1, r);
            return cmp(vl, vr) ? vl : vr;
        }
    }
public:
    DynamicRMQ() {}
    DynamicRMQ(int n_, Val init_) :n(1), init(init_) {
        for (; n<n_; n <<= 1);
        dat = vector<Val>(n << 1, init);
    }
    void update(int k, Val a) {
        k += n;
        dat[k] = a;
        while (k > 1) {
            k >>= 1;
            dat[k] = cmp(dat[k << 1], dat[(k << 1) | 1]) ? dat[k << 1] : dat[(k << 1) | 1];
        }
    }
    Val query(int a, int b) {
        return query(a, b, 1, 0, n);
    }
};

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

    int N, INF = 1 << 30;
    cin >> N;
    vi P(N), A(N + 1);
    rep(i, N) {
        cin >> P[i];
        A[P[i]] = i;
    }

    using RMQ = DynamicRMQ<pii, less<pii> >;
    using T = tuple<pii, int, int>;
    RMQ rmq[2];
    rep(i, 2)rmq[i] = RMQ(N, mp(INF,i));
    rep(i, N)rmq[i&1].update(i, mp(P[i],i));

    priority_queue<T, vector<T>, greater<T> > Q;
    Q.push(T(rmq[0].query(0, N), 0, N));
    vi ans;
    
    auto f = [&](int l, int r) {
        if (l >= r)return;
        pii p = rmq[l&1].query(l, r);
        Q.push(T(p, l, r));
        return;
    };

    while (sz(Q)) {
        pii p;
        int x, m, l, r;
        tie(p, l, r) = Q.top();
        Q.pop();
        tie(x, m) = p;
        // l=<m<n<r
        int y, n;
        tie(y, n) = rmq[!(l&1)].query(m + 1, r);
        ans.push_back(x);
        ans.push_back(y);
        rmq[0].update(m, mp(INF, m));
        rmq[1].update(n, mp(INF, n));
        f(l, m);
        f(m+1, n);
        f(n + 1, r);
    }

    rep(i, N)cout << ans[i] << (i != N - 1 ? ' ' : '\n');
}


Measured memory_bytes: 12788
#include <stdio.h>
#include <math.h>

int main(void)
{
	int num = 0, numa, numb, key, i, j;
	int a[20000], b[600];

	scanf("%d", &numa);

	for (i = 0; i < numa; i++) {
		scanf("%d", &a[i]);
	}

	scanf("%d", &numb);
	
	for (i = 0; i < numb; i++) {
		scanf("%d", &b[i]);
	}

	for (j = 0; j < numb; j++) {
		i = 0;
		key = b[j];
		a[numa] = key;
		while (a[i] != key) {
			i++;
		}
		if (i != numa) {
			num++;
		}
	}

	printf("%d\n", num);
	
	return 0;
}


Measured memory_bytes: 1992
#include<stdio.h>
int main(void){
  int H,N,c;
  scanf("%d %d",&H,&N);
  int A[N];
  for(int i=0;i<N;i++){
   scanf("%d",&A[i]);
   c+=A[i];
  }
  if(c>=H)printf("Yes");
   else printf("No");
  return 0;
}

Measured memory_bytes: 2516
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();
            int[] x = in.nextIntArray(n);
            int answer = 0;
            for (int i = 0; i < n; i++) {
                answer += Math.min(2 * Math.abs(x[i]), 2 * Math.abs(k - x[i]));
            }
            out.println(answer);
        }

    }

    static class InputReader {
        private int lenbuf = 0;
        private int ptrbuf = 0;
        private InputStream in;
        private byte[] inbuf = new byte[1024];

        public InputReader(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (lenbuf == -1) throw new InputMismatchException();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = in.read(inbuf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

    }
}



Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std ;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define ll long long
typedef long double ld ;
typedef vector<int> vi ;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define fre(i,a,b) for(int i=a;i<=b;i++)
#define rpe(i,a,b) for(i=a-1;i>=b;i--)
#define rp(i,n) rep(i,0,n)
#define fr(i,n) fre(i,1,n)
#define trav(a, x) for (auto& a : x)
#define pb push_back
#define F first
#define S second
#define pb push_back
#define prec(n) fixed<<setprecision(n)
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define mod 1e9+7

int32_t main(){

    IOS ;
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int n, k ;
    cin >> n ;

    map<string, int> m ;

    while(n--)
    {
        string s ;
        cin >> s ;

        sort(all(s)) ;

        m[s]++ ;
    }

    int ans = 0 ;
    for(auto t:m)
    {
        ans += t.S*(t.S-1)/2 ;
    }

    cout << ans << endl ;


return 0;}
///.... -dASH


Measured memory_bytes: 11264
#include <stdio.h>
#define n_max 500001
#define SWAP(a,b) { int temp = a; a = b; b = temp; }

void maxHeap(int *,int);
void buildmaxHeap(int *);
int H;

int main(){
  int i;
  int A[n_max];
  
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  
  buildmaxHeap(A);
  
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  
  return 0;
}

void maxHeap(int *A,int i){
  int l, r, largest;
  int tmp;
  
  l=i*2;
  r=i*2+1;
  
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  
  if(l<=H && A[l] > A[i])
    largest = l;
  else largest = i;

  if(r<=H && A[r] > A[largest])
    largest = r;

  if(largest != i){// i の子の方が値が大きい場合
    SWAP(A[i],A[largest]);
    maxHeap(A,largest);// 再帰的に呼び出し
  }
}

void buildmaxHeap(int *A){
  int i;
  for(i=H/2;i>=1;i--) maxHeap(A,i);
}




Measured memory_bytes: 3684
def main():
    N = int(input())
    A = list(map(int, input().split()))

    X1 = 0

    for i in range(N):
        if i % 2 == 0:
            X1 += A[i]
        else:
            X1 -= A[i]

    X = [0] * N
    X[0] = X1
    for i in range(1,N):
        X[i] = 2 * A[i-1] - X[i-1]

    print(*X)



main()

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:


int n;
string s;
int ary[100010];

bool check(){
	bool ok=true;

	rep(i,n){
		const int prv=(i+n-1)%n,nxt=(i+1)%n;
		//cout << i << " " << s[i] << " " << ary[prv] << ary[i] << ary[nxt] << endl; 

		if(ary[i]==(s[i]=='x')){
			if(ary[prv]!=ary[nxt])
				ok=false;
		}else{
			if(ary[prv]==ary[nxt])
				ok=false;
		}
		//cout << ok << endl;
	}
	return ok;
}

void output(){
	rep(i,n) cout << ((ary[i])?'W':'S'); 
	cout << endl;
}

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

	rep(mask,4){
		ary[0]=(mask>>0)&1;
		ary[1]=(mask>>1)&1;
		
		rep(i,2,n) ary[i]=(ary[i-2]^ary[i-1]^(s[i-1]=='x'));

		//output();

		if(check()){
			output();
			return 0;
		}
	}

	cout << -1 << endl;
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

ll x, y, z, k;

int main()
{
    cin >> x >> y >> z >> k;
    vector<ll> A(x), B(y), C(z);
    for (int i = 0; i < x; i++)
        cin >> A[i];
    for (int i = 0; i < y; i++)
        cin >> B[i];
    for (int i = 0; i < z; i++)
        cin >> C[i];
    vector<ll> D, E;
    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < y; j++)
        {
            D.push_back(A[i] + B[j]);
        }
    }
    sort(D.rbegin(), D.rend());
    int d = D.size();
    for (int i = 0; i < min(d, 3000); i++)
    {
        E.push_back(D[i]);
    }
    vector<ll> P;
    for (int i = 0; i < E.size(); i++)
    {
        for (int j = 0; j < z; j++)
        {
            P.push_back(E[i] + C[j]);
        }
    }
    sort(P.rbegin(), P.rend());
    for (int i = 0; i < k; i++)
    {
        cout << P[i] << endl;
    }
}

Measured memory_bytes: 43144
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  ll n,k;cin >> n >>k;
  vector<ll> v(n);
  repi(i,0,n) cin >> v[i];
  vector<ll> vsum(n-k+1);
  ll sum =0;
  for(ll j=0;j<k;++j)sum += v[j];
  vsum[0] = sum;
  for(ll l=1;l<n-k+1;++l){
  	vsum[l] = vsum[l-1] - v[l-1] + v[k-1+l];
  }
  sort(all(vsum));
  ll out = vsum[vsum.size()-1];
  cout << fixed << setprecision(10) << (double)(out+k)/2.0d<< endl;

  return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */

void solve() {
	int n, k;
	cin >> n >> k;
	int d[k];
	set<int> st;
	int a;
	for (int i = 0; i < k; i++) {
		cin >> d[i];
		for (int j = 0; j < d[i]; j++) {
			cin >> a;
			st.insert(a);
		}
	}
	cout << n - st.size() << "\n";
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN = 1e5+7;

LL covered(const vector< LL > &A, LL z) {
    LL ans = 0;
    LL idx = A.size();
    for (LL i = 0; i < A.size(); i++) {
//        LL y = z-A[i];
//        ans += A.end() - lower_bound(A.begin(), A.end(), y);
        while (idx > 0 && A[idx-1]+A[i] >= z) idx--;
        ans += A.size()-idx;
    }
//    cout << z << " -> " << ans << endl;
    return ans;
}

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

    LL n, m;
    cin >> n >> m;

    vector< LL >A(n);
    for (LL i = 0; i < n; i++) cin >> A[i];

    sort(A.begin(), A.end());

    LL lo = A.front()*2, hi = A.back()*2;

    while (lo <= hi) {
        LL mid = (lo+hi)/2;

        if (covered(A, mid) < m) hi = mid-1;
        else lo = mid+1;
    }

    ///hi has ans
    vector< LL >suffix(A);
    suffix.push_back(0);
    for (LL i = n-1; i >= 0; i--) suffix[i] += suffix[i+1];

    LL ans = 0;
    LL idx = A.size();
    for (LL i = 0; i < n; i++) {
//        LL idx = upper_bound(A.begin(), A.end(), hi-A[i])-A.begin();
        while (idx > 0 && A[idx-1]+A[i] > hi) idx--;
        m -= n-idx;
        ans += suffix[idx]+(n-idx)*A[i];
//        cout << i << " -> " << idx << endl;
    }

    assert(m >= 0);
    ans += m*hi;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	a <- readInt
	s <- getLine
	putStrLn $ which s "red" $ 3200 <= a

Measured memory_bytes: 508
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int total = 0;
		for (int i = 0; i < n; i++) {
			total += -sc.nextInt() + sc.nextInt() + 1;
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 26964
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

class Combi {
private:
	vector<lint> fac, inv, finv;

	void init(int N) {
		fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;

		for (int i = 2; i < N; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}

public:
	Combi(int N = 10000) : fac(N + 1), inv(N + 1), finv(N + 1) { init(N + 1); }

	lint Cmod(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

	lint Pmod(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * finv[n - k] % MOD;
	}
};

int main() {

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

	int N, K;
	cin >> N >> K;

	Combi C;

	for (int i = 1; i <= K; i++) cout << C.Cmod(N - K + 1, i) * C.Cmod(K - 1, i - 1) % MOD << "\n";

	return 0;
}

Measured memory_bytes: 512
#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>;
#define INF 1e9

void fact(int n, int &ret) {
  ret = 1;
  while (n > 0) {
    ret *= n--;
  }
}
bool is_permutation(int n) {
  const string s = to_string(n);
  vector<bool> num(s.size());
  int i;
  rep(i, s.size()) {
    int j = s[i] - '1';
    // cout << j << endl;
    if (0 <= j && j < s.size() && num.at(j) == true){
      // puts("doubled\n");
      return false;
    }
    else if (0 <= j && j < s.size())
      num.at(j) = true;
  }
  // rep (i, s.size())
  //   cout << num[i] << " ";
  // cout << endl;
  rep (i, s.size()) {
    if (num[i] == false){
      // puts("null\n");
      return false;
    }
  }
  return true;
}
int cnt_dict_order(string s, string t) {
  int ret=0, i;
  int p = stoi(s), q = stoi(t);
  int start = min(p, q), end = max(p, q);
  for (i = start; i < end; i++) {
    // cout << i << " " << is_permutation(i);
    if (is_permutation(i)) {
      // cout << "permutation";
      ret++;
    }
    // cout << endl;
  }
  return ret;
}
int main() {
  int i, j, k, N; cin >> N;
  string s, t;
  int P, Q;
  vector<int> p(N);
  vector<int> q(N);
  vector<int> a(N);
  rep (i, N) cin >> p[i], s+=to_string(p[i]);
  rep (i, N) cin >> q[i], t+=to_string(q[i]);
  rep (i, N) a.at(i) = i+1;
  int cnt = 0;
  do {
    if (a==p) P = cnt;
    if (a==q) Q = cnt;
    cnt++;
  } while (next_permutation(a.begin(), a.end()));
  cout << abs(P - Q) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <limits>

using namespace std;

int main()
{
  cin.ignore(numeric_limits<streamsize>::max(), '\n');

  istream_iterator<int> ii {cin};
  istream_iterator<int> eos {};

  vector<int> vi {ii, eos};

  ostream_iterator<int> oi {cout, " "};

  reverse_copy(++vi.begin(), vi.end(), oi);

  cout << *(vi.begin()) <<endl;
}


Measured memory_bytes: 3096
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
//#include <functional>

constexpr int32_t MIN_RANGE = -1000000;
constexpr int32_t MAX_RANGE =  1000000;

int main(){
    int32_t K,X;
    std::cin >> K >> X;

    int32_t lower_boud = std::max(MIN_RANGE, X - K + 1);
    int32_t upper_boud = std::min(MAX_RANGE, X + K - 1);

    for(int32_t i = lower_boud; i <= upper_boud; i++){
        std::cout << i << " ";
    }

    return 0;
}


Measured memory_bytes: 256
var data = require('fs').readFileSync('/dev/stdin', 'utf8');
var input = data.trim().split("\n");
var n = input.shift();
for (var i = 0; i < n; i++) {
    var dataset = input[i].split(/\s+/);

    console.log(scores(dataset) ? "Yes" : "No");
}

function scores(dataset) {
    var left = true;
    var right = true;
    dataset += '!';
    for (var i = 0; i < dataset.length; i++) {
        if (dataset[i] == dataset[i + 1])
            return false;
        if (dataset[i] == 'L' && i % 2 == 1)
            left = false;
        if (dataset[i] == 'R' && i % 2 == 0)
            left = false;
        if (dataset[i] == 'L' && i % 2 == 0)
            right = false;
        if (dataset[i] == 'R' && i % 2 == 1)
            right = false;
    }

    return (left | right);
}

Measured memory_bytes: 18060
def resolve():
    A, B, C, X = [int(input()) for _ in range(4)]
    ans = 0
    for a in range(min(X // 500, A) + 1):
        for b in range(min(X // 100, B) + 1):
            for c in range(min(X // 50, C) + 1):
                if a * 500 + b * 100 + c * 50 == X:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()


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

int main(){
int N,num;
  cin>>N;
vector<int>S(N);
for(int i=0; i<N-1; i++){

    cin>>num;
    S.at(num-1)++;
}
for(int i=0;i<N;i++){
    cout<<S.at(i)<<endl;
}
}

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

//100以下の素数の列挙
int pr[25]={2,3,5,7,11,13,17,19,23
  ,29,31,37,41,43,47,53,59,61,67,71
  ,73,79,83,89,97};
//素因数の個数
int pd[25]={0};
//N!の素因数分解
int setp(int m){
  if(m==1)return 0;
  int n=m,i=0;
  while(n>1){
    if(n%pr[i]==0){
      pd[i]++; n /= pr[i];i--;
    }
    i++;
  }
  return setp(m-1); 
}

//m個以上あるの素因数の個数。
int num(int m){
  int c=0;
 for(int i=0;i<25;i++)if(pd[i]>=m)c++;
  return c;
}

int N,cnt=0;

int main(){
  cin >> N;
  setp(N);
  
  //cntの計算
  //p4q4r2の場合
  cnt+=num(4)*(num(4)-1)*(num(2)-2)/2;
  //p14q4の場合
  cnt+=num(14)*(num(4)-1);
  //p24q2の場合
  cnt+=num(24)*(num(2)-1);
  //p74の場合
  cnt+=num(74);
  
  cout << cnt << endl;
  return 0;
}


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

using namespace std;

int main() {
	long long number_1, number_2, sum;
	
	while(scanf("%ld %ld", &number_1, &number_2) != EOF) {
		sum = number_1 + number_2;
		
		stringstream result;
		result << sum;
		
		cout << result.str().size() << endl;
	}	
	return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int x,maxx,minn,k;

#define getchar() (S==T&&(T=(S=BB)+fread(BB,1,1<<15,stdin),S==T)?EOF:*S++)
char BB[1 << 16], *S = BB, *T = BB;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*f;
}

int main()
{
	minn=0x3f3f3f3f;
	for (int i=1; i<=5; i++)
	{
		//x=read();
		cin>>x;
		maxx=max(maxx,x);minn=min(minn,x);
	}
	cin>>k;
	//k=read();
	if (maxx-minn>k) cout<<":("<<endl;
	else cout<<"Yay!"<<endl;
	return 0;
}

Measured memory_bytes: 256
# ABC131C

def euclid(m, n):
    m0 = m = abs(m)
    n0 = n = abs(n)
    while n != 0:
        m, n = n, m % n
    qm = m0 // m
    lcm = qm * n0
    return lcm


def check(a, b, c):
    x = a // c
    y = b // c
    if x * c < a:
        x += 1
    return y - x + 1

a, b, c, d = map(int, input().split())
nc = check(a, b, c)
nd = check(a, b, d)
ncd = check(a, b, euclid(c, d))
print(b - a + 1 -(nc + nd - ncd))


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

int main(){
  int n, k;
  cin >> n >> k;
  int max = n - k + 1;
  if(k == 1)cout << 0 << endl;
  else {
  	int ans = max - 1;
  	cout << ans << endl;
  }
  return 0;
}


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

Lmax = 0
Rmin = 1000000
for i in range(m):
	L,R = map(int,input().split())
	if Lmax < L:
		Lmax = L
	if Rmin > R:
		Rmin = R
res = Rmin - Lmax + 1
if res > 0:
	print("%d" % (Rmin - Lmax +1))
else:
	print(0)

Measured memory_bytes: 3060
fun main() {
    val s = readInt()

    val mod = 1000000007L
    val partitions = LongArray(s + 1)
    partitions[0] = 1
    for (i in 3..s) {
        for (sub in 3..i) {
            partitions[i] = (partitions[i] + partitions[i - sub]) % mod
        }
    }

    println(partitions[s])
}

// Input Reader
private fun readLn() = readLine()!!

private fun readInt() = readLn().toInt()


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

struct block{
  int w,s,v;
  bool operator<(const block &b) const{
  	return w+s<b.w+b.s;
  }
};

int main(){
  int n,maxwt=0;
  cin>>n;
  vector<block> v(n);
  for(int i=0;i<n;i++)
  {
  	cin>>v[i].w>>v[i].s>>v[i].v;
    maxwt+=v[i].w;
  }
  sort(v.begin(),v.end());
  vector<long> dp(maxwt+5);
  for(int i=0;i<n;i++)
  {
	for(int j=min(v[i].s,maxwt-v[i].w);j>=0;j--)
      dp[j+v[i].w]=max(dp[j+v[i].w],dp[j]+v[i].v);
  }
  long ans=-1;
  for(int j=maxwt;j>=0;j--)
    ans=max(ans,dp[j]);
  cout<<ans;
  
}

Measured memory_bytes: 78336
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		int n = c.length;

		boolean N = false;
		boolean W = false;
		boolean E = false;
		boolean S = false;

		for (int i = 0; i < n; i++) {
			if (c[i] == 'N') {
				N = true;
			} else if (c[i] == 'W') {
				W = true;
			} else if (c[i] == 'E') {
				E = true;
			} else {
				S = true;
			}
		}

		if (N && S) {
			if (W && E) {
				System.out.println("Yes");
			} else if (!W && !E) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else if (!N && !S) {
			if (W && E) {
				System.out.println("Yes");
			} else if (!W && !E) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}

	}

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

}


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

int n , x[10] , a , c ;

int main(){

cin>>n;
while( n-- ){
cin>>a;

if( a < 400 )x[0]=1;
else
if( a < 800 )x[1]=1;
else
if( a < 1200 )x[2]=1;
else
if( a < 1600 )x[3]=1;
else
if( a < 2000 )x[4]=1;
else
if( a < 2400 )x[5]=1;
else
if( a < 2800 )x[6]=1;
else
if( a < 3200 )x[7]=1;
else
c++;
}


int mn=0 , mx=0;
for(int i=0;i<8;i++){
    mn+=x[i];
    mx+=x[i];
    }

cout<< max(mn,1) << " "<< mx+c <<endl;

return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self,key = None,left = None,right = None):
        self.key = key
        self.left = left
        self.right = right

    def insert(self,t,key):
        '''
        if self.key==None:self.key = key
        elif key<self.key:
            if self.left == None:self.left = Node(key)
            else                :self.left.insert(key)
        else:
            if self.right == None:self.right = Node(key)
            else                 :self.right.insert(key)
        '''
        if t.key == None:
            t.key = key
            return
        y = None 
        x = t
        while x is not None:
            y = x
            if key<x.key:x = x.left
            else        :x = x.right

        if y is None  :t = Node(key)
        elif key<y.key:y.left = Node(key)
        else          :y.right = Node(key)

    def inorder(self):
        if self.left!=None:self.left.inorder()
        print (' %d'%self.key,end = '')
        if self.right!=None:self.right.inorder()

    def preorder(self):
        print (' %d'%self.key,end = '')
        if self.left!=None:self.left.preorder()
        if self.right!=None:self.right.preorder()

    def walk(self):
        self.inorder()
        print ()
        self.preorder()
        print ()

def main():
    Tree = Node()
    q = int(input())
    for _ in range(q):
        com = list(input().split())
        if com[0] == 'insert':
            Tree.insert(Tree,int(com[1]))
        else :
            Tree.walk()


if __name__ == '__main__':
    main()




Measured memory_bytes: 105140
N, Y = map(int, input().split())
for x in range(N+1):
    for y in range(N+1):
        if(N-(x+y) < 0):
            break
        if(10000*x+5000*y+1000*(N-(x+y)) == Y):
            print('{0} {1} {2}'.format(x,y,N-(x+y)))
            exit()
print('-1 -1 -1')

Measured memory_bytes: 3060
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
x = list(map(int, input().split()))
min_d = 10 ** 9
for i in range(n - k + 1):
    max_i = x[i + k - 1]
    min_i = x[i]
    if max_i <= 0:
        min_d_i = - min_i
    elif min_i >= 0:
        min_d_i = max_i
    else:
        min_d_i = min(- min_i + 2 * max_i, -2 * min_i + max_i)
    if min_d_i < min_d:
            min_d = min_d_i
print(min_d)


Measured memory_bytes: 14228
#include<iostream>

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

using namespace std;

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

    ll i;
    for(i = 1; i * i < n; i++){

    }

    cout << ((i * i == n) ? i * i : (i - 1) * (i - 1)) << endl;
}

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

int main(){
  int a,b,c,x,y,z,u;
  z=1000000;
  cin>>a>>b;
  vector<int>d(a);
  for(int i=0;i<a;i++){
    cin>>d[i];
    z=min(d[i],z);
    b-=d[i];
  }
  
  cout<<a+b/z<<endl;
}

Measured memory_bytes: 256
MAX = 7368792
while True:
    m,n = map(int,input().split())
    if m+n == 0:
        break
    ##
    E = [True]*(MAX)
    k = 0
    for i in range(m,MAX):
        if E[i]:
            n -= 1
            E[i::i] = [False]*((MAX-i-1)//i+1)
            if n!=0:
                continue
            i += 1
            while not E[i]:
                i += 1
            print(i)
            break


Measured memory_bytes: 159092
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n;
    cin>>n;
   long long int a[n],i,j=1,k=0,l,p=0,v;
   long long int h[n],f[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n,greater<int>());
    for(i=0;i<n-1;i++){
        if(a[i]==a[i+1]){
            j++;
        }
        else{
          h[k++]=a[i];
          f[p++]=j;
          j=1;
    }
    }
    h[k]=a[n-1];
    f[p]=j;
  /*  for(i=0;i<=p;i++){
        cout<<f[i]<<endl;
    }*/
    for(i=0;i<=p;i++){
        if(f[i]>=4){
            cout<<(h[i]*h[i])<<endl;
            return 0;
        }
        else if(f[i]>=2){
               // cout<<"i="<<i<<endl;
            for(v=i+1;v<=p;v++){
                if(f[v]>=2){
                   // cout<<"i="<<i<<endl;
                    cout<<(h[i]*h[v])<<endl;
                    return 0;
                }
            }
            break;
        }
    }
    cout<<0<<endl;
}



Measured memory_bytes: 5812
import sys

N, K = list(map(int, sys.stdin.readline().strip().split(" ")))
cost_list = list(map(int, sys.stdin.readline().strip().split(" ")))
dp = [10**9 for _ in range(N)]
dp[0] = 0
dp[1] = abs(cost_list[1] - cost_list[0])

for i in range(2, N):
    min_c = 10**9
    for j in range(1, K+1):
        min_c = min(min_c, dp[i-j] + abs(cost_list[i] - cost_list[i-j]))
    dp[i] = min_c

print(dp[N-1])


Measured memory_bytes: 55904
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
typedef long long LL;
#define dd c=getchar()
inline int read(){
	int a=0,b=1,dd;
	while(!isdigit(c)){if(c=='-')b=-b;dd;}
	while(isdigit(c)){a=a*10+c-'0';dd;}
	return a*b;
}
inline void print(LL x){
	static int c[23];
	static int n;
	if(x==0){
		putchar('0');
		return;
	}
	if(x<0){
		putchar('-');
		x=-x;
	}
	n=0;
	while(x>0){
		c[n++]=x%10;
		x/=10;
	}
	while(n-->0){
		putchar(c[n]+'0');
	}
}
inline void printsp(LL x){
	print(x);
	putchar(' ');
}
inline void println(LL x){
	print(x);
	putchar('\n');
}
#undef dd
int n;
struct st{
	int a,b;
}a[100003];

bool operator < (st a,st b){
	return a.a+a.b>b.a+b.b;
}

LL ans;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i].a=read();
		a[i].b=read();
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(i&1){
			ans+=a[i].a;
		}else{
			ans-=a[i].b;
		}
	}
	println(ans);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
  }
  int min=0,c=0;
  for(int i=0;i<n;i++){
	if(a[i]==min+1){c++;
                    min++;
                   }
  }
  if(c==0){
    printf("-1");
    return 0;
  }
printf("%d",n-c);
  return 0;
}

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

p = []
for _ in range(N):
    p.append(int(input()))

max_price = max(p)

sum_price = 0
count = 0
for x in p:
    if x == max_price and count == 0:
        sum_price += x // 2
        count += 1
    else:
        sum_price += x

print(sum_price)

Measured memory_bytes: 3060
N = int(input())
sum = 0
for i in range(1,N+1):
	if (i%3==0) and (i%5==0):
		sum += 0
	elif i%3 == 0:
		sum += 0
	elif i%5 == 0:
		sum += 0
	else:
		sum += i
print(sum)

Measured memory_bytes: 65188
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int a,b;
 
        while(true){
            a = sc.nextInt();
            b = sc.nextInt();
 
            if(a == 0 && b == 0)break;
 
            System.out.printf("%d %d\n", Math.min(a, b),Math.max(a, b));
        }
 
    }
}


Measured memory_bytes: 40768
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi a(n),b;
    rep(i,n){
        cin >> a[i];
    }
    b = a;
    zip(a);
    if(len(a) > 2){
        cout << "No\n";
    }else if(len(a) == 1){
        if(a[0] <= n/2 || a[0] == n-1){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }else{
        if(a[1]-a[0] > 1){
            cout << "No\n";
            return 0;
        }
        int x = 0;
        rep(i,n){
            if(b[i] == a[0]){
                x++;
            }
        }
        if(a[0] >= x && a[0] < x + (n-x)/2){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>
#include <set>

using namespace std;

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

	long long N, K;
	cin >> N >> K;

	set<long long> calc_val;
	calc_val.insert(N);

	while (true)
	{
		if (N >= K)
		{
			N %= K;
		}
		else
		{
			N = abs(N - K);
		}

		if (calc_val.find(N) != calc_val.end()) break;

		calc_val.insert(N);
	}

	cout << *calc_val.begin();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	vector<int> a(101),A(101);
	for (int b; cin >> b;) a[b]++;
	A = a;
	sort(A.rbegin(),A.rend());
	for (int i = 0; i < 101; i++) 
		if (a[i] == A[0])cout << i << endl;

	return 0;
}

Measured memory_bytes: 1216
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	r = II()
	print(r*r)

main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
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;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,w;cin >> n >>w;
    vl cost(n),price(n);
    vvl dp(n+1,vl(100010,inf));
    rep(i,n)cin >> cost[i] >> price[i];
    dp[0][0]=0;
    rep(i,n){
        rep(sump,100010){
            if(sump>=price[i]){
                chmin(dp[i+1][sump],dp[i][sump-price[i]]+cost[i]);
            }
            chmin(dp[i+1][sump],dp[i][sump]);
        }
    }
    ll ans=0;
    rep(i,100010){
        if(dp[n][i]<=w)ans=i;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 80256
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N, X, Y = [int(x) for x in input().strip().split()]
D = defaultdict(int)
for k in range(1, N):
    for k2 in range(k+1, N+1):
        D[min(k2 - k, abs(X-k) + 1 + abs(Y-k2), abs(Y-k) + 1 + abs(X-k2))] += 1

for k in range(1, N):
    print(D[k])


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int H,W;
    char c;
    int A[26]={};
    cin >>  H >> W;
    REP(i,H*W){
        cin >> c;
        A[(int)(c-'a')]++;
    }
    /*REP(i,26){
        cout << A[i] << " ";
    }cout << Endl;*/
    REP(i,26){
        A[i]%=4;
    }
    int one=0,two=0;
    int onel,twol;
    if(H%2==1&&W%2==1){
        onel=1;twol=H/2+W/2;
    }else if(H%2==0&&W%2==0){
        onel=0;twol=0;
    }else{
        onel=0;
        if(H%2==1){
            twol=W/2;
        }else{
            twol=H/2;
        }
    }
    REP(i,26){
        if(A[i]%2==1){
            one++;
        }
        if(A[i]>=2){
            two++;
        }
    }
    cerr << one << " " << two << endl;
    cerr << onel << " " << twol << endl;
    Yes(one<=onel && two<=twol);
    return 0;
}   


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

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    --x;--y;
    vector<int> ans(n,0);
    rep(s,n){
        vector<int> dist(n,INF);
        queue<int> q;
        auto push = [&](int v,int d){
            if(dist.at(v) != INF) return;
            dist.at(v) = d;
            q.push(v);
        };
        push(s,0);
        while(!q.empty()){
            int v = q.front();q.pop();
            int d = dist.at(v);
            if(v-1 >= 0) push(v-1,d+1);
            if(v+1 < n) push(v+1,d+1);
            if(v == x) push(y,d+1);
            if(v == y) push(x,d+1);
        }
        rep(i,n) ans[dist.at(i)]++;
    }
    rep(i,n) ans.at(i) /= 2;
    for(int i = 1; i < n;i++){
        cout << ans.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
typedef long long ll;

int main( void )
{
	ll k, n;

	cin >> k >> n;

	ll a[n];
	for ( ll& _a : a ) {
		cin >> _a;
	}

	ll max = 0;
	for ( ll i = 0; i < n - 1; i++ ) {
		if ( max < (a[i + 1] - a[i]) ) {
			max = a[i + 1] - a[i];
		}
	}
	if ( max < (a[0] + k - a[n - 1]) ) {
		max = a[0] + k - a[n - 1];
	}

	cout << (k - max) << endl;
}


Measured memory_bytes: 1792
N = 10 ** 5
D = [0] * (N + 1)
for i in range(2, N + 1):
  if(D[i] == 0):
    for j in range(i, N + 1, i):
      if(D[j] == 0):
        D[j] = i

T = [0] * (N + 1)
for i in range(3, N, 2):
  if(D[i] == i and D[i + 1] == 2 and D[(i + 1) // 2] == (i + 1) // 2):
    T[i] = 1
S = [0] * (N + 1)

for i in range(N):
  S[i + 1] = S[i] + T[i + 1]

Q = int(input())
for i in range(Q):
  l, r = list(map(int, input().split()))
  print(S[r] - S[l - 1])

Measured memory_bytes: 78696
using System;

namespace aoj
{
    public class atcoder
    {
        public static void Main()
        {
            string[] str = Console.ReadLine().Split();
            int a = int.Parse(str[0]), b = int.Parse(str[1]);
            int area = a * b - a - b + 1;
            Console.WriteLine(area);
        }
    }
}


Measured memory_bytes: 11220
h,w,k = map(int, input().split())
remv = [1,1,2,3,5,8,13,21]

dp = [ [0]*w for _ in range(h+1) ]
dp[0][0] = 1

MOD = 10**9+7
for i in range(h):
    for wi in range(w):
        left = wi
        right = w-wi-1
        com = remv[left] * remv[right]
        dp[i+1][wi] += dp[i][wi]*com
        dp[i+1][wi] %= MOD

        if wi > 0:
            left = wi-1
            right = w-wi-1
            com = remv[left] * remv[right]
            dp[i+1][wi-1] += dp[i][wi]*com
            dp[i+1][wi-1] %= MOD

        if wi < w-1:
            left = wi
            right = w-(wi+1)-1
            com = remv[left] * remv[right]
            dp[i+1][wi+1] += dp[i][wi]*com
            dp[i+1][wi+1] %= MOD


print(dp[h][k-1])



Measured memory_bytes: 62940
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
int main()
{
    fastio;
    int a,b,c;cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A,B;
  cin>>A>>B;
  cout<<max({A+B,A-B,A*B})<<endl;
  return 0;
}


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

#define rep(i, n) for(ll i = 0; i < n; i++)
#define loop(i, s, n) for(ll i = s; i < n; i++)
#define MOD 1e9+7
void max_self(int &a, int b) { a=a>b?a:b; }
void min_self(int &a, int b) { a=a<b?a:b; }

typedef long long ll;

using namespace std;

ll n, k;
ll temp;

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

    vector<ll> h(n);

    rep(i, n) scanf("%lld", &h[i]);

    sort(h.begin(),h.end(), greater<ll>());

    for(ll i = k; i < h.size(); i++) {
        temp+=h[i];
    }

    cout << temp << endl;

    
    return 0;
}


Measured memory_bytes: 1792
s = input()
odd = ["R", "U", "D"]
gu = ["L", "U", "D"]
flag = False
for i in range(len(s)):
    if i % 2 == 0:
        if not (s[i] in odd):
            flag = True
            break
    else:
        if not (s[i] in gu):
            flag = True
            break

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

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl;
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl;
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl;
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl;
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl;
#define pb push_back
#define pf push_front
#define oo (ll)1e18
#define inf (int)1e10
#define ll long long 
#define ld long double
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
typedef tuple<ll,ll,ll> tl3;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
const int MAXN = 305;
template <typename T> void maxself(T& a, T b) {
    a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
    a = min(a, b);
}

#define cerr if(0)cout
int A[100][100], B[100][100];
bool dp[85][85][50005];
int h,w;
int main() {
    IAMSPEED
	cin >> h >> w;
	FOR(i,1,h) {
		FOR(j,1,w) cin >> A[i][j];
	}
	FOR(i,1,h) {
		FOR(j,1,w) cin >> B[i][j];
	}
	dp[1][1][abs(A[1][1]-B[1][1])] = 1;
	FOR(i,1,h) {
		FOR(j,1,w) {
			FOR(k,0,49999) {
				if (dp[i][j][k]) {
					dp[i+1][j][abs(k-abs(A[i+1][j] - B[i+1][j]))] = 1;
					dp[i+1][j][k+abs(A[i+1][j] - B[i+1][j])] = 1;
					dp[i][j+1][abs(k-abs(A[i][j+1] - B[i][j+1]))] = 1;
					dp[i][j+1][k+abs(A[i][j+1] - B[i][j+1])] = 1;
				}
			}
		}
	}
	int ans = 0;
	FOR(i,0,49999) {
		if (dp[h][w][i]) {
			ans = i;
			break;
		}
	}
	cout << ans;
}


Measured memory_bytes: 338304