akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ABichromeCells {
public:
	void solve(istream& in, ostream& out) {
        int n,a; in >> n >> a;
        out << n * n - a << endl;
	}
};

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

Measured memory_bytes: 256
N=int(input())
A=[format(i,'060b') for i in map(int,input().split())]
ans=0
mod=10**9+7
for k in range(60):
    count=[a[60-1-k] for a in A].count('0')
    ans+=count*(N-count)*(2**k)%mod
print(ans%mod)


Measured memory_bytes: 65708
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

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

    vector<int64_t> a(N), b(N);
    for(int i = 0; i < N; ++i) cin >> a[i];
    for(int i = 0; i < N; ++i) cin >> b[i];

    int64_t ans = 0;
    for(int i = 0; i <= 29; ++i){
        vector<int64_t> a2(N);
        vector<int64_t> b2(N);
        int64_t T = 1 << i;
        for(int j = 0; j < N; ++j){
            a2[j] = a[j] % (2 * T);
            b2[j] = b[j] % (2 * T);
        }
        sort(b2.begin(), b2.end());
        int64_t cnt = 0;
        for(int j = 0; j < N; ++j){
            auto l = lower_bound(b2.begin(), b2.end(), T * 2 - a2[j]);
            auto r = lower_bound(b2.begin(), b2.end(), T - a2[j]);
            auto l2 = lower_bound(b2.begin(), b2.end(), T * 4 - a2[j]);
            auto r2 = lower_bound(b2.begin(), b2.end(), T * 3 - a2[j]);
            cnt += l - r + l2 - r2;
        }
        ans |= (cnt % 2) << i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6548
#include <stdio.h>
int main(void) {
  int a, b, mas, count = 0;
  while(scanf("%d",&a) != EOF) {
  	count = 0;
    scanf("%d",&b); 
    mas = a + b;
    while(mas != 0) {
      mas = mas / 10;
      count++;
    }
    printf("%d\n",count);
  }
  return(0);
}

Measured memory_bytes: 600
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
# 同一の集合の判定
def same(x, y):
    if find(x) == find(y):
        return True
    else:
        return False
# 集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x

# 集合の数
def uCnt(x):
    return -par[find(x)]

N, M = map(int, input().split())
par = [-1 for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)

ans = min(par)
print(-ans)

Measured memory_bytes: 14416
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		int len = S.length();
		int K = len;

		for (int i=0; i<len-1; i++){
			if (S.charAt(i) != S.charAt(i+1)){
				int T = Math.max(i+1, len-(i+1));
				K = Math.min(K, T);
			}
		}
		System.out.println(K);
	}
}


