akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


//ntt
ll mod = 998244353;
ll root = 3;
ll wlist[30];

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

vector<ll>dft(vector<ll>A,int N){
	//bit reverse
	int h = 0;
	for (int i = 0; (1 << i) < N; i++)h++;
	for (int i = 0; i < N; i++) {
		int j = 0;
		for (int k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
		if (i < j) swap(A[i], A[j]);
	}
	//

	//butterfly 
	int cnt = 1;
	for (int b = 1; b < N; b *= 2) {
		ll w = wlist[cnt];
		ll cur = 1;
		ll mul = modpow(w, b);
		for (int j = 0; j < b; j++) {
			for (int k = 0; k < N; k += 2 * b) {
				ll p = cur;
				ll q = (cur*mul) % mod;
				ll pre1 = A[j + k];
				ll pre2 = A[j + k + b];
				A[j + k] = (pre1 + p * pre2)%mod;
				A[j+k+b] = (pre1 + q * pre2)%mod;
			}
			cur = (w * cur)%mod;
		}
		cnt++;
	}
	//

	return A;
}
vector<ll>inv_dft(vector<ll>A,int N) {
	vector<ll>arranged = dft(A, N);
	vector<ll>swapped(N);
	for (int i = 0; i < N; i++)swapped[i] = arranged[(N - i) % N];
	vector<ll>ret(N);
	ll rev = modpow(N,mod-2);
	for (int i = 0; i < N; i++)ret[i] = (rev*swapped[i]) % mod;
	return ret;
}

vector<ll>ntt(vector<ll>A,vector<ll>B){
	//calculate Nth root
	ll P = mod;
	P--;
	int N = 1;
	int cnt = 0;
	while (P % 2 == 0) {
		N *= 2;
		cnt++;
		P /= 2;
		if (A.size() + B.size() <= N)break;
	}
	ll Nroot = modpow(root,P);
	//

	//make list of root
	ll cur = Nroot;
	for (int i = cnt; i >= 0; i--) {
		wlist[i] = cur;
		cur = (cur*cur) % mod;
	}
	//

	A.resize(N);
	B.resize(N);

	A = dft(A,N);
	B = dft(B,N);

	vector<ll>F(N);
	for (int i = 0; i < N; i++) {
		F[i] = (A[i] * B[i]) % mod;
	}
	return inv_dft(F,N);
}
//nttここまで

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

	int N, M;
	cin >> N >> M;
	vector<ll>A(N), B(M);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < M; i++)cin >> B[i];

	vector<ll>ans = ntt(A, B);
	for (int i = 0; i < N + M - 1; i++)cout << ans[i] << " ";
	puts("");


	return 0;
}

Measured memory_bytes: 68872
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func main() {
	defer write.Flush()

	var n, k int64
	fmt.Fscan(read, &n, &k)

	fmt.Fprintln(write, int64(math.Min(float64(n%k), float64(k-n%k))))
}


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

int main(){
    long long n, k;
    cin >> n >> k;

    map<long long, long long> mp;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }

    long long cnt = 0;
    for(auto x : mp){
        cnt += x.second;
        if(cnt >= k){
            cout << x.first << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>

#define N 2000000
#define INF 2000000000

void maxHeapify(int *, int);
int heapExtractMax(int *);
void maxHeapInsert(int *, int);
void heapIncreaseKey(int *, int, int);

int h = 0;

int main() {
  int  i, key, data[N];
  char s[8];

while(1) {
    scanf("%s", s);

    if (s[0] == 'i') {
        scanf("%d", &key);
        maxHeapInsert(data, key);
    }
    else if (s[0] == 'e' && s[1] == 'x') {
     printf("%d\n", heapExtractMax(data));
    }
    else if (s[0] == 'e' && s[1] == 'n') {
      break;
    }
  }
  return 0;
}


void maxHeapify(int *d, int i) {
  int l, r, largest, temp;
  
  l = i * 2;
  r = i * 2 + 1;

  if (l <= h && d[l] > d[i]) largest = l;
  else largest = i;

  if (r <= h && d[r] > d[largest]) largest = r;

  if (largest != i) {
    temp = d[i];
    d[i] = d[largest];
    d[largest] = temp;
    maxHeapify(d, largest);
  }
}

int heapExtractMax(int *d) {
    int max;
    if (h < 1) return -INF;
    max = d[1];
    d[1] = d[h];
    h--;
    maxHeapify(d, 1);
    return max;
}


void maxHeapInsert(int *d, int key) {
    h++;
    d[h] = -INF;
    heapIncreaseKey(d, key, h);
}


void heapIncreaseKey(int *d, int key, int i) {
    int temp;
    if (key < d[i]) return;
    d[i] = key;
    while(i > 1 && d[i / 2] < d[i]) {
        temp = d[i];
        d[i] = d[i / 2];
        d[i / 2] = temp;
        i = i / 2;
    }
}


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

using namespace std;
using ll = long long;
using pint = pair<int, int>;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		ll a;
		cin >> a;
		while (a % 2 == 0) {
			ans++;
			a /= 2;
		}
	}

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


Measured memory_bytes: 3632
def pos(x,n,M):
    if n==0:
        return 1
    res = pos(x*x%M, n /2, M)
    if n%2 ==1:
        res = res * x%M
    return res
 
m,n = map(int,raw_input().split())
 
print pos(m,n,1000000007)

Measured memory_bytes: 4208
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c && c<=b){
		swap(b,c);
	}
	else if(b<=a && a<=c){
		swap(a,b);
	}
	else if(b<=c && c<=a){
		swap(a,c);
		swap(a,b);
	}
	else if(c<=b && b<=a){
		swap(a,c);
	}
	else if(c<=a && a<=b){
		swap(c,b);
		swap(a,b);
	}
		cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}


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

