akhauriyash/Code-Regression huggingface dataset:
n = int(input())
A = list(map(int,input().split()))

ANS = []
a1 = sum(A)
for i in range(1,n,2):
    a1 -= A[i]*2
ANS.append(a1)
for i in range(1,n):
    ANS.append(A[i-1]*2-ANS[i-1])

#print(ANS)
s = ""
for i in range(len(ANS)):
    s += str(ANS[i])
    s += " "

print(s)

Measured memory_bytes: 14100
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stack>
#include <queue>
#include <string>
#include <deque>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#define  endl "\n"
using namespace std;

void FastInput() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

//void OutputFile(){freopen("output.txt","w",stdout);}


int main()
{
   FastInput();
   int a[5];
   for(int i=0;i<5;i++)
   	cin>>a[i];
   for(int i=0;i<5;i++){
   	if(a[i]==0){
   		cout<<i+1;
   		break;
   	}

   }


   return 0;
}



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

long long int knapsack(vector<int>w,vector<int>v,int mw)
{
    int n=v.size();
    vector<vector<long long int>>dp(n,vector<long long int>(mw+1));
    for(int i=0;i<mw;i++)
        dp[0][i]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=mw;j++)
        {
            if(w[i]<=j)
            {
                if(i>0)
            	    dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j]);
                else
                    dp[i][j]=v[i];
            }
            else
            {
                dp[i][j]=(i>0)?dp[i-1][j]:0;
            }
        }
    }
    return dp[n-1][mw];
}