Measured memory_bytes: 23716
#include<iostream>
#include<map>
using namespace std ;
int f,l,arr[15][15];
void sett(int x)
{
    l=x%10;
    while(x>9)
    {
        x/=10;
    }
    f=x;
}
typedef pair < int ,int > pii ;
int main()
{
    map < pii,int > m ;
    map < pii,int > :: iterator it ;
    int n;
    long long temp=0;
    cin >> n ;
    for(int i=1;i<=n;i++)
    {
        sett(i);
        if(l==0){continue;}
        m[pii(f,l)]++;
    }
    for(it=m.begin();it!=m.end();it++)
    {
        int a = it->first.first ;
        int b = it->first.second ;
        int x = m[pii(a,b)];
        int y = m[pii(b,a)];
        if(x!=0 && y!=0){temp+=(long long)(x*y);}
    }
    cout << temp << endl;
    return 0 ;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
            int typeFruit = Integer.parseInt(sc.next());
            int buy = Integer.parseInt(sc.next());

            List<Integer> fruit = new ArrayList<>();

            for(int i = 0; i < typeFruit; i++){
                fruit.add(Integer.parseInt(sc.next()));
            }

            Collections.sort(fruit);

            long ans = 0;

            for(int i = 0; i < buy; i++){
                ans += fruit.get(i);
            }

            System.out.println(ans);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 38560
#include<bits/stdc++.h>
using namespace std;
int func()
{
	int y,m,d;
	char c;
	cin>>y>>c>>m>>c>>d;
	if(m<=4)
		cout<<"Heisei"<<endl;
	else cout<<"TBD"<<endl;
	return 0;
}
int main()
{
	func();
	return 0;
}


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

int main()
{
  int a,b;
  cin>>a>>b;
  if(abs(a-b)%2==1)
  {
    cout<<"IMPOSSIBLE";
    return 0;
  }
  cout<<(a+b)/2;
  return 0;
  
}

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i=0; i<s.length(); i++){
    if(s[i]!=t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3852
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, M;
	cin >> N >> M;
	priority_queue<int> pq;
	int A;
	rep(i, 0, N)
	{
		cin >> A;
		pq.push(A);
	}

	rep(i, 0, M)
	{
		int p = pq.top();
		pq.pop();
		p /= 2;
		pq.push(p);
	}

	int ans = 0;
	while (!pq.empty())
	{
		ans += pq.top();
		pq.pop();
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main()
{
	int n, k;
  	string str;
    cin>>n;
  	cin>>str;
    cin>>k;
  	char ch = str[k-1];
  	for(int i = 0; i < str.size(); i++)
    {
      if(str[i] != ch)
        str[i] = '*';
    }
  cout<<str;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<long long> pre(n+1);

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

    pre[1] = a[1];
    pre[2] = a[2];
    for(int i = 3; i <= n; i++) {
        pre[i] = 1LL*a[i] + pre[i-2];
    }

    vector<long long> dp(n+1);
    dp[2] = max(a[1], a[2]);
    for(int i = 4; i <= n; i += 2) {
        dp[i] = max(a[i] + dp[i-2], pre[i-1]);
    }
    dp[1] = 0;
    for(int i = 3; i <= n; i += 2) {
        dp[i] = max(dp[i-1], 1LL * a[i] + dp[i-2]);
    }

    cout << dp[n] << endl;



    return 0;
}


Measured memory_bytes: 7164
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    string s;
    int count=0;
    cin >> s;
    if (s[1]=='B'){
      cout << "ARC" << endl;
    }
    if(s[1]=='R'){
      cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3596
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		int N = nextInt();
		myout(1 ^ N);
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 32752
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> s;
    for(int i=1;;i++){
        int p=i*(i+1)*(i+2)/6;
        if(p>1000000)break;
        else s.push_back(p);
    }
    int n=s.size();
    vector<int> dp(1000000);
    for(int i=0;i<n;i++){
        vector<int> ndp(1000000);
        for(int j=0;j<1000000;j++){
            if(!i)ndp[j]=j;
            else if(j<s[i])ndp[j]=dp[j];
            else ndp[j]=min(dp[j],min(dp[j-s[i]]+1,ndp[j-s[i]]+1));
        }
        dp=ndp;
    }
    vector<int> DP(1000000);
    for(int i=0;i<n;i++){
        if(s[i]%2==0)continue;
        vector<int> ndp(1000000);
        for(int j=0;j<1000000;j++){
            if(!i)ndp[j]=j;
            else if(j<s[i])ndp[j]=DP[j];
            else ndp[j]=min(DP[j],min(DP[j-s[i]]+1,ndp[j-s[i]]+1));
        }
        DP=ndp;
    }
    while(true){
        int p;scanf("%d",&p);
        if(!p)break;
        printf("%d %d\n",dp[p],DP[p]);
    }
    return 0;
}


Measured memory_bytes: 14240
#include<iostream>

int main() {

	int n;

	int a[1000];

	int b[1000];

	for (int i = 0; i < 1000; i++){
		a[i] = 0;
	b[i] = 0;
}

	int x, y;

	int j=0;

	f:

	std::cin >> n;

	if (n == 0)
		goto flag;

	for (int i = 0; i < n; i++) {
		std::cin >> x >> y;
		if (x > y)
			a[j] += (x + y);
		if (x < y)
			b[j] += (x + y);
		if (x == y){
			a[j] += x;
		b[j] += y;
	}
	}

	j++;

	goto f;

flag:

	for(int i=0;i<j;i++)
	std::cout << a[i] << ' ' << b[i] << std::endl;

	return 0;

}

Measured memory_bytes: 3008
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if((10*g+b)%4==0)  cout << "YES" << endl;
  else  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]%2==0)
		{
			if(a[i]%3!=0)
			{
				if(a[i]%5!=0)
				{
					cout<<"DENIED"<<endl;
					return 0;
				}
			 } 
		}
	}
	cout<<"APPROVED"<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,a[100010],x[100010];
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	x[0]=0;x[1]=abs(a[1]-a[0]);
	for (int i=2;i<n;i++) x[i]=min(abs(a[i]-a[i-1])+x[i-1],abs(a[i]-a[i-2])+x[i-2]);\
	cout<<x[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
string a,b;
int main()
{
	cin>>a>>b;
	for(int i=0;i<min(a.size(),b.size());i++)
	cout<<a[i]<<b[i];
	if(a.size()>b.size())
	for(int i=b.size();i<a.size();i++)cout<<a[i];
	else if(a.size()>b.size())
	for(int i=b.size();i<a.size();i++)cout<<a[i];
	cout<<endl;
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int,input().split()))
ans = 1
if 0 in As:
    print(0)
    exit(0)
