akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
int INF = numeric_limits<int>::max();
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

/* if in function
template <class T>
bool contain(vector<T> &vec, T find_it) {
  auto it = find(vec.begin(), vec.end(), find_it);
  return it != vec.end();
}

bool contain(string &str, char c) {
  return str.find(c) != string::npos;
}
*/

int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b > 9 ? "error" : to_string(a + b)) << endl;
}


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

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000
#define LLINF 1e18

#define MAX_V 200005
struct edge {
	int to;
	int cost;
};
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + MAX_V, INF);
	d[s] = 0;
	que.push(P(0, s));

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

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

void solve_abc_c() {
	ll n, m;
	ll k;
	ll h, w;
	//ll x;
	//ll a;
	string s;
	string s_ans;
	ll l_ans = 0;
	double d_ans = 0;

	cin >> k;

	if (k % 2 == 0 || k % 5 == 0) {
		cout << -1 << "\n";
		return;
	}

	V a(1000000);
	ll now = 1;
	rep(i, 1000000) {
		a[i] = now;
		now = now * 10 % k;
	}

	ll sum = 0;
	rep(i, 1000000) {
		sum += a[i] * 7;
		if (sum % k == 0) {
			l_ans = i;
			break;
		}
	}

	cout << l_ans + 1 << "\n";
}

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

	solve_abc_c();

	return 0;
}