int main()
{
  int n,mw;
  cin>>n>>mw;
  vector<int>w(n);
    vector<int>v(n);
  for(int i=0;i<n;i++)
  {
    cin>>w[i]>>v[i];
  } 
  cout<<knapsack(w,v,mw)<<endl;
  return 0;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;
  int len = sz(s);
  rep(i,len) {
    int x = (26 - (int)(s[i] - 'a')) % 26;
    if(x <= K) {
      K -= x;
      s[i] = 'a';
    }
  }
  int rest = (K + (s[len-1]-'a')) % 26;
  s[len-1] = rest + 'a';
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define int long long
#define elif else if
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int gcd(int x, int y){
  if(y == 0) {
    return x;
  } else{
    return gcd(y, x % y);
  }
}
signed main(){
  int a, b;
  cin >> a >> b;
  int c = gcd(a, b);
  cout << a * b / c << "\n";
}

Measured memory_bytes: 3652
/*
    to amy
    https://atcoder.jp/contests/abc135/tasks/abc135_c
*/

#include <bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define F first
#define S second
#define MAX 2005

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main() {
    IOS
    int n;
    while(cin>>n){
        vl v1,v2;
        ll x;
        for(int i=0;i<n+1;i++){
            cin>>x;
            v1.pb(x);
        }
        for(int i=0;i<n;i++){
            cin>>x;
            v2.pb(x);
        }

        ll sum=0;
        for(int i=0;i<n;i++){
            if(v2[i]>=v1[i]){
                sum += v1[i];
                v2[i] -= v1[i];
                if(v2[i]>=v1[i+1]){
                    sum += v1[i+1];
                    v1[i+1] = 0;
                }else{
                    sum += v2[i];
                    v1[i+1] -= v2[i];
                }
            }else{
                sum += v2[i];
            }
        }
        cout<<sum<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 2548
# AtCoder Beginner Contest 095 C - Half and Half
import sys

A, B, C, X, Y = map(int, sys.stdin.readline().strip().split())

"""
ans = A * X + B * Y
for z in range(2, 2 * 10 ** 5 + 1, 2):
    x = max(X - int(z / 2), 0)
    y = max(Y - int(z / 2), 0)

    price = A * x + B * y + C * z
    ans = min(price, ans)

print(ans)
"""

price1 = A * X + B * Y
price2 = C * 2 * X + B * max(Y - X, 0)
price3 = A * max(X - Y, 0) + C * 2 * Y
print(min(price1, price2, price3))



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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  cout << v[n / 2] - v[n / 2 - 1];
}

Measured memory_bytes: 640
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int m[200][200];
int x[200], y[200];
typedef long long ll;
ll p2[1000];
ll mod = 998244353;
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%d%d", &x[i], &y[i]);
	p2[0] = 1;
	for (int i = 1; i < 1000; i++)p2[i] = p2[i - 1] * 2 % mod;
	ll s = p2[num];
	for (int i = 0; i < num; i++)
	{
		for (int j = i + 1; j < num; j++)
		{
			if (m[i][j])continue;
			vector<int>v;
			for (int k = 0; k < num; k++)
			{
				if ((x[k] - x[i])*(y[j] - y[i]) == (y[k] - y[i])*(x[j] - x[i]))v.push_back(k);
			}
			s = (s + mod - p2[v.size()] + v.size() + 1) % mod;
			for (int k = 0; k < v.size(); k++)for (int l = 0; l < v.size(); l++)m[v[k]][v[l]] = 1;
		}
	}
	s = (s + mod - num - 1)%mod;
	printf("%lld\n", s);
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;

int main(){
	float T;
	int A, B, ans = 0;
	int k = 1;
	cin >> A >> B >> T;
	if(A <= (T+0.5)){
		for(int i = 1; i <= (T + 0.5); i = A * k){
			ans += B;
			k++;
		}
		cout << ans << endl;
	}else{
		cout << 0 << endl;
	}
        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static int a[];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a=new int[10000];
        int b;
        int i=1;
        while(true){
            b=sc.nextInt();
            if(b==0) break;
            System.out.printf("Case %d: %d\n",i,b);
            i++;
        }
        sc.close();
    }
}


Measured memory_bytes: 68016
using System;
using System.IO;
using System.Linq;

namespace ABC128C
{
    class Program
    {
        int N;
        int M;
        int[,] sw;
        int[] target;
        int count = 0;

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().Solve();
        }

        void Solve()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            N = temp[0]; // スイッチの数
            M = temp[1]; // 電球の数
            sw = new int[M, N];

            for (int i = 0; i < M; i++)
            {
                temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                var cnt = temp[0];

                for (int j = 1; j <= cnt; j++)
                {
                    sw[i, temp[j] - 1] = 1;
                }
            }

            target = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var li = new int[N];
            Search(0, li);
            Console.WriteLine(count);
        }

        void Search(int no, int[] li)
        {
            if (no == N)
            {
                // for (int i = 0; i < N; i++)
                // {
                //     Console.Write(li[i]);
                // }
                // Console.WriteLine();

                var fg = true;

                for (int i = 0; i < M; i++)
                {
                    var t = 0;

                    for (int j = 0; j < N; j++)
                    {
                        if (li[j] == 1 && sw[i, j] == 1)
                        {
                            t = (t + 1) % 2;
                            // Console.WriteLine("check: " + i + ":" + j + ":" + t);
                        }
                    }
                    // Console.WriteLine("t: " + t + ":" + target[i]);

                    if (t != target[i])
                    {
                        fg = false;
                        break;
                    }
                }

                if (fg)
                {
                    // Console.WriteLine("ok");
                    count++;
                }
            }
            else
            {
                li[no] = 0;
                Search(no + 1, li);

                li[no] = 1;
                Search(no + 1, li);
            }
        }
    }
}


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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/








int main()
{
    ll a;
    cin>>a;
    a-=1;
    ll s=((a+1)*a)/2;
    cout<<s<<endl;
	return 0;
}
































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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int k; cin >> k;
  int ans = 0;
  for(int a = 1; a <= k; ++a) for(int b = 1; b <= k; ++b) for(int c = 1; c <= k; ++c) ans += __gcd(a, __gcd(b, c));
  cout << ans << endl;
}


Measured memory_bytes: 3604
object Main{
  def main(args: Array[String]) = {
    val N = io.StdIn.readLine().toLong
    val a = io.StdIn.readLine().split(' ').map(_.toDouble)

    val bun = a.map{
      ai =>
        1.0 / ai
    }.sum

    println(1.0 / bun)
  }
}

Measured memory_bytes: 25520
import numpy as np
from collections import defaultdict
from functools import reduce

MOD = 1000000007

A = set()

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
n, m = map(int, input().split())

for _ in range(m):
    a = int(input())
    A.add(a)

res = [0]*(n+1)

res[0] = 1
if 1 not in A:
    res[1] = 1

