akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 200005
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define Edge(x) for(int i=head[x];i;i=e[i].nxt)
#define mset(x,y) memset(x,y,sizeof(x))
#define strL strlen
#define p_b push_back
#define mcpy(x,y) memcpy(x,y,sizeof(x))
#define lson l,mid,(o<<1)
#define rson mid+1,r,((o<<1)|1)
#define Ls (t[o].ls)
#define Rs (t[o].rs)
#define mod 924844033
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
using namespace std;
const int G=5;
int num[N],sz[N],len,_len,cnt,head[N],n,bit,rev[N*5];
ll fac[N],ans[N],_fac[N],g[N*5],_g[N*5],A[N*5],B[N*5];
struct ed{ int v,nxt; }e[N<<1];
void add(int u,int v){
	e[++cnt]=(ed){v,head[u]},head[u]=cnt;
	e[++cnt]=(ed){u,head[v]},head[v]=cnt;
}
ll qpow(ll x,int y){
	ll tmp=1;
	for(;y;y>>=1,(x*=x)%=mod) if(y&1) tmp=1ll*tmp*x%mod;
	return tmp;
}
ll C(int x,int y){
	if(x<y) return 0;
	return 1ll*fac[x]*_fac[y]%mod*_fac[x-y]%mod;
}
ll mnS(ll x,ll y){ return x-y<0?x-y+mod:x-y; } 
void init(){
	fac[0]=_fac[0]=fac[1]=_fac[1]=1;
	For(i,2,n){
		fac[i]=1ll*fac[i-1]*i%mod;
		_fac[i]=(1ll*mod-mod/i)*_fac[mod%i]%mod;
	}
	For(i,2,n) (_fac[i]*=_fac[i-1])%=mod;
	for(bit=0,len=1;len<=2*n+1;len<<=1,bit++);
	For(i,0,len-1) rev[i]=(rev[i>>1]>>1)|((i&1)<<bit-1);
	g[len]=qpow(1ll*G,(mod-1)/len),_g[len]=qpow(g[len],mod-2);
	for(int i=(len>>1);i>=2;i>>=1){
		g[i]=g[i<<1]*g[i<<1]%mod;
		_g[i]=_g[i<<1]*_g[i<<1]%mod;
	}
	_len=(int)qpow(len,mod-2);
}
void dfs(int x,int f){
	sz[x]=1;
	Edge(x){
		int to=e[i].v;
		if(to!=f){
			dfs(to,x);
			sz[x]+=sz[to];
		}
	}
	if(x!=1){
		num[sz[x]]++;
		num[n-sz[x]]++;		
	}
}
void NTT(ll *a,int f){
	For(i,0,len-1) if(rev[i]>i) swap(a[rev[i]],a[i]);
	for(int i=2;i<=len;i<<=1){
		ll omega;f==1?omega=g[i]:omega=_g[i];
		int mid=i>>1;
		for(int j=0;j<len;j+=i){
			ll w=1;
			for(int k=j;k<j+mid;++k,(w*=omega)%=mod){
				ll u=a[k],v=a[k+mid]*w%mod;
				a[k]=(u+v)%mod;
				a[k+mid]=(u-v+mod)%mod;
			}
		}
	}
	if(f==-1) For(i,0,len-1) (a[i]*=1ll*_len)%=mod; 
}
int main(){
	int u,v;
	scanf("%d",&n);
	init();
	For(i,1,n-1) scanf("%d%d",&u,&v),add(u,v);
	dfs(1,0);
	For(i,0,n) A[i]=fac[i]*num[i]%mod;
	For(i,0,n) B[n-i]=_fac[i];
	NTT(A,1),NTT(B,1);
	For(i,0,len-1) A[i]=A[i]*B[i]%mod;
	NTT(A,-1);
	For(i,1,n)
		ans[i]=mnS(1ll*n*C(n,i)%mod,_fac[i]*A[n+i]%mod);
	For(i,1,n-1) printf("%lld\n",ans[i]);
	printf("%lld",ans[n]);
}

Measured memory_bytes: 49280
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//#  define LOG(x) (cerr << #x << " = " << (x) << endl)
//#else
//#  define LOG(x) 0
//#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = 200005;
int ar[NN];
int n, m, k;


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

    int x, y;
    cin >> x >> y;
    cout << (y >= x ? "unsafe" : "safe") << endl;


}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        long double a,b;
        cin>>a>>b;
        cout<<(ll)(a*b);
    }
    return 0;
}

Measured memory_bytes: 3752
d=input()
d1=d.split()
a=int(d1[0])
b=int(d1[1])
c=int(d1[2])
x=int(d1[3])
if a+b>=x:
    if a>x:
        print(x)
    else:
        print(a)
