akhauriyash/Code-Regression huggingface dataset:
N, A, B, C, D = map(int, input().split())

ok = 0
B -= A; B = abs(B)
k = N-1
if B <= k*D:
    if (k-1)*(D-C) >= 2*C:
        ok = 1
    else:
        r = k*(D-C)
        sp = 2*C - (k-1)*(D-C)
        if k % 2 == 1:
            # sp/2 -> r -> sp -> r -> ...
            if sp//2 <= B and (B-sp//2) % (sp + r) <= r:
                ok = 1
        else:
            # r/2 -> sp -> r -> sp -> r -> ...
            if B <= r//2 or (B-r//2-sp) % (sp + r) <= r:
                ok = 1
print('YES' if ok else 'NO')

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

long long n,m;

int main(){
    cin >> n >> m;
    if(n==1 && m>=2){ cout<<m-2; return 0;}
    if(m==1 && n>=2){ cout<<n-2; return 0;}
    if(m==1 && n==1){cout<<1; return 0;}
    cout<<m*n-2*m-2*n+4;
    
    
    
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    ll zero = 0;
    vector<ll> plus, minus;
    rep(i,0,N){
        if(A[i] == 0) zero++;
        else if(A[i] > 0) plus.push_back(A[i]);
        else minus.push_back(A[i]);
    }
    sort(plus.begin(), plus.end());
    sort(minus.begin(), minus.end());

    ll zero_cnt = N*(N-1)/2 - (N-zero) * (N-zero-1) / 2;
    ll lv = -1e18+1, rv = 1e18+1;
    ll nplus = plus.size(), nminus = minus.size();

    while(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        ll res = 0;
        rep(i,0,nplus){
            ll v = plus[i];
            if(mid >= 0){
                ll target = mid / v;
                ll pos = upper_bound(plus.begin(), plus.end(), target) - plus.begin();
                if(v <= target) pos--;
                res += pos;
            }
            if(mid >= 0){
                res += nminus;
            }else{
                ll target = - (-mid + v - 1) / v;
                ll pos = upper_bound(minus.begin(), minus.end(), target) - minus.begin();
                res += pos;
            }
        }

        rep(i,0,nminus){
            ll v = minus[i];
            if(mid >= 0){
                ll target = (-1) * (mid / -v);
                ll pos = lower_bound(minus.begin(), minus.end(), target) - minus.begin();
                if(v >= target) pos++;
                res += nminus - pos;
            }
            if(mid >= 0){
                res += nplus;
            }else{
                ll target = (-mid + abs(v) - 1) / abs(v);
                ll pos = lower_bound(plus.begin(), plus.end(), target) - plus.begin();
                res += nplus - pos;
            }

        }
        res /= 2;
        if(mid >= 0) res += zero_cnt;

        if(res >= K){
            rv = mid;
        }else{
            lv = mid;
        }
    }
    print(rv);

}

Measured memory_bytes: 3956
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

ll gcd(ll a, ll b){
  if (a%b == 0){return b;}
  else{return(gcd(b, a%b));}
}

int main(){
  int N;
  cin>>N;
  vector <ll> T(N);
  rep(i, N){
    cin >> T[i];
    if (i == 0) continue;
    T[i] = T[i-1]*(T[i]/gcd(T[i-1], T[i]));
  }
  cout << T[N-1] <<endl;
  return 0;
}
    

Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] num = Input.ScanIntArray();
          int x = num[0]*num[1]*(num[0]+num[1])%3;
          Console.WriteLine(x==0 ? "Possible" : "Impossible");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

int main() {
	int N,K;
	cin >> N >> K;
	vector<int> A(N);
	rep(i,N)
		cin >> A.at(i);
	
	rep(i,N-K)
		cout << ((A.at(i)<A.at(i+K)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 4048
from math import cos, radians

A,B,H,M = [int(i) for i in input().split()]
ans = lambda a,b,c: (a**2 + b**2 - 2*a*b*cos(radians(c)))**0.5
ang = min(abs(H*30 + M*0.5 - M*6), 360 - abs(H*30 + M*0.5 - M*6))
print(ans(A,B,ang))

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

int main(){
  int N,D;
  cin >> N >> D;
  vector<vector<int>> X(N,vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> X.at(i).at(j);
    }
  }
  int ans=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      int sum=0;
      for(int d=0;d<D;d++){
        sum += (X.at(i).at(d) - X.at(j).at(d))*(X.at(i).at(d) - X.at(j).at(d));
      }
      int r=sqrt(sum);
      if(sum == r*r){
        ans ++;
      }
    }
  }
  cout << ans << endl;
}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int N, D;
  cin >> N >> D;
  int x[N][D];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < D; j++) {
      cin >> x[i][j];
    }
  }

  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      double dist = 0;
      for (int k = 0; k < D; k++) {
        dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      double tmp = sqrt(dist);
      if (ceil(tmp) == floor(tmp)) {
        ans++;
      } 
    }
  }

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