Measured memory_bytes: 15828
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n,m;
  int a[SIZE],b[SIZE],c[SIZE];
  ll cost[SIZE];
  
  scanf("%d%d",&n,&m);

  for(int i=0;i<m;i++){
    scanf("%d%d%d",a+i,b+i,c+i);
    a[i]--;
    b[i]--;
    c[i] *= -1;
  }

  for(int i=0;i<n;i++){
    cost[i] = LLINF;
  }
  cost[0] = 0;
  
  ll memo[2];
  
  for(int k=0;k<2;k++){

    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        cost[b[j]] = min(cost[b[j]],cost[a[j]] + c[j]);
      }
    }

    memo[k] = cost[n-1];
  }

  
  if(memo[0] != memo[1]){
    puts("inf");
  }else{
    printf("%lld\n",-memo[0]);
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int t,i,j,n,x,a[maxn],b[maxn],p1[maxn],p2[maxn];ll ans,sum,sa,sb,s;
int mi,cmi,z1,z2;
bool bz[maxn],B;
bool cmp1(int x,int y){return a[x]>a[y];}
bool cmp2(int x,int y){return b[x]>b[y];}
int main(){
	scanf("%d",&n);
	fo(i,1,n) scanf("%d%d",&a[i],&b[i]),p1[i]=p2[i]=i,sa+=a[i],sb+=b[i];
	sum=sa+sb;
	sort(p1+1,p1+1+n,cmp1);
	sort(p2+1,p2+1+n,cmp2);
	i=j=1;
	fo(t,1,n){
		if (i<=n&&a[p1[i]]>=b[p2[j]]) ans+=a[x=p1[i++]];else ans+=b[x=p2[j++]];
		if (t==n) mi=x;
		if (t==n-1) cmi=x;
		B|=bz[x],bz[x]=1;
	}
	z1=max(a[mi],b[mi]),z2=max(a[cmi],b[cmi]);
	if (!B){
		s=-2e9;
		fo(i,1,n){
			if (a[i]>=b[i]) s=max(s,b[i]-(i!=mi?z1:z2));
			else s=max(s,a[i]-(i!=mi?z1:z2));
		}
		ans+=s;
		ans=max(ans,sa);
		ans=max(ans,sb);
	}
	printf("%lld\n",sum-ans);
}

Measured memory_bytes: 1920
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

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

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

long long divide[1003];

void solution(int n){
    // 割る数の初期値
    int a=2;
    int temp=n;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (temp >= a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            divide[a]++;
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    divide[n]++;
}

int main() {
    int N;
    long long ans=1;
    cin >> N;

    for(int i=0; i<1002; i++){
        divide[i]=1;
    }
    for(int i=1; i<=N; i++){
        solution(i);
    }

    for(int i=2; i<=N; i++){
        ans*=divide[i];
        ans%=MOD;
    }


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



Measured memory_bytes: 256
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for(ll i = x; i < n; i++)
#define rrep(i, x, n) for(ll i = x; i >= n; i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define e emplace
#define mp make_pair
#define debug(this) cout<<"> "<<#this<<" : "<<this<<"\n"
typedef long long int ll;
typedef long double ld;
typedef pair< ll, ll > pii;
typedef vector< ll > vi;
typedef vector< vi > vvi;
const ll MOD = 1e9+7;
ld PI=3.1415926535897932384626;
ld EPS = 1e-9;
#define endl '\n'

int main() {
	boost;
	ll l, r;
	cin >> l >> r;
	if(l <= 2019 and r >= 2019) {
		cout << "0";
		return 0;
	}
	ll ans = (l * r) % 2019;
	l = max(l, r - 4 * 2019);
	rep(i, l, r) rep(j, (i+1), (r+1)) ans = min(ans, (i * j) % 2019);
	cout << ans;
}
























Measured memory_bytes: 256
// N, M, Q
// Q times ai, bi, ci, di
// A (vector)
// A -> N (size)
// Ai <= M
// A[b[i]] - A[a[i]] == c[i] -> Sum d[i];
// Find Max score!

#include <bits/stdc++.h>
using namespace std;

int n, m, q;
vector<int> a, b, c, d, A;
int ans = 0;

int check() {
	int res = 0;
	for (int i = 0; i < q; i++) {
		if(A[b[i] - 1] - A[a[i] - 1] == c[i]) {
			res += d[i];
		}
	}
	return res;
}

void makeSequence(int i, int cur) {
	if(i >= n) {
		// find our score!
		ans = max(ans, check());
		return;
	}

	for (int j = cur; j <= m; j++) {
		A.push_back(j);
		makeSequence(i + 1, j);
		A.pop_back();
	}
}

int main() {
	cin >> n >> m >> q;
	a = b = c = d = vector<int>(q);

	for (int i = 0; i < q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	makeSequence(0, 1);

	cout << ans << "\n";
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
using namespace std;
int main(void){
	string s;
	cin>>s;
	int end=s.size()-1;
	if((s[0]==s[end]&&end%2==1)||(s[0]!=s[end]&&end%2==0)){
		cout<<"First"<<endl;
	}else
	{
		cout<<"Second"<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
int n;
int bit[100010];
void add(int v, int x) {

	while (v <= n)
	{
		bit[v] += x;
		v += v & -v;
	}
}

ll sum(int v) {
	ll r = 0;
	while (v > 0)
	{
		r += bit[v];
		v -= v & -v;
	}
	return r;
}
class Dice {

public :
	int u, s, e, w, n, d;
	Dice(int u, int s, int e, int w, int n, int d) : u(u),s(s),e(e),w(w),n(n),d(d){
	}
	void cp(int _u, int _s, int _e, int _w, int _n, int _d) {
		u = _u;
		s = _s;
		e = _e;
		w = _w;
		n = _n;
		d = _d;
	}
	void swicth(char c) {
		if (c == 'S') {
			cp(n, u, e, w, d, s);
		}
		else if (c == 'E') {
			cp(w, s, u, d, n, e);
		}
		else if (c == 'W') {
			cp(e, s, d, u, n, w);
		}
		else if (c == 'N') {
			cp(s, d, e, w, u, n);
		}
	}

};
void solv() {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	Dice di(a, b, c, d, e, f);
	string s;
	cin >> s;
	for (size_t i = 0; i < s.size(); i++)
	{
		di.swicth(s[i]);
	}
	cout << di.u << endl;
}


int main() {
	//	COMinit();
	solv();

	return 0;
}



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

int main() {
    int k; cin >> k;
    long long ans = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                ans += __gcd(i, __gcd(j, l));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 50;


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

	const int NMAX = 2500;
	const int MMAX = 5000;
	int a[MMAX], b[MMAX];
	ll c[MMAX];

	for (int i = 0; i < M; ++i) {
		cin >> a[i] >> b[i] >> c[i];
		c[i] = -c[i] + P;
	}

	ll dist[NMAX];

	for (int i = 0; i < N; ++i) {
		dist[i] = INF;
	}

	dist[0] = 0;


	for (int loop = 0; loop < N - 1; ++ loop) {
		for (int i = 0; i < M; ++i) {
			if (dist[a[i] - 1] == INF) continue;

			if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
				dist[b[i] - 1] = dist[a[i] - 1] + c[i];
			}
		}
	}

	ll ans = dist[N - 1];


	bool negative[NMAX];

	for (int i = 0; i < N; ++i) {
		negative[i] = false;
	}

	for (int loop = 0; loop < N ; ++ loop) {
		for (int i = 0; i < M; ++i) {
			if (dist[a[i] - 1] == INF) continue;

			if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
				dist[b[i] - 1] = dist[a[i] - 1] + c[i];
				negative[b[i] - 1] = true;
			}

			if (negative[a[i] - 1] == true) {
				negative[b[i] - 1] = true;
			}
		}
	}


	if (negative[N - 1])
		cout << -1 << endl;
	else
		cout << max(0LL, -ans) << endl;

	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a, Collections.reverseOrder());
        System.out.println(a[0] - a[n - 1]);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  sort(all(a), greater<int>());
  int A = 0, B = 0;
  REP(i, n) {
    if (i%2==0) A += a[i];
    else B += a[i];
  }
  cout << A - B << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];

  vi diff(n);
  rep(i,n) diff[i] = a[i]-(i+1);
  sort(all(diff));
  ll ans = 0;
  rep(i,n) ans += abs(a[i] - (diff[n/2]+i+1));
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4744
#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)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const ll INF = 1E+16;

ll dp[200005][3];

ll f(ll a, ll v) {
    if (a==-INF) return -INF;
    else return a+v;
}

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans;

    if (n==2) {
        ans = max(a[0], a[1]);
        cout << ans << endl;
        return 0;
    }
    

    dp[0][0] = a[0];
    
    dp[1][1] = a[1];
    dp[2][0] = a[0] + a[2];
    dp[2][2] = a[2];

    rep(i, n) rep(j, 3) {
        if (i<=2) continue;
        if (j==0) {
            if (i%2==1) continue;
            dp[i][j] = dp[i-2][j]+a[i];
        }
        if (j==1) {
            if (i%2==0) continue;
            dp[i][j] = max(dp[i-2][j]+a[i], dp[i-3][j-1]+a[i]);
        }
        if (j==2) {
            if (i%2==1) continue;
            dp[i][j] = max(dp[i-4][j-2]+a[i], max(dp[i-2][j]+a[i], dp[i-3][j-1]+a[i]));
        }
        //cout << i << " " << j << " " << dp[i][j] << endl;
    }
    
    
    if (n%2==0) {
        ans = max(dp[n-1][1], dp[n-2][0]);
    }
    else {
        ans = max(dp[n-3][0], max(dp[n-1][2], dp[n-2][1]));
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  if(n>2100) cout<<1<<endl;
  else{
    int num=n/100;
    if(num*105 < n) cout<<0<<endl;
    else cout<<1<<endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int N; cin >> N;
  vector < pair<int, int> > A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i].first;
    A[i].second = i;
  }

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

  int cnt = 0;
  for (int i = 0; i < N; i++){
    if (i % 2 != A[i].second % 2){
      cnt++;
    }
  }
  cout << cnt / 2 << endl;

  return 0;
}


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

int main(){
    LL n;
    cin >> n;
    LL a[n];
    LL b[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    LL pa = 0;
    LL pb = 0;
    for(int i = 0; i < n; i++){
        if(b[i] < a[i]){
            pb += a[i] - b[i];
        } else {
            LL c = b[i] - a[i];
            pa += (c+1)/2;
            if(c % 2 == 1) pb ++;
        }
    }
    //cout << pa << " " << pb << endl;
    if(pa >= pb){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 384
#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>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    ll a, b;
    cin >> a >> b;
    cout << a / __gcd(a, b) * b << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

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

  private static Scanner sc;

  private void run() {
    sc = new Scanner(System.in);
    for (int i = 0; i < 5; i++) {
      int num = Integer.parseInt(sc.next());
      if (num == 0) {
        System.out.println(i + 1);
        break;
      }
    }
  }
}


Measured memory_bytes: 35612
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll A,B;
	cin >>A >>B;
	
	// 解法
	if (abs(A-B)%2==1) printf("IMPOSSIBLE\n");
	else printf("%lld\n", B + (A - B)/2);
	
}


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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while(1){
    C -= B;
    if(C <= 0){
      Yes;
      return 0;
    }

    A -= D;
    if(A <= 0){
      No;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include<algorithm>
using namespace std;
int main() {
      ios_base::sync_with_stdio(false);
       cin.tie(NULL);
       int n,k,sum=0;
       cin>>n>>k;
       int a[n];
       for(int i=0;i<n;i++)
       cin>>a[i];
       sort(a,a+n);
       for(int i=0;i<k;i++)
       sum=sum+a[i];
       cout<<sum;
	return 0;
}


Measured memory_bytes: 3620
program answer
  implicit none
  integer(16) :: N, i, ans
  integer(16), allocatable :: T(:)
  read(*,*) N
  allocate(T(N))
  do i = 1, N
     read(*,*) T(i)
  end do

  call koubai(N,T,ans)
  write(*,*) ans

  deallocate(T)
  stop
contains
  subroutine koubai(n,array,ans)
    implicit none
    integer(16) :: i, ans, n, maxyaku, a, b
    integer(16) :: array(n)
    a=array(1)
    do i = 1, n-1
       b=array(i+1)
       call koyaku(a,b,maxyaku)
       a=b/maxyaku*a
    end do
    ans=a
  end subroutine koubai

  subroutine koyaku(a,b,ans)
    implicit none
    integer(16) :: i, a, b, ans, s, t, u
    if(a>b) then
       s=b
       b=a
       a=s
    end if
    s=b
    t=a
    do
       if(mod(s,t)==0) then
          ans=t
          exit
       end if
       u=t
       t=mod(s,t)
       s=u
    end do
  end subroutine koyaku

 end program answer

Measured memory_bytes: 2780
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

int main() {
  int N;
  cin>>N;
  vector<vector<int>>A(N,vector<int>(N-1));
  for(int i=0;i<N;i++){
    for(int j=0;j<N-1;j++){
      cin>>A[i][j];
      A[i][j]--;
    }
    reverse(A[i].begin(),A[i].end());
  }
  set<pair<int,int>>k;
  queue<pair<int,int>>now;
  auto check=[&](int a){
    if(A[a].size()==0){return;}
    int b=A[a].back();
    if(A[b].back()==a){
      if(a>b){swap(a,b);}//cout<<1<<endl;
      if(!k.count(make_pair(a,b))){now.push(make_pair(a,b));k.insert(make_pair(a,b));}
    }
  };
  for(int i=0;i<N;i++){
    check(i);
  }

  int day=0;
  while(!now.empty()){
    day++;//cout<<day<<endl;
    queue<pair<int,int>>BACK;
    swap(BACK,now);
    while(!BACK.empty()){
      auto p=BACK.front();BACK.pop();
      int a=p.first,b=p.second;
      A[a].pop_back();
      A[b].pop_back();
      check(a);
      check(b);
    }
  }
  for(int i=0;i<N;i++){
    if(A[i].size()!=0){
      cout<<-1<<endl;return 0;
    }
  }
  cout<<day<<endl;
  return 0;  
}

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

using namespace std;

int main() {

	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;

	int counter = 0;
	if (a <= 0) {
		counter += -a * c + d + b * e;
	}
	else {
		counter += (b-a) * e;
	}
	
	cout << counter << endl;
}


Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()
 
 
int main() {
  int A, B;
  cin >> A >> B;
  int X;
  cin >> X;
  if(A <= X and X <= A + B) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

using namespace std;
typedef long long li;

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

    li n, k;
    cin >> n >> k;

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

    vector<bool> win(k + 1, false);

    for (int i = 0; i <= k; ++i) {
        bool x = false;
        for (int j = 0; j < n; ++j) {
            int stones = i - ops[j];
            if (stones < 0) {
                continue;
            }
            x |= !win[stones];
        }
        win[i] = x;
    }

    cout << (win[k] ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  reverse(S.begin(), S.end());
  vector <string> judge = {"maerd", "remaerd", "esare", "resare"};
  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j ++) {
      string juge = judge[j];
      if (S.substr(i, juge.size()) == juge) {
        can2 = true;
        i += juge.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;

	vector<int> t(N+3);
	vector<int> v(N+3);

	t[0] = numeric_limits<int>::min();
	t[1] = 0;
	t[N+2] = numeric_limits<int>::max();
	for (int i = 2; i <= N + 1; i++) {
		int ti;
		cin >> ti;
		t[i] = ti + t[i-1];
	}
	v[0] = 0;
	for (int i = 1; i <= N; i++) cin >> v[i];
	v[N+1] = 0;

	vector<double> V(2*t[N+1]+1);

	for (int x = 0; x <= 2 * t[N+1]; x++) {
		double m = numeric_limits<double>::max();
		for (int i = 0; i <= N+1; i++) {
			if (0.5 * x < t[i]) {
				m = min(m, - 0.5 * x + (v[i] + t[i]));
			} else if (0.5 * x < t[i+1]) {
				m = min(m, (double)v[i]);
			} else {
				m = min(m, 0.5 * x + (v[i] - t[i+1]));
			}
		}
		V[x] = m;
	}

	double ans = 0.0;
	for (int x = 0; x < 2 * t[N+1]; x++) {
		ans += V[x] + V[x+1];
	}

	cout << setprecision(20) << 0.25 * ans << endl;

	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> M(3);
    int a, b, c;
    cin >> M[0] >> M[1] >> a >> b >> c;
    vector<pair<int, int>> d(a + b + c);
    for (int i = 0; i < a; ++i) {
        cin >> d[i].first;
        d[i].second = 0;
    }
    for (int i = a; i < a + b; ++i) {
        cin >> d[i].first;
        d[i].second = 1;
    }
    for (int i = a + b; i < a + b + c; ++i) {
        cin >> d[i].first;
        d[i].second = 2;
    }
    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());
    vector<int> cnt(3, 0);
    M[2] = ~0u >> 1;
    long long ans = 0;
    for (int i = 0; i < a + b + c; ++i) {
        ++cnt[d[i].second];
        if (cnt[d[i].second] <= M[d[i].second]) {
            ans += d[i].first;
        }
        int out = 0;
        for (int j = 0; j < 3; ++j) out += max(cnt[j] - M[j], 0);
        if (out == i - M[0] - M[1] + 1) {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2560
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int UF[100];
int x[100][4];
int y[100][4];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);
	b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];
	UF[b]=a;
}
bool inclusive(int ax,int ay,int bx,int by,int cx,int cy,int px,int py){
	bool ok1=true;
	bool ok2=true;
	if((bx-ax)*(py-ay)-(px-ax)*(by-ay)<0)ok1=false;
	if((bx-ax)*(py-ay)-(px-ax)*(by-ay)>0)ok2=false;
	if((cx-bx)*(py-by)-(px-bx)*(cy-by)<0)ok1=false;
	if((cx-bx)*(py-by)-(px-bx)*(cy-by)>0)ok2=false;
	if((ax-cx)*(py-cy)-(px-cx)*(ay-cy)<0)ok1=false;
	if((ax-cx)*(py-cy)-(px-cx)*(ay-cy)>0)ok2=false;
	return ok1||ok2;
}

bool intersect(int ax,int ay,int bx,int by,int cx,int cy,int dx,int dy){
	long long ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	long long tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	long long tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	long long td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	if(ta*tb<0LL&&tc*td<0LL)return true;
	else return false;
}

int main(){
	int a;
	while(scanf("%d",&a),a){
		while(a--){
			int b;
			scanf("%d",&b);
			for(int i=0;i<b;i++){
				for(int j=0;j<4;j++)scanf("%d%d",&x[i][j],&y[i][j]);
			}
			for(int i=0;i<b;i++)UF[i]=-1;
			for(int i=0;i<b;i++){
				for(int j=i+1;j<b;j++){
					
					bool ok=false;
					for(int k=0;k<4;k++){
						if(inclusive(x[i][0],y[i][0],x[i][1],y[i][1],x[i][2],y[i][2],x[j][k],y[j][k]))ok=true;
						if(inclusive(x[i][0],y[i][0],x[i][3],y[i][3],x[i][2],y[i][2],x[j][k],y[j][k]))ok=true;
						if(inclusive(x[j][0],y[j][0],x[j][1],y[j][1],x[j][2],y[j][2],x[i][k],y[i][k]))ok=true;
						if(inclusive(x[j][0],y[j][0],x[j][3],y[j][3],x[j][2],y[j][2],x[i][k],y[i][k]))ok=true;
					}
					for(int k=0;k<4;k++){
						for(int l=0;l<4;l++)if(intersect(x[i][k],y[i][k],x[i][(k+1)%4],y[i][(k+1)%4],x[j][l],y[j][l],x[j][(l+1)%4],y[j][(l+1)%4]))ok=true;
					}
					if(ok)UNION(i,j);
				}
			}
			int ret=0;
			for(int i=0;i<b;i++)if(UF[i]<0)ret++;
			printf("%d\n",ret);
		}
	}
}

Measured memory_bytes: 1032
#include <stdio.h>

double pow(double a, int b)
{
    int i;
    double result = 1;
    for(i = 0; i < b; i++)
    {
        result *= a;
    }
    return result;
}

double ganri1(double money, int year, double rate)
{
    return money * (1 + year * rate);
}
double ganri2(double money, int year, double rate)
{
    return money * pow(1 + rate, year);
}



int main(void)
{
    while(true)
    {
        int n, y, i;
        int maxGanriBank = 0;
        double maxGanri = -1.0;
        if(scanf("%d", &n) == EOF) break;
        if(scanf("%d", &y) == EOF) break;
        for(i = 0; i < n; i++)
        {
            int b, r, t;
            scanf("%d %d %d", &b, &r, &t);
            double ganri = 0;
            if(t == 1)
            {
                ganri = ganri1(10000, y, (double)r/100);
            } else if(t == 2)
            {
                ganri = ganri2(10000, y, (double)r/100);
                
            }
            if(maxGanri < ganri)
            {
                maxGanri = ganri;
                maxGanriBank = b;
            }
            
        }
        printf("%d\n", maxGanriBank);
    }
    return 0;
}

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

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

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

    int r, s, p;
    cin >> r >> s >> p;
    vector<int> point(128, 0);
    point['r'] = p;
    point['s'] = r;
    point['p'] = s;

    string t;
    cin >> t;

    vector<vector<ll> > dp(t.size() + 1, vector<ll>(3, 0));
    vector<bool> flag(100001, false);

    REP(i, n) REP(j, 3) {
        if (i - k >= 0 && flag[i - k] && t[i] == t[i - k])
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        else {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + point[t[i]]);
            flag[i] = true;
        }
    }

    ll ans = 0;
    REP(i, 3) ans = max(ans, dp[n][i]);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5840
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c = sc.nextInt();
        int k = sc.nextInt();
        int[][] range = new int[n][2];
        for (int i = 0; i < n; i++) {
            int val = sc.nextInt();
            range[i][0] = val;
            range[i][1] = val+k;
        }

        Arrays.sort(range, Comparator.comparingInt(r -> r[0]));
        int count = 0;
        int used = 0;
        while (used < n) {
            int right = range[used][1];
            int c1 = 1;
            used++;
            while (c1 < c && used < n && range[used][0] <= right) {
                used++;
                c1++;
            }
            count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 63460
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if((i%2==0&&j%2==0)||(i%2==1&&j%2==1))
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int l;
string s;
bool f1,f2;
int main()
{
    cin>>s;
    l=s.length();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='C') f1=true;
        if(s[i]=='F'&&f1) f2=true;
    }
    if(f2) cout<<"Yes";
    else cout<<"No";
    return 0;
}

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 info[7][7] = {
	{0, 300, 500, 600, 700, 1350, 1650},
	{6, 0, 350, 450, 600, 1150, 1500},
	{13, 7, 0, 250, 400, 1000, 1350},
	{18, 12, 5, 0, 250, 850, 1300},
	{23, 17, 10, 5, 0, 600, 1150},
	{43, 37, 30, 25, 20, 0, 500},
	{58, 52, 45, 40, 35, 15, 0}
};

int main() {
	int s, st, e, et;
	while (cin >> s, s) {
		int h, m;
		cin >> h >> m;
		st = h * 60 + m;
		cin >> e;
		cin >> h >> m;
		et = h * 60 + m;
		
		s--; e--;
		int ans = info[s][e];
		if (st >= 17*60 + 30 && st <= 19*60 + 30 || et >= 17*60 + 30 && et <= 19*60 + 30) {
			if (info[e][s] <= 40) ans = ans % 100 == 0 ? ans / 2 : (ans + 100) / 2 - (ans / 2 % 50);
		}
		
		cout << ans << endl;
	}
	return 0;
}

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

int main(){
  int n,d;
  int result=0,s;
  int x[n+10][d+10];
  cin >> n >> d;
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin >> x[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      s=0;
      for(int k=0;k<d;k++){
        s+= pow(x[i][k]-x[j][k],2);
      }
      //cout<<sqrt(s)<<endl;
      double d=sqrt(s);
      if(d==int(d))result++;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 aa, bb;
	cin >> aa >> bb;
	if(2 * bb >= aa)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << (aa - 2 * bb) << endl;
	}
	return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <climits>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

int main(){
  int W, H, N;
  cin >> W >> H >> N;
  vector<PII> d(N);
  VI a(N);

  REP(i, 0, N){
    cin >> d[i].fst >> d[i].snd >> a[i];
  }

  int w = 0, h = 0;

  REP(i, 0, N){
    if(a[i] == 1){
      w = max(w, d[i].fst);
    } else if(a[i] == 2){
      W = min(W, d[i].fst);
    } else if (a[i] == 3){
      h = max(h, d[i].snd);
    } else if(a[i] == 4){
      H = min(H, d[i].snd);
    }
  }

  int ans = (W - w) * (H - h);
  if(W-w <= 0 || H-h <= 0){
    ans = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using graph = vector<vector<ll>>;
pair<pair<ll,ll>,ll> p[100010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll k;
    string s;
    cin>>k>>s;
    if(k>=s.size()) cout<<s<<endl;
    else cout<<s.substr(0,k)<<"..."<<endl;
    return 0;
}



Measured memory_bytes: 3616
n,m=map(int,input().split())
s=[list(map(int,input().split()))[1:]for _ in range(m)]
*p,=map(int,input().split())
print(sum([all([sum([i>>(k-1)for k in s[j]])%2==p[j]for j in range(m)])for i in range(2**n)]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
    int a,b; cin >> a >> b;
    if(a > 9) {
        cout << -1;
    } else if(b > 9) {
        cout << -1;
    } else {
        cout << a*b;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int flg[1001]={0},a,b,n,s,f,flg1,i,j;
	scanf("%d %d %d",&a,&b,&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&s,&f);
		for(j=s;j<f;j++){
			flg[j]++;
		}
	}
	for(i=a;i<b;i++){
		flg[i]++;
	}
	flg1=0;
	for(i=0;i<=1000;i++){
		if(flg[i]>=2){
			flg1=1;
		}
	}
	if(flg1==0){
		printf("0\n");
	}
	else{
		printf("1\n");
	}
	return 0;
}


Measured memory_bytes: 2608
#include <stdio.h>

int main(void) {
    for(;;) {
        int W, H;
        scanf("%d %d", &W, &H);
        if (W == 0 && H == 0) {
            return 0;
        } else {
            for (int i = 0; i < W; i++) {
                for (int j = 0; j < H; j++) {
                    printf("#");
                }
                printf("\n");
            }
        }
        printf("\n");
    }
}


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

int main() {
    int N,X,T;
    cin>>N>>X>>T;
    if(N%X==0)cout<<N/X*T<<endl;
    else cout<<((N/X)+1)*T<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI acos(-1) 
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define eb(a) emplace_back(a)
#define print(x) for(auto it:x) cout<<it<<' '; cout<<"\n";
#define int long long
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

ll fpower(ll x,ll y)
{
	if(!y)
		return 1;
	return (y&1) ? x*fpower(x*x%mod,y/2)%mod : fpower(x*x%mod,y/2)%mod ;
}

int findProductSum(vector <ll> A, ll n) 
{ 
    int array_sum = 0; 
    for (int i = 0; i < n; i++) 
        array_sum = (array_sum + A[i])%mod; 
    int array_sum_square = (array_sum * array_sum)%mod; 
    int individual_square_sum = 0; 
    for (int i = 0; i < n; i++) 
        individual_square_sum = (individual_square_sum + A[i]*A[i])%mod; 
    return ((array_sum_square - individual_square_sum + mod)%mod)*(fpower(2,mod-2)%mod)%mod; 
} 
main()
{
	FAST_IO ;
	ll i,j,k,n;
	cin >> n;
	vector <ll> arr(n);
	for(i=0;i<n;++i)
		cin >> arr[i] ;
	cout << findProductSum(arr,n) endl ;
	return 0;
}
 
/*
If u haven't come up with an approach yet ,skip this one
  Try this when feeling stuck -
  1. Int overflow, array bounds
  2. Special cases (n=1?)
  3. Prove your approach to yourself(mathematical induction,counter-intuitive or stronger test cases)
  4. Calm down and don't look at standings and stop thinking about rating and think about the question
  5. Just do it! 
*/ 

//Benq's advice - 
/* 
	And following advices are must for me -
	* do something instead of nothing and stay organized
	* WRITE STUFF DOWN 
*/

//#define _GLIBCXX_DEBUG 
// It will convert WA verdict to runtime error if that error is caused due to out of bound excess , declare it at the top
//#pragma GCC optimize "trapv" 
// It will convert WA to runtime error if WA was caused due to int overflow error,declare it anywhere

Measured memory_bytes: 6364
import java.util.*;
// warm-up
public class Main {

	static int[] a = null;

	static int sum () {
		int s = 0;
		for (int b : a) s+=b;
		return s;
	}

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(), i=1, j=1;
		a = new int[n+1];
		while (n-->0) a[i++] = sc.nextInt();
		int m = sc.nextInt(), s = sum();
		while (m-->0) {
			int k = sc.nextInt(), t = sc.nextInt();
			s-=a[k];
			System.out.println(s+t); 
			s+=a[k];
			j++;
		}
		sc.close();			
	}

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

}

Measured memory_bytes: 36476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007ll
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p(m);
  REP(i, m) {
    int k;
    cin >> k;
    REP(j, k) {
      int tmp_s;

      cin >> tmp_s;
      tmp_s--;
      s.at(i).push_back(tmp_s);
    }
  }
  REP(i, m) { cin >> p.at(i); }

  for (int bit = 0; bit < (1 << n); bit++) {
    bool f = true;
    REP(i, m) {
      int cnt = 0;
      for (auto sw : s.at(i)) {
        if (bit & (1 << sw)) cnt++;
      }
      if (cnt % 2 != p.at(i)) f = false;
    }
    if (f) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256