akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1000000007, INF = 1e9;

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,K = map(int,input().split())
A = [int(i) for i in input().split()]

# dp[i]: 石の個数が残りi個の局面での勝敗
dp = [False] * (K+1)

# 初期条件
dp[0] = False

for i in range(K+1):
    for a in A:
        if i+a > K:
            continue
        dp[i+a] |= not dp[i]

if dp[-1]:
    print("First")
else:
    print("Second")

Measured memory_bytes: 41836
#include<stdio.h>
int main(){
    int month=1,date=1;
    int nums=0;
    int det;
    while(month!=0&&date!=0){
    scanf("%d%d",&month,&date);
    switch(month){
        case 1: nums+=0;
                break;
        case 2: nums+=31;
                break;
        case 3: nums+=29+31;
                break;
        case 4: nums+=31+29+31;
                break;
        case 5: nums+=30+31+29+31;
                break;
        case 6: nums+=31+30+31+29+31;
                break;
        case 7: nums+=30+31+30+31+29+31;
                break;
        case 8: nums+=31+30+31+30+31+29+31;
                break;
        case 9: nums+=31+31+30+31+30+31+29+31;
                break;
        case 10: nums+=30+31+31+30+31+30+31+29+31;
                 break;
        case 11: nums+=31+30+31+31+30+31+30+31+29+31;
                 break;
        case 12: nums+=30+31+30+31+31+30+31+30+31+29+31;
                 break;

    }
    nums+=date;
    det=(nums-1)%7;
    switch(det){
    case 0: printf("Thursday\n");break;
    case 1: printf("Friday\n");break;
    case 2: printf("Saturday\n");break;
    case 3: printf("Sunday\n");break;
    case 4: printf("Monday\n");break;
    case 5: printf("Tuesday\n");break;
    case 6: printf("Wednesday\n");break;
    }
    nums=0;
    }
return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	long long A=0,B=0,N=0;
	cin>>A>>B>>N;
	long long x,f;
	x=min(N,B-1);
	f=floor(A*x/B)-A*floor(x/B);
	cout<<f;
	return 0;
}

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

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    
    int N; cin >> N;
    int ans = N;
    string S; cin >> S;
    char tc = 'A';
    rep(i, N) {
        if (S[i] == tc) {
            ans -= 1;
        } else {
            tc = S[i];
        }
    }

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

Measured memory_bytes: 512
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

x = Counter(a)
ans = sum(a)
for b, c in bc:
    ans += (c - b) * x[b]
    print(ans)
    x[c] += x[b]
    x[b] = 0


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  long long D;
  scanf("%lld", &D);

  cout << ceil(double(N) / (2.0 * D + 1.0)) << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 256
#include<cstdio>
int main(void)
{
    int n,sum=0,mi=1e9,p;
    scanf("%d" ,&n);
    while(n--){
        scanf("%d" ,&p);
        if(p<mi)
        {
            mi=p;
            sum++;
        }
    }
    printf("%d" ,sum);
    return 0;
}

Measured memory_bytes: 128
ans = "Yes"

lst_A = list(input())

lst_A.sort()

if len(lst_A) % 2 == 1:
    ans = "No"

else:
    for i in range(0,len(lst_A)-1,2):
        if lst_A[i] != lst_A[i+1]:
            ans = "No"

print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second 
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int n;
ll k,a[202020],s[202020];
queue<ll> q1,q2;
ll dfs(int l,int r){
	if(r-l==1)return 0;
	int mid=(l+r)/2;
	ll ret=dfs(l,mid)+dfs(mid,r);
	fo(i,l,mid)q1.push(s[i]);
	fo(i,mid,r)q2.push(s[i]);
	int j=l;
	while(!q1.empty()&&!q2.empty()){
		if(q1.front()>q2.front()){
			ret+=mid-l-q1.size();
			s[j++]=q2.front();
			q2.pop();
		}else{
			s[j++]=q1.front();
			q1.pop();
		}
	}
	while(!q1.empty()){
		s[j++]=q1.front();
		q1.pop();
	}
	while(!q2.empty()){
		ret+=mid-l;
		s[j++]=q2.front();
		q2.pop();
	}
	return ret;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>k;
	fo(i,0,n)cin>>a[i];
	s[0]=0;
	fo(i,0,n)s[i+1]=s[i]+a[i]-k;
	cout<<dfs(0,n+1)<<endl; 
	return 0;
}