Measured memory_bytes: 256
n,x = map(int,input().split())
s = list(map(int,input().split()))
mod = 10**9 + 7

s.sort(reverse=True)
dp = [[0] * (10**5+1) for _ in range(n+1)]

dp[0][x] = 1
for i in range(n):
    for j in range(10**5+1):
        dp[i+1][j] += dp[i][j] * (n-1-i)
        dp[i+1][j%s[i]] += dp[i][j]
        dp[i+1][j] %= mod
        dp[i+1][j%s[i]] %= mod

ans = 0
for i in range(10**5+1):
    ans += i*dp[-1][i]
    ans %= mod

print(ans)

Measured memory_bytes: 222304
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

//BEGIN CUT HERE
template<typename T>
struct BIT{
  int n;
  vector<T> bit;
  //1-indexed
  BIT(int n_):n(n_+1),bit(n,0){}

  T sum(int i){
    T s(0);
    for(int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }

  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }

  int lower_bound(int w){
    if(w<=0) return 0;
    int x=0,r=1;
    while(r<n) r<<=1;
    for(int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }

  // [l, r)
  T query(int l,int r){
    return sum(r-1)-sum(l-1);
  }

  T sum0(int i){
    return sum(i+1);
  }

  void add0(int i,T a){
    add(i+1,a);
  }

  T query0(int l,int r){
    return sum(r)-sum(l);
  }
};
//END CUT HERE


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M;
  cin>>N>>M;
  vector<pll> A(N);
  cin>>A;
  for(auto &I:A){I.S++;}
  sort(A.begin(),A.end(),[](pll a,pll b){return a.S-a.F>b.S-b.F;});
  ll idx=0;
  vector<ll> ans(M+1,0);
  BIT<ll> bit(M+20);
  for(auto &I:A){
    bit.add0(I.F,1);
    bit.add0(I.S,-1);
  }
  for(ll i=M;i>0;i--){
    while(idx<N && A[idx].S-A[idx].F>=i){
      bit.add0(A[idx].F,-1);
      bit.add0(A[idx].S,1);
      idx++;
    }
    ans[i]=idx;
    for(ll j=1;i*j<=M;j++){
      ans[i]+=bit.query0(0,i*j+1);
    }
  }
  for(int i=1;i<=M;i++){cout<<ans[i]<<endl;}
  
  
  return 0;
}


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

int main(){
  int N,X;
  cin>>N>>X;
  int j=1000;
  for(int i=0;i<N;i++){
    int k;
    cin>>k;
    j=min(j,k);
    X-=k;
  }
  cout<<N+X/j<<endl;
}

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

int main()
{
	int ar[26][1000];
	
	int n;
	cin>>n;
	for (int i =0; i < n; i++)
	{
		int a;
		char s;
		cin>>s>>a;
		switch (s)
	{
	case 'S': 
		{
			ar[1][a] = 1;
			break;
		}
		case 'H': 
		{
			ar[2][a] = 1;
			
			break;
		}
		case 'C': 
		{
			ar[3][a] = 1;
		
			break;
		}
		case 'D': 
		{
			ar[4][a] = 1;
			
			break;
		}
	}
	}
	char s;
	for ( int i = 1; i < 5; i++ )
	{
		for(int j = 1; j < 14 ; j++)
		{
            if(ar[i][j] == 0)
			{
                switch(i)
				{
					case 1:
					   s='S';
					  break;
					case 2:
					   s='H';
					   break;
					case 3:
					    s='C';
					  break;
					case 4:
					   s='D';
                    break;
                }
                cout<<s<<" "<<j<<endl;
            }
         }
    }
	return 0;
}