else:
    print(a-(x-a-b)) 


Measured memory_bytes: 9184
#include <iostream>
using namespace std;
string s;
int a,b,ok=1;
int main()
{
	cin>>a>>b;
	for(int i=1;i<=a+b+1;i++) cin>>s[i];
	for(int i=1;i<=a+b+1;i++) {
		if(i==a+1) continue;
		if(s[i]>='0'&&s[i]<='9') continue;
		ok=0;
	}
	if(s[a+1]!='-') ok=0;
	if(ok) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int match(char a,char b){
	if (a == b || a == '?' || b == '?')return 1;
	else return 0;
}
int cnt2(int l1,int r1,int l2,int r2){
	int l = max(l1, l2);
	int r = min(r1, r2);
	return max(r-l,0);
}
int cnt3(int l1, int r1, int l2, int r2, int l3, int r3) {
	int l = max(l1, max(l2, l3));
	int r = min(r1, min(r2, r3));
	return max(r-l,0);
}

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

	vector<string>s(3);
	cin >> s[0] >> s[1] >> s[2];
	sort(all(s));

	int ans = 1e9;
	do {
		string a = s[0];
		string b = s[1];
		string c = s[2];
		int sza = a.size();
		int szb = b.size();
		int szc = c.size();
		vector<int>checkab(5000);
		vector<int>checkbc(5000);
		vector<int>checkac(5000);
		for (int i = 0; i < 5000; i++) {
			int ok = 1;
			for (int j = 0; j < b.size(); j++) {
				if (i + j >= a.size())continue;
				else if (match(a[i + j], b[j]))continue;
				else ok = 0;
			}
			checkab[i] = ok;
		}
		for (int i = 0; i < 5000; i++) {
			int ok = 1;
			for (int j = 0; j < c.size(); j++) {
				if (i + j >= b.size())continue;
				else if (match(b[i + j], c[j]))continue;
				else ok = 0;
			}
			checkbc[i] = ok;
		}
		for (int i = 0; i < 5000; i++) {
			int ok = 1;
			for (int j = 0; j < c.size(); j++) {
				if (i + j >= a.size())continue;
				else if (match(a[i + j], c[j]))continue;
				else ok = 0;
			}
			checkac[i] = ok;
		}

		for (int x = 0; x <= sza; x++) {
			for (int y = x; y <= sza + szb; y++) {
				int ab = x;
				int bc = y - x;
				int ac = y;
				int l = sza + szb + szc - cnt2(0, sza, x,x+szb) - cnt2(x, x + szb,y,y+szc) - cnt2(y, y + szc,0,sza) + cnt3(0,sza,x,x+szb,y,y+szc);
				if (checkab[ab] && checkbc[bc] && checkac[ac])ans = min(ans,l);
			}
		}
	} while (next_permutation(all(s)));
	puts(ans);

	return 0;
}


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

int main(void)
{
    int X;
    cin >> X;

    for (int i = X; ; i++) {
        bool isPrime = true;
        for (int j = 2; j < X; j++) {
            if (i % j == 0) {
                isPrime = false;
                break;
            }
        }
        if (isPrime) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
x=int(input())
a=list(map(int,input().split()))
dp=[0]*x
dp[1]=abs(a[1]-a[0])
for i in range(2,x):
    dp[i]=(min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2])))
print(dp[x-1])    

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

// 数字の各桁の和を返す
int sumDigits (int n) {
    int s;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

// 最大公約数を返す
int gcd (int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main () {
    int A, B, C; cin >> A >> B >> C;
    if (B != A && B != C) cout << B << endl;
    else if (C != A && C != B) cout << C << endl;
    else cout << A << endl;
}

Measured memory_bytes: 256
def calc_gcd(m,n):
    a=max(m,n)
    b=min(m,n)
    r=a%b
    while r>0:
        a=b
        b=r
        r=a%b
    return b

def calc_lcm(m,n):
    return m*n//calc_gcd(m,n)
    
A,B,C,D=map(int,input().split())
c_div=B//C-(A-1)//C
d_div=B//D-(A-1)//D
cd_div=B//calc_lcm(C,D)-(A-1)//calc_lcm(C,D)
print(B-A+1-c_div-d_div+cd_div)

Measured memory_bytes: 3064
#include <stdio.h>

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

  scanf("%d%d%d",&a,&b,&c);

  if(a<b) { if (b<c) printf("Yes\n");
    if(b>c)  printf("No\n"); }

 

  else   printf("No\n");


  return 0;

}

Measured memory_bytes: 580
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int n, a, c[100001], s, cnt;
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> a; c[a]++; }
	for (int i = 1; i <= 100000; i++) { s += max(0, c[i] - 1); if (c[i] >= 1)cnt++; }
	if (s % 2 == 0) { cout << cnt << endl; }
	else { cout << cnt - 1 << endl; }
	return 0;
}