for i in range(N):
    ans*=As[i]
    if ans > 1000000000000000000:
        print("-1")
        exit(0)
print(ans)

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

using namespace std;


void solve() {
    int A,B;
    cin >> A >> B;
    if (A<=B) {
        cout << "Impossible";
        return;
    }

    auto q = [](int x, int y)->bool{
        cout << "? " << x << ' ' << y << endl;
        string s; cin >> s;
        return s[0] == 'Y';
    };

    vector<int> stk;
    int n = A+B;
    for (int i = 0; i < n; i++) {
        if (stk.empty()) stk.emplace_back(i);
        else if (q(stk.back(), i)) stk.emplace_back(i);
        else stk.pop_back();
    }
    string res(n, '#');
    res[stk.back()] = '1';
    for (int i = 0; i < n; i++) {
        if (i==stk.back()) continue;
        res[i] = q(stk.back(), i)?'1':'0';
    }
    cout << "! " << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

#define INF ((1<<31)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



int main(){
    bool flag=true;
    ll ans=0,sum=0;
    int n,a,b;
    cin >>n>>a>>b;
    if((b-a)%2 == 0)flag=false;
    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(flag)cout << "Borys" <<endl;
    else cout << "Alice" <<endl;
    
    return 0;
}


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


int A[]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
	int a,b,cnt=0;
	cin >> a >> b;
	for(int i=1;i<=a;i++){
		for(int j=1;j<=A[i];j++){
			if(i==j) cnt++;
			if(i==a&&j==b) break;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	sort(all(s));
	sort(all(t));
	reverse(all(t));
	if(s.compare(t)<0) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define testing 1
#define FOR(i,s,e) for(ll i = s; i <= (ll)e; ++i)
#define DEC(i,s,e) for(ll i = s; i >= (ll)e; --i)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << "\n"
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << "\n"
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"\n"
#define dbv(v) cerr << #v << ":"; for (auto ite : v) cerr << ite << ' '; cerr <<"\n"
#define dbvp(v) cerr << #v << ":"; for (auto ite : v) cerr << "{"  << ite.f << ',' << ite.s << "} "; cerr << "\n"
#define dba(a,ss,ee) cerr << #a << ":"; FOR(ite,ss,ee) cerr << a[ite] << ' '; cerr << "\n"
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <ll, ll> pi;
typedef tuple<ll,ll,ll> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
const int inf = (int)1e9 + 500;
const long long oo = (ll)1e18 + 500;
template <typename T> void chmax(T& a, T b) { a = max(a, b); }
template <typename T> void chmin(T& a, T b) { a = min(a, b); }
const int MAXN = -1;
#if !testing
#define cerr if(0)cout
#endif
 
int32_t main() 
{
	IAMSPEED
	int n; cin >> n;
	set<string>s;
	FOR(i,1,n) {
		string str; cin >> str;
		s.insert(str);
	}
	cout<<s.size();
}


Measured memory_bytes: 19132
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
const int maxn=1e5+10;
#define x first
#define y second
#define mp make_pair

int n;
pair<pii,int> pos[maxn];
LL ans;
int fa[maxn];
vector<pair<int,pii> > edg;

bool cmpx(pair<pii,int> a,pair<pii,int> b)
{
	return a.x.x<b.x.x;
}

bool cmpy(pair<pii,int> a,pair<pii,int> b)
{
	return a.x.y<b.x.y;
}

int father(int p)
{
	if (fa[p]==p) return p;
	else return fa[p]=father(fa[p]);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&pos[i].x.x,&pos[i].x.y);
		pos[i].y=i;
	}
	
	sort(pos+1,pos+n+1,cmpx);
	for(int i=1;i<n;i++)
		edg.push_back(mp(pos[i+1].x.x-pos[i].x.x,mp(pos[i+1].y,pos[i].y)));
	sort(pos+1,pos+n+1,cmpy);
	for(int i=1;i<n;i++)
		edg.push_back(mp(pos[i+1].x.y-pos[i].x.y,mp(pos[i+1].y,pos[i].y)));
	
	ans=0;
	sort(edg.begin(),edg.end());
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=0;i<edg.size();i++)
	{
		int tx=edg[i].y.x,ty=edg[i].y.y;
		if (father(tx)!=father(ty))
		{
			ans+=LL(edg[i].x);
			fa[father(tx)]=father(ty);
		}
	}
	
	printf("%I64d\n",ans);
	return 0;
}