int main(int argc, char const *argv[]) {
    int A, B;
    vector<int> num(3);
    cin >> A >> B;

    num.at(0) = A+B;
    num.at(1) = A-B;
    num.at(2) = A*B;

    sort(num.begin(), num.end());
    cout << num.at(2) << endl;
    
    return 0;
}


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

const int N = 1e5 + 100;
int a[N], n, m, v, p;
bool check(int x) {
	if (x <= p) return 1;
	if (a[x] + m < a[p]) return 0;
	long long cnt = 0;
    for (int i = n; i >= p; i--) {
        if (i == x) continue;
        cnt += min(m, a[x] + m - a[i]);
    }
	if (1ll * (p-1) * m + cnt + m >= 1ll * v * m) return 1;
	return 0;
}
int main() {
	ios::sync_with_stdio(0);
	cin >> n >> m >> v >> p;//swap(m,v);
	for (int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);
	int l = 1, r = n;
   // for (int i = 1; i <= n; i++) cout << a[i] << " ";cout << endl;
	while (l < r) {
		int mid = (l + r + 1) >> 1;
        //cout << l << " " << r << endl;
		if (check(mid)) l = mid;
		else r = mid - 1;;
	}
	cout << l << endl;
}

Measured memory_bytes: 768
S = input()
N = (len(S)-1)//2
M = (len(S)+3)//2
count = 0

if S[::-1] == S:
  if S[:N] == S[:N][::-1]:
    if S[(M-1):] == S[(M-1):][::-1]:
      count += 1
print("Yes" if count == 1 else "No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[N],f[N],g[N]; ll s[N];
int main()
{	int n; cin>>n; for(rint i=1;i<=n;i++) scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	f[1]=1; g[n]=n-1; ll ans=1e18;
	for(rint i=2;i<=n;i++)
	{	f[i]=f[i-1];
	//	debug(s[f[i]+1]-(s[i]-s[f[i]+1]));
		while(f[i]<i-1&&abs(s[f[i]+1]-(s[i]-s[f[i]+1]))<abs(s[f[i]]-(s[i]-s[f[i]]))) f[i]++;
	//	debug(f[i]);
	}
	for(rint i=n-1;i>=1;i--)
	{	g[i]=g[i+1];
	//	debug(s[n]-s[g[i]-1]);debug(s[g[i]-1]-s[i-1]);debug(s[n]-s[g[i]]);debug(s[g[i]]-s[i-1]);
	//	debug(abs(s[n]-s[g[i]-1]-(s[g[i]-1]-s[i-1])));debug(abs(s[n]-s[g[i]]-(s[g[i]]-s[i-1])));debug((g[i]>i+1));
		while(g[i]>i&&abs(s[n]-s[g[i]-1]-(s[g[i]-1]-s[i-1]))<abs(s[n]-s[g[i]]-(s[g[i]]-s[i-1]))) g[i]--;
	//	debug(g[i]);
	}
	for(rint i=3;i<n;i++)
	{	ll r=max(max(s[f[i-1]],s[i-1]-s[f[i-1]]),max(s[n]-s[g[i]],s[g[i]]-s[i-1]));
		ll l=min(min(s[f[i-1]],s[i-1]-s[f[i-1]]),min(s[n]-s[g[i]],s[g[i]]-s[i-1]));
	//	debug(g[i]);
	//	debug(r);debug(l);debug(s[f[i-1]]);debug(s[i-1]-s[f[i-1]]);debug(s[n]-s[g[i]]);
		ans=min(ans,r-l);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 14080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define MM 1e9

int N,W[100];

void input() {
    cin >> N;
    rep (i,0,N){
        cin >> W[i];
    }
}

void solve(){
    int T;
    int S1,S2;
    int result=MM;
    rep (i,1,N) {
        T=i;
        S1=0;
        S2=0;
        rep (j,0,N) {
            if (j<=T-1) S1+=W[j];
            else S2+=W[j];
        }
        result=min(result,abs(S1-S2));
    }
    cout << result << endl;
}

int main() {
    input();
    solve();
}



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

int main()
{
    vector<int> precompute(32);
    precompute[1]=1;
    precompute[2]=2;
    for(int c=3;c<32;c++)
    {
        if(c%2==0) precompute[c]=precompute[c-1]+precompute[c-2]+1;
        else precompute[c]=precompute[c-1]*2+1;
    }
    int n;
    while(cin>>n)
    {
        cout<<precompute[n]<<endl;
    }
}

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

string s;

int main() {
  cin >> s;

  if ( ((int)s.size() >= 4) &&
       s[0] == 'Y' &&
       s[1] == 'A' &&
       s[2] == 'K' &&
       s[3] == 'I') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;

}


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

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int _min;
    int _max = -1000000000;
    for (int i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if (i == 0) {
            _min = tmp;
            continue;
        }
        _max = max(_max, tmp - _min);
        _min = min(_min, tmp);
    }
    printf("%d\n", _max);
}


Measured memory_bytes: 2756
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define int long long
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

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

    int n;
    int ans = 0;
    cin >> n;
    while(ans*1000-n < 0){
        ans++;
    }
    cout << ans*1000-n;


    return 0;
}









Measured memory_bytes: 3608
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
  
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(a-b)<=d&&abs(b-c)<=d){
        cout<<"Yes"<<endl;
    }
    else if(abs(a-c)<=d){
        cout<<"Yes"<<endl;
    }
    
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
def selectionSort(a):
    sw = 0
    for i in range(len(a)):
        minj = i
        for j in range(i, len(a)):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if i != minj:
            sw += 1
    return a, sw