Measured memory_bytes: 3116
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
int N, M, Q, q[60][4], A[15] = { 1 }, res;
int check() {
    int ans = 0;
    for (int i = 1; i <= Q; i++) 
        if (A[q[i][1]] - A[q[i][0]] == q[i][2])ans += q[i][3];
        return ans;    
}
void dfs(int stp){
    if(stp>N){
        res = max(res, check());
        return;
    }
    for (int i = A[stp - 1]; i <= M; i++) {
        A[stp] = i;
        dfs(stp + 1);
        A[stp] = 0;
    }
}
int main() {
    scanf("%d%d%d", &N, &M, &Q);
    for (int i = 1; i <= Q; i++)
        for (int j = 0; j < 4; j++)
            scanf("%d", &q[i][j]);
    dfs(1);
    printf("%d\n", res);
    return 0;
}

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

#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 2000005;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(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;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

long long g(long long x, long long y) {
  return COM(x+y+2, x+1) - 1;
}
int main() {
  long long r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  COMinit();

  long long ans = g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1);
  ans %= MOD;
  while(ans < 0) ans += MOD;
  cout << ans << endl;
}


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

typedef long long ll;

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for (int r=0;r*R<=N;r++){
        for (int g=0;g*G<=N;g++){
          	int p = N - r*R - g*G;
            if (p >= 0 && p % B == 0){
              	ans++;
            }
        }
    }
    cout << ans << endl;
}

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

LL tag[800001], num[800001], qaq[200010], qp[200010];
LL QAQ = 0;

LL qpow(LL a, int b, LL p){
	return qp[b];
}

LL lc(LL p){
	return p << 1;
}

LL rc(LL p){
	return p << 1 | 1;
}

void pushup(LL p, int l, int r){
	int mid = (l + r) >> 1;
	num[p] = num[lc(p)] * qpow(10, (r - mid), 998244353) + num[rc(p)];
	num[p] %= 998244353;
}

void build(LL p, LL l, LL r){
	if (l == r){
		num[p] = 1;
		return;
	}
	LL mid = (l + r) >> 1;
	build(lc(p), l, mid);
	build(rc(p), mid + 1, r);
	pushup(p, l, r);
}

void upd(LL p, LL l, LL r, LL x){
	tag[p] = x;
	num[p] = qaq[r - l + 1] * x % 998244353;
}

void pushdown(LL p, LL l, LL r){
	LL mid = (l + r) >> 1;
	upd(lc(p), l, mid, tag[p]);
	upd(rc(p), mid + 1, r, tag[p]);
	tag[p] = 0;
}

void change(LL L, LL R, LL l, LL r, LL p, LL x){
	if (L <= l && r <= R){
		tag[p] = x;
		num[p] = qaq[r - l + 1] * x % 998244353;
		return;
	}
	if (tag[p]) pushdown(p, l, r);
	LL mid = (l + r) >> 1;
	if (L <= mid) change(L, R, l, mid, lc(p), x);
	if (R >= mid + 1) change(L, R, mid + 1, r, rc(p), x);
	pushup(p, l, r);
}