Measured memory_bytes: 6132
import java.util.Scanner;
public class Main{
	int X;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		X=sc.nextInt();
		System.out.println(X*X*X);
	
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17160
MOD = 10**9 + 7
n, m = [int(item) for item in input().split()]
a = set() 
dp = [0] * (n+10)
dp[0] = 1
for i in range(m):
    a.add(int(input()))
for i in range(n):
    if i+1 in a and i+2 in a:
        print(0)
        exit()
    elif i+1 in a:
        dp[i+2] += dp[i]
    elif i+2 in a:
        dp[i+1] += dp[i]
    else:
        dp[i+1] += dp[i]
        dp[i+2] += dp[i]
    dp[i+1] %= MOD
    dp[i+2] %= MOD
print(dp[n] % MOD)

Measured memory_bytes: 12652
import java.util.*;
public class Main{
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count = sc.nextInt();
    int array[] = new int[count];
    for(int i=0;i<count;i++)array[i] = sc.nextInt();
    Arrays.sort(array);
    System.out.println(array[count-1] - array[0]);
    }
}

Measured memory_bytes: 21844
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val h = readLine()?.split(" ")?.map(String::toInt) ?: return
    var max = 0
    var count = 0
    0.until(n - 1).forEach { i ->
        if (h[i] >= h[i + 1]) {
            count++
        } else {
            max = Math.max(max, count)
            count = 0
        }
    }
    max = Math.max(max, count)
    println(max.toString())
}

Measured memory_bytes: 59348
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		int[] n = new int[5];
		for(int i = 0; i < 5; i++){
			n[i] = stdIn.nextInt();
		}
		
		for(int i = 0; i < 5; i++){
			int max = i;
			for(int j = i+1; j < 5; j++){
				if( n[max] < n[j] ){
					max = j;
				}
			}
			int temp = n[max];
			n[max] = n[i];
			n[i] = temp;
		}
		for(int i = 0; i < 4; i++){
			System.out.print(n[i] + " ");
		}
		System.out.println(n[4]);
	}
}

Measured memory_bytes: 12000
/**
 * @Author:      G_bg
 * @DateTime:    2019-07-20 20:22:09
 * @Description: 
 */
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9+7;
const int maxn=2e5+10;
int a[maxn],b[maxn];
vector<int> v;
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	for(int i = n;i >= 1;i--){
		int num = 0;
		for(int j = i+i;j <= n;j += i){
			if(b[j] == 1) num++;
		}
		if(num%2 != a[i]) {
			b[i] = 1,v.push_back(i);
		}
	}
	int x = v.size();
	cout << x << endl;
	for(int i = 0;i < x-1;i++)
		cout << v[i] << " ";
	if(x > 0) cout << v[x-1] << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 2936
import java.util.Scanner;

public class Main {

	static Scanner sc = new java.util.Scanner(System.in);

	public static void main(String[] args) {

		String str = sc.nextLine();
		String str2 = str.replace("apple", "P");
		str2 = str2.replace("peach", "apple");
		str2 = str2.replace("P", "peach");
		System.out.println(str2);

	}

}

Measured memory_bytes: 25956
h,w=map(int,input().split())
l = [input() for _ in range(h)]
k = [['#' for x in range(w) ] for _ in range(h)]
dx = [0,0,1,-1,1,1,-1,-1]
dy = [1,-1,0,0,1,-1,1,-1]
for i in range(h):
    for j in range(w):
        if l[i][j] == '.':
            cnt = 0
            for di in range(8):
                x = j+dx[di]
                y = i+dy[di]
                if x<0 or y<0 or x >=w or y >=h:
                    continue
                if l[y][x] == '#':
                    cnt +=1
            k[i][j] = cnt
for i in range(h):
    print(''.join(map(str, k[i])))

