akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

const in MAX = 510000;
in fac[MAX], finv[MAX], inv[MAX];
//fac:n!  ,  finv:1/n  ,  inv:1/n!
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (in i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
in COM(in n, in k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

in nhr(in n,in r){
    return COM(n+r-1ll,r);
}
map<in,in> soin(in n){
    map<in,in> ret;
    for(in i=2;i*i<=n;i ++){
        while(n%i==0){
            ret[i] ++;
            n /= i;
        }
    }
    if(n!=1) ret[n]=1;
    return ret;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n,m;
    cin>>n>>m;
    auto a=soin(m);
    in ans=1ll;
    COMinit();
    for(auto x:a){
        in y=x.second;
        ans *=nhr(n,y);
        ans %=MOD;
    }
    cout<<ans<<endl;
}
//./problem.exe

Measured memory_bytes: 12160
#include <iostream>
#include <cmath>

using namespace std;

int N;

bool isPrime(int n) {
    if (n == 1) {
        return false;
    }
    if (n == 2 || n == 3) {
        return true;
    }
    if (n % 2 == 0) {
        return false;
    }    
    for (int i=3; i<=sqrt(n); i+=2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    cin >> N;

    for (int i=1; i<=55555; i++) {
        if (isPrime(i) && ((i-1) % 5) == 0 && 0 < N) {
            cout << i << " ";
            N--;
        }
        if (N == 0) {
            break;
        }
    }
    cout << endl;
}


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

def main():
    #入力
    a, b, c, d = list(map(int, input().split()))

    if abs(c - a) <= d:
        print('Yes')
    elif abs(b - a) <= d and abs(c - b) <= d:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#define mod 1000000007
using namespace std;
typedef long long ll;
bool chmax(ll &a,ll b){
    if(a>b)return 0;
    a=b; return 1;
}
bool chmin(ll &a,ll b){
    if(a<b)return 0;
    a=b; return 1;
}
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=a*b%mod

ll h,w,n;
ll sx,sy;
string s,t;
bool solve(){
    ll l=1,r=w;
    for(int i=n-1;i>=0;i--){
	if(t[i]=='L')r++; chmin(r,w);
	if(t[i]=='R')l--; chmax(l,1); //cout<<l<<" "<<r<<endl;
	if(l>r)return 0;
	if(s[i]=='R')r--; //chmax(r,1);
	if(s[i]=='L')l++; //chmin(l,h); 
      //cout<<l<<"#"<<r<<endl;
	if(l>r)return 0;
    }
  //cout<<l<<" "<<r<<endl;
    if(not(l<=sx&&sx<=r))return 0;
    
    l=1,r=h;
    for(int i=n-1;i>=0;i--){
	if(t[i]=='U')r++; chmin(r,h);
	if(t[i]=='D')l--; chmax(l,1);
	if(l>r)return 0;
	if(s[i]=='D')r--; //chmax(r,1);
	if(s[i]=='U')l++; //chmin(l,w);
	if(l>r)return 0;
    }
    if(not(l<=sy&&sy<=r))return 0;
    
    return 1;
}
int main(){
    cin>>h>>w>>n;
    cin>>sy>>sx;
    cin>>s>>t;
    cout<<(solve()?"YES":"NO")<<endl;
}




Measured memory_bytes: 776
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	int min = 1001;
	
	for (int i = 0; i < (s.size() - t.size() + 1); i++) {
		int wrong = 0;
		for (int j = 0; j < t.size(); j++) {
			if (s[i + j] == t[j])
				continue;
			else
				wrong++;
		}
		if (wrong < min)
			min = wrong;
	}
	cout << min;

	return 0;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var x = int.Parse(s[0] + s[1]);

            for (var i = 1; i <= 400; i++)
            {
                if (i * i == x)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int dist[2005];
int main(){
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1; i<=n; i++){
		for(int j=i+1; j<=n; j++){
			int d = min(j-i,1+abs(i-x)+abs(j-y));
			dist[d]++;
		}
	}
	for(int i=1; i<n; i++) cout<<dist[i]<<'\n';
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(){
  int a,b,c,k;
  
  scanf("%d %d %d %d",&a,&b,&c,&k);
  
  if(a >= k)
    printf("%d\n",k);
  else if(b >= (k-a))
    printf("%d\n",a);
  else
    printf("%d\n",a-(k-a-b));

  return 0;
}


Measured memory_bytes: 1732
#include "bits/stdc++.h"
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1e9+7
#define inf 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=n;i>=0;i++)
#define all(vec) vec.begin(),vec.end()
#define cend cout<<endl;
#define P pair<int,int>
#define prique priority_queue<P,vector<P>,greater<P>>
using namespace std;
int n,h,cnt=0;
priority_queue<P> que;
signed main() {
	cin>>n>>h;
	rep(i,n) {
		int a,b;
		cin>>a>>b;
		que.push(P(a,inf));
		que.push(P(b,1));
	}
	while(0<h) {
		P p=que.top(); que.pop();
		if(p.second==1) {
			h-=p.first;
			cnt++;
		}
		else {
			if(h%p.first==0) {
				cnt+=h/p.first;
				break;
			}
			else {
				cnt+=h/p.first+1;
				break;
			}
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 6128
#include<stdio.h>
int main()
{
    int a,b,c,sum;
    sum=0;
    // スペース区切りの整数の入力
    scanf("%d %d",&a,&b);
    // 文字列の入力
    for(c=0;c<2;c++){
      if(a>b){
      	sum += a;
        a -= 1;
      }
      else{
      	sum += b;
        b -= 1;
      }
    }
    // 出力
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

const int MAX = 8;
const int COLOR = 6;

int h,w,c;
int M[MAX][MAX];
int tmp[MAX][MAX];
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

void input(){
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++) cin >> M[i][j];
}

bool isInside(int x, int y){return 0<=x&&x<w&&0<=y&&y<h;}

void dfs(int x, int y, const int& col, const int& col2){
  if(!isInside(x,y)) return;
  if(tmp[y][x] != col) return;
  tmp[y][x] = col2;
  for(int i = 0; i < 4; i++) dfs(x+dx[i],y+dy[i],col,col2);
}

void count_panel(int x, int y, const int& col, int& cnt){
  if(!isInside(x,y)) return;
  if(tmp[y][x] != col) return;
  tmp[y][x] = -1;
  cnt++;
  for(int i = 0; i < 4; i++) count_panel(x+dx[i],y+dy[i],col,cnt);
}

int check(int c0, int c1, int c2, int c3, int c4, int c5){
 
  for(int i = 0; i < h; i++) 
    for(int j = 0; j < w; j++) tmp[i][j] = M[i][j];

  int col[] = {c0,c1,c2,c3,c4,c5};

  for(int i = 0; i < 5; i++){
    if(col[i] == col[i+1]) return 0;
    dfs(0,0,col[i],col[i+1]);
  }

  int cnt = 0;

  count_panel(0,0,c5,cnt);
  return cnt;
}

void solve(){
  int ans = 0;

  for(int i = 1; i <= COLOR; i++)
    for(int j = 1; j <= COLOR; j++)
      for(int k = 1; k <= COLOR; k++)
	for(int l = 1; l <= COLOR; l++)
	  ans = max(ans, check(M[0][0],i,j,k,l,c));

  cout << ans << endl;
}

int main(){
  while(cin >> h >> w >> c && h+w+c){
    input();
    solve();
  }
  return 0;
}

Measured memory_bytes: 1160
a,b,h,m=map(x->parse(Int,x),split(readline()))
const br=360/(60) #分あたりの角度
const ar1=360/(12) #時間あたりの角度
const ar2=30/(60)
arad= ar1*h+ar2*m
brad= br*m
rad = abs(arad-brad)
ans = a^2+b^2-2*a*b*cosd(rad)
println(sqrt(ans))

Measured memory_bytes: 201712
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n,k;
    cin>>n>>k;
    map<int,int> m;
    rep(i,k)
    {
        int d;
        cin>>d;
        rep(j,d)
        {
            int a;
            cin>>a;
            m[a]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(m[i]==0)ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <deque>
#include <cmath>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include "iomanip"
#include <cstdio>
#include <cstring>

using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a + b, min(a + c, c + b));

}

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

using namespace std;

typedef long long ll;

const int maxn = 100010;
const int inf = 0x3f3f3f3f;

int n, k, m, d;

int read()
{
	int x;
	scanf("%d", &x);
	return x;
}

//AtCoder 4721

int main()
{
	n = read(), d = read();
	d = d * 2 + 1;
	if(n % d == 0)cout << n / d << endl;
	else cout << n / d + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main() {
#ifdef DEBUG

#endif

	int N;;
	scanf("%d", &N);
	int tmp = N;
	int sum = 0;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (N%sum == 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"

int32_t main(){
	boost;
	int x;
	cin >> x;
	int ans = 0;
	if(x < 600)
		ans = 8;
	else if(x < 800)
		ans = 7;
	else if(x < 1000)
		ans = 6;
	else if(x < 1200)
		ans = 5;
	else if(x < 1400)
		ans = 4;
	else if(x < 1600)
		ans = 3;		
	else if(x < 1800)
		ans = 2;
	else
		ans = 1;
	cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    string s;
    int w;
    cin>>s>>w;
    for(i=0;i<s.length();i+=w){
        cout<<s[i];
    }
    cout<<endl;
}


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

int main() {
  int N,A;
  bool b=true;
  cin >> N;
  vector<bool>a(1000000001,false);
  for(int i=0;i<N;i++){
    cin >> A;
    if(a.at(A)){
      b=false;
      break;
    }else{
      a.at(A)=true;
    }
  }
  if(b){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 122368
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node

using namespace std;
///check n=1;
///check corner case;

int main()
{
    ll n,i,j,cc=0;
    cin>>n;
    ll ara[n];
    for(i=0;i<n;i++)cin>>ara[i];
    j=1;
    for(i=0;i<n;i++){
        if(j==ara[i]){
            j++;
        }
        else cc++;
    }
    if(j==1)cout<<-1<<endl;
    else
    cout<<cc<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int a,b;
int main(){
	scanf("%d %d", &a ,&b);
	if (a < b){
		printf("a < b\n");
	}else if (a > b){
		printf("a > b\n");
	}else 
		printf("a == b\n");
	return 0;
}


Measured memory_bytes: 2092
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <fstream>

using namespace std;


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

const string sep = " ";

class Compare {
public:
    bool operator()(int a, int b) {
        return a > b;
    }
};

std::vector<size_t> ZFunction(const std::string &text) {
    if (text.empty()) {
        return std::vector<size_t>();
    }
    std::vector<size_t> result(text.size());
    size_t left = 0;
    size_t right = 0;
    for (int i = 1; i < text.size(); ++i) {
        result[i] = std::max(0, std::min(static_cast<int>(right) - i,
                                         static_cast<int>(result[i - left])));
        while ((i + result[i] < text.size()) &&
               (text[result[i]] == text[i + result[i]])) {
            ++result[i];
        }
        if (i + result[i] > right) {
            left = i;
            right = i + result[i];
        }
    }
    return result;
}

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int s, w;
    cin >> s >> w;
    cout << ((s > w) ? ("safe") : ("unsafe"));
    return 0;
}

Measured memory_bytes: 3132
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define flash ios_base::sync_with_stdio(false);     cin.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(v) v.begin(),v.end()
#define f first
#define s second



using namespace std;

int main()
{
  flash
  ll n;
  cin>>n;
  set<string> s;

  for(int i=0;i<n;i++){
    string a;
    cin>>a;
    s.insert(a);
  }
  cout<<s.size()<<"\n";

}


Measured memory_bytes: 19140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, k;
  cin >> n >> k;
  vl a(n), all_n(n, n);
  rep(i, n) cin >> a[i];
  
  while(k) {
    if(a==all_n) break;
    
    vl d(n+1);
    rep(i, n) {
      d[max(i-a[i], 0LL)]++;
      d[min(i+a[i]+1, n)]--;
    }
    a[0]=d[0];
    rep(i, n-1) a[i+1] = a[i] + d[i+1];
    
    k--;
  }
  
  rep(i, n-1) cout << a[i] << " ";cout << a[n-1] << newl;
  return 0;
}

Measured memory_bytes: 7948
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int n , m,h[maxn],a[maxn], b[maxn];
vi g[maxn];
int main()
{
    close;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 1; i <= m; i++) {
        cin >> a[i] >> b[i];
        g[a[i]].eb(b[i]);
        g[b[i]].eb(a[i]);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int fl = 1;
        if(g[i].size() == 0) {ans++;continue;}
        trav(u , g[i]){
            if(h[u] >= h[i]){
                fl = 0;
                break;
            }
        }
        if(fl)ans++;
    }
    
    cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    string s;
    unordered_map<string,int> um;
    ll ans=0;
    for (int i=0; i<n; i++) {
        cin >> s;
        sort(s.begin(), s.end());
        if (um.find(s)==um.end()) um[s]=1;
        else {
            ans+=um[s];
            um[s]++;
        }
    }
    cout << ans << endl;
}

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

long N, M, X, ans;
vector<vector<long>> A;

int main(void) {

    cin >> N >> M >> X;
    A.resize(N, vector<long>(M+1));
    for (long i = 0; i < N; i++) {
        for (long j = 0; j < M+1; j++) {
            cin >> A[i][j];
        }
    }

    ans = -1;
    for (long bit = 0; bit < (1<<N); bit++) {
        vector<long> tmp(M+1);
        for (long i = 0; i < N; i++) {
            if (bit & (1<<i)) {
                for (long j = 0; j < M+1; j++) {
                    tmp[j] += A[i][j];
                }
            }
        }

        bool flag = true;
        for (long i = 1; i < M+1; i++) {
            if (tmp[i] < X) flag = false;
        }

        if (flag) {
            if (ans == -1)
                ans = tmp[0];
            else
                ans = min(ans, tmp[0]);
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	if(a <= 5)cout<<0<<endl;
	if(a > 5 && a < 13)cout<<b / 2<<endl;
	if(a >= 13)cout<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();

		char[] a = stdIn.next().toCharArray();
		StringBuilder sb = new StringBuilder();
		StringBuilder sc = new StringBuilder();

		if(n %2!= 0) {
			System.out.println("No");
			System.exit(0);
		}

		for(int i = 0; i < a.length/2; i++) {
			sb.append(a[i]);
		}
		String sbb = sb.toString();
		for(int i= a.length/2;i<a.length;i++) {
			sc.append(a[i]);
		}
		String scc = sc.toString();

		if(sbb.equals(scc)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 21972
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
long long c,x[100005],maxx,shun[100005],ni[100005];
long long v[100005],val[100005],rval[100005];
int main()
{
	int i,j,n;
	while(scanf("%d%lld",&n,&c)!=EOF)
	{
		memset(shun,0,sizeof(shun));
		memset(ni,0,sizeof(ni));
		memset(val,0,sizeof(val));
		memset(rval,0,sizeof(rval));
    for(i=1;i<=n;i++)
    {
        scanf("%lld%d",&x[i],&v[i]);
        val[i]=val[i-1]+v[i];
        shun[i]=max(shun[i-1],val[i]-x[i]);
    }
    for( i=n;i>=1;i--)
    {
    	
        rval[i]=rval[i+1]+v[i];
        ni[i]=max(ni[i+1],rval[i]-c+x[i]);
    }
    maxx=0;
    for(i=n;i>=1;i--)
    {
        maxx=max(maxx,rval[i]-2*(c-x[i])+shun[i-1]);
        maxx=max(maxx,ni[i]);
    }
    for(i=1;i<=n;i++)
    {
        maxx=max(maxx,val[i]-2*x[i]+ni[i+1]);
        maxx=max(maxx,shun[i]);
    }
   printf("%lld\n",maxx);
	}
	
	return 0;
}

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

typedef pair<int, int> ii;

const int dir[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

int main()
{
	int h, w, ch, cw, dh, dw;
	scanf("%d%d", &h, &w);
	scanf("%d%d", &ch, &cw);
	scanf("%d%d", &dh, &dw);
	char s[h+10][w+10];
	int dist[h+10][w+10];
	memset(s, '#', sizeof s);
	memset(dist, -1, sizeof dist);
	for (int i = 0; i < h; ++i) scanf("%s", s[i+2]+2), s[i+2][w+2] = '#';
	deque<ii> dq;
	dq.push_back(ii(ch+1, cw+1));
	dist[ch+1][cw+1] = 0;
	while (dq.size()) {
		int x = dq.front().first, y = dq.front().second;
		dq.pop_front();
		for (int i = 0; i < 4; ++i) {
			int X = x+dir[i][0], Y = y+dir[i][1];
			if (s[X][Y] != '#' && (dist[X][Y] == -1 || dist[X][Y] > dist[x][y])) {
				dist[X][Y] = dist[x][y];
				dq.push_front(ii(X, Y));
			}
		}
		for (int i = -2; i <= 2; ++i) for (int j = -2; j <= 2; ++j) {
			int X = x+i, Y = y+j;
			if (s[X][Y] != '#' && (dist[X][Y] == -1 || dist[X][Y] > dist[x][y]+1)) {
				dist[X][Y] = dist[x][y]+1;
				dq.push_back(ii(X, Y));
			}
		}
	}
	printf("%d\n", dist[dh+1][dw+1]);
}

Measured memory_bytes: 8808
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //a
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a * n, b) << endl;
  return 0;
}

Measured memory_bytes: 256
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const rule = lines.shift().split(" ").map(Number);
  const humanNum = rule[0];
  const type = rule[1];

  const data: any = lines.map((line) => {
    return line.split(" ").map((int) => parseInt(int));
  });

  let humanArray: boolean[] = new Array(humanNum).fill(false);
  let count = 0;
  for (let i = 1; i < type * 2; i += 2) {
    data[i].forEach((element) => {
      if (!humanArray[element - 1]) {
        count++;
        humanArray[element - 1] = true;
      }
    });
  }
  console.log(humanNum - count);
});


Measured memory_bytes: 30892
"""
author : halo2halo
date : 10, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M = map(int, read().split())
S = N + M

print(S // 2 if S % 2 == 0 else 'IMPOSSIBLE')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

void solve(){
     int a,b,c,k;cin >> a >> b >> c >> k;
     int cnt = 0;
     while(b<=a){b *= 2;cnt++;}
     while(c<=b) {c *= 2;cnt++;}
     if(cnt>k) cout <<"No";
     else cout <<"Yes";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);

vll dp,h;
int n,k;

ll f(int i)
{
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    else
    {
        if(i==0)
        {
            return dp[i] =0;
        }
        else
        {
            ll mini = 2e18;
            for (int p = i-1; p >=0 && p >= i-k; p--)
            {
                mini = min(f(p)+abs(h[i]-h[p]),mini);
            }
            return dp[i]=mini;
        }
    }
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    
    cin>>n>>k;
    dp.assign(n,-1);
    h.resize(n);
    for (int i = 0; i < n; i++)
    {
        cin>>h[i];
    }
    ll ans = f(n-1);
    cout<<ans<<"\n";
    return 0;
}

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

using ll = long long;

int main() {
        int N;
        cin >> N;
        vector<ll> s(N+1);
        for(int i = 0; i < N; i++) {
                ll a;
                cin >> a;
                s[i+1] = s[i] + a;
        }

        ll ans = 10000000000;
        for(int i = 1; i <= N-1; i++) {
                ans = min(ans, abs(s[i] - (s[N] - s[i])));
        }

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;

long long ap(long long a, long long p){
  if (p == 0){
    return 1;
  }else{
    long long sum = (a % nmax) * (a % nmax);
    sum = sum % nmax;

    if (p % 2 == 0){
      return ap(sum, p / 2) % nmax;
    }else{
      return ((a % nmax) * ap(sum, p / 2)) % nmax;
    }
  }
}

long long nCr(long long n, long long r){
  long long ans = 1;
  for (int i = 0; i < r; i++){
    ans = (ans * (n - i)) % nmax;
    ans = (ans * (ap(r - i, nmax - 2) % nmax)) % nmax;
  }
  return ans;
}

int main(){

  int N, M; cin >> N >> M;

  vector <int> kosuu;

  int orM = M;
  for (int i = 2; i * i <= orM; i++){
    int num = i, cnt = 0;
    while (M % num == 0){
      cnt++;
      M = M / num;
    }
    if(cnt != 0) kosuu.push_back(cnt);
  }
  if(M != 1) kosuu.push_back(1);

  long long ans = 1;
  for (int i = 0; i < kosuu.size(); i++){
    ans = ans * nCr(N + kosuu[i] - 1, N - 1);
    ans = ans % nmax;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

ll calc(ll h){
	if(h == 1) return 1;
	return calc(h / 2) * 2 + 1;
}

int main(){
	ll h; cin >> h;
	cout << calc(h) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main {
    static final long MOD = 1000000007L;
    static final int INF = 50000000;
    static final int NINF = -50000000;
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        
        int N = sc.ni();
        int[] type = new int[4];
        for (int i = 0; i < N; i++) {
        	String s = sc.next();
        	if (s.equals("AC")) {
        		type[0] += 1;
        	} else if (s.equals("WA")) {
        		type[1] += 1;
        	} else if (s.equals("TLE")) {
        		type[2] += 1;
        	} else {
        		type[3] += 1;
        	}
        }
        
        pw.println("AC x " + type[0]);
        pw.println("WA x " + type[1]);
        pw.println("TLE x " + type[2]);
        pw.println("RE x " + type[3]);
        
        pw.close();
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int ni() {
            return Integer.parseInt(next());
        }
 
        long nl() {
            return Long.parseLong(next());
        }
 
        double nd() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 48992
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque, defaultdict
from fractions import gcd
from functools import reduce
from itertools import groupby, combinations
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return list(map(lambda x: x + d, A))
def ldec(A, d=1): return list(map(lambda x: x - d, A))

def modinv(a, n):
    (x, lastx) = (0, 1); (y, lasty) = (1, 0); p = n
    while p != 0:
       q = a // p; (a, p) = (p, a % p)
       (x, lastx) = (lastx - q * x, x); (y, lasty) = (lasty - q * y, y)
    return lastx % n

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1: arr.append([temp, 1])
    if arr == []: arr.append([n, 1])
    return arr

N = n1()

if N == 1:
    print(1)
    exit(0)

fact = factorization(N)

if fact[0][0] == 2:
    fact[0][1] += 1
else:
    fact = [[2, 1]] + fact

#print(fact)

ans = 10**16
for n in range(2**len(fact)-1):
    cand = bin(n)[2:].zfill(len(fact))
    k = 1
    q = 1

    for i in range(len(cand)):
        p, t = fact[i][0], fact[i][1]
        if cand[i] == "1":
            k *= p**t
        else:
            q *= p**t

    x = - modinv(k, q) % q
    tmp = k*x

    """
    if k % 2 == 0:
        if x % 2 != 0:
            x *= 2
    else:
        if x % 2 != 0:
            x *= 2
    """

    ans = min(tmp, ans)
    #print(ans, k, x, q, k*x)

ans = min(tmp, ans)

print(ans)

Measured memory_bytes: 74340
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#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 vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#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 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 endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  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;
}

const ll N=1e5+5;

ll sp[N];

void fill(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      for(int j=i;j<N;j+=i){
        if(sp[j]==j)sp[j]=i;
      }
    }
}

vl f(N);


int main()
{ 

IOS;

ll n;cin>>n;

ll ans1=0,ans2=0;

vl a(n+1);

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

ll sum=0;

ll be=1;

for(int i=1;i<=n;i++){
if(i&1)be=1;
else be=-1;
  sum+=a[i];
  if(sum*be<=0){
ans1+=abs(sum)+1;
     sum=be;
  }
}

sum=0;

for(int i=1;i<=n;i++){
if(i&1)be=-1;
else be=1;
  sum+=a[i];
  if(sum*be<=0){
ans2+=abs(sum)+1;
     sum=be;
  }
}


cout<<min(ans1,ans2);


return 0;
 
}


Measured memory_bytes: 4732
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    int o = 0 ;
    for(int i=0; i < a.length(); i++ ){
        if(a.charAt(i) == '1'){
            o++;
        } ;
    }
        System.out.println(o);
        sc.close();
    }    
}


Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>

#define INF 1e9
#define MOD 1000000007
#define ll long long
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
typedef unsigned long long ull;
typedef pair<int, ll> pr;
vector<int>t[100004];
int h[105];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    int ans=0;
    int min=0;
    for(int i=0;i<101;i++){
        bool b=true;
        for(int j=1;j<=n;j++){
            if(h[j]){
                h[j]--;

                if(b){
                    ans++;
                    b=false;
                }

            }
            else{
                b=true;
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<vector<int>> xy(3,vector<int>(3));
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> xy.at(i).at(j);
        }
    }
    vector<int> x(3);
    vector<int> y(3);

    x.at(0) = 0;

    for (int i = 0; i < 3; ++i) {
        y.at(i) = xy.at(0).at(i) - x.at(0);
    }

    for (int i = 0; i < 3; ++i) {
        x.at(i) = xy.at(i).at(0) - y.at(0);
    }

    bool flg = true;

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
           if(xy.at(i).at(j) != x.at(i) + y.at(j)){
               flg = false;
           }
        }
    }
    if(flg == true){
        cout << "Yes";
    } else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 1;i < n+1 ;++i) {
			int x = i;
			if(x%3 == 0) {
				System.out.printf(" "+i);
				continue;
			}
				while(x != 0) {
					if(x%10 == 3) {
						System.out.printf(" "+i);
						break;
					}
						x = x/10;
					
			}
		}System.out.println("");
	sc.close();
	}
}



Measured memory_bytes: 30824
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int sum = 0;

        if(s.charAt(0)=='+'){
            sum++;
        }else{
            sum--;
        }

        if(s.charAt(1)=='+'){
            sum++;
        }else{
            sum--;
        }

        if(s.charAt(2)=='+'){
            sum++;
        }else{
            sum--;
        }

        if(s.charAt(3)=='+'){
            sum++;
        }else{
            sum--;
        }
    System.out.println(sum);

    }

}


Measured memory_bytes: 21204
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define MOD 1000000007
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int p;
        cin >> p;
        ans += 2*min(p, K-p);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int R,G,x;
	scanf("%d\n%d",&R,&G);
	x=2*G-R;
	printf("%d",x);
	return 0;
}

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


void outlist(int A[],int n){
	for(int i=0;i<n;i++){
		if (i>0){
			cout<<" ";
		}
    	cout<<A[i];
	}
  	cout<<endl;
}


int main(){
	int n;
	int A[1000];
	cin>>n;
	for(int i=0;i<n;i++){
			cin>>A[i];
	}
	outlist(A,n);
	for(int j=1;j<n;j++){
		int v=A[j];
		int k=j-1;
		while(k>=0&&A[k]>v){
			A[k+1]=A[k];
			k--;
		}
		A[k+1]=v;
		outlist(A,n);
	}
	return 0;
		
}


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

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

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

  int dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
  for (int i = 2; i < n; ++i)
  {
  	dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]) ,dp[i-2]+abs(h[i]-h[i-2]) );
  }
  cout<<dp[n-1];
 return 0;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	LL A,B,C,K; cin >> A >> B >> C >> K;
	cout << (A-B)*(K%2==0?1:-1) << endl;
}


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

class TrickOrTreat
{
    static void Main(string[] args)
    {

        var input = Console.ReadLine().Split(' ');

        var people = int.Parse(input[0]);
        var vary = int.Parse(input[1]);

        int[] PeopleList = new int[people];

        for(var i = 0; i < people; i++)
        {
            PeopleList[i] = 0;
        }

        for(var i = 0;i < vary; i++)
        {
            var times = int.Parse(Console.ReadLine());

            var people_number = Console.ReadLine().Split(' ');

            for(var j = 0;j < times; j++)
            {
                if(PeopleList[int.Parse(people_number[j])-1] == 0)
                {
                    PeopleList[int.Parse(people_number[j])-1] = 1;
                }
            }
        }
        var count = 0;
        foreach (var c in PeopleList)
        {
            if(c == 0)
            {
                count++;
            }
        }
        Console.WriteLine(count);

    }
}


Measured memory_bytes: 27620
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""

# 最大公約数 と 最小公倍数
"""def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g"""

# 二分探索
"""import bisect # 二分探索
print(A,bisect.bisect_left(A,4))
print(C,n - bisect.bisect_right(C,4))
print(sum(bisect.bisect_left(A,b) * (n-bisect.bisect_right(C,b)) for b in B))"""

# 円周率 pi
"""import math
pi_ = math.pi"""

# エラトステネスの篩
"""def Erato(n):
    prime = []
    is_prime = [True] * (n+1)
    p = 0
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,n+1):
      if is_prime[i] == True:
        prime.append(i)
        p += 1
        for j in range(2 * i,n+1,i):
          is_prime[j] = False
    return p"""

def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n = int(input())
  S = input()
  # あらかじめ iとjとkを保存しとけばよい

  R_ = [i for i in range(n) if S[i] == 'R']
  G_ = [j for j in range(n) if S[j] == 'G']
  B_ = [k for k in range(n) if S[k] == 'B']
  #print(R_,G_,B_,sep='\n')
  #二つが決まればもう1つが決まる?
  ans = len(R_) * len(G_) * len(B_)
  #now = 0
  for i in range(n):
    for d in range(n):
      j = i+d
      k = j+d
      if k >= n:
        break
      if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
        ans -=1
        
  print(ans)

  

if __name__ == '__main__':
  main()


Measured memory_bytes: 68424
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while (A > 0 && C > 0){
		C -= B;
		if(C <= 0){
			cout << "Yes" << endl;
			break;
		}
		A -= D;
		if(A <= 0){
			cout << "No" << endl;
			break;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3636
// Author: πα

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

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long int64_t

const int N = 1e5 + 5;
int dp[N][3];

int main()
{
    FastIO;
    int n, i;
    cin >> n;
    for(i = 1; i <= n; ++i)
    {
        cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
        dp[i][0] += max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] += max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] += max(dp[i-1][0], dp[i-1][1]);
    }
    cout << *max_element(dp[n], dp[n]+3);
    return 0;
}


Measured memory_bytes: 1408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, root = 1;
string s, t;

int main() {
    fast_io;

    cin >> s;
    n = s.size();
    s = "0" + s;
    t = s;
    reverse(all(t));
    if (s[1] == '0' || s != t) return cout << -1 << endl, 0;

    for (ll i = 1; i < n; i++) {
        cout << i + 1 << sep << root << endl;
        if (s[i] == '1') root = i + 1;
    }

    return 0;
}
/*

*/


Measured memory_bytes: 1664