akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printdbl(a) printf("%lf\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int factorial(int a) {
    int ans = 1;
    for (int i = 1; i <= a; ++i) 
        ans *= i;
    return ans;
}

int main() {
    int n;
    scanInt(n);
    vector<int> p(n), q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<int> tmp1(n), tmp2(n);
    rep(i,n) {
        tmp1[i] = i + 1;
        tmp2[i] = i + 1;
    }
    int count1, count2, p1, p2;
    count1 = count2 = p1 = p2 = 0;
    while(!tmp1.empty()) {
        auto res = find(tmp1.begin(), tmp1.end(), p[p1]);
        count1 += (res - tmp1.begin()) * factorial(tmp1.size() - 1);
        p1++;
        tmp1.erase(res);
    }
    while(!tmp2.empty()) {
        auto res = find(tmp2.begin(), tmp2.end(), q[p2]);
        count2 += (res - tmp2.begin()) * factorial(tmp2.size() - 1);
        p2++;
        tmp2.erase(res);
    }
    printInt(abs(count2 - count1));
    return 0;
}

Measured memory_bytes: 3788
#include<stdio.h>
#include<math.h>
int main()
{
	int s,j;
	int i[101];
	i[0]=1;
	while(scanf("%d",&s)!=EOF)
	{
		int c=0;
		for(j=1;j<=s;j++)
		{
			i[j]=pow(2,j);
			if(i[j]>s)
			{
				c=i[j-1];
				break;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}


Measured memory_bytes: 128
from heapq import heappop, heappush, heapify
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  A = list(x for x in map(int, readline().split()))
  heapify(A)
  Alice = 0
  Bob = 0
  for i in range(N):
    if i%2==0:
      Alice += heappop(A)
    else:
      Bob += heappop(A)
  ans = abs(Alice-Bob)
  print(ans)
  
  
if __name__ == '__main__':
  main()

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


using namespace std;

#define ll long long

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	vector<int> a(N);
	bool ok=true;
	int ans=1e9;
	//O(N * LOG(MAX(a)))
	for(int& x : a) {
		cin >> x;
		if(x&1) ok=false;
		int cnt=0;
		while(x) {
			if(x&1) {
				ans=min(ans,cnt);
				break;
			}
			cnt++;
			x/=2;
		}
	}
	if(!ok) {
		puts("0");return 0;
	}else {
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main()
{
    int n ;
    int l ; 
    int s;
    cin >> n ;
    cin >> l ;
    cin >> s ;
    int x = 0;
    for (int i = 3 ; i++ ;){
     if (l == n and l==s and s==n  )
    {
        cout  << "No";break;
    }
    if (s!= l and s!=n and l!=n)
    {
        cout<< "No";break;
    }
    else {
        cout << "Yes";break;
    }   
    }
    

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
  int64_t N, K;
  cin >> N >> K;
  int64_t ans = pow(K-1,N-1)*K;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>

const float kProbability = 1.0f / 6.0f;
const int kMaxSquare = 128;
const int kMaxTurn = 128;	//30?§s?±????????????\W?¨???126??^??[???¬????¢?\???¬x

enum BoardState{
	BLANK, LOSE, BACK
};

BoardState board[kMaxSquare];

float bp(const int N, const int T){
	float prob[kMaxTurn][kMaxSquare];
	for (int i = 0; i <= T; i++)
		for (int j = 0; j <= N; j++)
			prob[i][j] = 0.0f;
	prob[0][0] = 1.0f;

	for (int t = 0; t < T; t++){
		for (int n = 0; n < N; n++){
			if (prob[t][n] == 0.0f) continue;
			for (int dice = 1; dice <= 6; dice++){
				int pos = (n + dice <= N) ? n + dice : N - (n + dice - N);
				switch (board[pos]){
				case BLANK:
					prob[t + 1][pos] += prob[t][n] * kProbability;
					break;
				case LOSE:
					prob[t + 2][pos] += prob[t][n] * kProbability;
					break;
				case BACK:
					prob[t + 1][0] += prob[t][n] * kProbability;
				}
			}
		}
	}

	float res = 0.0f;
	for (int i = 1; i <= T; i++)
		res += prob[i][N];
	return res;
}

int main(){
	while (1){
		int N, T, L, B;
		scanf("%d %d %d %d", &N, &T, &L, &B);
		if (N == 0) return 0;
		for (int i = 0; i <= N; i++) 
			board[i] = BLANK;
		for (; L > 0; L--){
			int l;
			scanf("%d", &l);
			board[l] = LOSE;
		}
		for (; B > 0; B--){
			int b;
			scanf("%d", &b);
			board[b] = BACK;
		}
		printf("%.6f\n", bp(N, T));
	}
}

Measured memory_bytes: 1124
// ITP1_6_A:   Reversing Numbers
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int i, n;
	short a[101];

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);
	if (n >= 1) printf("%d", a[n - 1]);
	for (i = n - 2; i >= 0; i--) printf(" %d", a[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n,pre,tmp,ans;
    cin>>n;
    pre=0;
    ans=0;
    for(int i=0  ;i<n  ;i++){
        cin>>tmp;
        if (pre<tmp){
            ans+=tmp-pre;
            pre=tmp;
        }else{
            pre=tmp;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
int mod = 1000000007;

//Typical DP

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

    vector<int> broken(N+1);
    REP(i, M){
        int a;
        cin >> a;
        broken[a] = 1;
    }

    vector<int> dp(N+2);
    dp[N] = 1;

    FORD(i, N-1, 0){
        if(broken[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % mod;
    }

    cout << dp[0] << endl;

    return 0;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define _for(i,j,k) for(int i=j;i<k;i++)
#define endl  '\n'
#define inf 0x3f3f3f3f
const int mod=1e9+7;
const int MAX=1e4+7;
//ll a[MAX],b[MAX];
int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	string s;
	 cin>>s;
	 int flag=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='7')
		{
			flag=1;
			break;
		}
	 } 
	 if(flag)cout<<"Yes";
	 else
	cout<<"No";
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
	int N, K;
	cin >> N;
	cin >> K;
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		int path = min(tmp, K - tmp);
		ans += 2 * path;
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi A(100001,0);
    rep(i,n){
        int a; cin>>a;
        A[a]++;
    }
    int ans,sum=0;
    rep(i,100001){
        sum+=max(A[i]-1,0);
    }
    ans = n-(sum+1)/2*2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())

if 400 <= N < 600:
  print(8)
elif 600 <= N < 800:
  print(7)
elif 800 <= N < 1000:
  print(6)
elif 1000 <= N < 1200:
  print(5)
elif 1200 <= N < 1400:
  print(4)
elif 1400 <= N < 1600:
  print(3)
elif 1600 <= N < 1800:
  print(2)
elif 1800 <= N < 2000:
  print(1)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int w,h,n;
int l[5];
P path[5][50];
bool dp[405][25][25][1<<6];
int fie[25][25];

int solve(int sx,int sy){
	memset(dp,false,sizeof(dp));
	
	int rect=0;
	for(int a=0;a<n;a++){
		P p=path[a][0];
		if(p.first==sy && p.second==sx)rect+=(1<<a);
	}
	dp[0][sy][sx][rect]=true;
	for(int i=0;i<=w+h+1;i++){
		for(int bit=0;bit<(1<<n);bit++){
			for(int j=0;j<h;j++){
				for(int k=0;k<w;k++){
					if(!dp[i][j][k][bit])continue;
					//printf("%d %d %d %d\n",i,j,k,bit);
					if((bit+1)==(1<<n))return i;
					for(int a=-1;a<=1;a++){
						for(int b=-1;b<=1;b++){
							int nj=j+a;
							int nk=k+b;
							if(nj<0 || nj>=h || nk<0 || nk>=w)continue;
							if(fie[nj][nk]==-1)continue;
							int rec=0;
							for(int g=0;g<n;g++){
								if(bit>>g & 1)continue;
								P p=path[g][i+1];
								if(p.first==nj && p.second==nk)rec+=(1<<g);
							}
							dp[i+1][nj][nk][bit+rec]=true;
						}
					}
				}
			}
		}
	}
	return -1;
}

int main(void){
	scanf("%d%d%d",&w,&h,&n);
	int sx,sy;
	scanf("%d%d",&sx,&sy);
	sx--;
	sy--;
	for(int i=0;i<n;i++){
		scanf("%d",&l[i]);
		for(int j=0;j<l[i];j++){
			P p;
			scanf("%d%d",&p.second,&p.first);
			p.second--;
			p.first--;
			path[i][j]=p;
			if((j+1)==l[i]){
				fie[p.first][p.second]=-1;
				path[i][j]=P(-1,-1);
			}
		}
		for(int j=l[i];j<50;j++){
			path[i][j]=P(-1,-1);
		}
	}
	printf("%d\n",solve(sx,sy));
	return 0;
}


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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	int p[n],q[n];
	for(int i=0;i<n;i++){
		cin >> p[i];
		q[i] = p[i];
	}
	string ans = "NO";
	// keisan
	sort(q,q+n);
	for(int i=0;i<n;i++){
		if(p[i] != q[i]){
			break;
		}
		if(i == n-1){
			ans = "YES";
		}
	}
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			for(int k=0;k<n;k++){
				int tmp;
				tmp = k;
				if(k == i){
					tmp = j;
				}
				if(k == j){
					tmp = i;
				}
				if(q[k] != p[tmp]){
					break;
				}
				if(k == n-1){
					ans = "YES";
				}
			}
		}
	}
	// syutsuryoku
	cout << ans << endl;
}

Measured memory_bytes: 3616
X = int(input())

def is_prime(q,k=100):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    for i in range(3,k):
        x,y = q,i
        while y:
            x, y =  y, x % y
        if x != 1: continue
        if pow(i, q-1, q) != 1:
            return False
    return True

for i in range(X, 100100):
    if(is_prime(i)):
        print(i)
        exit()

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll N, K; 
  cin >> N >> K;

  string S;
  cin >> S;

  ll lb;
  lb = S[0] - '0';

  ll cnt = 1;
  vector<ll> v;


  if (S[0] == '0') v.push_back(0);
  for (ll i = 1; i < N; i++) {
    if(S[i] - '0' == lb) cnt++;
    else {
      v.push_back(cnt);
      lb = S[i] - '0';
      cnt = 1;
    }
  }
  v.push_back(cnt);
  if(S[N-1] == '0') v.push_back(0);

  ll ans = 0;
  ll sum = 0;
  ll num = (v.size()-1) / 2;
  num = min(K, num);

  for (int i = 0; i < num; i++) {
    sum += v[2*i];
    sum += v[2*i + 1];
  }
  sum += v[2*num];
  ans = sum;

  num = (v.size()-1)/2 - K + 1;
  if(num < 0) num = 0;
  for (int i = 1; i < num; i++) {
    sum -= v[2*i-2];
    sum -= v[2*i-1];
    sum += v[2*(i+K)-1];
    sum += v[2*(i+K)];
    ans = max(ans, sum);
  }
  
  cout << ans << endl;    

  return 0;
}



Measured memory_bytes: 4012
n = int(input())
x_list = list(map(int,input().split()))

ans_list = [0] * (max(x_list)+1)

for j in range(1, max(x_list)+1):
    ans = 0
    for i in range(0, n):
        ans += (x_list[i] - j) ** 2
    ans_list[j] = ans

ans_list.remove(0)
print(min(ans_list))

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	n, _ := strconv.Atoi(input())
	k, _ := strconv.Atoi(input())
	h := make([]int, n+1)
	for i := 1; i <= n; i++ {
		h[i], _ = strconv.Atoi(input())
	}

	dp := make([]int, n+1)
	dp[1] = 0
	for i := 2; i <= n; i++ {
		minv := dp[i-1] + abs(h[i]-h[i-1])
		jMax := min(k, i-1)
		for j := 2; j <= jMax; j++ {
			minv = min(minv, dp[i-j]+abs(h[i]-h[i-j]))
		}
		dp[i] = minv
	}
	fmt.Println(dp[n])
}


Measured memory_bytes: 2816
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int r = stdIn.nextInt();
		int D = stdIn.nextInt();
		int x = stdIn.nextInt();
		
		for(int i = 0; i < 10; i++) {
			x = r*x - D;
			System.out.println(x);
		}

	}

}

