akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#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 FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int p[SIZE];
vector<int>pp;
void prime_init(){
    for(int i=2;i<SIZE;i++){
        if(!p[i]){
            pp.PB(i);
            for(int j=i;j<SIZE;j+=i){
                if(!p[j])p[j]=i;
            }
        }
    }
}
bool is_prime(int x){
    return p[x]==x;
}
int dp[SIZE];
int main(){
    prime_init();
    for(int i=3;i<SIZE;i++){
        if(is_prime(i)&&is_prime((i+1)/2))dp[i]++;
        dp[i]+=dp[i-1];
    }
    int Q;
    R(Q);
    while(Q--){
        int l,r;
        R(l,r);
        W(dp[r]-dp[l-1]);
    }
    return 0;
}


Measured memory_bytes: 8824
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>

#define N_MAX 105

using namespace std;

int main(void){

	int N;
	int arry[N_MAX];
	int cnt=0;

	cin>>N;

	for(int i=0;i<N;i++){
		cin>>arry[i];
	}

	for(int i=0;i<N-1;i++){
		for(int j=N-1;j>i;j--){
			if(arry[j]<arry[j-1]){
				swap(arry[j],arry[j-1]);
				cnt++;
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 1160
for i in range(int(input())):
    x1, y1, x2, y2, x3, y3 = map(float, input().split())
    c = (x1-x2)**2 + (y1-y2)**2
    a = (x2-x3)**2 + (y2-y3)**2
    b = (x3-x1)**2 + (y3-y1)**2
    # 16s^2
    s = 2*(a*b + b*c + c*a) - (a*a + b*b + c*c)

    px = (a*(b+c-a)*x1 + b*(c+a-b)*x2 + c*(a+b-c)*x3) / s
    py = (a*(b+c-a)*y1 + b*(c+a-b)*y2 + c*(a+b-c)*y3) / s

    ar = a**0.5
    br = b**0.5
    cr = c**0.5

    r = ar*br*cr / ((ar+br+cr)*(-ar+br+cr)*(ar-br+cr)*(ar+br-cr))**0.5

    print("{:>.3f}".format(px),"{:>.3f}".format(py),"{:>.3f}".format(r))

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

int main(){
	int r;
	cin >> r;
	if(r < 1200){
		cout << "ABC" << endl;
	}else if(r < 2800){
		cout << "ARC" << endl;		
	}else{
		cout << "AGC" << endl;				
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n, q, v[300000], w[300000], h[300000];
vector<pii> memo[(1 << 12) + 100];
void rec(vector<pii>& r, int x) {
	if (x) {
		r.emplace_back(w[x], v[x]);
		rec(r, x / 2);
	}
}
int rec2(vector<pii>& r, int x) {
	if (h[x] == 12)
		return x;
	r.emplace_back(w[x], v[x]);
	return rec2(r, x / 2);
}
vector<pii> ref(vector<pii>& s) {
	sort(s.begin(), s.end());
	vector<pii> r;
	r.emplace_back(s[0]);
	for (int i = 1; i < s.size(); i++)
		if (r.back().second < s[i].second)
			r.emplace_back(s[i]);
	return r;
}
vector<pii> enu(const vector<pii>& s) {
	vector<pii> r;
	r.emplace_back(0, 0);
	for (int i = 0; i < s.size(); i++) {
		int c = r.size();
		for (int j = 0; j < c; j++)
			r.emplace_back(r[j].first + s[i].first, r[j].second + s[i].second);
	}
	return ref(r);
}
vector<pii> enu2(const vector<pii>& s, pii v) {
	vector<pii> r(s.begin(), s.end());
	int c = r.size();
	for (int i = 0; i < c; i++)
		r.emplace_back(r[i].first + v.first, r[i].second + v.second);
	return ref(r);
}

int solve(int u, int l) {
	vector<pii> p;
	if (h[u] <= 12) 
		return upper_bound(memo[u].begin(), memo[u].end(), pii(l, 2e9))[-1].second;
	int cen = rec2(p, u);
	vector<pii> v = memo[cen];
	vector<pii> w = enu(p);
	if (v.size() > w.size())
		v.swap(w);
	int max_v = 0;
	for (int i = 0; i < v.size() && v[i].first <= l; i++) {
		int val = upper_bound(w.begin(), w.end(), pii(l - v[i].first, 1e9))[-1].second;
		max_v = max(max_v, v[i].second + val);
	}
	return max_v;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d %d", v + i, w + i), h[i] = h[i / 2] + 1;
	h[n + 1] = 1e9;
	memo[0].emplace_back(0, 0);
	for (int i = 1; h[i] <= 12; i++)
		memo[i] = enu2(memo[i / 2], pii(w[i], v[i]));
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		int u, l;
		scanf("%d %d", &u, &l);
		printf("%d\n", solve(u, l));
	}
}

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

int main() {
    long long n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    for(int i = 0; i < n; ++i) cin >> t[i];
    
    sort(t.begin(), t.end());
    int res = 0;
    for(int i = 0; i < n;) {
        int num = 0;
        for(int j = i; t[j] <= t[i] + k; ++j) {
            if(num == c) break;
            ++num;
        }
        i += num;
        
        ++res;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 640
import GHC.Exts
import Data.Map (Map,(!))
import qualified Data.Map as M
import Control.Monad

main = do
  [n,m] <- map read.words <$> getLine
  dat <- zip [1..].map ((\[a,b]->(a,b)).map read.words) <$> replicateM m getLine
  let ls = M.elems.M.fromList.concatMap (to1nSndSnd.sortWith (snd.snd)).groupWith (fst.snd) $ sortWith (fst.snd) dat
  forM_ ls $ \(a,b) -> putStr (conv 6 a) >> putStrLn (conv 6 b)

to1nSndSnd :: [(a,(b,c))] -> [(a,(b,Int))]
to1nSndSnd = inner 1
  where
  inner _ [] = []
  inner i ((a,(b,_)):xs) = (a,(b,i)) : inner (i+1) xs

conv :: Int -> Int -> String
conv n a = replicate (n-length s) '0' ++ s
  where s = show a

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

using namespace std;

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

    int N, L; cin>>N>>L;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += L+i;
    }
    if (L > 0)
        ans -= L;
    else if (L+N-1 < 0)
        ans -= L+N-1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n; ll m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    
    auto ok = [&](int x) {
                 ll cnt = 0;
                 rep(i, n) {
                     int idx = lower_bound(all(a), x - a[i]) - a.begin();
                     cnt += n - idx;
                 }
                 return cnt <= m;
             };

    int l = -1, r = 1e6;
    while (r - l > 1) {
        int mid = (l + r) >> 1;
        if (ok(mid)) r = mid;
        else l = mid;
    }
    vector<ll> sum(n+1);
    rep(i, n) sum[i+1] = sum[i] + a[i];

    ll ans = 0;
    ll cnt = 0;
    rep(i, n) {
        int idx = lower_bound(all(a), r - a[i]) - a.begin();
        ans += sum[n] - sum[idx] + (ll)a[i] * (n - idx);
        cnt += n - idx;
    }
    ans += l * (m - cnt);
    cout << ans << endl;
}


Measured memory_bytes: 4520
#include <stdio.h>
#include <math.h>
#define ll long long

int main(){
  ll h,cnt = 0,sum=0;
  scanf("%lld",&h);
  while(h > 1){
    cnt++;
    sum+=pow(2,cnt);
    h/=2;
  }
  printf("%lld",sum+1);
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <array>
#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>
#include <random>
#include <ctime>

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<int64, int64> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int n;
  cin >> n;
  vector<ii> a(n);
  set<ii> A;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
    A.insert(a[i]);
  }
  int ret = n;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int64 p = a[j].first - a[i].first;
      int64 q = a[j].second - a[i].second;
      int cur = n;
      for (int k = 0; k < n; ++k) {
        if (A.count({a[k].first - p, a[k].second - q})) --cur;
      }
      ret = min(ret, cur);
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()
ans = a[0]
for i in range(1, n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
    
print(ans)

Measured memory_bytes: 22768
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] A = new int[1000001];
		int[] nms = new int[N];
		boolean one = false;
		for(int i = 0; i < N; i++) {
			int now = s.nextInt();
			A[now]++;
			nms[i] = now;
		}
		
		int ret = 0;
		for(int i = 0; i < N; i++) {
			if(!checkDivided(A, nms[i])) {
				ret++;
			}
		}
		System.out.println(ret);
	}
	
	// true 割り切れる　false 割り切れない
	private static boolean checkDivided(int[] A, int n) {
		int sqrt = (int)Math.sqrt(n);
		if(A[n] > 1) {
			return true;
		}
		if(n==1) {
			if(A[1] > 1) {
				return true;
			}else {
				return false;
			}
		}
		if(A[1] > 0) {
			return true;
		}
		for(int i = 2; i <= sqrt; i++) {
			int tmp = n;
			if(A[i] > 0 && n%i==0) {
				return true;
			}
			while(tmp%i==0) {
				tmp /= i;
				if(A[tmp] > 0) {
					if(n%tmp==0) {
						return true;
					}
				}
			}
		}
		return false;
	}
}

Measured memory_bytes: 64168
def prime_list(n):
    p = [True for i in range(n)]
    p[0] = False
    p[1] = False
    for j in range(4, n, 2):
            p[j] = False
    i = 3
    while i*i < n:
        if p[i]:
            for j in range(2*i, n, i):
                p[j] = False
        i += 2
    p_list = [2*i+1 for i in range(1,n//2) if p[2*i+1]]
    p_list.add(2)
    return p_list

def main():
    m = int(input())
    for _ in range(m):
        s = input()
        S = set()
        l = len(s)
        for i in range(1, l):
            S.add(s[0:i]+s[i:l])
            S.add(s[0:i][::-1]+s[i:l])
            S.add(s[0:i]+s[i:l][::-1])
            S.add(s[0:i][::-1]+s[i:l][::-1])
            S.add(s[i:l]+s[0:i])
            S.add(s[i:l][::-1]+s[0:i])
            S.add(s[i:l]+s[0:i][::-1])
            S.add(s[i:l][::-1]+s[0:i][::-1])
        print(len(S))
        # print(S)



if __name__ == '__main__':
    main()

Measured memory_bytes: 6872
import java.util.Scanner;

/**
 * 鈴木くんのプログラムを元（参考）に作成 クラス内の変数を直接読み込ませないようにカプセル化（？）をしてみたが、
 * 果たしてこれがカプセル化なのかがわからない…
 * 
 *
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		Dice2 dc = new Dice2();
		dc.dice(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());

		int q = sc.nextInt();
		int top, front;
		int[] r = new int[q];
		for (int i = 0; i < q; i++) {
			top = sc.nextInt();
			front = sc.nextInt();
			r[i] = dc.getRight(top, front);
		}

		for (int i = 0; i < q; i++) {
			System.out.println(r[i]);
		}
		sc.close();// Scannerを閉じる
	}

}

/**
 * Dice2クラス ダイスの面に数字をインプットする。回転させたりする。
 * 
 *
 */
class Dice2 {
	private int T, S, E, W, N, U;

	Dice2() {
		this.T = 0; // Top
		this.S = 0;
		this.E = 0;
		this.W = 0;
		this.N = 0;
		this.U = 0; // Under
	}

	/**
	 * Diceに数字をインプットする
	 * @param T_1	真上
	 * @param S_2	南
	 * @param E_3	東
	 * @param W_4	西
	 * @param N_5	北
	 * @param U_6	真下
	 */
	void dice(int T_1, int S_2, int E_3, int W_4, int N_5, int U_6) {
		this.T = T_1; // Top
		this.S = S_2;
		this.E = E_3;
		this.W = W_4;
		this.N = N_5;
		this.U = U_6; // Under
		// TODO 自動生成されたコンストラクター・スタブ
	}

	/**
	 * 南方向にサイコロを傾ける
	 */
	void MoveSouth() {
		int a = T;
		T = N;
		N = U;
		U = S;
		S = a;
	}

	void MoveEast() {
		int a = T;
		T = W;
		W = U;
		U = E;
		E = a;
	}

	void MoveNorth() {
		int a = T;
		T = S;
		S = U;
		U = N;
		N = a;
	}

	void MoveWest() {
		int a = T;
		T = E;
		E = U;
		U = W;
		W = a;
	}

	void right() {// 時計周りの回転
		int a = S;
		S = E;
		E = N;
		N = W;
		W = a;
	}

	/**
	 * 
	 * @param t 真上の数字（上面）
	 * @param f 南側の数字（前面）
	 * @return 東側（側面）の求めるべき数字
	 */
	int getRight(int t, int f) {
		for (int i = 0; i < 3; i++) {
			if (t == T) {
				break;
			}
			MoveNorth();
			if (t == T) {
				break;
			}
			MoveWest();
		}
		for (int i = 0; i < 3; i++) {
			if (f == S) {
				break;
			}
			right();
		}
		return E;
	}

}


Measured memory_bytes: 26260
#include <bits/stdc++.h>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int n;

void selectionSort(string *a) {

	int mi;
	rep(i, n - 1) {
		mi = i;
		for (int j = i; j < n; j++) {
			if (a[mi][1] > a[j][1] )
				mi = j;
		}
		if (mi != i)
			swap(a[mi], a[i]);
	}
}

void bubbleSort(string *a) {

	string tmp;
	int cut = 0;
	rep (i, n - 1) {
		for (int j = 0; j < n - i - 1; j++) {
			if (a[j][1] > a[j + 1][1]) {
				swap(a[j], a[j + 1]);
				cut++;
			}
		}
	}
}

int main() {

	cin >> n;

	string a[n];

	rep(i, n) {
		cin >> a[i];
	}

	string b[n] = a;

	bubbleSort(a);
	selectionSort(b);

	rep(i, n) {
		if (i) cout << ' ';
		cout << a[i];
	}

	cout << endl;
	cout << "Stable" << endl;

	rep(i, n) {
		if (i) cout << ' ';
		cout << b[i];
	}
	cout << endl;

	bool is = true;
	rep(i, n) {
		if (a[i] != b[i])
			is = false;
	}

	string ans = "Not stable";
	if (is) ans = "Stable";

	cout << ans << endl;
}



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

typedef unsigned long long ll;
struct edge {int to, cost; };

const int V_MAX = 100000;
array< vector< edge > , V_MAX> G;
ll d[V_MAX];
bool arrived[V_MAX];

void dfs (int node, ll distance) {
  d[node] = distance;
  arrived[node] = true;
  for (auto next : G[node]) {
    if (!arrived[next.to]) {
      dfs(next.to, distance+next.cost);
    }
  }
}

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N-1; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    struct edge st, rev;
    st.to = b-1;
    st.cost = c;
    G[a-1].push_back(st);
    rev.to = a-1;
    rev.cost = c;
    G[b-1].push_back(rev);
  }
  fill(arrived, arrived+N, false);
  int Q, K;
  cin >> Q >> K;
  dfs(K-1, 0);
  for (int i = 0; i < Q; i++) {
    int x, y;
    cin >> x >> y;
    cout << d[x-1]+d[y-1] << endl;
  }
}

Measured memory_bytes: 11264
#include<stdio.h>

int a[10000];

void set_prime()
{
int i,j;

a[2]=1;

for(i=3;i<10000;i+=2) a[i]=1;

for(i=3;i*i<10000;i+=2)
    if(a[i]==1)
        for(j=2;j*i<10000;j+=1)
            a[i*j]=0;
}

int main(void){

int i,n,count;
set_prime();

while(scanf("%d",&n)!=EOF){
    count=0;
    for(i=1;i<n+1;i++){
        if(a[i]==1&&a[n+1-i]==1){
            count++;
        }
    }
    printf("%d\n",count);
}
return 0;}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
  int a,b;
  cin >>a>>b;
  if(a>=b*2) {
    cout <<a-b*2<<endl;
  }
  else {
    cout <<0<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
std::vector<int> Factorial(1234567),Finverse(1234567);
void Cinit(){
  Factorial[0]=1;
  for(int i=1;i<1234567;i++)Factorial[i]=Factorial[i-1]*i%MOD;
  for(int i=0;i<1234567;i++)Finverse[i]=pw(Factorial[i],MOD-2);
}
int nCk(int n,int k){
  if(n<k)return 1;if(k<0)return 0;
  int res=Factorial[n];
  res*=Finverse[k];res%=MOD;
  res*=Finverse[n-k];res%=MOD;
  return res;
}
//main
signed main(){
  Cinit();
  int N,H,D;cin>>N>>H>>D;
  int sum=0;
  std::vector<int> wa(1234567);
  wa[0]=0;for(int i=1;i<1234567;i++)wa[i]=(wa[i-1]+Factorial[i])%MOD;
  //cout<<wa[5]<<endl;return 0;
  std::vector<int> dp(3234567,0);
  queue<int> que;
  for(int i=0;i<=H;i++){
    if(i==0){
      dp[1]+=Factorial[N];
      sum+=dp[1];
      que.push(sum);
      continue;
    }
    if(que.size()>D){
      int p=que.front();que.pop();
      sum-=p;
      if(sum<0)sum+=MOD;
    }
    dp[i]=sum;
    que.push(sum*wa[N]%MOD);
    sum+=sum*wa[N]%MOD;sum%=MOD;
  }
  //for(int i=0;i<=10;i++)cout<<dp[i]<<" ";cout<<endl;
  cout<<dp[H]<<endl;
}


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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T &_t) { for (auto &_e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

const char O = '#';
const char F = '.';

struct UnionFind {
	vector<int> data;
	UnionFind() {};
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int main(void) {
	int H, W;
	cin >> H >> W;
	vec<string> MAP;
	resize(MAP, H);

	for (int i = 0; i < H; ++i) {
		cin >> MAP[i];
	}

	vec<UnionFind> uW(H, UnionFind(2000 + 1));
	vec<UnionFind> uH(W, UnionFind(2000 + 1));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W - 1; ++j) {
			if (MAP[i][j] == F && MAP[i][j + 1] == F) {
				uW[i].unionSet(j, j + 1);
			}
		}
	}

	for (int j = 0; j < W; ++j) {
		for (int i = 0; i < H - 1; ++i) {
			if (MAP[i][j] == F && MAP[i + 1][j] == F) {
				uH[j].unionSet(i, i + 1);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int sum = uH[j].size(i) + uW[i].size(j);
			ans = max(ans, sum);
		}
	}

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

}

Measured memory_bytes: 35968
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8[:], i8)")
def binary_search(a, key):
    """Meguru type binary search"""
    ok = -1
    ng = len(a)

    while (ng - ok > 1):
        mid = (ok + ng) // 2
        if a[mid] <= key:
            ok = mid
        else:
            ng = mid

    return ok


@nb.njit("i8(i8,i8,i8,i8[:],i8[:])")
def solve(N, M, K, A, B):
    B_cumsum = B.cumsum()
    ans = 0
    time = 0
    for i in range(N + 1):
        if time > K:
            break
        j = binary_search(B_cumsum, K - time) + 1
        ans = max(ans, i + j)
        if i < N:
            time += A[i]
    return ans


def main():
    N, M, K = map(int, input().split())
    A = np.array(input().split(), dtype=np.int64)
    B = np.array(input().split(), dtype=np.int64)
    # A = tuple(map(int, input().split()))
    # B = tuple(map(int, input().split()))

    ans = solve(N, M, K, A, B)
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
	string s; cin >> s;
	s += (s[s.size() - 1] == 'W' ? 'B' : 'W');
	int num = 0;
	char flag = s[0];
	for(int i = 0; i < s.size(); ++i){
		if(flag != s[i]){
			flag = s[i];
			++num;
		}
	}
	cout << num - 1 << endl;
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  vll cnts(n);
  vb flgs(n);
  rrep(i,n){
    if(cnts[i]%2!=a[i]){
      flgs[i]=true;
      auto v=divisor(i+1);
      for(auto e:v){
        cnts[e-1]++;
      }
    }
  }
  
  ll cnt=0;
  vll ans;
  rep(i,n){
    if(flgs[i]){
      cnt++;
      ans.push_back(i+1);
    }
  }
  cout<<cnt<<endl;
  rep(i,cnt){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  if(cnt) cout<<endl;
  
 }

Measured memory_bytes: 5108
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int K;
	string S;
	cin >> K >> S;
	if (S.length() > K)
	{
		for (int count = 0; count < K; count++)
		{
			cout << S.at(count);
		}
		cout << "..." << endl;
	}
	else
	{
		cout << S << endl;
	}
}

Measured memory_bytes: 3600
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let (a, b) = {
        let mut ws = s.split_whitespace();
        let n: i64 = ws.next().unwrap().parse().unwrap();
        let m: i64 = ws.next().unwrap().parse().unwrap();
        (n, m)
    };

    let eight = (a as f64 / 0.08).ceil();
    let ten = (b as f64 / 0.1).ceil();
    if eight > ten && (eight * 0.1).floor() as i64 == b {
        println!("{}", eight);
    } else if (ten * 0.08).floor() as i64 == a {
        println!("{}", ten);
    } else {
        println!("-1");
    }
}

// floor(a/0.08), floor(b/0.1)で大きい方を出力する


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
typedef double D;
typedef complex<D> P;
const D EPS = 1e-8;
const D PI = acos(-1);

int n,r,q,r2;
P p[30];
int cur;
D min_s[30],x,y;

inline D dot(const P &x, const P &y){return real(conj(x)*y);}

inline P rotate(const P &v, const D &s){
  return P(real(v)*cos(s) - imag(v)*sin(s), real(v)*sin(s) + imag(v)*cos(s) );
}

inline D arg(const P &a,const P &b,const P &c){return dot(b-a,c-a)/(abs(b-a)*abs(c-a));}

inline D rot_seta(const int &end){
  D seta = acos( 1 - norm(p[end]-p[cur])/r2 );
  P nxt = rotate(p[cur],-seta);
  return arg(p[cur],p[end],nxt);
}

int main(){
  while(scanf("%d%d%d",&n,&r,&q), n){
    r2 = 2*r*r;
    rep(i,n){
      scanf("%lf%lf",&x,&y);
      p[i] = P(x,y);
      if(abs(abs(p[i])-r)<EPS)cur = i;
    }
    
    vector<int> nxt(n,-1);

    rep(i,q){
      if(nxt[cur]<0){
	min_s[cur] = PI;
	rep(j,n){
	  if(cur==j)continue;
	  D s = rot_seta(j);
	  if(nxt[cur]<0 || s > min_s[cur]+EPS)nxt[cur] = j, min_s[cur] = s;
	}
	min_s[cur] = acos(min_s[cur]);
      }

      rep(j,n){
	if(j==cur)continue;
	p[j] = rotate(p[j]-p[cur],min_s[cur]) + p[cur];
      }
      printf("%.9lf %.9lf\n",p[nxt[cur]].real(), p[nxt[cur]].imag());

      if(i==0){
	int tmp = nxt[cur];
	nxt[cur] = -1;
	cur = tmp;
      }else{
	cur = nxt[cur];
      }
    }
  }
}

Measured memory_bytes: 1336
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;




int main(void) {
	int N,ans;
	ans = 0;
	cin >> N;
	vint l(N), r(N);
	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
		ans += r[i] - l[i]+1;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,mi = n,ma = 0;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    rep(i,n){
        chmin(mi,a[i]);
        chmax(ma,a[i]);
    }
    if (ma-mi > 1){
        PRINT("No");
    }
    else if (ma == mi){
        if (mi == n-1 || mi <= n/2){
            PRINT("Yes");
        }
        else{
            PRINT("No");
        }
    }
    else{
        ll c = 0;
        rep(i,n){
            if (a[i] == ma) c++;
        }
        ll d = n-c;
        if (d+1 <= ma && ma <= d+c/2) PRINT("Yes");
        else PRINT("No");
    }
}


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

int main() {
    string a, b;
    cin >> a >> b;
    int x = stoi(a + b);
    int c = sqrt(x);
    if (c*c == x) cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>

int main(void){
	int pas[3], ju[2], i, total;
	for (i = 0; i < 3; i++)
		scanf("%d", &pas[i]);
	for (i = 0; i < 2; i++)
		scanf("%d", &ju[i]);
		
	if (pas[0] < pas[1] && pas[0] < pas[2])
		total = pas[0];
	else if (pas[1] < pas[2]) total = pas[1];
	else total = pas[2];
	
	if (ju[0] < ju[1]) total += ju[0];
	else total += ju[1];
	
	printf("%d\n", total -50);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;


void solve()
{
	string s,t;
	cin>>s>>t;
	int n=s.size();
	int ans=0;
	rep(i,n){
		if(s[i]!=t[i])++ans;
	}
	cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3780
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

char t[8][9];
int n = 8;
int all_turn;
int dx[]={-1,-1,-1,0,0,1,1,1},dy[]={-1,0,1,-1,1,-1,0,1};

bool check(int row, int col){
  return (row >= 0 && row <= 7 && col >= 0 && col <= 7);
}
void turn(int x, int y, char c){
  char e_c = (c == 'o' ? 'x' : 'o');
  //8-directions
  REP(i,n){
    int res = 1;
    while(check(x+res*dx[i], y+res*dy[i])){
      char focus = t[x+res*dx[i]][y+res*dy[i]];
      if(focus == c){
	t[x][y] = c;
	FOR(j,1,res) t[x+j*dx[i]][y+j*dy[i]] = c;
	break;
      }
      else if(focus == e_c) res++;
      else break;
    }
  }    
}

int simulate(int x, int y, char c){
  int ret = 0;
  char e_c = (c == 'o' ? 'x' : 'o');
  //8-directions
  REP(i,n){
    int res = 1;
    while(check(x+res*dx[i], y+res*dy[i])){
      char focus = t[x+res*dx[i]][y+res*dy[i]];
      if(focus == c){
	ret += res-1;
	break;
      }
      else if(focus == e_c) res++;
      else break;
    }
  }  
  return ret;
}
bool solve(){
  int max_n=0, max_x=-1, max_y=-1;
  char c = 'o';

  REP(i,n) REP(j,n){
    if(t[i][j] == '.'){      
      int num = simulate(i,j,c);
      if(max_n<num){
	max_n = num;
	max_x = i;
	max_y = j;
      }
    }
  }
  if(max_x >= 0) turn(max_x, max_y, c);  
  return (max_n > 0);
}

bool _solve(){
  int max_n=0, max_x=-1, max_y=-1;
  char c = 'x';

  ROF(i,7,0) ROF(j,7,0){
    if(t[i][j] == '.'){          
    int num = simulate(i,j,c);
    if(max_n<num){
      max_n = num;
      max_x = i;
      max_y = j;
    }
    }
  }
  if(max_x >= 0) turn(max_x, max_y, c);  
  return (max_n > 0); 
}

int
main(void){  
  ios_base::sync_with_stdio(false);

  REP(i, n) cin >> t[i];

  bool first = true, second = true;
  while(first || second){
    first = solve();
    second = _solve();
  }

  REP(i,n) {
    REP(j,n) cout << t[i][j];
    cout << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    int a,b,i;
    char s;
    cin>>a>>b;
    for (i=1;i<=a;i++)
    {
        cin>>s;
        if (s<'0'||s>'9')
        { cout<<"No"<<endl; return 0; }
    }
    cin>>s;
    if (s!='-') { cout<<"No"<<endl; return 0; }
    for (i=1;i<=b;i++)
    {
        cin>>s;
        if (s<'0'||s>'9')
        { cout<<"No"<<endl; return 0; }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String a = stdIn.next();
		String b = stdIn.next();
		
		if(a.equals("H") && b.equals("H")) { 
			System.out.println("H");
		}else if(a.equals("H") && b.equals("D")) {
			System.out.println("D");
		}else if(a.equals("D") && b.equals("H")) {
			System.out.println("D");
		}else {
			System.out.println("H");
		}
		
		
	}

}


Measured memory_bytes: 20692
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int A=scan.nextInt();
    int B=scan.nextInt();
    int x=A-B*2;
    if(x<0){
      System.out.println("0");
    }else{
      System.out.println(x);
    }
  }
}

Measured memory_bytes: 22996
import sys
sys.setrecursionlimit(10 ** 9)

n,m = map(int,input().split())
g = [[] for i in range(n)]
 
for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    g[x].append(y)
dp = [-1]*n
 
def dfs(i):
    #すでに計算されているなら
    if dp[i] != -1:
        return dp[i]
    #初期は長さ0
    tmp = 0
    #iからスタートしてつながっているところにDFS
    for j in g[i]:
        #今までの距離と比較
        tmp = max(tmp, dfs(j) + 1)
    #dp[i]はiからスタートして最長距離が記録される
    #空のリストにたどり着いたらDFS終わり
    dp[i] = tmp
    return tmp
 
for i in range(n):
    dfs(i)

print(max(dp))

Measured memory_bytes: 59008
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
 
 
int main(){
    std::string s;
    int n,k;
    std::cin >> n >> k;
    std::cin >> s;
  
  std::vector<std::pair<bool,size_t>> l;
  for(auto const& c:s){
    if(l.empty()){
      l.push_back({c == '1',1});
      continue;
    }    
    if(l.back().first == (c == '1')){
      l.back().second++;
    }else{
      l.push_back({c == '1',1});
    }
  }
  
  int max = 0;
  int cur = 0;
  size_t left = 0;
  for(size_t i=0;i<l.size();++i){
    cur += l[i].second;
  	if(!l[i].first){
      if(k == 0){
        do{
          cur -= l[left].second;;
      	  left++;
        }while(!l[left].first);
      }else{
        k--;
      }
    }
    max = std::max(max,cur);
  }
  std::cout << max << std::endl;
}

Measured memory_bytes: 2548
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

ub = 10 ** 12 + 10
lb = 0
while ub - lb > 1:
    mid = (ub + lb) // 2
    cnt = 0
    for x, y in zip(A, F):
        res = max(0, x * y - mid)
        cnt += -(-res // y)

    if cnt <= K:
        ub = mid
    else:
        lb = mid

if sum(A) <= K:
    print(0)
else:
    print(ub)


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


int main() {
  int n; cin>>n; 
  int sum=0;
  vector<int>d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d.begin(),d.end());
  cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 640
from bisect import bisect_left, bisect_right
N = int(input())

MOJI = [26]
for i in range(2,12):
  MOJI.append(MOJI[i-2]+26**i)

#print(MOJI)

C = bisect_left(MOJI, N)+1

ans = []
for i in range(0,C):
  tmp = N%26
  if tmp == 0:
    tmp = 26
  #print(tmp)
  ans.append(chr(tmp+ord("a")-1))
  N = (N-tmp)//26
  #print(N)

ans.reverse()

L=[str(a) for a in ans]
L="".join(L)
print(L)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

int a[N];
int n,k;
vector<int> l, r;
int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	sf(n); sf(k);
	f(i, 1, n) {
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	int l = 1, r = k;
	int res = inf;
	while (r <= n) {
		if (a[l] < 0 && a[r] < 0)res = min(res, -a[l]);
		else if (a[l] < 0 && a[r] >= 0) {
			res = min(res, 2 * min(-a[l], a[r]) + max(-a[l], a[r]));
		}
		else res = min(res, a[r]);
		l++, r++;
	}
	cout << res;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;

int main(){
  ll n;
  cin >> n;
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  ll a = 2, cnt = 0;
  bool ok = true;
  ll st = n;
  map<ll,ll> mp;
  //vector<ll> e = Eratosthenes(n);

  while(n >= a * a) {
    if(n % a == 0){
      mp[a]++;
      n /= a;
    }else{
      a++;
    }
  }
  mp[n]++;
  for(auto p : mp){
    ll tmp = 1;
    while(p.second > 0) {
      if(p.second >= tmp){
        p.second -= tmp;
        cnt++;
        tmp++;
      } else {
        p.second = 0;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, k;
	cin >> n >> k;
	vector<int> goo (n);
	cinv (goo);
	sort (all (goo));
	int s = 0;
	fr (i, k) {
		s += goo[i];
	} cout << s << '\n';








}

Measured memory_bytes: 3672
#include <stdio.h>

int main(void)
{
    int ant[5], min, max, i, k;

    for (i = 0; i < 5; i++)
        scanf("%d", &ant[i]);

    scanf("%d", &k);
    printf("%s", (ant[4] - ant[0] <= k) ? "Yay!" : ":(");
    
    return 0;
}

Measured memory_bytes: 128
//https://atcoder.jp/contests/abc114/tasks/abc114_a


#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <bitset>

using namespace std;


int main(){
	int x;
	string ans;
	cin>>x;
	
	if(x==3 or x==5 or x==7) ans="YES";
	else ans="NO";

	cout<<ans<<endl;
}








Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	int a, b;
	string s;
	cin >> a >> b >> s;
	bool ans = true;
	REP(i, a) {
		if (!(s[i] >= '0' && s[i] <= '9'))ans = false;
	}
	if (s[a] != '-')ans = false;
	FOR(i, a + 1, a + b + 1) {
		if (!(s[i] >= '0' && s[i] <= '9'))ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
#define int long long





int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	int n, k;
	cin >> n >> k;

	vector<int>a(n);

	vector <int>dp(k + 1);

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


	for (int i = 0; i <= k; i++) {
		for (auto x : a) {
			if (i >= x) {
				if (dp[i - x] == 0) {
					dp[i] = 1;
				}
			}
		}
	}




	cout << ((dp[k]) ? "First" : "Second") << endl;




}

Measured memory_bytes: 3992