for i in range(2, n+1):
    if i in A:
        continue
    res[i] = (res[i-1] + res[i-2])%MOD

print(res[n])



class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res



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

using namespace std;
typedef long long ll;
typedef long double ld;

const int N = 1001000;
const int INF = 0x3f3f3f3f;
char s[N];
int dp[N][13];
int n;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> (s+1);
    n = strlen(s+1);
    memset(dp, INF, sizeof dp);

    for (int i=1; i<=n; ++i) {
        s[i] -='0';
    }
    dp[0][0] = 0;
    for (int i=0; i<=n; ++i) {
        dp[i][1] = min(dp[i][1], dp[i][0]+1);
        dp[i+1][0] = min(dp[i][0]+s[i], dp[i][1]+10-s[i]);
        dp[i+1][1] = min(dp[i][0]+s[i]+1, dp[i][1]+9-s[i]);
    }
    cout << dp[n+1][0] << endl;

    return 0;
}

Measured memory_bytes: 52096
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Dice
{
public:
	Dice()
	{
	}
	Dice(unsigned int in[6])
	{
		for (int i = 0; i < 6; i++)
		{
			label[i] = in[i];
		}
		Reset();
	}
	~Dice()
	{
	}
	void Reset()
	{
		N = 5;
		E = 3;
		S = 2;
		W = 4;
		F = 1;
		B = 6;
	}
	void Run(string &cmd)
	{
		for (int i = 0; i < cmd.size(); i++)
		{
			char c = cmd[i];
			if (c == 'S')
			{
				int tmpF = F;
				F = N;
				N = B;
				B = S;
				S = tmpF;
			}
			else if (c == 'N')
			{
				int tmpN = N;
				N = F;
				F = S;
				S = B;
				B = tmpN;
			}
			else if (c == 'E')
			{
				int tmpB = B;
				B = E;
				E = F;
				F = W;
				W = tmpB;
			}
			else if (c == 'W')
			{
				int tmpW = W;
				W = F;
				F = E;
				E = B;
				B = tmpW;
			}
		}
	}
	int GetFront()
	{
		return F;
	}
	int GetLabel()
	{
		return label[F-1];
	}
	int GetSouthLabel()
	{
		return label[S-1];
	}
	int GetEastLabel()
	{
		return label[E-1];
	}
	int GetWestLabel()
	{
		return label[W-1];
	}
	int GetBackLabel()
	{
		return label[B-1];
	}
	int GetNorthLabel()
	{
		return label[N-1];
	}

	int IsSameDice(Dice &d)
	{
		if((d.GetLabel() == this->GetLabel())
			&& (d.GetSouthLabel() == this->GetSouthLabel())
			&& (d.GetEastLabel() == this->GetEastLabel())
			&& (d.GetWestLabel() == this->GetWestLabel())
			&& (d.GetBackLabel() == this->GetBackLabel())
			&& (d.GetNorthLabel() == this->GetNorthLabel())
		)
		{
			return 1;
		}
		return 0;
	}
	int ThrowTo(Dice &d)
	{
		for (int x = 0; x < 4; x++)
		{
			Reset();
			if (x == 0)
			{
			}
			else if (x == 1)
			{
				string cmd1 = "WSE";
				Run(cmd1);
			}
			else if (x == 2)
			{
				string cmd2 = "WSSE";
				Run(cmd2);
			}
			else if (x == 3)
			{
				string cmd3 = "WSSSE";
				Run(cmd3);
			}
			for (int w = 0; w < 4; w++)
			{
				for (int n = 0; n < 4; n++)
				{
					string nnnn = "N";
					Run(nnnn);
					if (IsSameDice(d))
						return 1;
				}
				string wwww = "W";
				Run(wwww);
			}
		}
		return 0;
	}
	
public:
	int N;
	int E;
	int S;
	int W;
	int F;
	int B;
private:
	unsigned int label[6];
};