Measured memory_bytes: 9244
S = input()
len_S = len(S)
now = "R"
R_cnt = 0
L_cnt = 0
ans = [0] * len_S
R_idx_list = []
L_idx_list = []
for i in range(len_S - 1):
    if S[i] == "R" and S[i + 1] == "L":
        R_idx_list.append(i)
        L_idx_list.append(i + 1)


idx = 0
for i in range(len(S)):
    s = S[i]
    if i == len_S - 1:
        L_cnt += 1
    if now == "L" and s == "R" or i == len_S - 1:
        ans[R_idx_list[idx]] = R_cnt - R_cnt // 2 + L_cnt // 2
        ans[L_idx_list[idx]] = L_cnt - L_cnt // 2 + R_cnt // 2
        idx += 1
        R_cnt = 0
        L_cnt = 0
    if s == "R":
        now = "R"
        R_cnt += 1
    else:
        now = "L"
        L_cnt += 1
print(*ans)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

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

int main(){
  string s;
  int n=0;
  cin >> s;
  n=s.length();
  if(s[n-1]=='s'){
    cout << s << "es" << endl;
  return 0;
  }
    else{
    cout << s << "s" << endl;
  return 0;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> num(N);
  
  for(int i = 0; i < N; i++){
    cin >> num.at(i);
  }
  
  sort(num.begin(), num.end());
  reverse(num.begin(), num.end());
  
  int a = 0, b = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0)
      a += num.at(i);
    else
      b += num.at(i);
  }

  cout << a - b << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

  static int[] parent;
  static int[] size;
  static int N,M;
  static int[] A,B;
  static long count;
  static long[] ans;

  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    N = sc.nextInt();
    M = sc.nextInt();
    A = new int[M];
    B = new int[M];
    ans = new long[M + 1];
    for(int i=0;i<M;i++){
      A[i]=sc.nextInt();
      B[i]=sc.nextInt();
    }
    UnionFindTree(N);
    ans[M] = 0;
    count = 0;
    for(int i=M-1;i>=0;i--){
      if (!same(A[i], B[i])) {
        count+=(long)size[find(A[i])]*size[find(B[i])];
      }
      ans[i] = count;
      union(A[i],B[i]);
    }
    for(int j=1;j<=M;j++){
      System.out.println((long)N*(N-1)/2-ans[j]);
    }
  }

  static void UnionFindTree(int Size) {
    parent = new int[Size+1];
    size = new int[Size+1];

    for (int i = 1; i < Size+1; i++) {
      makeSet(i);
    }
  }

  public static void makeSet(int x) {
    parent[x] = x;
    size[x] = 1;
  }


  public static void union(int x, int y) {
    if(x==y){}
    else{
      final int xRoot = find(x);
      final int yRoot = find(y);


      if (xRoot != yRoot) {
        parent[yRoot] = xRoot;
        size[xRoot]+=size[yRoot];

      }
    }
  }


  public static int find(int x) {
    if (x != parent[x]) {
      parent[x] = find(parent[x]);
    }
    return parent[x];
  }


  public static boolean same(int x, int y) {
    return find(x) == find(y);
  }
}

Measured memory_bytes: 89508
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,x;
    cin>>n;
    map<int,int> map;
    for(i=1;i<=n;i++){
        cin>>x;
        map[x]=i;
    }
    for(i=1;i<=n;i++){
        if(i!=1)cout<<" ";
        cout<<map[i];
    }
    cout<<endl;
}

Measured memory_bytes: 5504
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 1100000000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,ll> P;

struct edge{
  int to;
  ll cost;
};

int V;
ll S[110000],T[110000];
vector<P> SV[110000],TV[110000];
int d[110000];

void dijkstra(int s,vector<P> G[],ll d[]){
  // greater<P>を指定することでfirstが小さい順に取り出せる
  priority_queue<P,vector<P>,greater<P>> que;
  fill(d,d+100001,INF);
  d[s]=0;
  que.push(P(0,s));

  while(!que.empty()){
    P p=que.top(); que.pop();
    ll v=p.second;
    if(d[v]<p.first) continue;
    for(int i=0;i<(int)G[v].size();i++){
      P e=G[v][i];
      if(d[e.first]>d[v]+e.second){
        d[e.first]=d[v]+e.second;
        que.push(P(d[e.first],e.first));
      }
    }
  }
}

