akhauriyash/Code-Regression huggingface dataset:
import collections
memo = collections.defaultdict(int)
memo[0] = 0
memo[1] = 1


def f(x):
    if x in memo:
        return memo[x]
    else:
        y = x % bin(x).count('1')
        ret = 1 + f(y)
        memo[x] = ret
        return ret


N = int(input())
sX = input()
modX = sX.count('1')
if modX == 0:
    for _ in range(N):
        print(1)
elif modX == 1:
    sX = sX[::-1]
    for i, b in enumerate(sX):
        if b == '1':
            break
    #print(i)
    if i == 0:
        ans = [0] + [2] * (N - 1)
        ans = ans[::-1]
    else:
        ans = [1] * N
        ans[-1] = 2
        ans[-i - 1] = 0
    print('\n'.join(map(str, ans)))
else:
    modp = modX + 1
    modm = modX - 1
    sX = sX[::-1]
    Xmodp = 0
    Xmodm = 0
    for i, b in enumerate(sX):
        if b == '1':
            Xmodp += pow(2, i, modp)
            Xmodp %= modp
            Xmodm += pow(2, i, modm)
            Xmodm %= modm
    s = []
    for i, b in enumerate(sX):
        if b == '1':
            s += [(Xmodm - pow(2, i, modm)) % modm]
        else:
            s += [(Xmodp + pow(2, i, modp)) % modp]
    ans = []
    for k in s[::-1]:
        ans += [1 + f(k)]
    print('\n'.join(map(str, ans)))


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

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

    long long r, d, x;
    cin >> r >> d >> x;

    for(long long i = 0; i < 10; i++){
        long long nx = r * x - d;
        cout << nx << endl;
        x = nx;
    }

    return 0;
}

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

template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}
typedef pair<int,int> P;
int ans=1e9,n,a[20],b[20],now,p,q;

signed main(){
  cin>>n;
  vector<P> v(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  for(int i=0;i<(1<<n);i++){
    now=0;
    for(int j=0;j<n;j++)v[j]=P((i>>j)&1?b[j]:a[j],j);
    for(int j=0;j<n;j++)for(int k=0;k<j;k++)now+=(v[k]>v[j]);
    sort(v.begin(),v.end());
    stack<int> sta;
    for(int j=0;j<n;j++){
      int idx=v[j].second;
      if(((i>>idx)+idx-j)&1)sta.push(v[j].first*1000+j);
    }
    if(sta.size()&1)continue;
    while(sta.size()){
      p=sta.top();sta.pop();q=sta.top();sta.pop();
      if(p-q<1000&&(p-q)&1)now+=p-q;
      else now=1e9;
    }
    chmin(ans,now);
  }
  cout<<(ans<1e9?ans:-1)<<endl;
}


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

string S;
//             pos   , count
vector<pair<long long, long long> >L;
vector<pair<long long, long long> >R;
long long ans[100005];

int main(){
	cin >> S;

	long long num = 0;
	for(long long i = 0; i < S.size(); i++){
		if(S[i] == 'R'){
			num++;
		}else{
			R.push_back(make_pair(i-1, num));
			num = 0;
		}
	}

	num = 0;
	for(long long i = S.size()-1; i >= 0; i--){
		if(S[i] == 'L'){
			num++;
		}else{
			L.push_back(make_pair(i+1, num));
			num = 0;
		}
	}

	for(long long i = 0; i < R.size(); i++){
		long long pos = R[i].first;
		long long count = R[i].second;
		if(count % 2 == 0){
			ans[pos] += count/2;
			ans[pos+1] += count/2;
		}else{
			ans[pos] += count/2 + 1;
			ans[pos+1] += count/2;
		}
	}
	
	for(long long i = 0; i < L.size(); i++){
		long long pos = L[i].first;
		long long count = L[i].second;
		if(count % 2 == 0){
			ans[pos] += count/2;
			ans[pos-1] += count/2;
		}else{
			ans[pos] += count/2 + 1;
			ans[pos-1] += count/2;
		}
	}

	for(long long i = 0; i < S.size(); i++){
		cout << ans[i];
		if(i != S.size() - 1){
			cout << " ";
		}else{
			cout << endl;
		}
	}
}

Measured memory_bytes: 3124
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long


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

  vector<int> B;
  rep(i, M) {
    int b;
    cin >> b;
    B.pb(b);
  }

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

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
 
BLK = 1
WHT = 0
MOD = 10 ** 9 + 7
 
 
def calcdp(r, p, bw):
    if dp[r][bw] != -1:
        return dp[r][bw]
 
    if p == 0:
        cs = H[r]
    else:
        cs = H[r] - {p}
 
    if len(cs) == 0:
        dp[r][bw] = 1
        return 1
    else:
        if bw == BLK:
            res = 1
            for c in cs:
                res = (res * calcdp(c, r, WHT)) % MOD
            dp[r][BLK] = res
            return res
        else:
            res = 1
            for c in cs:
                res = (res * (calcdp(c, r, WHT) + calcdp(c, r, BLK))) % MOD
            dp[r][WHT] = res
 
            return res
 
 
N = int(input())
H = [set() for _ in range(N + 1)]
for _ in range(1, N):
    x, y = map(int, input().split())
    H[x].add(y)
    H[y].add(x)
 
dp = [[-1] * 2 for _ in range(N + 1)]
 
print((calcdp(1, 0, BLK) + calcdp(1, 0, WHT)) % MOD)

Measured memory_bytes: 148884
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size() << endl;
}