Measured memory_bytes: 5088
#include <iostream>
#include <iomanip>

using namespace std;

int N;
int a, b, c;
double ***DP;

double calcP(int i, int j, int k) {
	if (i == 0 && j == 0 && k == 0) return 0.0;
	else if (i < 0 || j < 0 || k < 0) return 0.0;
	else if (DP[i][j][k] >= 0.0) return DP[i][j][k];
	else {

		DP[i][j][k] = i * calcP(i - 1, j, k)
			+ j * calcP(i + 1, j - 1, k)
			+ k * calcP(i, j + 1, k - 1) + N;

		DP[i][j][k] /= i + j + k;

		return DP[i][j][k];
	}
}

int main() {
	int i, j, k;


	cin >> N;

	int *dish = new int[N];

	for (i = 0; i < N; i++)
		cin >> dish[i];


	a = b = c = 0;
	for (i = 0; i < N; i++) {
		switch (dish[i]) {
		case 1:
			a++;
			break;
		case 2:
			b++;
			break;
		case 3:
			c++;
			break;
		}
	}

	DP = new double**[a + b + c + 1];
	for (i = 0; i <= a + b + c; i++) {
		DP[i] = new double*[b + c + 1];
		for (j = 0; j <= b + c; j++)
			DP[i][j] = new double[c + 1];
	}

	//初期化
	for (i = 0; i <= a + b + c; i++) {
		for (j = 0; j <= b + c; j++) {
			for (k = 0; k <= c; k++)
				DP[i][j][k] = -1.0;
		}
	}

	cout << setprecision(16) << calcP(a, b, c) << endl;

	for (i = 0; i <= a + b + c; i++) {
		for (j = 0; j <= b + c; j++)
			delete[] DP[i][j];
		delete[] DP[i];
	}
	delete[] DP;
	delete[] dish;

	return 0;
}

Measured memory_bytes: 214784
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << max({A, B, C}) * 9 + A + B + C << endl;
}


Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
  a = input()[0]
  if a in ["M","A","R","C","H"]:
    s.append(a)
ans = 0    
import itertools
for i,j,k in itertools.combinations(["M","A","R","C","H"], 3):
  ans += s.count(i) * s.count(j) * s.count(k)
print(ans)

Measured memory_bytes: 3864
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        String ans = "No";
        for (int i = 0; i <= x; i++) {
            for (int j = 0; j <= (x - i); j++) {
                if (((i + j) == x) && (((2 * i) + (4 * j)) == y)) {
                    ans = "Yes";
                    break;
                }

            }
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 35592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;cin >> n;
  vector<string> S(n);
  string ans="Yes";
  cin >> S[0];
  for (int i=1;i<n;i++) {
    cin >> S[i];
    string S2=S[i-1];
	if (S[i][0]!=S[i-1][S2.size()-1]) ans="No";
  }
  sort(S.begin(),S.end());
  for (int i=1;i<n;i++) {
    if (S[i]==S[i-1]) ans="No";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        sum += i;
    }
    cout << sum << '\n';
}


Measured memory_bytes: 3628
#include <iostream>