int main(){
  ll a,b,ans[110000];
  int n,m,s,t,u,v;
  cin>>n>>m>>s>>t;
  ans[n+1]=INF;
  for(int i=0;i<m;i++){
    cin>>u>>v>>a>>b;
    SV[u].push_back(P(v,a));
    SV[v].push_back(P(u,a));

    TV[u].push_back(P(v,b));
    TV[v].push_back(P(u,b));
  }

  dijkstra(s,SV,S);
  dijkstra(t,TV,T);

  for(int i=n;i>0;i--){
    ans[i]=min(ans[i+1],S[i]+T[i]);
    //cout<<S[i]<<" "<<T[i]<<endl;
  }
  for(int i=1;i<=n;i++){
    cout<<1000000000000000-ans[i]<<endl;
  }
}


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

def divisors(n):
  divisors = set()
  for i in range(1, int(n**0.5)+1):
    if n%i == 0:
      divisors.add(i)
      divisors.add(n//i)
  return divisors

ans = 1
for i in sorted(divisors(M)):
  if i >= N:
    ans = M//i
    break
print(ans)

Measured memory_bytes: 3060
package main
import "fmt"
func main() {
  var s string
  fmt.Scan(&s)
  n := len(s)
  if s[n-1:n] == "1" || s[0:1] == "0" { fmt.Println(-1);return }
  for i:=0;i<n-i-2;i++ {
    if s[i:i+1] != s[n-i-2:n-i-1] { fmt.Println(-1);return }
  }
  p := n
  for i:=n-1;i>0;i-- {
    fmt.Println(i,p)
    if s[i-1:i] == "1" { p = i }
  }
}

Measured memory_bytes: 4096
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib;

immutable int INF = 1 << 29;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    auto G = new int[][](N);
    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }

    int[int] comp;
    auto B = A.dup.sort().uniq.array;
    foreach (i, b; B) comp[b.to!int] = i.to!int;
    foreach (ref a; A) a = comp[a];

    auto ans = new int[](N);
    auto dp = new int[](N);
    dp[] = INF;

    void dfs(int n, int p) {
        auto lb = dp.assumeSorted.lowerBound(A[n]).length.to!int;
        int prev;
        if (lb < N) {
            prev = dp[lb];
            dp[lb] = A[n];
        }
        ans[n] = dp.assumeSorted.lowerBound(INF).length.to!int;
        foreach (m; G[n]) if (m != p) {
            dfs(m, n);
        }
        if (lb < N) {
            dp[lb] = prev;
        }
    }

    dfs(0, -1);
    ans.each!writeln;
}


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

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int h, w; cin >> h >> w;
    int n; cin >> n;
    vii grid(h,vi(w));
    queue<int> que;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        rep(j, a) que.push(i);
    }
    for(int i = 0; i < h; i++) {
        if(i%2==0) {
            for(int j = 0; j < w; j++) {
                int num = que.front(); que.pop();
                grid[i][j] = num;
            }
        }
        else {
            for(int j = w-1; j >= 0; j--) {
                int num = que.front(); que.pop();
                grid[i][j] = num;
            }
        }
    }

    //出力
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << grid[i][j]+1 << (j==w-1 ? '\n' : ' ');
        }
    }

}