N = int(input())
A = list(map(int, input().split()))

A, sw = selectionSort(A)

print(*A)
print(sw)


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

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

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

int64_t getVal(int64_t d){
  int64_t ans = 1;
  for(int i=1;i<d;i++){
    ans *= 10;
  }
  return ans;
}



signed main() {
  int64_t n;
  cin >> n;
  int x[n],y[n];
  vector<int> visit(n);
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
    visit[i]=i;
  }

  double dist = 0;
  int64_t count = 0;
  do{
    for(int i=1;i<n;i++){
      dist += sqrt( pow(x[visit[i-1]]-x[visit[i]],2) + pow(y[visit[i-1]]-y[visit[i]],2) );
    }
    count++;                                           
  }while(next_permutation(visit.begin(),visit.end()));
  
  cout << fixed << setprecision(10) << dist / (double)count << endl;
  return 0;
  
}




Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;
const int mod = 998244353;

void dfs(vector<vector<int>> &table, vector<vector<int>> &graph, int i, int v, vector<bool> &seen){
    if (seen[v]) return;
    seen[v] = true;
    for (int nv : graph[v]){
        table[i][nv] = min(table[i][nv], table[i][v] + 1);
        dfs(table, graph, i, nv, seen);
    }
}

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    --x; --y;
    vector<vector<int>> table(n, vector<int>(n, INF));
    rep(i, n) table[i][i] = 0;
    rep(i, n){
        for(int j = i; j < n; j++){
            table[i][j] = min(j - i, abs(i - x) + abs(j - y) + 1);
        }
    }
    map<int, int> ans;
    rep(i, n){
        for(int j = i; j < n; j++){
            ans[table[i][j]] += 1;
        }
    }
    rrep(i, n-1){
        cout << ans[i] << endl;
    }

}





Measured memory_bytes: 16000
n = int(input())
a_list = list(map(int,input().split()))

if n == 2 or n == 3:
    print(max(a_list))
elif n % 2 == 0: # 1パス使える
    dp = [[-float('inf') for _ in range(n)] for __ in range(2)]
    dp[1][-1] = a_list[-1]

    for j in reversed(range(2)):
        for i in reversed(range(n)):
            if j == 1 and i >= n-2:
                pass
            elif j == 1:
                dp[j][i] = dp[j][i+2] + a_list[i]
            elif i == n-2:
                dp[j][i] = dp[j+1][i+1]
            elif i > n-2:
                pass
            else:
                dp[j][i] = max(dp[j+1][i+1],dp[j][i+2] + a_list[i])
    print(dp[0][0])
else: # 2パス使える
    dp = [[-float('inf') for _ in range(n)] for __ in range(3)]
    dp[2][-1] = a_list[-1]

    for j in reversed(range(3)):
        for i in reversed(range(n)):
            if j == 2 and i >= n-2:
                pass
            elif j == 2:
                dp[j][i] = dp[j][i+2] + a_list[i]
            elif i == n-2:
                dp[j][i] = dp[j+1][i+1]
            elif i > n-2:
                pass
            else:
                dp[j][i] = max(dp[j+1][i+1],dp[j][i+2] + a_list[i])
    print(dp[0][0])


