akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll a[101010];
struct UnionFind{
   vector<int> par,cnt;
   vector<ll> sum;
   UnionFind(int n):par(n,-1),sum(n),cnt(n){
       rep(i,n)sum[i]=a[i];
   }
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y){
           ++cnt[x];
           return false;
       }
       if(par[x]>par[y]){
           par[y]+=par[x];
           sum[y]+=sum[x];
           cnt[y]+=cnt[x]+1;
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           sum[x]+=sum[y];
           cnt[x]+=cnt[y]+1;
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   ll get(int x){
       return sum[find(x)];
   }
};

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n)cin>>a[i];
    int l[m],r[m],w[m];
    rep(i,m){
        cin>>l[i]>>r[i]>>w[i];
        --l[i];--r[i];
    }
    vector<int> ord(m);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int x,int y){
        return w[x]<w[y];
    });
    UnionFind uf(n);
    int ans=0;
    for(auto idx:ord){
        uf.unite(l[idx],r[idx]);
        if(uf.get(l[idx])>=w[idx]){
            int x=uf.find(l[idx]);
            ans+=uf.cnt[x];
            uf.cnt[x]=0;
        };
    }
    cout<<m-ans<<endl;
    return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int test[12345]; int uiop[12345][12345];
int main() {
	long long n, m, k, l, a = 0, b = 0, c = 1; cin >> n >> m >> k;
	for (int h = 0; h < k; h++) {
		cin >> l; test[h] = l;
	}
	for (int h = 0; h < n; h++) {
		if (h % 2 == 0) {
			for (int i = 0; i < m; i++) {
				uiop[h][i] = c; a++;
				if (test[b] == a) { a = 0; b++; c++; }
			}
		}
		else {
			for (int i = m - 1; i >= 0; i--) {
				uiop[h][i] = c; a++;
				if (test[b] == a) { a = 0; b++; c++; }
			}
		}
	}
	for (int h = 0; h < n; h++) {
		for (int i = 0; i < m; i++) {
			cout << uiop[h][i] << ' ';
		}
		cout << endl;
	}
	cin >> n;
}

Measured memory_bytes: 4608
N = int(input())
p = [int(i) for i in input().split()]

count = 0

for i in range(N):
    if p[i] == i+1:
        count += 1
        if i != N - 1:
            tmp = p[i]
            p[i] = p[i+1]
            p[i+1] = tmp
        else:
            tmp = p[i]
            p[i] = p[i-1]
            p[i-1] = tmp
print(count)

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

#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>

int N, K;
int mod = 1000000007;