Measured memory_bytes: 640
ri = lambda: map(int, input().split(' '))
L = [1]
C = [1]

def rec(n, x):
	if x == 0:
		return 0

	if n == 0:
		return 1

	if x == L[n]:
		return 2*C[n-1] + 1

	ans = 0
	if x >= L[n-1] + 2:
		ans += C[n-1] + 1
		ans += rec(n-1, x-L[n-1]-2)
	else:
		ans += rec(n-1, x-1)

	return ans

if __name__ == '__main__':
	N, X = ri()
	for i in range(1, N+1):
		L.append(2*L[i-1] + 3)
		C.append(2*C[i-1] + 1)
	ans = rec(N, X)
	print(ans)



Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int n, s[1010];
  double m, a2;
  while (true) {
    cin >> n;
    if (n == 0) break;

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

    a2 = 0;
    for (int i = 0; i < n; i++) {
      a2 += (s[i] - m) * (s[i] - m);
    }
    a2 /= n;

    printf("%lf\n", sqrt(a2));
  }
  
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>

using namespace std;

int main(){
    int k, s;
    int ans = 0;

    cin >> k >> s;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int l = s - i - j;
            if(0 <= l && l <= k) ans++;

        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define mp make_pair
#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    ll a[212345];

    cin >> n;

    REP(i, n)
    cin >> a[i];

    ll dp[212345][5];

    dp[0][0] = a[0];
    dp[0][1] = a[0] == 0 ? 2 : a[0] % 2;
    dp[0][2] = (a[0] + 1) % 2;
    dp[0][3] = a[0] == 0 ? 2 : a[0] % 2;
    dp[0][4] = a[0];

    for (int i = 1; i < n; i++)
    {
        int t1 = a[i] == 0 ? 2 : a[i] % 2;
        int t2 = (a[i] + 1) % 2;

        dp[i][0] = dp[i - 1][0] + a[i];

        dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + t1;

        dp[i][2] = min(dp[i - 1][2], min(dp[i - 1][0], dp[i - 1][1])) + t2;

        dp[i][3] = min(min(dp[i - 1][2], min(dp[i - 1][0], dp[i - 1][1])), dp[i - 1][3]) + t1;

        dp[i][4] = min(dp[i - 1][4], min(min(dp[i - 1][2], min(dp[i - 1][0], dp[i - 1][1])), dp[i - 1][3])) + a[i];
    }

    ll res = LLONG_MAX;

    REP(i, 5)
    res = min(res, dp[n - 1][i]);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 1 + n * ( n - 1) / 2;

    int syu[26] = {};
    REP(i,n){
        syu[s[i] - 'a'] ++;
    }

    REP(i,26){
        if(syu[i] >= 1){
            ans -= syu[i] * (syu[i] - 1) / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <array>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cstdio>

using namespace std;

#define int long long

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

    int n,x,sum = 0;

    cin >> n >> x;
    int i;
    for (i = 0; i < n; ++i)
    {

        int in;
        cin >> in;
        sum += in;
        //cout << "sum:" << sum << ",x:" << x << endl;
        if (sum > x)
        {
            break;
        }
    }
    cout << i + 1 << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

inf = 10**10

class Seg_min():
    def __init__(self,x):
        #####単位元######
        self.ide_ele_min = inf
        self.func = min

        self.n = len(x)

        #num_max:n以上の最小の2のべき乗
        self.num_max =2**(self.n-1).bit_length()
        self.x = [self.ide_ele_min]*2*self.num_max

        for i,num in enumerate(x, self.num_max):
            self.x[i] = num
        for i in range(self.num_max-1,0,-1):
            self.x[i] = self.func(self.x[i<<1],self.x[(i<<1) + 1])

    def update(self,i,x):
        i += self.num_max
        self.x[i] = x
        while(i>0):
            i = i//2
            self.x[i] = self.func(self.x[i<<1],self.x[(i<<1) + 1])

    def query(self,i,j):
        res = self.ide_ele_min
        if i>=j:
            return res
        i += self.num_max
        j += self.num_max -1
        while(i<=j):
            if(i==j):
                res = self.func(res,self.x[i])
                break
            if(i&1):
                res = self.func(res,self.x[i])
                i += 1
            if(not j&1):
                res = self.func(res,self.x[j])
                j -= 1
            i = i>>1
            j = j>>1
        return res

n,q,*query = list(map(int,read().split()))

wall_ns = Seg_min([inf] * (n-2))
wall_ew = Seg_min([inf] * (n-2))
min_ns = [n-2] * (q+1)
min_ew = [n-2] * (q+1)

ans = (n-2)*(n-2)
for i in range(1,q+1):
    x = query[i*2-1] - 2
    if(query[i*2-2] == 1):
        last = wall_ns.query(0,x)
        if(last == inf):
            last = i-1
        ans -= min_ew[last]

        wall_ns.update(x,i)
        min_ns[i] = min(min_ns[i-1], x)
        min_ew[i] = min_ew[i-1]
    else:
        last = wall_ew.query(0,x)
        if(last == inf):
            last = i-1
        ans -= min_ns[last]

        wall_ew.update(x,i)
        min_ew[i] = min(min_ew[i-1], x)
        min_ns[i] = min_ns[i-1]

print(ans)

Measured memory_bytes: 114376
a, b = map(int, input().split())
if a*b == 0 or a < 0 < b:
    ans = 'Zero'
elif a > 0 and b > 0:
    ans = 'Positive'
else:
    if (b - a) % 2 == 0:
        ans = 'Negative'
    else:
        ans = 'Positive'

print(ans)

Measured memory_bytes: 38256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		string S = GetString();

		Console.WriteLine((S[0] != S[1]) && (S[1] != S[2]) && (S[2] != S[3]) ? "Good" : "Bad");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f

N = INT()
a = [LIST() for _ in range(N)]

dp = [0]*(1<<N)
dp[0] = 1
for S in range(1, 1<<N):
    i = popcount(S)
    for j in range(N):
        if (S>>j)&1 and a[i-1][j] == 1:
            dp[S] += dp[S^(1<<j)]
            dp[S] %= mod
print(dp[(1<<N)-1])


Measured memory_bytes: 95304
#include<bits/stdc++.h>
#define mod 1000000007
#define mx 200001
//#define y 20
using namespace std;
typedef long long int ll;
# define f(i, n) for(int i = 0;i < n; ++i)
typedef long long int ll;
   ll ans = 1;
void dfs(vector<int>adj[], int s, int V, int k){


}
void input()
{
    ll l, r;
    cin >> l >> r;
    ll y = min(r, l + 5000);
    ll z = y - l + 1;
   vector<ll>a(z);
   int j = 0;
    for(ll i = l; i <= y ; ++i){
        a[j] = i % 2019;++j;
    }
    ll ans = INT_MAX;
    for(int i = 0; i < z; ++i){
        for(int j = i + 1; j < z; ++j){
           ll x = ((a[i] % 2019) * (a[j] % 2019)) % 2019;
            ans = min(ans, x);
        }
    }
    cout << ans % 2019 << endl;
}
int main()
{
    input();
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int a, b, c;
    cin >> a >> b >> c;

    if(c <= a + b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stack>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

const int MAX = 100111;
int N, M;
int A[100111];
int C[100111];
VI odd[100111];
VI even[100111];


const int INF = 1e9;

int main() {
    scanf("%d%d", &N, &M);
    REP (i, N) scanf("%d", A+i);
    REP (i, N) C[A[i]]++;
    REP (i, MAX) {
	if (C[i]) {
	    if (C[i] % 2) odd[i % M].push_back(C[i]);
	    else even[i % M].push_back(C[i]);
	}
    }
    
    int ans = 0;

    stack<int> st;

    REP (i, M) if (odd[i].size()) {
	st.push(i);
    }
    while (!st.empty()) {
	int v = st.top();
	if (odd[v].size()) {
	    int p = odd[v].back(); odd[v].pop_back();
	    int w = (M - v) % M;

	    if (odd[w].size()) {
		int q = odd[w].back(); odd[w].pop_back();
		ans++;
		p--;
		if (p) even[v].push_back(p);
		q--;
		if (q) even[w].push_back(q);
//		eprintf("oo %d %d\n", v, w);
	    } else if (even[w].size()) {
		int q = even[w].back(); even[w].pop_back();
		ans++;
		p--;
		if (p) { even[v].push_back(p); }
		q--;
		if (q) { odd[w].push_back(q); st.push(w); }
//		eprintf("oe %d %d\n", v, w);
	    } else {
		ans += p / 2;
	    }
	} else {
	    st.pop();
	}
    }

    REP (i, M) {
	EACH (e, even[i]) {
	    ans += *e / 2;
	}
    }


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

    return 0;
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int n;
    cin >> n;
    if (n % 2 == 0 && (n%3 != 0 && n%5 != 0)) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  ll x;
  cin >> x;
  bitset<32> b(x);
  cout << b << endl;
  cout << ~b << endl;
  cout << (b<<1) << endl;
  cout << (b>>1) << endl;
}



Measured memory_bytes: 3148
N = int(input())
D = []
for i in range(N):
    a, b = map(int, input().split())
    D.append((a, b))

D = sorted(D, key=lambda x: x[1])
pre = 0
for i in range(N):
    a, b = D[i]
    if pre + a > b:
        print('No')
        exit()
    else:
        pre += a

print('Yes')

Measured memory_bytes: 76632
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	int h[n];
	int i, j;
	for(i = 0; i < n; i++)
		scanf("%d", h + i);
	int ans[n];
	int temp, min;
	ans[0] = 0;
	ans[1] = abs(h[1] - h[0]);
	for(i = 2; i < n; i++){
		for(j = i - 1; j >= 0 && j >= i - k; j--){
			temp = ans[j] + abs(h[i] - h[j]);
			if(j == i - 1)
				min = temp;
			else if(temp < min)
				min = temp;
		}
		ans[i] = min;
	}
	printf("%d\n", ans[n - 1]);
	return 0;
}

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

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

#define TASKNAME somethinghere

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

	//freopen("input.txt", "r", stdin);
	//freopen(TASKNAME".inp", "r", stdin);
	//freopen(TASKNAME".out", "w", stdout);

    ll n, k;
    cin >> n >> k;
    ll ct = 0;
    for(ll i = 0; i < n; i++) {
		ll x; cin >> x;
		if(x >= k) ct++;
    }
    cout << ct;
}

/* stuff you should look for
	* array bounds
	* special cases (n=1?), set tle
	* do sth instead of nothing and stay organized
	* check for variables with close names
*/


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int main(void){
  int W,N,v[1001],w[1001];
  int cas = 1;
  while(cin>>W){
    if(W==0) break;
    int dp[1001]={0};
    printf("Case %d:\n",cas++);
    cin>>N;
    REP(i,N){
      scanf("%d,%d",&v[i],&w[i]);
    }
   for(int i=0; i<N; i++){
     for(int j=W;j-w[i]>=0;j--){
      dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
     }
   }
  printf("%d\n",dp[W]);
  for(int i=0; i<=W; i++){
    if(dp[i]==dp[W]){
      printf("%d\n",i);
      break;
    }
  }

  }
  return 0;
}

Measured memory_bytes: 0
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let s = scan.read::<String>();
    let days = vec!["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
    for i in 0..7 {
        if &s == days[i] {
            println!("{}", 7 - i);
        }
    }
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
N, M = map(int,input().split())

ax = [1]*(N+1)
for m in range(M):
    ai = int(input()) - 1
    ax[ai+1] = None
# maybe ax[k] = ax[k-1] + ax[k-2]
#print(ax)

chunk_num = []
num = 0
for i in range(len(ax)):
    if ax[i] is not None:
        num += 1
    else:
        chunk_num.append(num)
        num = 0
chunk_num.append(num)

#print(chunk_num)
bu = {0:1, 1:1}
for i in range(1, max(chunk_num)):
    if bu.get(i) is None:
        bu[i] = bu[i-1] + bu[i-2]

rs = 1
for num in chunk_num:
    #print('l', num, bu[num-1])
    try:
        rs *= bu[num-1]
    except:
        rs = 0
    rs %= 1000000007
print(rs%1000000007)

Measured memory_bytes: 469372
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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


lli ans = 1;

lli n, p;

lli power(lli a, lli b) {
    if (b == 0) {
        return 1;
    }
    lli temp = power(a, b/2);
    if(temp > 1e6) {
        cout << ans << endl;
        exit(0);
    }
    if (temp * temp > p) {
        cout << ans << endl;
        exit(0);
    }
    if (temp * temp > 1e6 and a > 1e6) {
        cout << ans << endl;
        exit(0);
    }
    lli res = (b & 1 ? temp * a * temp : temp * temp);
    return res;
}

void solve() {
    cin >> n >> p;
    if(n == 1) {
        cout << p << endl;
        return;
    } else {
        lli x = 1;
        while (1) {
            lli val = power(x, n);
            if (val > p) break;
            if(p % val == 0) {
                ans =  max(ans, x);
            }
            x++;
        }
    }
    //cout << (1e18) << endl;
    cout << ans << endl;
}

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

    while(t--)
        solve();
    return 0;
}


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

int64_t N, X, D, V[50], M[50], W[50];
vector<int> child[50];
const int MAX = 50*50*50;
int64_t dp[MAX+1];

void dfs(int i){
    V[i] = 1;
    W[i] = M[i];
    for(auto j : child[i]){
        dfs(j);
        V[i] += V[j];
        W[i] += W[j];
    }
}

int main(){
    cin >> N >> X >> D;
    for(int i=0; i<N; i++){
        cin >> M[i];
        if(i>0){
            int p;
            cin >> p;
            child[p-1].push_back(i);
        }
    }

    dfs(0);
    vector<int> order;
    for(int i=0; i<N; i++) order.push_back(i);
    sort(order.begin(), order.end(), [](int i, int j){ return V[i] * W[j] > V[j] * W[i];});

    int64_t INF = 1e10;
    fill(begin(dp), end(dp), INF);
    dp[0] = 0;
    for(int i=0; i<N; i++){
        int num = (i==0 ? 50 : min((int64_t)50, D));
        for(int k=1; num>0; k*=2){
            if(num<k) k = num;
            num -= k;
            int64_t wdiff = W[i] * k;
            int vdiff = V[i] * k;
            for(int j=MAX; j>=vdiff; j--){
                dp[j] = min(dp[j], dp[j-vdiff] + wdiff);
            }
        }
    }

    int ans = 0;
    for(int j=0; j<=MAX; j++){
        int64_t w = dp[j];
        int v = j;
        if(w > X) continue;
        for(auto i : order){
            int64_t num = (i==0 ? INF : max((int64_t)0, D-50));
            int use = min(num, (X-w)/W[i]);
            v += use * V[i];
            w += use * W[i];
        }
        ans = max(ans, v);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction
import sys

sys.setrecursionlimit(10 ** 6)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

n,p=MI()
if n==1:
    print(p)
    exit()
ans=1
for a in range(2,p+1):
    if a**2>p:break
    cnt=0
    while p%a==0:
        cnt+=1
        p//=a
    ans*=a**(cnt//n)
print(ans)

Measured memory_bytes: 10332
/*
https://t.me/unstoppabIesoIvemachinechannel
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(),a.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;








main(){
    int n;
    cin >> n;
    vector<double> p(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    double dp[n][n + 1];
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= n; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1 - p[0];
    dp[0][1] = p[0];
    for (int i = 1; i < n; i++){
        for (int j = 0; j <= n; j++){
            dp[i][j] = dp[i-1][j-1]*p[i];
            dp[i][j] += dp[i-1][j]*(1-p[i]);
        }
    }
    double ans = 0;
    for (int i = (n + 1) / 2; i <= n; i++){
        ans += dp[n - 1][i];
    }
    cout << fixed << setprecision(10) << ans;
    //for (int i = 0; i < n; i++){
    //    for (int j = 0; j <= n; j++){
    //        cout << i << ' ' << j << ' ' << dp[i][j] << endl;
    //    }
   // }
}


Measured memory_bytes: 70528
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int a[31],b[31],dp[31][1<<16];

int count(int bits){
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main(void){

  int n,c,in;

  while(cin >> n >> c,n|c){
    
    fill(a,a+n,0);
    fill(b,b+c,0);

    for(int i=0;i<n;i++){
      for(int j=0;j<16;j++){
	cin >> in;
	a[i] |= in<<(15-j);
      }
    }

    for(int i=0;i<c;i++){
      for(int j=0;j<16;j++){
	cin >> in;
	b[i] |= in<<15-j;
      }
    }

    memset(dp,-1,sizeof(dp));

    dp[0][0]=0;

    for(int i=0;i<n;i++){
      for(int j=0;j<(1<<16);j++){
	if(dp[i][j]<0)continue;
	int now=a[i]|j;

	for(int k=0;k<c;k++){
	  int next=now & ~b[k];
	  dp[i+1][next]=max(dp[i+1][next],dp[i][j]+count(now & b[k]));
	}
      }
    }
    int ans=0;
    for(int i=0;i<(1<<16);i++){
      ans=max(ans,dp[n][i]);
    }
    cout << ans << endl;
  }

  return 0;
}

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

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

 int r=0;
 std::string ans="No";
 while(N!=0){
  r=N%10;
  N=N/10;
  if(r==7){
   ans="Yes";
   break;
  }
 }

 std::cout<<ans;
}

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

int N;
  
int main() {
  cin >> N;
  int t = N;
  int sum = 0;

  while(t > 0){
    sum += t % 10, t /= 10;
  }
    if(N % sum == 0){
    cout << "Yes" << endl;
      return 0;
    }
   else{
    cout << "No" << endl;
     return 0;
   }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

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

    rep(i, s.length() - 1)
    {
        if (s[i] == s[i + 1])
        {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        if (i < s.length() - 1 && s[i] == s[i + 2])
        {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

using LL = long long;

const int MAX_C = 8000;

bool can_achive (int res, vector < int > x) {
    res +=  MAX_C;
    vector < vector < int > > used(x.size() + 1, vector < int > (MAX_C * 2 + 10, 0));
    used[0][MAX_C] = 1;
    for (int i = 0; i < x.size(); ++i) {
        for (int j = 0; j < used[i].size(); ++j) {
            if (used[i][j]) {
                // cout << i <<  " " << j << endl;
                if (j + x[i] >= 0) {
                    used[i + 1][j + x[i]] = 1;
                }
                if (j - x[i] >= 0) {
                    used[i + 1][j - x[i]] = 1;
                }
            }
        }
    }
    return static_cast<bool>(used.back()[res]);
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.setf(std::ios_base::fixed);
    cout.precision(24);
    // freopen("input.txt", "r+", stdin);
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    int idx = 0;
    while (idx < s.size() && s[idx] == 'F') {
        x--;
        idx++;
    }
    idx++;
    vector < vector < int > > nums(2);
    int cnt = 1;
    int temp = 0;
    for (; idx < s.size(); ++idx) {
        if (s[idx] == 'T') {
            nums[cnt].push_back(temp);
            cnt += 1;
            cnt %= 2;
            temp = 0;
        } else {
            temp++;
        }
    }
    nums[cnt].push_back(temp);
    /*for (int i = 0; i < 2; ++i) {
        for (auto p: nums[i]) {
            cout << p  << " ";
        }
        cout << endl;
    }
    cout << x << " " << y << endl;*/
    if (can_achive(x, nums[0]) && can_achive(y, nums[1])) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 248704
#include <bits/stdc++.h>
 
#define pb push_back
#define lp(i,a,b) for(int i = a;i<b;i++)
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define mk make_pair
#define sz size()
 
const int MAXN = 1e5+10 ;
 
using namespace std ;

int n , m ;
int vet[MAXN] , acu[MAXN] ;
set<pair<double,int> > s ;

int main()
{
	
	scanf("%d%d", &n, &m) ;
	
	lp(i,0,n) 
	{
		scanf("%d", &vet[i]) ;
		s.insert( {1.0 * vet[i] , i} ) ;
	}
	
	while( m -- )
	{
		pair<double,int> topo = *prev(s.end()) ;
		
		s.erase( prev(s.end()) ) ;
		topo.ff /= 2.0 ;
		acu[ topo.ss ] ++ ;
		s.insert( topo ) ;
		
		//printf("Coloquei em %d\n"  ,topo.ss) ;
		
	}
	
	ll tot = 0 ;
	
	lp(i,0,n)
		if( acu[i] < 30 )
			tot += 1LL * ( vet[i] / (1<<acu[i]) ) ;
		
	printf("%lld\n", tot ) ;
	
}









Measured memory_bytes: 7296
# C Otoshidama

n, y = map(int, input().split())

for a in range(n+1):
  bc = n - a
  for b in range(bc+1):
    c = bc - b
    sum = 10000*a + 5000*b + 1000*c
    if sum == y:
      print(a, b, c)
      break
  else:
    continue
  break
else:
  print(-1, -1, -1)

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

#define N 100000

int q2n[10] = {0,2,4,6,8,1,3,5,7,9};

int main() {
	int n, a[10], m, dp[N+1][10];
	string s;
	cin >> n >> s;
	cin >> m;
	for(int j=0; j<10; ++j) dp[0][j] = 0;
	for(int i=0; i<m; ++i) cin >> a[i];
	dp[0][0] = 1;
	for(int i=0; i<n; ++i) {
		for(int j=0; j<10; ++j) dp[i+1][j] = 0;
		if(s[n-1-i]=='*') {
			if(i%2) {
				for(int j=0; j<10; ++j) for(int k=0; k<m; ++k) {
					dp[i+1][(j+q2n[a[k]])%10] += dp[i][j];
				}
			}else {
				for(int j=0; j<10; ++j) for(int k=0; k<m; ++k) {
					dp[i+1][(j+a[k])%10] += dp[i][j];
				}
			}
		}else {
			if(i%2) {
				for(int j=0; j<10; ++j) {
					dp[i+1][(j+q2n[(int)(s[n-1-i]-'0')])%10] += dp[i][j];
				}
			}else {
				for(int j=0; j<10; ++j) {
					dp[i+1][(j+(int)(s[n-1-i]-'0'))%10] += dp[i][j];
				}
			}
		}
	}
	cout << dp[n][0] << endl;
	return 0;
}

Measured memory_bytes: 5236
n=int(input())
s=input()
lr=0
lw=0
rr=0
rw=0
for i in range(n):
  if s[i]=='R':
    rr+=1
  else:
    rw+=1
minans=rr
for i in range(n):
  if s[i]=='R':
    rr-=1
    lr+=1
  else:
    rw-=1
    lw+=1
  ans=max(lw,rr)
  minans=min(ans,minans)
print(minans)

Measured memory_bytes: 70564
#include<stdio.h>

int main(void){
  int d[10],v[3],sum,ans,i,a,b;

  while(1){
    for(i=sum=0;i<10;i++){
      if(scanf("%d,",&d[i])==EOF)return 0;
      sum+=d[i];
    }      
      scanf("%d,%d",&v[1],&v[2]);

      ans=sum*v[2]/(v[2]+v[1]);
      for(i=9;i>=0;i--){
	ans-=d[i];
	if(ans<0){
	  printf("%d\n",i+1);
	  break;
	}
      }
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long b = scan.nextLong();
		long r = scan.nextLong();
		
		long count = n/(r+b);
		long rest = Math.min((n%(r+b)),b);
		
        System.out.println(count * b + rest);

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

int main() {
    long long t, n;
    cin >> n >> t;
    vector<int> ts(n);
    int ans = t;
    for (int i = 0; i < n; i++) {
        cin >> ts[i];
    }
    for (int i = 1; i < n; i++) {
        if (ts[i - 1] + t > ts[i]) {
            // cout << i << endl;
            ans += ts[i] - ts[i - 1];
        } else {
            ans += t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
from heapq import heappush, heappop

N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)

pq = [-A[0]]
ans = 0

for a in A[1:]:
    v = -heappop(pq)
    ans += v
    heappush(pq, -a)
    heappush(pq, -a)

print(ans)



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

using namespace std;

void solveCase() {
    long long n, d;
    vector<long long> costs(3);
    vector<int> muls = {2, 3, 5};
    cin >> n;
    for (int i = 0; i < muls.size(); i++) {
        cin >> costs[i];
    }
    cin >> d;
    map<long long, long long> mem;
    function<long long(long long)> dp;
    long long MX = 2e18;
    dp = [&] (long long v) -> long long {
        if (v <= 0) {
            return 0;
        }
        if (mem.count(v) == 0) {
            long long ans = v > MX/d ? MX : v*d;
            for (int st = -4; st <= 4; st++) {
                long long nxt = st + v;
                if (nxt < 0) {
                    continue;
                }
                for (int i = 0; i < muls.size(); i++) {
                    int mul = muls[i];
                    long long cur = d*abs(st) + costs[i];
                    if (nxt % mul == 0 && nxt/mul < v) {
                        ans = min(ans, cur + dp(nxt/mul));
                    }
                }
            }
            mem[v] = ans;
        }
        return mem[v];
    };
    auto res = dp(n);
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        solveCase();
    }
}



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

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

int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	int n; cin >> n;
	ii p[n], q[n];
	for(int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second; 
	}
	for(int i = 0; i < n; i++) {
		cin >> q[i].first >> q[i].second; 
	}

	sort(p, p + n, greater<ii>()); 
	vector<int> vis(n + 1, 0);
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int idx = -1, miny = 1e9; 
		for(int j = 0; j < n; j++) if(!vis[j]) {
			if(p[i].first < q[j].first && p[i].second < q[j].second) {
				if(q[j].second < miny) {
					miny = q[j].second; 
					idx = j;
				}
			}
		}
		if(idx == -1) continue; 
		vis[idx] = 1; 
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	long long x; cin >> x;
	long long A[n];
	for (int i = 0; i < n; i++) cin >> A[i];
	sort(A, A + n);
	int  ans = 0;
	for (int i = 0; i < n; i++) {
		x -= A[i];
		if (x >= 0) ans++;
		if (i == n - 1 && x > 0) ans--;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
c = 1001
for i in range(n):
    if l[i][1] <= t:
        c = min(c, l[i][0])
if c == 1001:
    print('TLE')
else:
    print(c)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int h, w, ans = 1;
  char s[51][51];

  if(scanf("%d %d", &h, &w) == 1);

  for(int i = 0; i < h; i++) {
    if(scanf("%s", s[i]) == 1);
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(s[i][j] == '#') {
        ans--;
        if(s[i+1][j] == '#' || s[i-1][j] == '#' || s[i][j+1] == '#' || s[i][j-1] == '#') {
          ans++;
        }
      }
    }
  }

  if(ans == 1) {
    printf("Yes");
  } else {
    printf("No");
  }

  return 0;
}


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

int main()
{
  int n;
  string s;
  cin>>n>>s;
  
  for(int i=0;i<s.size();i++)
  {
    int x=s.at(i)-'A';
    s.at(i)='A'+(x+n)%26;
  }
  cout<<s<<endl;
}
      
      

Measured memory_bytes: 256