Measured memory_bytes: 48024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define REP(i,n) for (int i=1;i<=(n);++i)
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
#define FEC(p,u) for (edge*p=head[u];p;p=p->nxt)
using namespace std;
typedef long long LL;

char s[110000];
int n, k;
int main(){
	scanf("%s%d", s+1, &k);
	n = strlen(s+1);
	FOR(i,1,n-1) {
		int x = s[i]-'a';
		if ((26-x)%26 <= k) { k -= (26-x)%26; s[i] = 'a'; }
	}
	int x = s[n]-'a';
	s[n] = 'a'+(x+k%26)%26;
	printf("%s\n", s+1);
	return 0;
}


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

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

using namespace std;

bool solve() {

    int N;
    cin >> N;
    int n_odds = 0;
    REP(i, N) {
        int A;
        cin >> A;
        if (A % 2) ++n_odds;
    }
    return n_odds % 2 == 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << (solve() ? "YES" : "NO") << endl;
    return 0;
}


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


int main(){
  long long x;
  cin >> x;
  long long ans=0;
  long long a=100;
  while(a<x){
    a=a+(a*0.01);
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  int size = (int)a.size();

  cout << (a.at(size - 1) - a.at(0)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n, m;
    cin >> n >> m;
    if(n==m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;


void solve(long long N, long long D){
  cout << (N+2*D)/(2*D+1) << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  long long D;
  scanf("%lld",&D);
  solve(N, D);
  return 0;
}


Measured memory_bytes: 256
k = input()
s = input()
i = 0
l = int(k)
p = str()
 
while i < l and len(s) > l:
    p = p + s[i]
    i = i + 1
while i < len(s) and len(s) <=l:
    p = p + s[i]
    i = i + 1
if len(s) > l:
	print(p + '...')
else:
	print(p)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
int n,x[1005],y[1005];
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d%d",&x[i],&y[i]);
	For(i,2,n)
		if ((x[i]+y[i]+x[1]+y[1])&1)
			return puts("-1"),0;
	int fl=(x[1]+y[1]+1)&1;
	printf("%d\n",31+fl);
	if (fl) printf("1 ");
	Rep(i,30,0) printf("%d ",1<<i); puts("");
	For(i,1,n){
		if (fl) putchar('R'),x[i]--;
		int px=x[i],py=y[i];
		Rep(j,30,0){
			if (py>abs(px))
				putchar('U'),py-=1<<j;
			else if (py<-abs(px))
				putchar('D'),py+=1<<j;
			else if (px>abs(py))
				putchar('R'),px-=1<<j;
			else if (px<-abs(py))
				putchar('L'),px+=1<<j;
		}
		assert(!px&&!py);
		puts("");
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            // input //
            int n, m;
            args = Console.ReadLine().Split();
            Console.Write(int.Parse(args[0]) * int.Parse(args[1]));
        }
    }
}


Measured memory_bytes: 17836
S = input()

b_cnt = 0
C = [0] * len(S)
for i in range(len(S)):
    if S[i] == 'B':
        # 白の個数+1
        b_cnt += 1
    if S[i] == 'W':
        # それまでにあった白の個数を記録
        C[i] = b_cnt

print(sum(C))


Measured memory_bytes: 6476
#include <bits/stdc++.h>
     
    using namespace std;
     
    #define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define endl "\n"
    #define dump(x) cerr << "~ " << #x << " = " << x << endl
     
    #define N 300005
     
    long long rowCnt,colCnt,row[N],col[N],tot,a,b,ans;
    pair<int,int> ar[N];
     
    int main() {
     
    	fast_cin;
    	
        int n,m,k,x,y;
     
        cin >> n >> m >> k;
     
        for(int i = 1; i <= k; i++) {
            cin >> x >> y;
            row[x]++; col[y]++;
     
            ar[i] = make_pair(x,y);
        }
     
        a = b = -1;
     
        for(int i = 1; i <= n; i++) {
            if(a < row[i]) {
                a = row[i];
            }
        }
     
        for(int i = 1; i <= m; i++) {
            if(b < col[i]) {
                b = col[i];
            }
        }
     
        
    	
        for(int i = 1; i <= n; i++) {
            if(row[i] == a) {
                rowCnt++;
            }
        }
     
        for(int i = 1; i <= m; i++) {
            if(col[i] == b) {
                colCnt++;
            }
        }
     
        tot = rowCnt * colCnt;
     
        for(int i = 1; i <= k; i++) {
            x = ar[i].first, y = ar[i].second;
     
            if(row[x] == a and col[y] == b) {
                tot--;
            }
        }
     
        ans = a+b;
        if(tot == 0) ans--;
    	
        cout << ans << endl;
    	
    	return 0;
    }

Measured memory_bytes: 10628
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:isize = read();
    let y:isize = read();
    let mut ans = false;

    'outer: for i in 0..n+1 {
        for j in 0..n+1 {
            if y == (i*10000 + j*5000 + (n-i-j)*1000) {
                if (n-i-j) >= 0 {
                    println!("{} {} {}",i,j,(n-i-j));
                    ans = true;
                    break 'outer;
                }
            }
        }
    }

    if !ans {
        println!("-1 -1 -1");
    }
}


