akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
template<typename T>
inline void read(T &x){
    int ch = getchar(); x = 0;
    bool f = false;
    for(;ch != '-' && (ch < '0' || ch > '9');ch = getchar());
    if(ch == '-'){f = true; ch = getchar();}
    for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
    if(f) x = -x;
}
const int N = 1003;
int n, x[N], y[N], t, ans[40], m;
char str[40];
int main(){
    read(n);
    for(Rint i = 1;i <= n;++ i) read(x[i]), read(y[i]);
    t = abs(x[1] + y[1]) & 1;
    for(Rint i = 2;i <= n;++ i)
        if((abs(x[i] + y[i]) & 1) != t) return puts("-1"), 0;
    printf("%d\n1", 32 - t);
    ans[0] = m = 1;
    if(!t) printf(" 1"), ans[m ++] = 1;
    for(Rint i = 1;i <= 30;++ i) printf(" %d", ans[m ++] = 1 << i); putchar('\n');
    for(Rint i = 1;i <= n;++ i){
        for(Rint j = m - 1, nowx = 0, nowy = 0;~j;-- j){
            int dx = x[i] - nowx, dy = y[i] - nowy;
            if(abs(dx) > abs(dy)){
                if(dx > 0) nowx += ans[j], str[j] = 'R';
                else nowx -= ans[j], str[j] = 'L';
            } else {
                if(dy > 0) nowy += ans[j], str[j] = 'U';
                else nowy -= ans[j], str[j] = 'D';
            }
        }
        printf("%s\n", str);
    }
}

Measured memory_bytes: 256
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
    return result % M;
}

int n,arr[3005] = {0};
int dpx[3005][3005], dpy[3005][3005];

int fx(int left, int right);
int fy(int left, int right);

int fx(int left, int right){
    //cout<<" fx -> "<<left<<' '<<right<<" -------> "<<endl;
    if(left>n-1 || right<0) return 0;
    if(left == right){ /*cout<<arr[left]<<endl;*/ return arr[left]; } 
    if(dpx[left][right]>=0){ /*cout<<dpx[left][right]<<endl;*/ return dpx[left][right];} 
    dpx[left][right] = max(arr[left] - fy(left+1, right), arr[right] - fy(left, right-1));
    //cout<<dpx[left][right]<<endl;
    return dpx[left][right];
}

int fy(int left, int right){
   // cout<<" fy -> "<<left<<' '<<right<<" -------> "<<endl;
    if(left>n-1 || right<0) return 0;
    if(left == right){/* cout<<arr[left]<<endl;*/ return arr[left]; } 
    if(dpy[left][right]>=0){/* cout<<dpy[left][right]<<endl; */return dpy[left][right];} 
    dpy[left][right] = max((1)*arr[left] - fx(left+1, right), (1)*arr[right] - fx(left, right-1));
    //cout<<dpy[left][right]<<endl;
    return dpy[left][right];
}

signed main()
{
    tezz
 

    memset(dpx,-1,sizeof(dpx));
    memset(dpy,-1,sizeof(dpy));
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        sum+=arr[i];
    }

    cout<<fx(0,n-1);
}

Measured memory_bytes: 141568
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using vi = vector<int>;
using i64 = int64_t;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

template <typename T>
void print(vector<T> v) {
  REP(i, v.size()) {
    if (i) cout << " ";
    cout << v[i];
  }
  cout << endl;
}

int partition(vi &A, int p, int r) {
  auto x = A[r];
  auto i = p - 1;
  FOR(j, p, r) {
    if (A[j] <= x) swap(A[++i], A[j]);
  }
  swap(A[i + 1], A[r]);
  return i + 1;
}

int main() {
  int n;
  cin >> n;
  vi A(n);
  REP(i, n) cin >> A[i];
  auto q = partition(A, 0, n - 1);

  REP(i, A.size()) {
    if (i) cout << " ";
    if (i == q) cout << "[";
    cout << A[i];
    if (i == q) cout << "]";
  }
  cout << endl;
}


