akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<int>& a, vector<int>& b) {
	return a[0] < b[0];
}

int ycomp(vector<int>& a, vector<int>& b) {
	return a[1] < b[1];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)
#define YSORT(c) sort((c).begin(),(c).end(),ycomp)

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


LL mod = 1000000007;
int main() {
	string s;
	cin >> s;
	REP(i, 19) {
		if (i == 5 || i == 13) {
			cout << " ";
		}
		else {
			cout << s[i];
		}
		
	}
	cout << endl;

}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		StringBuilder sb = new StringBuilder();
		for(char c: s) {
			c += n;
			if (c > 'Z') {
				c -=26;
			} 	
			sb.append(c);
		}
		out.println(sb);
	}
}

Measured memory_bytes: 22100
#include <stdio.h>
#include <stdlib.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  
  for(i=0; i<n1; i++) L[i] = A[left + i];
  for(i=0; i<n2; i++) R[i] = A[mid + i];
  
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  
  for(k=left; k<right; k++){
    if (L[i].value <= R[j].value) A[k] = L[i++];
    else A[k] = R[j++];
  }

  return ;
}

void mergeSort(struct Card A[], int n, int left, int right){
  int mid;
  
  if(left + 1 < right){
    mid = (left+ right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }

  return ;
}

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;

  x = A[r];
  i = p-1;
  
  for(j=p; j<r; j++){
    if(A[j].value <= x.value){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  
  if(p<r){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q-1);
    quickSort(A, n, q+1, r);
  }

  return ;
}

int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }
  
  mergeSort (A, n, 0, n);
  quickSort (B, n, 0, n-1);
  for(i=0; i<n; i++) if(A[i].suit != B[i].suit) stable = 0;
  
  if(stable == 1) printf("Stable\n");
  else printf("Not stable\n");
  for (i=0; i<n; i++) printf("%c %d\n", B[i].suit, B[i].value);
  
  return 0;
}



Measured memory_bytes: 4072
#include <stdio.h>

int leap_year(int, int);

int main(void)
{
	int a, b;
	int i = 0;
	while (1) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) {
			break;
		}
		if (i++) {
			printf("\n");
		}
		leap_year(a, b);
	}
	return 0;
}

int leap_year(int a, int b)
{
	int leap_year_number = 0;
	for (int i = a; i <= b; i++) {
		if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) {
			printf("%d\n", i);
			leap_year_number += 1;
		}
	}
	if (leap_year_number == 0) {
		printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 1044
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) (((a) >> (b)) & 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, K;
int h[101010];

signed main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> h[i];

  sort(h, h + N);

  int ans = INF;
  for (int i = 0; i + K - 1 < N; i++) {
    int tmp = abs(h[i + K - 1] - h[i]);
    chmin(ans, tmp);
  }

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


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).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;}
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 5) << " " << s.substr(6, 7) << " " << s.substr(14, 5) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=100001;
const string F = "Female";
const string M = "Male";
const string V = "Vacant";
int n,st,fi,mid;
string s,ge0;



int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	cout<<0<<endl;
	cin >> s;
	if(s==F)ge0=F;
	else ge0=M;
	if(s==V)return 0;

	st=0;
	fi=n-1;
	int k=0;

	while(fi-st>1){
		mid=(fi+st)/2;
		cout<<mid<<endl;
		cin>>s;
		if(s==V)return 0;

		if(s==ge0){
			if(mid%2){
				fi=mid;
				k=0;
			}else{
				st=mid;
				k=1;
			}
		}else{
			if(mid%2){
				st=mid;
				k=1;
			}else{
				fi=mid;
				k=0;
			}
		}
	}
	if(k)cout<<fi<<endl;
	else cout<<st<<endl;
	return 0;
}

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

int main(void) {
    int n, i, ab, p1, p4 = 0;
    long p2, p3;
    cin >> n;
    int x[n], y[n];
    for (i = 0; i < n; i++) cin >> x[i];
    for (i = 0; i < n; i++) cin >> y[i];
    for (i = 0; i < n; i++) {
        ab = abs(x[i] - y[i]);
        p1 += ab;
        p2 += pow(ab, 2);
        p3 += pow(ab, 3);
        p4 = max(p4, ab);
    }
    cout << fixed << double(p1) << endl << sqrt(p2) << endl;
    cout << fixed << cbrt(p3) << endl << double(p4) << endl;
    return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W,a,b;
  cin >> W >> a >> b;
  int x=max(a,b)-min(a+W,b+W);
  if (x<0){
    cout << 0 << endl;
  }
  else {
    cout << x << endl;
  }
}

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