Measured memory_bytes: 384
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			string s;
			cin >> s;
			
			if(s == "snuke"){
				char a1 = 'A' + j;
				printf("%c", a1);
				cout << i + 1 << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

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



int main(void)
{
	int a, b;

	cin >> a >> b;

	int ans = -9999999;

	ans = max(ans, a + b);
	ans = max(ans, a - b);
	ans = max(ans, a * b);

	cout << ans << endl;


	
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

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

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n),b(n),c(n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	for(int i=0;i<n;i++)
	{
		cin >> b[i];
	}
	for(int i=0;i<n-1;i++)
	{
		cin >> c[i];
	}
	for(int i=0;i<n;i++)
	{
		sum+=b[a[i]-1];
		if(a[i]+1==a[i+1])
		{
			sum+=c[a[i]-1];
		}
	}
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/

__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
	vector<P> A(n);
	for(int i = 0; n > i; i++){
		cin>>A[i].first>>A[i].second;
	}
	sort(A.begin(),A.end());
	int z = 0;
	double s = 0;
	do{
		z++;
		for(int i = 1; n > i; i++){
			s += sqrt((A[i].first-A[i-1].first)*(A[i].first-A[i-1].first)+(A[i].second-A[i-1].second)*(A[i].second-A[i-1].second));
		}
	}while(next_permutation(A.begin(),A.end()));
	cout << fixed << setprecision(10) << (double)s/z << endl;
}

Measured memory_bytes: 256
import java.awt.geom.Line2D;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	class P {
		double x, y;

		P(double x_, double y_) {
			x = x_;
			y = y_;
		}

		P add(P p) {
			return new P(x + p.x, y + p.y);
		}

		P sub(P p) {
			return new P(x - p.x, y - p.y);
		}

		P mul(double v) {
			return new P(x * v, y * v);
		}

		P div(double v) {
			return new P(x / v, y / v);
		}

		double dot(P p) {
			return x * p.x + y * p.y;
		}

		double det(P p) {
			return x * p.y - y * p.x;
		}

		double abs2() {
			return x * x + y * y;
		}

		double abs() {
			return Math.sqrt(abs2());
		}

		P norm() {
			return div(abs());
		}

		P rot90() {
			return new P(-y, x);
		}

		P proj(P src, P dst) {
			P p_sd = dst.sub(src).norm();
			return src.add(p_sd.mul(sub(src).dot(p_sd)));
		}

		P reflect(P src, P dst) {
			P middle = proj(src, dst);
			return add(middle.sub(this).mul(2));
		}

		public String toString() {
			return String.format("%f %f", x, y);
		}
	}

	P isLL(P p1, P p2, P q1, P q2) {
		double d = p2.sub(p1).det(q1.sub(q2));
		if (Math.abs(d) < 1e-10)
			return null;
		return p1.add(p2.sub(p1).mul(q1.sub(q2).det(p1.sub(q2)) / d));
	}

	boolean intersect(P p1, P p2, P q1, P q2) {
		return Line2D.linesIntersect(p1.x, p1.y, p2.x, p2.y, q1.x, q1.y, q2.x, q2.y);
	}

	double distSS(P p1, P p2, P q1, P q2) {
		if (intersect(p1, p2, q1, q2))
			return 0;
		double dist = Double.MAX_VALUE;
		for (double d : new double[] { distSP(p1, p2, q1), distSP(p1, p2, q2), distSP(q1, q2, p1),
				distSP(q1, q2, p2) }) {
			dist = Math.min(d, dist);
		}
		return dist;
	}

	double distSP(P p1, P p2, P p) {
		return Line2D.ptSegDist(p1.x, p1.y, p2.x, p2.y, p.x, p.y);
	}

	void run() {

		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		while (q-- > 0) {
			P p1 = new P(sc.nextDouble(), sc.nextDouble());
			P p2 = new P(sc.nextDouble(), sc.nextDouble());
			P q1 = new P(sc.nextDouble(), sc.nextDouble());
			P q2 = new P(sc.nextDouble(), sc.nextDouble());
			System.out.println(distSS(p1, p2, q1, q2));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 56936
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat
const int N = 2e5 + 5;
ll a[N];

bool possible(ll val, ll& n, ll& k){
    ll ans = 0;
    rep(i, n){
        if(a[i] > val){
        	ans += (ceil(1.0*a[i]/val) - 1);
        }
    }
    if(ans <= k){
    	return true;
    }
    return false;
}

int main(int argc, char const *argv[])
{
	sync;
	ll n, k;
	cin >> n >> k;
	rep(i,n){
		cin >> a[i];
	}
	ll lf = 1, rght = 1000000001, mid, ans = 1000000000;
	while(lf <= rght){
        mid = (lf + rght)/2;
        if(possible(mid, n, k))
        {
            ans = min(ans, mid);
            rght = mid - 1;
        }
        else 
        {
            lf = mid + 1;
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5100
#include "bits/stdc++.h"

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MII = map<int, int>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

const long kMaxN = 1e5 + 5;

template <class T>
void PrintVector(const vector<T> & v) {
  for (const auto & e: v) {
    cout << e << endl;
  }
}

template <class T>
void PrintVector(const vector<T> & v, unsigned n) {
  rep(i, 0, n - 1) {
    cout << v[i] << endl;
  }
}

int main(int argc, char const *argv[]) {
  L n;
  L ans = 0;
  MII map_count;
  cin >> n;
  rep(i, 0, n - 1) {
    L a;
    cin >> a;
    ++map_count[a];
  }
  for (const auto & e: map_count) {
    auto x = e.first;
    auto y = e.second;
    if (y >= x) { ans += y - x; }
    else { ans += y; }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

int main()
{
	FAST;


	int n, m;
	int arr[1001];
	cin >> n >> m;

	int ans = 0;
	for (int i = 0 ; i < n ; i++)
		cin >> arr[i];

	int sum = accumulate(arr , arr + n , 0);
	
	for (int i = 0 ; i < n ; i++)
		ans += 4 * m * arr[i] >= sum;


	if (ans >= m)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    
    return 0;
}



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

void insertionSort(int a[], int n){
	for(int i = 1; i < n; i++){
		int tmp = a[i], j = i-1;
		while(j >= 0 && a[j] > tmp){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = tmp;
		cout << a[0];
		for(int j = 1; j < n; j++)
			cout << ' ' << a[j];
		cout << endl;
	}
}

int main(){
	int n, a[100];
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	cout << a[0];
	for(int j = 1; j < n; j++)
		cout << ' ' << a[j];
	cout << endl;
	insertionSort(a, n);
	return 0;
}


Measured memory_bytes: 3108
from collections import defaultdict


def nCr(n, r):
    if n - r < r:
        return nCr(n, n - r)
    if r == 0:
        return 1
    if r < 0:
        return 0

    primes = [True] * (n + 1)
    primes[0] = primes[1] = False
    for i in range(2, int(n ** 0.5) + 2):
        if primes[i]:
            for j in range(i * 2, n + 1, i):
                primes[j] = False
    primes = [i for i, b in enumerate(primes) if b]

    factors1 = defaultdict(lambda: 0)
    for p in primes:
        num = n
        q = p
        while q <= num:
            factors1[p] += num // q
            q *= p

    factors2 = defaultdict(lambda: 0)
    for p in primes:
        num = r
        q = p
        while q <= num:
            factors2[p] += num // q
            q *= p

    factors3 = defaultdict(lambda: 0)
    for p in primes:
        num = n - r
        q = p
        while q <= num:
            factors2[p] += num // q
            q *= p

    value = 1
    for p in factors1:
        value *= p ** (factors1[p] - (factors2[p] + factors3[p]))

    return value


X, Y = map(int, input().split())
if (2 * Y - X) % 3 != 0 or (2 * X - Y) % 3 != 0:
    print(0)
else:
    a = (2 * X - Y) // 3
    b = (2 * Y - X) // 3
    n = a + b
    print(nCr(n, a) % (10 ** 9 + 7))

Measured memory_bytes: 69980
import java.util.Scanner;

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

        String str = stdIn.nextLine();
        String[] strArray = str.split("");
        if (strArray[0].equals(strArray[1]))
            System.out.println("Bad");
        else if (strArray[1].equals(strArray[2]))
            System.out.println("Bad");
        else if (strArray[2].equals(strArray[3]))
            System.out.println("Bad");
        else
            System.out.println("Good");
    }
}


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define per(i,a,b) for(int i = a; i >= b; i--)
#define inf 9223372036854775807
#define all(x) x.begin(),x.end()
#define sz(x) (ll)(x).size()
#define trav(a,x) for(auto& a : x)

int main(){
  ll a,b,c; cin >> a >> b >> c;
  cout << min(c,a+b+1)+b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

int n;
vector<pair<ll, ll>> a;

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

    cin >> n;
    a.resize(n);
    rep(i, n) {
        int x;
        cin >> x;
        a[i] = {x, i};
    }
    sort(ALL(a));
    V<V<ll>> dp(n + 1, V<ll>(n + 1, -inf));
    rep(i, n + 1) dp[i][i] = 0;
    FOR(bit, 1, n + 1) {
        auto p = a[bit - 1];
        rep(l, n + 1 - bit) {
            ll r = l + bit;
            // cout << l << " " << r << endl;
            chmax(dp[l][r], dp[l][r - 1] + abs(p.second - (r - 1)) * p.first);
            chmax(dp[l][r], dp[l + 1][r] + abs(p.second - l) * p.first);
        }
    }
    cout << dp[0][n] << endl;

    return 0;
}

Measured memory_bytes: 34616
import itertools
n=int(input())
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
lst=[i for i in itertools.permutations(range(1,n+1))]
cnt=0
for i in lst:
  if a==i:
    a=cnt
  if b==i:
    b=cnt
  cnt+=1
print(abs(a-b))

Measured memory_bytes: 79940