Measured memory_bytes: 3096
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	X := sc.NextInt()
	ans := X / 500 * 1000
	X -= X / 500 * 500

	ans += X / 5 * 5
	fmt.Println(ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
int main()
    {
    long long int n;
    cin>>n;
    long long int sum=0;
    for(long long int i=1;i<=n;i++)
    {
        if((i%3!=0)&&(i%5!=0))
        sum+=i;
    }
    cout<<sum;
    return 0;
    
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cmath>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <cstdlib>
#include <stdlib.h>
#include <set>
#include <unordered_set>
#include <cassert>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll p = 997;
const ll base = 1e9 + 7;
const ll MAXN = 5e5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double PII = 3.14159265358979323846264338327950288419716939937510;
const double Epsilon = 1.19209e-9;
const ld fi = 1.6180339887498948482;
const ll one = 2147483647;
const ll two = 1e9 + 7;
void print_vectorll(vector<ll> & a) {
    forn(i, (int)a.size()) {
        cout << a[i] << " ";
    }
    cout << "\n";
}
void print_vectorint(vector<int> & a) {
    forn(i, (int)a.size()) {
        cout << a[i] << " ";
    }
    cout << "\n";
}
void read_vector(vector<ll> & a, ll n) {
    ll h;
    forn(i, n) {
        cin >> h;
        a.pb(h);
    }
}
bool check_four(int a){
  int sum = 0;
  while(a){
    sum += a % 10;
    a /= 10;
  }
  return sum % 4 == 0;
}
void upd_max(int & a, int b){
  a = max(a, b);
}
void upd_min(int & a, int b){
  a = min(a, b);
}
ll n, a, b;
bool check_sum(ll ss){
    while(ss){
        if(ss % 10 != a && ss % 10 != b){
            return false;
        }
        ss /= 10;
    }
    return true;
}
ll upd_mod(ll a, ll MOD){
    if (a > MOD){
        a %= MOD;
    }
    return a;
}
ll bin_pow(ll a, ll pow){
    if (pow == 0){
        return 1;
    }
    if (pow == 1){
        return a;
    }
    ll h = bin_pow(a, pow / 2);
    if (pow % 2 == 0){
        return upd_mod(h * h, MOD);
    }
    return upd_mod(upd_mod(h * h, MOD) * a, MOD);
}
//#define DEBUG
int main(){
    FastIO;
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
    #endif // DEBUG
    ll n;
    ll ans = 0;
    cin >> n;
    int hi = 1e9;
    forn(i, n - 1){
        int a;
        cin >> a;
        ans += min(hi, a);
        hi = a;
    }
    ans += hi;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll T1, T2, A1, B1, A2, B2;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> T1 >> T2;
    cin >> A1 >> A2;
    cin >> B1 >> B2;
    if (A1 > B1 && A2 > B2) cout << 0;
    else if (A1 < B1 && A2 < B2) cout << 0;
    else {
        if (A1 < B1) {
            swap(A1, B1);
            swap(A2, B2);
        }
        ll x = A1 - B1;
        ll y = B2 - A2;
        // cout << x << ' ' << y << endl;

        ll res = 0;
        if (x * T1 <= y * T2) {
            ll tu = y * T2;
            ll mau = y * T2 - x * T1;
            if (mau == 0) {
                cout << "infinity";
                return 0;
            }
            ll num = max(0LL, tu / mau - (tu % mau == 0));
            res += num;
        }
        if (y * T2 > T1 * x) {
            ll tu = x * T1;
            ll mau = y * T2 - x * T1;
            if (mau == 0) {
                cout << "infinity";
                return 0;
            }
            ll num = max(0LL, tu / mau);
            res += num;
        }
        cout << res;
    }
    return 0;
}


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

int main() {
   int H, W;
   cin >> H >> W;
   if (H == 1 or W == 1)
      cout << "1\n";
   else if (H % 2 == 0 or W % 2 == 0)
      cout << (1ll * H * W) / 2 << "\n";
   else cout << ((1ll * H * W) + 1) / 2 << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#include <utility>
#include <numeric>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	vector<int>p(n);
	REP(i, n) {
		cin >> p[i];
	}
	vector<int>prob(3,0);
	REP(i, n) {
		if (p[i] <= a) {
			prob[0]++;
		}
		else if (p[i] <= b) {
			prob[1]++;
		}
		else {
			prob[2]++;
		}
	}
	sort(prob.begin(),prob.end());
	int m = prob[0];
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
def show_list(target):
    for i, item in enumerate(target):
        if i == len(target) - 1:
            print(item)
        else:
            print(item, end=" ")

def insection_sort(target):
    for i in range(1, len(target)):
        show_list(target)
        j = i - 1
        while j >= 0:
            if target[j] > target[j+1]:
                target[j], target[j+1] = target[j+1], target[j]
                j -= 1
            else:
                break
    return target

if __name__ == "__main__":
    n = input()
    a = [int(x) for x in input().split()]
    answer = insection_sort(a)
    show_list(answer)

Measured memory_bytes: 5984
n, ma, mb = map(int,input().split())
INF = 10**9
dp = {(0,0):0}
for _ in range(n):
  a, b, c = map(int, input().split())
  #print('chk!',a,b,c)
  for (ea, eb), ec in dp.copy().items():
    dp[ea+a,eb+b] = min(dp.get((ea+a,eb+b),INF), ec+c)
    #print(dp)
ans = min(dp.get((i*ma,i*mb),INF) for i in range(1,401))
print(ans if ans != INF else -1)

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);






int main()
{
//    FAST();

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

    int i,r,x,d;
    S("%d %d %d",&r,&d,&x);
    for(i=0;i<10;i++)
    {
        x=r*x-d;
        P("%d\n",x);
    }
    return 0;
}







LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;  // デフォルトでnの最大値は300000

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i * fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n;
    cin >> n;

    vl x(n+1);
    exrep(i, 1, n) {
        cin >> x[i];
    }

    init();

    ll u = 0;
    ll ans = 0;
    exrep(i, 1, n-1) {
        u += inv[i];
        u %= mod;
        ans += (x[i+1] - x[i])*u%mod;
        ans %= mod;
    }
    ans *= fact[n-1];
    ans %= mod;

    out(ans);
    re0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    string S; cin >> S;
    int year = stoi(S.substr(0, 4));
    int month = stoi(S.substr(5, 2));
    int day = stoi(S.substr(8, 2));
    if (year > 2019) {
        cout << "TBD" << endl;
    } else if (year < 2019) {
        cout << "Heisei" << endl;
    } else {
        if (month > 4) {
            cout << "TBD" << endl;
        } else {
            cout << "Heisei" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long h[10], i, j, temp;

    for(i=0; i<10; i++)
    {
        scanf("%lld", &h[i]);
    }
    for(i=0; i<9; i++)
    {
        for(j=i+1; j<10; j++)
        {
            if(h[j]>h[i])
            {
                temp = h[i];
                h[i] = h[j];
                h[j] = temp;
            }
        }
    }
    for(i=0; i<3; i++)
    {
        printf("%lld\n", h[i]);
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main() {
    
      string s;
      cin >> s;
      if(s=="ARC")cout << "ABC\n";
      else cout << "ARC\n";
	return 0;
}




Measured memory_bytes: 3560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main()
        {
            string line = Console.ReadLine();
            int num = int.Parse(Console.ReadLine());
            var mozi = new LinkedList<string>();
            Boolean flag = false;
            foreach (var item in line)
            {
                mozi.AddLast(item.ToString());
            }

            for (int i = 0; i < num; i++)
            {
                var input = Console.ReadLine().Split(' ');
                if (input[0] == "1")
                {
                    flag = !flag;
                }
                else
                {
                    if (input.Length < 3)
                    {
                        return;
                    }
                    if (((input[1] == "1") && flag == false) || ((input[1] == "2") && flag == true))
                    {
                        mozi.AddFirst(input[2]);
                    }
                    else
                    {
                        mozi.AddLast(input[2]);
                    }
                }
            }


            var mozi2 = new List<string>();
            if (flag)
            {
                mozi2 = mozi.Reverse().ToList();
            }
            else
            {
                mozi2 = mozi.ToList();
            }
            var mozi3 = new StringBuilder();
            foreach (var item in mozi2)
            {
                mozi3.Append(item);
            }
            Console.WriteLine(mozi3.ToString());
        }
    }
}


Measured memory_bytes: 50592
#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 ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int N, M, C;
    cin >> N >> M >> C;

    vi B(M);
    rep(i, M) {
        cin >> B[i];
    }

    int A;
    int ans = 0;
    rep(i, N) {
        int calc = 0;
        rep(j, M) {
            cin >> A;
            calc += A * B[j];
        }
        if (calc + C > 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

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

	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if ((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])) ans++;
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
A, B = gets.chomp.split(' ').map(&:to_i)
def gcd(a, b)
  a, b = b, a if a < b
  loop do
    m = a % b
    return b if m == 0
    a, b = b, m
  end
end
def lcm(a, b)
  return ((a * b) / gcd(a, b))
end
puts lcm(A, B)

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

public class Main{
	static boolean[] d=new boolean[10];
	static boolean check(int x){
		String str=Integer.toString(x);
		for(int i=0;i<str.length();i++) if(d[str.charAt(i)-'0']) return false;
		return true;
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			int k=sc.nextInt();
			Arrays.fill(d,false);
			for(int i=0;i<k;i++) d[sc.nextInt()]=true;
			for(int i=n;;i++){
				if(check(i)){
					System.out.println(i);
					break;
				}
			}
		}
	}
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static vector<int> vec;
	for(int i = 1 ; i < (1<<16) ; i ++){
		int sum = 0;
		for(int j = 0 ; j < 16 ; j ++){
			if((i>>j)&1)sum ^=j;
		}
		if(sum == 0){
			vec.pb(i);
			//if(i < 32)cout << i << endl;
		}
	}
	
	static int dp[1<<16];
	dp[0] = 0;
	for(int i = 1 ; i < (1<<16) ; i ++){
		for(int j = 0 ; j < vec.size() ; j ++){
			if((i&vec[j]) == vec[j]){
				dp[i] = max( dp[i] , dp[i^vec[j]] + 1 );
			}
		}
	}
	
	static int N;
	static int x[100010],y[100010],a[100010];
	scanf("%d",&N);
	for(int i = 1 ; i <= N-1 ; i ++){
		scanf("%d%d%d",&x[i],&y[i],&a[i]);
	}
	
	static int b[100010] = {};
	for(int i = 1 ; i <= N-1 ; i ++){
		b[x[i]] ^= a[i];
		b[y[i]] ^= a[i];
	}
	
	/*for(int i = 0 ; i < N ; i ++){
		printf("%d ",b[i]);
	}
	cout << endl;*/
	
	static int cnt[1<<4] = {};
	for(int i = 0 ; i < N ; i ++){
		cnt[b[i]] ++;
	}
	
	static int ret = cnt[0];
	static int t = 0;
	for(int i = 1 ; i <= 15 ; i ++){
		ret += cnt[i]/2;
		if(cnt[i]&1)t |= 1<<i;
	}
	//cout << t << " " << dp[t] << endl;
	ret += dp[t];
	
	cout << N-ret << endl;
}



Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b});
}


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

