akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<string>
#include<iostream>
#define ll long long
using namespace std;
const int maxn=100009*2;
const int maxm=100009*2;
struct node
{
    int x;int y;int id;
}a[100009*2],b[100009*2];
const bool com1(const node &a,const node &b)
{
    return a.x<b.x;
}
 const bool com2(const node &a,const node &b)
{
    return a.y<b.y;
}
struct Edge
{
    int u,v;
    ll dist;
    Edge(){}
    Edge(int u,int v,ll d):u(u),v(v),dist(d){}
    bool operator<(const Edge&rhs)const
    {
        return dist <rhs.dist;
    }
};

struct Kruskal
{
    int n,m;
    Edge edges[maxm];
    int fa[maxn];
    int findset(int x){ return fa[x]==-1? x: fa[x]=findset(fa[x]); }

    void init(int n)
    {
        this->n=n;
        m=0;
        memset(fa,-1,sizeof(fa));
    }

    void AddEdge(int u,int v,ll dist)
    {
        edges[m++]=Edge(u,v,dist);
    }

    ll kruskal()
    {
        ll sum=0;
        int cnt=0;
        sort(edges,edges+m);

        for(int i=0;i<m;i++)
        {
            int u=edges[i].u, v=edges[i].v;
            if(findset(u) != findset(v))
            {
                sum += edges[i].dist;
                fa[findset(u)] = findset(v);
                if(++cnt>=n-1) break;
            }
        }
        if(cnt<n-1) return -1;
        return sum;
    }
}KK;

