akhauriyash/Code-Regression huggingface dataset:
using System;
class Program
{
    static void Main(string[] args)
    {
        /*
        // 整数の入力
        int a = int.Parse(Console.ReadLine());
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int b = int.Parse(input[0]);
        int c = int.Parse(input[1]);
        // 文字列の入力
        string s = Console.ReadLine();
        //出力
        Console.WriteLine((a + b + c) + " " + s);

        Console.ReadLine();
        */
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int b = int.Parse(input[0]);
        int c = int.Parse(input[1]);

        if (b * c % 2 == 0)
        {
            Console.WriteLine("Even");
        }
        else
        {
            Console.WriteLine("Odd");
        }

        Console.ReadLine();
    }
}

Measured memory_bytes: 11092
def main():
    n = int(input())
    high = list(map(int, input().split()))
    INF = float("inf")

    def chmin(a, b):
        if a > b:
            a = b
        return a

    dp = [INF] * n

    dp[0] = 0

    for i in range(1, n):
        dp[i] = chmin(dp[i], dp[i - 1] + abs(high[i] - high[i - 1]))
        if i > 1:
            dp[i] = chmin(dp[i], dp[i - 2] + abs(high[i] - high[i - 2]))

    print(dp[n - 1])

if __name__ == "__main__":
  	main()


Measured memory_bytes: 52296
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
string s, t = "CODEFESTIVAL2016";
int main() {
	cin >> s;
	int ret = 0;
	for (int i = 0; i < 16; i++) if (s[i] != t[i]) ret++;
	cout << ret << endl;
	return 0;
}

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

int main(void)
{
    int a,b,c,d,i;

        while(scanf("%d %d",&a,&b)!=-1){
       
        c=a+b;
        d=log10(c);
        printf("%d\n",d+1);
        }
    return 0;
}

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

using namespace std;
#define BUF (1000)
#define ll long long 

int n;
vector<int> v;
vector<int> v_sort;

int main(void){
	cin >> n;
	for(int i=0;i<n;i++){
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
		v_sort.push_back(tmp);
	}

	sort(v_sort.begin(), v_sort.end());

	int ml = v_sort[n/2-1];
	int mh = v_sort[n/2];

	for(int i=0;i<n;i++){
		if(v[i]<=ml){
			cout << mh << "\n";
		}else{
			cout << ml << "\n";
		}
	}

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;
using tTree = __gnu_pbds::tree<ll, __gnu_pbds::null_type, less<ll>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

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

#define FACSIZE 200002

ll invfac[FACSIZE];
ll fac[FACSIZE];

template <class T>
bool chmax(T &, const T &);
template <class T>
bool chmin(T &, const T &);
ll gcd(ll, ll);
ll powLL(ll x, ll y);

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
ll comb(ll, ll);
void make_fact(ll);
void make_invfact(ll);
void fact_init();

int main(void)
{
  ll k, x;
  cin >> k >> x;
  if (500 * k >= x)
  {
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return mod_mul(t, t);
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = mod_mul(t, t);
    return (k % mod) * (x % mod);
  }
}
ll mod_add(ll a, ll b)
{
  return ((a % mod) + (b % mod)) % mod;
}

ll mod_mul(ll a, ll b)
{
  return ((a % mod) * (b % mod)) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void fact_init()
{
  make_fact(FACSIZE - 1);
  make_invfact(FACSIZE);
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

ll comb(ll n, ll r)
{

  return mod_mul(mod_mul(fac[n], invfac[r]), invfac[n - r]);
}
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;
}

ll qp(ll a, ll b)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * mod_mul(ans, a) % mod;
    a = 1LL * mod_mul(a, a) % mod;
  } while (b >>= 1LL);
  return ans;
}
ll qp(ll a, ll b, ll mo)
{
  ll ans = 1LL;
  do
  {
    if (b & 1LL)
      ans = 1LL * (ans % mo) * (a % mo);
    a = 1LL * (a % mo) * (a % mo);
  } while (b >>= 1LL);
  return ans;
}
ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}
ll powLL(ll x, ll y)
{
  ll ans = 1LL;
  for (ll i = 0LL; i < y; i++)
    ans *= x;
  return ans;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N, K; cin >> N >> K;
  vector<LL> V(N); cin >> V;

  LL vmax = 0;
  for (int l = 0; l <= min(N, K); ++l) {
    for (int r = 0; l + r <= min(N, K); ++r) {
      priority_queue<LL> que;
      LL score = 0;
      for (int i = 0; i < l; ++i) {
        score += V[i];
        if (V[i] < 0) que.push(-V[i]);
      }
      for (int i = 0; i < r; ++i) {
        int j = N - i - 1;
        score += V[j];
        if (V[j] < 0) que.push(-V[j]);
      }

      int k = K - l - r;
      for (int i = 0; i < k; ++i) {
        if (que.empty()) break;
        score += que.top(); que.pop();
      }
      vmax = max(vmax, score);
    }
  }
  cout << vmax << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define CYES cout << "Yes" \
                  << "\n";
#define CNO cout << "No" \
                 << "\n";
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const string MM = " ";

struct UnionFind
{
    vector<int> _parent;
    vector<int> _size;

    explicit UnionFind(int n) : _parent(n), _size(n, 1LL)
    {
        for (int i = 0; i < n; i++)
            _parent[i] = i;
    }

    int root(int x)
    {
        if (_parent[x] == x)
            return x;
        return _parent[x] = root(_parent[x]);
    }

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

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        if (size(rx) < size(ry))
            swap(rx, ry);
        _parent[ry] = rx;
        _size[rx] += _size[ry];
    }

    int size(int x)
    {
        return _size[root(x)];
    }
};