int main() {
  int k, s;
  std::cin >> k >> s;

  int ans = 0;
  for (int x=0; x<=k && x<=s; x++) {
    for (int y=0; y<=k && x+y<=s; y++) {
      if (x+y+k >= s) ans++;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,a,b,ans;
long long pow(long long a,long long n){	
	long long res=1ll;
	while(n){		
		if (n&1){
			res=res*a%mod;		
		}        
		a=a*a%mod;		
		n>>=1;	
	}	
	return res%mod;
}
long long c(long long n,long long m){	
	if(n<m){
		return 0;	
	}  
	if(n==m||!m){
		return 1;	
	}	
	if(m<n-m){
		m=n-m;
	}	
	long long a=1;	
	for(long long i=m+1;i<=n;++i){
		a=a*i%mod;
	}
	long long b=1;	
	for(long long i=1;i<=n-m;++i){
		b=b*i%mod;	
	}
	return a*pow(b,mod-2)%mod;
}
int main(){	
	long long n,a,b;	
	cin>>n>>a>>b;	
	ans=((pow(2ll,n)-c(n,a)-c(n,b)-1)%mod+mod)%mod;	
	cout<<ans;    
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void call(int n) {
	int i = 1;
	for (; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			cout << " " << i;
		}
		else {
			for (; x; x /= 10) {
				if (x % 10 ==3) {
					cout << " " << i;
					break;
				}
			}
		}
	}
	cout << endl;
} 
int main() {
	int a;
	cin >> a;
	call(a);
	return 0;
}


Measured memory_bytes: 3108
function Main(input){
	input = ~~input;
  
  var cc = 0;
 	
  for(var i = 1; i <= input ; i += 2){
  	var count = 0;
  	for(var j = 1; j <= i ; j++){
    	if(i % j == 0)count++;
    }
    if(count == 8)cc++;
  }
  
  return cc;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
200
`);

Measured memory_bytes: 11468
#include<iostream>
using namespace std;
int main() {
	int n,ans=0; cin >> n;
	int p[25];
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n-2; i++) {
			if (p[i]<p[i+1]&&p[i+1]<p[i+2])ans++;
			else if (p[i + 2] < p[i + 1] && p[i + 1] < p[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math
def main():
    N = int(input())
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())
    cost = [A, B, C, D, E]

    f = lambda x : int((N//x))
    t = [f(A), f(B), f(C), f(D), f(E)]

    idx = 0
    ma = 0

    for i in range(len(t)):
        if t[i] > ma:
            ma = t[i]
            idx = i
    ma += idx

    ans = ma + (5 - idx)

    if N % cost[idx] == 0:
        ans -= 1

    print(ans)

if __name__ == "__main__":
    main()

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int c = a % 2;
  int d = b % 2;
  int e = c + d;

  if (e == 0 || e == 1) {
    cout << "Even" << endl;
  }
  
  else {
  cout << "Odd" << endl;
  }
}


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

vector<int> divisor(int n) {
  vector<int> ret;
  for(int i = 1; i*i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i*i != n) ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return move(ret);
}

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

    vector<int> cnt(n, 0);
    vector<int> ans;

    for(int i=n-1;i>=0;--i)
    {
        if(cnt[i]%2!=a[i])
        {
            ans.push_back(i+1);
            auto v = divisor(i+1);
            for(auto m:v)
                cnt[m-1]++;
        }
    }
    
    cout << ans.size() << endl;
    for(auto i:ans) cout << i << " ";
    cout << endl;

    return 0;
}

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

using namespace std;

using ll =  long long;

int comb(int n, int k) {
    // Lucas の定理を使って comb(n, k) % 2 を求める
    while(n) {
        if(!(n & 1) and (k & 1)) return 0;
        n >>= 1;
        k >>= 1;
    }
    return 1;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    string s;
    cin >> s;
    bool exists[3] = {false, false, false};
    for(int i=0;i<n;++i) {
        a[i] = int(s[i]-'0') - 1;
        exists[a[i]] = true;
    }

    if(exists[2]) {
        if(exists[1]) {
            for(int i=0;i<n;++i) if(a[i] == 2) a[i] = 0;
        } else {
            for(int i=0;i<n;++i) if(a[i] == 2) a[i] = 1;
        }
    }

    int ans = 0;
    for(int i=0;i<n;++i) {
        ans += a[i] * comb(n-1, i);
        ans %= 2;
    }

    if(exists[2] && !exists[1]) {
        ans *= 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 5788
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int l, r, d; cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    ll n;
    std::cin >> n;
    for (int i = 0; i <= 50000; i++) {
        if(floor(i*1.08) == n){
            std::cout << i << std::endl;
            return 0;
        }
    }
    std::cout << ":(" << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a, ll b)
{
    if(b==0) return a;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
    ll gc = gcd(a,b);
    ll ret;
    if(a%gc==0){
        ret = (a/gc)*b;
    }
    else{
        ret = (b/gc)*a;
    }
    return ret;
}
int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    for(int i=0; i<n; i++){
        cin>>arr[i];
    }
    sort(arr, arr+n);
    ll ans = arr[0];
    for(int i=1; i<n; i++){
        ans = lcm(ans, arr[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e15 + 42;
const ll N = (ll)1e6 + 2;
 

ll power ( ll x , unsigned ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % mod ;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res % mod ;
}
 
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
//    //ans[a] += ans[b];
//    //return true;
// }
//
//ll sev[275];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 275 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 275 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}

void solve()
{
    ll n , k;
    cin >> n >> k;
    ll arr[n + 1] , dp[n + 1];
    for(ll i = 1 ; i <= n ; i ++)
        cin >> arr[i];
    arr[0] = arr[1];
    mem(dp , 0);
    for(ll i = 2 ; i <= n ;i ++)
    {
        dp[i] = 1e15;
        for(ll j = 1 ; j <= k && i - j > 0 ; j ++)
            dp[i] = min(abs(dp[i - j] + abs(arr[i - j] - arr[i])) , dp[i]) ;
    }
    cout << dp[n] << '\n';
}
/*
 5 810688740
 7 948963500
 */

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
    
}
 


Measured memory_bytes: 1792
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s

main = do

   n <- readLn :: IO Int
   an <- (map bsreadInt) <$> replicateM n BC.getLine
   let bn = map length (group (sort an))
   let cn = filter (odd) bn
   print (length cn)


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

using namespace std;

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

typedef long long ll;

void solve(){
	int n, m;
	cin >> n >> m;
	int sum = 0;
	for(int i = 0; i < m; ++i) {
		int value;
		cin >> value;
		sum += value;
	}
	cout << max((n - sum), -1);
}

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

	solve();
    
    return 0;
}


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

int n, k;
bool d[MAXN], flag;

int main()
{
	cin >> n >> k;
	for(int i = 0; i < k; i++){
        int a;
        cin >> a;
        d[a] = true;
	}
	for(int i = n;; i++){
        int a = i;
        while(a){
            if(d[a % 10]){
                flag = true;
                break;
            }
            a /= 10;
        }
        if(!flag){
            cout << i << endl;
            return 0;
        }
        flag = false;
	}

	return 0;
}


Measured memory_bytes: 256
number = input()
l = list(input().split(" "))

loop_count = 0
count = 0
min_count = 0

for n in l:
    loop_count = loop_count + 1
    while int(n) % 2 == 0:
        n = int(n)/2
        count = count + 1
    if loop_count == 1:
        min_count = count
    elif min_count > count:
        min_count = count
    count = 0

print(min_count)

Measured memory_bytes: 3064
N = int(input())
h = list(map(int, input().split()))
ans = 0


def water(x):
  global ans
#  print(x, ans)
  if any(x) == False:
#    print(0)
    return
  else:
#    print(1)
    if 0 in x:
#      print(2)
      x1, x2 = x[0:x.index(0)], x[x.index(0)+1:]
      water(x1)
      water(x2)
    else:
#      print(3)
      ans += min(x)
      x = list(map(lambda i:i-min(x), x))
      water(x)
  return    
  
water(h)
print(ans)
  


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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++) cin >> d.at(i);
  long sum = 0;
  for(int i = 0; i < N; i++){
    int yumI = d.at(i);
    for(int j = 0; j < N; j++){
      if(i == j) continue;
      int yumJ = d.at(j);
      sum += yumI * yumJ;
    }
  }
  sum /= 2;
  cout << sum << endl;
}


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

#define ll long long
#define ld long double
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<

int main(){
  ll t, x;
  cin >> t >> x;
  ld t2, x2;
  t2 = double(t);
  x2 = double(x);
  ld result = t2 / x2;
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split(" ");
  var A = parseInt(input[0]);
  var B = parseInt(input[1]);
  var result;

  if(13<=A && A<=100) {
    result = B;
  } else if (6<=A && A<=12){
    result = B/2;           
  } else if (0<=A && A<=5) {
    result = 0;
  }
	
  console.log(result);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 9420
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int b_search(ll v[], int n, ll x){
	if(x<=v[0]) return -1;
	if(x>=v[n-1]) return n-1;

	ll l=0, r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(v[m]<x) l=m;
		else r=m;
	}
	return l;
}

int main(){
	int a, b, q;
	cin >> a >> b >> q;
	ll s[a], t[b];
	for(int i=0; i<a; i++) cin >> s[i];
	for(int i=0; i<b; i++) cin >> t[i];

	for(int i=0; i<q; i++){
		ll x;
		cin >> x;
		ll ans=(ll)(1e11);
		int m[2], n[2];
		
		m[0]=b_search(s, a, x);
		if(m[0]==-1){
			m[0]=0; m[1]=0;
		}else if(m[0]==a-1){
			m[0]=a-1; m[1]=a-1;
		}else m[1]=m[0]+1;
		for(int j=0; j<2; j++){
			ll dist=abs(x-s[m[j]]);
			n[0]=b_search(t, b, s[m[j]]);
			if(n[0]==-1){
				n[0]=0; n[1]=0;
			}else if(n[0]==b-1){
				n[0]=b-1; n[1]=b-1;
			}else n[1]=n[0]+1;
			dist+=min(abs(s[m[j]]-t[n[0]]), abs(s[m[j]]-t[n[1]]));
			ans=min(ans, dist);
		}

		m[0]=b_search(t, b, x);
		if(m[0]==-1){
			m[0]=0; m[1]=0;
		}else if(m[0]==b-1){
			m[0]=b-1; m[1]=b-1;
		}else m[1]=m[0]+1;
		for(int j=0; j<2; j++){
			ll dist=abs(x-t[m[j]]);
			n[0]=b_search(s, a, t[m[j]]);
			if(n[0]==-1){
				n[0]=0; n[1]=0;
			}else if(n[0]==a-1){
				n[0]=a-1; n[1]=a-1;
			}else n[1]=n[0]+1;
			dist+=min(abs(t[m[j]]-s[n[0]]), abs(t[m[j]]-s[n[1]]));
			ans=min(ans, dist);
		}

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

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        ll a[n],dp[n];
        loop(i,0,n-1) cin>>a[i];
        ms(dp,0);
        dp[1]=abs(a[1]-a[0]);
        loop(i,2,n-1)
        {
            dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
        }
        cout<<dp[n-1];
    }
    return 0;
}


Measured memory_bytes: 5084
#include<stdio.h>
int i,b[11],x;
void dfs(int i,int left,int right)
{
	if(i==10)
	{
		x=1;
		return;
	}
	if(x)
	{
		return;
	} 
	if(b[i]>left)
	{	
		dfs(i+1,b[i],right);
	}
	if(b[i]>right)
	{
		dfs(i+1,left,b[i]);
	}
}
int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		while(a--)
		{
			x=0;
			for(i=0;i<10;i++)
			{
				scanf("%d",&b[i]);
			}
			dfs(0,0,0);
			if(x==1)
			{
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
	}
	return 0;	
} 



Measured memory_bytes: 2576
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs(string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout << lcs << endl; 
} 

/* Driver program to test above function */
int main() 
{
string X, Y; cin >> X >> Y;
int m = X.length();
int n = Y.length();
lcs(X, Y, m, n); 
return 0; 
} 


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

int main() {
	int a,b;
	cin>>a>>b;
	if(a>12)
	cout<<b;
	else if(a==5)
	cout<<0;
	else if(a>=6&&a<=12)
	cout<<b/2;
	else if(a==0)
	cout<<0;
	else
	cout<<b;
	return 0;
}

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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
  return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
  return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

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

  var(int, N, M); vector<int> x(M); rep(i, M) input(x[i]); if (N >= M) { outl(0); return 0; } sort(all(x)); priority_queue<int> que; reps(i, 1, M - 1) { que.emplace(x[i] - x[i-1]); } N--; while (N--) { que.pop(); } i64 res = 0; while (que.size()) { res += que.top(); que.pop(); } outl(res); return 0; }


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int X, A, B; cin >> X >> A >> B;
    X -= A;
    int cnt = X / B;
    X -= B * cnt;
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 3636
a,b= map(int,input().split())

def make_divisors(n):
	divisors = set()
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			divisors.add(i)
			if i != n // i:
				divisors.add(n//i)
	return divisors
	
A = make_divisors(a)
B = make_divisors(b)
S = A & B
#Sから素数だけを抽出してカウント
import math

def is_prime(n):
	if n == 1: return False
	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False
	return True
cnt = 1
for i in S:
	if is_prime(i) == True:
		cnt += 1

print(cnt)

Measured memory_bytes: 5120
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i=0;i<N;i++) A[i]=sc.nextInt();
		sc.close();
		
		
		SegTree st = new SegTree(N);
		for(int i=0;i<N;i++) st.update(i, A[i]);
		int ans = 0;
		for(int i=0;i<N;i++) {
			int tmp = st.dat[(st.dat.length+1)/2 - 1 + i];
			st.update(i,0);
			ans = Math.max(ans,st.dat[0]);
			st.update(i, tmp);
		}
		System.out.println(ans);
		
	}
}

class SegTree{
	int n;
	int dat[];
	SegTree(int x){
		n = 1;
		while(n<=x) {
			n*=2;
		}
		dat = new int[2*n-1];
	}
	
	void update(int x, int u) {
		x += n-1;
		dat[x] = u; 
		while(x>0) {
			x = (x-1)/2;
			dat[x] = gcd(dat[2*x+1], dat[2*x+2]);
		}
	}
	
	int queryGcd(int x, int y, int k, int l, int r) {
		if(x<r||y<l)return 0;
		else if(x<=l&&y<=r)return dat[k];
		else {
			int lres = queryGcd(x, y, 2*k+1, l, (l+r)/2);
			int rres = queryGcd(x, y, 2*k+1, (l+r)/2, r);
			return gcd(lres, rres);
		}
	}
	
	int gcd(int x,int y) {
		return y==0? x : gcd(y, x%y);
	}
}

Measured memory_bytes: 50072
#include <iostream>
using namespace std;
int main()
{
   int a,b,c;
   cin >> a >> b >> c;
   if(a==b && b==c)
    cout<<"No";
    if(a!=b && b!=c && c!=a)
        cout <<"No";
   if(a==b && a!=c)
    cout<<"Yes";
    if(b==c && c!=a)
    cout<<"Yes";
    if(a==c && a!=b)
    cout<<"Yes";
   return 0;
}

Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,t,p,k;
    cin>>a>>b>>c>>p;
    int ans=0;
    for(i=0;i<a+1;i++){
        for(j=0;j<b+1;j++){
            for(k=0;k<c+1;k++){
                if(p==i*500+j*100+k*50)
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> S;

    A = 0;

    rep(i,4)
    {
        if(S[i] == '+') A++;
        else A--;
    }
    cout<< A;
    
    return 0;
}

Measured memory_bytes: 256
main() {
  int x, y;scanf("%d %d",&x, &y);
  if((y-2*x)<0 || (-y+4*x)<0 || (y-2*x)%2 || (-y+4*x)%2){
    printf("No\n");
    return 0;
  }
  printf("Yes\n");
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
void print(vector<T> vec)
{
    int n = vec.size();
    for (int i = 0; i < n; i++)
    {
        cout << vec[i] << (i == n - 1 ? "\n" : " ");
    }
}

list<int> ls;
int n, a;
string s;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        if (s == "insert")
        {
            cin >> a;
            ls.insert(ls.begin(), a);
        }
        else if (s == "delete")
        {
            cin >> a;
            for (auto itr = ls.begin(); itr != ls.end(); itr++)
            {
                if (*itr == a)
                {
                    ls.erase(itr);
                    break;
                }
            }
        }
        else if (s == "deleteFirst")
        {
            ls.pop_front();
        }
        else
        {
            ls.pop_back();
        }
    }
    vector<int> v;
    while (!ls.empty())
    {
        int a = ls.front();
        ls.pop_front();
        v.push_back(a);
    }
    print(v);
}


Measured memory_bytes: 34352
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
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 Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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 Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  while(true){
    ll n,r;cin>>n>>r;
    if(n==0 && r==0) break;
    vector<vector<ll>> v(r+1);
    rep(i,n) v[0].push_back(n-i);
    rep(i,r){
      ll p,c;cin>>p>>c;p--;
      rep(j,c){
        v[i+1].push_back(v[i][p+j]);
      }
      rep(j,n){
        if(p<=j && j<p+c) continue;
        v[i+1].push_back(v[i][j]);
      }
    }
    cout<<v[r][0]<<endl;
  }
}


Measured memory_bytes: 3056
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

LL N;
vector<LL>A;
vector<LL>bits[29];

int main(void)
{
	cin >> N;
	LL xum = 0;
	for (int i = 0; i < N; ++i) {
		LL a;
		cin >> a;
		A.push_back(a);
		xum ^= a;
		for (int b = 0; b < 29; ++b) {
			bits[b].push_back(a & ((1 << b) - 1));
		}
	}
	for (int b = 0; b < 29; ++b) {
		sort(bits[b].begin(), bits[b].end());
	}
	LL ans = 0;
	for (int i = 0; i < N; ++i) {
		LL X;
		cin >> X;
		LL tot = 0;
		for (int b = 0; b < 29; ++b) {
			LL val = X & ((1 << b) - 1);
			val = (1 << b) - val;
			LL can = lower_bound(bits[b].begin(), bits[b].end(), val) - bits[b].begin();
			if (((X / (1 << b))) % 2) {
				//[0,val)までの個数
			}
			else {
				//[val,2のb乗)までの個数
				can = (LL)bits[b].size() - can;
			}
			can %= 2;
			if (can) {
				tot ^= (1 << b);
			}
		}
		ans ^= tot;
		ans ^= xum;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 52736
h, w = map(int, input().split())

s = []
for i in range (h):
	s.append(list(input()))

for i in range (h):

	for n in range (w):

		if (s[i][n] == "#"):

			r = "#"

		else:

			cnt = 0
			r = 0

			for a in ([-1, 1]):
				if(i + a < 0) or (i + a > h - 1):
					continue
				for t in ([-1, 0, 1]):
					if ((n + t) < 0) or ((n + t) > (w - 1)):
						continue
					if (s[i + a][n + t] == "#"):
						cnt += 1
			for t in ([-1, 1]):
				if ((n + t) < 0) or ((n + t) > (w - 1)):
					continue
				if (s[i][n + t] == "#"):
					cnt += 1

			r = cnt

		print (r, end="")

	print ("")



Measured memory_bytes: 3444
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

vector <int> ro[101],dis;
queue <int> Q;
int n,s,d,v;
int r,kk;

void reset() {
  dis.resize(n);
  for(int i=0;i<n;i++) 
    dis[i] = 100000000;
}


int bfs() {
  Q.push(s);
  dis[s] = 1;
  int t,a;
  while(!Q.empty()) {
    t = Q.front();
    Q.pop();
   
    for(int i=0;i<ro[t].size();i++) {
      a = ro[t][i];
      if(dis[a] > dis[t]+1 ){
	dis[a] = dis[t]+1;
	if(dis[t]+1 < v && a != d) Q.push(a);
      }
    }
  }
  return dis[d];
}

int main() {
  
  cin >> n;
  int a;
  for(int i=0;i<n;i++) {
    cin >> r >> kk;
    ro[r-1].resize(kk);
    for(int j=0;j<kk;j++) {
      cin >> a;
      ro[r-1][j] = a - 1;
    }
  }
  
  int p;
  int ans;
  cin >> p;
  for(int i=0;i<p;i++) {
    cin >> s >> d >> v;
    s--;
    d--;
    reset();
    ans = bfs();
    if(ans <= v) cout << ans << endl;
    else cout <<"NA" << endl;
    
  }
  
  return 0;
  

}

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

typedef long long ll;

int main() {
    int n;
    cin >> n;
    ll a[100100];
    for (int i = 0; i < n; i++) { cin >> a[i]; }


    // 初項が正の場合
    ll x = 0, sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i % 2 == 0 && sum < 1) {
            x += 1 - sum;
            sum = 1;
        } else if (i % 2 == 1 && sum > -1) {
            x += 1 + sum;
            sum = -1;
        }
    }

    // 初項が負の場合
    ll y = 0;
    ll sum2 = 0;
    for (int i = 0; i < n; i++) {
        sum2 += a[i];
        if (i % 2 == 0 && sum2 > -1) {
            y += 1 + sum2;
            sum2 = -1;
        } else if (i % 2 == 1 && sum2 < 1) {
            y += 1 - sum2;
            sum2 = 1;
        }
    }

    cout << min(x, y) << endl;
}

Measured memory_bytes: 1024