int main()
{
    /*map<string,int> mp;
    ll max_sum;
    int n,m;
    scanf("%lf%d",&max_sum,&n);
    KK.init(n);
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]=i;
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++)
    {
        string s1,s2;
        ll x;
        cin>>s1>>s2>>x;
        KK.AddEdge(mp[s1],mp[s2],x);
    }
    ll ans = KK.kruskal();
    if(ans==-1 || ans> max_sum) printf("Not enough cable\n");
    else printf("Need %.1f miles of cable\n",ans);
    return 0;*/
    int n;
    cin>>n;
     KK.init(n);
    for(int i=1;i<=n;i++)
    {
        int u,v;
        cin>>u>>v;
        a[i].x=u;
        a[i].y=v;
        a[i].id=i;
        b[i].x=u;
        b[i].y=v;
        b[i].id=i;
    }
    sort(a+1,a+1+n,com1);
    sort(b+1,b+1+n,com2);
    for(int i=1;i<=n-1;i++)
    {
        KK.AddEdge(a[i].id,a[i+1].id,abs(a[i].x-a[i+1].x));
        KK.AddEdge(b[i].id,b[i+1].id,abs(b[i].y-b[i+1].y));
    }
     ll ans = KK.kruskal();
     cout<<ans<<endl;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n = s.size();
    string ans = "Yes";
    rep(i,n){
        if(i%2==1){
            if(s[i]=='R'){
                ans = "No";
                break;
            }
        }else{
            if(s[i]=='L'){
                ans = "No";
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define inf 1e18
#define pi acos(-1.0)
#define mod 1000000007

bitset<4000005>b;

int main(void)
{
    fastio;

    int n,a,s=0,i;
    cin >> n;
    b[0]=1;
    for(i=0;i<n;i++)
    {
        cin >> a;
        s=s+a;
        b=b|(b<<a);
    }
    for(i=(s+1)/2;i<=s;i++)
    {
        if(b[i])break;
    }
    cout << i ;

    return 0;
}



Measured memory_bytes: 5124
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> stringconvert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}

int X, Y,Z;
int main()
{
	cin >> X >> Y >> Z;
	cout << Z << " " << X << " " << Y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;


int main(){
    ll a,b,n;cin>>a>>b>>n;
    if(n<=b){
        ll an=max(floor(a*n/b)-a*floor(n/b),floor(a*(n-1)/b)-a*floor((n-1)/b));
        cout<<an<<endl;
    }
    else{
        ll an=floor(a-((double)a/b));
        cout<<an<<endl;
    }
}
    









Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ret.push_back(i);
            if (i != 1 && i*i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

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

    int N;
    cin >> N;
    vector<pair<ll, ll>> AB(N);
    cin >> AB;

    auto modulo = [](ll a, ll b) -> ll {
        return a - std::floor(a / b) * b;
    };

    ll ans = 0;
    FORR(i, N, 0) {
        AB[i].first += ans;
        ll num = (AB[i].second + modulo(AB[i].second - AB[i].first, AB[i].second)) % AB[i].second;
        ans += num;
    }

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

Measured memory_bytes: 1792
import sys

B, W = map(int, sys.stdin.readline().split())
MOD = 10**9 + 7

L = B+W
fact = [1]*(L+1)
rfact = [1]*(L+1)
for i in range(L):
    fact[i+1] = r = fact[i] * (i+1) % MOD
    rfact[i+1] = pow(r, MOD-2, MOD)

rev2 = pow(2, MOD-2, MOD)

p = q = 0
base = 1
ans = ["%d\n" % rev2]
for i in range(1, B+W):
    base = rev2 * base % MOD
    if i-B >= 0:
        p = (p + ((fact[i-1]*rfact[B-1] % MOD)*rfact[i-B] % MOD)*base % MOD) % MOD
    if i-W >= 0:
        q = (q + ((fact[i-1]*rfact[W-1] % MOD)*rfact[i-W] % MOD)*base % MOD) % MOD
    ans.append("%d\n" % ((1-p+q)*rev2 % MOD))
sys.stdout.writelines(ans)

Measured memory_bytes: 35204
N = int(input())
A = list(map(int, input().split()))

if N == 1:
	print(1)

elif N == 2:
	print(1)

else:
	L = []
	for i in range(1, N):
		x = A[i] - A[i - 1]
		if x > 0:
			L.append("+")
		elif x == 0:
			L.append(".")
		else:
			L.append("-")

	c = 1
	judge = L[0]
	for i in range(1,N - 1):
		if L[i] == ".":
			pass
		elif L[i] == "+":
			if judge == "+" or judge == ".":
				judge = "+"
			else:
				c += 1
				judge = "."
		else:
			if judge == "-" or judge == ".":
				judge = "-"
			else:
				c += 1
				judge = "."

	print(c)


Measured memory_bytes: 14484
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ss = 0;
int a[200010], b[200010], c[200010];
map<int,int>s;
int main() {
	int n;
	s.clear();
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		b[i] = a[i] + i;
		c[i] = i - a[i];
		if (!s[c[i]]) s[c[i]] = 1;
		else s[c[i]]++;
	}
	ll ss = 0;
	for (int i = 1; i <= n; i++) {
		s[c[i]]--;
		ss = ss + s[b[i]];
	}
	printf("%lld\n", ss);
	return 0;
}

Measured memory_bytes: 23084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for (int i = 0; i < ty - sy; i++) cout << 'U';
    for (int i = 0; i < tx - sx; i++) cout << 'R';
    for (int i = 0; i < ty - sy; i++) cout << 'D';
    for (int i = 0; i < tx - sx; i++) cout << 'L';
    cout << 'L';
    for (int i = 0; i <= ty - sy; i++) cout << 'U';
    for (int i = 0; i <= tx - sx; i++) cout << 'R';
    cout << 'D';
    cout << 'R';
    for (int i = 0; i <= ty - sy; i++) cout << 'D';
    for (int i = 0; i <= tx - sx; i++) cout << 'L';
    cout << 'U';
    cout << endl;
}

Measured memory_bytes: 256
import collections
from collections import deque

s= input()
n=int(input())
q= [list(input().split()) for i in range(n)]

s=deque(s)
flag=True
for i in range(n):
    if q[i][0]==str(1):
        if flag:
            flag=False
        else:
            flag=True
    else:
        if flag:
            if q[i][1]==str(1):
                s.appendleft(q[i][2])
            else:
                s.append(q[i][2])
        else:
            if q[i][1]==str(1):
                s.append(q[i][2])
            else:
                s.appendleft(q[i][2])

if not flag:
    s.reverse()
print(''.join(s))

Measured memory_bytes: 118140
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;

    int64_t ans = 0;
    for(int b=K+1; b<=N; b++) {
        ans += (b-K) * (N/b) + max(N%b-max(K-1, 0), 0);
    }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int LL;
int main() {
        LL num;
        cin>>num;
    string result = "";
    while (num > 0) {
      num--; // 1 => a, not 0 => a
      LL remainder = num % 26;
      char digit = (char) (remainder + 97);
      result = digit + result;
      num = (num - remainder) / 26;
    }
    cout<<result<<endl;
}


Measured memory_bytes: 3616
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    if (N == 1)
    {
        cout << "Hello World" << endl;
        return 0;
    }
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
    return 0;
}

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

res = [0] * (n + 1)

for i in range(1, n + 1)[::-1]:
    sum_res = sum(res[x] for x in range(i, n + 1, i))
    if sum_res % 2 != arr[i - 1]:
        res[i] = 1

print(sum(res))

if sum(res):
    ans = []
    for i, elm in enumerate(res):
        if elm:
            ans.append(i)
    print(*ans)


Measured memory_bytes: 14132
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N=2200;
int a[N][N],n,m,d[N][N],h[N][N],ans,stack[N][2],top,tt;
char ch;
int main(){
//    freopen("1.in","r",stdin);
    scanf("%d%d\n",&n,&m);
    	if(n==1||m==1){
    		printf("%d",n*m);
    		return 0;
    	}
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%c",&ch);
            if(ch=='#')a[i][j]=1;
            else a[i][j]=0;
        }scanf("\n");
    } ans=max(n,m);n=n-1;m=m-1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            d[i][j]=1-((a[i][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1])%2);
        }
    }
   
    for(int i=1;i<=n;i++){
        for(int j=m;j>=1;j--){
            if(d[i][j]==1)h[i][j]=h[i][j+1]+1;
            else h[i][j]=0;
        }
    }