map<int, int> a;
int n, m;

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

	cin >> m;
	for (int i = 0; i < m; ++i) {
		int x; cin >> x;
		if (a[x] == 0) {
			cout << "NO\n";
			return 0;
		}

		a[x]--;
	}

	cout << "YES\n";
}


Measured memory_bytes: 9600
import numpy as np

a = int(input())
b_np = np.array(list(map(int, input().split())))
ans_count = 0

while True:
  if 1 not in np.mod(b_np,2):
    b_np = b_np / 2
    ans_count += 1
  else:
    print(ans_count)
    break

Measured memory_bytes: 12488
#include <stdio.h>

long long N;

void dfs(long long x, int bits, long long int *cnt){
    if(x>N) return;
    if(bits == 0b111) *cnt = *cnt+1;
    dfs(x*10+3,bits|0b001,cnt);
    dfs(x*10+5,bits|0b010,cnt);
    dfs(x*10+7,bits|0b100,cnt);
}

int main(void){
    scanf("%lld",&N);
    long long int ans=0;
    dfs(0,0,&ans);
    printf("%lld",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	vector<string> strings;
	string s;
	while (cin >> s) {
		size_t found;
		while ((found = s.find(",", 0)) != string::npos)
			s.erase(found);
		while ((found = s.find(".", 0)) != string::npos)
			s.erase(found);
		if (3 <= s.size() && s.size() <= 6)
			strings.push_back(s);
	}
	vector<string>::iterator it = strings.begin();
	int ifs = 1;
	while (it != strings.end()) {
		if (ifs == 0)
			cout << " ";
		cout << *it;
		ifs = 0;
		it++;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
typedef long long ll;
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=2e5+10;
char s[maxn];
int sum[maxn];
int main(){
	ll ans=0;
	scanf("%s",s+1);
	REP(i,1,strlen(s+1)) sum[i]=sum[i-1]+(s[i]=='B');
	REP(i,1,strlen(s+1)) if(s[i]=='W') ans+=sum[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1280
import Control.Applicative
main = do xs <- (map read) . lines <$> getContents
          putStr . unlines $ solve 1 xs

solve :: Int -> [Int] -> [String]
solve i (x:xs) | x == 0 = []
               | otherwise = ("Case " ++ (show i) ++ ": " ++ (show x)) : solve (i+1) xs

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

int main(){
    ll N;
    cin >> N;
    bool even = false;
    if(N % 2 == 0){
        even = true;
    }
    vector<ll> A(N),memo(N,0);
    rep(i,N){
        cin >> A[i];
        if(even){
            if(A[i] % 2 == 0){
                cout << 0 << endl;
                return 0;
            }
        }else{
            if(A[i] % 2 == 1){
                cout << 0 << endl;
                return 0;
            }
        }
        memo[A[i]]++;
    }
    if(N == 1 && A[0] == 0){
        cout << 1 << endl;
        return 0;
    }
    if(even){
        if(memo[0] != 0){
            cout << 0 << endl;
            return 0;
        }
    }else{
        if(memo[0] != 1){
            cout << 0 << endl;
            return 0;
        }
    }
    //cout << "AAA"<<endl;
    if(even){
        rep(i,ll(N/2) + 1){
            if(memo[i+1] != 2){
                cout << 0 << endl;
                return 0;        
            }
        i++;
        }
    }else{
        rep(i,ll(N/2) + 1){
            if(memo[i+2] != 2){
                cout << 0 << endl;
                return 0;        
            }
        i++;
        }
    }
    //cout << "BBB"<<endl;


    ll tot = 1;
    rep(i, N/2){
        tot *= 2;
        tot %= mo;
    }
    cout << tot << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int cnt=0,sum=0;
    cin>>s;
    for(int i=0; i<s.size()-1; i++){
        if(s[i]!=s[i+1]){cnt++;}
        else continue;
    }
   cout<<cnt<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 10010;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h,n;
    cin>>h>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    int dp[d5];
    for(int i=0;i<d5;i++)dp[i]=mod;
    dp[0]=0;
    //dp[i]:iをけずるのに最小の魔力
    for(int i=0;i<n;i++){
        for(int j=0;j<d5;j++){
            dp[j]=min(dp[j],dp[max(j-a[i],0ll)]+b[i]);
        }
    } 
    cout<<dp[h]<<endl;
}

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

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

    string s;
    cin >> s;

    // 現在のスコアを計算
    int Score = 0;
    for(int i=0; i<n-1; i++){
        if(s.at(i) == s.at(i+1))
            Score++;
    }

    // 1回の操作で基本的に+2points（グループ数が1なら変化なし。2なら+1point）
    int group = n - Score;  // ランレングス圧縮後のグループ数
    for(int i=0; i<k; i++){
        if(group == 1)
            break;
        else if(group == 2){
            Score += 1;
            break;
        }
        
        Score += 2;
        group -= 2;
    }

    cout << Score << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){

  while(1){
    int x,y,t;
    cin >> x >> y;

    if(x == 0 && y == 0) break;
    if(x > y) {
      t = x;
      x = y;
      y = t;
    }
    cout << x << " " << y << endl;
  }
  return 0;
}


Measured memory_bytes: 3032
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else 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;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

int main() {
	ll A, B,ans;
	std::cin >> A >> B;
	ans = max(B /0.1,A/0.08);
	while (true) {
		ll tmpA = ans * 0.08;
		ll tmpB = ans * 0.1;
		if (tmpA == A && tmpB == B) {
			std::cout << ans << endl;
			break;
		}
		else if (tmpA > A || tmpB > B) {
			std::cout << -1 << endl;
			break;
		}

		ans++;
	}
	
	return 0;

}


Measured memory_bytes: 256
m=float("INF")
sunukes=[]
for i in range(7,-1,-1):
    for j in range(1000,10,-1):
        #print(i,j)
        sunuke=j*(100**i)-1
        s=str(sunuke)
        sn=0
        for k in range(len(s)):
            sn+=int(s[k])
        x=sunuke/sn
        #print(sunuke,x)
        if x<=m :
            m=x
            sunukes.append(sunuke)
for i in range(9,0,-1):
    sunukes.append(i)
sunukes=sunukes[::-1]
k=int(input())
#print(sunukes)
for i in range(k):
    print(sunukes[i])

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int num1=0,num2=0,num3=0;
	
	cin>>num1>>num2>>num3;
	if(num1==7&&num2==5&&num3==5){
		cout<<"YES\n";
	}
	else if(num1==5&&num2==7&&num3==5){
		cout<<"YES\n";
	}
	else if(num1==5&&num2==5&&num3==7){
		cout<<"YES\n";
	}
	else{
		cout<<"NO\n";
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
/*istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}*/
const ll INF=1e9+7;

ll n;

vector<ll> que;

void dfs(ll t,bool p,bool q,bool r){
    if(p && q && r) que.push_back(t);
    string s=to_string(t);
    if(s.length()==10) return;
    dfs(t*10+7,true,q,r);
    dfs(t*10+5,p,true,r);
    dfs(t*10+3,p,q,true);
    return;
}

int main()
{
    
    cin >> n;
    dfs(0,false,false,false);
    sort(que.begin(),que.end());
    ll ans=0;
    ll i=0;
    while(true){
        if(que[i]<=n){
            ans++;
            i++;
        }
        else break;
    }
    cout << ans << endl;
    return 0;
} 


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<set>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,x;
string st;
char s[25];
set<int> cant;
bool check(int x)
{
	sprintf(s,"%d",x);
	st=s;
	int i;
	for (i=0;i<st.length();i++)
	{
		if (cant.count(st[i]-'0')) return 0;
	}
	return 1;
}
int main()
{
	cin>>n>>m;
	for (i=1;i<=m;i++)
	{
		cin>>x;
		cant.insert(x);
	}
	while (!check(n)) n++;
	cout<<n;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String s=reader.readLine();
			int n=Integer.parseInt(s);
			if(n==0){System.exit(0);}
			int[] tensuu=new int[n];
			for(int i=0;i<n;i++){
				tensuu[i]=Integer.parseInt(reader.readLine());
			}
			Arrays.sort(tensuu);
			int sum=0;
			for(int j=1;j<n-1;j++){
				sum+=tensuu[j];
			}
			int ans=sum/(n-2);
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 16932
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str;

        //String[] num = str.split(" ",0);
        //int i = 1;
        while(true){
            str = scan.nextLine();
            String[] num = str.split(" ",0);
            if(Integer.valueOf(num[0]) == 0&&Integer.valueOf(num[1]) == 0){
                break;
            }
            if(Integer.valueOf(num[0]) > Integer.valueOf(num[1])){
                System.out.println(Integer.valueOf(num[1]) + " " + Integer.valueOf(num[0]));
            }else{
                System.out.println(Integer.valueOf(num[0]) + " " + Integer.valueOf(num[1]));
            }
            
        }


        scan.close();
    }

}



Measured memory_bytes: 35800
#include <bits/stdc++.h>
    typedef int ll;
    using namespace std;
    int dp[102][100004];
    int pref[102][100004];
        int main() 
        {
            ios::sync_with_stdio(false);    
            int n,k;
            int a[102];
            cin>>n>>k;
            for(int i=1;i<=n;i++)cin>>a[i];
            int mod=1e9+7;
            memset(dp,0,sizeof dp);
            memset(pref,0,sizeof pref);
            dp[0][0]=1;

            for(int i=1;i<=n;i++)
            {
                pref[i-1][0]=dp[i-1][0];
                for(int j=1;j<=k;j++){
                    pref[i-1][j]=dp[i-1][j];
                    pref[i-1][j]%=mod;
                    pref[i-1][j]+=pref[i-1][j-1];
                    pref[i-1][j]%=mod;

                }
                for(int j=0;j<=k;j++)
                {


                     if(j-a[i]-1>=0)
                         dp[i][j]=(pref[i-1][j]-pref[i-1][j-a[i]-1]+mod)%mod;
                     else
                         dp[i][j]=pref[i-1][j];




                }

            }
            cout<<dp[n][k]<<endl;
            return 0;
        }

Measured memory_bytes: 80000
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class FactInvMOD:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        # 階乗テーブル
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        # 階乗の逆元テーブル
        inverse = [1] * MAX
        # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            # 最後から戻っていくこのループならMAX回powするより処理が速い
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく) """

        if n < r: return 0
        # 10C7 = 10C3
        r = min(r, n-r)
        # 分子の計算
        numerator = self.fact[n]
        # 分母の計算
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

    def nPr(self, n, r):
        """ 順列 """

        if n < r: return 0
        return self.fact[n] * self.inv[n-r] % self.MOD

    def nHr(self, n, r):
        """ 重複組み合わせ """

        # r個選ぶところにN-1個の仕切りを入れる
        return self.nCr(r+n-1, r)

N = INT()
A = LIST()

# 唯一2つある値を見つける
target = 0
for k, v in Counter(A).items():
    if v == 2:
        target = k
        break
idx = A.index(target)
# 2つある値の1回目と2回目の出現位置の間にいくつ数があるか
btw = A[idx+1:].index(target)

fim = FactInvMOD(N+1, MOD)
for i in range(1, N+2):
    # 部分列の総数 - 重複分
    ans = fim.nCr(N+1, i) - fim.nCr(N-1-btw, i-1)
    print(ans%MOD)


Measured memory_bytes: 19936
package main

import "fmt"

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func check(time, distance int) bool {
	if time < distance || (distance-time)%2 != 0 {
		return false
	}
	return true
}

func main() {
	var n int
	fmt.Scan(&n)

	t := make([]int, n)
	x := make([]int, n)
	y := make([]int, n)
	for i := range t {
		fmt.Scan(&t[i], &x[i], &y[i])
	}

	ans := "Yes"
	distance := x[0] + y[0]
	time := t[0]
	if !check(time, distance) {
		ans = "No"
	}
	for i := 0; i < n-1; i++ {
		distance = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
		time = t[i+1] - t[i]
		if !check(time, distance) {
			ans = "No"
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
//define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


//auto mod int
//https://github.com/atcoder-live/library/blob/master/mint.cpp

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


// combination mod prime
// https://github.com/atcoder-live/library/blob/master/comb.cpp


int n_, a, b;

struct combination {
    vector<mint> frac, ifrac;
    combination(int n):frac(n+1), ifrac(n+1) {
        assert(n < mod);
        frac[0] = n_;
        for (int i = 1; i <= n; ++i) frac[i] = frac[i-1]*(n_-i);
        ifrac[0] = 1;
        for (int i = 1; i <= n; ++i) {
            mint i_ = i+1;
            ifrac[i] = ifrac[i-1]*i_.inv();
        }
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return frac[k-1]*ifrac[k-1];
    }
} ;

int main() {
    
    cin >> n_ >> a >> b;

    combination c(200001);
    mint ans = 2;
    ans = ans.pow(n_);

    ans -= 1;
    ans -= c(n_, a);
    ans -= c(n_, b);
    cout << ans << endl;
}



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

const int MN = 3003;
int N, i, x, y, arr[MN], dp[MN];
vector<int> adj[MN];

void solve(int n,int p){
    dp[n]=0;
    for(auto v : adj[n]){
        if(v==p||arr[n]<=arr[v]) continue;
        solve(v, n);
        dp[n]|=(!dp[v]);
    }
}

int main(){
    for(scanf("%d",&N),i=1;i<=N;i++)
        scanf("%d",&arr[i]);
    for(i=1;i<N;i++){
        scanf("%d%d",&x,&y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(i=1;i<=N;i++){
        solve(i, 0);
        if(dp[i]) printf("%d ",i);
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main() {
  int t = 1;
  // cin>>t;
  while(t--) {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    bool ok = false;
    while(k--) {
      if(a < b && b < c) {
        ok = true;
        break;
      }
      if(a < b) {
        c <<= 1;
      } else {
        b <<= 1;
      }
    }
    if(a < b && b < c) {
      ok = true;
    }
    cout<<(ok?"Yes":"No");
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>

bool flg[100];
bool ans[100];

bool solv(ssize_t n) {
  if (n < 0) return false;

  if (! flg[n]) {
    flg[n] = true;
    if (solv(n-4) || solv(n-7)) {
      ans[n] = true;
    } else {
      ans[n] = false;
    }
  }

  return ans[n];
}

int main() {
  ssize_t n;
  std::cin >> n;

  for (ssize_t i=0; i<n; i++)
    flg[i] = false;

  flg[0] = true;
  ans[0] = true;

  std::cout << (solv(n) ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 256
try:
    while True:
        a = map(int, raw_input().split())
        b = map(int, raw_input().split())
        p = q = 0
        for i in range(len(b)):
            if a[i] == b[i]:
                p += 1
            elif a.count(b[i]) != 0:
                q += 1
        print p, q
except:
    pass

Measured memory_bytes: 4212
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif 
}

int32_t main(){
   boost;
   IO();

   int N; cin>>N;
   str s; cin>>s;
   set <int> st;
   for(int i=0; i<N; i++) if(s[i]=='R') st.insert(i);

   int ans=0;
   for(int i=0; i<N && !st.empty(); i++){
      auto it=st.end(); it--;
      if(*it<i) break;
      if(s[i]=='W'){
      	swap(s[i],s[*it]);
      	ans++;
      	st.erase(it);
      }
   }

   cout << ans << endl;
   //cout << s << endl;

   return 0;
}



Measured memory_bytes: 12980
#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c,d,e;
    scanf("%d%d",&a,&b);
    c=a+b;
    d=a-b;
    e=a*b;
    if(c<d)
        c=d;
    if(c<e)
        c=e;
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

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

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  string S;
  cin >> S;
  vector<int> tmp(2);
  int f = 1;
  int N = S.size();
  vector<int> odd(N), even(N);
  FOR(i, N) {
    if (S[i] == 'R') {
      tmp[f]++;
      f = 1 - f;
    } else {
      even[i] += tmp[0];
      odd[i] += tmp[1];
      tmp[0] = 0;
      tmp[1] = 0;
      f = 1;
    }
  }
  f = 1;
  tmp[0] = 0;
  tmp[1] = 0;
  for (int i = N - 1; i >= 0; --i) {
    if (S[i] == 'L') {
      tmp[f]++;
      f = 1 - f;
    } else {
      even[i] += tmp[0];
      odd[i] += tmp[1];
      tmp[0] = 0;
      tmp[1] = 0;
      f = 1;
    }
  }
  vector<int> ans(N);
  FOR(i, N - 1) {
    if (S[i] == 'R' && S[i + 1] == 'L') {
      even[i] += odd[i + 1];
      even[i + 1] += odd[i];
    }
  }

  FOR(i, N) { cout << even[i] << " "; }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1792
from bisect import bisect_right


def solve(n, d, a, xh_list):
    res = 0
    xh_list_s = sorted(xh_list, key=lambda x: x[0])
    x_list_s = [xh[0] for xh in xh_list_s]
    h_list_s = [xh[1] for xh in xh_list_s]
    dmg = 0
    wait_list = [0] * (n + 1)
    for i in range(n):
        dmg -= wait_list[i]
        v = h_list_s[i] - dmg
        if v > 0:
            t = (v - 1) // a + 1
            res += t
            dmg += t * a
            j = bisect_right(x_list_s, x_list_s[i] + 2 * d)
            wait_list[j] += t * a

    return res


def main():
    n, d, a = map(int, input().split())
    xh_list = []
    for _ in range(n):
        x, h = map(int, input().split())
        xh_list.append((x, h))
    res = solve(n, d, a, xh_list)
    print(res)


def test():
    assert solve(3, 3, 2, [(1, 2), (5, 4), (9, 2)]) == 2
    assert solve(9, 4, 1, [(1, 5), (2, 4), (3, 3), (4, 2), (5, 1), (6, 2), (7, 3), (8, 4), (9, 5)]) == 5
    assert solve(3, 0, 1, [(300000000, 1000000000), (100000000, 1000000000), (200000000, 1000000000)]) == 3000000000


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 42580
N = int(input())
H = list(map(int,input().split()))
dp = [0]*N

dp[1] = abs(H[1]-H[0])
for i in range(2,N):
  dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))
print(dp[-1])

Measured memory_bytes: 13928
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

bool solve(string s){
  if(s == "mew" || s == "") return true;
  if(s[0] != 'm' || s[s.length()-1] != 'w') return false;
  vector<int> cnt(3, 0);
  for(int i = 1; i < s.length()-1; i++){
    if(s[i] == 'm') cnt[0]++;
    else if(s[i] == 'w') cnt[2]++;
    if(s[i] == 'e' && cnt[0] == cnt[1] && cnt[0] == cnt[2]){
      string a = s.substr(1, i-1), b = s.substr(i+1, s.length()-2-i);
      if(solve(a) && solve(b)) return true;
    }
    if(s[i] == 'e') cnt[1]++;
  }
  return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  string s; cin >> s;
  if(solve(s)) cout << "Cat" << endl;
  else cout << "Rabbit" << endl;
  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}



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

int main() {
  float a,b,c,d,e;
  int remA,remB,remC,remD,remE;
  cin >> a >> b >> c >> d >> e ;
  int Ap =  ceil(a / 10) * 10;
  int Bp = ceil(b / 10) * 10;
  int Cp = ceil(c / 10) * 10;
  int Dp = ceil(d / 10) * 10;
  int Ep = ceil(e / 10) * 10;
  if (a == Ap){
  remA += 10;
  }
  else{
    remA +=  a + 10 - Ap;
  }
  if (b == Bp){
    remB +=  10;
  }
  else{
    remB +=  b + 10 - Bp;
  }
  if (c == Cp){
    remC +=  10;
  }
  else{
    remC +=  c+ 10 - Cp;
  }
  if (d == Dp){
    remD +=  10;
  }
  else{
    remD +=  d + 10 - Dp;
  }
  if (e== Ep){
    remE +=  10;
  }
  else{
    remE +=  e + 10 - Ep;
  }
  int rem = std::min({remA,remB,remC,remD,remE});
  //cout <<remA<<remB<<remC<<remD<<remE << endl;
  int result = Ap + Bp + Cp + Dp + Ep - 10 + rem;
  cout << result << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"YES"<<endl;
	exit(0);
}
 
void No(){
	cout<<"NO"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int cntx = 0;
  char s;
  while(cin >> s) {
	if(s == 'x') cntx++;
  }
  if(cntx >= 8) No();
  Yes();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char a[100100],b[100010];
int main()
{
	cin>>a;
	int j=0;
	int l=strlen(a);
	for(int i=l-1;i>=0;i--)
	{
		b[j]=a[i];	
		if(b[j]=='p')
		b[j]='q';
		else if(b[j]=='q')
		b[j]='p';
		else if(b[j]=='b')
		b[j]='d';
		else if(b[j]=='d')
		b[j]='b';
		j++;
	}
	if(!strcmp(a,b))
	cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <random>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	int n;
	string s;
	cin >> s;
	n = s.length();
	cout << s.substr(0, n - 8) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
//#include<string.h>
using namespace std;
//cout << "Yes" << endl;
//cout << "No" << endl;
int seiyaku_check(long i,int Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int a,b,c;
	
	cin >> a >> b;
	
	seiyaku_check(a,1,100);
	seiyaku_check(b,1,100);
	
	c=a-2*b;
	if(c<0)c=0;
	
	cout << c << endl;
	
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n, m) for(int i = n; i < (int)(m); i++)
/*
void Debug_print(vector<int> p){
  rep(q,0,p.size()){
    cout << p.at(q);
  }
  cout << endl;
}
*/

int main() {
  int N;
  cin >> N;
  
  vector<string> Si;
  rep(i,0,N){
    string tmps;
    cin >> tmps;
    Si.push_back(tmps);
  }


  int64_t ans = 0;
  string sorted_Si;
  map<string, int> mp;
  
  rep(i,0,N){
    sort(Si.at(i).begin(), Si.at(i).end());
    sorted_Si = Si.at(i);
    
    if (mp.count(sorted_Si)) {
      int times = mp.at(sorted_Si);
      ans += times;
      mp[sorted_Si] = mp.at(sorted_Si) + 1;
    }else{
      mp[sorted_Si] = 1;
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
   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++) b[a[i] - 1] = i+1;

   for(int i=0;i<N;i++) cout << b[i] << endl;


    return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
#define st string
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define gcd __gcd
#define F first
#define S second
using namespace std;
int cocoa(int n) {
	int cnt=0;
	while(n%2==0) {
		cnt++;
		n/=2;
	}
	return cnt;
}
signed main() {
	int n;
	cin>>n;
	int a[n];
	int chino=0;
	rep(i,n) {
		cin>>a[i];
		chino+=cocoa(a[i]);
	}
	cout<<chino<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
using ordered_set = tree<key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
#define F first
#define S second
#define T second.first
#define D second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(v) v.begin(),v.end()
#define OO 0x3f3f3f3fLL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll,pair<ll,ll>> piii;
const int N = 3e3+5, M= 20, mod = 1000000000;
const double EPS = 1e-10;

ll n,m,k;
ll A[N][N], mem[N][N][4];

ll solve(int x, int y, int rem){
    if(x == n-1 && y == m-1){
        if(rem)return A[x][y];
        return 0;
    }
    if(x == n || y == m){
        return -INF;
    }

    ll&ret = mem[x][y][rem];
    if(~ret)
        return ret;

    if(rem){
        ret = max(solve(x, y+1, rem-1), solve(x+1, y, 3))+A[x][y];
    }
    ret = max(ret, solve(x, y+1, rem));
    ret = max(ret, solve(x+1, y, 3));
    return ret;
}


int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n>>m>>k;
    for(int i=0; i<k; i++){
        ll a, b, c;
        cin>>a>>b>>c;
        A[a-1][b-1]=c;
    }
    memset(mem, -1, sizeof mem);
    cout<<solve(0,0,3);
}


Measured memory_bytes: 356744
#include<stdio.h>
#define MAX 100005
#define NIL -1
 
int D[MAX],H[MAX];
int n;
int A;
/*
 p: parent
 l: left-child
 r: right sibling
 */
void print(int);
 
struct Node{ int p, l, r;};
struct Node T[MAX]; // Tree
 
int getDepth(int u);
void tree(int a);
void hairetu(int);
int parent(int);
int sibling(int);
int degree(int);
int height(int);
 
 
void hairetu(int a){
  int leaf;
   
  if(getDepth(a) == 0){
    printf("root\n");
  }
// leaf
  else if(T[a].r ==NIL && T[a].l ==NIL){
      printf("leaf\n");
    }
  
  // internal node
  else if(T[a].r!=NIL || T[a].l!= NIL){
    printf("internal node\n"); 
  }
}
 
 
int getDepth(int u){
  int d = 0;
  int i;
  if(u == A) return 0;
  else{
    i = n-1;
    while(1){
      if(u == A) break;
      if(T[i].l == u || T[i].r == u){
    d++;
    u = T[i].p;
      }
      i--;
      if(i<0) i = n-1;
    }
    return d;
  }
   
}
 
int parent(int a){
  int i;
  if(a==A) return -1;
  else {
  for(i=0;i<n;i++){
    if(T[i].l==a || T[i].r == a){
      return T[i].p;
      break;
  }
  }
  }
}
 
int sibling(int b){
  int i;
  if(b==A) return -1;
  else {
    for(i=0;i<n;i++){
      if(T[i].l == b){
    return T[i].r;
      }
      if(T[i].r == b){
    return T[i].l;
      }
    }
  }
}
 
int degree(int d){
  if(T[d].l==-1 && T[d].r == -1){
    return 0;
  }
  else if(T[d].l != -1 && T[d].r != -1){
    return 2;
  }
  else if((T[d].l == -1 && T[d].r != -1) || (T[d].l != -1 && T[d].r == -1)){
    return 1;
  }
  
}
int height(int c){
  int l=0;
  int r=0;
 
  if(T[c].l==-1 && T[c].r == -1){
    return 0;
  }
  if(T[c].l!=-1 && T[c].r != -1){
    l = height(T[c].l)+1;
    r = height(T[c].r)+1;
    if(l<r){
      return r;
    }
    else return l;
  }
  else if(T[c].l==-1&&T[c].r!=-1){
      return height(T[c].r)+1;
    }
  else if(T[c].l!=-1&&T[c].r==-1){
      return height(T[c].l)+1;
    }
}
void print(int u){
  
   
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,parent(u),sibling(u),degree(u),D[u],height(u));
  hairetu(u);
}
 
 
main(){
  int i, j, d, v, c, l;
  int t;
  int flag=0;
 
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r = NIL;
  }
 
  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &v, &d, &c);
 
    T[v].p = v;
     
    T[v].l = d;
 
    T[v].r = c;
     
 
  }
  A = 0;
  for(i=n-1;i>0;i--){
    if(T[i].l==A || T[i].r==A){
      A = T[i].p;   
      flag++;
      if(A == 0){
    break;
      }
    else {
      i = n-1;
    }
    } 
  }

  if(flag == 0){
    A= 0;
  }
  
  
  for(i=0;i<n;i++){
    D[i] = getDepth(i);
  }
 
  for ( i = 0; i < n; i++ ) print(i);
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n+1,0);
    for(int i=1;i<=n;i++) cin>>a[i];
    int ans=0;
    for(int i=1;i<=n;i++){
        if(a[a[i]]==i) ans++;
    }
    cout<<ans/2<<"\n";
    return 0;
}

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

const int N = 100005;

int n, m, c[N];
vector<int> v[N], e[N];

int f(int x){
    c[x] = 1;
    int r = 1;
    for(int i : e[x]) if(!c[i]) r += f(i);
    return r;
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1, t; i <= n; i++){
        scanf("%d", &t);
        for(int x; t--; ){
            scanf("%d", &x);
            v[x].push_back(i);
        }
    }
    for(int i = 1; i <= m; i++){
        for(int j = 0; j + 1 < v[i].size(); j++){
            e[v[i][j]].push_back(v[i][j + 1]);
            e[v[i][j + 1]].push_back(v[i][j]);
        }
    }
    puts(f(1) == n ? "YES" : "NO");
}

Measured memory_bytes: 11896
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

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

int main() {
  double res;
  double N;
  cin >> N;
  vector<double> X = vector<double>(3);
  double C_1 = 0;
  double C_2 = 0;
  double P;
  REP(i, N) {
    cin >> X[i];
    C_1 += X[i];
    C_2 += X[i] * X[i];
  }
  P = round(C_1 / N);
  res = N * pow(P, 2) - 2 * C_1 * P + C_2;
  // res = C_2 - pow(C_1, 2) / N;
  //
  // if ((long long)C_1 % (long long)N != 0) {
  //   res += N * pow((round(C_1 / N) - (C_1 / N)), 2);
  // }
  cout << (long long)res << endl;
}


Measured memory_bytes: 3784
N = int(input())
S = list(input())

m = ""
for i in range(ord('A'), ord('Z') + 1):
    m += chr(i)
S2 = []
for c in S:
    i = ord(c) - 65
    S2.append(m[(i + N) % len(m)])
print(''.join(S2))


Measured memory_bytes: 3188
#include <cstdio>

int main()
{
    int X;
    scanf("%d", &X);
    for (int A = 0; A < 120; ++A)
    {
        for (int B = 0; B < A; ++B)
        {
            int a5 = A * A * A * A * A;
            int b5 = B * B * B * B * B;
            if (a5 - b5 == X)
            {
                printf("%d %d", A, B);
                return 0;
            }
            else if (a5 + b5 == X)
            {
                printf("%d %d", A, -B);
                return 0;
            }
        }
    }
}


Measured memory_bytes: 1724