akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] roads = new int[n];
		
		for(int i = 0; i < m*2; i++) {
			roads[sc.nextInt()-1]++;
		}
		
		Arrays.stream(roads).forEach(out::println);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 29524
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric> // next_parmutation
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); i++)

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;

    if(y>=x*2 && y <= x*4 && y%2 == 0){
    cout << "Yes"<< endl;
    }else{
    cout << "No" << endl;
    }


}

Measured memory_bytes: 3624
n = gets.chomp.to_i
a = gets.split.map(&:to_i)

a.sort!
ans = []

def abs(a)
  a < 0 ? -a : a
end

cval = 0
maxv = a.last
a.delete(a.last)

idx = 0
center = maxv.to_f / 2.to_f
min = abs(center - a[0])
a.each_with_index do |v, i|
  if min > abs(center - v)
    min = abs(center - v)
    idx = i
  end
end

puts "#{maxv} #{a[idx]}"

Measured memory_bytes: 11136
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
map<ll, ll> m;
ll n, a, b, c, d;
ll find(ll n) {
	if(n == 0) {
		return 0;
	}
	if(n == 1) {
		return d;
	}
	if(m.count(n) != 0) {
		return m[n];
	}
	// ll ans = n * d;
	ll ans = 3*1e18;
	if(d < ans / n) {
		ans = n * d;
	}	
	ll pos[] = {2, 3, 5};
	ll price[] = {a, b, c};
	for(int i = 0; i < 3; i++) {
		ll num1 = n / pos[i];
		ll num2 = 1 + num1;
		ans = min(ans, price[i] + abs(n - num1*pos[i]) * d + find(num1));
		if(n % pos[i] != 0)
			ans = min(ans, price[i] + abs(num2*pos[i] - n ) * d + find(num2));
	}
	return m[n] = ans;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--) {
    	m.clear();
    	cin >> n >> a >> b >> c >> d;
    	cout<< find(n)<<"\n";
    }
}

Measured memory_bytes: 4436
N = int(input())
K = int(input())
X = int(input())
Y = int(input())

def goukei(N,K,X,Y):
    money = 0
    if N > K:
        for i in range(K):
            money += X
    else:
        for i in range(N):
            money += X
    if N - K > 0:
        for j in range(N-K):
            money += Y
    return money

print(goukei(N,K,X,Y))

Measured memory_bytes: 3064
//
// Created by MengHaitao on 2019/11/27 0027.
//

#include <iostream>
#include <vector>
using namespace std;
vector<int> vc;
int n,t,maximum,mins ;
void solve() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin>>t;
        vc.push_back(t);
    }
    maximum =-2000000000;
    mins=vc[0];
    for (int i = 1; i < n; ++i) {
        if(vc[i]-mins>maximum) maximum=vc[i]-mins;
        if(mins>vc[i]) mins=vc[i];
    }
    cout<<maximum<<endl;


}

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


Measured memory_bytes: 3844
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rd(x)  scanf("%lf" , &x)
#define rrd(x , y)  scanf("%lf%lf" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define we(x)  printf("%d\n" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++)
#define per(i , n , x)  for(int i = n ; i >= x ; i --)
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << '*' << x << '\n'
#define ddebug(x , y)  cout << '*' << x << ' ' << y << '\n'
#define ios std::ios::sync_with_stdio(false) , cin.tie(0)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std ;
using namespace __gnu_pbds ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
typedef pair<double , double> pdd ;
typedef pair<int , double> pid ;
const int inf = 0x3f3f3f3f ;
const ll linf = 0x3f3f3f3f3f3f3f3f ;
const int mod = 998244353 ;
const int maxn = 5005 ;
const int maxm = 30 ;
const double eps = 1e-6 ;
const double pi = acos(-1.0) ;
queue<pii> q ;
int n ;
int w[505][505] ;
int dis[505][505] ;
int row[4] = {-1 , 1 , 0 , 0} , col[4] = {0 , 0 , -1 , 1} ;
int main()
{
	r(n) ;
	rep(i , 0 , n - 1)  rep(j , 0 , n - 1)  w[i][j] = 1 ;
	rep(i , 0 , n - 1)  rep(j , 0 , n - 1)  dis[i][j] = min({i , n - 1 - i , j , n - 1 - j}) ;
	int ans = 0 ;
	rep(i , 0 , n * n - 1)
	{
		int x ;
		r(x) ;
		x -- ;
		int u = x / n , v = x % n ;
		ans += dis[u][v] ;
		w[u][v] = 0 ;
		q.push({u , v}) ;
		while(!q.empty())
		{
			int u = q.front().fi , v = q.front().se ;
			q.pop() ;
			rep(j , 0 , 3)
			{
				int nu = u + row[j] ;
				int nv = v + col[j] ;
				if(nu >= 0 && nu < n && nv >= 0 && nv < n
				&& dis[nu][nv] > dis[u][v] + w[u][v])
				  dis[nu][nv] = dis[u][v] + w[u][v] , q.push({nu , nv}) ;
			}
		}
	}
	we(ans) ;
	return 0 ;
}

