akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("input.txt");ofstream coutt("output.txt");
int poww(int a,int b,int m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}


signed main(){
    FASTER;
    string s;cin>>s;
    int n=s.size();
    
    int mp[2019]={0};
    mp[0]=1;
    int lst=0,ans=0,ten=1;
    for(int i=n-1;i>=0;i--){
        lst=(lst+(s[i]-'0')*ten)%2019;
        ten=(ten*10)%2019;
        ans+=mp[lst];
        mp[lst]++;
    }
    cout<<ans;
}

Measured memory_bytes: 3756
#include<stdio.h>
int main()
{
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c))
	{
		int x=0,y=0;
		if(a==5)x+=1;
		else if(a==7)++y;
		if(c==5)x+=1;
		else if(c==7)++y;
		if(b==5)x+=1;
		else if(b==7)++y;
		if(x==2&&y==1)printf("YES\n");
		else printf("NO\n");
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Sep 19 21:06:18 JST 2020
 **/

signed main() {
    Int n, x, m;
    std::cin >> n >> x >> m;
    std::vector<Int> memo(m + 2, x);
    std::vector<Int> cnt(m, -1);
    REP(i, m + 1) {
        if (cnt[memo[i]] != -1) {
            Int ans = 0, tmp = 0;
            REP(j, std::min(n, cnt[memo[i]])) ans += memo[j];
            REP(j, cnt[memo[i]], i) tmp += memo[j];
            Int rem = n - cnt[memo[i]];
            if (rem > 0) {
                Int cycle = i - cnt[memo[i]];
                ans += tmp * (rem / cycle);
                REP(j, cnt[memo[i]], cnt[memo[i]] + rem % cycle) ans += memo[j];
            }
            std::cout << ans << std::endl;
            return 0;
        }
        cnt[memo[i]] = i;
        memo[i + 1] = memo[i] * memo[i] % m;
    }
}


Measured memory_bytes: 4776
n = int(input())

txy = [list(map(int,input().split())) for _ in range(n)]
txy =[[0,0,0]] + txy

for i in range(n):
    move = abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
    time = txy[i+1][0]-txy[i][0]
    if time % 2 ^ move % 2 == 1 or time < move:
        print("No")
        exit()

print("Yes")

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

class Main {
	static final String YES = "Yes";
	static final String NO = "No";

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		long[][] A = new long[(int) (3)][(int) (3)];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				A[i][j] = sc.nextLong();
			}
		}
		long N = sc.nextLong();
		boolean[][] c = new boolean[3][3];
		for (int i = 0; i < N; i++) {
			long b = sc.nextLong();
			for (int j = 0; j < A.length; j++) {
				for (int k = 0; k < A[0].length; k++) {
					if (A[j][k] == b) {
						c[j][k] = true;
					}
				}
			}
		}
		for (int i = 0; i < 3; i++) {
			boolean ok = true;
			for (int j = 0; j < 3; j++) {
				if (!c[i][j]) ok = false;
			}
			if (ok) {
				System.out.println(YES);
				return;
			}
		}
		for (int i = 0; i < 3; i++) {
			boolean ok = true;
			for (int j = 0; j < 3; j++) {
				if (!c[j][i]) ok = false;
			}
			if (ok) {
				System.out.println(YES);
				return;
			}
		}

		if ((c[0][0] && c[1][1] && c[2][2]) || (c[0][2] && c[1][1] && c[2][0])) {
			System.out.println(YES);
			return;
		}

		System.out.println(NO);
	}
}


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