int main()
{
	int n;
	cin >> n;
	vector<Dice> ary;
	
	for (int i = 0; i < n; i++)
	{
		unsigned int in1[6] = {0};
		for (int j = 0; j < 6; j++)
		{
			cin >> in1[j];
		}
		
		Dice dice(in1);
		ary.push_back(dice);
	}
	
	int sameFlag = 0;
	if (n == 2)
	{
		if (ary[0].ThrowTo(ary[1]))
			sameFlag = 1;
	}
	else
	{
		for (int i = 0; i< n; i++)
		{
			for (int j = i+1; j < n-1; j++)
			{
				if (ary[i].ThrowTo(ary[j]))
				{
					sameFlag = 1;
					break;
				}
			}
			if (sameFlag == 1)
				break;
		}
	}
	cout << ((sameFlag == 0) ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 1224
const BKRT = "\n";
const SPAC = " ";
const NOSP = "";

function Main(input){
	input = [].concat(...input.split(BKRT).map(a=>a.split(SPAC)));
  const strShift = ()=>input.shift();
  const intShift = ()=>~~input.shift();
  
  var a = intShift();
  var b = intShift();
  
  var p = ~~Math.pow(2,b);
  
  return ((a-b)*100 + b * 1900) * p;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
100 5
`);

Measured memory_bytes: 7372
function parseInt(x) parse(Int, x) end
function main()
  n = parseInt.(split(readline()))
  x = parseInt.(split(readline()))
  y = [0 for i in 1:n[1]-n[2]+1]
  for i in 1:n[1]-n[2]+1
    z = x[i+n[2]-1]
    if x[i]*z >= 0
      y[i] = max(abs(x[i]),abs(z))
    else
      if abs(x[i]) > z
        y[i] = z*2-x[i]
      else
        y[i] = z-x[i]*2
      end
    end
  end
  print(minimum(y))
end

main()


Measured memory_bytes: 133772
#include <iostream>
#include <algorithm>
#define ll long long int
using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	ll *x = new ll[n];
	ll *y = new ll[n];
	for(int i = 0; i < n; i++){
			cin >> x[i];
			y[i] = x[i];
	}
	sort(x, x + n, greater<ll>());
	ll med = x[n/2-1];
	ll med2 = x[n/2];
	for(int i = 0; i < n; i++){
			if(y[i] >= med)cout << med2 << endl;
			else cout << med << endl;
	}
	
	return 0;
}


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


int main(){
  int n,k,i;
  cin >> n >> k;
  string s;
  cin >> s;
  if(s[k-1]=='A'){
    s[k-1]='a';
  }else if(s[k-1]=='B'){
    s[k-1]='b';
  }else{
    s[k-1]='c';
  }
  cout << s << endl;
  return 0;
}


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

int main() {
  string str;
  char c;
  for (int i = 0; i < 3; i++){
    cin >> str;
    if(i == 1){
      c = str.at(0);
    }
  }
  cout << "A" << c << "C" << endl;
  
}


Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = input().unwrap();
    let mut s = Vec::new();
    for _i in 0..n {
        s.push(input::<usize>().unwrap());
    }

    let sum = s.iter().sum::<usize>();

    let ans = if sum % 10 == 0 {
        let f = s.iter().filter(|x| **x % 10 != 0).min();
        match f {
            Some(t) => sum - *t,
            None => 0
        }
    } else {
        sum
    };

    println!("{}", ans);
}

pub fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf.trim().parse().ok().unwrap())
}

pub fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf
        .trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>())
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


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

using namespace std;

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

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

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

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

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

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


int main(){
  string s; cin >> s;
  ll k; cin >> k;
  if(k == 1){
    cout << s.front() << endl;    
  } else {
    int i = 0;
    while(s[i] == '1' && k > 1){i++;k--;}      
    cout << s[i] << endl;
  }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define ios; ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define ls(x) (x<<1)
#define rs(x) (ls(x)|1)
#define eps 1e-11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef double db;
mt19937 rnd(random_device{}());
const int mod = 998244353;
const int N = 2e5 + 5;
const int M = 1e6 + 5;
inline ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }
inline ll lcm(ll a,ll b){ return a*b/gcd(a,b); }
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;
x=x*x%mod; y>>=1;} return res; }
int n, m;

ll solve(vector<pii> d){
    sort(d.begin(),d.end(),greater<pii>());
    int now=0;
    priority_queue<int> que;
    ll res=0;
    per(i,d.size(),1){
        while(now<d.size()&&d[now].fi>=i){
            que.push(d[now].se);
            ++now;
        }
        if(!que.empty()){
            res+=que.top();
            que.pop();
        }
    }
    return res;
}

int main(){
    ios;
    int _; cin>>_;
    while(_--){
        cin>>n;
        ll ans=0;
        vector<pii> L, R;
        rep(i,1,n){
            int k,l,r;
            cin>>k>>l>>r;
            ans+=min(l,r);
            if(l>=r) L.emplace_back(k,l-r);
            else R.emplace_back(n-k,r-l);
        }
        ans += solve(L);
        ans += solve(R);
        cout<<ans<<"\n";
    }

    return 0;
}
/*
2
1 5 10
2 15 5
3
2 93 78
1 71 59
3 57 96
*/
//
//                            _ooOoo_
//                           o8888888o
//                           88" . "88
//                           (| -_- |)
//                           O\  =  /O
//                        ____/`---'\____
//                      .'  \|     |//  `.
//                     /  \|||  :  |||//  \
//                    /  _||||| -:- |||||-  \
//                    |   | \  -  /// |   |
//                    | \_|  ''\---/''  |   |
//                    \  .-\__  `-`  ___/-. /
//                  ___`. .'  /--.--\  `. . __
//               ."" '<  `.___\_<|>_/___.'  >'"".
//              | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//              \  \ `-.   \_ __\ /__ _/   .-` /  /
//         ======`-.____`-.___\_____/___.-`____.-'======
//                            `=---='
//        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                     佛祖保佑      永无BUG


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

int N;
vector<int> d;

int main() {
    cin>>N;
    d.resize(N);
    int ans=0;
    for (int i=0; i<N; i++) cin>>d[i];
    for (int i=0; i<N-1; i++)
        for (int j=i+1; j<N; j++) ans+=d[i]*d[j];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// Author: Harshdeep Sharma , IIT Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();
const ll mod = 1e9 + 7 ;



ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}
bool isBalanced(const string &exp)
{
	// Initialising Variables
	bool flag = true;
	int count = 0;

	// Traversing the Expression
	for (int i = 0; i < exp.length(); i++) {

		if (exp[i] == '(') {
			count++;
		}
		else {
			count--;
		}
		if (count < 0) {
			flag = false;
			break;
		}
	}
	if (count != 0) {
		flag = false;
	}

	return flag;
}

ll gcd (ll a, ll  b) {
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

ll lcm (ll  a, ll  b) {
	return a / gcd(a, b) * b;
}



ll power(ll x, ll y, ll mod) {
	int res = 1;
	while (y) {
		if (y & 1)
			res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}




int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {
	int a, b , c ;
	cin >> a >> b >> c ;
	// int tempa , tempb , tempc ;
	// tempa = a ;
	// tempb = b ;
	// tempc = c ;
	int k ;
	cin >> k ;
	int ans = 0 ;
	while (a >= b) {
		b *= 2 ;
		ans++ ;
	}
	// cout << ans << " " << a << " " << b << "\n";
	while (b >= c) {
		c *= 2 ;
		ans++ ;
	}
	// cout << ans << " " << b << " " << c << "\n";

	if (ans > k ) {
		cout << "No\n";
	} else {
		cout << "Yes\n";
	}
	// cout << ans << "\n";


	// }


	return 0 ;
}

Measured memory_bytes: 3648
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, int n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7
const double PI = 3.1415926535897932384626;

/*********** variables ************/
int N;
int a[100010];
lng wa[100010];
/**********************************/


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N;
    REP(i, N) cin>>a[i+1];

    UP(i, 1, N) {
        wa[i] = wa[i-1] + a[i];
    }

    lng ans = 1LL<<60;
    for(int s=1; s>=-1; s-=2) {
        lng diff = 0;
        lng cnt = 0;
        UP(i, 1, N) {
            if(wa[i]+diff == 0) {
                diff += s*(i%2 ? 1 : -1);
                cnt++;
            }
            else if((wa[i]+diff)*s*(i%2?1:-1) < 0) {
                int d = -(wa[i]+diff) + s*(i%2?1:-1);
                diff += d;
                cnt += llabs(d);
            }
        }
        //cout << "cnt: " << cnt << endl;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}


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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

VI memo;
int dfs(int k, VI& av) {
    if(memo[k] != 0) return memo[k];
    int first_res = -1;
    for(auto a1 : av) {
        if(k - a1 >= 0) {
            int second_res = 1;
            if(memo[k - a1] != 0) {
                second_res = memo[k - a1] * -1;
            } else {
                for(auto a2 : av)if(k - a1 - a2 >= 0)
                    second_res = min(second_res, dfs(k - a1 - a2, av));
                memo[k - a1] = second_res * -1;
            }
            first_res = max(first_res, second_res);
        }
    }
    return memo[k] = first_res;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VI a(n);
    REP(i, n) cin >> a[i];
    memo.resize(k + 1);
    cout << (dfs(k, a) == 1 ? "First" : "Second") << ln;
    return 0;
}


Measured memory_bytes: 5376
// AOJ 0236: Alien Messages
// 2017.10.29 bal4u@uu

#include <stdio.h>
#include <string.h>

int magic[6] = { 10,5,3,6,12,9 };
int map[8][8], mk[8][8], h, w, nc, vc;
int mv[4][2] = {{0,1},{-1,0},{0,-1},{1,0}};

int eq(int a, int r, int b, int c)
{
	return ((a & (1<<r)) > 0) == ((b & (1<<c)) > 0);
}

void dfs(int r, int c)
{
	int i, r2, c2;

	mk[r][c] = 1, vc++;
	for (i = 0; i < 4; i++) {
		r2 = r + mv[i][0], c2 = c + mv[i][1];
		if ((map[r][c] & (1<<i)) && !mk[r2][c2]) dfs(r2, c2);
	}
}

int rec(int pos)
{
	int r, c, v, t;

	if (pos == h*w) {
		vc = 0;
		memset(mk, 0, sizeof(mk));
		for (r = 0; r < h; r++) for (c = 0; c < w; c++) {
			if (map[r][c] == 0) continue;
			dfs(r, c);
			return nc == vc;
		}
		return 0;
	}
	r = pos / w, c = pos % w;
	if (map[r][c] == 0) {
		v = 0;
		if (c && !eq(map[r][c-1], 0, v, 2)) return 0;
		if (r && !eq(map[r-1][c], 3, v, 1)) return 0;
		if (rec(pos+1)) return 1;
	} else {
		for (t = 0; t < 6; t++) {
			v = magic[t];
			if (c && !eq(map[r][c-1], 0, v, 2)) continue;
			if (r && !eq(map[r-1][c], 3, v, 1)) continue;
			if (r == 0   && (v & (1<<1))) continue;
			if (r == h-1 && (v & (1<<3))) continue;
			if (c == 0   && (v & (1<<2))) continue;
			if (c == w-1 && (v & 1))      continue;
			map[r][c] = v;
			if (rec(pos+1)) return 1;
		}
	}
	return 0;
}

int main()
{
	int k, r, c;

	while (scanf("%d%d", &w, &h) && w > 0) {
		nc = 0;
		for (r = 0; r < h; r++) for (c = 0; c < w; c++) {
			scanf("%d", &k), map[r][c] = 1-k;
			if (!k) nc++;
		}
		puts(rec(0) ? "Yes" : "No");
	}
	return 0;
}

Measured memory_bytes: 1688
n,t = map(int,input().split())
c_t = []
for i in range(n):
    ci,ti = map(int,input().split())
    if ti <= t:
        c_t.append(ci)
    else:
        pass
if len(c_t) > 0:
    print(min(c_t))
else:
    print('TLE')


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v, w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

int main() {
	int N; cin >> N;
	vector<int> t(N);
	for (int i = 0; i < N - 1; i++)
		cin >> t[i];
	vector<int> dp1(N / 2 + 1, 10000), dp2 = dp1;
	dp1[0] = dp2[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = N / 2; j >= 1; j--)
			dp1[j] = dp1[j - 1];
		dp1[0] = 10000;
		for (int j = 0; j <= N / 2; j++) {
			dp1[j] = min(dp1[j], dp2[j] + t[i]);
			dp2[j] = min(dp2[j], dp1[j] + t[i]);
		}
	}
	cout << min(dp1[N / 2], dp2[N / 2]) << endl;
}

Measured memory_bytes: 1292
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] p = new int[N];
    for (int i = 0; i < N; i++) {
      p[i] = sc.nextInt();
    }
    
    int ans = 0;
    for (int i = 0; i < N-1; i++) {
      if (p[i] == i+1) {
        int tmp = p[i];
        p[i] = p[i+1];
        p[i+1] = tmp;
        ans++;
      }
    }
    if (p[N-1] == N) {
        int tmp = p[N-1];
        p[N-1] = p[N-2];
        p[N-2] = tmp;
        ans++;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 52472
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const objvs =(a)=>{const b=[];for(const v in a){b.push(a[v])}return b};
const main=()=>{
  let n=tn()
  for(let i=n;i>0;i--){
    for(let j=2;j**2<=n;j++){
      for(let k=2;j**k<=n;k++){
        if(j**k==i){
          to(i)
          return
        }
      }
    }
  }
  to(1)
}
main()


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

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

    cout <<setprecision(10)<< 2*R*3.1415926 <<endl;
}

Measured memory_bytes: 3824
'use strict';

var fs = require('fs');
var contents = fs.readFileSync('/dev/stdin', 'utf-8');

var printTest = function(contents) {
    var a = contents.trim().split("\n");
    for (var i = 0; i < a.length; i++) {
        var n = parseInt(a[i]);
        if (n === 0) {
            break;
        }
        console.log("Case " + (i + 1) + ": " + n);
    }
}

printTest(contents);

Measured memory_bytes: 20936
#include <iostream>
#include <algorithm>

using namespace std;

int x, y, restT, restC, divT, divC;

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

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

Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}



int main(){
    queue<ll> que;
    rep2(i,10) que.push(i);
    ll k; cin >> k;
    ll ans = 0;
    while(k>0){
        ans = que.front();
        que.pop();
        k--;

        if(ans % 10 != 0) que.push(10 * ans + ans % 10 - 1);
        que.push(10 * ans + ans % 10);
        if(ans % 10 != 9) que.push(10 * ans + ans % 10 + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int x=nextInt();
		int n=nextInt();
		TreeSet<Integer> set=new TreeSet<>();
		for(int i=0;i<=101;i++)
			set.add(i);
		for(int i=1;i<=n;i++)
			set.remove(nextInt());
		if(set.contains(x))
			out.println(x);
		else
		{
			int low=set.lower(x);
			int high=set.higher(x);
			if(Math.abs(x-high)<Math.abs(x-low))
				out.println(high);
			else
				out.println(low);
		}
	}

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

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 33240
import heapq
N,M=map(int,input().split())
A=[-int(x) for x in input().split()]
heapq.heapify(A)
for i in range(M):
    maxA = heapq.heappop(A)
    heapq.heappush(A,(-1)*(-maxA//2))
print(-sum(A))

Measured memory_bytes: 72088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) lower_bound(all(v),k)-v.begin()
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=100100100100;
const int mod=1000000007;
int main(){
   ll n,k;cin>>n>>k;
   vector<P> v;
   rep(i,n){
       ll a,b;cin>>a>>b;
       v.eb(a,b);
   }
   sort(all(v));
   ll ans=0;
   rep(i,n){
       ans+=v[i].second;
       if(ans>=k){
           cout<<v[i].first<<endl;
           return 0;
       }
   }
}


Measured memory_bytes: 2420
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	string s ; cin >> s ;
	if(s=="RRR") cout << 3 ;
	else if(s=="RRS"||s=="SRR") cout << 2 ;
	else if(s=="SSS") cout << 0 ;
	else cout << 1 ;
	cout << endl ;
}


Measured memory_bytes: 3620
s = gets.chomp.split("")

left_streak = [0]
current_left_streak = 0
s.each do |c|
  current_left_streak = c == "<" ? current_left_streak + 1 : 0
  left_streak << current_left_streak
end

right_streak = [0]
current_right_streak = 0
s.reverse.each do |c|
  current_right_streak = c == ">" ? current_right_streak + 1 : 0
  right_streak.unshift(current_right_streak)
end

nums = []
(s.size + 1).times { |i| nums << [left_streak[i], right_streak[i]].max }

puts nums.inject(:+)


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

public class Main {
		public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] SW = br.readLine().split(" ");
		
		int S = Integer.parseInt(SW[0]);
		int W = Integer.parseInt(SW[1]);
		
		System.out.println(S>W? "safe" : "unsafe");
	}
}


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

int main(){
while(1){
double a,b;
cin>>a;
if (cin.fail()) break;
cin>>b;
if(a<35.5&&b<71){cout<<"AAA"<<endl;}
else if(a<37.5&&b<77){cout<<"AA"<<endl;}
else if(a<40&&b<83){cout<<"A"<<endl;}
else if(a<43&&b<89){cout<<"B"<<endl;}
else if(a<50&&b<105){cout<<"C"<<endl;}
else if(a<55&&b<116){cout<<"D"<<endl;}
else if(a<70&&b<148){cout<<"E"<<endl;}
else{cout<<"NA"<<endl;}

}
}

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


int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    ll ans = 0;
    rep(i,n) cin >> a[i];
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n; j++)
            for(int k = j+1; k < n; k++)
            {
                ll x = a[i], y = a[j], z = a[k];
                if(x == y || y == z || z == x) continue;
                if(x+y > z && y+z > x && z+x > y) ans++;
            }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
s = input()

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i in range(len(s)):
    # print(s[i])
    if (i+1) % 2 == 0:
        if s[i] not in even:
            print('No')
            exit()
    else:
        if s[i] not in odd:
            print('No')
            exit()
print('Yes')


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

// Binary Indexed Tree (Fenwick Tree)
// https://youtu.be/lyHk98daDJo?t=7960
template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
};

int main(){
  ll n,d,a;cin>>n>>d>>a;
  vector<pll> xh(n);
  rep(i, n)cin>>xh[i].first>>xh[i].second;
  sort(xh.begin(), xh.end());

  ll result=0;
  BIT<ll> bit(n+1);
  rep(i, n){
    ll x = xh[i].first;
    ll h = xh[i].second;
    h -= bit.sum(i);
    if(h<=0)continue;

    ll num = (h+a-1)/a;
    result += num;
    ll damage = num*a;

    bit.add(i, damage);
    ll rx = x+2*d;
    ll j = upper_bound(xh.begin(), xh.end(), pll(rx+1, -1))-xh.begin();
    bit.add(j, -damage);
//cout<<i<<' '<<j<<endl;
  }

  cout<<result;

  return 0;
}


Measured memory_bytes: 4992
#include <set>
#include <iostream>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

string sss(vector<string> v){
 loop:
  REP(i,v.size()){
    REP(j,v.size()) if(i != j){
      if(string::npos != v[i].find(v[j])){
	v.erase(v.begin() + j);
	goto loop;
      }
    }
  }

  int n = v.size();
  vector<vector<int> > same(n, vector<int>(n));

  REP(i,n) REP(j,n){
    for(int ii = 0; ii <= v[i].size(); ii++){
      bool ok = true;
      for(int jj = 0; ii + jj < v[i].size() && jj < v[j].size(); jj++){
	if(v[i][ii + jj] != v[j][jj]){
	  ok = false;
	  break;
	}
      }
      if(ok){
	same[i][j] = ii;
	break;
      }
    }
  }

  string ret = ""; REP(i, n) ret += v[i];
  vector<int> pm(n); REP(i,n) pm[i] = i;

  do{
    int len = v[pm[0]].size();
    REP(i, n - 1){
      int a = pm[i + 1];
      int b = pm[i];
      len += v[a].size() - (v[b].size() - same[b][a]);
    }    

    if(len <= ret.size()){
      string tmp = v[pm[0]];
      
      REP(i, n - 1){
	int a = pm[i + 1];
	int b = pm[i];
	
	tmp += v[a].substr(v[b].size() - same[b][a]);
      }
      
      if(tmp.size() < ret.size()) ret = tmp;
      else if(tmp.size() == ret.size()){
	if(ret > tmp) ret = tmp;
      }
    }
  }while(next_permutation(pm.begin(), pm.end()));

  return ret;
}

int main(){
  int n;
  while(cin >> n, n){
    vector<string> v(n);
    REP(i,n) cin >> v[i];
    cout << sss(v) << endl;
  }
  return 0;
}

Measured memory_bytes: 920