void Q(LL L, LL R, LL l, LL r, LL p){
	if (L <= l && r <= R){
		QAQ *= qpow(10, r - l + 1, 998244353);
		QAQ %= 998244353;
		QAQ += num[p];
		return;
	}
	if (tag[p]) pushdown(p, l, r);
	LL mid = (l + r) >> 1;
	if (L <= mid){
		Q(L, R, l, mid, lc(p));
	}
	if (R >= mid + 1) Q(L, R, mid + 1, r, rc(p));
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	LL n, m;
	cin >> n >> m;
	qp[0] = 1;
	for (int i = 1; i <= n; i++){
		qp[i] = qp[i - 1] * 10;
		qp[i] %= 998244353;
	}
	build(1, 1, n);
	long long ans = 0;
	for (int i = 1; i <= n; i++){
		qaq[i] = qaq[i - 1] + qpow(10, i - 1, 998244353);
		qaq[i] %= 998244353;
	}
	ans = qaq[n];
	for (LL i = 1; i <= m; i++){
		QAQ = 0;
		LL l, r, x;
		cin >> l >> r >> x;
		Q(l, r, 1, n, 1);
		LL awa = QAQ;
//		cout << awa << endl;
		ans -= awa * qpow(10, n - r, 998244353) % 998244353;
		while (ans < 0) ans += 998244353;
		QAQ = 0;
		ans %= 998244353;
		change(l, r, 1, n, 1, x);
		awa = qaq[r - l + 1] * x % 998244353;
		ans += awa * qpow(10, n - r, 998244353);
		ans %= 998244353;
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

#define fastio cin.tie(NULL);cout.tie(NULL);ios_base::sync_with_stdio(0);
#define debug(x) cout << x << endl;
#define endl '\n'
#define sz(x) (int)x.size()
#define popcount __builtin_popcount
#define MAXN 2005
#define LOG 20
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define pb push_back
#define int long long

typedef long long ll;
typedef pair <ll, ll> pii;
typedef vector <int> vi;
typedef vector <pii> vii;
typedef vector <vi> matriz;

int n;
int v[MAXN];

int C(int n, int k) {
    double res = 1;
    for (int i = 1; i <= k; ++i)
        res = res * (n - k + i) / i;
    return (int)(res + 0.01);
}

int32_t main(){
    fastio
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> v[i];
    int l, r, mid, opt;
    int res = 0;
    sort(v + 1, v + n + 1);

    for(int i = n; i > 2; i--){
        for(int j = 1; j < i - 1; j++){
            l = j, r = i;
            opt = -1;
            while(l <= r){
                mid = (l + r) / 2;
                //cout << i << " " << j << " " << l << " " << r << " " << mid << endl;
                if(v[i] < v[mid] + v[j] && v[mid] < v[i] + v[j] && v[j] < v[mid] + v[i] && mid != j){
                    if(mid != i && mid != j) opt = mid;
                    r = mid - 1;
                } else  l = mid + 1;
            }
            if(opt != -1 && opt < i){
                
                res += (i - opt);
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int n;
  cin>>n;
  map<int,int> m;
  for (int i = 0; i < n-1; i++){
    int j;
    cin>>j;
    m[j]++;
  }
  for(int i=1;i<=n;i++){
    cout<<m[i]<<endl;
  }
  
}

Measured memory_bytes: 13012
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
string S;
cin >> N;
vector<string> gacha;
for(int i=0; i<N; i++){
cin >> S;
gacha.push_back(S);
}
sort(gacha.begin(),gacha.end());
int count = 1;
for(int i=1; i<N; i++){
if(gacha.at(i-1)!=gacha.at(i)){
  count++;
}
}
cout << count << endl;
}


Measured memory_bytes: 11660
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for (int i=1;i<=n;i++)
#define REP(i,a,b) for (int i=a;i<=b;i++)
 
#define pb push_back
 
typedef long long ll;

const int inf=0x3f3f3f3f;
const int N=10000+10;

ll a[5];
int n;
int main() {
 
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	//freopen("in.txt","r",stdin);
	FOR(i,4) cin>>a[i];
	ll Q=a[1],H=a[2],S=a[3],D=a[4];
	cin>>n;
	int p=0,p2=0;
	int mn=inf,mn2=inf;
	FOR(i,4) {
		if ((1<<(4-i))*a[i]<mn) {
			mn2=mn;
			p2=p;
			mn=(1<<(4-i))*a[i];
			p=i;
		} else if ((1<<(4-i))*a[i]<mn2) {
			mn2=(1<<(4-i))*a[i];
			p2=i;
		}
	}
	if (p==4) {
		if (n%2==0) {
			cout<<n/2*D<<endl;
		} else {
			ll ans=n/2*D;
			n=1;
			if (p2==1) ans+=4*Q;
			if (p2==2) ans+=2*H;
			if (p2==3) ans+=S;
			cout<<ans<<endl;
		}
	} else {
		if (p==1) cout<<4*n*Q<<endl;
		if (p==2) cout<<2*n*H<<endl;
		if (p==3) cout<<n*S<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  string S;
  cin >> S;

  ll x = 0;
  ll maxi = 0;

  rep(i, N){
    x = S[i] == 'I' ? x + 1 : x - 1;
    maxi = max(x, maxi);
  }

  cout << maxi << endl;
  
  return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}
#define int ll
string n;
int k;

void read() {
	cin >> n >> k;
}

ll calc(int len, int cnt) {
	if (cnt == 0) return 1;
	if (cnt == 1) return len * 9;
	if (cnt == 2) return len * (len - 1) / 2 * 9 * 9;
	return len * (len - 1) * (len - 2) / 6 * 9 * 9 * 9;
}

ll solve(string n, int cnt, int pos) {
	// Осталось слишком мало цифр
	if (cnt > n.size() - pos) return 0;
	
	// Дошли до конца
	if (pos == n.size()) {
		return cnt == 0;
	}
	
	// Всё остальное нули
	if (cnt == 0) return 1;
	
	ll ans = 0;
	
	// поставили n[pos]
	if (n[pos] > '0')
		ans += solve(n, cnt - 1, pos + 1);
	else
		ans += solve(n, cnt, pos + 1);
	//cout << "cnt = " << cnt << " pos = " << pos << " ans = " << ans << endl;
	
	int len = n.size() - pos - 1;
	int fcnt = 0;
	if (n[pos] - '0' > 1)
		fcnt = n[pos] - '0' - 1;
	//cout << "len = " << len << " fcnt = " << fcnt << endl;
	if (len >= cnt - 1)
		ans += calc(len, cnt - 1) * fcnt;
	//cout << "ans = " << ans << endl;
	if (len >= cnt && n[pos] > '0')
		ans += calc(len, cnt);
	//cout << "ans = " << ans << endl;
	return ans;
}

ll ans;

void run() {
	ans = solve(n, k, 0);
}

void write() {
	cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
string s,ss;
int main()
{
	fast;
	cin>>s;
	ss=s;
	for (int i=0;i<=s.size()-1;i++)
	   if (s[i]=='b')
		    s[i]='d';
		 else if (s[i]=='d')
		    s[i]='b';
		 else if (s[i]=='p')
		    s[i]='q';
		 else
		    s[i]='p';
	reverse(s.begin(),s.end());
	for (int i=0;i<=s.size()-1;i++)
	   if (s[i]!=ss[i])
		 {
			 cout<<"No\n";
			 return 0;
		 }
	cout<<"Yes\n";
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+5;
void solve(){
	int n; 
	cin>>n; 
	int a[1234];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3592
// Sasageyo! Sasageyo! Shinzou wo Sasageyo !
// https://goo.gl/IwJzbx

#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

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

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define endl '\n'

int main()
{
	fast_io;
  int n;
  cin >> n;
  VI x(n+1);
  for(int i=1;i<=n;i++)
    cin >> x[i];
  int cl = 1;
  int  iter = 0;
  while(cl != 2) {
    ++iter;
    if(iter > 1e6) {
      iter = -1;
      break;
    }
    cl = x[cl];
  }
  cout << iter << endl;
	return 0;
}

Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

void fail() {
    puts("-1");
    exit(0);
}

int main() {
    int N; scanf("%d", &N);

    bool valid = true;
    vector<ll> two(N+1, 1), max_v(N+1, 1);
    for(int i=1; i<=N; i++) two[i] = min(two[i-1] << 1, 1LL << 50);
    vector<ll> A(N+2, INF);
    for(int i=0; i<=N; i++) {
        scanf("%lld", &A[i]);
        valid &= (A[i] <= two[i]);
        if(A[i] == two[i]) valid &= (i == N);
        if(!valid) fail();
    }
    for(int i=0; i<N; i++) {
        valid &= ((A[i+1] + 1) / 2 + A[i] <= two[i]);
        if(!valid) fail();
    }
    
    // 下から決定
    for(int i=0; i<N; i++) {
        max_v[i+1] = (max_v[i] - A[i]) << 1;
        chmin(max_v[i+1], 1LL << 50);
    }
    if(max_v[N] < A[N]) fail();
    max_v[N] = min(max_v[N], A[N]);
    // 上から決定
    for(int i=N; i>0; i--) {
        chmin(max_v[i-1], max_v[i] + A[i-1]);
        chmin(max_v[i-1], two[i-1]);
    }

    for(int i=0; i<N; i++) {
        if(max_v[i] < (max_v[i+1] + 1) / 2 + A[i]) fail();
    }

    ll ans = 0, lb = A[N], ub = A[N];
    for(int i=N; i>=0; i--) {
        fprintf(stderr, "ma = %lld\n", max_v[i]);
        /*
        fprintf(stderr, "lb = %lld, ub = %lld, max = %lld\n", lb, ub, max_v[i]);
        ans += ub;
        if(i == 0) continue;
        ub = min({two[i-1], ub + A[i-1], max_v[i-1]});
        lb = (lb + 1) / 2 + A[i-1];
        */
        ans += max_v[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5768
import sys,math
input = sys.stdin.readline

A,B,H,M=list(map(int,input().split()))
wth = 2*math.pi/12/60
whm = 2*math.pi/60
radh = (H*60+M)*wth
radm = M*whm
rad = radh-radm
print((A**2+B**2-2*A*B*math.cos(rad))**0.5)


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

int main() {
  int n,k; cin >> n >> k;
  int ans = k;
  rep(i,n-1) {
    ans *= (k-1);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int64_t N;
  string S;
  cin>>N>>S;
  int64_t K=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R') K++;
  }
  int64_t L=0;
  for(int i=0;i<K;i++){
    if(S.at(i)=='R') L++;
  }

  cout<<K-L<<endl;
}
 

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

map<int, int> store;
pair<int, int> nxt[200007];

bool cmp(pair<int, int> a, pair<int, int> b)
{
    if (a.second < b.second) return true;
    return false;
}

int main()
{
    int N, K;
    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        store[tmp]++;
    }

    int id = 0;
    for (auto x : store) {
        nxt[id].first = x.first;
        nxt[id].second = x.second;

        id++;
    }

    if (K >= id) {
        cout << "0\n";
        return 0;
    }

    sort(nxt, nxt+id, cmp);

    int cnt = 0;
    for (int i = 0; i < id; i++) {
        cnt += nxt[i].second;
        //cout << nxt[i].first << ' ' << nxt[i].second << endl;
        if (id - (i+1) == K) break;
    }

    cout << cnt << "\n";
}


Measured memory_bytes: 11136
// skip until line 65
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
struct Vec;
//set<int, Comparator> S;

// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
ll table[3010][3010];
ll mod=998244353;
long long invMod(int n, int p) {
    long long power = n;
    long long res = 1;
    long long index = p -2;
    for(int i=0;(index >> i )!= 0;++i) {
        if( ((index >> i) & 1) ==1) {
            res = (res*power) %p;
        }
        power = (power*power) %p;
    }
    return res;
}
ll powx(ll n, ll x) {
    long long power = n;
    long long res = 1;
    long long index = x;
    for(int i=0;(index >> i )!= 0;++i) {
        if( ((index >> i) & 1) ==1) {
            res = (res*power) %mod;
        }
        power = (power*power) %mod;
    }
    return res;

}
int main() {
    cout.precision(15);
    cout << fixed;
    ll N,S;
    ll inv2=invMod(2,mod);
    cin >> N>>S;
    vector<ll> As(N);
    REP(i,N) {
        cin>>As[i];
    }
    memset(table,0,sizeof(table));
    for(int i=0;i<N;++i) {
        for(int j=0;j<3010;++j) {
            table[i+1][j]=table[i][j]+((j-As[i]>0)?AS_MOD(table[i][j-As[i]]*inv2,mod):0);
            table[i+1][j]=AS_MOD(table[i+1][j],mod);
            if (j==As[i]) {
                table[i + 1][As[i]] += powx(2, N - 1);
                table[i + 1][As[i]] = AS_MOD(table[i + 1][As[i]], mod);
            }
        }
    }
    cout<<table[N][S]<<endl;
}


Measured memory_bytes: 74420
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
const int MAXN = 500000;
char S[MAXN + 5]; int N;
int d[MAXN + 5], f[MAXN + 5];
int main() {
	scanf("%s", S + 1), N = strlen(S + 1) + 1;
	for(int i=1;i<N;i++)
		if( S[i] == '>' ) d[i]++;
		else d[i+1]++;
	queue<int>que;
	for(int i=1;i<=N;i++)
		if( d[i] == 0 ) que.push(i);
	while( !que.empty() ) {
		int x = que.front(); que.pop();
		if( S[x - 1] == '>' ) {
			d[x-1]--, f[x-1] = max(f[x-1], f[x] + 1);
			if( d[x-1] == 0 )
				que.push(x - 1);
		}
		if( S[x] == '<' ) {
			d[x+1]--, f[x+1] = max(f[x+1], f[x] + 1);
			if( d[x+1] == 0 )
				que.push(x + 1);
		}
	}
	long long sum = 0;
	for(int i=1;i<=N;i++)
		sum += f[i];
	printf("%lld\n", sum);
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

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

  int sum = 0;
  int p;
  int pmax = 0;

  for( int i=0; i<N; i++ ){
    cin >> p;
    sum += p;
    if( p > pmax ) pmax = p;
  }
  sum -= pmax / 2;

  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
vector<long long> v;
const long long mod = 1e9 + 7;

int main() {
    int n, k, pos = 0;
    bool zeros = false;
    scanf("%d %d", &n, &k);
    for (int i = 0; i != n; i++) {
        long long j;
        scanf("%lld", &j);
        pos += j > 0;
        zeros |= !j;
        v.push_back(j);
    }
    sort(v.begin(), v.end());
    long long ans = 1;
    long long l = 0, r = n - 1;
    if (k & 1)ans = v[r--], k--;
    while (k) {
        long long lf = v[l] * v[l + 1], rt = v[r] * v[r - 1], c = ans > 0 ? 1 : -1;
        if (lf * c > rt * c) {
            l += 2;
            ans = ans * (lf % mod) % mod;
        } else {
            r -= 2;
            ans = ans * (rt % mod) % mod;
        }
        k -= 2;
    }
    printf("%lld", (ans + mod) % mod);
    return 0;
}

Measured memory_bytes: 5332
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

long GetLCM(const long &a, const long &b){
    long x = max(a,b);
    long y = min(a,b);
    while(x % y != 0){
        long t = x % y;
        x = y;
        y = t;
    }
    return a * b / y;  
}

int main(){
    long n,m;
    scanf("%ld %ld", &n, &m);
    printf("%ld", GetLCM(n,m));
    return 0;
}


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		//long k = sc.nextLong();
		//long l = sc.nextLong();
		long count=0;
		long[] array=new long[3];

		/*for(int i=0;i<=3;i++) {
			if(s.substring(i,i+1).equals("+")) {
				count++;
			}else {
				count--;
			}
		}*/
		//Arrays.sort(array);
		/*if(n%m==0) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}*/
		System.out.println(n*m-n-m+1);
		//System.out.println(Math.abs(array[2]-array[1])+Math.abs(array[1]-array[0]));
	}
}




Measured memory_bytes: 21844
#include<cmath>
#include<cstdio>
#include<algorithm>
#define INF 0x3f3f3f3f
const int MAXN=100+10;
int n;
int w[MAXN];
int s1,s2;
int ans=INF;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&w[i]);
	for(int t=1;t<n;t++){
		s1=0;s2=0;
		for(int j=1;j<=t;j++) s1+=w[j];
		for(int j=t+1;j<=n;j++) s2+=w[j];
		ans=std::min(ans,abs(s1-s2));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int K = 0;
        if(b > (a + W)) K = b - (a + W);
        else if((b+W) < a) K = a - (b + W);
        System.out.println(K);
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  string s;
  int q;
  cin >> s >> q;
  int rev = 0;
  string head, foot;
  rep(i, q){
    int t;
    cin >> t;
    if(t == 1) rev++;
    else if(t == 2){
      int f; char c;
      cin >> f >> c;
      if(f == 1){
        if(rev % 2 == 0) head += c;
        else foot += c;
      }else{
        if(rev % 2 == 1) head += c;
        else foot += c;
      }
    }
  }
  reverse(head.begin(), head.end());
  string ans = head + s + foot;
  if(rev % 2 == 0) cout << ans << endl;
  else{
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
#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 ALL(a) a.begin(),a.end()
typedef long long ll;

int Roundup(int a,int b){
    return (a+b-1)/b;
}


int main()
{
    int N,D,A;
    int x,h;
    cin >> N >> D >> A;
    vector<pair<int,int>> M;
    vector<int> X,H;
    REP(i,N){
        cin >> x >> h;
        M.push_back({x,h});
    }

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

    REP(i,N){
        X.push_back(M[i].first);
        H.push_back(M[i].second);
        H[i] = Roundup(H[i],A);
    }
    vector<int> Hs;
    Hs.push_back(H[0]);
    FOR(i,1,N)Hs.push_back(H[i]-H[i-1]);
    //REP(i,N)cout << X[i] << " " << Hs[i] << endl;

    ll count = 0;
    int now = 0;
    REP(i,N){
        now += Hs[i];
        if(now<=0)continue;
        auto it = upper_bound(X.begin(),X.end(),X[i]+2*D);
        if(Hs.size()>it-X.begin()){
            Hs[(int)(it-X.begin())]+=now;
        }
        Hs[i]-=now;
        count+=now;
        now = 0;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 5488
W = input()

D = {}

flag = 0

for w in W:
    if w in D:
        D[w] += 1
    else:
        D[w] = 1


for v in D.values():
    if v % 2 == 1:
        flag = 1
        continue
    else:
        pass

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



Measured memory_bytes: 2940
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Ans = []
for y in range(H):
    for x in range(W-1):
        if A[y][x] % 2:
            A[y][x+1] += 1
            Ans.append("{} {} {} {}".format(y+1, x+1, y+1, x+2))
x = W-1
for y in range(H-1):
    if A[y][x] % 2:
        A[y+1][x] += 1
        Ans.append("{} {} {} {}".format(y+1, x+1, y+2, x+1))
N = len(Ans)
print(N)
if N>0:
    print("\n".join(Ans))


Measured memory_bytes: 20120
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan =  new Scanner(System.in);
		int N = scan.nextInt();
		int A = scan.nextInt();
		int[] num = new int[N];
		for(int i=0;i<N;i++){
			num[i] = scan.nextInt();
		}
		for(int i=0;i<N-A;i++){
			int p = num[i];
			int k = num[i+A];
			if(p<k){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}
}


Measured memory_bytes: 52232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#ifndef ONLINE_JUDGE
#define OJ \
    freopen("input.txt", "r", stdin); \
    //freopen("output.txt", "w", stdout);
#else
#define OJ ;
#endif
#define fo(int, i, l, r) for ( int i = l ; i < r ; ++ i)
#define srtV(a) sort(a.begin(),a.end())
void solve()
{
    int n,x,t;
    cin>>n>>x>>t;
    cout<<((x-1+n)/x)*t<<"\n";
}
signed main()
{
    OJ
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //int _t;cin>>_t;while(_t--)
    solve();
    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

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

        int N = Integer.parseInt(scanner.next());
        List<Integer> d = new ArrayList<>();

        for(int i = 0; i < N; i++) {
            d.add(Integer.parseInt(scanner.next()));
        }

        int sum = 0;

        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                sum = sum + d.get(i) * d.get(j);
            }
        }

        System.out.println(sum);

        scanner.close();
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
//#include <queue>

using namespace std;
#define n_max 10000
#define INF 10001000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rep2(i, a, n) for(int i = a; i <= n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define rrep2(i, a, n) for(int i = a; i >= n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

int main()
{
    int A, B;

    cin >> A >> B;

    if((A+B)%2!=0) { cout << "IMPOSSIBLE" << endl; return 0;}

    cout << (A+B)/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  vvl c(3,vl(3)); vl a(3); vl b(3);
  
  rep(i,3){
    rep(j,3){
      cin >> c[i][j];
    }
  }
 
  
  b[0] = c[0][0];
  b[1] = c[0][1];
  b[2] = c[0][2];
  a[1] = c[1][0] - b[0];
  a[2] = c[2][0] - b[0];
  
  bool flag = true;
  for(ll i=1; i < 3; i++){
    for(ll j=1; j < 3; j++){
      if(a[i] + b[j] != c[i][j]) flag = false;
    }
  }
  
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
n=int(input())
check=[[0]*9 for i in range(9)]
for i in range(1,n+1):
    s=str(i)
    s1=int(s[0])-1
    s2=int(s[-1])-1
    if s2==-1:continue
    check[s1][s2]+=1
cnt=0
for i in range(9):
    for j in range(9):
        cnt+=check[i][j]*check[j][i]
print(cnt)


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
	int darah;
	int damage;
	int mantap;
	scanf("%d %d", &darah, &damage);
	mantap=darah%damage==0? mantap=darah/damage : mantap=darah/damage+1;
	printf("%d", mantap);
	
	
	
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int x,n; cin >>x >>n; int ans;
  vector<bool>v(102,1);
  for(int i=0; i<n; i++){
    int a; cin >>a;
    v[a]=0;
  }
  for(int i=0; i<51; i++){
    if(v[x-i]){ans=x-i; break;}
    if(v[x+i]){ans=x+i; break;}
  }
  cout <<ans;
return 0;}

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

int main(void){
    int A,B,ans=0;
    cin>>A>>B;
    for(;ans<10000;ans++){
        double a=(double)ans;
        if(int(a*0.08)==A&&int(a*0.1)==B){
            break;
        }
    }
    if(ans==10000)ans=-1;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from fractions import gcd
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N = inputI()
C = inputIL()

C.sort()

if N == 1:
  print((C[0]*2)%MOD)
  exit()

MAX = (N+1)*pow(2,N-2,MOD)
MIN = pow(2,N-1,MOD)

d = inv(N-1) * (MAX-MIN) % MOD
  
ans = 0
for i in range(N):
  ans = (ans + (C[N-1-i] * (MIN+d*i)) % MOD ) % MOD

ans = (ans * pow(2,N,MOD)) % MOD
  
print(ans)

Measured memory_bytes: 104400