akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var h = ReadInts();
            Array.Reverse(h);

            for (int i = 0; i < n-1; i++)
            {
                if (h[i] >= h[i + 1])
                {
                    //ok
                }
                else if (h[i] - h[i + 1] == -1)
                {
                    //ok
                    h[i + 1] = h[i + 1] - 1;
                }
                else
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数

        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        //文字数を数える
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }
    }
}


Measured memory_bytes: 24668
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n;

    vector<int> a;

    cin >> n;

    for (int i = 0; i < n; ++i) {
        int v;
        cin >> v;
        a.push_back(v);
    }

    int size = a.size();

    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());

    cout << (size == a.size() ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define pr printf
#define sc scanf

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef long double ld;
int n;
int a[100010];
int b[100010];

int main () {
    vector<ll> v(13, 0LL);
    v[0] = 1;
    char ch = getchar();
    while(ch != '\n') {
        vector<ll> nextv(13, 0LL);
        if(ch == '?') {
            for(int i = 0; i <= 9; i++) {
                for(int j = 0; j < 13; j++) {
                    int md = ((j*10)+i)%13;
                    nextv[md] = (nextv[md] + v[j]) % 1000000007LL;
                }
            }
        } else {
            int i = ch-'0';
            for(int j = 0; j < 13; j++) {
                int md = ((j*10)+i)%13;
                nextv[md] = (nextv[md] + v[j]) % 1000000007LL;
            }
        }
        v = nextv;
        ch = getchar();
    }
    pr("%lld\n", v[5]);
    return 0;
}


Measured memory_bytes: 256
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end


n,m = inp
a = inp
a.sort!.reverse!
if a[m-1] >= sum(a)/4.0/m
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

int n, a[100000]; long long s[200000];

inline int reader()
{
	int ret = 0;

	while (true)
	{
		char c = getchar();

		if (c == '\n') break;

		ret = (ret << 1) + (ret << 3) + c - 48;
	}

	return ret;
}

long long sum(int l, int r)
{
	return s[r] - s[l];
}

int main()
{
	n = reader();

	for (int i = 0; i < n; i++) a[i] = reader();

	s[0] = 0; for (int i = 1; i < 2 * n; i++) s[i] = s[i - 1] + a[(i - 1) % n];

	long long ret = 0, sums = s[n];

	for (int i = 0; i < n; i++)
	{
		int posr1 = lower_bound(s, s + 2 * n + 1, s[i] + sums / 3) - s;
		int posl1 = posr1 - 1;
		int posr2 = lower_bound(s, s + 2 * n + 1, s[i] + sums * 2 / 3) - s;

		ret = max(ret, min({ sum(i, posl1), sum(posl1, posr2), sum(posr2, i + n) }));
		ret = max(ret, min({ sum(i, posr1), sum(posr1, posr2), sum(posr2, i + n) }));
	}

	printf("%lld\n", ret);

	return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
ll a[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0;i < n; i++) {
        cin >> a[i];
    }
    ll cur_sum, res, ans;

    cur_sum = 0, res = 0;
    for (int i = 0; i < n; i++) {
        cur_sum += a[i];
        if (i % 2 == 1 && cur_sum <= 0) {
            res += 1 - cur_sum;
            cur_sum = 1;
        }
        if (i % 2 == 0 && cur_sum >= 0) {
            res += cur_sum + 1;
            cur_sum = -1;
        }
    }
    ans = res;

    cur_sum = 0, res = 0;
    for (int i = 0; i < n; i++) {
        cur_sum += a[i];
        if (i % 2 == 0 && cur_sum <= 0) {
            res += 1 - cur_sum;
            cur_sum = 1;
        }
        if (i % 2 == 1 && cur_sum >= 0) {
            res += cur_sum + 1;
            cur_sum = -1;
        }
    }
    ans = min(ans, res);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<cmath>
#include<limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <memory>
#include <numeric>
#include <type_traits>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
typedef long long ll;

 
int main() {
    ll x; cin >> x;
    ll m = 100;
    int count = 0;
    while(m < x){
        m = m*1.01;
        ++count;
    }

    cout << count << endl;
    
    
    



    return 0;
}

Measured memory_bytes: 3620
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

// int dx[4] = {0, 1, 0, -1}; // x軸方向への変位
// int dy[4] = {1, 0, -1, 0}; // y軸方向への変位
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int main(void) {
  int H, W;
  bool flag = false;
  cin >> H >> W;
  char arr[H][W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (arr[i][j] == '#') {
        flag = false;
        for (int k = 0; k < 4; k++) {

          int y = i + dy[k];
          int x = j + dx[k];
          if (y < 0 || x < 0 || y >= H || x >= W)
            continue;
          if (arr[y][x] == '#')
            flag = true;
        }
        if (!flag) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

char a,b;

int main(){
    cin >> a >> b;
    cout << (a == b ? 'H' : 'D') << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

const int MAXN = 200005;
LL a[MAXN];

int n;

int main() {
    GI(n);

    LL sum = 0;

    FOR1(i, n) {
        GLL(a[i]);
        sum += a[i];
    }

    LL curr = 0, res = 1LL * INF * INF;

    FOR1(i, n-1) {
        curr += a[i];
        res = min(res, abs(curr - (sum - curr)));
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
using P = pair<int, int>;
int main(){
    int n;
    cin >> n;
    vector<P> b_p, b_m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        int mn = 0, fin = 0;
        for(int j = 0; j < s.size(); j++){
            if(s[j] == ')'){
                fin--;
                mn = min(mn, fin);
            }else{
                fin++;
            }
        }
        if(fin >= 0) b_p.emplace_back(mn, fin);
        else b_m.emplace_back(mn - fin, -1 * fin);
    }
    sort(b_p.begin(), b_p.end(), greater<P>());
    sort(b_m.begin(), b_m.end(), greater<P>());
    bool f = true;
    int h1 = 0;
    for(auto p : b_p){
        if(h1 + p.first < 0){
            f = false;
        }
        h1 += p.second;
    }
    int h2 = 0;
    for(auto p : b_m){
        if(h2 + p.first < 0){
            f = false;
        }
        h2 += p.second;
    }
    f &= (h1 == h2);
    if(f) cout <<"Yes";
    else cout <<"No";
    /*for(auto p : b_p){
        cout << p.first << " " << p.second << "\n";
    }
    cout << " 天才";
    for(auto p : b_m){
        cout << p.first << " " << p.second << "\n";
    }*/
}

Measured memory_bytes: 11332
//organize and stay in moment - Abhinav IIIT-A
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,x,n) for(int i=x;i<n;++i)
#define ar array
#define MAXN (int)2e5+5
#define pb push_back
#define ld long double
int mod= 1e9+7;
int mod2=998244353;
int arr[MAXN];
int as;
void input(){
  cin>>as;
  f(i,0,as) cin>>arr[i];
}
int nc2(int n){
	if(n<2)
	return 0;
	int p=n-1;
	if(n&1)
		p/=2;
	else n/=2;
	p*=n;
	return p;
}
bool isPallin(string s){
	int n=s.size();
	f(i,0,n/2)
	if(s[i]!=s[n-i-1])
	return 0;
	return 1;
}
void solve(){
	ld l; cin>>l;
	ld a=l/3;
	ld r=1;
	r*=a;r*=a;r*=a;
	cout << fixed << setprecision(10) << r <<"\n"; 
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t; t=1; //cin>>t;
  while(t--) solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;

int euclid(int a, int b){
    if (a%b == 0)
        return b;
    if (b%a == 0)
        return a;
    return (a>b) ? euclid(a%b, b) : euclid(a, b%a);
}

int main() {
    int a, b;
    cin >> a >> b;

    cout << euclid(a, b) << endl;
    return 0;
}

Measured memory_bytes: 1160
using System;

class P
{
    public static void Main()
    {
        
        for(int i = 0; i < 10000; i++)
        {
            string[] str = Console.ReadLine().Split(' ');
        
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            
            if(a < b)
                Console.WriteLine(a + " " + b);
            else if(a > b)
                Console.WriteLine(b + " " + a);
            else if(a == 0 & b == 0)
                break;
            else if(a == b)
                Console.WriteLine(a + " " + b);
        }
    }
}


Measured memory_bytes: 17908
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int t = sc.nextInt();
    int min =1001;
    for(int i = 0; i < n; i++){
      int c = sc.nextInt();
      int tmp = sc.nextInt();
      if(t >= tmp){
        min = Math.min(min, c);
      }
    }
    if(min == 1001){
      System.out.println("TLE");
    }else{
      System.out.println(min);
    }
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define int long long
using namespace std;
typedef long long ll;
const int INF = 1e9;

int N;
int L[210];

signed main()
{
    cin >> N;
    REP(i,2*N) cin >> L[i];

    sort(L, L + 2 * N);
    int ans = 0;
    for (int i=0; i<2*N; i+=2) {
        ans += L[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream&o,const pair<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
template<typename T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e6+1;

int n;
ll f[N], s[N], ss[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  ll ma = 0, ans = 0;
  FOR(i, 0, n){
    ll a;
    cin >> a;
    maxs(ma, a);
    (s[a] += a) %= MOD;
    (ss[a] += a*a) %= MOD;
  }
  ma++;
  FOR(i, 1, ma){
    ll a = (modInv(i, MOD) - f[i]%MOD + MOD) % MOD, t=0, tt=0;
    for(int j=i; j<ma; j+=i){
      f[j] += a;
      t += s[j];
      tt += ss[j];
    }
    t %= MOD;
    tt %= MOD;
    ans += (t*t%MOD-tt)*a%MOD;
  }
  cout << (ans%MOD * modInv(2, MOD) % MOD + MOD) % MOD << endl;
}

Measured memory_bytes: 23680
function Main(input) {
  input=input.split("\n");
  var array=['AC','WA','TLE','RE'];
  var times=[0,0,0,0];
  for(var i=1;i<input.length;i++){
    times[array.findIndex(e=>{return e===input[i];})]++;
  }
  for(var i=0;i<4;i++){
    console.log(array[i],'x',times[i]);
  }
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 38308
#include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
using namespace std;

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

    int n;
    cin>>n;
    int a[n], cnt = 0;
    rep(i, n){
        cin>>a[i];
    }
    int maxv = -2000000000;
    int minv = a[0];
    for(int j = 1; j < n; j++){
        maxv = max(maxv, a[j]-minv);
        minv = min(minv, a[j]);
    }

    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3924
//755

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

set<int>ans;

bool chk(string t){
    bool c[3] = {false,false,false};
    rep(i,0,t.size()){
        if(t[i]=='7')c[0]=true;
        else if(t[i]=='5')c[1]=true;
        else if(t[i]=='3')c[2]=true;
    }
    if(c[0]&&c[1]&&c[2])return true;
    else return false;
}

void dfs(string s,int keta,string n){
    if(s.size()==keta)return;
    char c[3] = {'7','5','3'};
    rep(i,0,3){
        string t = s;
        t.pb(c[i]);
        if(stoi(t)<=stoi(n)){
            if(chk(t)){
                ans.insert(stoi(t));
            }
            dfs(t,keta,n);
        }
    }
}

signed main (){
    string n;cin>>n;
    int keta = n.size();
    string s = "";
    dfs(s,keta,n);
    cout<<ans.size()<<nnn;
    return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
int main() {
  long int N, A, B;
  cin >> N >> A >> B;
  if ((N % (A + B)) < A) {
    cout << (N / (A + B) * A + (N % (A + B))) << endl;
  }
  else {
    cout << (N / (A + B) + 1) * A << endl;
  }
}
  

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <bitset>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define int long long 
#define eps 1e-8
#define fi first
#define se second
#define endl '\12'
#define eb emplace_back
#define SZ(a) int32_t(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
constexpr int mod = 1e9+7;
constexpr int Erica = 998244353;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ex_gcd(ll a, ll b, ll& x, ll& y){if(!b){x=1;y=0;return a;}ll ret=ex_gcd(b,a%b,y,x);y-=a/b*x;return ret;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
int norm(int x) { return x >= mod ? (x - mod) : x; }
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
inline ll get_inv(ll a) { ll x, y; ex_gcd(a, mod, x, y); return norm(x + mod);}
template<class T>inline void umin(T &x, T y) {x = x > y ? y : x;}
template<class T>inline void umax(T &x, T y) {x = x < y ? y : x;}
template<class T>inline void dec(T &x, T y) {x -= y; if(x < 0) x += mod;}
template<class T>inline void add(T &x, T y) {x += y; if(x >= mod) x -= mod;}
const double PI = acos(-1.0);
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260817, P_2=999998639;
constexpr int maxn = 1e6+10; // remember to calculate. if tle, check maxn first.
int n , k , a[maxn];
bool chk(int x){
    int ret = 0;
    for(int i = 1; i <= n; i++){
        if(a[i] > x) {
            ret += (a[i]) / x;
        }
    }
    return ret <= k;
}
int32_t main()
{
    close;
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int l = 1 , r = INF;
    while(l <= r){
        int mid = (l + r) >> 1;
        if(chk(mid)) r = mid-1;
        else l = mid+1;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, res = 10e12; cin >> N;
  vecll AS(N);
  vecll ACC(N);
  REP(i, N) {
    cin >> AS[i];
    AS[i] -= (i+1);
  }
  sort(AS.begin(), AS.end());
  int idx = N/2;
  ll sm1 = 0;
  REP(i, N) {
    sm1 += abs(AS[i]-AS[idx]);
  }
  if (idx > 0) {
    ll sm2 = 0;
    REP(i, N) {
      sm2 += abs(AS[i]-AS[idx-1]);
    }
    cout << min(sm1, sm2) << endl;
  } else {
    cout << sm1 << endl;
  }
  return 0;
}
// 8+6+4+2+2


Measured memory_bytes: 3328
import java.util.*;

public class Main{
    char conv(char ch, int d){
	return (char)('a'+(int)(ch-'a'+d)%26);
    }

    Main(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int n = sc.nextInt();
	    if(n == 0) break;
	    int[] a = new int[n+1];
	    int[] b = new int[n+1];
	    char[] ch = (sc.next()).toCharArray();

	    for(int i = n-1; i >= 0; --i){
		a[i] = sc.nextInt();
		b[i] = sc.nextInt();
		a[i]--; b[i]--;
	    }

	    for(int i = 0; i < n; ++i){
		ch[a[i]] = conv(ch[a[i]], b[i]-a[i]);
		ch[b[i]] = conv(ch[b[i]], b[i]-a[i]);
		char tmp = ch[a[i]];
		ch[a[i]] = ch[b[i]];
		ch[b[i]] = tmp;
	    }

	    System.out.println(String.valueOf(ch));
	}
    }

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

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

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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;

int main(){
    int N;
    cin >> N;
    vector<double> v(N+1);
    double ans = 0.0000000000;

    for(int i = 0; i < N; i++){
        cin >> v[i];
       // cout << v[i] << endl;
    }
    sort(v.begin(),v.end());
    ans += v[1];

    for(int i = 2; i <= N; i++){
        ans =  (ans+v[i])/2;
    }
    cout << ans << endl;



}

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

int main() {
    // 入力
    int N, K;
    cin >> N >> K;
    vector<int>h(N);
    for (int i = 0; i < N ; ++i) {
        cin >> h[i];
    }

    vector<int>dp(N, -1);
    dp[0] = 0;
    for (int i = 1; i < N; ++i) {
        dp[i] = mod;
        // i+1-jからi+1へのジャンプ
        for (int j = 1; j < K+1 && i >= j; ++j) {
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }

    cout << dp[N-1];
    return 0;
}

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

int main() {
    int n;
    const int calpg[3] = {4, 9, 4};

    while (cin >> n, n) {
        int s[1001][4] = {0};
        for (int i = 0; i <= n; i++) {
            cin >> s[i][0] >> s[i][1] >> s[i][2] >> s[i][3];
        }

        bool na = true;
        for (int i = 0; i < n; i++) {
            bool suitable = true;
            int cal = 0;
            for (int j = 0; j < 3; j++) {
                cal += s[i][j+1] * calpg[j];
                if (s[i][j+1] > s[n][j]) suitable = false;
            }
            if (suitable && cal <= s[n][3]) {
                na = false;
                cout << s[i][0] << endl;
            }
        }
        if (na) cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
#define maxl 100010
using namespace std;

int n,m;
pair<int,int>p[maxl];
int a[maxl],f[maxl];
bool vis[maxl];
int cnt,res;
long long ans;
inline int find(int x)
{
	if(f[x]!=x)
		f[x]=find(f[x]);
	return f[x];
}

inline void prework()
{
	for(int i=1;i<=n;i++)
	{
		f[i]=i;
	}
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int u,v,x,y;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		u++;v++;
		x=find(u);y=find(v);
		if(x!=y)
			f[y]=x;
	}
	for(int i=1;i<=n;i++)
		x=find(i);
	for(int i=1;i<=n;i++)
		p[i]=make_pair(a[i],f[i]);
	sort(p+1,p+1+n);
}

inline void mainwork()
{
	cnt=n-m,res=0;
	ans=0;
	for(int i=1;i<=n;++i)
		if(!vis[p[i].second])
		{
			--cnt;
			ans+=p[i].first;
			++res;
			vis[p[i].second]=1;
		}
		else
		{
			if(res+cnt<(n-m-1)*2)
				ans+=p[i].first,++res;
		}
}

inline void print()
{
	if((n-m-1)==0)printf("0\n");
	else if(cnt==0&&res==(n-1-m)*2)
		printf("%lld\n",ans);
	else
		puts("Impossible");
}

int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		prework();
		mainwork();
		print();
	}
	return 0;
}
 

Measured memory_bytes: 1920
import sys

def read_str(): return sys.stdin.readline().strip()
def read_int(): return int(sys.stdin.readline().strip())
def read_ints(): return map(int, sys.stdin.readline().strip().split())
def read_str_split(): return list(sys.stdin.readline().strip())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))

def Main():
    l, r = read_ints()
    ans = 2020
    if r - l >= 2019:
        print(0)
        exit()
    for i in range(l, r + 1):
        for j in range(l, i):
            ans = min(ans, i * j % 2019)
    print(ans)

if __name__ == '__main__':
    Main()


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int h, w; cin >> h >> w;
    vector<string> lis(h);
    vector<vector<int> > flag(h, vector<int>(w, 1e9));
    queue<Pii> q;
    REP(i, 0, h){cin >> lis[i];}
    REP(i, 0, h){
        REP(l, 0, w){
            if(lis[i][l] == '#'){
                flag[i][l] = 0;
                q.push({i, l});
            }
        }
    }
    while(!q.empty()){
        Pii A = q.front();
        q.pop();
        int x = A.first, y = A.second;
        REP(i, 0, 4){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx >= 0 && ny >= 0 && nx < h && ny < w && flag[nx][ny] == 1e9){
                flag[nx][ny] = flag[x][y] + 1;
                q.push({nx, ny});
            }
        }
    }
    int ma  = 0 ;
    REP(i, 0, h){
        REP(l, 0, w){
            ma = max(ma, flag[i][l]);
        }
    }
    cout << ma << endl;
}

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

typedef long long int64;
#define REP(i, n) for(int64 i=0;i<(int64)(n);i++)
#define REPD(i, n) for(int64 i=(int64)(n)-1;i>=0;i--)
#define FOR(i, a, b) for(int64 i=(a);i<=(b);i++)
#define FORD(i, a, b) for(int64 i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int64)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define GSORT(x) sort(ALL(x), greater<int64>());
#define SUM(x) accumulate(ALL(A), 0);

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

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

using namespace std;

void Main() {

	int64 N, M;
	cin >> N >> M;
	string result = "a == b";

	if (N > M) result = "a > b";
	else if (N < M) result = "a < b";
	cout << result << endl;
	return;
}

int main() {
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}



Measured memory_bytes: 3180
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			BigInteger a = new BigInteger(scanner.next());
			BigInteger b = new BigInteger(scanner.next());
			System.out.println((a.equals(b) ? "EQUAL" : (a.compareTo(b) < 0) ? "LESS" : "GREATER"));
		}
	}
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 55, M = 3e3, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    string s;   cin >> s;

    int n = s.size();

    char a[n];
    for(int i = 0;i < n;i++)    a[i] = 'p';

    int score = 0, p = 0;
    for(int i = 0;i < n;i++){
        p++;

        if(p <= (i + 1 - p));
        else p--, a[i] = 'g';

        score += (a[i] == 'p' && s[i] == 'g');
        score -= (a[i] == 'g' && s[i] == 'p');
    }

    cout << score;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  vector<int> a(n);

  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> sa = a;
  sort(sa.begin(), sa.end(), greater<int>());

  for (int i = 0; i < n; ++i) {
    if (a[i] == sa[0]) {
      cout << sa[1] << '\n';
    } else {
      cout << sa[0] << '\n';
    }
  }

  return 0;
}


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

typedef long long int ll;
ll A, B, C, K;

int main(void) {
  cin >> A >> B >> C >> K;
  int ans;
  if (K <= A) ans = K;
  else if (A < K && K <= A + B) ans = A;
  else ans = A - (K - A - B);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
//#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    vector<pair<int, int>> CB(M);
    rep(i, 0, M) cin >> CB[i].second >> CB[i].first;
    sort(A.begin(), A.end());
    sort(CB.rbegin(), CB.rend());
    int index = 0;
    bool hasFinished = false;
    for (auto& p : CB)
    {
        while (p.second)
        {
            if (A[index] < p.first)
            {
                A[index] = p.first;
                ++index;
            }
            else
            {
                hasFinished = true;
                break;
            }
            --p.second;
        }
        if (hasFinished)
        {
            break;
        }
    }
    ll ans = 0;
    rep(i, 0, N) ans += A[i];
    cout << ans << endl;
}


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

long long gcd(long long a, long long b){
  if(a<b) std::swap(a,b);
  long long r;
  while(b){
    r=a%b;
    a=b;
    b=r;
  }
  return a;
}

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


class Solution{
public:
  int N,M;
  std::vector<int> A;
  void input();
  void solve();
};

void Solution::input(){
  std::cin>>N>>M;
  A.resize(N);
  for(int i=0;i<N;i++){
    std::cin>>A[i];
    A[i]/=2;
  }
}

void Solution::solve(){
  for(int i=0;i<N;i++){
    int cnt0=0,cnti=0;
    int A0=A[0],Ai=A[i];
    while(A0%2==0){
      A0/=2,cnt0++;
    }
    while(Ai%2==0){
      Ai/=2,cnti++;
    }
    if(cnt0!=cnti){
      std::cout<<"0\n";
      return;
    }
  }
  
  long long lcm_A=1;
  for(int i=0;i<N;i++){
    lcm_A=lcm(lcm_A,A[i]);
    if(lcm_A>M||lcm_A<0){
      std::cout<<"0\n";
      return;
    }
  }
  
  int ok=1,ng=1e9;
  while(abs(ok-ng)>1){
    int mid=(ok+ng)/2;
    if(lcm_A*mid>0&&lcm_A*mid<=M) ok=mid;
    else ng=mid;
  }
  std::cout<<ok/2+ok%2<<std::endl;
  return;
}

int main(){
  class Solution sol;
  sol.input();
  sol.solve();
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define INF (1<< 28)
#define SIZE 1000

int main(){
  int min_cost[SIZE][SIZE];
  int n,m,a,b,c,mins,minj,sum;
  cin >> m;
  while(m != 0){
    for(int i=0;i<=101;i++){
      for(int j=0;j<=101;j++){
	if(i == j) min_cost[i][j] = 0;
	else min_cost[i][j] = INF;
      }
    }
    n = 0;
    for(int i=0;i<m;i++){
      cin >> a >> b >> c;
      n = max(n,max(a,b));
      min_cost[a][b] = min_cost[b][a] = c;
    }
    for(int k=0;k<=n;k++){
      for(int i=0;i<=n;i++){
	for(int j=0;j<=n;j++){
	  min_cost[i][j] = min(min_cost[i][j],min_cost[i][k]+min_cost[k][j]);
	}
      }
    }
    mins = minj = INF; 
    for(int i=0;i<=n;i++){
      sum = 0;
      for(int j=0;j<=n;j++){
	sum += min_cost[i][j];
      }
      if(mins > sum){
	mins = sum;
	minj = i;
      }
    }
    cout << minj << ' ' << mins << endl;
    
    cin >> m;
  }
  
  return 0;
}

Measured memory_bytes: 3376
#include<stdio.h>
int main()
{
	int h, w, a, b;
	scanf("%d %d %d %d", &h, &w, &a, &b);
	int i, j;
	int ans[1003][1003];
	for (i = 0; i < h; i++)
		for (j = 0; j < w; j++)
			ans[i][j] = 0;
	for (i = b; i < h; i++)
		for (j = 0; j < a; j++)
			ans[i][j] = 1;
	for (i = 0; i < b; i++)
		for (j = a; j < w; j++)
			ans[i][j] = 1;
	for (i = 0; i < h; i++)
	{
		for (j = 0; j < w; j++)
			printf("%d", ans[i][j]);
		printf("\n");
	}
	return 0;
}

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


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

        //
        int count = 0;
        for(int i = 1; i <= n - 2; i++)
        {
            for(int j = i + 1; j <= n - 1; j++)
            {
                for(int k = j + 1; k <= n; k++)
                {
                    if(i + j + k == x){ count++; }
                }
            }
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int h,a;
	cin>>h>>a;
	if (a>=h)
		cout<<"1";
	if(h>a){
		if(h%a!=0){
			a=h/a+1;
			cout<<a;
		}
		else{
		cout<<h/a;
	}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  if(a >= b && a >= c){
    cout << a * (int)pow(2.0,(double)k) + b + c;
  }else if(b>= c){
    cout  << a + b * (int)pow(2.0,(double)k) + c;
  }else{
    cout << a + b + c * (int)pow(2.0,(double)k);
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

const int INF = (1<<29);

struct State{
  int h, w;
  int d;
};

bool compare(State a, State b){
  if(a.d == b.d) return a.h < b.h;
  return a.d < b.d;
}

int main(){
  vector<State> state;
  for(int i = 1 ; i <= 151 ; i++){
    for(int j = 1 ; j <= 151 ; j++){
      if(i >= j) continue;
      int d = i*i + j*j;
      State tmp;
      tmp.h = i, tmp.w = j, tmp.d = d;
      state.push_back(tmp);
    }
  }
  
  sort(state.begin(), state.end(), compare);
  
  int H, W;
  while(cin >> H >> W, H|W){    
    int ansh, answ;
    
    ansh = answ = -1;
    
    int D;
    D = H*H + W*W;    
    for(int i = 0 ; i < state.size() ; i++){
      if(D == state[i].d){
	if(H < state[i].h){
	  ansh = state[i].h;
	  answ = state[i].w;
	  goto END;
	}
      }
      else if(D < state[i].d){
	ansh = state[i].h;
	answ = state[i].w;
	break;
      }
    }
  END:;
    cout << ansh << ' ' << answ << endl;
    
  }
  return 0;
}

  

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int X; cin >> X;
    int ans = 0;
    ans += X / 500 * 1000; X %= 500;
    ans += X / 5 * 5;
    cout << ans << '\n';
    return 0;
}


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

using System.Collections;

class Program
{
    static void Main()
    {
        var xx = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int a = xx[0];
        int b = xx[1];
        int c = xx[2];
        int d = xx[3];

        bool isOk = false;

        if (Math.Abs(a - c) <= d) isOk = true;
        if (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d) isOk = true;

        Console.WriteLine(isOk ? "Yes" : "No");
    }
    
}


static class MathUtil
{
    public static T Max<T>(params T[] datas)
    {
        return datas.Max();
    }

    public static T Min<T>(params T[] datas)
    {
        return datas.Min();
    }

    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=1000010;
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int n,sum[Maxn];
char s[Maxn];
int main()
{
	n=read();
	scanf("%s",s+1);
	sum[0]=0;for(int i=1;i<=n;i++)sum[i]=sum[i-1]+(s[i]=='M');
	int q=read();
	while(q--)
	{
		int k=read();
		LL ans=0,Sum=0,cnt=0;
		for(int i=1;i<=n;i++)
		{
			if(i-k>0&&s[i-k]=='D')cnt--,Sum-=sum[i-k-1];
			if(s[i]=='C')ans+=cnt*sum[i]-Sum;
			if(s[i]=='D')cnt++,Sum+=sum[i-1];
		}
		printf("%lld\n",ans);
	}
}


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

int N;

int main() {
    cin >> N;
    
    bool flag = 0;
    int k = 2;
    while (k*(k-1) <= 2*N) {
        if (N == k * (k - 1) / 2) {
            flag = 1;
            break;
        }
        k++;
    }
    if (flag) {
        cout << "Yes" << endl;
        cout << k << endl;
        for (int i = 1; i < k; i++) {
            cout << k-1;
            int l = i*(i-1)/2;
            int r = i*(i+1)/2;
            for (int j = 0; j < i; j++) {
                l += 1;
                cout << ' ' << l;
            }
            for (int j = 0; j < k-1-i; j++) {
                r += i + j;
                cout << ' ' << r;
            }
            cout << endl;
        }
        int a = 0;
        cout << k-1;
        for (int m = 1; m < k; m++) {
            a += m;
            cout << ' ' << a;
        }
        cout << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a*n, b);
    
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
q = int(stdin.readline().rstrip())
prime_accum = [0] * 1000001

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data

prime = set(get_sieve_of_eratosthenes(100000))
    
cnt = 0
for i in range(1,100001):
    if i % 2 ==1 and (i in prime) and (((i+1)//2) in prime):
        cnt += 1
    prime_accum[i] = cnt

for _ in range(q):
    l,r = [int(x) for x in stdin.readline().rstrip().split()]
    print(prime_accum[r]-prime_accum[l-1])
#print(prime_accum)

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

int main() {
  string s;
  int pos;
  cin >> s;
  cin >> pos;

  vector<string> t;

  for (int k = 0; k < (int)s.size(); k++) {
    for (int l = 0; l < 5; l++) {
      t.push_back(s.substr(k, l+1));
    }
  }
  sort(t.begin(), t.end());
  unique(t.begin(), t.end());
  cout << t[pos-1] << endl;
}

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

using namespace std;

main(int argc, char const *argv[])
{
    long long n, k;
    cin >> n >> k;
    vector<vector<int>> ab(n, vector<int>(2));

    for (size_t i = 0; i < n; i++)
    {
        cin >> ab[i][0] >> ab[i][1];
    }

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

    for (size_t i = 0; i < ab.size(); i++)
    {
        k -= ab[i][1];
        if (k <= 0)
        {
            cout << ab[i][0] << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>

int main(void)
{
	char day[7][4] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	char s[4];
	int i;

	scanf("%s", s);

	for (i = 0; i < 7; i++)
	{
		if (strcmp(s, day[i]) == 0)
		{
			printf("%d\n", 7 - i);
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

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

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int t = a - b;
  int ans = c - t > 0 ? c - t : 0;

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
 

vector <int > H;

int N,K,R,S,P; 
string T;

int main()
{
  cin >> N >> K >> S;
  REP(i,N){
    if(i<K){
      cout << S << " ";
    } else{
      if(S == 1000000000){
        cout << 1 << " ";
      } else{
        cout << 1000000000 << " ";
      }
    }
  }
}


Measured memory_bytes: 1280