Measured memory_bytes: 21716
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long A = sc.nextLong();
		String s = sc.next();
		
		long B = 0;
		int dotIndex = s.indexOf('.');
		int d = 0;
		if(dotIndex>=0) {
			B = Long.valueOf(s.substring(0, dotIndex) + s.substring(dotIndex+1));
			d = s.length() - dotIndex-1;
		} else {
			B = Long.valueOf(B);
			d = 0;
		}
		
		long ans = A*B;
		for(int i=0; i<d; i++)
			ans /= 10;

		System.out.println(ans);
		sc.close();
	}
}


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

using u128 = __uint128_t;

#define int long long
#define idxSet tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define atIdx find_by_order
#define idxOf order_of_key
#define MOD 1000000007
#define MAX 200005
#define endl '\n'

#define v(type) vector<type>
#define p(type1, type2) pair<type1 , type2>
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

int dp[MAX];

void get_all_primes(int upto_primes, vector<int> &primes){
    primes.clear();
    vector < bool > mark(upto_primes +2,true);

    for(int i=3 ; i * i <= upto_primes ; i+=2){
        if(mark[i]){
            for(int j=i*i ; j<=upto_primes ; j+=2*i){
                mark[j]=false;
            }
        }
    }
    primes.push_back(2);
    for(int i=3 ; i<=upto_primes ; i+=2 ){
        if(mark[i]){
            primes.push_back(i);
        }
    };
}
void solve() {
    vi primes;
    get_all_primes(3001 , primes);
    int n;
    cin>>n;
    map<int,int> p;
    for(int i = 1 ; i <= n ; i++){
        int k = i;
        for(int j = 0 ; primes[j] * primes[j] <= k ; j++){
            while(k % primes[j] == 0){

                p[primes[j]]++;
                k /= primes[j];
            }
        }
        if(k != 1){
            p[k]++;
        }

    }
    int ans = 1 ;
    for(auto i : p){
        ans *= (i.second + 1);
        ans %= MOD;
    }
    cout<<ans<<endl;

}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left, int mid, int right) {
  int n1 = mid -left;
  int n2 = right - mid;
// C++for??????????°???¨???int????????£?¨???§??????
// ???????????????????????????????????§?????¨
  for(int i=0;i<n1;i++) L[i] = A[left + i];
  for(int i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i=0, j=0;
  for(int k=left; k<right; k++) {
    cnt++;
    if(L[i]<=R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

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

int main() {
  int A[MAX], n, i;
  cnt = 0;

	cin >> n; // scanf("%d",&n);
  for(i=0;i<n;i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i)cout << " ";
    cout << A[i];
  }
  cout << endl; // endl?????????

  cout << cnt << endl; // printf("\n");

  return 0;
}

Measured memory_bytes: 6988
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n; cin >> n;
    list<int> b;
    int cnt = 0;
    rep(i, n) {
        cnt++;
        int a; cin >> a;
        if(i % 2 == 0) b.push_back(a);
        else b.push_front(a);
    }
    if(cnt % 2 == 1) reverse(all(b));
    int i = 0;
    for(int a: b) {
        if(i != 0) cout << " ";
        cout << a;
        i++;
    }
    cout << endl;
    return 0;
}


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

int main(){
  vector<vector<int>> c(3, vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> c[i][j];
    }
  }
  string A,B;
  for(int i=0;i<2;i++){
      int a = c[i+1][0]-c[i][0];
      int b = c[i+1][1]-c[i][1];
      int d = c[i+1][2]-c[i][2];
      if(a != b || a !=d){
        B = "No";
        break;
      }
  }
  for(int i=0;i<2;i++){
      int a = c[0][i+1]-c[0][i];
      int b = c[1][i+1]-c[1][i];
      int d = c[2][i+1]-c[2][i];
      if(a != b || a !=d){
        B = "No";
        break;
      }
  }
  if(A == "No" || B == "No"){
    cout << "No" <<endl;
  }else{
    cout << "Yes" <<endl;
  }
}

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


int main() {
    ll a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    if(a>=k){
        ans+=k;
        k-=k;
        
    }
    else if(a<k){
        ans+=a;
        k-=a;
    }
    
    if(b>=k){
        ans+=0;
        k-=k;
        
    }
    else if(b<k){
        ans+=0;
        k-=b;
    }
     if(c>=k){
        ans-=k;
        k-=k;
        
    }
    else if(c<k){
        ans-=c;
        k-=c;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3636
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b = readInts()
print('+' if a + b == 15 else('*' if a*b == 15 else 'x'))


Measured memory_bytes: 5276
import collections
N = int(input())
A = list(map(int,input().split()))
count_dict = collections.Counter(A)
d = []
for k,v in count_dict.items():
	d.append([k,v])

d.sort(reverse=True)
ans = []
for i in range(len(d)):
	if d[i][1] >= 2:
		ans.append(d[i])
	if len(ans) == 2:
		break
ans += [[0]*2]*2
if ans[0][1] >= 4:
	print(ans[0][0]**2)
else:
	print(ans[0][0]*ans[1][0])

Measured memory_bytes: 24100
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	if k == 0 {
		fmt.Println(n * n)
		return
	}

	ans := 0
	for b := k + 1; b <= n; b++ {
		ans += (b - k) * (n / b)
		if n%b > 0 && n%b > k-1 {
			ans += n%b - (k - 1)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int n,x[100005],a=0;
	long long s[2];
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x[i];
	}
	sort(x,x+n);
	for(int i=n-1;i>0;i--){
		if(x[i]==x[i-1]){
			s[a]=x[i];
            a++;
			i--;
			if(a==2){
				cout << s[0]*s[1] << endl;
				return 0;
			}
		}
	}
	cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int a;
  cin>>a;
  cout<<a*a*a+a*a+a<<endl;
  return(0);
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 1; i <= k; i++){
        a *= i;
    }
    return a;
}
int main(){
    intl n;
    cin >> n;
    intl a[n];
    cin(i,a);
    map <intl,intl> m;
    rep(i,n){
        m[a[i]]++;
    }
    intl cnt = 0;
    for(auto i :m){
        cnt += (i.second * (i.second - 1))/2;
    }
    rep(i,n){
        cnt -= m[a[i]]*(m[a[i]]-1)/2;
        cnt += (m[a[i]]-1)*(m[a[i]]-2)/2;
        cout << cnt << endl;
        cnt += m[a[i]]*(m[a[i]]-1)/2;
        cnt -= (m[a[i]]-1)*(m[a[i]]-2)/2;
    }
    return 0;
}

Measured memory_bytes: 11008
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll x,y;
	cin>>x>>y;
	cout<<(abs(x-y)<=1?"Brown":"Alice")<<endl;	
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int w = in.nextInt();
        int[][] a = new int[2][n];
        for (int i = 0; i < n; i++) {
            a[0][i] = in.nextInt();
            a[1][i] = in.nextInt();
        }

        long[][] dp = new long[n + 1][w + 1];

        for (int i = 0; i < n; i++) {
            for (int j = 0; j <= w; j++) {
                if (j >= a[0][i]) {
                    dp[i + 1][j] = Math.max(dp[i][j - a[0][i]] + a[1][i], dp[i][j]);
                } else {
                    dp[i + 1][j] = dp[i][j];
                }
            }
        }

        out.println(dp[n][w]);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 126164
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
#include <atcoder/all>

using namespace std;
using namespace atcoder;
typedef long long ll;

/*
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
void Add(ll &pos,ll val){pos=mod(pos+val);}
void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
*/

#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

typedef long double dd;
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second

#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;


//using mint = modint998244353;
using mint = modint1000000007;
//////////////////////////



int main(){fastio
    string s;cin>>s;
    auto sa=suffix_array(s);
    for(auto x:sa){
        //cout<<x<<":"<<s.substr(x,s.size())<<endl;
    }
    auto la=lcp_array(s,sa);
    ll n=s.size();
    ll ans=n*(n+1)/2;
    for(auto x:la){
        //cout<<x<<endl;
        ans-=x;
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 15600
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int cnt[200010][20];
int main() {
	int N; cin >> N;
	vector<int> vals(N);
	for (int i = 0; i < N; i++) cin >> vals[i];
	for (int i = 0; i < N; i++) for (int j = 0; j < 20; j++) if (vals[i] & (1 << j)) cnt[i][j] = 1;
	for (int i = 1; i < N; i++) for (int j = 0; j < 20; j++) cnt[i][j] += cnt[i - 1][j];
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		int lo = 0, hi = i;
		while (lo < hi) {
			int mid = (lo + hi) >> 1;
			bool possib = true;
			for (int j = 0; j < 20; j++) if (cnt[i][j] - (mid - 1 >= 0 ? cnt[mid - 1][j] : 0) > 1) {
				possib = false;
				break;
			}
			if (possib) hi = mid;
			else lo = mid + 1;
		}
		ans += i - hi + 1;
	}
	cout << ans << endl;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for(int i=1; i<=N; i++){
        int n = i, t = 0;
        while(n < K){
            n *= 2;
            t++;
        }
        ans += pow(0.5, t);
    }
    ans /= N;
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
int main()
{
	long long k;
	cin >>k;
	queue<long long>q;
	for(int i=1;i<=9;i++)
	q.push(i);
	while(!q.empty())
	{
		long long x=q.front();
		q.pop();
		k--;
		if(k==0)
		{
			cout <<x<<endl;
			break;
		}
		for(int y=(x%10)-1;y<=(x%10)+1;y++)
		{
			if(y<0||y>=10)
			continue;
			q.push(x*10+(long long)y);
		}
	}
	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

template<class T> class segtree{
public:
    int n;
    vector<T> dat,sum; //区間の和,区間に一様に足された値
    segtree(int size,T x){
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,0);
        sum.assign(2*n-1,0);
        add(0,size,x);
    }
    void add(int a,int b,T x){ add(a,b,x,0,0,n); }
    T add(int a,int b,T x,int k,int l,int r){
        if(b<=l or r<=a) return dat[k];
        if(a<=l and r<=b){
            sum[k]+=x;
            return dat[k]+=x;
        }
        int m=(l+r)/2;
        return dat[k]=max(add(a,b,x,2*k+1,l,m),add(a,b,x,2*k+2,m,r))+sum[k];
    }
    T query(int a,int b){ return query(a,b,0,0,n); }
    T query(int a,int b,int k,int l,int r){
        if(b<=l or r<=a) return -inf64;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return max(query(a,b,2*k+1,l,m),query(a,b,2*k+2,m,r))+sum[k];
    }
};

void solve(){
    i64 N,M;
    cin >> N >> M;
    
    vector<pair<i64,i64>> ps;
    rep(i,0,N){
        i64 L,R;
        cin >> L >> R;
        ps.push_back(make_pair(L,R));
    }
    sort(ps.begin(),ps.end());

    segtree<i64> seg(M+2,0);
    rep(i,1,M+1) seg.add(0,i+1,-1);
    i64 ans=0,k=1;
    for(auto &p:ps){
        i64 l=p.first,r=p.second;
        while(k<=l){
            seg.add(k+1,M+2,-1);
            ++k;
        }
        seg.add(0,r+1,1);
        ans=max(ans,seg.query(0,M+2));
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 12652
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5;
struct wjmzbmr
{
    int c0,c1,id;
    wjmzbmr(){}
    wjmzbmr(int a,int b,int c):c0(a),c1(b),id(c) {}
    bool operator < (const wjmzbmr& x) const
    {
        if(1LL*c0*x.c1!=1LL*c1*x.c0) return 1LL*c0*x.c1>1LL*c1*x.c0;
        return id<x.id;
       // return 1LL*c0*x.c1>=1LL*c1*x.c0;
    }
    /*bool operator == (const wjmzbmr &x) const
    {
        return c0==x.c0&&c1==x.c1&&id==x.id;
    }*/
}a[maxn+5];
int p[maxn+5],f[maxn+5],tmp[maxn+5],tail[maxn+5],nx[maxn+5],c0[maxn+5],c1[maxn+5],d[maxn+5];
int n,root;
int b[maxn+5];
int c[maxn+5];
long long ans=0;
multiset<wjmzbmr> s;
int find(int x)
{
    if(f[x]==x) return f[x];else return f[x]=find(f[x]);
}
int main()
{

    scanf("%d",&n);
    for(int i=2;i<=n;++i) scanf("%d",&p[i]);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",&tmp[i]);
        f[i]=i,tail[i]=i;
        if(tmp[i]==0) a[i]={1,0,i},c0[i]=1;else a[i]={0,1,i},c1[i]=1;
        if(i>=2)
        s.insert(a[i]);
    }
    while(s.size()>0)
    {
        wjmzbmr x=*s.begin();
        s.erase(s.begin());
        int u=x.id;

        int v=find(p[x.id]);
       // printf("ce : %d %d\n",u,v);
       // printf("%d %d %d\n",c0[v],c1[v],v);
        nx[tail[v]]=u;
        ++d[u];
        f[u]=v,tail[v]=tail[u];
       // printf("ok\n");
       // for(auto x:s) printf("wmr : %d %d %d\n",x.c0,x.c1,x.id);
       //  printf("%d %d %d\n",c0[v],c1[v],v);
        //if(s)
        if(v!=1) s.erase(s.find(wjmzbmr(c0[v],c1[v],v)));
        c0[v]+=c0[u],c1[v]+=c1[u];
        if(v!=1) s.insert(wjmzbmr(c0[v],c1[v],v));
    }
    for(int i=1;i<=n;++i)
        if(d[i]==0)
        {
            root=i;
            break;
        }
    for(int i=1;i<=n;++i,root=nx[root])
    {
        b[i]=tmp[root];
        //printf("%d ",root);
    }

    int now=0;
    for(int i=n;i>=1;--i)
        if(b[i]==1) ans+=now;else now+=1;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.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(){
  int n,l;
  cin>>n>>l;
  vector<string>s(n);
  rep(i,n)cin>>s[i];
  sort(s.begin(),s.end());
  string ans="";
  rep(i,n)ans=ans+s[i];
  cout<<ans<<endl;
    
    
  return 0;
}


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

int main(){
	int n,s = 0;
	while(cin >> n && n > 0){
		int result = 0;
		vector<int> buf;
		for(int i = 0;i < n;i++){
			cin >> s;
			buf.push_back(s);
			result += s;
		}
		int min = *min_element(buf.begin(),buf.end());
		int max = *max_element(buf.begin(),buf.end());
		cout << (result - (min+max)) / (n-2) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3052
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        int N = NK[0];
        int K = NK[1];
        var D = ReadLine().Split().Select(_=>_[0]).ToArray();
        while (true)
        {
            bool frag = true;
            string S = N.ToString();
            for (int i = 0; i < K; i++)
            {
                if (S.Contains(D[i]))
                {
                    frag = false;
                    break;
                }
            }

            if (frag)
            {
                WriteLine(S);
                return;
            }
            N++;
        }
    }
}


Measured memory_bytes: 30816
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long LL;
int main()
{
	int a,b,c;
	LL k;
	scanf("%d %d %d %lld",&a,&b,&c,&k);
	if(k%2==0)
		printf("%d\n",a-b);
	else
		printf("%d\n",b-a);
	return 0;
}

Measured memory_bytes: 128
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e5+5;
vc <vc <ll> > adj;
vc <ll> dp;
vc <int> vis;
ll ans = 0;
void dfs(ll node) {
    vis[node]++;
    for(auto i: adj[node]) {
        if(!vis[i]) dfs(i);
        dp[node] = max(dp[i] + 1, dp[node]);
        ans = max(ans, dp[node]);
    }
}

int32_t main(){
    FastIO;
    int n, m;
    cin >> n >> m;
    adj.resize(n+1),dp.assign(n+1, 0), vis.assign(n+1, 0);
    for(int i=0; i<m; i++) {
        ll x, y;
        cin >> x >> y;
        adj[x].pb(y);
    }
    for(int i=1; i<=n; i++) {
        if(!vis[i]) dfs(i);
    }
    cout << ans << endl;
    // cout << dp << endl;
    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<ll> a(n);
	vector<ll> b(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	for(int i = 0; i < n; i++) {
		cin>>b[i];
	}
	ll sum = 0;
	for(int i = 0; i < n; i++) {
		if (b[i] >= a[i]){
			sum += (b[i] - a[i]) / 2;
		}
		else{
			sum += (b[i] - a[i]);
		}
	}
	if (sum >= 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  ll n; cin >> n;

  ll ans = 0;
  ll max = 0;

  rep(i,n){
    ll a; cin >> a;
    if(a>=max){
      max = a;
    }else{
      ans+=max-a;
    }
  }

  cout << ans <<endl;

}


Measured memory_bytes: 3564
from math import *

N, P = [int(s) for s in input().split()]

A = [int(e) for e in input().split()]

counter = [0, 0]

for a in A:
    counter[a % 2] += 1

even = 0

def nCk(n, k):
    res = 1
    for i in range(k):
        res *= (n - i)
    res //= factorial(k)
    return res

for c in range(counter[0] + 1):
    even += nCk(counter[0], c)

ans = 0
if P == 0:
    for i in range(0, counter[1] + 1, 2):
        ans += nCk(counter[1], i) * even
else:
    for i in range(1, counter[1] + 1, 2):
        ans += nCk(counter[1], i) * even

print(ans)


Measured memory_bytes: 3316
a,b = map(int,input().split())
ans = 0
if b-a<=10:
    for i in range(a,b+1):
        ans ^= i
else:
    while a % 4 != 0:
        ans ^= a
        a += 1
    while b % 4 != 3:
        ans ^= b
        b-= 1
print(ans)

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m;
   cin>>n>>m;
   int arr[n+1];
   double sum=0;
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
       sum+=arr[i];
   }
  
   int count=0;
   
   for(int i=0;i<n;i++)
   {
       if(arr[i]>=(sum/(4*m)))
       {
           count++;
       }
      
   }
   if(count<m)
   {
       cout<<"No";
   }
   else
   {
       cout<<"Yes";

   }
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    string s;
    int D;
    cin >> N >> s >> D;
    
    vector<int> vis(N, 0);
    
    rep(i, N){
        if (s[i] == '0' && D > 0) {
            D--;
            s[i] = '1';
            vis[i] = 1;
        }
    }
    for (int i = N - 1; i >= 0; i--) {
        if (s[i] == '1' && D > 0 && vis[i] == 0) {
            D--;
            s[i] = '0';
        }
    }
    
    output(s, 0);
    return 0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define REP(i, a, b)  for(LL i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(LL i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const long long maxn = 100000 + 10;
 
template<typename T> T read() {
	T n(0), f(1);
	char ch = getchar();
	for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}
 
long long N, P;
long long s[2];
long long C[100][100];

void init() {
    for(long long i = 0; i < 100; i++) {
        C[i][0] = C[i][i] = 1;
        for(long long j = 1; j < i; j++) 
            C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
}

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif

    init();
 
    cin >> N >> P;
    for(long long i = 0; i < N; i++) {
        long long x = read<LL>();
        ++ s[x & 1];
    }

    long long T1 = 0, T2 = 0;
    long long ans = (long long)(pow(2, s[0]) + 0.1);

    for(int i = 0; i <= s[1]; i += 2) { T1 += C[s[1]][i]; }
    for(int i = 1; i <= s[1]; i += 2) { T2 += C[s[1]][i]; }

    if(P == 0) 
        ans *= T1;
    else 
        ans *= T2;

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 512
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    K, X = input_nums()
    a = [x for x in range(K*2-1)]
    m = a[len(a)//2]
    d = m - X
    print(*[x - d for x in a])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
    using namespace std;
    int main(){
        int N=0, count, ans=1;
        cin >> N;
        for(int i=0;;i++){
            if(N != 0){
                ++count;
                N /= 2;
                }
            else  break;
        }
        for(int i=0;i < count-1; i++){
            ans *= 2;
        }
        cout << ans <<endl;
    }

Measured memory_bytes: 256