Measured memory_bytes: 5744
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main(){
    ll n,k,r,s,p;
    string t;
    cin>>n>>k>>r>>s>>p>>t;
    ll ans=0;
    vector<vector<int>> dp(n,vector<int>(3));
    rep(i,n){
        dp[i][0]=0;
        dp[i][1]=0;
        dp[i][2]=0;
        if(t[i]=='r'){
            dp[i][2]=p;
        }else if(t[i]=='s'){
            dp[i][0]=r;
        }else if(t[i]=='p'){
            dp[i][1]=s;
        }
    }
    for(int i=n-1-k; i>=0; i--){
        dp[i][0]+=max(dp[i+k][1],dp[i+k][2]);
        dp[i][1]+=max(dp[i+k][0],dp[i+k][2]);
        dp[i][2]+=max(dp[i+k][0],dp[i+k][1]);

    }
    for(int i=0; i<k; i++){
        ans+=max(dp[i][0],max(dp[i][1],dp[i][2]));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int main() {
	map<int, int> m;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		m[A]++;
	}
	int ans = 0;
	for (auto x : m) ans += x.second % 2;
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
	v.resize(n);
	for (int i = 0; i < v.size(); i++) cin >> v[i];
}

bool cnt[30];

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

	if (S == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}

	rep(i, S.size()) {
		cnt[S[i] - 'a']++;
	}

	if (S.size() < 26) {
		char ch;
		rep(i, 26) {
			if (cnt[i] == 0) {
				ch = i + 'a';
				break;
			}
		}
		cout << S << ch << endl;
	} else {
		for (int pt = 25; pt >= 0; pt--) {
			for (char ch = S[pt] + 1; ch <= 'z'; ch++) {
				if (cnt[ch - 'a']) continue;
				cout << S.substr(0, pt) << ch << endl;
				return 0;
			}
			cnt[S[pt] - 'a'] = false;
			S = S.substr(0, pt);
		}
	}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, m;

int main() {
    cin >> n >> m;
    map<int, int> mcnt;
    for(int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        mcnt[a]++; mcnt[b]++;
    }

    bool flg = true;
    for(auto x : mcnt) {
        if(x.second % 2 != 0) {
            flg = false;
            break;
        }
    }

    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 7564
"use strict";

function main(input) {
  var lines = input.split('\n');
  var N = parseInt(lines[0]);
  var result = [];

  while (N !== 0) {
    if (N % 2 !== 0) {
      N--;
      result.push(1);
    } else {
      result.push(0);
    }

    N /= -2;
  }

  result.reverse();
  console.log(result.join("") || "0");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	ll x;
	cin >> x;
	for (ll i = -150; i <= 150; i++) {
		for (ll j = -150; j <= 150; j++) {
			if (i*i*i*i*i - j*j*j*j*j == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3648
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int a, b;
	cin >> a >> b;
	int hoge = (b - a) * (b - a - 1) / 2;
	cout <<  hoge - a << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pb push_back
#define log(x,b) (log(b)/log(x))
#define rep(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;
const int mod=1e9+7;
int32_t main()
{
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int m=t.size();
    if(n>m){cout<<"GREATER\n";return 0;}
    else if(n<m){cout<<"LESS\n";return 0;}
    else{
    int p=0;
        while(s[p]==t[p] && p<n)p++;
    if(p==n)puts("EQUAL");
    else if(s[p]>t[p])puts("GREATER");
    else puts("LESS");
    }

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
const int MOD = 1000000007;

long long modPow(long long a, long long n) {
    if (n == 1) return a;
    if (n % 2) {
        return a * modPow(a, n - 1) % MOD;
    } else {
        return modPow(a * a % MOD, n / 2);
    }
}

long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    for (int i = 0; i < r; i++) {
        A *= (n - i) % MOD;
        A %= MOD;
        B *= (r - i) % MOD;
        B %= MOD;
    }
    return A * modPow(B, MOD - 2) % MOD; 
}
 
int main() {
    long long X, Y; cin >> X >> Y;
    int n, m;
    if ((2 * X - Y) % 3 || (2 * Y - X) % 3) {
        cout << 0 << endl;
    } else {
        n = (2 * X - Y) / 3, m = (2 * Y - X) / 3;
        if (n < 0 || m < 0) {
            cout << 0 << endl;
        } else {
            cout << nCr(n + m, n) << endl;
        }
    }
}

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

int main()
{
  int n;
  cin>>n;
  n=n%10;
  if(n==2||n==4||n==5||n==7||n==9)cout<<"hon";
    else if(n==3)cout<<"bon";
  else cout<<"pon";
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int N = 1e7 + 4;
int c[N];
int main() {
#ifndef ONLINE_JUDGE
#endif
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n;
   cin >> n;
   for(int i= 1 ; i <= n ; ++i){
      for(int j = i ; j <= n ; j += i){
         c[j]++;
      }
   }
   long long rs = 0;
   for(int i = 1 ; i <= n ; ++i)
      rs += (1ll * i * c[i]);
   cout << rs << "\n";
}

Measured memory_bytes: 42656
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL N,A,B;
int main(){
    cin>>N>>A>>B;
    LL mi=A+(N-1)*B;
    LL ma=A*(N-1)+B;
    if(N==1&&(A!=B)){
       cout<<0<<endl;
       return 0;
    }
    if(A>B){
       cout<<0<<endl;
    }else{
       cout<<abs(ma-mi)+1<<endl;
    }
    return(0);
}

Measured memory_bytes: 256
s=input()
p=0
g=0
ans=0
for i in range(len(s)):
    if(s[i]=='p'):
        if(p+1<=g):
            p+=1
        else:
            g+=1
            ans-=1
    else:
        if(p+1<=g):
            p+=1
            ans+=1
        else:
            g+=1
print(ans)

Measured memory_bytes: 3316
import os
from collections import Counter

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
S = sys.stdin.buffer.readline().decode().rstrip()

eq = 0
nb = 0
l, m, r = 0, 1, 2
for w in range(1, N):
    l = 0
    m = l + w
    r = m + w
    while r < N:
        eq += S[l] == S[m] or S[m] == S[r] or S[r] == S[l]
        nb += 1
        l += 1
        m += 1
        r += 1
rgb = Counter(S)
na = 0
na += (N - rgb['R']) * (rgb['R'] * (rgb['R'] - 1) // 2)
na += (N - rgb['G']) * (rgb['G'] * (rgb['G'] - 1) // 2)
na += (N - rgb['B']) * (rgb['B'] * (rgb['B'] - 1) // 2)
na += (rgb['R'] - 1) * (rgb['R'] - 2) * rgb['R'] // 6
na += (rgb['B'] - 1) * (rgb['B'] - 2) * rgb['B'] // 6
na += (rgb['G'] - 1) * (rgb['G'] - 2) * rgb['G'] // 6

total = N * (N - 1) * (N - 2) // 6
print(total - na - nb + eq)

# ans = 0
# na2 = 0
# for l, m, r in itertools.combinations(range(N), r=3):
#     if abs(r - m) != abs(m - l):
#         ans += S[l] != S[m] and S[m] != S[r] and S[r] != S[l]
#     na2 += S[l] == S[m] or S[m] == S[r] or S[r] == S[l]
# print(ans)
# print(na2, na)


Measured memory_bytes: 74148
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
//#define for(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0};

void solve(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	sort(arr, arr+n);
	float temp=arr[0];
	for(int i=1;i<n;i++){
		temp=(arr[i]+temp)/2;
	}
	cout<<fixed<<setprecision(4)<<temp<<endl;

}


signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 256
n, y = map(int, input().split())
for i in range(n + 1):
  for j in range(n - i + 1):
    k = n - i - j
    if k >= 0:
      if 10000 * i + 5000 * j + 1000 * k == y:
        print(i, j, k)
        exit()
print(-1, -1, -1)

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

using namespace std;


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

	int  d;

	if (a > b)
		d = a - b - W;
	else
		d = b - a - W;

	if (d > 0)
		cout << d << endl;
	else
		cout << 0 << endl;		
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<functional>
using namespace std;
int main(){
	string str;
	string ans;
	cin >> str;
	for(int i = 0; i < str.size(); i++){
		ans += str[i] - 3 >= 'A'?str[i] - 3:str[i] - 3 + 26;
	}
	cout << ans << endl;
	return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int a , b ;
    cin >> a >> b ;

    int minn = b - a ;
    minn ++ ;

    int maxx = b + a ;
    maxx -- ;

    for ( int i=minn ; i < maxx + 1 ; i++ )
        cout << i << " " ;
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 764
import numpy as np
import itertools

H,W,K = map(int,input().split())
arr = []
for i in range(H):
    arr.append(list(input()))
narr = np.array(arr)
counter = 0


r = list(itertools.product([True, False], repeat = H))
c = list(itertools.product([True, False], repeat = W))
for row in r:
    for col in c:
        narrc = np.copy(narr)
        narrc[row, :] = '0'
        narrc[:, col] = '0'
        if np.count_nonzero(narrc == '#') == K:
            counter += 1
print(counter)

Measured memory_bytes: 26844
#include <stdio.h>

using namespace std;

int main()
{
  int n , curr = 0, max = 0 , x , per;
  scanf("%d" , &n);
  for(int i = 0; i < n; i++)
  {
    if(!i)
    {
      scanf("%d" , &x);
      per = x;
    }
    else 
    {
       scanf("%d" , &x);
       if(per >= x) curr++;
       else curr = 0;
       if(curr >= max) max = curr;
       per = x;
    }
  }
  printf("%d" , max);
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double ans;
    double dh = 30*h+m/2;
    double dm = m*6;
    const double i = M_PI/180;
    ans = a*a+b*b-2*a*b*cos(i*abs(dh-dm));
    ans=sqrt(ans);
    printf("%.20f",ans);
	return 0;
	//4.56425719433005567605

}


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

#define QQ 9
int main() {
	for (int i = 1; i <= QQ; i++) {
		for (int j = 1; j <= QQ; j++) {
			cout << i << "x" << j << "=" << i * j << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
int main(){
string S,T;
  cin>>S>>T;
  bool nazo=false;
 for(int i=0;i<=(S.size()-1);i++){
 	if(S.at(i)==T.at(i)){
    	nazo=true;
    }
   else{
   nazo=false;
     break;
   }
 }
if(nazo){
cout<<"Yes";
}
  else{
  cout<<"No";
  }
}

Measured memory_bytes: 3628
import numpy as np

N,M = map(int,input().split())

tmp_list = [[int(i) for i in input().split()] for i in range(N)]
tmp_list = np.array(tmp_list)
# print(np.argsort(tmp_list[:, 0]))
tmp_list = tmp_list[np.argsort(tmp_list[:, 0])].T
A_list = tmp_list[0]
B_list = tmp_list[1]

# print(A_list)
# print(B_list)


residue = M
min_cache = 0
idx = 0

while(True):
    if B_list[idx] >= residue:
        ans = min_cache + A_list[idx] * residue
        break
    else:
        residue = residue - B_list[idx]
        # print(residue)
        min_cache = min_cache + A_list[idx] * B_list[idx]
        # print(min_cache)
        idx += 1
    # print(min_cache)
print(ans)


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> input;

	rep(i, n){
		int x;
		cin >> x;

		vector<pair<int, int>> v;

		rep(i, x){
			int a, b;

			cin >> a >> b;
			v.push_back(make_pair(a - 1, b));
		}

		input.push_back(v);
	}

	int ans = 0;

	for(int i = 0; i < pow(2, n); i++){
		int bit = 1;

		int tmpans = 0;
		bool flag = true;

		for(int j = 0; j < n; j++){
			if(i & bit){
				rep(k, input[j].size()){
					int t;

					if(i & (1 << input[j][k].first)) t = 1;
					else t = 0;

					if(t != input[j][k].second){
						flag = false;
						// cout << i << " " << j << " " << t << " " << input[j][k].second << endl;
					}
				}

				tmpans++;
			}

			// cout << bit << endl;
			bit <<= 1;
		}

		if(flag){
			if(ans < tmpans) ans = tmpans;
		}
		
		// cout << ans << " " << tmpans << endl;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#C - Poll
N = int(input())
S = [str(input()) for i in range(N)]
S = sorted(S)
count = 1
tmpcount = 1
DP = [S[0]]
for i in range(1,N):
    if S[i] == S[i-1]:
        count += 1
        if tmpcount < count:
            DP.clear()
            DP.append(S[i])
            tmpcount = count
        elif tmpcount == count:
            DP.append(S[i])
        else:
            pass
    else:
        count = 1
        if tmpcount == count:
            DP.append(S[i])
        else:
            pass

for l in range(len(DP)):
     print(DP[l])

Measured memory_bytes: 20132
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int b[n];
    for(int i = 0; i < n-1; i++){
        cin >> b[i];
    }
    int dp[n];
    dp[0] = b[0];
    for(int i = 1; i < n-1; i++){
        dp[i] = dp[i-1] + min(b[i], b[i-1]);
    }
    cout << dp[n-2] + b[n-2] << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, T;
  cin >> n >> T;
  vector<int> c(n), t(n);
  rep(i, n) cin >> c[i] >> t[i];
  int ans = INF;
  rep(i, n) {
    if (t[i] <= T) cmin(ans, c[i]);
  }
  if (ans == INF)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    L = [1]
    temp = 1
    while temp <= N:
        temp *= 6
        L.append(temp)
    temp = 1
    while temp <= N:
        temp *= 9
        L.append(temp)
    L.sort()
    D = [i for i in range(N+1)]
    for i in L[1:]:
        for j in range(i, N+1):
            D[j] = min(D[j], D[j-i]+1)
    print(D[N])

if __name__ == "__main__":
    main()

Measured memory_bytes: 74256
#include <stdio.h>
#include <iostream>
#include <cmath>

using namespace std;

bool isPrime(int n) {
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    if (n == 3) return true;
    if (n % 3 == 0) return false;

    for (int i = 5; i <= sqrt(n); i += 2) {
        if (n % i == 0) {
            return false;
        }
    }

    return true;
}

int main() {
    int X; cin >> X; // 2 <= X <= 1e5

    for (int i = X; i <= 200000; ++i) {
        if (isPrime(i)) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
bool checked[7400000];
int n, m;
int MAX = 7370000;
int main() {
    //cout.precision(10);
    while(true) {
        cin >> m >> n;
        if(m == 0 && n == 0) break;
        int now = m;
        for(int i = 0; i <= MAX; i++) checked[i] = false;
        while(true) {
            while(checked[now]) now++;
            if(n == 0) break;
            n--;
            for(int j = now; j <= MAX; j += now) {
                checked[j] = true;
            }
        }
        cout << now << endl;
    }
    return 0;
}


Measured memory_bytes: 10320
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import glob

class InputGenerator(object):
    def __init__(self, input_path=None):
        if input_path != None:
            self.g = self.input_generator(input_path)
        else:
            self.g = None

    def input_generator(self, input_path):
        with open(input_path) as f:
            for line in f:
                yield line

    def get_input(self):
        if self.g == None:
            return input()
        else:
            return next(self.g)

def solve(gen):
    len_list = gen.get_input().rstrip().split()
    [x, k, d] = list(map(int, len_list))
    # print(x, k, d)

    r = abs(x) % d
    l = d - r
    q = abs(x) // d

    if abs(x) > k * d:
        print(abs(x) - k * d)
    elif (k - q) % 2 == 0:
        print(r)
    else:
        print(l)

if __name__ == '__main__':
    test_flag = len(sys.argv) > 1

    if test_flag == True:
        file_path_list = sorted(glob.glob('test/*'))
    else:
        file_path_list = [None]

    for file_path in file_path_list:
        gen = InputGenerator(file_path)
        solve(gen)


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

long long ans;
int n;

int main(){

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

    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j+=i){
            ans+=j;
        }
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
int main(){
    //宣言、入力部
    ll n,m; cin >> n >> m;
    vector<ll> a(n);
    vector<ll> b(m),c(m);
    rep(i,n) cin >> a[i];
    vector<pair<ll,ll>> CB(m);

    //B[i],C[i]をpairにする
    rep(i,m){
        cin >> b[i] >> c[i];
        CB[i] = make_pair(c[i],b[i]);
    }


    long long ans = 0; //答えとして出力


    //A,CBをそれぞれソート
    //CBベクトルは降順にする
    sort(a.begin(),a.end());
    sort(CB.begin(),CB.end(),greater<pair<ll,ll>>());


    ll point = 0; //このインデックスと、これより右のaの要素は未更新
    ll tmp; //lower_bound()のイテレータとa先頭のイテレータとの距離を保存
    //0 <= i < tmpでa[i]がc[]より小さい

    //A[]の中でC[i]を超える最初の値を二分探索
    //そのインデックスとB[i]+pointで大きい方について入れ替え判定を考える
    //入れ替えた数から足していく
    rep(i,m){
        tmp = ll(lower_bound(a.begin(),a.end(),CB[i].first) - a.begin() );
        if(min(tmp,CB[i].second + point) >= n){ //書き替えていない残り全てを書き替える場合
            ans += (n-point)*CB[i].first;
            point = n;
            break;
        }else if(min(tmp,point + CB[i].second) >= point){ //普通に書き替える場合
            ans += (min(tmp,point + CB[i].second) - point)*CB[i].first;
            point = min(tmp,point + CB[i].second); //ポインター更新
        }else{ //書き替えられない場合
            continue;
        }
    }
    
    //書き替えてないa[]を足す
    for(int i = point; i < n; i++) ans += a[i];

    //最後に出力
    cout << ans << endl;
}

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

int main(void)
{
    int H, N;
    int A[999999];
    int i,j;
    int ij;
    int max;

    cin >> H >> N;

    for (i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    for ( i = 0; i < N; i++)
    {
        H -= A[i];
    }

    if (H <= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        String d = "" + a.charAt(0) + b.charAt(0) + c.charAt(0);
        System.out.println(d.toUpperCase());
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    bool flg =false;

    for(int i = 1; i < 10; i++){
        for (int j = 1; j < 10; j++)
        {
            if(i * j ==N){
                flg = true;
            }
        }   
    }

    if(flg){
        cout << "Yes" <<endl;
    }else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        for (int i = 0; i < n + 1; i++) {
            a[i] = sc.nextLong();
        }
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextLong();
        }
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += Math.min(a[i], b[i]);
            if (a[i] - b[i] < 0) {
                ans += Math.min(a[i + 1], b[i] - a[i]);
                a[i + 1] = Math.max(0, a[i + 1] - b[i] + a[i]);
            }
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 24564
/* AOJ 0053
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0053
 *
 */

#include <stdio.h>

#define true 1
#define false 0
#define SIZE 200000

int table[SIZE];


int isprime(int n){
    int i;
    for(i=2;i*i<=n;i++){
        if(table[i] && !(n%i)){
            return false;
        }
    }
    return true;
}

void build(void){
    int i;
    table[0]=1;
    table[1]=1;
    table[2]=1;
    for(i=2;i<SIZE;i++){
        table[i]=isprime(i);
    }
}


int sumOfPrime(int n){
    int sum;
    int i, j;
    sum = 0;
    i = 0;
    j = 1;

    while(i<n){
        j++;
        while(!table[j]){
            j++;
        }
        sum += j;
        i++;
    }
    return sum;
}


int main(){
    int n, largest, smallest;
    build();
    while(scanf("%d", &n) == 1 && n){
        printf("%d\n", sumOfPrime(n));
    }

    return 0;
}

Measured memory_bytes: 1016
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<climits>
#include<iomanip>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int dx[] = {+0,+1,+0,-1,+1,+1,-1,-1};
int dy[] = {+1,+0,-1,+0,-1,+1,-1,+1};
int H,W;
map<string,int> cnt;
string ans;
vector<string> vec;

/*
void compareS(string &a,string b)
{
  int as = a.size();
  int bs = b.size();
  if(bs < 2)return;
  cnt[a]++,cnt[b]++;
  if(cnt[b] < 2)return;
  if(as > bs)return;
  if(as != bs)a = (as < bs)?b:a;
    a = min(a,b);
}
*/

void dfs(string *G,bool used[][20],int x,int y,int dir,string s)
{
  if(used[y][x])return;
  used[y][x] = true;
  //compareS(ans,s);
  if(s.size() >= 2)vec.push_back(s);
  int nx = (x+dx[dir]+W)%W, ny = (y+dy[dir]+H)%H;
  dfs(G,used,nx,ny,dir,s+G[ny][nx]);
}

int main()
{
  //clock_t s,t;
  //s = clock();
  while(cin >> H >> W,H|W)
    {
      vec.clear();
      cnt.clear();
      string G[H];
      rep(i,H)
	cin >> G[i];

      ans = "";
      rep(i,H)
	{
	  rep(j,W)
	    {
	      rep(k,8)
		{
		  bool used[10][20];
		  rep(a,H)rep(b,W)used[a][b] = false;		 
		  dfs(G,used,j,i,k,string(1,G[i][j]));
		}
	    }
	}
	  
      
      sort(vec.begin(),vec.end());
      rep(i,vec.size()-1)
	{
	  if(vec[i] == vec[i+1])
	    {
	      int vs = vec[i].size();
	      int as = ans.size();
	      if(vs < as)continue;
	      if(vs != as)ans = (as < vs)?vec[i]:ans;
	      else        ans = min(ans,vec[i]);
	      i++;
	    }
	}
      
	ans == ""?cout << 0 << endl:cout << ans << endl;

    }
  //t = clock();
  //cout << setiosflags(ios::fixed) << setprecision(10) << (double)(t-s)/CLOCKS_PER_SEC << endl;
  return 0;
}

Measured memory_bytes: 28772
#include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main(){
	vector<pair<double , int> > a,b,c,d;
	int x;
	double y;

	rep(i,8){
		cin>>x>>y;
		a.pb(make_pair(y,x));
	}
	rep(i,8){
		cin>>x>>y;
		b.pb(make_pair(y,x));
	}
	rep(i,8){
		cin>>x>>y;
		c.pb(make_pair(y,x));
	}

	sort(all(a));
	sort(all(b));
	sort(all(c));

	d.pb(a[2]);
	d.pb(b[2]);
	d.pb(c[2]);
	sort(all(d));
	rep(i,2)printf("%d %.2lf\n",a[i].second,a[i].first);
	rep(i,2)printf("%d %.2lf\n",b[i].second,b[i].first);
	rep(i,2)printf("%d %.2lf\n",c[i].second,c[i].first);
	rep(i,2)printf("%d %.2lf\n",d[i].second,d[i].first);
}

Measured memory_bytes: 1252
#include<iostream>

using namespace std;

int main() {

	int N, K, x[1000];
	int sum = 0;

	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}

	for (int i = 0; i < N; i++) {

		if (K - x[i] > x[i]) {

			sum += 2 * x[i];
		}
		else {

			sum += 2 * (K - x[i]);
		}
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  ll n,i=2,k=2;
  std::cin >> n;
  if(n<4 && n!=1){printf("1\n"); return 0;}
  while(k<=n){
    i++;
    k=i*i;
  }
  std::cout << (i-1)*(i-1) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char moji[21];
	int a,i;
	scanf("%s",moji);
	a=strlen(moji);
	a=a-1;
	for(;a!=-1;a--)printf("%c",moji[a]);
	
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
import sys


def outer(vec_a, vec_b):
    return vec_a[0] * vec_b[1] - vec_a[1] * vec_b[0]

try:
    while True:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
        vec_12 = [x2-x1, y2-y1]
        vec_23 = [x3-x2, y3-y2]
        vec_31 = [x1-x3, y1-y3]
        vec_1p = [xp-x1, yp-y1]
        vec_2p = [xp-x2, yp-y2]
        vec_3p = [xp-x3, yp-y3]
        if (outer(vec_12, vec_1p) > 0 and
                outer(vec_23, vec_2p) > 0 and
                outer(vec_31, vec_3p) > 0):
            print('YES')
        elif (outer(vec_12, vec_1p) < 0 and
                outer(vec_23, vec_2p) < 0 and
                outer(vec_31, vec_3p) < 0):
            print('YES')
        else:
            print('NO')

except:
    sys.exit()

Measured memory_bytes: 5596
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

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

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

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    priority_queue<ll> que;
    set<ll> value_set;
    REP(i, N){
        cin >> A[i];
    }
    REP(i, N) cin >> F[i];

    sort(A.rbegin(), A.rend());
    sort(F.begin(), F.end());

    ll x, ub = 1e12, lb = -1;
    while(lb + 1 < ub) {
        cerr << "lb = " << lb << " ub = " << ub << endl;
        x = (ub + lb)/2;

        ll sum = 0;
        for(int i=0; i<N; i++)
            sum += max(A[i] - x / F[i], 0ll);
        cerr << sum << endl;
        if(sum<=K)
            ub = x;
        else
            lb = x;
    }
    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 3328
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n;
  readf (" %d", &n);
  auto a = new int[n];
  foreach (i; 0 .. n) {
    readf (" %d", &a[i]);
  }
  int j;
  foreach (i; 1 .. n + 1) {
    while (j < n && a[j] != i) {
      ++j;
    }
    if (j >= n) {
      int res = n - (i - 1);
      if (res >= n) res = -1;
      writeln (res);
      return;
    }
  }
  writeln (0);
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int main(){
#ifdef LOCAL
	freopen("in.txt","r",stdin);
#endif
	int n,x,y;
	scanf("%d",&n);
	int flag=0,now=0;
	for(int i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		if(x==y)now++;
		else now=0;
		if(now==3)flag=1;
	}
	if(flag)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 3684
def solve(k, t ,a):
    if t == 1:
        return k-1
    Q = [[i, num] for i, num in enumerate(a)]
    prev = -1
    ans = 0
    for i in range(k):
        Q = sorted(Q, key=lambda _:-_[1])
        i1, num1 = Q[0]
        i2, num2 = Q[1]
        if (prev != i1) or (num2 == 0):
            Q[0][1] -= 1
            if prev == i1:
                ans += 1
            prev = i1
        else:
            Q[1][1] -= 1
            prev = i2
    return ans

k, t = map(int, input().split())
a = list(map(int, input().split()))
print(solve(k, t, a))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

void solve()
{
	int Q;
	cin >> Q;
	for(int i = 0; i < Q; ++i)
	{
		int c, a, n;
		cin >> c >> a >> n;
		int team = min(c, min(a, n));
		c -= team;
		a -= team;
		n -= team;
		if(c >= 2 * a)
		{
			team += a;
			c -= a * 2;
			a = 0;
		}
		else
		{
			team += c / 2;
			a -= c / 2;
			c = 0;
		}
		team += c / 3;
		cout << team << endl;
	}
}

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

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin>>s>>k;
  vector<string> su;
  for(int j=1;j<=k;j++){
    for(int i=0;i+j-1<s.length();i++){
      su.push_back(s.substr(i,j));
    }
  }
  sort(su.begin(),su.end());
  unique(su.begin(),su.end());
  cout<<su[k-1]<<endl;
}

Measured memory_bytes: 1660
def cnt_div_two(n):
    res = 0
    while n % 2 == 0:
        n //= 2
        res += 1
    return res


ans = 0
max_cnt = -1
for i in range(1, int(input()) + 1):
    cdt = cnt_div_two(i)
    if cdt > max_cnt:
        ans = i
        max_cnt = cdt
print(ans)


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

const int N=2e5+100;
const int mod=1e9+7;

int a[N];
int vis[N];
int has[N];

vector<int>ve[N];
int cnt;
int ans=0;
void bfs(int x)
{
    queue<int>q;
    q.push(x);
    vis[x]=1;
    has[cnt]++;
    while(q.size()){
        int kk=q.front();q.pop();
        for(auto v:ve[kk]){
        if(!vis[v]){
            q.push(v);
            vis[v]=1;
            has[cnt]++;
        }
        }
    }
  //  cout<<cnt<<" "<<has[cnt]<<endl;
    ans=max(ans,has[cnt]);
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    int n,m;
    cin>>n>>m;

    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        ve[a].push_back(b);
        ve[b].push_back(a);
    }

    for(int i=1;i<=n;i++){
          if(!vis[i]){
            cnt++;
            bfs(i);
          }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15852