akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

int main(){

    int N,i=1;
    scanf("%d",&N);
  	//printf("%d\n",N);

    char S[10000];
    scanf("%s",S);
  	//printf("%s\n",S);

    for (i = 0; i < strlen(S);i++){
	//printf("OK\n");
        S[i] += N;
      	if(S[i] >= 91) S[i] -= 26;
    }

    for (i = 0; i < strlen(S); i++){
      //printf("Go\n");
            printf("%c",S[i]);
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c)
{
    stack<int> S;
    S.push(r);
    color[r] = c;
    while (!S.empty())
    {
        int u = S.top();
        S.pop();
        for (int i = 0; i < G[u].size(); i++)
        {
            int v = G[u][i];
            if (color[v] == NIL)
            {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor()
{
    int id = 1;
    for (int i = 0; i < n; i++)
        color[i] = NIL;
    for (int u = 0; u < n; u++)
    {
        if (color[u] == NIL)
            dfs(u, id++);
    }
}

int main()
{
    int s, t, m, q;

    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    assignColor();

    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> s >> t;
        if (color[s] == color[t])
        {
            cout << "yes" << endl;
        }
        else
        {
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8996
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (max(a)+2)
for i in range(n):
    if a[i] != 0:
        cnt[a[i]-1] += 1
    cnt[a[i]] += 1
    cnt[a[i]+1] += 1
print(max(cnt))

Measured memory_bytes: 13964
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 5
long long A[MAXN + 5], k = MAXN + 5;
int main() {
	for (int i = 1; i <= 3; i++) {
		cin >> A[i];
		if (A[i] % 2 == 0) k = 0;
	}
	sort(A + 1, A + 4);
	k = min(k, A[3] % 2);
	printf("%lld", A[1] * A[2] * k);
	//getchar(); getchar(); getchar();
	return 0;
}


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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<ll> A(MAXN, 0);
string S, T;

signed main(){
    cin >> S >> T;
    if(S.size()<T.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    if(S.size()==T.size()) {
        for(int i=0;i<T.size();i++) {
            if(S[i]=='?') continue;
            if(S[i]!=T[i]) {
                cout << "UNRESTORABLE" << endl;
                return 0;
            }
        }
        cout << T << endl;
        return 0;
    }
    for(int i=S.size()-T.size();i>=0;i--) {
        ll flag=0;
        for(int j=0;j<T.size();j++) {
            if(S[i+j]=='?') continue;
            if(S[i+j]!=T[j]) {
                flag=1;
            }
        }
        if(flag==0) {
            for(int k=0;k<S.size();k++) {
                if(k<=i+T.size()-1&&k>=i) {
                    cout << T[k-i];
                }
                else {
                    if(S[k]=='?') cout << 'a';
                    else cout << S[k];
                }
            }
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
 
  public static void Main (string[] args) {
    var temp = Console.ReadLine().Split(' ');
    var A = int.Parse(temp.ElementAt(0));
    var B = int.Parse(temp.ElementAt(1));
    var ans = B % A == 0 ? A + B : B - A;


    Console.WriteLine(ans);
  }

}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define ll long long

using namespace std;

void max_self(ll &a, ll b) {
    a = max(a, b);
}

int main()
{
    int n, w;
    cin >> n >> w;
    vector<ll> dp(w + 1);
    for(int i = 0; i < n; i++) {
        ll w1, v;
        cin >> w1 >> v;
        for(int j = w - w1; j >= 0; j--) {
            max_self(dp[w1 + j], dp[j] + v);
        }
    }
    ll ans = 0;
    for(int i = 0; i <= w; i++) {
        max_self(ans, dp[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long LL;


multiset<string> S;
int main(){

	int n;
	scanf("%d", &n);for (int i=0; i<n; i++) S.insert("a");
	scanf("%d", &n);for (int i=0; i<n; i++) S.insert("b");
	scanf("%d", &n);for (int i=0; i<n; i++) S.insert("c");
	while ( S.size() >1){
		string s1= *S.begin(), s2= *(--S.end());
		string t= s1+s2;
		S.erase(S.begin());S.erase(--S.end());
		S.insert(t);
	}
	printf("%s\n", S.begin()->c_str());
	return 0;
}



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

int main() {
  long n;
  cin >> n;
  long a[n+1];
  vector<long> ans(n+1);
  for (long i = 2; i <= n; i++) {
    cin >> a[i];
    ans[a[i]] += 1;
  }
  
  for (long i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 6428
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pll             pair<ll,ll>
#define vll              vector<int>
#define mll             map<ll,ll>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define md             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
void hi()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void bye()
{
    #ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    #endif
}

void solve()
{
    ll n,ans=0,c=0; cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    ans+=a[n-1];c++;
    if(c!=n-1)
    for(int i=n-2;i>=0;i--)
    {
        ans+=a[i];c++;
        if(c==n-1) break;
        ans+=a[i];c++;
        if(c==n-1) break;
    }
    cout<<ans;
}
int main()
{
    hi();
    ll test_cases=1; //cin>>test_cases;
    for(ll t=1;t<=test_cases;t++)
    {
        solve();
    }
    bye();
    return 0;
}

Measured memory_bytes: 5196
n, a, b = [ int(i) for i in input().split() ]

res = 0
for i in range(n+1):
    x = 0
    tmp = i
    while tmp / 10 > 0:
        x += tmp % 10
        tmp //= 10
    if (x >= a) and (x <= b):
        res += i
        
print(res)


Measured memory_bytes: 2940
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 21;
 
int dp[maxN][10];

void go(int i, int d, int n)
{
	if (i == 0)
	{
		printf("\n");
		return;
	}
	int d2 = d == 0 ? d : d-1;
	
	printf("%d", d);
	while (dp[i-1][d2] < n)
		n -= dp[i-1][d2], d2++;
	go(i-1, d2, n);
}
 
void solve()
{
	int n;
	scanf ("%d", &n);
	if (n < 10)
	{
		printf("%d\n", n);
		return;
	}
	
	FOR(i, 0, 10)
		dp[1][i] = 1;
	n -= 9;
		
	FOR(i, 2, maxN) FOR(d, 0, 10)
	{
		dp[i][d] = dp[i-1][d];
		if (d != 0)
			dp[i][d] += dp[i-1][d-1];
		if (d != 9)
			dp[i][d] += dp[i-1][d+1];
			
		if (dp[i][d] < n and d != 0)
			n -= dp[i][d];
			
		else if (dp[i][d] >= n and d != 0)
		{
			go(i, d, n);
			return;
		}
	}
}
 
int main()
{
	int t;
t=1;////	scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>

using namespace std;

int main(void)
{

    int N;
    if (scanf("%d", &N) < 1) return 0;

    array<array<int, 300>, 300> dist;

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            if (scanf("%d", &dist[i][j]) < 1) return 0;

    long long int total = 0L;

    // Warshall-Floyd
    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            bool flg = false;
            for (int k = 0; k < N; k++)
            {
                if (k == i || k == j) continue;
                if (dist[i][k] + dist[k][j] < dist[i][j])
                {
                        printf("%d\n", -1);
                        return 0;
                }
                else if (dist[i][k] + dist[k][j] == dist[i][j])
                {
                    flg = true;
                    break;
                }
            }
            if (!flg) total += dist[i][j];
        }
    }

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


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll INF = (1LL<<60);

int main(){

    string s; cin >> s;

    if(s == "SUN") cout << 7 << endl;
    if(s == "MON") cout << 6 << endl;
    if(s == "TUE") cout << 5 << endl;
    if(s == "WED") cout << 4 << endl;
    if(s == "THU") cout << 3 << endl;
    if(s == "FRI") cout << 2 << endl;
    if(s == "SAT") cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh = sorted(xyh, key = lambda x: -x[2])
tx, ty, th = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = th + abs(tx - Cx) + abs(ty - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  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();
    P p = P(i, j);
    if(p.second < p.first) swap(p.first, p.second);
    if(A[j].back() == i) {
      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(q, prevQ);
    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) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define inf 1e9
#define pp pop_back
#define pii pair<int,int>
#define vec vector<int>
#define mp make_pair
using namespace std;
int w[101],v[101];
int dp[101][100001];
int ans(int n,int W)
{
  if(n==0)
    return 0;

  if(dp[n][W]!=-1)
        return dp[n][W];
  if(w[n]<=W)
    return dp[n][W]=max(v[n]+ans(n-1,W-w[n]),ans(n-1,W));
  else
    return dp[n][W]=ans(n-1,W);
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t=1;
  //cin>>t;
  while(t--)
  {
    memset(dp,-1,sizeof(dp));
    int n,W,i;
    cin>>n>>W;
    for(i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    cout<<ans(n,W);
  }
}


Measured memory_bytes: 82548
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	string N;

	cin >> N;
	int ans = 0, n = 9;

	for (int i = 2; i <= N.size(); i += 2)
	{
		ans += n;
		n *= 100;
	}
	int num = stoi(N);

	for (n /= 9; n <= num; n++)
	{
		ans++;
	}
	cout << ans << endl;
}



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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> A(n,0);
  for(int i = 0; i < n; i++) cin >> A.at(i);
  
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  int votes = 0;
  for(int i = 0; i < n; i++) votes += A.at(i);
  int judge;
  if(votes % (4*m) == 0 ) judge = votes/(4*m);
  else judge = votes/(4*m) + 1;
  
  bool ok = true;
  for(int i = 0; i < m; i++){
    if(A.at(i) < judge) ok = false;
  }
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

string S, T;
void input(){
  cin >> S >> T;
}

void solve(){
  T.pop_back();
  if(S == T) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main() {
 input();
 solve();
 return 0;
}


Measured memory_bytes: 3532
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    a, b = map(int, input().split())
    print(a + b if a + b < 10 else 'error')

if __name__ == '__main__':
    main()


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

int main(){
    int N;
    cin >> N;
    int P = 0;
    vector<int> X(N);
    for(int i=0;i<N;i++){
        cin >> X[i];
        P += X[i];
    }
    int P1 = P/N, P2 = (P+N-1)/N;
    int ans1 = 0, ans2 = 0;
    for(int i=0;i<N;i++) ans1 += (X[i]-P1)*(X[i]-P1);
    for(int i=0;i<N;i++) ans2 += (X[i]-P2)*(X[i]-P2);
    int ans = min(ans1, ans2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

// 154-c
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

int main() {
    int n, a;
    cin >> n;
    map<int, bool> mp{};
    rep(i, 0, n) {
        cin >> a;
        if (mp[a]) {
            cout << "NO" << endl;
            return 0;
        } else {
            mp[a] = true;
        }
    }

    cout << "YES" << endl;

    return 0;
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

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

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	ll a[n];
	ll b[n];
	FOR(i,0,n)cin >> a[i];
	FOR(i,0,n){
		if(n % 2 == 0){
			if(i % 2 == 0){
				b[n/2+i/2] = a[i];
			}else{
				b[n/2-i/2-1] = a[i];
			}
		}else{
			if(i % 2 == 0){
				b[n/2-i/2] = a[i];
			}else{
				b[n/2+i/2+1] = a[i];
			}
		}
	}
	FOR(i,0,n){
		if(i == 0){
			cout << b[i];
		}else{
			cout << " " << b[i];
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 5248
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    int ans = 11;
    for(int i = 1; i <= Math.sqrt(n); i++){
      if(n%i == 0){
        long j= n/i;
        int temp = Math.max(String.valueOf(i).length(),String.valueOf(j).length());
        if(temp < ans){
          ans = temp;
        }
      }
    }
    System.out.println(ans);
  }
}

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

p=0
q=1
for i in range(N):
  if q*5 <= N:
    q = q*5
    p = p+1
  else:
    break

if N%2==1:
    print(0)
else:
    ans = 0
    for i in range(1,p+1):
        ans = ans + N//(2*(5**i))
    print(ans)

Measured memory_bytes: 3060
from numba import jit
import numpy as np

@jit
def resolve():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    for m in range(k):
        B = np.zeros(n + 1, dtype=np.int64)
        for i in range(n):
            l = max(0, i - A[i])
            r = min(n, i + A[i] + 1)
            B[l] += 1
            if r < n:
                B[r] -= 1
        A = np.cumsum(B)[:-1]
        if np.all(A == n):
            break

    for a in A:
        print(a, end=" ")

resolve()

Measured memory_bytes: 138176
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int R; cin >> R;

    int ans = 3*R*R;
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

long long s[100005];

map<int, long long> memo[100005];

int N;

long long dp(int C, int k){
	//printf("%d %d\n", C, k);
	if(k == 0){
		return 0;
	}else if(memo[C].find(k) != memo[C].end()){
		return memo[C][k];
	}else{
		if((N-1)%C == 0 && N-1-(k-1)*C <= (k-1)*C){
			return memo[C][k] = -1LL << 61;
		}
		
		memo[C][k] = dp(C, k-1) + s[(k-1)*C] + s[N-1-(k-1)*C];
		/*if(memo[C][k] == 57){
			printf("57: %d %d\n", C, k);
		}else if(memo[C][k] == 59){
			printf("59: %d %d\n", C, k);
		}else if(memo[C][k] == 3){
			printf("3: %d %d\n", C, k);
		}else if(memo[C][k] == 13){
			printf("13: %d %d\n", C, k);
		}*/
		return memo[C][k];
	}
}


int main(){
	scanf("%d", &N);
	
	for(int i = 0; i < N; i ++){
		scanf("%lld", &s[i]);
	}
	
	long long ans = 0;
	for(int C = 1; C <= N; C ++){
		if((N-1)%C >= 0){
			for(int k = 0; k*C < N; k ++){
				ans = max(ans, dp(C, k));
			}
		}
	}
	
	printf("%lld", ans);
	return 0;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>x(n);
  for(i=0;i<n;i++)cin>>x[i];
  for(i=0;i<n;i++){
    result+=2*min(x[i],abs(x[i]-k));
  }
  cout<<result<<endl;



  return 0;
}

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

int main(){
    int a ,b ,c , d;
    cin >> a >> b >> c >> d;
    cout << max({ 1LL * b * d , 1LL * a * c , 1LL * a * d , 1LL * b * c });
    return 0; 
}

Measured memory_bytes: 3612
n = gets.chomp.to_i
commands = []
n.times { commands.push(gets.chomp) }

# arr = []
# commands.each do |cmd|
#     if cmd.split(' ')[0] == "insert" then
#         arr.push(cmd.split(' ')[1]) unless arr.include?(cmd.split(' ')[1])
#     else
#         if arr.include?(cmd.split(' ')[1]) then
#             puts "yes"
#         else
#             puts "no"
#         end
#     end
# end

hs = Hash.new([])
commands.each do |command|
    # p hs
    cmd, str = command.split(' ')
    if cmd == "insert" then
        hs[str] = str
    else
        if hs[str] == str then
            puts "yes"
        else
            puts "no"
        end
    end
end





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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 100005;

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

    int x, y;
    cin >> x >> y;

    if (x == 1 && y == 1) {
        cout << 300000 + 300000 + 400000 << endl;
        return 0;
    }

    int money = 0;
    
    if (x == 1) money += 300000;
    if (x == 2) money += 200000;
    if (x == 3) money += 100000;
    if (y == 1) money += 300000;
    if (y == 2) money += 200000;
    if (y == 3) money += 100000;

    cout << money << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

#インデックス付きソート
#(index,value)の順に格納
from operator import itemgetter
def index_sort(A):
    return sorted(enumerate(A),key=itemgetter(1))

N = I()
A = Line(N,1)

B = index_sort(A)
num = 0
for i in range(N):
    if abs(B[i][0]-i)%2==1:
        num += 1

print(num//2)

Measured memory_bytes: 52700
s=input()
s_exit_x=''
ans = 0
for n,i in enumerate(s):
    if i !='x':
        s_exit_x += i
if s_exit_x != s_exit_x[::-1]:
    print(-1)
else:
    left=0
    right=len(s)-1
    while left < right:
        if s[left] == s[right]:
            left += 1
            right -=1
        elif s[left]=="x":
            left += 1
            ans += 1
        else:
            right -=1
            ans += 1
    print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll fac[MAXN];
ll inver[MAXN];
int A[MAXN];

ll mypow(ll n,ll m)
{
    ll res = 1;

    n%=MOD;

    while(m){
        if(m&1)res = (res*n)%MOD;
        n = (n*n)%MOD;
        m>>=1;
    }
    return res;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>k;

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

    sort(A+1,A+n+1);

    fac[0] = 1;

    for(int i=1;i<=n;i++)
        fac[i] = (1LL*i*fac[i-1])%MOD;

    inver[n] = mypow(fac[n],MOD-2);

    for(int i=n-1;i>=0;i--)
        inver[i] = (1LL*(i+1)*inver[i+1])%MOD;

    ll res = 0;
    ll curv = 0;

    for(int i=1;i<=n-k+1;i++){
        curv = MOD-A[i];
        curv *= fac[n-i];
        curv %= MOD;
        curv *= inver[k-1];
        curv %= MOD;
        curv *= inver[n-k+1-i];
        curv %= MOD;
        res += curv;
        if(res>=MOD)res-=MOD;
    }

    for(int i=n;i>=k;i--){
        curv = MOD+A[i];
        curv *= fac[i-1];
        curv %= MOD;
        curv *= inver[k-1];
        curv %= MOD;
        curv *= inver[i-k];
        curv %= MOD;
        res += curv;
        if(res>=MOD)res-=MOD;
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 5584
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main() {
	int i, j;
	char S[101], T[101], temp;
	bool flag = false;

	scanf("%s", S);
	scanf("%s", T);

	for (i = 0; i < strlen(S); i++) {
		if (strcmp(S, T) == 0) {
			flag = true;
			break;
		}
		temp = S[0];
		for (j = 1; j < strlen(S); j++) {
			S[j - 1] = S[j];
		}
		S[j - 1] = temp;
	}

	printf(flag == true ? "Yes\n" : "No\n");

	return 0;
}

Measured memory_bytes: 128
using System;

namespace teisyutusensei
{
    class Program
    {
        static void Main(string[] args)
        {
            
            ////?????????????????????
            string dmmy = Console.ReadLine();

            string[] input = dmmy.Split(' ');

            int W = int.Parse(input[0]);
            int H = int.Parse(input[1]);
            int x = int.Parse(input[2]);
            int y = int.Parse(input[3]);
            int r = int.Parse(input[4]);

            int fr = 0;

            if (r <= x && x <= W - r)
            {
                if (r <= y && y <= H - r)
                {
                    fr = 1;
                }
            }

            if (fr == 1)
            {
                Console.WriteLine("Yes");
            }
            if (fr == 0)
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();

        }
    }

}

Measured memory_bytes: 5312
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int R;
int C;
int N;
int Y[214514];
int X[214514];
int used[214514];
vector<int> ps;

bool OnEdge(int y, int x) {
  if (y == 0 || y == R) return true;
  if (x == 0 || x == C) return true;
  return false;
}

int Calc(int y, int x) {
  if (y == 0) return x;
  if (x == C) return C + y;
  if (y == R) return C + R + C - x;
  if (x == 0) return C + R + C + R - y;
  assert(0);
}

int main() {
  scanf("%d%d%d", &R, &C, &N);
  rep(i, N) {
    int cnt = 0;
    rep(j, 2) {
      int idx = i*2 + j;
      scanf("%d%d", &Y[idx], &X[idx]);
      cnt += OnEdge(Y[idx], X[idx]);
    }
    
    if (cnt == 2) {
      rep(j, 2) {
        int idx = i*2 + j;
        ps.eb(idx);
      }
    }
  }

  sort(all(ps), [](int a, int b) {
    int av = Calc(Y[a], X[a]);
    int bv = Calc(Y[b], X[b]);
    return av < bv;
  });

  stack<int> st;
  for (int v : ps) {
    int idx = v/2;
    if (used[idx]) {
      if (st.top() != idx) {
        puts("NO");
        return 0;
      }
      st.pop();
    } else {
      st.push(idx);
      used[idx] = true;
    }
  }
  puts("YES");
}


Measured memory_bytes: 3188
# import sys
# input = sys.stdin.readline

n, k = map(int, input().split())
h = [0]*n

for i in range(n):
    h[i] = int(input())

h.sort()

ans = 10**9
for i in range(n-k+1):
    temp = h[i+k-1] - h[i]
    if ans > temp:
        ans = temp
print(ans)

Measured memory_bytes: 7472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

bool is753(int n){
	bool a3 = false;
	bool a5 = false;
	bool a7 = false;
	while(n){
		int a = n % 10;
		if(a == 3) a3 = true;
		else if(a == 5) a5 = true;
		else if(a == 7) a7 = true;
		else return false;
		n /= 10;
	}
	if(a3 && a5 && a7) return true;
	return false;
}

int main(){
	int n; cin >> n;
	int ans = 0;
	if(n < 500000000){
		for(int i=1; i<=n; i++){
			ans += is753(i);
		}
	}else{
		ans += 14384;
		for(int i=500000000; i<=n; i++){
			ans += is753(i);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {


    int price,money,count;

    cin >> price >> money >> count ;

    int riron = money / price ;

    if(riron >= count ) cout << count << endl;
    else cout << riron << endl;

    return 0;
}

Measured memory_bytes: 256
s = list(map(int, input()))
l = [0]*2
l[0] = s[0]*10 + s[1]
l[1] = s[2]*10 + s[3]

F = False
L = False

if 0 < l[0] <= 12:
  F = True
if 0 < l[1] <= 12:
  L = True

if F == True and L == True:
  print('AMBIGUOUS')

elif F == True:
  print('MMYY')

elif L == True:
  print('YYMM')

else:
  print('NA')

Measured memory_bytes: 9160
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    S = input()
    T = input()

    if S == T[:-1]:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10412
#define NAME "a"

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cctype>
#include <cassert>
#include <memory>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <iterator>

#define pb push_back
#define mp make_pair
#define frs first
#define snd second

using namespace std;

#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 7;
const ll INFLONG = (ll) 1e18 + 7;
const double EPS = 1e-9;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<string> vs;

typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;

template <typename T>
T sqr(T a) {
    return a * a;
}

int main() {
    srand(time(0));

//    freopen(NAME".in", "r", stdin);
//    freopen(NAME".out", "w", stdout);

    int n;
    cin >> n;
    char ok = 0;

    while (n) {
        int x = n % 10;
        n /= 10;

        if (x == 7) {
            ok = 1;
            break;
        }
    }

    cout << ((ok) ? "Yes" : "No") << endl;

//    printf("%.3lf\n", (double) clock() / CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int n,k;
int dp[11][2001];

int main(){
	vector<int> vcc[11];
    vector<int> vc[11];
	scanf("%d %d",&n,&k);
	int a,b;
	for(int i=0;i<n;i++){
		scanf("%d %d",&a,&b);
		vcc[b].push_back(a);
	}
	for(int i=1;i<11;i++){
		sort(vcc[i].begin(),vcc[i].end(),greater<int>());
        for(int j=0;j<=vcc[i].size();j++){
            int aa=0;
            for(int l=0;l<j;l++){
                aa+=vcc[i][l]+j-1;
            }
            vc[i].push_back(aa);
        }
	}

    fill(&dp[0][0],&dp[10][2000],-1);
    dp[0][0] = 0;
	for(int i=1;i<=10;i++){
        for(int j=0;j<=k;j++){
            if(j==0){dp[i][j]=0;continue;}
            int m = dp[i-1][j];
            for(int l=0;l<vc[i].size();l++){
               if(j-l<0){break;}
               if(dp[i-1][j-l] == -1){continue;}
               int a = dp[i-1][j-l] + vc[i][l];
               if(a > m){m = a;}
            }
            dp[i][j] = m;
        }
    }
    printf("%d\n",dp[10][k]);
}

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

signed main(){
	int N,K;
	cin >> N>>K;
	vector<int> H(N);
	for(int i=0;i<N;i++)cin>>H[i];
	sort(H.begin(),H.end());
	reverse(H.begin(),H.end());
	int ans=0;
	if(N>K){
		for(int i=K;i<N;i++)ans+=H[i];
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 1792
n = int(input())
H = list(map(int, input().split()))

No_flag = 0
for i in range(n-1, 0, -1) : 
    if H[i] >= H[i-1] : 
        pass
    elif H[i-1] - H[i] == 1 : 
        H[i-1] -= 1
    elif H[i-1] - H[i] >= 2 : 
        No_flag = 1
        break
    
if No_flag == 1 : 
    print("No")
else : 
    print("Yes")

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
//#define int 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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int a,b;cin >> a >> b;
  if(a>b)swap(a,b);
  if(a==2)cout << 1 << endl;
  else{
    if(b==2)cout << 3 << endl;
    else cout << 2 << endl;
  }

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		char[] str1 = br.readLine().toCharArray();
		char[] str2 = br.readLine().toCharArray();
		
		boolean checked[] = new boolean[str1.length];
		
		for(int i = 0; i < str1.length ; i++){
			if(checked[i]){
				continue;
			}
			
			for(int j = i + 1; j < str1.length ; j++){
				if((str1[i] == str1[j] && str2[i] != str2[j] )|| 
						(str1[i] != str1[j] && str2[i] == str2[j] )){
					System.out.println("No");
					return;
				}
				
				else if(str1[i] == str1[j]){
					checked[j] = true;
				}
			}
		}
		
		System.out.println("Yes");
		
	}

}


Measured memory_bytes: 29672
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder.XXX.A
{ 
    public class Program
    {
        public static void Main(string[] args)
        {
            var datas = cr();
            var cnt = 0;
            foreach(var data in datas)
			{
                if(data == 0)
				{
                    P(cnt+1);
                    return;
				}
                cnt++;
			}
        }

        private static StreamReader sr;
        public static int[] Ecr()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static string Er()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine();
        }
        public static string r()
        {
            return Console.ReadLine();
        }
        public static  int[] cr()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static int cri()
        {
            return int.Parse(Console.ReadLine());
        }
        public static void P(string str)
        {
            Console.WriteLine(str);
        }
        public static void P(int num)
        {
            P(num.ToString());
        }
    }
}


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

A = sorted(A)[::-1]
total = sum(A)
vote_need = total / (4 * M)

# print(A, total, vote_need)

c = 0
for a in A:
    if a >= vote_need:
        c += 1
    else:
        break
if c >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool ok = true;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=s.at(s.size()-1-i)){
      ok = false;
    }
  }
  string s1 = s.substr(0,((s.size()-1)/2));
  for(int i=0;i<s1.size();i++){
    if(s1.at(i)!=s1.at(s1.size()-1-i)){
      ok = false;
    }
  }
  string s2 = s.substr(((s.size()+3)/2)-1);
  for(int i=0;i<s2.size();i++){
    if(s2.at(i)!=s2.at(s2.size()-1-i)){
      ok = false;
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}
    

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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(9)<<fixed;
	
	char c;
	cin>>c;
	if('A'<=c && c<='Z')
		cout<<'A'<<endl;
	else
		cout<<'a'<<endl;
	return 0;
}

Measured memory_bytes: 3652
n = int(input())
h = list(map(int, input().split()))
maxcnt = 0
cnt = -1
hi = 10**9+1
for i in range(n):
    if h[i] <= hi:
        cnt += 1
        hi = h[i]
    else:
        cnt = 0
        hi = h[i]
    if maxcnt < cnt:
        maxcnt = cnt
print(maxcnt)

Measured memory_bytes: 63856
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int H, W, N;
	cin >> H >> W >> N;
	int ans = H+W;
	for(int k = 1; k <= H; k++)
		if(k*W >= N) ans = min(ans, k);
	for(int k = 1; k <= W; k++)
		if(k*H >= N) ans = min(ans, k);
	for(int k = 1; k <= H; k++) for(int l = 1; l <= W; l++)
		if(H*W-(H-k)*(W-l) >= N) ans = min(ans, k+l);
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define F first
#define int long long int
#define S second
#define boost ios_base::sync_with_stdio(false),cin.tie(NULL);
const int MOD = 998244353;
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp>  
//using namespace __gnu_pbds; 
//stringstream ss; string temp; ss<<str(original string) ss>>temp;

int32_t main()
{   
    boost
    
    int a,b; cin>>a>>b;
    cout<<max(0ll,a-2*b);
    return 0;
} 


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

using namespace std;

int check(string S, int length)
{
        int res = 1;
        for (int i = 0; i < length / 2; i++) {
                if (S[i] != S[length - i - 1])
                        res = 0;
        }

        return res;
}

int
main()
{
        string S;
        cin >> S;

        int ans = check(S, S.length());
        if (ans == 0) {
                cout << "No" << endl;
                return 0;
        }
        ans = check(S, S.length() / 2);
        if (ans == 0) {
                cout << "No" << endl;
                return 0;
        }

        cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e7 + 5;
const int maxm = 5e5 + 5;
const ll inf = 2147483647;

int main(){
    ll a, v, b, w, t;
    int f = 0;
    cin>>a>>v>>b>>w>>t;
    ll  d = abs(a - b);
    ll k = v - w;
    if(d <= k * t){
        cout<<"YES";
        return 0;
    }
    cout<<"NO";
    return 0;
}


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

int main() {
  double N,T,A,ans,min,dif;
  cin>>N>>T>>A;
  vector<double> H(N);
  min=100000;
  for(int i=0;i<N;i++){
    cin>>H.at(i);
    dif=abs((T-0.006*H.at(i))-A);
    
    if(dif<min){
      min=dif;
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <iostream>
#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

class UnionFind{
private:
  mutable vector<int> id;

  int getId(int i) const{
    if(i == id[i]) return i;
    return id[i] = getId(id[i]);
  }
public:
  UnionFind(int size = 0){ init(size); }
  ~UnionFind(){}
  void init(int size){
    id = vector<int>(size);
    for(int i = 0; i < size; i++)
      id[i] = i;
  }
  void unite(int i, int j){
    int next = min( getId(i), getId(j) );
    id[getId(i)] = id[getId(j)] = next;
  }
  int operator [](int i) const{ return getId(i); }
  int count() const{
    set<int> s;
    for(int i = 0; i < (int)id.size(); i++)
      s.insert(getId(i));
    return s.size();
  }
};


int main(){
  const int n = getInt();
  const int m = getInt();
  UnionFind uf(n);
  vector<int> p(n);
  REP(i,n) p[i] = getInt() - 1;
  REP(i,m){
    const int x = getInt() - 1;
    const int y = getInt() - 1;
    uf.unite(x, y);
  }

  vector<set<int> > s(n);
  REP(i,n){
    s[uf[i]].insert(p[i]);
  }

  int ans = 0;
  REP(i,n){
    if(s[uf[i]].count(i)) ans += 1;
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 10368
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<long long> dp(n + 1, 0);
    for (int i = 0; i <= n; i++) {
        dp[i] = i;
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 6; j + i <= n; j *= 6) {
            dp[i + j] = std::min(dp[i + j], dp[i] + 1);
        }

        for (int j = 9; j + i <= n; j *= 9) {
            dp[i + j] = std::min(dp[i + j], dp[i] + 1);
        }
    }

    std::cout << dp[n] << std::endl;
}


Measured memory_bytes: 1272
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    B = [0] * n
    x = 0
    for a in A:
        x ^= a
    for i in range(n):
        B[i] = x^A[i]
    print(" ".join(map(str,B)))


if __name__=='__main__':
    main()

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

int main() {
	int N; cin >> N;
	int a, odd=0, two=0, four=0;
	for(int i=0; i<N; ++i){
	    cin >> a;
	    if(a%2>0) ++odd;
	    else if(a%4>0) ++two;
	    else ++four;
	}
	if(odd<=four || (four+1==odd && two<1)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256