using namespace std;

#define mp makepair

int main(){
  int n,m,k,l;
  int a,b,c;
  string data;
  pair<int,pair<int,int> > p;
  while(true){
    cin>>n;
    if(!n)break;
    vector<pair<int,pair<int,int> > > nodes;
    cin>>m;
    int num[m],count=0;
    for(int i=0;i<m;i++){
      num[i] = i;
      cin>>data;
      a = atoi(data.substr(0,data.find(",")).c_str());
      b = atoi(data.substr(data.find(",")+1,data.find(",",data.find(",")+1)).c_str());
      c = atoi(data.substr(data.find(",",data.find(",")+1)+1).c_str());
      p.first = c/100-1;
      p.second.first = a;
      p.second.second = b;
      nodes.push_back(p);
    }
    sort(nodes.begin(),nodes.end());
    for(int i=0;i<m;i++){
      if (num[nodes[i].second.first]!=num[nodes[i].second.second]){
	k = min(num[nodes[i].second.first],num[nodes[i].second.second]);
	l = max(num[nodes[i].second.first],num[nodes[i].second.second]);
	count+=nodes[i].first;
	for(int j=0;j<m;j++)if(num[j]==l)num[j] = k;
      }
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  vector<int> a(3); REP(i, 3) cin >> a[i];
  cout << (accumulate(ALL(a), 0) >= 22 ? "bust\n" : "win\n");
  return 0;
}


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

int main(){
    int N; cin >> N;
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin >> P[i];
    }
    int cnt = 0;
    int min = P[0];
    for(int i=0;i<N;i++){
        if(min >= P[i]){
            cnt++;
        }
        if(min > P[i]){
            min = P[i];
        }
    }  
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm> 
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;
int main() {
	int x,a,b,z,y;
	cin>>x>>a>>b;
	z=x-a;
	y=z/b;
	cout<<z-(y*b)<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String[] sl = s.split("[\\s]+");
    int n = Integer.parseInt(sl[0]);
    int k = Integer.parseInt(sl[1]);

    int v = 0;

    int a[] = new int[100001];
    s = r.readLine();
    sl = s.split("[\\s]+");

    for(int i = 1; i < n; i++)
    {
      a[i] = Integer.parseInt(sl[i - 1]);
      if(a[i] == 1)
      {
        v = i;
      }
    }

    int c = (v - 1 + k - 2) / (k - 1);

    int z = c * (k - 1) + 1;

    if(z < n) c += (n - z + k - 2) / (k - 1);

    System.out.println(c);
  }

}


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

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		long rem = LINF;
		long sum = 0;
		for(int i=0;i<n;i++) {
			int a = fs.nextInt(), b = fs.nextInt();
			if(a>b) {
				rem = Math.min(rem, b);
			}
			sum += b;
		}	
		if(rem==LINF) {
			System.out.println(0);
			return;
		}
		long ans = sum - rem;
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

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

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 32164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N;
  cin >> N;
  vector<long> num(N);
  
  for (int i = 0; i < N; i++) {
    cin >> num.at(i);
    num.at(i) -= (i + 1);
  }
  
  sort(num.begin(), num.end());
  
  int ma,mb;
  
  if (N % 2 == 0) {
    ma = num.at(N/2);
    mb = num.at(N/2 - 1);
  }
  else {
    ma = num.at((N - 1)/2);
    mb = num.at((N - 1)/2);
  }
  
  long sunuke1,sunuke2 = 0;
  
  for (int i = 0; i < N; i++) {
    sunuke1 = sunuke1 + abs(num.at(i) - ma);
    sunuke2 = sunuke2 + abs(num.at(i) - mb);
  }
  
  cout << min(sunuke1,sunuke2) << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9+7;
int main(){
    ll n;
    cin >> n;
    auto s = vector<int>(n+1,0);
    for(int i=n;i>=1;i--){
        int k=i;
        while(k%2==0){
                s[2]++;
                k/=2;
        }
        for(int j=3;j<=k;j+=2){
            while(k%j==0){
                s[j]++;
                k/=j;
            }
        }
    }
    ll ans = 1;
    for(auto i:s){
        if(i==0) continue;
        ans = ans * (i+1) % INF;
    }
    cout << ans;
}

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

int main() {
  int n;
  cin>>n;
  int cnt=0;
  for(int i=1;i<=n;i++){
     string s=to_string(i);
    if((s.size())%2==0)continue;
    cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main() {
    val (H, W, M) = readIs()
    val hc = IntArray(H + 1)
    val wc = IntArray(W + 1)
    val map = mutableMapOf<Int, MutableSet<Int>>()
    repeat(M) {
        val (h, w) = readIs()
        hc[h]++
        wc[w]++
        map.computeIfAbsent(h) {
            mutableSetOf()
        } += w
    }

    val maxh = hc.max()!!
    val maxhh = mutableSetOf<Int>()
    hc.forEachIndexed { h, cnt ->
        if (cnt == maxh) maxhh += h
    }

    val maxw = wc.max()!!
    val maxww = mutableSetOf<Int>()
    wc.forEachIndexed { w, cnt ->
        if (cnt == maxw) maxww += w
    }

    val x = maxh + maxw
    var y = 0
    for ((h, ww) in map) {
        for (w in ww) {
            if (h in maxhh && w in maxww) y++
        }
    }
    println(if (y == maxhh.size * maxww.size) x - 1 else x)
}


Measured memory_bytes: 211180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long

using namespace __gnu_pbds;
using namespace std;

template <class T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

void usaco(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main()
{
    usaco();
    int n;
    cin >> n;
    vector <array <int, 2>> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i][0] >> a[i][1];
    for (int i = 2; i < n; ++i)
    {
        if (a[i][0] == a[i][1] && a[i-1][0] == a[i-1][1] && a[i-2][0] == a[i-2][1])
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}


Measured memory_bytes: 3660
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func check(n int, k int, a []int) int {
	for i := 0; i < k; i++ {
		n = n - n%a[i]
	}
	return n
}

func checkmax(k, ma int, a []int) int {
	l := 0
	r := 2 + k*ma
	for l+1 != r {
		m := (l + r) / 2
		ret := check(m, k, a)
		// out(m, ret)
		if ret > 2 {
			r = m
		} else {
			l = m
		}
	}
	// out(l, r)
	if check(r, k, a) == 2 {
		return r
	}
	if check(l, k, a) == 2 {
		return l
	}
	return -1
}

func checkmin(k, ma int, a []int) int {
	l := 0
	r := 2 + k*ma
	for l+1 != r {
		m := (l + r) / 2
		ret := check(m, k, a)
		// out(m, ret)
		if ret >= 2 {
			r = m
		} else {
			l = m
		}
	}
	// out(l, r)
	if check(l, k, a) == 2 {
		return l
	}
	if check(r, k, a) == 2 {
		return r
	}
	return -1
}

func main() {
	sc.Split(bufio.ScanWords)

	K := getInt()
	a := make([]int, K)
	mx := 0
	for i := 0; i < K; i++ {
		a[i] = getInt()
		mx = max(mx, a[i])
	}

	mi := checkmin(K, mx, a)
	ma := checkmax(K, mx, a)
	if mi != -1 && ma != -1 {
		out(mi, ma)
	} else {
		out(-1)
	}
}


Measured memory_bytes: 3072
a_sco = gets
b_sco = gets

a_score = a_sco.split(nil)
b_score = b_sco.split(nil)

a_sum = a_score[0].to_i + a_score[1].to_i + a_score[2].to_i + a_score[3].to_i
b_sum = b_score[0].to_i + b_score[1].to_i + b_score[2].to_i + b_score[3].to_i

if a_sum >= b_sum
	puts a_sum
else
	puts b_sum
end

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  bool flag1 = (abs(c - a) <= d);
  bool flag2 = (abs(b - a) <= d && abs(c - b) <= d);
  if(flag1 || flag2){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> locate(M), by(M-1);
  for (int &e : locate) cin >> e;
  sort(locate.begin(), locate.end());
  
  for (int i = 0; i < M-1; i++) {
    by[i] = locate[i+1] - locate[i];
  }
  
  sort(by.begin(), by.end(), greater<int>());
  int dec = 0;
  for (int i = 0; i < N-1; i++) {
    dec += by[i];
  }
  
  cout << locate[M-1]-locate[0]-dec << endl;
}

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


int main()
{
    long long n;
    cin >> n;
    long long a[10000];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }

    cout << *min_element(a, a + n) << " "
         << *max_element(a, a + n) << " "
         << accumulate(a, a + n, 0LL) << endl;

}


Measured memory_bytes: 3152
#include <vector>
#include <queue>
#include <iostream>
using namespace std;

int main(){
    int N,Q;cin >> N >> Q;
    vector<int> link[N + 1];
    int point[N + 1] = {0};
    int used[N + 1] = {0};

    for(int i = 0;i<N-1;i++){
        int edge1,edge2;cin >> edge1 >> edge2;
        link[edge1 -1].push_back(edge2 -1);
        link[edge2 - 1].push_back(edge1 -1);
    }
    
    for(int i = 0;i < Q;i++){
        int n,p;cin >> n >> p;
        point[n - 1] += p;
    }

    queue<int> points;
    points.push(0);

    while(!points.empty())
    {
        int current = points.front();
        points.pop();
        used[current] = 1;
        for(auto&& next : link[current]){
            if(!used[next]){
                point[next] += point[current];
                points.push(next);
            }
        }
    }

    cout << point[0];
    for(int i = 1;i < N;i++) {
        cout << " " << point[i];
    }
    cout << endl;
}


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

int w, h;
char map[102][102];
bool closed[102][102];
void rec(int x, int y){
  if(closed[y][x]){
    cout << "LOOP" << endl;
    return;
  }
  closed[y][x] = true;
  if(map[y][x] == '>')rec(x+1,y);
  else if(map[y][x] == 'v')rec(x, y+1);
  else if(map[y][x] == '<')rec(x-1,y);
  else if(map[y][x] == '^')rec(x,y-1);
  else {
    cout << x << " " << y << endl;
  }
}
void solve(){
  rec(0,0);
}
int main(){
  while(cin >> h >> w, w||h){
    memset(closed, 0, sizeof(closed));
    for(int i = 0; i < h; i++)cin >> map[i];
    solve();
  }
  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};


//-----------------------------------------------------------------------------

int n,k,sum;

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

	cin>>n>>k;
	REP(i,n) {
		int x;cin>>x;
		sum+=min(k-x,x)*2;
	}
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

template <typename Edge, typename T>
void Dijkstra(const vector<vector<Edge>> &edge, int s, vector<T> &d) {
    using P = pair<T, int>;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push({0, s});
    while (q.size()) {
        T dist;
        int v;
        tie(dist, v) = q.top();
        q.pop();
        if (d[v] < dist) continue;
        for (auto &&e : edge[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                q.push({d[e.to], e.to});
            }
        }
    }
}

struct Edge {
    int to;
    double cost;
};

int main() {
    i64 sx, sy, tx, ty;
    int N;
    cin >> sx >> sy >> tx >> ty;
    cin >> N;
    vector<tuple<i64, i64, i64>> data(N + 2);
    vector<vector<Edge>> edge(N + 2);
    data[0] = make_tuple(sx, sy, 0);
    data[N + 1] = make_tuple(tx, ty, 0);
    for(int i = 1; i <= N; i++) {
        i64 x, y, r;
        cin >> x >> y >> r;
        data[i] = make_tuple(x, y, r);
    }
    for(int i = 0; i < N + 2; i++) {
        i64 x1, y1, r1;
        tie(x1, y1, r1) = data[i];
        for(int j = 0; j < N + 2; j++) {
            i64 x2, y2, r2;
            tie(x2, y2, r2) = data[j];
            if(i == j) continue;
            Edge e = {j, max(.0, hypot(x1 - x2, y1 - y2) - double(r1 + r2))};
            edge[i].push_back(e);
        }
    }
    vector<double> ans(N + 2, 1e18);
    ans[0] = 0;
    Dijkstra(edge, 0, ans);
    cout << std::fixed << std::setprecision(15) << ans[N + 1] << endl;
    return 0;
}

Measured memory_bytes: 22256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n,r,t,memo = 0,memo2 = 0;
    cin >> n;
    
    rep(i,0,n){
        cin >> t >> r;
        
        memo = r / 30;
        memo2 = t /100;
        
        
        if(r % 30 == 0 && t % 100 == 0 ){
            cout << 5*memo+memo2 << endl;
        }
        else if(r % 30 == 0){
            cout << 5*memo+memo2 << " " << 5*memo+memo2+1 << endl;
        }
        else if(t % 100 == 0){
            cout << 5*memo+memo2 << " " << 5*(memo+1)+memo2 << endl;
        }
        else{
            cout << 5*memo+memo2 << " " << 5*memo+memo2+1 << " ";
            cout << 5*(memo+1)+memo2 << " " << 5*(memo+1)+memo2+1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3068
#include <stdio.h>
#include <vector>
int main(int argc, char **argv) {
  int n;
  scanf("%d", &n);

  std::vector<int> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);

  printf("%d", a[n - 1]);
  for (int i = n - 3; i >= 0; i -= 2)
    printf(" %d", a[i]);
  for (int i = n % 2; i <= n - 2; i += 2)
    printf(" %d", a[i]);

  return 0;
}

Measured memory_bytes: 3072
A, B, C, X, Y = map(int, input().split())

is_ab = ((A+B)/2) >= C

amount = 0

if is_ab:
    amount += 2*C*min(X, Y)
    tmp = min(X, Y)
    X -= tmp
    Y -= tmp
    
    if X>0:
        if A>(2*C):
            amount += 2*C*X
        else:
            amount += A*X
    
    else:
        if B>(2*C):
            amount += 2*C*Y
        else:
            amount += B*Y

else:
    amount += (A*X+B*Y)

print(amount)

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class BOneClue {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int k, x;
    cin >> k >> x;
    k--;
    for (int i = x - k; i <= x + k; i++)
        cout << i << " ";
    cout << endl;
}
};

int main() {
	BOneClue solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
/**akshaykumar99**/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;

int main() 
{
   IOS();
   
	ll k,x;
   cin>>k>>x;
   if(k*500>=x)
      cout<<"Yes\n";
   else
      cout<<"No";

   	
    return 0;
}

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var HW = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var H = HW[0];
                var W = HW[1];
                if (H == 0)
                    break;
                var h = H % 2;
                var w = W % 2;
                foreach (var i in Enumerable.Range(0, H / 2))
                {
                    foreach (var j in Enumerable.Range(0, W / 2))
                    {
                        Console.Write("#.");
                    }
                    if (w == 1)
                    {
                        Console.WriteLine("#");
                    }
                    else
                    {
                        Console.WriteLine();
                    }
                    foreach (var j in Enumerable.Range(0, W / 2))
                    {
                        Console.Write(".#");
                    }
                    if (w == 1)
                    {
                        Console.WriteLine(".");
                    }
                    else
                    {
                        Console.WriteLine();
                    }
                }
                if (h == 1)
                {
                    foreach (var i in Enumerable.Range(0, W / 2))
                    {
                        Console.Write("#.");
                    }
                    if (w == 1)
                    {
                        Console.WriteLine("#");
                    }
                    else
                    {
                        Console.WriteLine();
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

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


int main(){

int k;
cin >> k;
int ans,a=0,b=0;
for(int i = 1; i<=k;++i){
    
    if(i%2==1) b++;
    else a ++ ;
}
ans = a*b;
cout << ans << endl;


}

Measured memory_bytes: 256