//    for(int i=1;i<=n;i++){
//    	for(int j=1;j<=m;j++)printf("%d ",d[i][j]);
//    	printf("\n");
//    }printf("\n\n");
//    for(int i=1;i<=n;i++){
//    	for(int j=1;j<=m;j++)printf("%d ",h[i][j]);
//    	printf("\n");
//    }
    for(int j=1;j<=m;j++){
        top=0;memset(stack,0,sizeof stack);
        for(int i=1;i<=n+1;i++){
            tt=1;
            while(top>0&&stack[top][0]>=h[i][j]){
                tt+=stack[top][1];
                ans=max(ans,(stack[top][0]+1)*(tt));
                --top;
            }
            ++top;
            stack[top][0]=h[i][j];
            stack[top][1]=tt;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 55424
import sys
H,W=map(int,input().split())
a=list(sys.stdin)
rs,cs=[1]*H,[1]*W
for i in range(H):
    for j in range(W):
        if a[i][j]=='#':
            rs[i]=cs[j]=0
ans=''
for i in range(H):
    if rs[i]:
        continue
    r=''
    for j in range(W):
        if cs[j]:
            continue
        r+=a[i][j]
    ans+=r+'\n'
print(ans)


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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  int N; cin >> N;
  vector<P> que;
  rep(i, N){
    ll x, l; cin >> x >> l;
    que.emplace_back(x - l, x + l);
  }
  sort(que.begin(), que.end(), [](auto &left, auto &right){return left.second < right.second;});
  ll ans = 1;
  ll last = que[0].second;
  for (int i = 1; i < N; ++i){
    if (que[i].second > last && que[i].first >= last) {
      ans++;
      last = que[i].second;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 2420
package main

import (
	"fmt"
)
func hoge(X int , Y int , x int , y int) int {
	switch {
	case X == 1:
		x = 300000

	case X == 2:
		x = 200000
	
	case X == 3: 
		x = 100000

	default:
		x = 0
	}
	switch {
	case Y == 1:
		y = 300000

	case Y == 2:
		y = 200000

	case Y == 3: 
		y = 100000
	
	default:
		y = 0
	}
	
	if X == 1 && Y == 1 {
		x = 1000000
		y = 0
	}

	return x + y
}

func main(){
	var X, Y int
	var x, y int

	fmt.Scan(&X, &Y)
	fmt.Println(hoge(X, Y, x, y))
	
}

Measured memory_bytes: 512
#include<stdio.h>

int main()
{
    int n, m;   scanf("%d%d", &n, &m);
    int U[n];
    int i;
    int tmp[2];

    for(i = 0; i < n; i++){
        U[i] = 0;
    }

    for(i = 0; i < m; i++){
        scanf("%d%d", &tmp[0], &tmp[1]);

        U[tmp[0] - 1]++;
        U[tmp[1] - 1]++;
    }

    for(i = 0; i < n; i++){
        printf("%d\n", U[i]);
    }

    return 0;
}

Measured memory_bytes: 128
import numpy as np
import copy

# d日目の終わりで低下する満足度
def cost(c, d, lastdi):
    total = 0
    for i in range(26):
        total += c[i]*(d - lastdi[i])
    return total

# 日数
D = int(input())
# type毎の満足度の下がりやすさ
c = list(map(int, input().split()))

# [d,i]の満足度
s = [[] for _ in range(D)]
for d in range(D):
    si = list(map(int, input().split()))
    s[d] = si

# type毎の最後に開催された日を管理
lastdi = [0 for _ in range(26)]

ans = 0
# for d in range(D):
#     # d日目に選択されたtype
#     typei = int(input()) - 1
#     lastdi[typei] = d+1 # 日付なので+1
#     ans += s[d][typei] - cost(c, d+1, lastdi)
#     print(ans)

for d in range(D):
    # その日の満足度リストをソートしてindexを取得    
    sd_sort = np.argsort(s[d])
    max_ans = 0
    typei = -1
    
    for i in range(26):
        tmp_lastdi = copy.deepcopy(lastdi)
        choicei = sd_sort[i]
        tmp_lastdi[choicei] = d+1 # 日付なので+1
        ans = s[d][choicei] - cost(c, d+1, tmp_lastdi)
        if ans > max_ans:
            # print("更新{}".format(ans))
            typei = choicei

    lastdi[typei] = d+1 # 日付なので+1
    typei = s[d].index(max(s[d])) + 1
    print(typei)


Measured memory_bytes: 27504
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;string s;cin>>n>>s>>k;char a=s.at(k-1);
  for(int i=0;i<n;i++){
    if(s.at(i)!=a)s.at(i)='*';
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string s, t;
  cin >> s >> t;

  int cnt = 0;
  rep(i, s.size()){
    if(s[i] != t[i]) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3916
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;

  int ans = max(A - 2 * B, 0);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
def yaku(n):
	a=1
	p=[3,5,7,11,13]
	for i in p:
		j=0
		while n%i==0:
			n//=i
			j+=1
		a*=j+1
	return a
print(sum([1 for i in range(int(input())+1) if i%2==1 and yaku(i)==8]))

Measured memory_bytes: 38256
N=int(input())
N=N+1
L1 = 2
L2 = 1
if N==1:print(L1)
if N==2:print(L2)
if N>2:
  N=N-2
  for i in range(N):
    L=L1+L2
    L1 = L2
    L2 = L
  print(L)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
vector<long long> memo(90, -1);

long long luca (int n){
  if (memo[n] != -1) return memo[n];
  return memo[n] = luca(n -1) + luca(n - 2);
}
int main() {
  long long N;
  cin >> N;
  memo[0] = 2;
  memo[1] = 1;
  cout << luca(N) << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n;
    cin >> n;

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

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

    ll total = 0;
    for(int i = 0; i < n; i++){
        total += b[i] - a[i];
    }

    ll cnt1 = 0;
    ll cnt2 = 0;
    for(int i = 0; i < n; i++){
        if(a[i] > b[i]){
            cnt1 += a[i] - b[i];
        } else if(b[i] > a[i]){
            if((b[i] - a[i]) % 2 == 0){
                cnt2 += (b[i] - a[i]) / 2;
            } else {
                cnt2 += (b[i] - a[i]) / 2 + 1;
            }
        }
    }

    if(max(cnt1, cnt2) > total){
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, a[100000], sum = 0, b[3] = {-1, -1, -1}, c[3] = {};
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum ^= a[i];
  }
  sort(a, a + n);
  if (a[n - 1] == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  b[0] = a[0];
  c[0] = 1;
  int p = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == b[p]) {
      c[p]++;
    } else {
      if (!(c[p] == n / 3 * 2 || c[p] == n / 3)) {
        cout << "No" << endl;
        return 0;
      }
      p++;
      b[p] = a[i];
      c[p] = 1;
      if (p == 3) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  if (b[0] == 0 && c[0] == n / 3 && c[1] == n / 3 * 2 ||
      (b[0] ^ b[1] ^ b[2]) == 0 && c[0] == c[1] && c[1] == c[2]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

int main(){

   int i,j,H,W;

   while(1){
	cin >> H >> W;

	if((H==0)&&(W==0)) break;

	for(i=0;i<H;i++){

		for(j=0;j<W;j++){

			if((i == 0)||(j == 0)||(j == W-1)||(i == H-1)){
				cout << "#";

			}else{
				cout << ".";
			}
		}

		cout << endl;

	}

	cout << endl;

   }

   return 0;

}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int n,b;
        int a[][]  = new int[3][3];
        String ans = "No"; 
        
        Scanner scan = new Scanner(System.in);
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                a[i][j] = scan.nextInt();
            }
        }
        

        
        n = scan.nextInt();
        
        for(int k = 0; k < n; k++){
            b = scan.nextInt();
                for(int i = 0; i < 3; i++){
                    for(int j = 0; j < 3; j++){
                        if(a[i][j] == b){
                            a[i][j] = -1;

                        }
                        if((a[i][0] == -1) && (a[i][1] == -1) && (a[i][2] == -1)){
                            ans = "Yes";
                        }
                        if((a[0][j] == -1) && (a[1][j] == -1) && (a[2][j] == -1)){
                            ans = "Yes";
                        }
                        if((a[0][0] == -1) && (a[1][1] == -1) && (a[2][2] == -1)){
                            ans = "Yes";
                        }
                        if((a[0][2] == -1) && (a[1][1] == -1) && (a[2][0] == -1)){
                            ans = "Yes";
                        }
                    }
                }
            
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

int rx[100], ry[100];
int bx[100], by[100];

vector<int> adj[100];
int vis[100];
int match[100];

int dfs(int x)
{
    if (vis[x])
        return 0;

    vis[x] = 1;
    for (int y : adj[x])
    {
        if (match[y] == -1 || dfs(match[y]))
        {
            match[y] = x;
            return 1;
        }
    }
    return 0;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> rx[i] >> ry[i];
    for (int i = 0; i < n; ++i)
        cin >> bx[i] >> by[i];

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (rx[i] < bx[j] && ry[i] < by[j])
                adj[i].push_back(j);
        }
    }
    int sol = 0;
    memset(match, -1, sizeof match);
    for (int i = 0; i < n; ++i)
    {
        memset(vis, 0, sizeof vis);
        if (dfs(i))
            sol++;
    }
    cout << sol;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "iostream"
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
using System;
using System.Linq;
//Dp[h,x] h=移動前の縦、x=移動後の横　結果=場合の数

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int h = In[0];//横線が引ける段
            int w = In[1];//本数
            int e = In[2];//終点
            var Dp = new long[h+1, w];
            //最初は左の棒(0)からスタートし、二本目(1)に移動する
            Dp[0, 0] = 1;
            if (w > 1)
            {
                for (int i = 1; i < w; i++)
                {
                    Dp[0, i] = 0;
                }
            }
            int mod=1000000007;
            //左の棒に行く、とどまる、右の棒
            for(int i = 0; i < h; i++)
            {
                for(int j = 0; j < w; j++)
                {
                    //ある高さの横線の引き方は2^(w-1)
                    for(int k=0; k < 1 << (w - 1); k++)
                    {
                        //２連続で横線はダメ
                        bool ok = true;
                        for(int l = 0; l < w - 2; l++)
                        {
                            if(((k>>l) & 1)==1 && (((k >> (l + 1)) & 1)==1))
                            {
                                ok = false;
                            }
                        }
                        if (!ok) continue;
                        //左、下に行く
                        if(j>=1 && (((k >> (j - 1)) & 1) == 1))
                        {
                            Dp[i + 1, j - 1] += Dp[i, j];
                            Dp[i + 1, j - 1] %= mod;
                        }
                        //右、下に行く
                        else if(j<=w-2 && (((k >> j) & 1) == 1))
                        {
                            Dp[i + 1, j + 1] += Dp[i, j];
                            Dp[i + 1, j + 1] %= mod;
                        }
                        //そのまま下に行く
                        else
                        {
                            Dp[i + 1, j] += Dp[i, j];
                            Dp[i + 1, j] %=mod;
                        }
                    }
                }
            }
            Console.WriteLine(Dp[h, e - 1]);
        }
    }
}


Measured memory_bytes: 28220
use proconio::input;

fn main() {
  input! {
    N: usize,
    A: [usize;N-1],
  }

  let mut result: Vec<usize> = Vec::with_capacity(N+1);
  for _ in 0..=N {
    result.push(0);
  }

  for i in A.into_iter() {
    result[i] += 1;
  }
  
  for i in 1..=N {
    println!("{}", result[i]);
  }
}


Measured memory_bytes: 6324
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
p = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    r = ni()

    print(2 * math.pi * r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9736
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	vl a(3),b(3);
	rep(i,3) cin >> a[i];
	rep(i,3) cin >> b[i];
	a.push_back(1);
	b.push_back(1);
	vl dp(n+1,0);
	rep(i,n){
		rep(j,4){
			if(i+a[j]>n) continue;
			chmax(dp[i+a[j]],dp[i]+b[j]);
		}
	}
	ll N = dp[n];
	vl dp2(N+1,0);
	rep(i,N){
		rep(j,4){
			if(i+b[j]>N) continue;
			chmax(dp2[i+b[j]],dp2[i]+a[j]);
		}
	}
	cout << dp2[N] << endl;
}

Measured memory_bytes: 195584
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

const int CMax = 100002;

string S;

int main(){
    cin >> S;
    if (S[0] == S[2]) printf("Yes\n");
    else printf("No\n");
}


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

int main(){
 int n;
 string s;
 cin>>n>>s;

 int cnt=0;
 for (int i = 0; i < n-2; i++)
 {
     /* code */
     if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
     {
         /* code */
         cnt++;
     }
     
 }
 cout<<cnt<<endl;
 
}
  

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int dp[3001][3001];

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

    int n, t;
    cin >> n >> t;

    vector< P > v;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    SORT(v);

    fill(dp[0], dp[n + 1], -IINF);
    dp[0][0] = 0;

    rep(i, n){
        rep(j, t){
            chmax(dp[i + 1][j], dp[i][j]);
            chmax(dp[i + 1][min(j + v[i].first, t)], dp[i][j] + v[i].second);
        }
        chmax(dp[i + 1][t], dp[i][t]);
    }

    int ans = -IINF;
    rep(j, t + 1){
        chmax(ans, dp[n][j]);
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 35456
K, X = map(int, input().split())
# R,S,P = map(int, input().split())
# T = input()
# N = int(input())

if K*500 >=X:
    print("Yes")
else:
    print("No")
    
# dict_sample = {
#     "r":P,
#     "s":R,
#     "p":S
# }
# ans = 0

        
# print(ans)



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long


using namespace std;

set<vector<int>> seqs;

int n, m, q;

void createSeq(vector<int> seq, int pos)
{
	if(pos >= n-1)
	{
		seqs.insert(seq);
		return;
	}
	
	for(int i = seq[pos]; i <= m; i++)
	{
		seq[pos+1] = i;
		createSeq(seq, pos+1);
	}
}

int main()
{
    ios_base::sync_with_stdio(false);	
    cin.tie(NULL); cout.tie(NULL);
    
    cin >> n >> m >> q;
    
    vector<vector<int>> nums(q);
    
    for(int i = 0; i < q; i++)
    {
		int a,b,c,d; cin >> a >> b >> c >> d;
		
		nums[i].pb(a);
		nums[i].pb(b);
		nums[i].pb(c);
		nums[i].pb(d);
	}
	
	vector<int> a(n,1);
	
	createSeq(a, 0);
	
	int res = 0;
	
	for(auto seq: seqs)
	{
		int ans = 0;
		for(auto y: nums)
		{
			if(seq[y[1]-1] - seq[y[0]-1] == y[2])
			{
				ans+=y[3];
			}
		}
		res = max(ans, res);
	}

	cout<< res << '\n';
    
    return 0;
}



Measured memory_bytes: 8912
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    rep(i,n)cin>>a[i];
    ll lb=0,ub=inf;
    while(ub-lb>1){
        ll mid=(ub+lb)/2;
        ll sum=0;
        rep(i,n){
            sum+=(a[i]+mid-1)/mid-1;
        }
        if(sum>k)lb=mid;
        else ub=mid;
    }
    cout<<ub<<endl;
}


Measured memory_bytes: 4324
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

struct Eratosthenes{
  vector<ll> sieve;// sieve[i]: 数字iがエラトステネスで篩落とされた時の素数

  Eratosthenes(ll n): sieve(n+1){
    for(int i=0; i<=n; i++) sieve[i] = i;
    for(ll i=2; i*i<=n; i++){
      if(sieve[i] < i) continue;
      for(ll j=i*i; j<=n; j+=i) sieve[j] = min(sieve[j], i);
    } 
  }

  vector<ll> prime_divisors(ll x, bool tmp=false){
    vector<ll> res(1,1);//back()のところで ひっかかるので1を入れとかないとダメ
    while(x > 1){
      if(res.back() != sieve[x]) res.push_back(sieve[x]);
      x /= sieve[x];
    }
    return res;
  }

  map<ll, int> prime_divisors(ll x, int tmp=0){
    map<ll, int> mp;
    while(x > 1){
      mp[sieve[x]]++;
      x /= sieve[x];
    }
    return mp;
  }
};

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A[i];

  sort(A.begin(), A.end());//82行目のbreakを入れないとTLEになるらしく，それならsortしないといけない
  // const int INF  =1e6+1;// sortじゃなくてこっちがTLEの原因?
  const int INF = A.back()+1;
  vector<int> vec(INF, 0);
  for(int i=0; i<N; i++){
    for(int j=1; j*A[i]<=INF; j++){
      vec[A[i]*j]++;
      // if(vec[A[i]*j] >= 2) break;// これいれたらWA?
    }
  }
  int ans = 0;
  for(ll i=0; i<N; i++){
    if(vec[A[i]] == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  string s;
  vector<char> st(4);
  cin >> s;
  for(int i=0;i<4;i++) st.at(i) = s.at(i);
  sort(st.begin(),st.end());
  if(st.at(0) == st.at(1) && st.at(2) == st.at(3) && st.at(1) != st.at(2)) 
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
x=input()
a=[0]
d={}
d[0]=0
for i in range(1,1000):
	a+=[i**5]
	a+=[-i**5]
	d[i**5]=i
	d[-i**5]=-i

a.sort()
for i in range(len(a)):
    if x+a[i] in a:
        print d[a[i]+x],d[a[i]]
        break

Measured memory_bytes: 65712
a,b=map(int,input().split())
ans=1
for i in range(0,b):
  for j in range(0,b):
   if i+j==a and i*2+4*j==b:
    ans+=1
    break
   else:
     pass

if ans>1:
  print("Yes")
else:
  print("No")

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

ans_r=0
min_num=P[0]
for p in range(0, N):
  if (min_num > P[p]):
    min_num=P[p]
  if (min_num < P[p]):
    ans_r += 1
print (N-ans_r)



Measured memory_bytes: 24744
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
using namespace std;


int main() 
{
	int n, count_p = 0, count_q = 0;
	cin >> n;
	vector <int> p(8);
	vector <int> q(8);
	for (int i = 0; i < n; i++) 
	{
		 cin >> p[i];
	}
	
	for (int i = 0; i < n; i++) 
	{
		cin >> q[i];
	}

	while (next_permutation(p.begin(), p.begin() + n)) 
	{
		count_p++;
	}
	
	while (next_permutation(q.begin(), q.begin() + n)) 
	{
		count_q++;
	}

	cout << abs(count_p - count_q) << endl;
	return 0;
}


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

using namespace std;

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

    vector<double> A(N);

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

    double sum=0;
    for(int i=0;i<N;i++){
        sum = sum+A[i];
    }


    int count =0;
    long double tem =sum/(4*M);

    for(int i=0;i<N;i++){
        if(A[i]<tem){count++;}
    }

    int check = N-count;

    if(check>=M){cout<< "Yes" << endl;}
    if(check<M){cout << "No" << endl;}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
const int N = 2e5+9;
// long long a[N];
vector<vector<char>> norms;
vector<char> cur;
int n;
int uniq;
void solve(int ind) {
    // cout << ind << " " << string(cur.begin(), cur.end()) << endl;
    if(ind == n) {
        norms.push_back(cur);
        return;
    }
    for(int i = 0; i < uniq; i++) {
        cur.push_back('a' + i);
        solve(ind+1);
        cur.pop_back();
    }
    cur.push_back('a' + uniq);
    uniq++;
    solve(ind+1);
    uniq--;
    cur.pop_back();
}

signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    cur.push_back('a');
    uniq = 1;
    solve(1);
    sort(norms.begin(), norms.end());
    for(auto it: norms) {
        cout << string(it.begin(), it.end()) << "\n";
    }




    return 0;
    
}

Measured memory_bytes: 7856
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let h: usize = scan(tokens);
    let w: usize = scan(tokens);
    let k: usize = scan(tokens);
    let white: Vec<Vec<usize>> = vec(h, |_| {
        let s: String = scan(tokens);
        s.bytes().map(|b| b as usize - b'0' as usize).collect()
    });
    let mut cumsum = vec![vec![0; w + 1]; h + 1];
    for i in 0..h {
        for j in 0..w {
            cumsum[i + 1][j + 1] = cumsum[i + 1][j] + cumsum[i][j + 1] - cumsum[i][j] + white[i][j];
        }
    }
    fn rec(a: usize, ys: &mut Vec<usize>, res: &mut usize, cumsum: &Vec<Vec<usize>>, k: usize) {
        let h = cumsum.len() - 1;
        let w = cumsum[0].len() - 1;
        if a < h {
            rec(a + 1, ys, res, cumsum, k);
            ys.push(a);
            rec(a + 1, ys, res, cumsum, k);
            ys.pop();
        } else {
            ys.push(h);
            let mut count = ys.len() - 2;
            let mut x_prev = 0;
            let mut x = 1;
            loop {
                if count == *res {
                    break;
                }
                let mut ok = true;
                for i in 1..ys.len() {
                    if (cumsum[ys[i]][x] - cumsum[ys[i]][x_prev])
                        - (cumsum[ys[i - 1]][x] - cumsum[ys[i - 1]][x_prev])
                        > k
                    {
                        ok = false;
                    }
                }
                if !ok {
                    if x == x_prev + 1 {
                        break;
                    } else {
                        count += 1;
                        x_prev = x - 1;
                    }
                } else {
                    if x == w {
                        *res = std::cmp::min(*res, count);
                        break;
                    } else {
                        x += 1;
                    }
                }
            }
            ys.pop();
        }
    }
    let mut ys = vec![0];
    let mut res = h + w - 2;
    rec(1, &mut ys, &mut res, &cumsum, k);
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  string N,M;
  int m=100000;
  cin>>N>>M;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  for(int i=0; i<N.size()-M.size()+1; i++){
    int a=0;
     for(int j=0; j<M.size(); j++){
         if(N[i+j] != M[j])a++;
     }
    m=min(m,a);
   }
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << m << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <stack>

using namespace std;

int main(){
  long N,tmp,minsub;
  long Min = 2000000009;
  cin >> N;
  vector<long> sum;
  
  for(int i=0;i<N;++i){
    cin >> tmp;
    if(i==0){
      sum.push_back(tmp);
    }else{
      sum.push_back(sum[i-1]+tmp);
    }
  }

  for(int i=0;i<N-1;++i){
    minsub = abs(sum[N-1]-sum[i]-sum[i]);
    if(Min > minsub){
      Min = minsub;
    }
  }

  cout << Min << endl;
}


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

template<typename S> class SegmentTree {
 public:
  using FS = std::function<S(S, S)>;
  SegmentTree(int n, FS fs, S es) : n(size(n)), fs(fs), es(es), dat(size(n) << 1, es) {}
  void update(int k, S x) {
    dat[k += n] = x;
    while(k = parent(k)) dat[k] = fs(dat[lchild(k)], dat[rchild(k)]);
  }
  S query(int a, int b) const {
    auto vl = es, vr = es;
    for(auto l = a + n, r = b + n; l < r; l = parent(l), r = parent(r)) {
      if(l&1) vl = fs(vl, dat[l++]);
      if(r&1) vr = fs(dat[--r], vr);
    }
    return fs(vl, vr);
  }
 private:
  constexpr int size(int n) const {return n & (n - 1) ? size(n + (n & -n)) : n;}
  inline int parent(int k) const {return (k >> 1);}
  inline int lchild(int k) const {return (k << 1);}
  inline int rchild(int k) const {return (k << 1) | 1;}
  int n;
  std::vector<S> dat;
  FS fs;
  S es;
};

long long bit(char c) {return 1ll << (c-'a');}

int main() {
  int N; string S; int Q;
  cin >> N >> S >> Q;
  SegmentTree<long long> T(N, [](auto l, auto r){return l | r;}, 0ll);
  for(auto i=0; i<N; ++i) T.update(i, bit(S[i]));
  for(auto q=0; q<Q; ++q) {
    int t;
    cin >> t;
    if(t==1) {
      int i; char c;
      cin >> i >> c;
      T.update(i-1, bit(c));
    } else {
      int l, r;
      cin >> l >> r;
      cout << __builtin_popcount(T.query(l-1, r)) << endl;
    }
  }
}


Measured memory_bytes: 12196
s=input()
from collections import deque
s=deque(s)
ans=0
while len((s)):
  if s[0]==s[-1]:
    if len((s))==1:
      s.pop()
      break
    else:
      s.pop()
      s.popleft()
  else:
    if s[0]=="x" and s[-1]!="x":
      s.append("x")
      ans+=1
    elif s[0]!="x" and s[-1]=="x":
      s.appendleft("x")
      ans+=1
    elif s[0]!="x" and s[-1]!="x":
      print(-1)
      exit(0)

print(ans)


Measured memory_bytes: 4212