int main(){
  int x,t;
  int ans;
  cin>>x>>t;
  if(x<t){
	ans = 0;
  }else{
    ans = x-t;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder {
    public class Program {
        public static void Main() {
            string s = Console.ReadLine();
            if ((s[0] == s[1] && s[1] == s[2])|| (s[1] == s[2] && s[2] == s[3])) {
                Console.WriteLine("Yes");
            }            else{
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  string S;cin>>S;
  S+='Z';
  int left=0, right,ans=-1;
  REP(right,0,S.size()){
    if((S.at(right)!='A'&&S.at(right)!='C'&&S.at(right)!='G'&&S.at(right)!='T')||right==S.size()-1){
      ans=max(ans,right-left);
      left=right+1;
    }
  }
  print(ans);

}


Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))

count = 0

for i in range(N):
    if i == 0 or i == 1:
        continue
    else:
        MAX = max(P[i-2],P[i-1],P[i])
        # print("max {}, p-2 {} ,p-1 {} p {}".format(MAX,P[i-2],P[i-1],P[i]))


        if MAX == P[i]:
            if P[i-1] >= P[i-2]:
                count += 1
                continue
            else:
                continue

        elif MAX == P[i-1]:
            continue

        elif MAX == P[i-2]:
            if P[i-1] >= P[i]:
                count += 1
                continue
            else:
                continue


print(count)




# print(max(1,3,5))

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

using namespace std;

int main (void) {
    long long N, M;
    cin >> N >> M;

    long long ans = 1;
    for ( long long i = 1; i * i <= M; i++ ) {
        if ( M % i != 0 )
            continue;

        long long x = M / i;
        if ( i * N <= M )
            ans = max(ans, i);
        if ( x * N <= M )
            ans = max(ans, x);
    }

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


Measured memory_bytes: 3640
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=set([0]+f);Y=set(X);R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):a,b,c=I();R+=[((a,b),c)];Y.add(c);X.add(a);X.add(b)
for i in r(m):a,b,c=I();H+=[(a,(b,c))];X.add(a);Y.add(b);Y.add(c)
s=dict(enumerate(sorted(X)));K=len(s);t=dict(enumerate(sorted(Y)));L=len(t);h=dict(zip(s.values(),s.keys()));w=dict(zip(t.values(),t.keys()));V=[[0]*-~K for i in r(L+1)];U=[i[:]for i in V];v=[i[:]for i in V]
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for i in r(L+1):
 for j in r(K):U[i][j+1]+=U[i][j]
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for j in r(K+1):
 for i in r(L):V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0:
   if U[-~f//2+y][x]|e==0 or V[y][-~e//2+x]|f==0:q+=[(c,d)];v[d][c]=1
if a>F:a='INF'
print(a)

Measured memory_bytes: 551336
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct Data {
    int start;
    int len;
    int v;
    Data(int start, int len, int v) : start(start), len(len), v(v) {}
    bool operator<(const Data d) const {
        if (start == d.start) {
            return len < d.len;
        }
        return start < d.start;
    }
};

int dp[45][45]; // dp[i][j] := j??????????????§????§??????????i???????????????????????§???

signed main()
{ // #define int long long ?????????????????§scanf???????????¨???????????????????????\?????????????????????
    int N, M, L; cin >> N >> M >> L;

    vector<Data> kamoku;

    rep(i, M) {
        int d, a, k, t; cin >> d >> a >> k >> t;
        --a;

        kamoku.PB(Data(a + d * N, k, t));
    }

    sort(all(kamoku));

    for (int i = 1; i <= L; ++i) {
        for (int j = 0; j < M; ++j) {
            Data da = kamoku[j];

            for (int k = da.start; k >= 0; --k) {
                chmax(dp[i][da.start + da.len], dp[i - 1][k] + da.v);
            }
        }
    }

    cout << *max_element(dp[L], dp[L] + 45) << endl;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const int max_n = 2e5+10;
int dp[max_n],ans[max_n];
deque<int> lis;

void dfs(vector<vector<int>> &g, int cv, int p, vector<int> &a){
  int idx = lower_bound(dp, dp+max_n, a[cv]) - dp;
  int pre_idx = idx;
  int pre_v = dp[idx];
  dp[idx] = a[cv];
  ans[cv] = lower_bound(dp, dp+max_n, INT_MAX/2) - dp;
  for(auto i:g[cv]){
    if(i == p) continue;
    dfs(g,i,cv,a);
  }
  dp[pre_idx] = pre_v;
}



int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  rep(i,max_n) dp[i]=INT_MAX/2;
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<vector<int>> g(n,vector<int>());
  rep(i,n-1){
    int u,v;
    cin >> u >> v;
    --u;--v;
    g[u].pb(v);
    g[v].pb(u);
  }

  dfs(g,0,-1,a);
  rep(i,n){
    cout << ans[i] << endl;
  }




  return 0;
    

}


Measured memory_bytes: 30824
#include<stdio.h>
int main(){
  int n,left=0,right=0,i;
  scanf("%d",&n);
  char s[n+1];
  scanf("%*c%s",s);
  for(i=0;i<n;i++){
    if(s[i]=='(')
      left++;
    else{
      if(left!=0)
        left--;
      else
        right++;
    }
  }
  for(i=0;i<right;i++)
    printf("(");
  printf("%s",s);
  for(i=0;i<left;i++)
    printf(")");
  puts("");
  return 0;
}


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

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

  if ( b == "A" ) {
    cout << "T" << endl;
  }
  else if ( b == "T" ) {
    cout << "A" << endl;
  }
  else if ( b == "C" ) {
    cout << "G" << endl;
  }
  else {
    cout << "C" << endl;
  }
 
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

//#define int ll

class DAnInvisibleHand {
public:
    ll N, T;
    ll A[101010];
    ll MX[101010];
void solve(std::istream& cin, std::ostream& cout) {
    cin >> N >> T;
    _for(i,N)cin >> A[i];
    ll mx = -1;
    rep(i,N,0)MX[i] = mx = max(mx, A[i]);
    ll difmx = -1, res = 0;
    _for(i,N-1)difmx = max(difmx, MX[i+1] - A[i]);
    _for(i,N-1)if(MX[i+1] - A[i] == difmx)res ++;
    cout << res << endl;


}
};


#undef int
int main() {
	DAnInvisibleHand solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int A[200][200], D[200], X[200];
int main() {
    int K;
    string S;
    cin >> K >> S;
    
    if (S.length() <= K){
        cout << S;
    } else {
        cout << S.substr(0, K) + "...";
    }
    return 0;
}



Measured memory_bytes: 3636
#include <stdio.h>

int main(void){
  int a,b,n,t;
  int i;
  while(scanf("%d %d %d",&a,&b,&n)!=EOF){
    //printf("%d,%d,%d\n",a,b,n);
    int s=0;
    t=a/b;
    a-=b*t;
    a*=10;
    for(i=0;i<n;i++){
      t=a/b;
      a-=b*t;
      a*=10;
      s+=t;
      if(a==0)  break;
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main(){
    string s;
    cin>>s;
    int l=s.size();
    if(l%2!=0) s=s.substr(0,l-1);
    else s=s.substr(0,l-2);
    l=s.size();
    string t;
    while(1){
        t=s.substr(0,l/2);
        if(t+t==s){
            cout<<l<<endl;
            return 0;
        }else{
            s=s.substr(0,l-2);
            l=s.size();
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<set>
#include <numeric> //For gcd()
#define ll long long int
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fo(i, n) for (int i = 0; i < n; ++i)
#define foe(i, n) for (int i = 1; i <= n; ++i)
#define Fo(i, k, n) for (int i = k; i < n; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++(i))
#define vi vector<int>
#define vll vector<ll>
#define vvl vector<vector<ll>>
#define vpll vector<pair<ll, ll>>
#define MOD 998244353
#define MAX 1024
using namespace std;
using pi = pair<ll, ll>;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	set<string> s;
	fo(i,n){
		string temp;
		cin>>temp;
		s.insert(temp);
	}
	cout<<s.size()<<endl;
}

Measured memory_bytes: 15592
#include<bits/stdc++.h>
using namespace std;
bool vis[111];
int n,k,d[111];
int main()
{
	cin>>n>>k;
	for(int i=0;i<k;i++)
	{
		cin>>d[i];
		for(int j=0;j<d[i];j++)
		{
			int a;
			cin>>a;
			vis[a]=true;
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3640
N = int(input())
A = list(map(int, input().split()))

dam_prob = 0
for i in range(N - 1):
    dam_prob = (A[i] - (dam_prob // 2)) * 2


start_dam = (A[-1] - (dam_prob // 2))
ans = [start_dam]
for i in range(N - 1):
    ans.append((A[i] - (ans[-1] // 2)) * 2)

print(*ans, sep=' ')


Measured memory_bytes: 14092
n=int(input())
a=[]
b=[]
c=[]

for i in range(n):
    ai,bi,ci=list(map(int,input().split()))
    a.append(ai)
    b.append(bi)
    c.append(ci)

last_a=[0 for i in range(n)]
last_b=[0 for i in range(n)]
last_c=[0 for i in range(n)]

last_a[0]=a[0]
last_b[0]=b[0]
last_c[0]=c[0]

for i in range(1,n):
    last_a[i]=max(last_b[i-1]+a[i],last_c[i-1]+a[i])
    last_b[i]=max(last_a[i-1]+b[i],last_c[i-1]+b[i])
    last_c[i]=max(last_a[i-1]+c[i],last_b[i-1]+c[i])

print(max([last_a[n-1],last_b[n-1],last_c[n-1]]))

Measured memory_bytes: 26820
#define _USE_MATH_DEFINES

#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>
#include <ctgmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;
const ll inf = 10e17;
const ld eps = 10e-9;

ll solve(void);

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

ll n, m;
vector<ll> a;


ll solve(void)
{
	cin >> n >> m;
	a.resize(n);
	for(auto&v :a)
		cin >> v;

	ll sum = 0;

	priority_queue<ll, vector<ll>, less<>> q;

	for (auto v : a) {
		sum += v;
		q.push(v);
	}

	ll cnt = 0;
	while (m - cnt > 0 && !q.empty())
	{
		auto p = q.top();
		q.pop();
		sum -= (p - p/2);
		if (p/2>0)
			q.push(p/2);
		cnt ++;
	}

	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 2168
N = int(input())

l = [int(x) for x in input().split(" ")]



mat = []
for _ in range(N):
	mat.append([])

for index, i in enumerate(l):
	for _ in range(i):
		mat[index].append(1)
	while len(mat[index]) != max(l):
		mat[index].append(0)


def trans(A:list) -> list:
    ans = []
    for col in range(len(A[0])):
        l = []
        for line in range(len(A)):
            l.append(A[line][col])
        ans.append(l)

    return ans    

garden = trans(mat)


count = 0
for line in reversed(garden):
	mark = False
	for index, i in enumerate(line):
		if i == 1 and mark == False:
			count += 1
			line[index] = 0
			mark = True
		
		elif i == 1 and mark == True:
			line[index] = 0

		elif i == 0:
			mark = False


print(count)



Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

struct Ed {
  int u, v;
  ll w;

  Ed() {}

  Ed(int u, int v, ll w) : u(u), v(v), w(w) {}

  bool operator<(const Ed &rhs) const {
    return w < rhs.w;
  }

  bool operator>(const Ed &rhs) const {
    return rhs < *this;
  }
};

const int N = 200010;
const ll INF = 1LL << 60;

int n, d;
int a[N], f[N];
pair<ll, int> p[N], q[N];
Ed mst[N];
Ed tmp[N * 2];

int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }

void divideConquer(int l, int r) {
  if (l == r)
    return;
  int mid = (l + r) >> 1;
  divideConquer(l, mid);
  divideConquer(mid + 1, r);
  merge(mst + l, mst + mid, mst + mid + 1, mst + r, tmp + 1);
  pair<ll, int> x = p[l], y = q[mid + 1];
  int a = r - l - 1, b = a;
  for (int i = l; i <= mid; ++i)
    tmp[++b] = Ed(p[i].second, y.second, p[i].first + y.first);
  for (int i = mid + 1; i <= r; ++i)
    tmp[++b] = Ed(x.second, q[i].second, x.first + q[i].first);
  inplace_merge(tmp + a + 1, tmp + a + mid - l + 2, tmp + b + 1);
  inplace_merge(tmp + 1, tmp + a + 1, tmp + b + 1);
  for (int i = l; i <= r; ++i)
    f[i] = i;
  int cnt = l;
  for (int i = 1; i <= b; ++i) {
    int u = find(tmp[i].u), v = find(tmp[i].v);
    if (u != v) {
      mst[cnt++] = tmp[i];
      f[u] = v;
    }
  }
  inplace_merge(p + l, p + mid + 1, p + r + 1);
  inplace_merge(q + l, q + mid + 1, q + r + 1);
}

int main() {

  scanf("%d%d", &n, &d);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i)
    p[i] = make_pair(a[i] - i * (ll)d, i);
  for (int j = 1; j <= n; ++j)
    q[j] = make_pair(a[j] + j * (ll)d, j);
  divideConquer(1, n);
  ll ans = 0;
  for (int i = 1; i < n; ++i)
    ans += mst[i].w;
  printf("%lld\n", ans);

  return 0;
}


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

int main() {
    char s[5];
    int len;
    int bus=0;

    scanf("%s", s);
    char set = s[0];

    for(int i=1; i<3; i++) {
        if (set != s[i]) {
            bus = 1;
            break;
        }
    }

    if (bus) printf("Yes");
    else printf("No");

    return 0;
}

Measured memory_bytes: 128
l=list(map(int,input().split()))
s=[1,4,7,9]
flag=True
for i in l:
    if i not in s:
        flag=False
if l[0]==l[1] or l[0]==l[2] or l[0]==l[3] or l[1]==l[2] or l[1]==l[3] or l[3]==l[2]:
    flag=False
if flag:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
N,x=map(int,input().split())
a=list(map(int,input().split()))
data=[10**20 for i in range(0,N)]
ans=10**20
test=0
for i in range(0,N):
    flag=0
    for j in range(0,N):
        if a[j-i]<data[j]:
            data[j]=a[j-i]
            flag=1
    if flag==1:
        test=sum(data)+x*i
        if test<ans:
            ans=test

print(ans)


Measured memory_bytes: 42604
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int main(){
int counter;
string n;
string hoshino="Hoshino";
cin>>counter;
cin.ignore();
for(int iii=0;iii<counter;iii++){
	getline(cin,n);
	string tmp="";
	for(int i=0;i<=max( 0,(int)n.size()-7 );i++){
		bool f=1;
		int cnt=0;
		for(int j=i;j<i+7;j++)if(n[j]!=hoshino[j-i])f=0;
		if(f)n[i+6]='a';
	}//endfor
	cout<<n<<endl;
}

	return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
    string S;
    cin >> S;
    S.erase(S.begin()+7);
    S.erase(S.begin()+4);
    
    istringstream yyyymmdd = istringstream(S);
    int date;
    yyyymmdd >> date;
    
    
    if (date>20190430) {
        cout << "TBD" << endl;
    }
    else{
        cout << "Heisei" << endl;
    }
    
}


Measured memory_bytes: 256
s=list(input())

l=[]
for i in s[1::2]:
  l.append(i)

new_l=[]
for i in s[::2]:
  new_l.append(i)
ans=0
if 'L' in new_l:
  ans='No'
else:
  ans='Yes'
num=0
if 'R' in l:
  num='No'
else:
  num='Yes'

if ans == 'Yes' and num == 'Yes':
  print('Yes')
else:
  print('No')
  

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

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> v;
    ll res = 100000000000;
    REP(i, N) {
        int tmp; cin >> tmp;
        v.push_back(tmp);
    }
    REP(i, 101) {
        ll tmp_res = 0;
        for (auto x: v) {
            tmp_res += (x-i)*(x-i);
        }
        res = min(res,tmp_res);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readInt

object Main {
  def round(n:Double) = {
    val m = n % 1000
    if(m>0) n-m+1000 else n
  }

  def getDebt(n:Int,m:Double):Int = if(n==0) m.toInt else getDebt(n-1,round(m*1.05))

  def main(args:Array[String]) = {
    val y = 100000.0
    val ratio = 1.05
    val n = readInt

    println(getDebt(n,y))
  }
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n - 1; i++){
        int a;
        cin >> a;
        A[--a]++;
    }

    copy(A.begin(), A.end(), ostream_iterator<int>(cout, "\n"));
}

Measured memory_bytes: 4048
def dfs(i, P):
    if len(P) == N:
        return 1
    c = 0
    for j, v in enumerate(G[i]):
        if j in P or v != 1:
            continue
        c += dfs(j, P + [j])
    return c


N, M = map(int, input().split())
G = [[0] * N for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a][b] = 1
    G[b][a] = 1
ans = 0
for i, v in enumerate(G[0]):
    if v == 1:
        ans += dfs(i, [0, i])
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

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

        String s = sc.next();
        int n = s.length();
        String sub1 = s.substring(0, ((n-1)/2));
        String sub2 = s.substring(((n+3)/2)-1, n );

        if(isPalindrome(s) && isPalindrome(sub1) && isPalindrome(sub2)){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }

    }

    static boolean isPalindrome(String str)
    {

        // Pointers pointing to the beginning
        // and the end of the string
        int i = 0, j = str.length() - 1;

        // While there are characters toc compare
        while (i < j) {

            // If there is a mismatch
            if (str.charAt(i) != str.charAt(j))
                return false;

            // Increment first pointer and
            // decrement the other
            i++;
            j--;
        }

        // Given string is a palindrome
        return true;
    }
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b;
  if (a==2 && b==2) cout << "Yes" << endl;
  else if (a==2 || b==2) cout << "No" << endl;
  else if (((a>=8 && a%2==0) || (a<8 && a%2)) && ((b>=8 && b%2==0) || (b<8 && b%2))) cout << "Yes" << endl;
  else if (!((a>=8 && a%2==0) || (a<8 && a%2)) && !((b>=8 && b%2==0) || (b<8 && b%2))) cout << "Yes" << endl;
  else cout << "No" << endl;
}




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

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)

typedef vector<int> vi;

int calc(vi& a,int bit)
{
	int sum[2]={0};
	rep(i,a.size())
		sum[!!((1<<i)&bit)]+=a[i];
	return abs(sum[0]-sum[1]);
}

int main()
{
	for(int n;cin>>n,n;){
		vi a(n);
		rep(i,n)
			cin>>a[i];
		int res=20000000;
		rep(i,1<<n)
			res=min(res,calc(a,i));
		cout<<res<<endl;
    }
	
	return 0;
}

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

using namespace std;

int main() {

	long n;
	cin >> n;

	map<long, long> a;
	long tmp;

	for (long i = 0; i < n; i++) {
		cin >> tmp;
		a[tmp]++;
	}

	long counter = 0;
	auto itr = a.begin();
	do {
		while (itr->second > 2) {
			itr->second -= 2;
			counter++;
			counter++;
		}
		itr = next(itr, 1);
	} while (itr != a.end());

	itr = a.begin();
	long count2 = 0;

	vector<long> c2;
	do {
		if (itr->second == 2) {
			c2.push_back(itr->first);
		}
		itr = next(itr, 1);
	} while (itr != a.end());

	if (c2.size() % 2 == 0 ) {
		counter += c2.size();
	}
	else  {
		counter += c2.size()+1;
	}
	
	cout << n-counter << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<string,int>> vpsi;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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

int n;string s;int ans=0;
cin >> n >> s;
rep(i,n){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
        ans++;
        i+=2;
    }
}
fin(ans);

//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 256
n = gets.to_i
p = n.times.map{gets.to_i}
dp = Array.new(n,Float::INFINITY)
dp[0] = 0
visited = Array.new(n,false)

cur = 0
adj = [cur]
while !adj.empty?
    cur = adj.shift
    break if cur == n - 1
    1.upto(6) do |d|
        break if cur + d >= n
        next if visited[cur+d]
        if p[cur+d] == 0
            adj.push(cur+d)
            dp[cur+d] = dp[cur] + 1 if dp[cur] + 1 < dp[cur+d]
            visited[cur+d] = true
        else
            nd = cur + d
            l = false
            while p[nd] != 0
                if visited[nd]
                    l = true
                    break
                end
                visited[nd] = true
                nd += p[nd]
            end
            if !visited[nd]
                adj.push(nd)
                dp[nd] = dp[cur] + 1 if dp[cur] + 1 < dp[nd]
                visited[nd] = true
            end
        end
    end
end
p dp[n-1]

Measured memory_bytes: 8612
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
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 main() {
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
 }


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  vector<int> A(3);
  for (int i=0; i<3; i++) cin >> A[i];
  sort(A.begin(),A.end());
  int ans = 0;
  for (int i=0; i<2; i++) {
    ans += A[i+1]-A[i];
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

#define REP(i, a, n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define N 100010
#define M 200010
#define endl "\n"

ll gcd(ll a_,ll b_){if(b_>a_)swap(b_,a_);return (b_==0?a_:gcd(b_,a_%b_));}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	string s;
	
	int a, b, c, d;
	
	cin >> s;
	
	a = s[0] - '0', b = s[1] - '0', c = s[2] - '0', d = s[3] - '0';
	
	if(a + b + c + d == 7){
		cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
	}
	else if(a+b+c-d == 7){
		cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
	}
	else if(a+b-c+d == 7){
		cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
	}
	else if(a-b+c+d == 7){
		cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
	}
	else if(a+b-c-d == 7){
		cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
	}
	else if(a-b+c-d == 7){
		cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
	}
	else if(a-b-c+d == 7){
		cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
	}
	else{
		cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#   ?¬?????±??????????????????????????????????????????¢??????????????\??¬????????§????????????????????°??????

#   ????????????????????¨????????????
dice = [0 for i in range(6)]
#   ??????????????¢????¨??????\???????????????
dice = list(input().split())
#   ??¢????????????????¨??????\???????????????
order = list(input())

for i in range(0, len(order)):
    #   S:5->1->2->6,5???1,1???2,,,
    if order[i] == "S":
        temp = dice[0]
        dice[0] = dice[4]
        dice[4] = dice[5]
        dice[5] = dice[1]
        dice[1] = temp
    #   E:4->1->3->6
    elif order[i] == "E":
        temp = dice[0]
        dice[0] = dice[3]
        dice[3] = dice[5]
        dice[5] = dice[2]
        dice[2] = temp
    #   W:3->1->4->6
    elif order[i] == "W":
        temp = dice[0]
        dice[0] = dice[2]
        dice[2] = dice[5]
        dice[5] = dice[3]
        dice[3] = temp
    #   N:2->1->5->6
    elif order[i] == "N":
        temp = dice[0]
        dice[0] = dice[1]
        dice[1] = dice[5]
        dice[5] = dice[4]
        dice[4] = temp
print("{0}".format(dice[0]))

Measured memory_bytes: 7592
import java.util.Scanner;		
	class Main{		
		public static void main(String[ ] args)throws java.lang.Exception {	
			
			//????????¬?????°?????????????????????????????????
			Scanner reader = new Scanner(System.in);
			
			//?¨??????\?????§?????????????????????????????????????????¨??´??°???
			
			int height = reader.nextInt();
			
			//?¨??????\?????§?????????????????????????????????????????¨??´??°???
			
			int width = reader.nextInt();
			
			reader.close();
			
			//??¢???????¨????
			int area = height*width;
			
			//??¨?????????????¨????
			int length = 2*height + 2*width;
			
			//?????????1?????§??????
			System.out.println(area + " " + length);
		}	
	}		

Measured memory_bytes: 25832
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define multiCase int T;cin>>T;for(int t=1;t<=T;t++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define perr(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define eb emplace_back
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-12;
const double PI=acos(-1.0);
const double ATRconst=PI/180.0;
const ll mod=998244353;
ll max_3(ll a,ll b,ll c){if(a>b&&a>c)return a;if(b>c)return b;return c;}
ll min_3(ll a,ll b,ll c){if(a<b&&a<c)return a;if(b<c)return b;return c;}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll n){ll r=1;while(n){if(n&1)r=(r*a)%mod;n>>=1;a=(a*a)%mod;}return r;}



void solve()
{
    int h1,m1,h2,m2,k,t1,t2;
    cin>>h1>>m1>>h2>>m2>>k;
    t1=h1*60+m1;
    t2=h2*60+m2;
    if(t2<t1)
        t2+=24*60;
    cout<<t2-t1-k<<'\n';
}
int main()
{
    closeSync;
    //multiCase
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3168
N, R = map(int, input().split())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
############################
 
x2 = Base_10_to_n(N, R)
print(len(x2))

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

LL n,s;

int check(LL b){
	LL sum=0,tmp=n;
	while(tmp){
		sum+=tmp%b;
		tmp/=b;
	} 
	return sum==s;
}

int check(int i,LL sum){
	LL x0=s-i;
	LL b=sum/i+1;
	return x0>=0 && x0<b && i<b;
}

int main(){
	cin>>n>>s;
	LL sn=(LL)sqrt(n)+1;
	for(int i=2;i<=sn;i++){
		if(check(i)){
			cout<<i<<endl;
			return 0;
		}
	}
	
	if(n<=s){
		if(n<s) cout<<-1<<endl;
		else cout<<n+1<<endl;
		return 0;
	}
	
	LL sum=n-s;
	sn=sum/sn+1;
	for(int i=sn;i>=1;i--){
		if(sum%i==0 && check(i,sum)){
			cout<<sum/i+1<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
} 

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

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        long[] x = new long[n];
        long[] y = new long[m];
        long sum = 0;
        for (int i = 0; i < n; i++) {
            x[i] = scanner.nextInt();
            if (i > 0) {
                x[i] -= sum;
            }
            sum += x[i];
        }
        sum = 0;
        for (int i = 0; i < m; i++) {
            y[i] = scanner.nextInt();
            if (i > 0) {
                y[i] -= sum;
            }
            sum += y[i];
        }
        long c = 0;
        for (int i = 1; i < m; i++) {
            c = (c + y[i] * i % mod * (m - i) % mod) % mod;
        }

        long ans = 0;
        for (int i = 1; i < n; i++) {
            ans = (ans + c * x[i] % mod * i % mod * (n - i) % mod) % mod;
        }
        System.out.println(ans);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);
        StringTokenizer tokenizer;

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

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

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

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

Measured memory_bytes: 45052
N = int(input())
A = list(map(int , input().split()))
Pos_min =  10**9
Neg_max = -10**9
Sum = 0

M = 0
for n in range(N):
	if A[n] < 0:
		M += 1

if M % 2 == 1:
	for n in range(N):
		if A[n] < 0:
			Neg_max = max(Neg_max , A[n])
		else:
			Pos_min = min(Pos_min , A[n])
#	print("Neg_max = " + str(Neg_max))
#	print("Pos_min = " + str(Pos_min))
	
	if abs(Neg_max) < abs(Pos_min):
		A.remove(Neg_max)
		Sum += Neg_max
	else:
		A.remove(Pos_min)
		Sum -= Pos_min
	
	for n in range(N-1):
		Sum += abs(A[n])

else:
	for n in range(N):
		Sum += abs(A[n])

print(Sum)



Measured memory_bytes: 14496
#include<bits/stdc++.h>
using namespace std;
bitset<2000005>bit;
int sum,n,x;
int main(){
	scanf("%d",&n);
	bit[0]=1;
	for(int i=1;i<=n;++i){
		scanf("%d",&x);
		bit|=(bit<<x);
		sum+=x;
	}
	for(int i=(sum+1)/2;i<=sum;++i){
		if(bit[i]){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
m = n
if n in [2,3]:
  print(n)
  exit()
while True:
  for i in range(2,int(m**0.5)+1):
    if m %i == 0:
      break
    elif i > int(m**0.5)-1:
      print(m)
      exit()
  m += 1

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define MAX 100005
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;

typedef long long ll;

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, h[MAX];

    cin>>n;

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

    h[0]--;
    for(int i = 1; i < n; i++){
        if(h[i] > h[i-1])
            h[i]--;
        if(h[i] < h[i-1]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

    return 0;
}



Measured memory_bytes: 640
const fs = require('fs');

function main(input) {
  var s = input.split('')
  var cnt = 0;
  for (i = 0; i < 3; i++) {
    if (s[i] == '1') {
      cnt++
    }
  }
  console.log(cnt)
}

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

Measured memory_bytes: 7496
use std::io::*;
use std::str::*;
use std::cmp;

fn read_from_stdin<T: FromStr>() -> T {
    let temp = stdin();
    let mut temp = temp.lock();
    read(&mut temp).unwrap()
}

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

fn main() {
    let N: i32 = read_from_stdin();
    let (mut max, mut min) = (1, std::i32::MAX as i32);
    for _ in 1..N + 1 {
        let A: i32 = read_from_stdin();
        max = cmp::max(A, max);
        min = cmp::min(A, min);
    }
    println!("{}", max - min);
}


Measured memory_bytes: 4476
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int edge[200][200];


int search(int p, int n) {
	vector<int> score(n, -1);
	queue<int> search;

	score[p] = 1;
	search.push(p);

	int max_s = -1;
	while (!search.empty()) {
		int c = search.front();
		search.pop();

		max_s = max(max_s, score[c]);

		FOR_LT(i, 0, n) {
			if (!edge[c][i]) continue;

			if (score[i] == -1) {
				score[i] = score[c] + 1;
				search.push(i);
				continue;
			}

			if (score[i] == score[c] - 1 || score[i] == score[c] + 1) {
				continue;
			}

			return -1;
		}
	}

	return max_s;
}

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

	int n; cin >> n;

	FOR_LT(i, 0, n) {
		FOR_LT(j, 0, n) {
			char c; cin >> c;
			if (c == '0') {
				edge[i][j] = 0;
			}
			else {
				edge[i][j] = 1;
			}
		}
	}

	int ans = -1;
	FOR_LT(i, 0, n) {
		int cur = search(i, n);
		ans = max(cur, ans);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=[]
for i in range(n-k+1):
  ans.append(min(abs(l[i])+abs(l[i]-l[i+k-1]),abs(l[i+k-1])+abs(l[i+k-1]-l[i])))
print(min(ans))

Measured memory_bytes: 14224
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/03/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int h,w; cin>>h>>w;
  constexpr int INF = 1e4;
  vector<vector<int>> dist(10, vector<int>(10, INF));
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      int c; cin>>c;
      dist[i][j] = c;
    }
  }
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int a; cin>>a;
      if (a == -1) continue;
      ans += dist[a][1];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def SI(): return input().split()

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

from math import ceil, floor, log2
from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product


def solve():
    a, b, x = MI()

    def f(n, x):
        return n // x

    print(f(b, x) - f(a-1, x))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3380
import collections
import numpy as np
import sys
sys.setrecursionlimit(10000000)
import copy
#N=int(input())
L,R=map(int,input().split())
l=[]
for i in range(2021):
    l.append(L%2019)
    if L==R:
        break
    L+=1
ans=2019999
for i in range(len(l)):
    for j in range(i+1,len(l)):
        ans=min(l[i]*l[j]%2019,ans)
print(ans)

Measured memory_bytes: 20644