Measured memory_bytes: 19116
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;cin>>s;
  t=s;
  reverse(all(t));
  ll cnt=0;
  rep(i,s.length()){
    if(s[i]!=t[i])cnt++;
  }
  cout<<cnt/2<<endl;



  return 0;

}


Measured memory_bytes: 256
# ABC135C - City Savers
# greedy algorithm
def main():
    N, *AB = map(int, open(0).read().split())
    ans, a1 = 0, AB[0]
    for a2, b in zip(AB[1 : N + 1], AB[N + 1 :]):
        cnt1 = a1 if a1 < b else b
        x = b - cnt1
        cnt2 = a2 if a2 < x else x
        ans += cnt1 + cnt2
        a1 = a2 - cnt2  # a2 becomes a1 in next turn
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25180
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class BResale {
        public void solve (int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] v = in.nextIntArr(n), c = in.nextIntArr(n);
            int[][] dp = new int[n][2];
            dp[0][0] = 0;
            dp[0][1] = v[0] - c[0];
            for (int i = 1; i < n; ++i) {
                dp[i][0] = Math.max(dp[i - 1][0], dp[i - 1][1]);
                dp[i][1] = Math.max(dp[i - 1][0], dp[i - 1][1]) + v[i] - c[i];
            }
            out.println(Math.max(dp[n - 1][1], dp[n - 1][0]));
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader (InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

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

        public int[] nextIntArr (int length) {
            int[] res = new int[length];
            for (int i = 0; i < length; ++i) {
                res[i] = nextInt();
            }
            return res;
        }

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

    }
}



Measured memory_bytes: 21460
// ------------------------------------
// Date:2018/ 3/ 1
// Problem:ABC 075 OneOutOfThree a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    cout << c << endl;
  } else if (a == c) {
    cout << b << endl;
  } else {
    cout << a << endl;
  }
  return 0;
}



Measured memory_bytes: 256
import Data.List
import Data.Array

main = do
 [a, b] <- (map read . words) <$> getLine
 putStrLn (solve a b)

solve :: Int -> Int -> String
solve a b = if (mod a 3) == 0 || (mod b 3) == 0 || (mod (a+b) 3) == 0
            then "Possible"
            else "Impossible"
            


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

struct edge {
  ll to, cost;
  edge(ll to, ll cost) : to(to), cost(cost) {
  }
};


typedef pair<ll, int> P;  // <最短距離, 頂点の番号>