Measured memory_bytes: 4352
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())

ans = 0
for i in range(len(A)):
    a = A[i]
    ans += B[a-1]
    if i > 0 and A[i-1] == a - 1:
        ans += C[a-2]


print(ans)

Measured memory_bytes: 8936
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N,A,B,C,X,Y;
  int a[110000];
  int res=0;
  cin >> A>>B>>C>>X>>Y;

  if(A+B>C*2) {
    int n = min(X,Y);
    res += C*2*min(X,Y);
    X -= n;
    Y -= n;
  }
  if(A>C*2 && X>0){
    res += C*2*X;
    X = 0;
    Y = max(Y-X,0);
  }
  if(B>C*2 && Y>0){
    res += C*2*Y;
    X = max(X-Y,0);
    Y = 0;
  }

  res += A*X + B*Y;

  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    vector<int> a(k);
    for(int i = 0; i < k; i++){
        cin >> a[i];
    }
    if(a[k - 1] != 2){
        cout << -1 << endl;
        return 0;
    }
    reverse(a.begin(), a.end());
    int MIN = 2, MAX = 2;
    for(int i = 1; i < k; i++){
        MIN = (MIN + a[i] - 1) / a[i] * a[i];
        int limit = MAX + a[i - 1] - 1;
        MAX = limit / a[i] * a[i];
    }
    MAX += a[k - 1] - 1;
    reverse(a.begin(), a.end());
    int now = MIN;
    for(int i = 0; i < k; i++){
        now -= now % a[i];
    }
    if(now != 2) cout << -1 << endl;
    else cout << MIN << ' ' << MAX << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include<vector>
#include<set>
#define ll long long
using namespace std;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t,a,b,c,d=0,n,m,k,sum=0,i,j;
     
    cin>>n>>m;
    ll dp[n]{};
    bool flag=false;
     
    vector<pair<ll,ll>>v;
    k=m;
    while(m--)
    {
      cin>>a>>b;
      v.push_back(make_pair(a,b));
      
      /*
	  if(b==n)
      {
      	dp[a]=1;
	  }
	  else if(a==1 && dp[b])
	  {
	  	flag=true;
	  }
	  */
	}
	for(i=0;i<k;i++)
	{
	
	    //cout<<v[i].second<<endl;
	    
		if(v[i].second==n)
		{
			dp[v[i].first]=1;
			
		}
	   
	}
	
	for(i=0;i<k;i++)
	{
		 if(v[i].first==1 && dp[v[i].second])
		{
			//cout<<243<<endl;
			flag=true;
		}
	}
	if(flag)cout<<"POSSIBLE\n";
	else cout<<"IMPOSSIBLE\n";
	
    
      
  return 0;
}


