akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
//Bitwise 
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI = 2*acos(0.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
db eps       =          0.000001;
ll mod       =          998244353;   //(1e9+7)
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";
    
    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  
    iota(B,B+r,1);     

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
const int SIZE=2000008;
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}

int main(){ 
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(10);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	vii arr(n);
	rep(i,0,n) cin>>arr[i];
	int tot=0;
	rep(i,0,n) tot=tot^arr[i];
	vii ans(n);
	rep(i,0,n) ans[i]=tot^arr[i];
	print(ans);
    return 0;
}

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

int main(){
  int n;
  int i,j,k;
  cin >> n;
  vector<int> bou(n);
  int ans=0;
  rep(i,n) cin >> bou[i];
  sort(bou.begin() ,bou.end() );
  for(i=0;i<n-2;i++){
  	for(j=i+1;j<n-1;j++){
    	for(k=j+1;k<n;k++){
        	if(bou[k]<bou[i]+bou[j]){
            	ans ++;
            }else{break;}
        }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
d[4],e[9],f,k;
char s[30];
z(){
	int a,b,c;
	a=e[f++];
	a>9?s[k++]=40,
		b=z(),
		s[k++]=a,
		c=z(),
		s[k++]=41,
		a=a-43?a-45?b*c:b-c:b+c:
		(s[k++]=a+48);
	return a;
}
y(o,n,i,j){
	if(i==7){
		f=k=0;
		if(z()==10){
			s[k]=0;
			puts(s);
			return 1;
		}
		return 0;
	}
	if(o){
		for(j=0;j<3;j++){
			e[i] = "+-*"[j];
			if(y(o-1,n+1,i+1,0))return 1;
		}
	}
	if(n||i==6){
		for(j=0;j<4;j++){
			if(e[i]=d[j]){
				d[j]=0;
				if(y(o,n-1,i+1,0))return 1;
				d[j]=e[i];
			}
		}
	}
	return 0;
}

int main(void){
	for(;scanf("%d%d%d%d",d,d+1,d+2,d+3),f=*d;)
		y(3,0,0,0)||puts("0");
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
#define abs(zz) ((zz>=0) ? (zz) : (-(zz)))

int main()
{
    int i,lng,test,d,ans=10000;
	char s[10];
	scanf("%s",&s);
	lng=strlen(s);
	
	for(i=0;i<(lng-2);i++)
	{
		test=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
		d=abs(test-753);
		if(d<ans)ans=d;
	}
	printf("%d",ans);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e,f;
	double x,y;

	while(scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)!=EOF){
		x=(double)(c*e-b*f)/(a*e-b*d);
		y=(double)(f*a-c*d)/(a*e-d*b);
		x=(double)(int)(x*1000+(x>0? 0.5 :-0.5))/1000;
		y=(double)(int)(y*1000+(y>0? 0.5 :-0.5))/1000;
		printf("%.3f %.3f\n",x,y);
	}

	return 0;
}

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

using namespace std;

#define MAXN 100005
vector<int> h;
int memo[MAXN];
int cost(int curr) {
	if(memo[curr] != -1)
		return memo[curr];
	//cout<<"Called with curr "<<curr<<endl;
	if(curr == h.size()-1)
		return 0;
	int cost1 = cost(curr + 1) + abs(h[curr] - h[curr+1]);
	int cost2 = (curr < h.size() - 2)?cost(curr + 2) + abs(h[curr] - h[curr+2]):INT_MAX;
	memo[curr] = min(cost1, cost2);
	return memo[curr];
}
int main() {
    int N;
	cin>>N;
	int temp;
	for(int i = 0; i < N; i++) {
		cin>>temp;
		h.push_back(temp);
	}
	memset(memo,-1,sizeof memo);
	cout<<cost(0);

}

Measured memory_bytes: 5880
/* 
   AOJ 1172
   Chebyshev's Theoreme
   2015.4.28
 */

#include<stdio.h>
#define MAX_N 123456

int count_prime(int n)
{
  int n_limit = n * 2, i, j, prime_by_n = 0, prime_by_nlimit = 0, prime_num[MAX_N * 2 + 1];
  
  for(i = 0; i < MAX_N * 2 + 1; i++)
    {
      prime_num[i] = 1;
    }

  prime_num[0] = 0;
  prime_num[1] = 0;  

  for(i = 2; i <= n_limit; i++)
    {
      /* printf("%d\n", i*i); */
      /* fflush(stdout); */

      if(prime_num[i] == 1)
	{
	  for(j = 2; i * j <= n_limit; j++)
	    {
      /* printf(" %d\n", j); */
      /* fflush(stdout); */
	      prime_num[i * j] = 0;
	    }
	}
    }


  for(i = 0; i <= n_limit; i++)
    {
      if(prime_num[i] == 1)
	{
	  if(i <= n)
	    {
	      prime_by_n++;
	      prime_by_nlimit++;
	    }
	  else
	    {
	      prime_by_nlimit++;
	    }
	}
    }

  return prime_by_nlimit - prime_by_n;
  
}

int main(void)
{
  int n, prime_num;
  while(1)
    {

      scanf("%d", &n);

      if(n == 0)
	{
	  break;
	}
      
      prime_num = count_prime(n);
      printf("%d\n", prime_num);

    }
  return 0;
}

Measured memory_bytes: 1560
#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[112345];

    ll w = 0, h = 0;

    map<int, bool> mp;

    cin >> n;

    vector<ll> v;

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

        if (mp[a[i]])
        {
            mp[a[i]] = false;
            v.push_back(a[i]);
        }
        else
        {
            mp[a[i]] = true;
        }
    }

    v.push_back(0);
    v.push_back(0);

    SORT(v);

    ll res = v[v.size() - 1] * v[v.size() - 2];

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 5760
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    def check(h,w):
        if(h+w)%2==0:
            return"#"
        else:
            return"."
    for h in range(H):
        for w in range(W):
            print(check(h,w),end="")
        print()
    print()


Measured memory_bytes: 7004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
const int maxn=1e5+5;
int main()
{
    int n;
    string s;
    scanf("%d",&n);
    int ans=0,x=0,y=0,z=0;
    rep(i,n)
    {
        cin>>s;
        int n=s.size();
        rep(i,n-1) if(s[i]=='A'&&s[i+1]=='B') ans++;
        if(s[0]=='B') x++;
        if(s[n-1]=='A') y++;
        if(s[0]=='B'&&s[n-1]=='A') z++;
    }
    if(x==y&&x==z&&x&&y&&z) ans+=(x-1);
    else ans+=min(x,y);
    printf("%d\n",ans);
}


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

int main() {
	// your code goes here
	int r, d ,x = 0;
	cin>>r>>d>>x;
	int resp = 0;
	
	for (int i=0; i<10;i++){
		
		resp=0;
		resp= r*x -d;
		x= resp;
		cout<<resp<< "\n";
		
	}
	return 0;
}

Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using tiii = tuple<int,int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const ll DIV =1e9+7;
//const double PI = M_PI;
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
#define chmax(a,b) a=max(a,b)

/*Coding Space*/
int main(){
  int n; cin >> n;
  int now = 1;
  int ans = 0;
  rep(i,n){
    int in; cin >> in;
    if(in == now){
      now++;
    }else{
      ans++;
    }
  }
  if(now == 1) {ans = -1;}
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
const int z = 1e9+7;
 
int fp(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * fp(a, x-1) % z;
    }
    int t = fp(a, x/2);
    return 1ll * t * t % z;
}
 
int rev(int a) {
    return fp(a, z - 2);
}
 
int c(int n, int m) {
    int ret = 1;
    for (int i = 1; i <= m; i++) {
        ret = 1ll * ret * (n - i + 1) % z;
        ret = 1ll * ret * rev(i) % z;
    }
    
    return ret;
}
 
int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> pc;
    for (int i = 2; i * i <= m; i++) {
        if (m % i == 0) {
            pc.push_back(0);
            while (m % i == 0) {
                pc[pc.size()-1]++;
                m /= i;
            }
        }
    }
    if (m != 1) {
        pc.push_back(1);
    } 
    
    int ans = 1;
    for (int i : pc) {
        ans = 1ll * ans * c(n+i-1, i) % z;
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int xorv(const vector<int>& v){
    int res=0;
    for(auto e:v){
        res^=e;
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    vector<int> b(n);
    for(int i=0;i<n;i++) cin>>b[i];
    if(a==b){
        cout<<0<<endl;
        return 0;
    }    
    int xa=xorv(a);
    int xb=xorv(b);
    multiset<int> as(a.begin(),a.end());
    multiset<int> bs(b.begin(),b.end());
    bool isneg=(as!=bs); 
    as.insert(xa);
    bs.insert(xb);
    if(as!=bs) cout<<-1<<endl;
    else{
        int res=0;
        map<int,set<int>> s;
        map<int,int> par;
        for(int i=0;i<n;i++){
            par[a[i]]=a[i];
            s[a[i]].insert(a[i]);
        }
        par[xa]=xa; s[xa].insert(xa);
        auto unite=[&](int x,int y){
            if(par[x]==par[y]) return;
            x=par[x],y=par[y];
            if(s[x].size()>s[y].size()){
                for(auto v:s[y]){
                    s[x].insert(v);
                    par[v]=x;
                }
            }
            else{
                for(auto v:s[x]){
                    s[y].insert(v);
                    par[v]=y;
                }
            }
        };
        for(int i=0;i<n;i++){
            if(a[i]!=b[i]){
                res++;
                unite(a[i],b[i]);
            }
        }
        set<int> ss;
        for(int i=0;i<n;i++){
            if(!ss.count(a[i]) && par[a[i]]==a[i]){
                ss.insert(a[i]);
                if(s[a[i]].size()>1 && !s[a[i]].count(xb)){
                    res++;
                }
            }
        }
        cout<<res<<endl;
        
    }


    
    return 0;
}

Measured memory_bytes: 54656
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include <set>
typedef long long ll;
using namespace std;
int a[1000005],maxx=-1,minn=1e9;
int main()
{
	ll n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{cin>>a[i];
	maxx=max(maxx,a[i]);
	minn=min(minn,a[i]);
	}
	cout<<maxx-minn;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>
#include <bitset>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  bool is_open[100][10];
  int p[100][11];
  for(int i=0;i<n;i++){
    for(int j=0;j<10;j++){
      cin>>is_open[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<=10;j++){
      cin>>p[i][j];
    }
  }

  int result=INT32_MIN;

  for(int i=0;i<(1<<10);i++){
    std::bitset<10> plan(i);
    if(plan.count()==0) continue;
    int tmp=0;
    for(int si=0;si<n;si++){
      int count=0;
      for(int ti=0;ti<10;ti++){
        if(plan[ti]&&is_open[si][ti]){
          count++;
        }
      }
      tmp+=p[si][count];
    }
    result=std::max(result,tmp);
  }
  cout<<result<<endl;



  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  set<int> res{};
  for (int i = 1; i < 10; ++i) {
    for (int j = 1; j < 10; ++j) {
      res.emplace(i * j);
    }
  }

  int N; cin >> N;
  auto ans = res.find(N) != res.end();
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m,s=map(int,input().split())
uvab=[list(map(int,input().split())) for i in range(m)]
cd=[list(map(int,input().split())) for i in range(n)]

def dijkstra(s,n):
    hq = [(0, s)]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost = [float('inf')] * n # 行ったことのないところはinf
    cost[s] = 0 # 開始地点は0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]: # コストが現在のコストよりも高ければスルー
            continue
        for d, u in e[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost


e = [[] for _ in range(10000*(n+1))]
for i in range(n):
    c,d=cd[i]
    for j in range(2500):
        e[10000*i+j].append((d,10000*i+min(j+c,2500)))
    
for i in range(m):
    u,v,a,b=uvab[i]
    u,v = u-1, v-1
    for j in range(2500):
        if j-a>=0:
            e[10000*v+j].append((b,10000*u+j-a))
            e[10000*u+j].append((b,10000*v+j-a))
# print(e)
s=min(2499,s)
# print(s)
lst=dijkstra(s,10000*(n+1))
# print(lst)
for i in range(1,n):
    ans=float('inf')
    for j in range(2500):
        ans=min(ans,lst[10000*i+j])
    print(ans)

Measured memory_bytes: 151676
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ab, cd;
	ab = a * b;
	cd = c * d;

	if (ab > cd)
		cout << ab << endl;
	else
		cout << cd << endl;
} 

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long inv[400000], f1[400000], f2[400000];
long long modexp(long long a, long long n)
{
    if(n==1)
        return a;
    long long res = modexp(a,n/2)%mod;
    if(n%2==0)
        return (res%mod*res%mod)%mod;
    else
        return (a%mod*res%mod*res%mod)%mod;
}
 long long C(long long n , long long a)
 {
    long long nca=1;
    for(long long i = 1; i<=a; i++)
    {
        nca = (nca%mod * (n+1-i)%mod *(modexp(i,mod-2)%mod))%mod;
    }
    return nca%mod;
 }

 long long fastC(long long n , long long k)
 {
     return (f1[n]%mod*f2[n-k]%mod*f2[k]%mod)%mod;
 }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,k;
    cin>>n>>k;

    inv[1]=1;
    for(int i=2; i<400000; i++)
    {
        inv[i] = mod - mod/i*inv[mod%i]%mod;
    }
    f1[0]=f2[0]=1;
    for(int i=1; i<400000; i++)
    {
        f1[i] = f1[i-1]*i%mod;
        f2[i] = f2[i-1]*inv[i]%mod;
    }
    if(n<=k)
{
    cout<<fastC(2*n-1, n);
     }

  else
  {
     long long ans=fastC(2*n-1, n);

     for(long long p=k+1; p<n ; p++)
     {
         ans = (ans%mod + mod  -(fastC(n,p)%mod * fastC(n-1,p)%mod)%mod)%mod;
     }
     cout<<ans%mod;
  }

    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <queue>

int main()
{
    long N,M;
    std::cin >> N >> M;
    std::priority_queue<long> A_queue;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        A_queue.push(temp);
    }

    for(long i=0; i<M; i++){
        long top=A_queue.top();
        A_queue.pop();
        A_queue.push(top/2);
    }

    long result=0;
    for(long i=0; i<N; i++){
        result+=A_queue.top();
        A_queue.pop();
    }
    std::cout << result << std::endl;
    return 0;
}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

  int ans = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 22; j <= d; j++) {
      if (j % 10 < 2) continue;
      if ((j % 10) * (j / 10) == i) ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
 * Created by Dipta Das on 27-04-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

int n;
vector<int> values;
vector<int> cost;
int ans = 0;

void sol (int idx, int v, int c) {
    if (idx >= n) return;

    cout << "VALUE: " << v << " COST: " << c << " DIFF: " << v-c << endl;
    ans = max (ans, v-c);

    sol (idx + 1, v + values[idx], c + cost[idx]);
    sol (idx + 1, v, c);
}

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


    cin >> n;
    values.assign(n, 0);
    cost.assign(n, 0);

    for (auto &i : values) cin >> i;
    for (auto &i : cost) cin >> i;

    for (int i = 0; i < n; ++i) {
        int x = values[i] - cost[i];
        ans += x > 0 ? x : 0;
    }

    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn p_of_divisors(x: u64) -> bool {
    let mut p = 1;
    for i in 1.. {
        if i * i > x {
            break;
        }
        if x % i == 0 {
            p *= i;
            if x / i != i && i != 1 {
                p *= x / i;
            }
        }
        if p >= x * 2 {
            return true;
        }
    }
    false
}

fn main() {
    let mut a = [0; 100001];
    let q = read::<usize>();

    for i in 2..100000 + 1 {
        let b = p_of_divisors(i as u64);
        if b {
            a[i] = a[i - 1] + 1;
        } else {
            a[i] = a[i - 1];
        }
    }

    for _ in 0..q {
        let n = read::<usize>();
        println!("{}", a[n]);
    }
}



Measured memory_bytes: 5424
n, m = map(int,input().split())
a = list(map(int,input().split()))
total = sum(a)

def counter(val):
  return True if val >= total / (4 * m) else False
  
def main():
  res = list(map(counter, a))
  print("YNeos"[sum(res)<m::2])

if __name__ == "__main__":
  main()
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

vector<int> tree[400010];

vector<vector<int> > nums;

void build(int n = 0,int l = 0,int r = (int)nums.size() - 1) {
	if(l == r) {
		tree[n] = nums[l];
		sort(tree[n].begin(),tree[n].end());
		return;
	}
	int md = (l+r)>>1;
	build(2*n+1,l,md);
	build(2*n+2,md+1,r);
	tree[n] = tree[2*n+1];
	tree[n].insert(tree[n].end(),tree[2*n+2].begin(),tree[2*n+2].end());
	sort(tree[n].begin(),tree[n].end());
}

int K;
int get(int a,int b,int n = 0,int l = 0,int r = (int)nums.size() - 1) {
	if(a == l && b == r) {
		return lower_bound(tree[n].begin(),tree[n].end(),K) - tree[n].begin();
	}
	int md = (l+r)>>1;
	int res = 0;
	if(a <= md)
		res = get(a,min(b,md),2*n+1,l,md);
	if(b > md)
		res += get(max(a,md+1),b,2*n+2,md+1,r);
	return res;
}

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

	int N,M,u,v;
	cin>>N>>M;
	nums.resize(M+1);
	for(int i = 0;i < N;i++) {
		cin>>u>>v;
		nums[u].push_back(v);
	}
	build();
	for(int i = 1;i <= M;i++) {
		int res = N;
		for(int j = 0;j < M;j+=i) {
			K = j + i;
			res -= get(j+1,min(j+i-1,M));
		}
		cout<<res<<'\n';
	}
	return 0;
}
/**/


Measured memory_bytes: 40336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    int sum = 0;
    rep(i, N) {
        cin >> vec[i];
        sum += vec[i];
    }
    int ans = N;
    int mini = 1e5;
    rep(i, N) {
        if (abs(sum - N*vec[i]) < mini) {
            mini = abs(sum - N*vec[i]);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define f0(i, a, n) for(i = a; i < n; i++)
#define f1(i, a, n) for(i = a; i <= n; i++)
#define tc(t) int t;cin >> t;while(t--)
#define ini(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define ll long long int
#define vi vector<int>
#define si set<int>
#define pb push_back
#define mp make_pair
#define M 1e9+7
#define rr return 0
#define endl '\n'

using namespace std;

void solve() {
    ll k, r = 0, cnt = 0;
    cin >> k;
    if(k % 2 == 0 || k % 5  == 0) {
        cout << -1 << endl;
    } else {
        do {
            r = ( (r * 10) + 7 ) % k;
            cnt++;
        } while(r != 0);
        cout << cnt << endl;
    }
}

int main () {
    IOS;
    solve();
    rr;
}

Measured memory_bytes: 3644
K,A,B = list(map(int,input().split()))
if B-A <= 1:
    print(K+1)
    exit()
ans = A
K = K - (A-1)
yen = 0
if K%2 == 0:
    ans += (B-A)*(K//2)
else:
    ans += (B-A)*(K//2)+1
print(ans)

Measured memory_bytes: 3060
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
a = LI()
cnt_4 = len([True for elem in a if elem % 4 == 0])
if cnt_4 >= n // 2:
    print('Yes')
    sys.exit()
rest = n - cnt_4 * 2
cnt_2 = len([True for elem in a if elem % 2 == 0 and elem % 4 != 0])
if rest == 1:
    print('Yes')
elif cnt_2 == rest:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 20000
import Data.List

toInt :: String -> Int
toInt = read :: String -> Int

main = do
  [a, b, h, m] <- map fromIntegral . map toInt . words <$> getLine
  let alpha = 2*pi*(h/12 + m/720)
  let beta = 2*pi*(m/60)
  print $ sqrt ((a*(cos alpha)-b*(cos beta))^2 + (a*(sin alpha)-b*(sin beta))^2)


Measured memory_bytes: 4468
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e6;
const long long int inf = 1e9+7;
typedef pair<ll,ll> pairs;
vector<pairs> p;


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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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

int main(){
    ll r;
    cin>>r;
    ld ans = 2*r*3.141;
    cout<<2*r*3.141592<<endl;

    return 0;
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                bool flag1 = false;
                bool flag2 = false;
                for (int l = 0; l < N; l++) {
                    if (!flag1 && (S[l] - '0') == i) {
                        flag1 = true;
                    } else if (flag1 && !flag2 && (S[l] - '0') == j) {
                        flag2 = true;
                    } else if (flag1 && flag2 && (S[l] - '0') == k) {
                        ans++;
                        break;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
status = [0, 0, 0]
ans = "Yes"
for i in range(0, n):
    line = input().split(" ")
    a = list(map(int, line))
    if a[0] - status[0] < abs(a[1] - status[1]) + abs(a[2] - status[2]):
        ans = "No"
        break
    elif (abs(a[1] - status[1]) + abs(a[2] - status[2]) - a[0] + status[0]) % 2 != 0:
        ans = "No"
        break
    else:
        status = a[:]
print(ans)

Measured memory_bytes: 3064
/**
 *      ABC 53 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-06 01:56:00
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s; cin >> s;
    int a = s.find("A");
    int z = s.rfind("Z");

    cout << z - a + 1 << endl;

    return 0;
}

Measured memory_bytes: 720
#include <stdio.h>
#include <string.h>

int main(void)
{
	char code[1000];
	char decode[1000];
	int i;
	
	scanf("%s", code);
	
	i = 0;
	while (code[i] != '\0'){
		if (code[i] == 'A'){
			decode[i] = 'X';
		}
		else if (code[i] == 'B'){
			decode[i] = 'Y';
		}
		else if (code[i] == 'C'){
			decode[i] = 'Z';
		}
		else {
			decode[i] = code[i] - 3;
		}
		i++;
	}
	
	decode[i] = '\0'; 
	
	printf("%s\n", decode);
	
	return (0);
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  int a_,b_,c_;
  int ans = 0;
  cin >> a >> b >> c;
  if (a==b&&b==c&c%2==0){
    cout << -1 << endl;
  }else{
    while(a%2==0 && b%2==0 && c%2==0){
      ans++;
      a_ = (b+c)/2;
      b_ = (c+a)/2;
      c_ = (a+b)/2;
      a = a_;
      b = b_;
      c = c;
      

    }
    cout << ans << endl;
  }
  

}


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

int main(){
  string S;
  cin >> S;
  int A=S.size(),min_distance=1000;
  for(int i=0;i<A-2;i++){
    string T=S.substr(i,3);
    int B=stoi(T);
    min_distance=min(min_distance,abs(B-753));
  }
  cout << min_distance << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(n),c(m),d(m);
  rep(i,n) cin >> a[i] >> b[i];
  rep(i,m) cin >> c[i] >> d[i];
  rep(i,n){
    int md = 1000000000;
    rep(j,m) md = min(md,abs(a[i]-c[j])+abs(b[i]-d[j]));
    rep(j,m){
      if(abs(a[i]-c[j])+abs(b[i]-d[j]) == md){
        cout << j+1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
  long long n;
  cin >> n;
  long long sum = 0;
  while (n)
  {
      if (n % 5 != 0 && n % 3 != 0)
        sum += n;
        n--;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    ll n;
    cin>>n;
    ll ans=0;
    for (ll i=1;i*i<=n-1;i++)
    {
        if ((n-1)%i==0)
        {
            if (i>=2)
            ans++;
            if ((n-1)/i>=2)
                ans++;
            if (i*i==(n-1)&&i>1)
                ans--;
        }
    }
    for (ll i=1;i*i<=n;i++)
    {
        if (n%i==0)
        {
            if (i==1)
            {
                ans++;
                continue;
            }
            ll wn=n;
            while (wn%i==0)
                wn/=i;
            if (wn%i==1&&i>1)
                ans++;
            wn=n;
            while (wn%(n/i)==0)
                wn/=(n/i);
            if (wn%(n/i)==1&&n/i>1)
                ans++;
            if (wn%i==1&&i*i==n&&i>1)
                ans--;
        }
    }
    cout<<ans;







}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 1005
#define MX 25
#define MOD 1000000007
using namespace std;
typedef long long int ll;

int A[MX];
int C[SIZE][SIZE];
int dp[MX][SIZE];

void make()
{
	for(int i=0;i<SIZE;i++)
	{
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
	}
}
int main()
{
	make();
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++) scanf("%d",&A[i]);
	dp[0][0]=1;
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(dp[i][j]==0) continue;
			for(int k=0;j+k<=n&&k<=A[i];k++)
			{
				ll way=dp[i][j];
				way=way*C[n-j][k]%MOD;
				way=way*C[n-k][A[i]-k]%MOD;
				dp[i+1][j+k]+=way;
				if(dp[i+1][j+k]>=MOD) dp[i+1][j+k]-=MOD;
			}
		}
	}
	printf("%d\n",dp[m][n]);
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int  main(){
  int N,K,B;
  str S1,S2,S3;
  cin>>N>>K>>B;
  if(-N+B<=0)cout<<"delicious"<<endl;
  else if(abs(K-B)<=N)cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
}


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

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
P mp(int x, int y) {
  if (x > y) swap(x, y);
  return P(x, y);
}

map<P, int> ctr;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  vector<int> xs;
  rep(_, 6) {
    int w, h;
    cin >> w >> h;
    xs.pb(w);
    xs.pb(h);
    ctr[mp(w, h)]++;
  }
  sort(all(xs));
  for (int w : xs) {
    for (int h : xs) {
      for (int l : xs) {
        map<P, int> copy(ctr);
        copy[mp(w, h)]-=2;
        copy[mp(h, l)]-=2;
        copy[mp(l, w)]-=2;
        bool ok = true;
        for (auto p : copy) {
          if (p._2 != 0) ok = false;
        }
        if (ok) {
          cout << "yes\n";
          return 0;
        }
      }
    }
  }
  cout<<"no\n";
  return 0;
}

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

using lli = int64_t;
using vi = vector<lli>;
using vvi = vector<vi>;

int main()
{
    ios_base::sync_with_stdio(0);

    int n; cin >> n;

    vvi g(n, vi(n));

    for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++) cin >> g[i][j];

    lli ans = 0;

    for(int i = 0; i < n; i++)
    for(int j = i; j < n; j++) if(i != j)
    {
        int fl = 0;

        for(int k = 0; k < n; k++) if(k != i && k != j)
        {
            lli direct = g[i][j];
            lli path1 = g[i][k];
            lli path2 = g[k][j];

            if(path1 + path2 < direct)
            {
                cout << -1 << endl;
                return 0;
            }
            else fl |= path1 + path2 == direct;
        }

        if(!fl) ans += g[i][j];
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll K[110];
int main()
{
    ll a,b,c,d,e,g,h,i,j,l,m,n,o,ans=0;
    cin>>a;
    ll ar[3];
    ar[0]=500;
    ar[1]=5;
    for(i=0; i<=1; i++)
    {
        b=a/ar[i];
        if(ar[i]==500)
            ans+=b*1000;
        else ans+=b*5;
        if(a%ar[i]==0)
            break;
        else
        {
            a=a-(b*ar[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

using hash_t = unsigned long long;

struct rolloing_hash {
    int n, b;
    vector<hash_t> pow, hash;
    
    rolloing_hash() {}
    
    rolloing_hash(const string &s, hash_t b_ = 10007) {
        set(s, b_);
    }
    
    void set(const string &s, hash_t b_ = 10007) {
        n = s.size();
        b = b_;
        calc_pow();
        calc_hash(s.c_str());
    }

    void calc_pow() {
        pow.resize(n + 1); pow[0] = 1;
        for (int i = 0; i < n; i++) {
            pow[i + 1] = pow[i] * b;
        }
    }
    
    void calc_hash(const char *s) {
        hash.resize(n + 1);
        hash[0] = 0;
        for (int i = 0; i < n; i++) {
            hash[i + 1] = s[i] + hash[i] * b;
        }
    }
    
    hash_t get(int i) const {
        return hash[i]; 
    }
    
    hash_t get(int i, int j) const {
        return get(j) - get(i) * pow[j - i];
    }
};

using RH = rolloing_hash;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int a = n % 2 == 0 ? 2 : 1;
    int b = n % 2 == 0 ? n / 2 - 1 : n / 2;
    int c = b + a;
    int d = n - a;
    RH rh(s);
    int ans = n;
    while (a < b) {
        hash_t A = rh.get(0, a);
        if (rh.get(b, c) == A && rh.get(d, n) == A && rh.get(a, b) == rh.get(c, d)) {
            ans = min(ans, b);
        }
        a += 2;
        b -= 1;
        c += 1;
        d -= 2;
    }
    if (ans != n) {
        cout << "Love " << s.substr(0, ans) << '!';
    } else {
        cout << "mitomerarenaiWA";
    }
    cout << '\n';
}

Measured memory_bytes: 20080
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int mod = 998244353;
ll modinv(ll a,ll n){
	if(n == 0) return 1;
	ll small = modinv(a,n/2);
	small = (small * small) % mod;
	if(n % 2) small = (small * a) % mod;
	return small;
}
int main() 
{
	ll n,s;
	cin>>n>>s;
	ll arr[n+1];
	REP(i,0,n){
		cin>>arr[i+1];
	}
	ll power[n+1];
	power[0] = 1;
	REP(i,1,n+1){
		power[i] = (power[i-1] * 2) % mod;
	}
	ll dp[s+1][n+1];
	REP(i,0,n+1){
		REP(j,0,s+1){
			dp[j][i] = 0;
		}
	}
	// REP(i,0,n+1){
		dp[0][0] = power[n];
	// }
	ll val = modinv(2,mod-2);

	REP(i,1,n+1){
		// if(arr[i] <= s)
			// dp[arr[i]][i] = (dp[arr[i]][i] + (dp[0][i-1] * val) % mod) % mod;
		REP(j,0,s+1){
			dp[j][i] = (dp[j][i] + dp[j][i-1]) % mod;
		}
		REP(j,0,s+1){
			if(j + arr[i] <= s){
				dp[j+arr[i]][i] = (dp[j+arr[i]][i] + (dp[j][i-1]*val) % mod) % mod;
			}
		}
	}
	cout<<dp[s][n]<<endl;
	return 0;
}




Measured memory_bytes: 73964
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll N,K; cin >> N >> K;
    ll out=0;
    ll cnt=1;
    ll dev=modinv(2,MOD);
    for(ll i=K;i<=N;i++){
        ll tmp=N-i;
        out += ((N+1)*(N)%MOD*dev%MOD)%MOD;
        out -= (tmp*(tmp+1)%MOD*dev%MOD);
        if(out<0)out += MOD;
        out -=(i*(i-1)%MOD*dev%MOD);
        if(out<0)out += MOD;
        cnt++;
    }

    out += cnt;
    out = out%MOD;
    if(out<0)out += MOD;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

constexpr u64 MAX=1000100;

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

  i64 n;
  std::cin>>n;

  std::vector<i64> a(n);
  for(auto&& e:a)std::cin>>e;

  i64 gcd=a[0];

  rep(i,0,n)gcd=std::gcd(gcd,a[i]);

  if(gcd!=1){
    std::cout<<"not coprime\n";
    return 0;
  }

  std::vector<i64> pr(MAX+1,0);
  std::iota(all(pr),0);

  for(i64 i=2;i*i<=MAX;i++){
    if(pr[i]==i){
      for(i64 j=i*i;j<=MAX;j+=i){
        if(pr[j]==j)pr[j]=i;
      }
    }
  }

  std::set<i64> prime;

  rep(i,0,n){
    std::set<i64> tmp;
    i64 num=a[i];
    while(num!=1){
      tmp.emplace(pr[num]);
      num/=pr[num];
    }

    for(const auto& e:tmp){
      if(prime.find(e)!=prime.end()){
        std::cout<<"setwise coprime\n";
        return 0;
      }
      prime.emplace(e);
    }
  }

  std::cout<<"pairwise coprime\n";
  
  return 0;
}

Measured memory_bytes: 18668
import java.util.*;

public class Main{
  
  public static void main(String[] args){
  
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    char[] list = new char[str.length()];
    
    for(int i = 0; i < str.length(); ++i){
      list[i] = str.charAt(i);
    }
    
    int num1 = 0;
    int num2 = 0;
    for(int i = 0; i < list.length; ++i){
      char m = list[i];
      if(m == 'A'){
        num1 = i;
        break;
      }
     }
    for(int i = 0; i < list.length; ++i){
      char v = list[i];
      if(v == 'Z' && num2 < i){
        num2 = i;
      }
    }
    
    int count = 0;
    for(int i = num1; i <= num2; ++i){
      count++;
    }
   System.out.println(count);
  }  
}


Measured memory_bytes: 41068