/* 負閉路の検出はできない。O(E logV) */
/* 負の辺があってもダメ */
void dijkstra(int V, int E, vector<vector<edge>>& G, vector<ll>& dist, int s) {
  priority_queue<P, vector<P>, greater<P>> que;
  fill(dist.begin(), dist.end(), LINF);
  dist[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (dist[v] < p.first)
      continue;

    for (int i = 0; i < G[v].size(); ++i) {
      edge e = G[v][i];
      if (dist[e.to] > dist[v] + e.cost) {
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
}

int main() {
  int N, u, v;
  cin >> N >> u >> v;
  u--, v--;
  vector<int> A(N - 1), B(N - 1);
  rep(i, N - 1) {
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
  }

  int V, E;

  V = N, E = N - 1;

  vector<vector<edge>> G(V);
  for (int i = 0; i < E; i++) {
    ll from, to, cost;
    from = A[i], to = B[i], cost = 1;
    G[from].push_back(edge(to, cost));
    G[to].push_back(edge(from, cost));
  }
  vector<ll> dist_T(V);
  dijkstra(V, E, G, dist_T, u);
  vector<ll> dist_A(V);
  dijkstra(V, E, G, dist_A, v);

  ll ans = 0;
  rep(i, N) {
    if (dist_T[i] < dist_A[i])
      chmax(ans, dist_A[i]);
  }
  ans--;
  cout << ans << endl;
}

Measured memory_bytes: 10908
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var K = one[0];
  var N = one[1];
  var list = nextIntArray();
  var diff = new Array(N);
  for(var i = 0; i < N - 1; i++){
    diff[i] = list[i + 1] - list[i];
  }
  diff[N - 1] = (K - list[N - 1]) + list[0];
  myerr(diff);
  diff.sort(function(a,b){
  	return a - b;
  });
  diff.pop();
  var sum = 0;
  for(var i = 0; i < N - 1; i++){
    sum += diff[i];
  }
  myout(sum);
}

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

int main(){
  ll N;
  cin >> N;
  ll minj = 200000;
  vector<ll>P(N);
  int ans = 0;
  rep(i,N){
    cin >> P[i];
    if(minj >=P[i])ans++;
    minj = min(minj,P[i]);
  }
  cout << ans << endl;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int n, t, a, hi;
    cin >> n;
    cin >> t >> a;
    vector<float> avg;
    for (int i = 0; i < n; i++)
    {
        cin >> hi;
        avg.push_back(abs(a - (t - hi * 0.006)));
    }
    float minn = avg[0];
    int index = 0;
    for (int i = 1; i < n; i++)
    {
        if (avg[i] < minn)
        {
            minn = avg[i];
            index = i;
        }
    }
    cout << index + 1;
    return 0;
}


Measured memory_bytes: 256
S = str(input())
atcg = "ATCG"
count = 0
count_max = 0
for x in S:
    if x in atcg:
        count += 1
    else:
        if count_max <= count:
            count_max = count
        count = 0
if count_max <= count:
  count_max = count
print(count_max)


Measured memory_bytes: 2940
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
ll D;
ll ok(vl x, vl y){
    ll sq = 0;
    rep(i, D){
        sq += (x[i]-y[i])*(x[i]-y[i]);
    }
    rep(i, 1000){
        if(sq == i*i) return 1;
    }
    return 0;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N >> D;
    vvl X(N, vl(D));
    rep(i, N) rep(j, D) cin >> X[i][j];
    ll ans = 0;
    rep(i, N) FOR(j, i+1, N){
        ans += ok(X[i], X[j]);
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int main()
{
     int a,b;
     scanf("%d%d",&a,&b);
     int c=a*b;
     if(c%2) printf("Odd\n");
     else printf("Even\n");
     return 0;
}


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

int h, w;
int n;
int a[10000];
int b[100][100];
int p;

int main(){
	scanf("%d %d %d", &h, &w, &n);
	for(int i=0; i<n; ++i) scanf("%d", &a[i]);

	for(int i=0; i<n; ++i){
		for(int j=0; j<a[i]; ++j){
			if(p/w%2 == 0) b[p/w][p%w] = i+1;
			else b[p/w][w-p%w-1] = i+1;
			++p;
		}
	}

	for(int i=0; i<h; ++i){
		printf("%d", b[i][0]);
		for(int j=1; j<w; ++j) printf(" %d", b[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1000000007;
const LL LINF = 1LL * INF * INF;
const int MAXN = 100007;
const LD EPS = 1e-7;

const int MAXK = 2007;

int X[MAXN], Y[MAXN], W[MAXK];
char C[MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, k, ans = 0;
	cin >> n >> k;
	REP(i, n)
		cin >> X[i] >> Y[i] >> C[i];
	REP(i, k)
	{
		memset(W, 0, 4 * MAXK);
		int cur = 0;
		REP(j, n)
		{
			int x2 = X[j] % (2 * k), y2 = (Y[j] + 2 * k - i) % (2 * k);
			if (y2 < k)
			{
				if (C[j] == 'W')
				{
					++W[x2];
					if (x2 < k)
						++cur;
				}
				else
				{
					--W[x2];
					if (x2 >= k)
						++cur;
				}
			}
			else
			{
				if (C[j] == 'B')
				{
					++W[x2];
					if (x2 < k)
						++cur;
				}
				else
				{
					--W[x2];
					if (x2 >= k)
						++cur;
				}
			}
		}
		ans = max(ans, cur);
		FOR(j, 1, 2 * k)
		{
			cur += W[(j + k - 1) % (2 * k)] - W[(j - 1) % (2 * k)];
			ans = max(ans, cur);
		}
	}
	cout << ans;
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
	int i = 0;
	int x = 0;
	
	while(1){
		scanf("%d",&x);
		if(x == 0) break;
		i++;
		printf("Case %d: %d\n",i,x);	
	}
	
	return 0;
}

Measured memory_bytes: 600
N = int(input())
P = list(map(int, input().split()))


# 最小値更新して越えてたらアウト
resultCount = 0
minNum = P[0]
for i in range(N):
    isMitasu = True
    if i != 0:
        if P[i] > minNum:
            isMitasu = False
        else:
            # 最小値更新
            minNum = P[i]
    if isMitasu:
        resultCount += 1
print(resultCount)

Measured memory_bytes: 24744
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a,b = na()
if a >=13:
    print(b)
elif 6 <= a and a<=12:
    print(b//2)
else:
    print(0)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
typedef long long li;
#define S_MAX 100000
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }



int main(){
  int a,b,c,d,e,f; cin >>a >>b >>c >>d >>e >>f;
  int tpw=1,tps=0;
  rep(x,30){
    li sum=x*a*100;
    if(sum>f)break;
    rep(y,30){
      sum=(x*a+y*b)*100;
      if(sum>f)break;
      rep(z,S_MAX){
        sum=(x*a+y*b)*100+z*c;
        if(sum>f)break;
        if(c*z>(a*x+b*y)*e) break;
        rep(w,S_MAX){
          sum=(x*a+y*b)*100+z*c+w*d;
          if(sum>f)break;
          if(c*z+d*w>(a*x+b*y)*e) break;
          li s=c*z+d*w,wa=(a*x+b*y)*100;
          if((double)tps/(tps+tpw) <=(double)s/(s+wa)){
            tps=s; tpw=wa;
          }
        }
      }
    }
  }
  print(tpw+tps,tps);
}


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

using namespace std;

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

int main(){
    int a,b;cin>>a>>b;
    if(a%3==0 or b%3==0 or (a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int a;
    cin >> a;
    cout << pow(a,3)+pow(a,2)+a << endl;
return 0;
}

Measured memory_bytes: 4304
function main(input) {
    var i, j, A, ans=0
    var arg = input.split("\n")[0].split(" ")
    var B = input.split("\n")[1].split(" ")
    for (i=0;i<arg[0];i++){
        A = new Array(input.split("\n")[i+2].split(" "))
        var sum = Number(arg[2]);
        for (j=0;j<arg[1];j++){
            sum += Number(A[0][j])*Number(B[j])
        }
        if (sum>0) ans++
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  int64_t ans=0;
  for(int i=0;i<N;i++)
    ans+=abs(A.at(i));
  auto itr=upper_bound(A.begin(),A.end(),0);
  int k=distance(A.begin(),itr);
  if(k%2==0)
    cout<<ans<<endl;
  else if(k==N){
  ans+=2*A.at(N-1);
    cout<<ans<<endl;
  }
  else{
    int64_t Min=2*min(abs(A.at(k-1)),A.at(k));
    ans-=Min;
    cout<<ans<<endl;
  
  }
   return 0;
}

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


int main(){
  int fib[N+1];
  int n;
  cin >> n;
  fib[0]=fib[1]=1;
  for(int i=2;i<=n;i++){
    fib[i]=fib[i-1]+fib[i-2];
}

cout<< fib[n]<< endl;
  return 0;
}



Measured memory_bytes: 3100
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }
        
        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}

fn main(){
    let n: i64 = read_as_vec()[0];

    if n%2 == 0{
        println!("{}", 1.0/2.0);
    }else{
        println!("{}", ((n/2) as f64+1.0)/ (n as f64));
    }
}


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

using namespace std;

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

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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 4; ++i) cout << s[i];
  cout << " ";
  for (int i = 4; i < 12; ++i) cout << s[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n % 10 == 7 || (n % 100) / 10 == 7 || n / 100 == 7) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3620
n,m=map(int,input().split())
ab=[set(map(int,input().split())) for _ in range(m)]
def dfs(v,visited):
  if v in visited:
    return 0
  if len(visited|{v})==n:
    return 1
  return sum(dfs(i,visited|{v}) for i in range(1,n+1) if {i,v} in ab)
print(dfs(1,set()))

Measured memory_bytes: 3060
using System;

class Program
{
    static void Main(string[] args)
    {
        int N  = int.Parse(Console.ReadLine());
        int[] a = new int[N];
        for(int i = 0; i < N; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }
        int[] b = new int[N];
        Array.Copy(a, b, N);
        Array.Sort(a);
        int max1st = a[N - 1];
        int max2nd = a[N - 2];

        for(int i =0; i<N; i++)
        {
            if(b[i] == max1st)
            {
                Console.WriteLine(max2nd);

            }
            else
            {
                Console.WriteLine(max1st);
            }
        }
    }
}


Measured memory_bytes: 17876
#include <bits/stdc++.h>
using namespace std;
int w[101],v[101];
long long f[101][100001];
int main()
{
	int i,j,w1,n,max_v=0;
	scanf("%d %d",&n,&w1);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d",&w[i],&v[i]);
		max_v+=v[i];
	}
	for(i=1;i<=max_v;i++)
		f[0][i]=INT_MAX;
	f[0][0]=0;
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=max_v;j++)
		{
			f[i][j]=f[i-1][j];
			if(j>=v[i])
				f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
		}
	}
	for(i=max_v;i>=1;i--)
	{
		if(f[n][i]<=w1)
			break;
	}
	printf("%d",i);
	return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
using namespace std;
using VI = vector<long>;

class RangeCount {
    const int ST_SIZE = (1 << 20) - 1;
    int n;
    VI data;
    vector<VI> segtree;
    
    void init(int k, int l, int r) {
        if (r - l == 1) {
            segtree[k].push_back(data[l]);
        } else {
            int lch = k * 2 + 1;
            int rch = k * 2 + 2;
            init(lch, l, (l + r) / 2);
            init(rch, (l + r) / 2, r);
            segtree[k].resize(r - l);
            
            merge(segtree[lch].begin(), segtree[lch].end(), segtree[rch].begin(), segtree[rch].end(), segtree[k].begin());
        }
    }
    
    // number of x in [i, j)
    int query(int i, int j, long x, int k, int l, int r) {
        if (j <= l || r <= i) {
            return 0;
        }
        
        if (i <= l && r <= j) {
            return upper_bound(segtree[k].begin(), segtree[k].end(), x) - segtree[k].begin();
        }
        
        int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
        int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
        return lc + rc;
    }
    
public:
    RangeCount(VI v) {
        n = v.size();
        data = VI(v);
        segtree = vector<VI>(ST_SIZE);
        init(0, 0, n);
    }
    
    int exact(int i, int j, long x) {
        return query(i, j, x, 0, 0, n) - query(i, j, x - 1, 0, 0, n);
    }
    
    int le(int i, int j, long x) {
        return query(i, j, x, 0, 0, n);
    }
    
    int lt(int i, int j, long x) {
        return query(i, j, x - 1, 0, 0, n);
    }
    
    int ge(int i, int j, long x) {
        return query(i, j, 1e18, 0, 0, n) - query(i, j, x - 1, 0, 0, n);
    }
    
    int gt(int i, int j, long x) {
        return query(i, j, 1e18, 0, 0, n) - query(i, j, x, 0, 0, n);
    }
};

int main() {
    long n, k;
    cin >> n >> k;
    VI as;
    for (int i = 0; i < n; i++) {
        long a;
        cin >> a;
        a -= k;
        as.push_back(a);
    }
    VI sum = {0};
    for (auto a: as) {
        sum.push_back(sum.back() + a);
    }
    
    long ans = 0;
    RangeCount r(sum);
    for (int i = 0; i < n; i++) {
        ans += r.ge(i + 1, n + 1, sum[i]);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 67440
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    string s;
    while(cin>>s){
        for(int i=0;s[i];i++){
            if(i%2) continue;
            printf("%c",s[i]);
        }
        printf("\n");
    }
return 0;}


Measured memory_bytes: 764
import java.util.Scanner;
 
public class Main {
	 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[m];
		int[] d = new int[m];
		int min = 99999999;
		int index = 0;
		int date = 99999999;
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		
		for(int i = 0; i < m; i++){
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		
		for(int i = 0;i < n; i++){
			for(int j = 0; j < m; j++){
				date = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if(date < min){
					min = date;
					index = j;
				}
			}
			System.out.println(index + 1);
			min = 999999999;
			index = 0;
		}
			
	}
 
}

Measured memory_bytes: 21844
/*
     _              ,_,
    / \   _ __, ___,| |__   __ _,_ __
   / ^ \ | '_ \/ _ \| '_ \ / _` | /_/
  /-/-\-\|-| |--| |-|-|_)-|-(_|-|-|
 /_/   \_\_| |__| |_|_.__/ \__,_|_|
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(a)       (a).begin(),(a).end()
#define rep(i,a,n)   for(int i=a ; i<n ; i++)
 
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<ll,ll> mii;
typedef map<char,ll> mci;
 
ll gcd(ll a, ll b){
	if(b==0)return a;
	else return gcd(b, a%b);
}

signed main(){
    ios_base :: sync_with_stdio (false);
	cin.tie(NULL);
	// cout << fixed << setprecision(15);
 
	ll TESTS=1; 
	// cin>>TESTS;
	while(TESTS--){
		ll n, d; cin>>n>>d;
		ll ans=0;
		rep(i, 0, n){
			ll x, y;
			cin>>x>>y;
			if(sqrt(x*x+y*y)<=d)ans++;
		}
		cout<<ans<<endl;

	}
    return(0);
}

Measured memory_bytes: 3684
import java.io.*;

class Main{
	public static void main(String[] args) {

		InputStreamReader sr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(sr);
        try{
	        String[] str = br.readLine().split(" ");
			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);
			int c = Integer.parseInt(str[2]);	
		
			if (a < b && b < c) {
				System.out.println("Yes");				}
			else {
				System.out.println("No");
			}
			
		}	
		catch(IOException e) {
            e.printStackTrace();
        }
	}
}

Measured memory_bytes: 24224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)1e6+7;

priority_queue<int>qu;
pi e[MAXN];

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

    int N,M;
    cin >> N >> M;
    rep(i,1,N) {
        int x,y;
        cin >> x >>y;
        e[i] = make_pair(x,y);
    }
    sort(e+1,e+1+N);
    int pl = 1;
    int ans = 0;
    for(int i = M-1;i >= 0;i --) {
        int day = M-i;
        while (pl <= N && e[pl].first <= day) {
            qu.push(e[pl++].second);
        }
        if (!qu.empty()) {
            ans += qu.top();
            qu.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1660
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define mod 1000000007
#define endl '\n'
typedef long long int ll ;
typedef unsigned long long int ull;
using namespace std;
int main(){
    
    ll n;
    cin>>n;
    ll x;
    cin>>x;
    if(1<=x && x<=9 && 1<=n && n<=9) cout<<n*x;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
S = input().rstrip()
T = input().rstrip()


def check(A, B):
    alphabets = "abcdefghijklmnopqrstuvwxyz"
    d = {c: None for c in alphabets}
    for i in range(len(A)):
        if d[A[i]] is None:
            d[A[i]] = B[i]
        elif d[A[i]] != B[i]:
            return False
    return True


print("Yes" if check(S, T) and check(T, S) else "No")


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> L(n); rep(i, n) cin >> L[i];
  sort(all(L));
  ll ans = 0;
  rep(i, n) REP(j, i+1, n) {
    ans += (upper_bound(begin(L)+j+1, end(L), L[i]+L[j]-1) - (begin(L)+j+1));
  }
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3668
package main

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

func main() {
	fmt.Println(resolve(os.Stdin))
}

func resolve(r io.Reader) int {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	a, b, _, k := scanInt(sc), scanInt(sc), scanInt(sc), scanInt(sc)
	max := 0
	if k <= a {
		max += k
		k = 0
	} else {
		max += a
		k -= a
	}
	if k <= b {
		k = 0
	} else {
		k -= b
	}
	max -= k
	return max
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1764
#include<iostream>
#include<vector>

using namespace std;

struct Trump
{
	char mark;
	int num;
};

vector<struct Trump> BubbleSort(vector<struct Trump> A,int n)
{
	int flag = 1;
	
	while(flag == 1){
		flag = 0;
		for(int i=n-1;i>0;i--){
			if(A[i].num < A[i-1].num){
				struct Trump change = A[i];
				A[i] = A[i-1];
				A[i-1] = change;
				flag = 1;
			}
		}
	}
	return A;
}

vector<struct Trump> SelectSort(vector<struct Trump> A,int n)
{
	int flag;
	for(int i=0;i<n-1;i++){
		int minj = i;
		flag = 0;
		for(int j=i+1;j<n;j++){
			if(A[j].num < A[minj].num){
				minj = j;
				flag = 1;
			}
		}
		if(flag == 1){
			swap(A[i],A[minj]);
		}
	}
	return A;
}

void Output(vector<struct Trump> A,int n)
{
	for(int i=0;i<n;i++){
		if(i == n-1)cout << A[i].mark << A[i].num <<endl;
		else{
			cout << A[i].mark << A[i].num << " " << flush;
		} 
	}
}

bool Judge_Stable(vector<struct Trump> A,vector<struct Trump> B,int n)
{
	for(int i=0;i<n;i++){
		if(A[i].mark != B[i].mark)return false;
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	
	vector<struct Trump> card;
	card.resize(n);

	for(int i=0;i<n;i++){
		cin >> card[i].mark >> card[i].num;
	}
	
	vector<struct Trump>card_bubble = BubbleSort(card,n);
	Output(card_bubble,n);
	cout << "Stable" << endl;
	
	vector<struct Trump>card_select = SelectSort(card,n);
	Output(card_select,n);
	if(Judge_Stable(card_bubble,card_select,n))cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	
	return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {
    static final int MAX = 2000000;
    static int       p   = 0;
    static int[]     h   = new int[MAX + 1];;

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

        while (true) {
            String order = sc.next();
            if (order.startsWith("i")) {
                insert(sc.nextInt());

            } else if (order.startsWith("ex")) {
                System.out.println(heapExtractMax());

            } else {
                break;
            }
        }
    }


    static void insert(int key) {
        p++;
        h[p] = Integer.MIN_VALUE;
        heapIncreaseKey(p, key);
    }

    static void heapIncreaseKey(int i, int key) {
        if (key < h[i]) {
            // error
        }
        h[i] = key;
        while (i > 1 && h[i / 2] < h[i]) {
            int temp = h[i];
            h[i] = h[i / 2];
            h[i / 2] = temp;
            i = i / 2;
        }
    }

    static int heapExtractMax() {
        if (p < 1) {
            // error
        }
        int max = h[1];
        h[1] = h[p];
        p--;
        maxHeapify(h, 1); 
        return max;
    }

    static int l(int i) {
        return 2 * i;
    }

    static int r(int i) {
        return 2 * i + 1;
    }

    static void maxHeapify(int[] h, int idx) {
        int n = p;
        int l = l(idx);
        int r = r(idx);
 
        int maxNodeIdx = 0;
        if (l <= n && h[l] > h[idx]) {
            maxNodeIdx = l;
        } else {
            maxNodeIdx = idx;
        }
        if (r <= n && h[r] > h[maxNodeIdx]) {
            maxNodeIdx = r;
        }

        if (maxNodeIdx != idx) {
            int temp = h[idx];
            h[idx] = h[maxNodeIdx];
            h[maxNodeIdx] = temp;
            maxHeapify(h, maxNodeIdx);
        }
    }
}


Measured memory_bytes: 555940
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    long A = Long.parseLong(sc.next());
    long B = Long.parseLong(sc.next());
    
    long n = (B-A)*(N-2)+1;
    
    long ans = Math.max(0, n);
    if((N==1 && A != B) || N == 0){
      ans = 0;
    }
    System.out.println(ans);
  }
}

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

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	
	if (abs(a-c) <= d) cout << "Yes" << endl;
	else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ll long long
#define ull unsigned long long int
#define db double
#define fi first
#define se second
#define pb push_back
#define vec vector<ll>
#define pr pair<ll,ll>
#define pq priority_queue<ll,vector<ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
typedef priority_queue<ll,vector<ll>,greater<ll>> pqlg;
#define GS(s)   string s; getline(cin,s);
#define lll __int128_t
#define endl "\n"

struct compare_queue
{
    bool operator()(const ll& a, const ll& b)
    {
        return a>b;
    }
};

// ll gcd(ll u,ll v)
// {
// 	if(v==0)
// 	return u;
	
// 	else
// 	return gcd(v,u%v);
// }

    // ll power(ll x,ll y){
    //     ll i;
    //     ll ans=1;
    //     for(i=0;i<y;i++){
    //         ans=ans*x;
    //     }
    //     return ans;
    // }

// // // #define MAX 1000000
// int primes[100009],cnt=0;
// // vector<int> factors[1000009];
// char str[1000009];
// void pre()
// {
//     // calcualting primes
//     int n=1000000;
//     for(int i=2; i*i<=n; i++)
//         if(str[i]==0)
//             for(int j=i; j*i<=n; j++)
//                 str[i*j]=1;
//     for(int i=2; i<=n; i++)
//         if(str[i]==0)primes[cnt]=i,cnt++;
// }


// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
// vector<ll> getFactorization(ll x) 
// { 
//     vector<ll> ret; 
//     while (x != 1) 
//     { 
//         ret.push_back(spf[x]); 
//         x = x / spf[x]; 
//     } 
//     return ret; 
// } 

// C:\Users\A\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\lambda

ll power(ll x,ll y,ll p) 
{ 
	ll res = 1;	

	x = x % p; 

	if (x == 0) return 0;

	while (y > 0) 
	{ 
		
		if (y & 1) 
			res = (res*x) % p; 

		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

// struct node{
// int val;
// node* left;
// node* right;
// };

// node* getNode(int k){
//     node* temp =new node;
//     temp->left=NULL;
//     temp->right=NULL;
//     temp->val=k;
// }



void Function(){

ll d,t,s;
cin >> d >> t >> s;
if(d>t*s){
    cout << "No" << endl;
}
else{
    cout << "Yes" << endl;
}

}

int main(){ 
fast;
ll t=1,i=0,j=0,k=0,h,n;
// pre();
// cin >> t;
for(h=1;h<=t;h++){
Function();
}
return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
#include<string>
#include<string.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int a, b, c, d;
	cin >> a >> b;
	if (a%b == 0) {
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}
	return 0;
}

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

ll N;
vector<ll> a;
const ll inf = 1e18;

int main() {
    cin >> N; a.resize(N);
    for (int i = 0; i < N; i++) scanf("%Ld", &a[i]);
    ll ans = inf;

    ll sum = 0;
    ll tempans = 0;
    for (int i = 0; i < N; i++) {
        if (i%2) {
            if (a[i]+sum >= 0) {
                tempans += a[i]+sum+1;
                sum = -1;
            }else{
                sum += a[i];
            }
        }else{
            if (a[i]+sum<=0) {
                tempans += abs(a[i]+sum)+1;
                sum = 1;
            }else{
                sum += a[i];
            }
        }
    }
    ans = min(ans, tempans);

    sum = 0;
    tempans = 0;
    for (int i = 0; i < N; i++) {
        if (!(i%2)) {
            if (a[i]+sum >= 0) {
                tempans += a[i]+sum+1;
                sum = -1;
            }else{
                sum += a[i];
            }
        }else{
            if (a[i]+sum<=0) {
                tempans += abs(a[i]+sum)+1;
                sum = 1;
            }else{
                sum += a[i];
            }
        }
    }
    ans = min(ans,tempans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# coding=utf-8


def from_down(base, number, upper):
    return_list = []
    range_upper = min(upper+1, base+number)
    for i in range(base, range_upper):
        return_list.append(i)
    return return_list


def from_up(base, number, down):
    return_list = []
    range_down = max(base-number+1, down)
    for i in range(range_down, base+1):
        return_list.append(i)
    return return_list


def remove_double(object_list):
    list_unique = []
    for x in object_list:
        if x not in list_unique:
            list_unique.append(x)
    return list_unique


if __name__ == '__main__':
    A, B, K = map(int, input().split())
    down_list = from_down(A, K, B)
    upper_list = from_up(B, K, A)
    down_list.extend(upper_list)
    unique_list = remove_double(down_list)
    output = [print(element) for element in unique_list]


Measured memory_bytes: 3064