Measured memory_bytes: 8960
#include"bits/stdc++.h"
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++) {
        cin >> s[i];
    }


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

    auto isOK = [&](int i, int j) {
        return (0 <= i && i < H && 0 <= j && j < W);
    };
    auto check = [&](int i, int j) {
        if (s[i][j] == '.') {
            return true;
        }

        for (int k = 0; k < 4; k++) {
            if (!isOK(i + dy[k], j + dx[k])) {
                continue;
            }

            if (s[i + dy[k]][j + dx[k]] == '#') {
                return true;
            }
        }

        return false;
    };

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (!check(i, j)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys
if __name__ == '__main__':
    letter_counts = [0] * 26  # ?????¢????????????????????????????????° [0]???'a'???[25]???'z'??????????????°
    for line in sys.stdin:

        # ?°?????????¨??§??????????????\????????????
        lower_text = line.lower()

        # ??¢???????????????????????¨??????????????°???????¨?
        for c in lower_text:
            if 'a' <= c <= 'z':
                letter_counts[ord(c)-ord('a')] += 1

    # ????????? 'a : a????????°' ?????¢??§z?????§1????????¨?????????
    for i, n in enumerate(letter_counts):
        print('{0} : {1}'.format(chr(ord('a')+i), n))

Measured memory_bytes: 7400
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  ts <- map readInt . BS.lines <$> BS.getContents
  print $ solve n ts

solve :: Int -> [Int] -> Int
solve _ = foldr1 lcm

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt


Measured memory_bytes: 508
#include<stdio.h>
int main(void)
{
	int n;
	int a,b;
	int i;
	int cnt[2];
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<2;i++)	cnt[i]=0;
		
		for(i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a > b){
				cnt[0]+=a+b;
			}
			else if(a < b){
				cnt[1]+=a+b;
			}
			else{
				cnt[0]+=a;
				cnt[1]+=b;
			}
		}
		printf("%d %d\n",cnt[0],cnt[1]);
		scanf("%d",&n);
	}
	return 0;
}

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int h, w, n, res = 0;
map<int, vector<int>> col;
map<int, int> row;
set<pair<int, int>> vis;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w >> n;
    for(int i = 0; i < n; ++i){
        int x, y; cin >> x >> y;
        vis.insert({x, y});
        col[y].pb(x);
        row[x]++;
    }
    int mx = 0, rm = 0, xc = 0;
    for(auto i : col){
        ckmax(mx, sz(i.s));
    }
    for(auto i : row){
        ckmax(rm, i.s);
    }
    for(auto i : row){
        xc += i.s == rm;
    }
    res = mx + rm - 1;
    // cout << mx << " " << rm << "\n";
    for(auto i : col){
        if(sz(i.s) == mx){
            int cnt = 0;
            // cout << i.f << ": ";
            for(auto j : i.s){
                // cout << j << "\t";
                if(row[j] == rm ){
                    cnt++;
                }
            }
            if(cnt < xc) res = mx + rm;
            // cout << "\n";
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 64544
unittest
{
	assert( [ "3 3", "1 7 11" ].parse.expand.solve == 2 );
	assert( [ "3 81", "33 105 57" ].parse.expand.solve == 24 );
	assert( [ "1 1", "1000000000" ].parse.expand.solve == 999999999 );
	
	assert( [ "3 10", "4 14 22" ].parse.expand.solve == 2 );		// 最大公約数が必要なケース
}



import std.algorithm;
import std.conv;
import std.functional;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nx = input.front.split.to!( long[] );
	input.popFront;
	auto xs = input.front.split.to!( long[] );
	return tuple( nx[ 0 ], nx[ 1 ], xs );
}

auto solve( long n, long x, long[] xs )
{
	xs ~= x;
	xs.sort();
	
	// 都市間の距離を計算
	auto ds = new long[ xs.length - 1 ];
	foreach( i, ref d; ds )
	{
		d = xs[ i + 1 ] - xs[ i ];
	}
	auto ds_u = ds.sort().uniq;
	
	// 都市間の距離の最大公約数を計算
	auto dg = ds[ 0 ];
	foreach( d; ds[ 1 .. $ ] )
	{
		dg = memoize!gcd( dg, d );
	}
	
	return dg;
}

auto gcd( long a, long b )
{
	while( a != 0 )
	{
		auto r = b % a;
		b = a;
		a = r;
	}
	
	return b;
}


Measured memory_bytes: 8244
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;



int main(){FIN
    string s;cin>>s;
    ll cnt=0;
    ll cnt2=0;
    REP(i,s.size()){
        if(i%2==0){
            if (s[i]=='1') cnt++;
            else cnt2++;
        }
        else{
            if(s[i]=='0') cnt++;
            else cnt2++;
        }
    }
    cout<<min(cnt,cnt2)<<endl;
    return 0;
}

Measured memory_bytes: 512
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (intercalate)

main :: IO ()
main = do
  (x : y : z : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  putStrLn . intercalate " " . map show $ [z, x, y]

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
a,b,c,d = list(map(int, input().split()))

i = 0
while True:
    if i % 2 == 0:
        c -= b
        if c <= 0:
            print('Yes')
            break
    else:
        a -= d
        if a <= 0:
            print('No')
            break
    i += 1

Measured memory_bytes: 9152
while True:
    try:
        a,op,b=input().split()
        a=int(a)
        b=int(b)
        if op=='?':
            pass
        else:
            if op=='+':
                print(a+b)
            elif op=='-':
                print(a-b)
            elif op=='*':
                print(a*b)
            elif op=='/':
                print(a//b)
        
    except:
        break;



Measured memory_bytes: 5600
N = int(input())
T = list(map(int, input().split()))
M = int(input())

P = [None] * M
X = [None] * M
for i in range(M) :
  P[i], X[i] = map(int, input().split())
  
sum = 0
for i in range(N) :
  sum += T[i]
  
for i in range(M) :
  print(sum - T[P[i]-1] + X[i])

Measured memory_bytes: 3064
program main
  
  implicit none
  integer :: n,i,j !859
  character(100) :: s, t
  character(200) :: new

  read(*,*) n 
  read(*,*) s, t 
  j = 0 
  do i = 1, 2*n 
    j = j + 1 
    new(j:j) = s(i:i) 
    j = j + 1 
    new(j:j) = t(i:i) 
  end do
  print*, new(1:2*n)
   
end program main


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		int k = int.Parse(input[2]);
		int cnt = 0;
		int r = a;
		if (a > b) { r = b; }
		while (cnt < k)
		{
			if (a % r == 0 && b % r == 0)
			{
				cnt++;
				if (cnt == k)
				{
					break;
				}
			}
			r--;
		}
		Console.WriteLine(r);
	}
}


Measured memory_bytes: 11092
def main():
    a, b, k = [int(i) for i in input().split()]

    s = set()
    for i in range(k):
        if a <= a+i and a+i <= b:
            s.add(a+i)
    for i in reversed(range(k)):
        if a <= b-i and b-i <= b:
            s.add(b-i)

    ans = list(s)
    ans.sort()

    for a in ans:
        print(a)
            
if __name__ == '__main__':
    main()


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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	int k, x;
	scanf("%d %d", &k, &x);
	if (500 * k >= x)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
string s[1000];
int e[1000],w[1000];
int main(){
	while(true){
		int n,q;
		cin>>n>>q;
		if(n==0) break;
		rep(i,n) cin>>s[i]>>e[i]>>w[i];
		rep(i,q){
			int y;
			cin>>y;
			bool ok=0;
			rep(j,n) if(w[j]-e[j]<y && y<=w[j]){
				ok=1;
				cout << s[j] << " " << e[j]-w[j]+y << endl;
			}
			if(!ok) cout << "Unknown\n";
		}
	}
}

Measured memory_bytes: 1300
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;


int main(){  
  int n,k;
  cin >> n >> k;
  ll ans = 1;
  while(n--){
    if(ans<k){
      ans *= 2;
    } else {
      ans += k;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

bool isPrime(int num)
{
    if (num == 2) return true;
    if (num < 2) return false;
    if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

void solve() {
    vll p(100010), cs(100010);
    REP(i, 100010) {
        if(i%2==0) continue;
        if(isPrime(i) && isPrime((i+1)/2)) p[i] |= 1;
    }
    CUMSUML(p, cs);
    ll Q;
    cin >> Q;
    REP(i, Q) {
        ll l, r;
        cin >> l >> r;
        out(cs[r]-cs[l-1]);
    }
}

int main() {
    fast_io;
    solve();
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	std::string s; cin >> s;
	
	if(s[0] == '0' || s.back() == '1') {
		cout << -1 << endl;
		return 0;
	}
	
	for(int i = 0; i < s.size() - 1; i++) {
		if(s[i] != s[s.size() - 1 - i - 1]) {
			cout << -1 << endl;
			return 0;
		}
	}
	
	int now = 0, cur = 0, to = 1, m = 0;
	std::vector<std::vector<int>> g(s.size());
	while(now < s.size() - 1) {
		g[cur].push_back(to++); m++;
		
		while(s[now++] == '0') {
			g[cur].push_back(to++); m++;
		}
		
		cur = to - 1;
	}
	
	//assert(m == s.size() - 1);
	for(int i = 0; i < g.size(); i++) {
		for(auto e : g[i]) cout << i + 1 << " " << e + 1 << endl;
	}
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int left = 0;
    int right = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == '(') left++;
        else {
            if (left> 0) left--;
            else right++;
        }
    }
    s.reserve(n + right);
    for (int i = 0; i < right; i++) s.insert(0, "(");
    
    int k = (int)s.size();
    left = 0;
    right = 0;
    for (int i = k - 1; i >= 0; i--){
        if (s[i] == ')') right++;
        else {
            if (right > 0) right--;
            else left++;
        }
    }

    s.reserve(k + left);
    for (int i = 0; i < left; i++) s.push_back(')');
    
    cout << s << endl;
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	if(3 * n % 4 == 0){
		long long ans = 3 * (long long)n /4;
		cout << ans << " ";
		cout << ans << " ";
		cout << ans << endl;
		return 0;
	}

	long long ans[3] = {0,0,0};
	for(long long i = 1; i < 3501; i++){
		for(long long j = 1; j < 3501; j++){
	//		cout << i << " " << j << endl;
			if(4*i*j-n*(i+j) <= 0) continue;
			if((n * i * j) % (4*i*j - n*(i + j)) == 0){
				ans[0] = i;
				ans[1] = j;
				ans[2] = (n*i*j)/(4*i*j-n*(i+j));
				break;
			}
		}
		if(ans[0] != 0)break;
	}
	cout << ans[0] << " " ;
	cout << ans[1] << " ";
	cout << ans[2] << endl;
	return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())

m = []
for i in range(1,n + 1):
    counter = 0
    while True:
        if i >= k:
            m += [counter]
            break
        else:
            i = i*2
            counter += 1
ans = 0
for i in m:
    ans += (1/n) * ((1/2) ** i)

print(ans)


Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 105
int h, w;
char gr[MN][MN];
int dp[MN][MN];

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

    cin >> h >> w;
    FOR(i, 1, h){
        FOR(j, 1, w){
            cin >> gr[i][j];
        }
    }
    memset(dp, 0x3f, sizeof dp);
    if(gr[1][1] == '#') dp[1][1] = 1;
    else dp[1][1] = 0;
    FOR(i, 1, h){
        FOR(j, 1, w){
            if(i == 1 && j == 1) continue;
            if(i != 0){
                dp[i][j] = min(dp[i][j], dp[i-1][j]+(gr[i][j]=='#' && gr[i-1][j] == '.'));
            }
            if(j != 0){
                dp[i][j] = min(dp[i][j], dp[i][j-1]+(gr[i][j]=='#' && gr[i][j-1] == '.'));
            }
        }
    }
    cout << dp[h][w] << "\n";

    return 0;
}


Measured memory_bytes: 256
import math
A,B,H,M = map(int,input().split())	
hun = H*60 + M
doji = (hun / 720)*360
#print(doji)
dohun = (M/60)*360
#print(dohun)
if abs(doji - dohun) <= 180 :
    ans = A**2+B**2-2*A*B*math.cos(math.radians(abs(doji-dohun)))
elif doji - dohun >=0:
    ans = A**2+B**2-2*A*B*math.cos(math.radians(360-doji+dohun))
else:
    ans = A**2+B**2-2*A*B*math.cos(math.radians(360-dohun+doji))

print(math.sqrt(ans))

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

int main() {
  int N; cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  
  int ans = 0;
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  if(N%2 == 0) {
    rep(i, N/2) ans += a[2*i]-a[2*i+1];
  } else {
    rep(i, N/2) ans += a[2*i]-a[2*i+1];
    ans += a[N-1];
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
  * Created by ui on 2016/02/04.
  */
object Main {
  def main(args: Array[String]): Unit = {
    var x: Int = 0
    var y: Int = 0
    val sc = new java.util.Scanner(System.in)
    y = sc.nextInt
    x = sc.nextInt
    while (x != 0 || y != 0) {
      val s = "".padTo(x, '#')
      for (i <- 0 until y) println(s)
      println
      y = sc.nextInt
      x = sc.nextInt
    }
  }
}

Measured memory_bytes: 45296
#include <bits/stdc++.h>
#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define oprecision                                                             \
  cout.precision(30);                                                          \
  cerr.precision(7);
#define bb bool
#define ii int
#define ll long long
#define ff float
#define dd double
#define cc char
#define ss string
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(i, sz) for (int i = 1; i <= sz; i++)
#define fornid(i, m, sz) for (int i = m; i <= sz; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vii vector<ii>
#define vii64 vector<ll>
#define vb vector<bb>
using namespace std;
int con(int a) { return (to_string(a).size() % 2 == 1); }
ii a, cnt;
ii main() {
  speed;
  oprecision;
  /*#ifndef ONLINE_JUDGE
    freopen("outd.txt", "rt", stdin);
  #endif*/
  // code
  cin >> a;
  forn(a) {
    if (con(i))
      cnt++;
  }
  cout << cnt;
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7,maxn=200;
int f[maxn][4][4][4];
/*
A 0
G 1
C 2
T 3

012
0 12
102
021
01 2

012
021
102
*/
signed main(){
	int i,j,k,m,n,u,v;
	cin>>n;
	for(i=0;i<4;i++)
		for(j=0;j<4;j++)
			for(k=0;k<4;k++){
			f[3][i][j][k]=1;
		}
	f[3][2][1][0]=f[3][1][2][0]=f[3][2][0][1]=0;
	for(i=4;i<=n;i++)
		for(j=0;j<4;j++)
			for(k=0;k<4;k++)
				for(u=0;u<4;u++)
					for(v=0;v<4;v++){
						if(v==2&&u==1&&k==0)continue;
						if(v==1&&u==2&&k==0)continue;
						if(v==2&&u==0&&k==1)continue;
						if(v==2&&u==1&&j==0)continue;
						if(v==2&&k==1&&j==0)continue;
						f[i][v][u][k]+=f[i-1][u][k][j];
						f[i][v][u][k]%=mod;
				}
	int sum=0;
	for(i=0;i<4;i++)
		for(j=0;j<4;j++)
			for(k=0;k<4;k++){
			sum+=f[n][k][j][i];
			sum%=mod;
		}
	printf("%lld\n",sum%mod);	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
 const long long mod=1e9+7;
int main() {
  int a,d,e;
  cin>>a>>e;
 vector< bool> b(a+1,true);
  long long int c[a+1];
  rep(i,a+2)c[i]=0;
  c[0]=1;
  rep(i,e){
    cin>>d;
    b[d]=false;
  }
for(int now=0;now<a;++now){
 for(int next=now+1;next<=min(a,now+2);++next){
 if(b[next]){
 c[next]+=c[now];
 c[next]%=mod;
 }
 }
 }
  cout<<c[a];
}

Measured memory_bytes: 1024
s = input()
n = len(s)
res0 = "01"*(n//2) + "0"*(n % 2)
res1 = "10"*(n//2) + "1"*(n % 2)
ans0 = 0
ans1 = 0
for i in range(n):
    ans0 += abs(int(res0[i]) - int(s[i]))
    ans1 += abs(int(res1[i]) - int(s[i]))
print(min(ans1, ans0))

Measured memory_bytes: 43244