int main()
{
    CFS
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind relation(n);
    vector<int> f(n, 0);
    vector<pii> b;
    for (size_t i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        f[a]++;
        f[b]++;
        relation.unite(a, b);
    }
    for (size_t i = 0; i < k; i++)
    {
        int c, d;
        cin >> c >> d;
        c--;
        d--;
        b.emplace_back(c, d);
    }
    vector<int> ans(n);
    for (size_t i = 0; i < n; i++)
    {
        ans[i] = relation.size(i) - f[i] - 1;
    }
    for (size_t i = 0; i < b.size(); i++)
    {
        int c, d;
        tie(c, d) = b[i];
        if (relation.same(c, d)) {
            ans[c]--;
            ans[d]--;
        }
    }
    
    for (size_t i = 0; i < n; i++)
    {
        cout << ans[i] << MM;
    }
    cout << "\n";
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int sum = 0;
  for (int i = A; i <= B; i++) {
    int c, d, f, g;
    int j = i;
    g = j % 10;
    j /= 10;
    f = j % 10;
    j /= 100;
    d = j % 10;
    j /= 10;
    c = j % 10;
    if ((c == g) && (d == f))
      sum++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int INF = 1e+18;
int n;
int a[400];
int ra[401];
int dp[400][400];

//[l, r]
int dfs(int l, int r) {
	if (l >= r) return 0;
	if (dp[l][r] != -1) return dp[l][r];
	
	int i, ret = INF;
	for (i = l; i < r; i++) {
		int res = dfs(l, i) + dfs(i + 1, r) + ra[r + 1] - ra[l];
		ret = min(res, ret);
	}
	return dp[l][r] = ret;
}

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	rep(i, n) ra[i + 1] = ra[i] + a[i];
	rep(i, n) rep(j, n) dp[i][j] = -1;
	cout << dfs(0, n - 1) << endl;
	return 0;
}

Measured memory_bytes: 1536
n, k = map(int, input().split())
A = list(map(int, input().split()))

dp = [0] * (k+1)

for i in range(1, k+1):
    for a in A:
        if i - a < 0:
            break
        if dp[i-a] == 0:
            dp[i] = 1

if dp[k] == 1:
    print("First")
else:
    print("Second")

Measured memory_bytes: 3828
import numpy as np

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

C = np.array([list(map(int, input().split())) for _ in range(N)])

cost = float("inf")

for i in range(2**N):
    buy = np.zeros(M+1)
    for j in range(N):
        if ((i >> j)&1):
            buy += C[j]
        if np.all(buy[1:] >= X):
            cost = min(cost, buy[0])

if cost == float("inf"):
    print(-1)
else:
    print(int(cost))

Measured memory_bytes: 27016
#include <stdio.h>

int main(void)
{
	int N;
	scanf("%d", &N);
	int i = 0;
	while (i <= 50000)
	{
		if ((int)(i * 1.08) == N)
		{
			printf("%d\n", i);
			return 0;
		}
		i++;
	}
	printf(":(\n");
	// printf("%d\n", y);
	// printf("%f\n", y * 1.08);
	return (0);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n;
  ll a[22222]={};
  ll b[22222]={};
  cin>>n;
  for(int i=0;i<n;i++){
    ll p;
    cin>>p;
    if(p!=1)b[p-2]+=n-i;
    if(p!=n)a[p]+=n-i;
  }
  for(int i=1;i<n;i++){
    a[i]+=a[i-1];
    b[n-1-i]+=b[n-i];
  }
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<i+1+a[i];
  }
  cout<<endl;
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<n-i+b[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
// typedef int long l;
typedef pair<int, int> Pii;

int n, l;
string s[100];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> l;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(s, s + n);
    for (int i = 0; i < n; i++) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<unordered_map>
#include<bits/stdc++.h>
#define ll long long 
#define dd double
using namespace std;
const ll MOD = 1e9 + 7; 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  string s;
  cin>>s;
  int k;
  cin>>k;
  int i;
  for(i=0;i<s.length();i++){
  	if(i!=(k-1)&&s[i]!=s[k-1]){
  		s[i]='*';
	  }
  }
  cout<<s<<endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<vector<int> > a(2, vector<int>(n));
	rep(i, 0, 2){
		rep(j, 0, n){
			cin >> a[i][j];
		}
	}
	int ans = 0;
	rep(i, 0, n){
		int tmp = 0;
		rep(j, 0, i + 1){
			tmp += a[0][j];
		}
		rep(j, i, n){
			tmp += a[1][j];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  int pos = 1;
  REP(i, n) {
    if (a[i] == pos) pos++;
  }
  int ans;
  if (pos == 1) ans = -1;
  else ans = n - (pos - 1);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 1024
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

N = int(input())						# 5

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

P=[]
for i in range(N):
	x, y = map(int, input().split())
	P.append((x,y))

#print(P)


from itertools import permutations
from itertools import combinations
L = list(combinations(P, 2))
#print( L )
#print( len(L) )

A=[]

for l in L:
	a=l[1][0]-l[0][0]
	b=l[1][1]-l[0][1]
	if a<0:
		a,b=-a,-b
	if a==0 and b<0:
		b=-b
	A.append((a,b))

#print(A)


# 各朝食メニューの回数を調べる
from collections import defaultdict

d = defaultdict(int)
for b in A:
	d[b] += 1

#print("dict(d)", dict(d))
# => {'pan': 2, 'kome': 4, 'cereal': 1}

# Value降順
B=[]
for k, v in sorted(d.items(), key=lambda x: -x[1]):
	#print(str(k) + ": " + str(v))
	break

#print("k,v", k,v)

print(N-v)

Measured memory_bytes: 39664
N, K = map(int, input().split())
A = list(map(int, input().split()))
imos = [0]*(N+1)

# 全体でO(NlogN) ≒ 10^6
for k in range(K): # 下のifによってO(logN)で抑えられる.
    if min(A) == N:
        break

    imos = [0]*(N+1)
    for i,a in enumerate(A): # O(N)
        imos[max(0, i-a)] += 1
        imos[min(N, i + a + 1)] -= 1
        
    A = [imos[0]]
    for i in range(1,len(imos)-1): # O(N)
        A.append(A[i - 1] + imos[i])
        
print(*A, sep=" ")

Measured memory_bytes: 219792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t=0,x=0,y=0,f=0,time,tx,ty,i;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>time>>tx>>ty;
        if((abs(tx-x)+abs(ty-y))%2!=(time-t)%2||abs(tx-x)+abs(ty-y)>(time-t))
        {
            f=1;
        }
        t=time;
		x=tx;
		y=ty;
    }
    if(f==0)
	{
		cout<<"Yes";
	}
    else
	{
		cout<<"No";
	}
    return 0;
}

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

int main() {
  vector<int> t(3);
  for (int i = 0; i < 3; i++) {
    cin >> t[i];
  }
  sort(t.begin(), t.end());
  cout << t[0] + t[1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i,N)cin >> A[i];
	ll ans = 0;
	for(int i = 1; i < N; ++i){
		ans += max(0LL, A[i-1] - A[i]);
		A[i] = max(A[i], A[i-1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4788
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n = ni()
ans = 0
for a in range(1,n):
    ans += (n-1)//a
print(ans)


Measured memory_bytes: 67984
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        if(n <= 999){
        	System.out.println("ABC");
        }else{
        	System.out.println("ABD");
        }
    }
}

Measured memory_bytes: 35720
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

const int N = 1e5+10;
int a[N];
int main(){
    int k;
    cin >> k;
    if(k%2==1)cout << k/2+1;
    else cout << k/2;





    return 0;
}

Measured memory_bytes: 256
/*************************************************************************
     File Name: 1.cpp
     ID: Liusiyu
     BLOG: http://blog.csdn.net/r_o_j
     LANG: C++ 
     Mail: 779532360@qq.com 
     Created Time: 2016年07月23日 星期六 20时17分41秒
************************************************************************/
#include<bits/stdc++.h>
#define MEM(a,x) memset(a,x,sizeof(a));
#define MEMINF(a) memset(a,0x3f,sizeof(a));
#define MAPIT(a,b) map<a,b>::iterator it;
#define VECIT(type) vector<type>::iterator it;
#define SETIT(type) set<type>::iterator it;
using namespace std;
typedef long long ll;
const int MAXN=1e2+10;
//const int MINN=;
const int INF=0x3f3f3f3f;
int main()
{
  char a[11000];
  bool b[10];
  int n,k;
  while(cin>>a>>k){
  MEM(b,0);
  for(int i=0;i<k;i++){
    int c;
    cin>>c;
    b[c]=1;
  }
  int len=strlen(a);
  int flag=0;
  for(int i=0;i<len;i++){
    if(b[a[i]-48]){
      flag=1;
      break;
    }
  }
    int flag2=1;
  char ans[100];
  int canfind;
  if(flag){
    int h=0;//代表这从这一位开始最大
    for(int i=0;i<len;i++){
      canfind=0;
      if(!h){
        if(b[a[i]-48]){
          h=1;
          for(int j=a[i]-48;j<10;j++)
          if(b[j]==0){ans[i]=j+48;canfind=1;break;}
        }
        else
        ans[i]=a[i];
      }
      else{
          for(int j=0;j<10;j++)
          if(b[j]==0){
            ans[i]=j+48;
            canfind=1;
            break;
          }
        }
      if(!canfind){
        h=0;
        int j;
        if(i!=0)j=0;
        else j=1;
        for(;j<10;j++)
        if(b[j]==0){
          ans[i]=j+48;
          break;
        }
      }

      if(flag2)
      if(i==len-1){
        h=1;
        if(strncmp(a,ans,len)>0){
        len++;
          flag2=0;
        }
      }
    }
    for(int i=0;i<len;i++)
    cout<<ans[i];
    puts("");
  }
  else
  cout<<a<<endl;
  }

}


      


Measured memory_bytes: 256
package main

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

func solve() {
	n := getInt()
	as := getIntSlice(n)

	cumGcdL := make([]int, n)
	cumGcdL[0] = as[0]
	for i := 1; i < n; i++ {
		cumGcdL[i] = gcd(cumGcdL[i-1], as[i])
	}
	cumGcdR := make([]int, n)
	cumGcdR[n-1] = as[n-1]
	for i := n - 2; i >= 0; i-- {
		cumGcdR[i] = gcd(cumGcdR[i+1], as[i])
	}

	ans := -1
	for i := 0; i < n; i++ {
		var x int
		switch i {
		case 0:
			x = cumGcdR[i+1]
		case n - 1:
			x = cumGcdL[i-1]
		default:
			x = gcd(cumGcdL[i-1], cumGcdR[i+1])
		}

		ans = max(ans, x)
	}
	fmt.Fprintln(wr, ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

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

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 4736
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;
int main() {
    //cout<<endl;
    string s;
    int c=0,max=0;
    cin>>s;
    for(int i=0;s[i]!='\0';i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T'){
            c++;
        }else{
            if(max<c)max=c;
            c=0;
        }
    }
    if(max<c)max=c;
    cout<<max<<endl;
    return 0;
}



Measured memory_bytes: 256
n,k = (int(x) for x in input().split())
p = list(map(int, input().split()))
list2 = [0]
ma=0
for i in range(n):
	list2.append(list2[i]+p[i])
for i in range(n-k+1):
	su = list2[k+i-n-1]-list2[i]
	if ma < su:
		ma=su
print((ma+k)/2)

Measured memory_bytes: 25060
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

#define sz(a) (int)(a.size())

const int MAXN = 1e5 + 10, MAXD = 11;

vector <int> adj[MAXN];

int dfs(int v = 0, int p = -1) {
	int sum = 0;
	for(int i : adj[v])
		if(i != p)
			sum += dfs(i, v);
//	cout << sum << endl;
	if(sum == 1)
		return 0;
	if(sum == 0)
			return 1;
	cout << "First";
//	cout << v << ' ' << p << ' ' << sum << endl;
	exit(0);
}

signed main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b); 
		adj[b].push_back(a);
	}
	if(!dfs()) cout << "Second";
	else cout << "First";
}


Measured memory_bytes: 5888
#include<iostream>

using namespace std;
int main(){

	int n;
	cin >> n;
	int ans = 0;

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < 15; j++) {
			if (i * 4 + j * 7 == n) {
				ans = 1;
				break;
			}
		}
	}

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {
         if (n == r){dp[n][n] = 1;}
	else if (r == 0) {return dp[n][0] = 1;}
	else if (r == 1) {return dp[n][1]=n;}
	else {dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
	return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;}
}
int main() {
	int N;
	int t = 1;
	cin >> N;
	vector<int>a(N);
	for (int i = 0;i < N;i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			if (a[i] % 5 != 0 && a[i] % 3 != 0)t = 0;
		}
	}
	if (t == 1)cout << "APPROVED" << endl;
	else cout << "DENIED" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	int ans = max(0, abs(b - a) - x);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main(){
    long H, W;
    cin >> H >> W;
    if (H == 1 or W == 1){
        cout << 1 << endl;
        return 0;
    }
    if (H%2 == 1 and W%2 == 1){
        cout << (H * W + 1) / 2 << endl;
    }else{
        cout << (H * W) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
n = int(input())
a_list = list()
for _ in range(n):
    a_list.append(int(input()))
light_button = 1
target_light_button = 2
for i in range(n):
    light_button_index = light_button - 1
    light_button = a_list[light_button_index]
    if light_button == target_light_button:
        print(i + 1)
        exit(0)
print(-1)

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

constexpr int64_t inf = 1e9;

int main() {
    int n, m;
    cin >> n >> m;

    vector< pair<int64_t, int64_t> > keys(m, {0, 0});
    for(int i = 0; i < m; i++) {
        int64_t b;
        cin >> keys[i].first >> b;
        for(int j = 0; j < b; j++) {
            int64_t c;
            cin >> c;
            keys[i].second |= 1 << (c - 1);
        }
    }

    vector< vector<int64_t> > dp(m, vector<int64_t>(1 << n, inf));
    dp[0][0] = 0;
    dp[0][keys[0].second] = keys[0].first;
    for(int i = 1; i < m; i++) {
        for(int j = 0; j < (1 << n); j++) {
            dp[i][j] = dp[i - 1][j];
        }
        for(int j = 0; j < (1 << n); j++) {
            dp[i][j | keys[i].second] = min(dp[i][j | keys[i].second], dp[i][j] + keys[i].first);
        }
        /*
        cout << i << " : ";
        for(int j = 0; j < (1 << n); j++) cout << dp[i][j] << " ";
        cout << endl;
        */
    }

    if(dp[m - 1][(1 << n) - 1] == inf) cout << "-1" << endl;
    else                               cout << dp[m - 1][(1 << n) - 1] << endl;

    return 0;
}

Measured memory_bytes: 32384
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
///////////////////////////////////////


ll N, M;
Graph G;
ll w = 0;
ll b = 0;
ll color[100010];
bool dfs(int v,int p) {
	color[v] = p;
	for (int i : G[v]) {
		if (color[i] == p)return false;
		if (color[i] == 0 && !dfs(i, -p))return false;
	}
	return true;
}
int main() {
	cin >> N >> M;
	G.resize(N);
	REP(i, M) {
		int a, b; cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	REP(i, 100010) {
		color[i] = 0;
	}
	if (dfs(0,1)) {
		REP(i, N) {
			if (color[i] == 1)w++;
			else b++;
		}
		cout << w * b - M << endl;
	}
	else {
		cout << N * (N - 1) / 2 - M << endl;
	}
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
using namespace std;


int main(void) {
    int a = 0;
    int n, k;
    
    cin >> n >> k;
    
    int n_ary[n];
    
    for (int i = 0; i < n; i++) {
        cin >> n_ary[i];
    }
    
    int a_cost = 0;
    int b_cost = 0;
    int total_cost = 0;
    for (int j = 0; j < n; j ++) {
        a_cost = abs((n_ary[j] - a) * 2);
        b_cost = abs((n_ary[j] - k) * 2);
        if (a_cost < b_cost) {
            total_cost += a_cost;
        }else
            total_cost += b_cost;
    }
    cout << total_cost << endl;
    
    
    return 0;
}

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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int a,b,c;cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	if (a <= c && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long maxDevider = 1;
		for(long i = 1; i * i <= n; i++){
			if(n % i == 0){
				maxDevider = i;
			}
		}
		System.out.println(maxDevider + n / maxDevider - 2);
	}
}


Measured memory_bytes: 23764
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
an = list(map(int, input().split()))
l = lcm(an)-1
an = [l%i for i in an]
print(sum(an))

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

int main(){
  int t,s=0;
  int T=10;
  vector<int> a(5);
  vector<int> b(5);
  for(int i =0;i<5;i++){
    cin>>a.at(i);
  }
   for(int i =0;i<5;i++){
     b.at(i)=a.at(i)%10;}
   for(int i =0;i<5;i++){
     if(b.at(i)==0){}
     else{a.at(i)=a.at(i)-b.at(i)+10;}
   }
  sort(b.begin(),b.end());
  for(int i=0;t<1&&i<5;i++){
    t=b.at(i);}
  if(t==0){T=0;}
  s=t+a.at(0)+a.at(1)+a.at(2)+a.at(3)+a.at(4)-T;
  cout<<s<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	@SuppressWarnings("unchecked")
	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if ((n | m) == 0)
				break;
			List<Point>[] lists = new ArrayList[n + 1];
			for (int i = 0; i <= n; i++)
				lists[i] = new ArrayList<Point>();
			for (int i = 1; i <= n; i++) {
				int k = scanner.nextInt();
				for (int j = 0; j < k; j++) {
					int x = scanner.nextInt();
					int cost = scanner.nextInt();
					lists[i - 1].add(new Point(1, x, cost));
					if (i != 1)
						lists[i - 2].add(new Point(2, x, cost));
					if (i == n - 1)
						lists[i].add(new Point(2, x, 0));
					if (i == n)
						lists[i].add(new Point(1, x, 0));

				}
			}
			PriorityQueue<Point> pq = new PriorityQueue<Main.Point>();
			pq.offer(new Point(0, 0, 0, 0, m));
			int[][][] dp = new int[m + 1][n + 1][1001];
			for (int[][] d : dp)
				for (int[] dd : d)
					Arrays.fill(dd, Integer.MAX_VALUE);
			dp[m][0][0] = 0;
			loop: while (!pq.isEmpty()) {
				Point point = pq.poll();
				int y = point.y;
				int x = point.x;
				int cost = point.cost;
				int total = point.total;
				int mm = point.m;

				if (y >= n) {
					System.out.println(total);
					break;
				}
				for (int i = mm; i <= m; i++)
					if (dp[i][y][x] < total)
						continue loop;
				for (Point p : lists[y]) {
					int nc = (cost + p.cost) * Math.abs(x - p.x) + total;
					int ny = Math.min(n, y + p.y);
					if (p.y == 2) {
						if (mm >= 1) {
							if (dp[mm - 1][ny][p.x] > nc) {
								dp[mm - 1][ny][p.x] = nc;
								pq.offer(new Point(ny, p.x, p.cost, y == 0 ? 0
										: nc, mm - 1));
							}
						}
					} else {
						if (dp[mm][ny][p.x] > nc) {
							dp[mm][ny][p.x] = nc;
							pq.offer(new Point(ny, p.x, p.cost,
									y == 0 ? 0 : nc, mm));
						}
					}
				}
			}

		}
	}

	class Point implements Comparable<Point> {
		int y, x, cost, total, m;

		public Point(int y, int x, int cost, int total, int m) {
			super();
			this.y = y;
			this.x = x;
			this.cost = cost;
			this.total = total;
			this.m = m;
		}

		public Point(int y, int x, int cost) {
			super();
			this.y = y;
			this.x = x;
			this.cost = cost;

		}

		@Override
		public String toString() {
			return "Point [y=" + y + ", x=" + x + ", cost=" + cost + ", total="
					+ total + ", m=" + m + "]";
		}

		@Override
		public int compareTo(Point o) {
			if (this.total == o.total)
				return o.y - this.y;
			return this.total - o.total;
		}
	}
}

Measured memory_bytes: 171420
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

int happy(string S){
    int N = S.length();
    int ans=0;
    for(int i=0; i<N; i++){
        if(S[i]=='R' && i<N-1 && S[i]==S[i+1]){
            ans++;
        }else if(S[i]=='L' && i>0 && S[i-1]==S[i]){
            ans++;
        }
    }
    
    return ans;
}

int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    int ans=happy(S);
    
   // cout<<ans<<endl;
    int cnt=0;
    for(int i=1; i<N; i++){
        if(S[i]!=S[i-1]){
            cnt++;
        }
    }
    
    if(cnt%2==0){
        ans+=min(K*2,cnt);
    }else{
        ans+=min(K*2,cnt/2*2);
        K-=min(K,cnt/2);
        if(K>0){
            ans++;
        }
    }
    
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let h: number;
    let w: number;
    let m: number;
    let hm: number[];
    let wm: number[]
    let ans;
    // init
    [h, w, m] = input.shift().split(" ").map(x => Number(x));
    [hm, wm] = [[], []];
    let hw = new Map();
    for (let mx = 0; mx < m; mx++) {
        let wrk0 = input[mx].split(" ").map(x => Number(x) - 1);
        hm[mx] = wrk0[0];
        wm[mx] = wrk0[1];
        hw.set(hm[mx] * w + wm[mx], 1);
    }
    // solve
    let ha: number[] = new Array(h).fill(0);
    let wa: number[] = new Array(w).fill(0);
    for (let hv of hm) { ha[hv]++; }
    for (let wv of wm) { wa[wv]++; }
    let hb: number = Math_max(ha);
    let wb: number = Math_max(wa);
    let hc: number[] = [];
    let wc: number[] = [];
    ha.forEach((val, idx) => { if (val == hb) hc.push(idx) });
    wa.forEach((val, idx) => { if (val == wb) wc.push(idx) });
    let isfull;
    if (m < hc.length * wc.length) {
        isfull = false;
    } else {
        let cnt = 0;
        for (let hce of hc) {
            for (let wce of wc) {
                if (hw.get(hce * w + wce) == 1) cnt++;
            }
        }
        isfull = hc.length * wc.length == cnt;
    }
    ans = Math_max(ha) + Math_max(wa) + (isfull ? -1 : 0);
    // answer
    console.log(ans);
}
// math lib
function Math_max(arr: number[]): number { return arr.reduce((x, y) => Math.max(x, y)); }
// entrypoint
function entrypoint() {
    try {
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 137236
import java.lang.Math.min

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val dequeue = readLine()!!.split(" ").map(String::toInt).toIntArray()

    var ans = 0
    val r = min(n, k)
    for (a in 0 .. r) {
        for (b in 0 .. (r - a)) {
            val c = k - (a + b)
            val hand = dequeue.sliceArray(0 until a) + dequeue.sliceArray((n - b) until n)
            hand.sort()
            for (i in 0 until hand.size) {
                if (i >= c) {
                    break
                }
                if (hand[i] < 0) {
                    hand[i] = 0
                }
            }
            val sum = hand.sum()
            if (ans < sum) {
                ans = sum
            }
        }
    }

    println(ans)
}


Measured memory_bytes: 39012
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;


const int kN = 350000;
void primeNumber(bool p[kN], vector<int> &v){
    rep(i,kN) p[i] = 1;
    p[0] = p[1] = p[2] = p[3] = p[4] = p[5] = 0;
    rep(i,kN){
        if(i % 7 == 1 || i % 7 == 6){
            if(p[i]){
                v.emplace_back(i);
                for(int j = i + i; j < kN; j+=i){
                    p[j] = 0;
                }
            }
        }else{
            p[i] = 0;
        }
    }
}

int main(){
    vector<int> v;
    vector<int>::iterator it;
    bool p[kN];
    primeNumber(p,v);

    int n;
    while(cin >> n, n != 1){
        int temp = n;
        map<int, int> m;
        it = v.begin();
        while(*it <= n){
            if(n % *it == 0){
                m[*it] = 1;
            }
            it++;
        }

        cout << temp << ':';
        for(auto out:m){
            cout << ' ' << out.first;
        }
        cout << endl;
    }

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define P pair<int, int>

using namespace std;

int main(){
  long long h, w, d, q;
  cin >> h >> w >> d;
  map<int, P> mp;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int a;
      cin >> a;
      mp[a] = P(i, j);
    }
  }
  cin >> q;
  long long cost[100000];
  for(int i=1;i<=d;i++){
    cost[i]=0;
    for(int j=1;i+d*j<=h*w;j++){
      int cur=i+j*d;
      int prev=i+(j-1)*d;
      P p_cur = mp[cur];
      P p_prev = mp[prev];
      cost[cur] += cost[prev] + abs(p_cur.first-p_prev.first)+abs(p_cur.second-p_prev.second);
    }
  }
  for(int i=0;i<q;i++){
    int l, r;
    cin >> l >> r;
    cout << cost[r] - cost[l] << endl;
  }
}



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

const int M = 1e5 + 10;

struct P
{
    int b;
	ll c;
    bool operator < ( const P & rhs ) const
	{
        return c > rhs.c;      
    }
} p[M];

int n,m,i,x,b;

int main ()
{
	cin >> n >> m;
    priority_queue < ll , vector < ll > , greater < ll > > que;
    for ( i = 0 ; i < n ; ++ i )
	{
		cin >> x;
        que.push ( ( ll ) x );
    }    
    for ( i = 0 ; i < m ; ++ i )
	    cin >> p[i].b >> p[i].c;
    sort ( p , p + m );
    for ( i = 0 ; i < m ; ++ i )
	{
        b = p[i].b;
        if ( p[i].c <= que.top () )
		   break;
        while ( b -- )
		{
            if ( que.top () < p[i].c )
			{
                que.pop ();
                que.push ( p[i].c );
            }
			else
			{
                break;
            }
        }
    }
    
    ll sum = 0;
    
    while ( ! que.empty () )
	{
        x = que.top ();
		que.pop ();
        sum += x;
    }
    
    cout << sum << endl;
    
    return 0;
    
}

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

int main() {
	int n, a;
	long min, max, sum;
	min =1000000;
	max =-1000000; 
	sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (min >a)min = a;
		if (max < a)max = a;
		sum = a + sum;
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
        a[i] %= 2;
    }
    if(count(ALL(a), 1)%2==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pb push_back
#define fastcin() ios_base::sync_with_stdio(false); cin.tie(0)
using namespace std;
typedef pair<int, int> ii;

const int maxn = 200050; 
int n, p[33], a[maxn]; 
bool vis[maxn]; 

map<int, vector<int> > b; 

signed main()
{
	for(int i = 0; i <= 32; i++) p[i] = (1 << i); 
	cin >> n; 
	for(int i = 1; i <= n; i++) cin >> a[i]; 
	sort(a+1, a+n+1); 
	for(int i = 1; i <= n; i++) b[a[i]].pb(i); 
	int ans = 0;
	for(int i = n; i >= 1; i--) 
	{
		if(vis[i]) continue; 
		b[a[i]].pop_back(); 
		for(int j = 32; j >= 0; j--) 
		{
			if(p[j] > 2 * a[i] or p[j] <= a[i] or (!b.count(p[j] - a[i]) or b[p[j] - a[i]].empty())) continue; 
			int id = *b[p[j] - a[i]].rbegin(); 
			b[p[j] - a[i]].pop_back(); 
			ans++; 
			vis[id] = 1;
			break;  
		}
	}
	cout << ans; 
}


Measured memory_bytes: 23808
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[200000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  ll sum = 0;
  REP(i, n) cin >> a[i], sum += a[i];

  ll hn = sum / 2;
  ll suma = 0;
  ll diff = LLINF;
  ll difft = 0;
  REP(i, n) {
    if(abs(suma + a[i] - hn) <= diff) {
      suma += a[i];
      diff = abs(suma - hn);
    } else {
      break;
    }
  }

  cout << abs((sum - suma) - suma) << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

void insertionSort(int[],int);
void printdata(int[],int);

int main(){
  int N,i;
  int A[1000];
  
  scanf("%d",&N);
  
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  printdata(A,N);
  insertionSort(A, N);
  return 0;
}


void insertionSort(int A[],int N){
  int i,v,j;
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    printdata(A,N);
  }  
}
  void printdata(int A[],int N){
    int i;
    for(i=0;i<N;i++){
      if(i > 0) printf(" ");
      printf("%d",A[i]);
    }
    printf("\n");
  }
  



Measured memory_bytes: 2072
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            string[] s1 = Console.ReadLine().Split(' ');
            int n = int.Parse(s1[0]), x = int.Parse(s1[1]);
            int[] l = new int[n];
            string[] s2 = Console.ReadLine().Split(' ');
            for (int i=0; i<n; i++) l[i] = int.Parse(s2[i]);

            int pos = 0;
            for (int i=0; i<n; i++)
            {
                pos += l[i];
                if (pos > x)
                {
                    Console.WriteLine(i + 1);
                    return;
                }
            }
            Console.WriteLine(n + 1);
            
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11092