signed main()
{
    cin >> N >> K;
    int l = 0, r = 0;
    int ans = 0;
    for(int i = 0; i < K - 1; i++)
    {
        l += i;
        r += N - i;
    }
    for(int i = K; i <= N + 1; i++)
    {
        l += i - 1;
        r += N - i + 1;
        ans = (r - l + 1 + ans) % mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
template<class Abel> struct WeightedUnionFind {
    vector<ll> par;
    vector<ll> rank;
    vector<Abel> diff_weight;

    WeightedUnionFind(ll n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(ll n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (ll i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    ll root(ll x) {
        if (par[x] == x) {
            return x;
        }
        else {
            ll r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(ll x) {
        root(x);
        return diff_weight[x];
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    bool unite(ll x, ll y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(ll x, ll y) {
        return weight(y) - weight(x);
    }
};
int main(){
    ll n,m;
    cin >> n >> m;
    WeightedUnionFind<int> a(n); 
    ll l,r,w;
    bool out = 0;
    rep(i,m){
        cin >> l >> r >> w;
        --l;--r;
        if (a.same(l,r)){
            if (a.diff(l,r) != w) out = 1;
        }
        else a.unite(l,r,w);
    }
    if (out) PRINT("No");
    else PRINT("Yes");
}

Measured memory_bytes: 2176
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	cout << abs(a - b) << endl;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if ( A == 5 && B == 5 && C == 7 ) {
    cout << "YES" << endl;
  }
  else if ( A == 5 && B == 7 && C == 5 ) {
    cout << "YES" << endl;
  }
  else if ( A == 7 && B == 5 && C == 5 ) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  
}


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

using namespace std;

int main(void)
{
    string s;
    cin>>s;
    int len = s.length();
    if(s[len-1]=='s')
    {
        cout<<s<<"es\n";
    }
    else
    {
        cout<<s<<"s\n";
    }
    
    return 0;
}

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


long long N;

void read() {
    cin >> N;
}


void work() {
    if (N % 2 == 1) {
        cout << 0 << endl;
        return;
    }
    
    long long ans = N / 10;

    N /= 10;
    while (N >= 5) {
        ans += N / 5;
        N /= 5;
    }
    
    cout << ans << endl;
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N;
    cin >> N;
    int o = 0, e = 0;
    rep(i, N) {
        int A;
        cin >> A;
        A % 2 == 0 ? e += 1 : o += 1;
    }
    cout << (o % 2 == 0 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define inf 1e18+9
using namespace std;
const int N=200009;
int a[N];
int n,k,ans=-1,z=0;
vector <int> p,m;
int count(int s){
	int sum=0;
	if(s>=0){
		sum+=z*(p.size()+m.size())+p.size()*(long long)m.size()+z*(z-1)/2;
		int i=0,j=(long long)p.size()-1;
		while(i<j){
			while(j>=0 and p[j]*p[i]>s)j--;
			sum+=max(j-i,0ll);
			i++;
		}
		i=0,j=(long long)m.size()-1;
		while(i<j){
			while(j>=0 and m[j]*m[i]>s)j--;
			sum+=max(j-i,0ll);
			i++;
		}
	}
	else if(s<0){
		int i=0,j=m.size()-1;
		while(i<p.size()){
			while(j>=0 and i<p.size() and m[j]*p[i]>=-s)j--;
			sum+=j+1;
			i++;
		}
		sum=p.size()*(long long)m.size()-sum;
	}
	return sum;
}
int32_t main(){
	if(fopen("input.txt", "r"))
		freopen("input.txt", "r", stdin),
		freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]>0)p.push_back(a[i]);
		else if(a[i]<0)m.push_back(-a[i]);
		else z++;
	}
	sort(p.begin(),p.end());
	sort(m.begin(),m.end());
	int lo=-inf,hi=inf;
	while(hi>=lo){
		int mid=(hi+lo)/2;
		int c=count(mid),d=count(mid-1);
		if(c>=k){
			ans=mid;
			hi=mid-1;
		}
		else lo=mid+1;
		// if(c>=k and d<k){
		// 	ans=mid;
		// 	break;
		// }
		// else if(c<k)lo=mid+1;
		// // else if(c==d and c>=k)
		// // 	hi=mid;
		// else hi=mid-1;
	}
	// int p=-inf;
	// for(int i=0;i<n;i++){
	// 	if(!a[i])continue;
	// 	int x=ans/a[i];
	// 	if(x>=a[i])continue;
	// 	int l=upper_bound(a,a+n,x)-a;
	// 	p=max(p,a[i]*a[l-1]);
	// }
	cout << ans ;
	// cout << count(0) << endl;
}

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

struct S{
    int u, v, w;
};

int main(){
    int l;
    cin >> l;
    int r = 0;
    for(int i = 19; i >= 0; i--){
        if(l & (1 << i)){
            r = i; break;
        }
    }
    vector<S> G;
    for(int i = 0; i < r; i++){
        G.push_back({i, i + 1, 1 << i});
        G.push_back({i, i + 1, 0});
    }
    int rest = l - (1 << r);
    int tmp = 1 << r;
    for(int i = r - 1; i >= 0; i--){
        if(rest & (1 << i)){
            rest -= 1 << i;
            G.push_back({i, r, tmp});
            tmp += 1 << i;
        }
    }
    cout << r + 1 << ' ' << G.size() << endl;
    for(int i = 0; i < G.size(); i++){
        cout << G[i].u + 1 << ' ' << G[i].v + 1 << ' ' << G[i].w << endl;
    }
}

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

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

  vector<string> vec;
  set<string> st;
  for (int i = 0; i < s.size(); i++)
  {
    for (int j = 1; j <= 5; j++)
    {
      if(i+j>s.size()) break;
      st.insert(s.substr(i,j));
    }
  }
  for(auto x:st){
    vec.push_back(x);
  }
  sort(vec.begin(),vec.end());

  cout << vec[k-1] << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;
const ll C = 1e9+7; //10の9乗

ll F(ll A, ll B) {
    return max(log10(A)+1, log10(B)+1);
}

int main(){
    ll N;
    cin >> N;
    ll min_value = INF;

    for(ll i=1; i * i <= N; i++) {
        if(N % i == 0) {
            ll B = N / i;
            min_value = min(min_value, F(i, B));
        }
    }
    cout << min_value << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll ans=0;
    vector<char>memo;
    ll n,k;cin >>n>>k;
    ll r,s,p;cin >>r>>s>>p;
    string t;cin >>t;
    for (int i = 0; i < n; ++i) {
        if(i<k){
            if(t[i]=='r'){
                ans+=p;
                memo.push_back('p');
            }
            else if(t[i]=='s'){
                ans+=r;
                memo.push_back('r');
            }
            else {
                ans+=s;
                memo.push_back('s');
            }
        }
        else {
            if(t[i]=='r'){
                if(memo[i-k]=='p'){
                    memo.push_back('a');
                }
                else {
                    ans += p;
                    memo.push_back('p');
                }
            }
            else if(t[i]=='s'){
                if(memo[i-k]=='r'){
                    memo.push_back('a');
                }
                else {
                    ans += r;
                    memo.push_back('r');
                }
            }
            else {
                if(memo[i-k]=='s'){
                    memo.push_back('a');
                }
                else {
                    ans += s;
                    memo.push_back('s');
                }
            }
        }
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>;
#include<vector>
#include<algorithm>
using namespace std;
int ceil(int a) {
    int b = a / 10;
    int c = a % 10;
    if(c == 0) {
        return b * 10;
    } else {
        return (b + 1) * 10;
    }
}
bool func(int i, int k) {
    int a = ceil(i);
    int b = ceil(k);
    return a - i < b - k;
}
int main() {
    int a[5];
    vector<int> as;
    for(int i = 0; i < 5; i++) {
        cin>>a[i];
        as.push_back(a[i]);
    }
    sort(as.begin(), as.end(), func);
    int res = 0;
    for(int i = 0; i < 4; i++) {
        res += ceil(as[i]);
    }
    res += as[4];
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
declare var require: (x: string) => any;

const MOD = 1000000007;

function mul(x: number, y: number){
  if (x == 1) return y;
  if (y == 1) return x;
  if (x == 0 || y == 0) return 0;
  let ans = 0;
  while(y > 0){
    ans += x * (y%1000) % MOD;
    ans %= MOD;
    x = x * 1000 % MOD;
    y = Math.floor(y/1000);
  }
  return ans;
}

function Main(input: string[]) {
  const s = input[0];
  const n = s.length;

  let aa = new Uint32Array(n);
  let cc = new Uint32Array(n);
  let qq = new Uint32Array(n);

  let totalq = s[0]=='?' ? 1 : 0;

  aa[0] = s[0]=='A' ? 1 : 0;
  qq[0] = s[0]=='?' ? 1 : 0;
  for(let i = 1; i < n; i++){
    if (s[i] == 'A'){
      aa[i] = aa[i-1] + 1;
    } else {
      aa[i] = aa[i-1];
    }

    if(s[i] == '?'){
      qq[i] = qq[i-1] + 1;
      totalq++;
    } else {
      qq[i] = qq[i-1];
    }
  }

  cc[n-1] = s[n-1]=='C' ? 1 : 0;
  for(let i = n - 2; i >= 0; i--){
    if (s[i] == 'C'){
      cc[i] = cc[i+1] + 1;
    } else {
      cc[i] = cc[i+1];
    }
  }

  let pow3 = new Uint32Array(n);
  pow3[0] = 1;
  for(let i = 1; i < n; i++) {
    pow3[i] = pow3[i-1]*3;
    while(pow3[i] >= MOD) pow3[i] -= MOD;
  }

  let ans = 0;
  for (var i = 1; i < n-1; i++) if(s[i]=='?' || s[i]=='B'){
    let lv = mul(aa[i-1], pow3[qq[i-1]]);
    if(qq[i-1] > 0) lv += mul(qq[i-1], pow3[qq[i-1]-1]);
    lv %= MOD;

    let rq = totalq - qq[i];
    let rv = mul(cc[i+1], pow3[rq]);
    if(rq > 0) rv += mul(rq, pow3[rq - 1]);
    rv %= MOD;

    ans += mul(lv, rv);
    ans %= MOD;
  }

  console.log(ans);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));


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

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

Measured memory_bytes: 3580
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();

        if ((A1 + A2 + A3) >= 22) {
            System.out.println("bust");
        } else {
            System.out.println("win");
        }

        sc.close();
    }
}

Measured memory_bytes: 21716
/* AIZU ITP1_4_A */
import java.io.*;

class Main
{
  public static void main(String[] args) throws IOException
  {
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      String str = br.readLine();
      double rad = Double.parseDouble(str); // input radius
      double space = rad * rad * Math.PI; // space
      double cirf = 2 * rad * Math.PI; //circumference

      System.out.printf("%.6f %.6f", space, cirf); //output
      System.out.println("");

    } catch (Exception e){ // error detection
      System.exit(-1);
    }
  }
}

Measured memory_bytes: 24636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int N=1e5+5;
const int MAXN=1e5+5;
const ll inf=0x3f3f3f3f;
int a[N],b[N];
int main(){
    std::ios::sync_with_stdio(false);
    int n,l,r;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<=n;i++){
        if(a[i]<=a[i-1]) b[i]=b[i-1]+1;
        else b[i]=0;
    }
    int ans=0;
    for(int i=0;i<n;i++) ans=max(ans,b[i]);
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 1024
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from collections import defaultdict
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
A,B,C,K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A+B:
    print(A)
elif K <= A+B+C:
    p = K - A - B
    print(A-p)
else:
    print(A-C)

Measured memory_bytes: 27124
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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


int main(){
    int n;
    cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int idx=n-1;
    ll ans=0;
    rep(i,n-1){
        ans+=a[idx];
        if(i%2==0) idx--;
    }
    cout<< ans << endl;
}



Measured memory_bytes: 4032
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	int ans = INF;
	int x[N];
	rep(i, N) cin >> x[i];
	rep(i, N - K + 1) {
		int tmp = 0;
		if (x[i] * x[K + i - 1] < 0) tmp = min(abs(x[i] * 2) + abs(x[K + i - 1]),
			abs(x[i]) + abs(x[K + i - 1]) * 2);
		else tmp = max(abs(x[i]), abs(x[K + i - 1]));
		ans = min(ans, tmp);
	}
	cout << ans << endl;



    return 0;
}


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

int main(){
    int N, x;
    scanf("%d%d", &N, &x);

    if(x == 1 || x == 2*N-1){
        printf("No\n");
        return 0;
    }else{
        printf("Yes\n");
    }

    int cnt = (x+N-1)%(2*N-1);
    for(int i = 0; i < 2*N-1; i ++){
        printf("%d\n", cnt+1);
        cnt = (cnt+1)%(2*N-1);
    }

    return 0;
}


Measured memory_bytes: 1536
//FIRST THINK THEN CODE.

  #include <bits/stdc++.h>


  using namespace std;

  typedef long long ll;

  #define rep(i,a,b) for(ll i=a;i<b;++i)
  #define rrep(i,a,b) for(ll i=a;i>b;--i)
  #define FOR(i,n)  for(ll i=0;i<n;i++)
  #define vi vector<int>
  #define vl vector<ll>
  #define ld long double
  #define vld vector<ld>
  #define vvi vector<vector<int>>
  #define vvl vector<vector<long long>>
  #define vvld vector<vector<ld>>
  #define pii pair<int,int>
  #define pll pair<long,long>
  #define vpii vector<pii>
  #define vpll vector<pll>
  #define ff first
  #define ss second
  #define pb push_back
  #define pf push_front
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define bs binary_search
  #define d1(x) cout<<(x)<<endl
  #define d2(x,y) cout<<(x)<<" "<<(y)<<endl
  #define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
  #define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
  #define PI 3.1415926535897932384626433832795
  #define fix(f,n) fixed<<setprecision(n)<<f
  #define all(x) x.begin(),x.end()
  #define rev(p) reverse(p.begin(),p.end());
  #define endl "\n"
  #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #define popcount(x) __builtin_popcountll(x)
  #define sz(x) ((ll)x.size())
  const ll M=1000000007;
  const ll MM=998244353;
  ll begtime = clock();
  #define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
  //#define _Find_next 
  //#define _Find_first 



  ll newmod(ll a,ll b)
  {
  return ((a%b)+b)%b;
  }


  ll powM(ll a,ll b,ll m )
  { 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
  if(b&1)ans=ans*a%m;
  a=a*a%m;
  b>>=1;
  }

  return ans;
  }



  ll poww(ll a,ll b)
  { 

  ll ans=1;
  while(b)
  {
  if(b&1)ans=ans*a;
  a=a*a;
  b>>=1;
  }

  return ans;

  }

  template<typename T,typename F>
  void chmax( T &a,F b){
  if(b>a)a=b;
  }

  template<typename T,typename F>
  void chmin( T &a,F b){
  if(b<a)a=b;
  }

string tostring(ll x){
  stringstream sss;
  sss<<x;
  string ans=sss.str();
  return ans;
}


  const ll N=1e6+5;

//ll a[N];


  int main()
  { 

    IOS;

ll x,k,d;
cin>>x>>k>>d;

ll y=min(abs(x)/d,k);

if(y==k){
  if(x<0)x+=y*d;
  else x-=y*d;
  d1(abs(x));
  return 0;
}

ll parity1=abs(x)/d%2;
ll parity2=k%2;

if(x<0)x+=y*d;
  else x-=y*d;

if(parity2==parity1){
   
  d1(abs(x));
  return 0;
}


ll ans=min(abs(x+d),abs(x-d));

d1(ans);







  return 0;

  }

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int gcd(int x, int y){
  if(y==0)return x;
  return gcd(y,x%y);
}

int cnter(int n){
  int cnt = 0;
  while(n&&n%2==0){
    cnt++;
    n/=2;
  }
  return cnt;
}

int f(int x){
  int y = 0;
  while(x){
    y += x%10;
    x /= 10;
  }
  return y;
}

int main(){
  string s,t; cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  cout << (s < t ? "Yes" : "No") << endl;
} 


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

int main()
{
  ll n;
  cin >> n;
  
  ll t[n+1], y[n];
  rep(i,n+1) cin >> t[i];
  rep(i,n) cin >> y[i];
  
  ll ans = 0;
  rep(i,n)
  {
    if(y[i] > t[i])
    {
      ans += t[i];
      y[i] -= t[i];
      if(y[i] > t[i+1])
      {
        ans += t[i+1];
        t[i+1] = 0;
      }else{
        ans += y[i];
        t[i+1] -= y[i];
      }
    }else{
      ans += y[i];
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5160
MOD = 10 ** 9 + 7


def main():
    n, k = map(int, raw_input().split())
    a = aa = n + 1 - k
    b = 1
    bb = k
    for i in xrange(1, k + 1):
        print a * b % MOD
        aa -= 1
        a = a * aa // (i + 1)
        bb -= 1
        b = b * bb // i


if __name__ == '__main__':
    main()


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

int main()
{
    long long int n,m;
    cin >> n >> m;
    long long int a[m];
    long long int sum=0;
    for(long long int i=0;i<m;++i)
    {
        cin >> a[i];
        sum=sum+a[i];
    }
    if(sum<=n)
    {
        cout << n-sum << endl;
    }
    else
    cout << "-1" << endl;

    return 0;
}

Measured memory_bytes: 3708
def examC():
    N, x = LI()
    a = LI()
    cur = int(0)
    if a[0]>x:
        cur += a[0]-x
        a[0] = x
    for i in range(N-1):
        cur += max((a[i]+a[i+1])-x,0)
        a[i+1] = min(x-a[i],a[i+1])
    print(cur)


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 14524
#include<cstdio>
#include<iostream>
#include<string>
#define Max 2000

using namespace std;
int n, A[Max];

int Solve(int ii, int t)
{
	if (A[ii] == t)
		return 1;
	if (ii < n)
	{
		if (Solve(ii + 1, t) || Solve(ii + 1, t - A[ii]))
			return 1;
	}
	return 0;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	int s;
	cin >> s;
	int total = 0;
	for (int i = 0; i < s; i++)
	{
		int t;
		cin >> t;
		if (Solve(0, t))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;

}


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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    map<ll,ll> dict;

    map<ll,ll>::iterator it;

    ll t;
    cin>>t;
    while(t--) {
        ll num;
        cin>>num;
        if(dict.find(num)!=dict.end()) {
            cout<<"NO"<<endl;
            return 0;
        }
        else {
            dict[num]=1;
        }
    }
    cout<<"YES"<<endl;
}




Measured memory_bytes: 16112
A=input()
B=input()
C=input()
turn="a"
while True:
    if turn=="a":
        if A=="":
            print("A")
            break
        else:
            turn=A[0]
            A=A.replace(A[0],"",1)
    elif turn=="b":
        if B=="":
            print("B")
            break
        else:
            turn=B[0]
            B=B.replace(B[0],"",1)
    else:
        if C=="":
            print("C")
            break
        else:
            turn=C[0]
            C=C.replace(C[0],"",1)

Measured memory_bytes: 3064
//Deep Godhani
//DAIICT

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

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x,d) cout << fixed << setprecision(d) << x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

void solve()
{
  int n,x,t;
  cin >> n >> x >> t;

  if(n%x == 0)
  {
    cout << (n/x)*t << endl;
  }
  else
  {
    cout << (n/x + 1)*t << endl;
  }
}

int main()
{
    FAST;
    ll t=1;
    //cin >> t;
    while(t--)
    {
			solve();
    }
		return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const ll mod = 1e9 + 7;
const int maxn = 2e5 + 5;
ll fac[maxn],inv[maxn];

ll modpow(ll a,ll b){return b ? modpow(a*a%mod,b/2)*(b%2?a:1)%mod : 1;}
ll prm(ll n, ll k){
  ll res = 1;
  for(int i=0;i<k;i++){ res = res * (n-i) % mod; }
  return res;
}
ll modinv(ll a, ll p){ return modpow( a, p-2 ); }
ll cmb(ll n,ll k){
	k = min(k, n-k);
	return prm(n,k) * modinv(prm(k,k), mod) % mod;
} 
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans = modpow(2,n) - 1 - cmb(n,a) - cmb(n,b);
	ans = (ans % mod + mod) % mod;
	cout << ans << "\n";
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N, M = LI()
    X = LI()
    X = sorted(X)
    diff = []
    for i in range(M-1):
        d = X[i+1] - X[i]
        diff.append(d)
    diff = sorted(diff)
    while N - 1> 0 and len(diff) > 0:
        diff.pop()
        N -= 1
    ans = sum(diff)
    print(ans)
    '''
    X = sorted(X)
    min_dist = [0] * M
    if N == 1:
        return X[-1] - X[0]
    print(X)
    for i in range(1, M-1):
        min_dist[i] = min(abs(X[i] - X[i-1]), abs(X[i+1] - X[i]))
        print(min_dist)
    min_dist = sorted(min_dist)[::-1]
    print(min_dist)
    for i in range(N-2):
        if len(min_dist) > 0:
            min_dist.pop(-1)
    print(sum(min_dist))
    '''
main()



Measured memory_bytes: 15644
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main( ){
    double r;
    cin>>r;
    
    double pi=acos(-1);
    cout<<fixed<<setprecision(6);
    double area =r*r*pi;
    double cir=(r+r)*pi;
    cout<<area<<" "<<cir<<endl;
}


Measured memory_bytes: 3272
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <cmath>
#include <set>

using namespace std;

int main()
{
    string a, b, c;
    cin  >> a >> b >> c;
    char d = 'A' - 'a';
    char bA = a[0] + d;
    char bB = b[0] + d;
    char bC = c[0] + d;
    cout << bA << bB << bC << endl;
    return 0;
}

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

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

	int sum = 0;
	int smallest = 2000;
	int temp;
	for (int i = 0; i < N ; i++) {
		cin >> temp;
		sum += temp;
		if (smallest > temp) smallest = temp;
	}
	int result;
	result = (X - sum) / smallest + N;

	cout << result << endl;

	return 0;

}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// UnionFind高速
type UnionFind struct {
	d []int
}

func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.d = make([]int, N)
	for i := 0; i < N; i++ {
		u.d[i] = -1
	}
	return u
}

func (p *UnionFind) root(x int) int {
	if p.d[x] < 0 {
		return x
	}
	p.d[x] = p.root(p.d[x])
	return p.d[x]
}

func (p *UnionFind) unite(x, y int) bool {
	x = p.root(x)
	y = p.root(y)
	if x == y {
		return false
	}
	if p.d[x] > p.d[y] {
		x, y = y, x
	}
	p.d[x] += p.d[y]
	p.d[y] = x
	return true
}

func (p *UnionFind) same(x, y int) bool {
	return p.root(x) == p.root(y)
}

func (p *UnionFind) size(x int) int {
	return -p.d[p.root(x)]
}

type edge struct {
	a, b int
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()
	e := make([]edge, M)
	for i := 0; i < M; i++ {
		e[i].a, e[i].b = getInt()-1, getInt()-1
	}

	cnt := 0
	for i := 0; i < M; i++ {
		u := newUnionFind(N)
		for j := 0; j < M; j++ {
			if j == i {
				continue
			}
			u.unite(e[j].a, e[j].b)
		}
		if u.same(e[i].a, e[i].b) {
			cnt++
		}
	}
	out(M - cnt)
}


Measured memory_bytes: 640
S = input()
head, tail, ans = 0, len(S)-1, 0

while head < tail:
    if S[head] == S[tail]:
        head += 1
        tail -= 1
    elif S[head] == 'x':
        head += 1
        ans += 1
    elif S[tail] == 'x':
        tail -= 1
        ans += 1
    else:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 3316
#include<stdio.h>

int main(){

	int		dan,	kazu;
	
	for( dan = 1 ; dan < 10 ; dan ++ )
	{
		for( kazu = 1 ; kazu < 10 ; kazu ++ )
		{
			printf("%dx%d=%d\n", dan, kazu, dan*kazu );
		}
	}
	
	return 0;
}

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

using namespace std;

double a, b, x, mid, ans, ref;
const double pi = 3.14159265358979;
bool empt;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> a >> b >> x;
	mid = a * a * b / 2;
	if (x > mid) {
		x = a * a * b - x;
		x = 2.0 * x / a / a;
		ans = atan(x / a) * 180.0 / pi;
	}
	else {
		x = 2.0 * x / a / b;
		ans = atan(b / x) * 180.0 / pi;
	}
	cout << fixed << setprecision(12);
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int DFS(const vector<vector<int> >& ws, int depth, int value, int w, int w0, int W) {
	if (depth >= ws.size()) {
		if (w > W) {
			return 0;
		}
		else {
			return value;
		}
	}
	int res = DFS(ws, depth + 1, value, w, w0, W);
	for (int i = 0; i < ws[depth].size(); ++i) {
		int newW = w + (w0 + depth)*(i+1);
		int newValue = value + ws[depth][i];
		if (newW > W) break;
		res = max(res, DFS(ws, depth + 1, newValue, newW, w0, W));
	}
	return res;
}

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

	vector<vector<int>> ws(4);
	int w0, v0; cin >> w0 >> v0;
	ws[0].push_back(v0);
	for (int i = 0; i < N - 1; ++i) {
		int w, v; cin >> w >> v;
		ws[w - w0].push_back(v);
	}

	for (auto &w : ws) {
		sort(w.begin(), w.end(), greater<int>());
		for (int i = 1; i < w.size(); ++i) {
			w[i] = w[i] + w[i - 1];
		}
	}

	cout << DFS(ws, 0, 0, 0, w0, W) << endl;;
	system("pause");
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    long long n,ans=3;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    bool tate=true;
    if(s1[0]==s2[0])tate=true;
    else ans*=2,tate=false;
    for(int i=1;i<n;i++){
        if(i==1&&tate==false)i++;
        if(s1[i]==s2[i]){
            if(!tate){
                tate=true;
                continue;
            }
            tate=true;
            ans*=2;

        }else{
            if(tate)ans*=2;
            else ans*=3;
            tate=false;
            i++;
        }
    }
    cout<<(ans)%1000000007<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long gcd(long long a,long long b){
    if(a<b){
        long long tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(b !=0){
        long long tmp = a%b;
        a = b;
        b = tmp;
    }
    return a;
}

int main(){
    int n;
    cin >> n;
    vector<long long> t;
    for(int i=0;i<n;i++){
        long long tmp;
        cin >> tmp;
        t.push_back(tmp);
    }
    if(n == 1){
        cout << t[0] << endl;
        return 0;    
    }
    else{
        long long a= t[0]*(t[1]/gcd(t[0],t[1]));
        for(int i=2;i<t.size();i++){
            a = a*(t[i]/gcd(a,t[i]));

        }
        cout << a << endl;
        return 0;
    }
}

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

int main() {
    int n,a=0,b,s=0;
    cin >> n;
    b = n;
    for(int i = 8; i >= 0; i--){
        a = n % (int)pow(10,i);
        int t = (b-a)/pow(10,i);
        b = a;
        s += t;
    }
    if(n%s == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
	int n, m;
	cin >> n >> m;
	vector<int> k(n, 1);
	for (int i = 1; i < n; i++) k[i] = k[i-1] * 2;
	vector<pair<int, int>> G[1 << n];
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		int c = 0;
		for (int j = 0; j < b; j++) {
			int cc;
			cin >> cc;
			c += k[cc - 1];
		}
		for (int j = 0; j < (1 << n); j++) {
			G[j].push_back(make_pair(a, j | c));
		}
	}
	int inf = 1000000000;
	vector<int> d((1 << n), inf);
	d[0] = 0;
	priority_queue<pair<int, int>> que;
	que.push(make_pair(-d[0], 0));
	while (!que.empty()) {
		int cost = -que.top().first;
		int from = que.top().second;
		que.pop();
		if (cost > d[from]) continue;
		for (auto x: G[from]) {
			int nc = cost + x.first;
			int to = x.second;
			if (nc < d[to]) {
				d[to] = nc;
				que.push(make_pair(-d[to], to));
			}
		}
	}
	if (d[(1 << n) - 1] == inf) cout << -1 << endl;
	else cout << d[(1 << n) - 1] << endl;
}


Measured memory_bytes: 33408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,p;
  cin>>n>>p;
  int a[n],odd=0,even=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0)
      even++;
    else odd++;
  }
  
  long long int ans=0;
  
  ans=pow(2,n-1);
    
  if(p==1 && odd==0)
    ans=0;
  else if(p==0 && n==1 && odd==1)
    ans=0;
  else if(p==0 && odd==0)
    ans=ans*2;
  
  cout<<ans;
  
  
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 1;
    rep(i, 1, (ll)sqrt(m)+1) {
        if (m % i != 0) continue;
        ll j = m / i;
        if (i * n <= m) chmax(ans, i);
        if (j * n <= m) chmax(ans, j);
    }
    cout << ans << endl;
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int A[N], B[N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n; cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	sort(A, A + n);
	deque<int> dq;
	for (int i = 0; i < n / 2; i++) {
		if (i & 1) dq.push_back(A[i]), dq.push_front(A[n - i - 1]);
		else dq.push_back(A[n - i - 1]), dq.push_front(A[i]);
	}
	if (n & 1) {
		if (abs(A[n / 2] - dq.back()) > abs(A[n / 2] - dq.front())) dq.push_back(A[n / 2]);
		else dq.push_front(A[n / 2]);
	}
	ll sum = 0;
	for (int i = 0; i < n - 1; i++) sum += abs(dq[i + 1] - dq[i]);
	cout << sum << endl;

	return 0;
}


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

int main() {
    int n;
    string s;

    cin >> n >> s;

    int turn_to_e[n] = {};
    int turn_to_w[n] = {};

    for (int i = 1; i < n; i++) {
        turn_to_e[i] = turn_to_e[i - 1] + (s[i - 1] == 'W' ? 1 : 0);
    }

    for (int i = n - 2; i >= 0; i--) {
        turn_to_w[i] = turn_to_w[i + 1] + (s[i + 1] == 'E' ? 1 : 0);
    }

    int ans = 300000;
    for (int i = 0; i < n; i++) {
        ans = min(ans, turn_to_e[i] + turn_to_w[i]);
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  char f,e;
  vector<string> S(N);
  
  cin >> S.at(0);

  e = S.at(0).back();
  for(int i=1;i<N;i++){
    cin>>S.at(i);
    if(S.at(i).at(0)!=S.at(i-1).back()){
      cout<<"No"<<endl;
      return 0;
    }
    e = S.at(i).back();
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      if(S.at(i)==S.at(j)){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Two Coins
            var line = ReadLine();
            int A = line[0];
            int B = line[1];
            int C = line[2];

            if (A + B >= C)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

typedef pair<int, int> P;

//すぬけさんの　
int main()
{
   ios::sync_with_stdio(false);
   cin.tie(0);

   int n;
   cin >> n;
   vector<vector<int>> a(n, vector<int>(n - 1));
   for (int i = 0; i < n; i++)
   {
      for (int j = 0; j < n - 1; j++)
      {
         cin >> a[i][j];
         a[i][j]--;
      }
      reverse(a[i].begin(), a[i].end());//前から見るのは遅いので、後ろから見る
   }
   vector<P> q;
   auto check = [&](int i) {
      if (a[i].size() == 0)
         return;
      int j = a[i].back();
      if (a[j].size() == 0)
         return;
      if (a[j].back() == i)
      {
         P p(i, j);
         if (p.second < p.first)
            swap(p.first, p.second);
         q.push_back(p);
      }
   };

   for (int i = 0; i < n; i++)
   {
      check(i);
   }
   int day = 0;
   while (q.size() > 0)
   {
      day++;
      sort(q.begin(), q.end());
      q.erase(unique(q.begin(), q.end()), q.end());
      vector<P> prevQ;
      swap(prevQ, q);
      for (P p : prevQ)
      {
         int i = p.first, j = p.second;
         a[i].pop_back();
         a[j].pop_back();
      }
      for (P p : prevQ)
      {
         int i = p.first, j = p.second;
         check(i);
         check(j);
      }
   }
   for (int i = 0; i < n; i++)
   {
      if (a[i].size() != 0)
      {
         puts("-1");
         return 0;
      }
   }
   cout << day << endl;
}

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

const int maxn=50005;

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


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

int main(){
	int len, i, j;
	string s;
	cin>>s;
	len=s.length();
	for(i=0; i<len; i++){
		for(j=0; j<len; j++){
			if(s[i]==s[j] && i!=j) {
				cout<<"no"<<endl;
				return 0;
			}
		}
	}
	cout<<"yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
char s[300000],t[300000];
int main(){
	int cnt = 0;
	scanf("%s %s",s,t);
	int len = strlen(s);
	for(int i=0;i<len;i++){
		if(s[i] != t[i]){
			cnt++;
		}
	}
	printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
   //// #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
   // #endif
    cin>>a;
    vector<int>v(a);
    for(int i=0;i<a;i++){
    	cin>>v[i];
    }
    ans=0;
    for(int i=0;i<a-1;i++){
    	if(v[i]==0)continue;
    	for(int j=i+1;j<a;j++){
        ans+=(v[i]*v[j]);
    	}
    }
    cout<<ans<<endl;
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


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

win = {"r":"p", "s":"r", "p":"s"}  # 勝つ手に変換
points = {"r":R, "s":S, "p":P}  # 得点換算

hands = []
ans = 0

for i in range(N):
    if i < K:
        hands.append(str(win[T[i]]))
        ans += points[str(win[T[i]])]
    elif str(win[T[i]]) == hands[-K]:
        hands.append("n")
    else:
        hands.append(str(win[T[i]]))
        ans += points[str(win[T[i]])]

print(ans)


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

void main_()
{
    string S;
    cin >> S;

    char prev = S.front();
    ll ans = 0;
    for (auto ch : S) {
        if (ch != prev) {
            ans++;
            prev = ch;
        }
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int isprime(int );

int main()
{
  int n,i,count=0,a,ori[10000];
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ori[10000]);    
   if(isprime(ori[10000])==1) count++;
}

  printf("%d\n",count);
  
  return 0;
}

int isprime(int x)
{
  int i,a,b;
  
  if(x==2) return 1;

if(x<2 || x%2==0) return 0;

 for(i=3;i<=sqrt((double)x);i+=2){
if(x%i==0) return 0;
}

 return 1;
}



Measured memory_bytes: 2100