akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int a[200100],b[200100];
int main()
{
  
  int n;
  cin>>n;
  ll ans1=0,ans2=0;
  rep(i,n)
  {
  	cin>>a[i]>>b[i];
  }
  sort(a,a+n);
  sort(b,b+n);
  if(n%2==1)
  {
  	ans1=a[n/2];
  	ans2=b[n/2];
  }
  else
  {
  	ans1=a[n/2-1]+a[n/2];
  	ans2=b[n/2-1]+b[n/2];
  }
  cout<<(ans2-ans1+1)<<endl;
  return 0;
}


Measured memory_bytes: 5156
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
  for j in range(n):
    if i == j: continue
    ans += ((xy[i][0] - xy[j][0])**2 + (xy[i][1] - xy[j][1])**2)**0.5
print(ans/n)

Measured memory_bytes: 9392
#include <stdio.h>
#include <stdlib.h>

int cmp(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int n, k;
	scanf("%d %d", &n, &k);
	int *p = malloc(sizeof(int) * n);
	for(int i = 0; i < n; i++)
		scanf("%d", p + i);
	qsort(p, n, sizeof(int), cmp);
	int sum = 0;
	for(int i = 0; i < k; i++)
		sum += p[i];
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 2128
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

int n,a,b,cnt=0;
vi g[M];
int flag[M];
int dist1[M]={},distn[M]={};
void __dist1(int node){
	flag[node]=true;
	for(auto x:g[node])
		if(!flag[x]){
			dist1[x]=(dist1[node]+1);
			__dist1(x);
		}
}
void __distn(int node){
	flag[node]=true;
	for(auto x:g[node])
		if(!flag[x]){
			distn[x]=(distn[node]+1);
			__distn(x);
		}
}

int main(){
	cin>>n;
	rep(i,0,n-1){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rep(i,0,n+1)flag[i]=false;
	__dist1(1);
	rep(i,0,n+1)flag[i]=false;
	__distn(n);
	int X=0,Y=0;
	rep(i,1,n+1){
		if(dist1[i]<=distn[i])X++;
		else Y++;
	}

	if(X>Y)print("Fennec");
	else print("Snuke");


}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

bool solve() {
    string S;
    cin >> S;
    int n = S.size();
    if ( S[0] != S[n-1] ) {
        return n % 2 == 1;
    } else {
        return n % 2 == 0;
    }
}

int main() {
    string ans = solve() ? "First" : "Second";
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		int[] cost = new int[210];
		for (int j = -100; j <= 100; j++) {
			for (int i = 0; i < n; i++) {
				cost[j+100] += Math.pow(a[i]-j, 2);
			}
		}
		final int INF = Integer.MAX_VALUE / 10;
		int min = INF;
		for (int i = 0; i < 201; i++) {
					if (cost[i] < min) {
						min = cost[i];
					}
				}
		System.out.println(min);
	}
}


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

using namespace std;
using ll = long long;
using pl = pair<ll,ll>;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


template <class Abel> struct BIT {
  vector<Abel> dat;
  Abel UNITY_SUM = 0;                        // to be set
  
  /* [1, n] */
  BIT(int n) : dat(n + 1, UNITY_SUM) { }
  void init(int n) { dat.sssign(n + 1, UNITY_SUM); }
  
  /* a is 1-indexed */
  inline void add(int a, Abel x) {
    for (int i = a; i < (int)dat.size(); i += i & -i)
      dat[i] = dat[i] + x;
  }
  
  /* [1, a], a is 1-indexed */
  inline Abel sum(int a) {
    Abel res = UNITY_SUM;
    for (int i = a; i > 0; i -= i & -i)
      res = res + dat[i];
    return res;
  }

  /* [a, b), a and b are 1-indexed */
  inline Abel sum(int a, int b) {
    return sum(b - 1) - sum(a - 1);
  }
  
  /* debug */
  void print() {
    for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
    cout << endl;
  }
};

bool cmp(pair<pl, ll> x, pair<pl, ll> y) {
  return make_pair(x.first.second, x.second) < make_pair(y.first.second, y.second);
}

void solve(long long N, long long M, long long Q, std::vector<long long> L, std::vector<long long> R, std::vector<long long> p, std::vector<long long> q){
  vector<pair<pl, ll>> v;
  for(ll i=0; i<M; i++)
    v.push_back(make_pair(make_pair(L[i], R[i]+1), -1));
  for(ll i=0; i<Q; i++)
    v.push_back(make_pair(make_pair(p[i], q[i]+1), i));
  sort(v.begin(), v.end(), cmp);
  BIT<ll> b(N);
  vector<ll> ans(Q);
  for(auto &x: v) {
    if(x.second==-1)
      b.add(x.first.first, 1);
    else
      ans[x.second] = b.sum(x.first.first, x.first.second);
  }
  for(auto a: ans)
    std::cout << a << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> L(M);
  std::vector<long long> R(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&L[i]);
    scanf("%lld",&R[i]);
  }
  std::vector<long long> p(Q);
  std::vector<long long> q(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&p[i]);
    scanf("%lld",&q[i]);
  }
  solve(N, M, Q, std::move(L), std::move(R), std::move(p), std::move(q));
  return 0;
}


Measured memory_bytes: 18796
a=`sed 1d`.split.map(&:to_i).sort
31.downto(1){|s|i=0;j=a.size-1
!a[i]?i+=1:!a[j]?j-=1:(k=a[i]+a[j]-2**s)<0?i+=1:k>0?j-=1:(a[i]=a[j]=!$.+=1;i+=1;j-=1)while i<j}
p$.

Measured memory_bytes: 21032
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC158C();

#if 1
int main()
{
	ABC158C();
	fflush(stdout);
	return 0;
}
#endif

static void ABC158C()
{
	int A, B;
	getint(A, B);

	int ans = -1;
	for (int i = 0; i <= 1250; i++) {
		if (((int)(i * 0.08) == A) && ((int)(i * 0.1) == B)) {
			ans = i;
			break;
		}
	}
	printf("%d\n", ans);
}


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

using namespace std;
using ll = long long;

int main() {
    int H, W;
    cin >> H >> W;
    vector<int> x{1, 0, -1, 0};
    vector<int> y{0, 1, 0, -1};
    vector<vector<char> > m(H,vector<char>(W));
    for(int i = 0; i < H; i++) {
        string S;
        cin >> S;
        for(int j = 0; j < W; j++) {
            m.at(i).at(j) = S.at(j);
        }
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(m.at(i).at(j) == '.') {
                continue;
            }
            int check = 0;
            for(int k = 0; k < 4; k++) {
                int nx = j + x.at(k);
                int ny = i + y.at(k);
                if(nx > -1 && ny > -1 && nx < W && ny < H) {
                    if(m.at(ny).at(nx) == '#') {
                        check = 1;
                    }
                }
            }
            if(check) {
                continue;
            } else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;



    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>

using namespace std;

int main() {
	

	char a, b;
	
	cin >> a >> b;

	if (a == 'H' && b == 'H') {
		cout << "H" << endl;
	}
	else if (a == 'H' && b == 'D') {
		cout << "D" << endl;
	}else if(a == 'D' && b == 'H')cout << "D" << endl;
	else cout << "H" << endl;

	return 0;
}





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

using namespace std;

bool is_palindrone(int i) {
  string a = to_string(i);
  for (int i = 0; i < a.size() / 2; ++i) {
    if (a[i] != a[a.size() - i - 1]) return false;
  }
  return true;
}

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

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

  int cnt = 0;
  for (int i = a; i <= b; ++i) {
    if (is_palindrone(i)) ++cnt;
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;

string table[]={"qwertasdfgzxcvb","yuiophjklnm"};


int main(){
	
	while(true){
		string str;
		cin >> str;

		if(str=="#") break;
		
		int count=0;
		
		int flag = -1;
		bool s_flag = false;
		//右手==0,左手==1
		for(int i=0;i<str.length();i++){
			for(int k=0;k<table[0].length();k++){
				if(str[i]==table[0][k] && (flag==0 || flag==-1)){
					if(i==0){
						flag=1;
						break;
					}
					s_flag=true;
					count++;
					flag=1;
					break;
				}
				if(str[i]==table[1][k] && (flag==1 || flag==-1)){
					if(i==0){ 
						flag=0;
						break;
					}
					count++;
					flag=0;
					break;	
				}
			}
		}
	
		cout << count << endl;
	}

}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <assert.h>
#include <stdio.h>

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

static int maxElement(int* array, size_t size)
{
    assert(array != NULL);
    assert(size >= 1);

    int max = array[0];
  

   int i;
  
   int temp;
  
    for (i = 1; i < size; ++i) {
     
        if (max < array[i]) {
          
            max = array[i];
            temp = i;
              
        }
       
    }

    
    
    return temp;
}


static int maxd(vector<int> c, size_t size){
  
  int max = c[0];
     int i = 0;
  
   int temp = 0;
  
    for (i = 0; i < size; ++i) {
      
       if (max < c[i]) {
          
            max = c[i];
            temp = i;
              
        }
    }
  
  return temp;
}

int main() {
  
  int a; int l, n=0, b[101];
  vector<int> c;
   cin >> a;
  
    while(cin>>l){
      
        b[n] = l;
        c.push_back(l);
      
        n++;
    }
  
 
   int i;
   int flag = 0;
   int alice = 0;
  
   int bob = 0;
  
   for (i=0;i < a;i++){
      
     if (flag%2==0){
       
     //  cout << "gu" << endl;
       
       
        int d = maxd(c,a);
       
     //   cout << c[0] << endl;
      //  cout << c[1] << endl;
      //  cout << c[2] << endl;
      // cout << d << endl;
       //cout << c[d] << endl;
       
        alice = alice + c[d];
  
    
         c[d]=0;
       
       
      // b[maxElement(b,a)] = 0; 
      
     }else{
       
       // cout << "ki" << endl;
       
       int d = maxd(c,a);
       
        //cout << c[0] << endl;
      //  cout << c[1] << endl;
      //  cout << c[2] << endl;
      // cout << d << endl;
      // cout << c[d] << endl;
       bob = bob + c[d];
   
     
         
         
          c[d]=0;
      
      
     //  b.erase(b.begin()+d);
     //  b[maxElement(b,a)] = 0;
      
         
     }
      
     
     
      flag++;
     
   }
  
   cout << alice - bob << endl;
  
  
  return 0;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int mod=924844033;
struct Combin{
	#define N 400005
	int fac[N],rv[N],facrv[N];
	Combin(){
		fac[0]=rv[1]=facrv[0]=1;
		for(int i=2;i<N;i++) rv[i]=((-(LL)(mod/i)*rv[mod%i]%mod)+mod)%mod;
		for(int i=1;i<N;i++) fac[i]=(LL)fac[i-1]*i%mod;
		for(int i=1;i<N;i++) facrv[i]=(LL)facrv[i-1]*rv[i]%mod;
	}
	int C(int r1,int n1){
		if(r1>n1) return 0;
		return fac[n1]*(LL)facrv[r1]%mod*facrv[n1-r1]%mod;
	}
	#undef N
}C;

namespace NTT{
	#define N ((1<<19)+3)
	const int base=5;
	int wn[N+N];
	int rv[N];
	int len;
	int fastpow(int w,int x){
		int ret=1;
		while(x){
			if(x&1) ret=ret*1LL*w%mod;
			w=w*1LL*w%mod;x>>=1;
		}
		return ret;
	}
	void NTT(int *x,int len,int f){
		for(int i=0;i<len;i++) if(i<rv[i]) swap(x[i],x[rv[i]]);
		for(int i=2,d=(len>>1)*f;i<=len;i<<=1,d/=2){
			for(int j=0;j<len;j+=i){
				int *x1=x+j,*x2=x+j+(i>>1),*w=wn+N;long long t1;
				for(int p=0,t=i>>1;p<t;p++,w+=d){
					x2[p]=(x1[p]-(t1=(1LL*x2[p]*(*w))))%mod;
					x1[p]=(x1[p]+t1)%mod;
				}
			}
		}
	}
	
	void pre(int tot){//最终项数（最大次数+1） 
		len=1;while((1<<len)<tot) len++;
		for(int i=1;i<(1<<len);i++) rv[i]=(rv[i>>1]>>1)|((i&1)<<(len-1));
		wn[N]=1;int w=fastpow(base,(mod-1)>>len);len=1<<len;int rv=fastpow(w,mod-2);
		for(int i=1;i<len;i++) wn[N+i]=(1LL*wn[N+i-1]*w)%mod;
		for(int i=N-1;i>=N-len;i--) wn[i]=(1LL*wn[i+1]*rv)%mod;
	}
	void solve(int *a,int *b){
		NTT(a,len,1);NTT(b,len,1);
		for(int i=0;i<len;i++) a[i]=(1LL*a[i]*b[i])%mod;
		NTT(a,len,-1);
		int rl=fastpow(len,mod-2);
		for(int i=0;i<len;i++) a[i]=((a[i]*1LL*rl)%mod+mod)%mod;
	}
}

#define M 200005
struct edge{
	int t,next;
}e[M*2];int ecnt,head[M];
void addedge(int f,int t){
	e[++ecnt]=(edge){t,head[f]};head[f]=ecnt;
	e[++ecnt]=(edge){f,head[t]};head[t]=ecnt;
}
int ai[N],bi[N],ci[M];
int DFS(int u,int fr){
	int sz=1;
	for(int i=head[u];i;i=e[i].next){
		if(e[i].t!=fr)
			sz+=DFS(e[i].t,u);
	}
	if(u!=1) ci[sz]++;
	return sz;
} 
int n;

int ans[M];
int main(){
	scanf("%d",&n);
	for(int i=1,f,t;i<n;i++){
		scanf("%d%d",&f,&t);
		addedge(f,t);
	}
	DFS(1,0);
	for(int i=0;i<=n;i++){
		ans[i]=n*1LL*C.C(i,n)%mod;
		ai[i]=ci[i]*1LL*C.fac[i]%mod;
		bi[n+1-i]=C.facrv[i];
	}
	NTT::pre(n+n+1);
	NTT::solve(ai,bi);
	for(int i=1;i<=n;i++)
		ans[i]=(ans[i]-ai[n+i+1]*1LL*C.facrv[i])%mod; 
	memset(ai,0,sizeof(ai));
	memset(bi,0,sizeof(bi));
	for(int i=0;i<=n;i++){
		ai[i]=ci[i]*1LL*C.fac[n-i]%mod;
		bi[i]=C.facrv[i];
	} 
	NTT::solve(ai,bi);
	for(int i=1;i<=n;i++)
		ans[i]=(ans[i]-ai[n-i]*1LL*C.facrv[i])%mod;
	for(int i=1;i<=n;i++)
		printf("%d\n",(ans[i]+mod)%mod);
} 

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

using namespace std;
#define ll long long

const int sz = 200001;
int n, h[sz], a[sz];
ll dp[sz];

void update(int x, ll y) {
    while (x < sz){
        dp[x] = max(dp[x], y);
        x += x & -x;
    }
}

ll get(int x) {
    ll rt = -1;
    while(x>0){
        rt = max(rt, dp[x]);
        x -= (x & -x);
    }
    return rt;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    int i, j;
    for (i = 0; i < n; ++i) cin >> h[i];
    for (i = 0; i < n; ++i) cin >> a[i];
    for (i = 0; i < n; ++i) update(h[i], get(h[i]) + a[i]);
    cout << get(n) << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <string>
#include <vector>

using namespace std;

int main(){

  int n,m,r,q,w=0;
  vector<int> a;
  vector<int> c;

    cin>>n>>m;
    
    for(int i=0; i<n; ++i){
      cin>>q;
      a.push_back(q);
      c.push_back(0);
    }

    for(int i=0; i<m; ++i){
      cin>>q;
      for(int k=0; k<n; ++k)
	if(a[k]<=q){
	  ++c[k];
	  break;
	}
    }
    q=0;
    for(int i=0; i<n; ++i){
      if(q < c[i]) q=c[i],w=i+1;
    }
    cout << w <<endl;

    //    cout<<endl;
    //   for(int i=0; i<n; ++i){
    //     cout<<a[i]<<"  "<<c[i]<<endl;
    //      }
  
  
  return 0;
}



Measured memory_bytes: 3152
I = input()
N = len(I)
ans = ""
for n in range(1 << (N-1)):
  A = I[0]
  for i in range(N-1):
    if n & (1 << i):
      A += "+" + I[i+1]
    else:
      A += "-" + I[i+1]
  if eval(A) == 7:
    ans = A + "=7"

print(ans)

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

int main(void) {
    string s;
    int ans = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    for (int i = s.length() - 2; i >= 0; i -= 2) {
        if (s.substr(0, i / 2) == s.substr(i / 2, i / 2)) {
            ans = i;
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}

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

bool isVisited[101];

int dfs(const vector<vector<int>>& r, int pos) {
    if (isVisited[pos]) {
        return 0;
    }

    isVisited[pos] = true;
    int ret = 0;
    for (int i = 0; i < r[pos].size(); i++) {
        ret = max(ret, dfs(r, r[pos][i]));
    }
    isVisited[pos] = false;

    return ret+1;
}

int main(void) {
    for (int i = 0; i <= 100; i++) {
        isVisited[i] = false;
    }

    int n;
    while (cin >> n, n) {
        vector<vector<int>> rings(101);
        int a, b;
        for (int i = 0; i < n; i++) {
            cin >> a >> b;
            rings[a].push_back(b);
            rings[b].push_back(a);
        }

        int ans = 0;
        for (int i = 1; i <= 100; i++) {
            ans = max(ans, dfs(rings, i));
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3052
#!python3

# input
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]


def main():
    link = [[] for _ in range(N)]
    for a, b in AB:
        link[a - 1].append(b - 1)
        link[b - 1].append(a - 1)

    ans = N
    for i in range(N):
        for x in link[i]:
            if H[i] <= H[x]:
                ans -= 1
                break
    
    print(ans)


if __name__ == "__main__":
    main()


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

template <typename T>
class segment_tree
{
private:
    int n;
    vector<T> tree;

public:
    segment_tree(int size)
    {
        int temp = 1;
        while (temp < size)
            temp = temp * 2;

        n = temp * 2;
        tree.resize(n, 0); // empty seg. tree
    }

    T query(int l, int r, int ql, int qr, int pos)
    {
        if (ql > r || qr < l)
        {
            return 0;
        }
        else if (ql <= l && qr >= r)
        {
            return tree[pos];
        }
        int mid = (l + r) / 2;
        return max(query(l, mid, ql, qr, 2 * pos + 1), query(mid + 1, r, ql, qr, 2 * pos + 2));
    }
    void update(int l, int r, int pos, long long val, int range)
    {
        if (l == r)
        {
            tree[pos] = val;
            return;
        }
        int mid = (l + r) / 2;
        if (mid >= range)
            update(l, mid, 2 * pos + 1, val, range);
        else
            update(mid + 1, r, 2 * pos + 2, val, range);

        tree[pos] = max(tree[pos * 2 + 1], tree[pos * 2 + 2]);
    }
};

int main()
{
    int n;
    cin >> n;
    vector<int> height(n);
    vector<long long> beauties(n);
    for (auto &x : height)
        cin >> x;
    for (auto &y : beauties)
        cin >> y;
    vector<long long> dp(n + 1);
    segment_tree<long long> seg(n);
    for (int flower = 0; flower < n; ++flower)
    {
        dp[height[flower]] = seg.query(0, n - 1, 0, height[flower] - 2, 0) + beauties[flower];
        seg.update(0, n - 1, 0, dp[height[flower]], height[flower] - 1);
    }
    long long ans = 0;
    for (auto &x : dp)
        ans = max(ans, x);

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

Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string divide[4] = { "dream", "dreamer", "erase", "eraser" };
int main(void){
	string s;

	cin >> s;
	//後ろから解くかわりにすべての文字列を「左右反転」する
	reverse(s.begin(), s.end());
	for (int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());

	bool can = true;
	for (int i = 0; i < s.size();){
		bool can2 = false;//4 個の文字列たちどれかで divide できるか
		for (int j = 0; j < 4; j++){
			string d = divide[j];
			if (s.substr(i, d.size()) == d){
				can2 = true;
				i += d.size();	// divide できたら i を進める
			}
		}
		if (!can2){	// divide できなかったら
			can = false;
			break;
		}
	}
	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    vector<int>a(n),b(n);
    for(auto && e : a) cin >> e;
    for(auto && e : b) cin >> e;
    int  asum = accumulate(all(a),0LL,[](int a,int b){return a+b;});
    int  bsum = accumulate(all(b),0LL,[](int a,int b){return a+b;});
    if(bsum > asum)return puts("-1")*0;
    rep(i,n){
        if(a[i] >= b[i]){
            if(i == n-1)return puts("0")*0;
        } else
            break;
    }
    vector<int>pdif,mdif;
    rep(i,n){
        int dif = a[i] - b[i];
        if(dif > 0)pdif.push_back(dif);
        if(dif < 0)mdif.push_back(abs(dif));
    }
    sort(all(pdif),greater<int>());
    int msum = accumulate(all(mdif),0LL,[](int a,int b){return a+b;});
    int ans = (int)mdif.size();
    for(auto p : pdif){
        ans++;
        msum -= p;
        if(msum <= 0){ return cout << ans << endl,0;}
    }
    
}




Measured memory_bytes: 2812
#include<stdio.h>
#include<iostream>
using namespace std;
main(){
	long long n,a,b;scanf("%lld%lld%lld",&n,&a,&b);
	if((b-a)&1)printf("%lld\n",min((unsigned long long)((n<<1)-a-b+1),(unsigned long long)(a+b-1))>>1);
	else printf("%lld\n",b-a>>1);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (){
	int n;
	scanf ("%d", &n);
	char str[n + 1]; 
	scanf ("%s", str);
	
	if (n % 2 == 1){
		puts ("No");
	}	
		
	else {
		int half = 1;
		for (int i = 0; i < n / 2; i++){
			if (str[i] != str[i + n / 2]){
				half = 0;
			}
		}
		if (half){
			puts ("Yes");
		}
		else {
			puts ("No");
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<map>
#include<stack>
using namespace std;
typedef long long LL;
LL R,C;
 
LL dist(LL x,LL y){
    if(x!=0&&x!=R&&y!=0&&y!=C) return -1;
    if(y==0) return x;
    if(x==R) return R+y;
    if(y==C) return 2*R+C-x;
    if(x==0) return 2*(R+C)-y;
    return -1;
}
 
int main(){
    map<LL,int> mp;
    stack<int> s;
    int N;
    cin >> R >> C >> N;
    for(int i=0;i<N;i++){
        LL x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(dist(x1,y1)!=-1&&dist(x2,y2)!=-1){
            mp[dist(x1,y1)]=i;
            mp[dist(x2,y2)]=i;
        }
    }
    s.push(-1);
    for(auto p : mp){
        if(p.second!=s.top()) s.push(p.second);
        else s.pop();
    }
    if(s.size()==1) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 13184
// Problem : D - .. (Double Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

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

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    int n, m;
    cin >> n >> m;
    vvi adj(n + 1);
    vi par(n + 1);
    vi vis(n + 1, false);
    while (m--) {
      int a, b;
      cin >> a >> b;
      adj[a].pb(b);
      adj[b].pb(a);
    }
    queue<int> q;
    q.push(1);
    vis[1] = true;
    cout << "Yes\n";
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      for (auto it : adj[t]) {
        if (!vis[it]) {
          par[it] = t;
          vis[it] = true;
          q.push(it);
        }
      }
    }
    rep(i, 2, n) { cout << par[i] << '\n'; }
  }

  return 0;
}


Measured memory_bytes: 13684
//q086.cpp
//Sun Sep  6 16:35:59 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int par[60]; //親。1個上の親でしか無いことに注意。グループの根はfindで呼び出す。
int treerank[60]; //木の深さ

//n要素で初期化
void init(int n){
	for (int i=0;i<n;i++){
		par[i] = i;
		treerank[i] = 0;
	}
}

//木の根（親）を見つける。再帰することで、グループの根まで辿る。
int find (int x){
	if (par[x] == x){
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}

//xとyの属する集合の併合
void unite(int x, int y){
	x = find(x);
	y = find(y);
	if (x == y) {
		return;
	} 

	if (treerank[x] < treerank[y]){
		par[x] = y;
	} else {
		par[y] = x;
		if (treerank[x] == treerank[y]){
			treerank[x]++;
		}
	}
}

//xとyが同じグループに属するか判定
bool same(int x, int y){
	return find(x) == find(y);
}

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

	vector<int> a(m,0);
	vector<int> b(m,0);
	rep(i,m){
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	} 

	int count = 0;
	int ans = 0;
	while(count<m){
		init(n);
		rep(i,m){
			if(i==count)continue;
			unite(a[i],b[i]);
		}
		set<int> st;
		rep(i,n){
			st.insert(find(i));
		}
		if (st.size()!=1){
			ans++;
		}
		count++;
	}

	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3552
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>

using namespace std;

int calc(int k, int r, vector<int> a, int *num_a, int *mem){
  int s=-1;
  if (k == 0) return 0;
  if (k < r) return -100;
  if (mem[k] > 0) return mem[k];
  for(int x: a){
    s = max(s, calc(k-num_a[x], r, a, num_a, mem) +1);
  }
  mem[k] = s;
  return s;
}

int main(){
  int num_a[10];
  num_a[0] = 0;
  num_a[1] = 2;
  num_a[2] = 5;
  num_a[3] = 5;
  num_a[4] = 4;
  num_a[5] = 5;
  num_a[6] = 6;
  num_a[7] = 3;
  num_a[8] = 7;
  num_a[9] = 6;

  int n, m;
  cin >> n >> m;
  
  vector<int> a;
  int dum;
  int r = 10;
  for (int i =0;i<m;i++) {
    cin >> dum;
    a.push_back(dum);
    r = min(r, num_a[dum]);
  }
  
  sort(a.begin(), a.end(), greater<int>());
  
  int mem[n+1];
  memset(mem, -1, sizeof(mem));
  
  while(n > 0){
    for(int x :a){
	  if(calc(n,r,a,num_a,mem)==calc(n-num_a[x],r,a,num_a,mem)+1){
        cout << x;
        n = n-num_a[x];
        break;
      }
    }
  }
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

//Write From this Line

int main()
{
	int n ;
	cin >>  n ;
	vector<int> a(n);
	rep(i,n){
		int b ;
		cin >> b;
		b -- ;
		a[i] = b;
	}
	int ans = 0 ;
	rep(i,n){
		int x = a[i];
		if(a[x] == i){
			ans ++ ;
		}
	}
	cout << ans / 2 << endl;

}


Measured memory_bytes: 640
N, A, B = map(int, input().split())
H = sorted(int(input()) for _ in range(N))

import bisect, math
def f(ll, ul):
    if ul == ll: return ll
    cur = (ll + ul) // 2
    r = H[bisect.bisect_right(H, B * cur):]
    p = sum(math.ceil((x - B * cur) / (A - B)) for x in r)

    if p == cur:
        return cur
    elif p < cur:
        return f(ll, cur)
    else:
        return f(cur + 1, ul)

print(f(0, math.ceil((H[-1]) / B)))

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if( A % 2 != B % 2 ){
    cout << "IMPOSSIBLE" << endl;
  }else{
    int K = ( A + B ) / 2;
    cout << K << endl;
  }
  
}

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

int main(){
  ll n;  
  cin>>n;
  ll keta=1;
  while(1){
    if(n-powl(26,keta)<=0) break;
    n-=powl(26,keta);
    keta++;
  }
  string s(keta,'a');
  ll i=keta-1;
  n--;
  while(n>0){
    if(i==keta-1) s[i]='a'+n%26;
    else s[i]='a'+n%26;
    n/=26;
    i--;
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <bitset>

int main() {
	using namespace std;

	int n, m;
	cin >> n >> m;

	static bitset<200000> x, y;
	x[0] = true;
	y[n - 1] = true;
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		u--;
		v--;
		if (u == 0) x[v] = true;
		if (v == n - 1) y[u] = true;
	}

	puts((x & y).any() ? "POSSIBLE" : "IMPOSSIBLE");
}

Measured memory_bytes: 256
def divisor(i):
    s = []
    for j in range(1, int(i ** (1 / 2)) + 1):
        if i % j == 0:
            s.append(i // j)
            s.append(j)
    return sorted(set(s))

n, m = map(int, input().split())
l = m // n
s = divisor(m)
s.reverse()
for i in s:
    if m % i == 0 and l >= i:
        ans = i
        break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;vl al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
mt19937 rnd; void set_rnd(){random_device r;rnd=mt19937(r());}
vl fact, rfact; void set_fact(int n, ll m){fact.pb(1);rfact.pb(1);FOR(i,1,n+1)fact.pb(fact[i-1]*i%m),rfact.pb(modpow(fact[i],m,m-2));}
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 2e5;
void init(){
  set_rnd();
//  set_fact(N);
}
int n, a[N+1];

bool check(int c){
  if(c==1) return is_sorted(a, a+n);
  map<int, int> m;
  FOR(i, 1, n+1){
    if(a[i] > a[i-1]) continue;
    m.erase(m.upper_bound(a[i]), m.end());
    m[a[i]]++;
    int b = a[i];
    while(m[b] == c){
      m[b] = 0;
      b--;
      m[b]++;
    }
    if(!b) return false;
  }
  return true;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  init();
  cin >> n;
  FOR(i, 1, n+1) cin >> a[i];
  int l = 0, r = 2e5, mid;
  while(r-l > 1){
    mid = (l+r)/2;
    if(check(mid)){
      r = mid;
    }else{
      l = mid;
    }
  }
  cout << r << endl;
  return 0;
}

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

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

class CTaxIncrease {
 public:
  void solveOne(std::istream &in, std::ostream &out) {
    int a, b;
    in >> a >> b;

    for (int i = 1; i < (1 << 20); ++i) {
      int x = (int) i * 0.08;
      int y = (int) i * 0.1;
      if (a == x && b == y) {
        out << i << endl;
        return;
      }

    }
    out << -1 << endl;

  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  CTaxIncrease solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)
 
//=====I/O=====
 
var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)
 
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}
 
func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}
 
func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}
 
func scanText() string {
	sc.Scan()
	return sc.Text()
}
 
func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}
 
//=====main=====
 
func main() {
	sc.Split(bufio.ScanWords)
 
	h := scanInt()
	w := scanInt()
 
	ss := make([]string, h)
	for i := 0; i < h; i++ {
		ss[i] = scanText()
	}
 
	con := make([][]int, h*w)

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if ss[i][j]=='#' {
				continue
			}

			if i!=0 && ss[i-1][j]!='#' {
				con[i*w+j] = append(con[i*w+j], (i-1)*w+j)
			}

			if i!=h-1 && ss[i+1][j]!='#' {
				con[i*w+j] = append(con[i*w+j], (i+1)*w+j)
			}

			if j!=0 && ss[i][j-1]!='#' {
				con[i*w+j] = append(con[i*w+j], i*w+j-1)
			}

			if j!=w-1 && ss[i][j+1]!='#' {
				con[i*w+j] = append(con[i*w+j], i*w+j+1)
			}
		}
	}

	cost := make([][]int, h*w)

	for i := 0; i < h*w; i++ {
		cost[i] = make([]int, h*w)
		for j := 0; j < h*w; j++ {
			cost[i][j] = 1 << 30
		}
	}

	for i := 0; i < w*h; i++ {
		cost[i][i] = 0
		for _, e := range con[i] {
			cost[i][e] = 1
		}
	}

	for k := 0; k < h*w; k++ {
		for i := 0; i < h*w; i++ {
			for j := 0; j < h*w; j++ {
				cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j])
			}
		}
	}

	ans := 0

	for i := 0; i < h*w; i++ {
		for j := 0; j < h*w; j++ {
			if cost[i][j]==(1<<30) {
				continue
			}
			ans = max(ans, cost[i][j])
		}
	}

	fmt.Println(ans)
 
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] { res = a[i] }
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] { res = a[i] }
	}
	return res
}


Measured memory_bytes: 2048
#include <iostream>
using namespace std;
int main () {
    int a,b;
    cin >> a >> b;
    if (a % b == 0) {
        cout << a / b;
    }
    else if (b > a) {
        cout << 1;
    }
    else if (a % b != 0) {
        cout << a / b + 1;
    }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll x,y;
cin>>x>>y;
ll f=0;
for(ll i=0; i<=x; i++){
if(i*2+(x-i)*4==y){
cout<<"Yes"<<endl;
f++;
break;}
}
if(f!=1){
cout<<"No"<<endl;}}


Measured memory_bytes: 3632
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

typedef long long ll;
#define rep(i, n) for(int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)
using namespace std;

int main() {
    string s;
    int N;
    vector<vector<int>> vec;
    vector<int> answer;
    cin >> N;
    vec.resize(N-1);
    answer.resize(N-1);
    rep(i, N-1) {
        answer[i] = 0;
    }
    rep(i, N-1) {
        rep(j, 3) {
            int a;
            cin >> a;
            vec[i].push_back(a);
        }
    }
    rep(i, N-1) {
        answer[i] += vec[i][1];
        for (int j = i; j < N-1; ++j) {
            answer[i] += vec[j][0];
            if(j+1 < N-1) {
            if (answer[i] <= vec[j+1][1]) {
                answer[i] += (vec[j+1][1] - answer[i]);
            } else {
                int temp = vec[j+1][1];
                while(true) {
                    temp += vec[j+1][2];
                    if (temp >= answer[i]) {
                        answer[i] = temp;
                        break;
                    }
                }
            }
            }
        }
    }
    rep(i, N-1) {
        cout << answer[i] << endl;
    }
        cout << 0 << endl;
    return 0;
}

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

int main() {
	int k;
  	cin>>k;
  	
  long long int sum=0;
  for(int i=1;i<=k;++i) {
  	for(int j=1;j<=k;++j) {
    	for(int l=1;l<=k;++l) {
        	sum += __gcd(i,__gcd(j,l));
        }
    }
  }
  cout<<sum;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main(){
  ll N; cin >> N;
  auto p = prime_factorize(N-1);
  auto q = enum_divisors(N);
  ll ans = 1;

  for(auto c:p){
    ans *= (c.second + 1);
  }
  ans--;

  for(auto c:q){
    ll M = N;
    if(c == 1) continue;
    while(M % c == 0) M /= c;
    if(M % c == 1) ans++; 
  }

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

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n, k;
    cin >> n >> k;
    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }
    sort(v.begin(), v.end());
    int c = 0;
    for (int i = 0; i < n; i++) {
        c += v[i].second;
        if (k <= c) {
            cout << v[i].first << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 1792
N = int(input())
a = list(map(int, input().split()))

cnt = {}

for i in range(N):
    cnt.setdefault(a[i], 0)
    cnt[a[i]] += 1

ans = 0

for k, v in cnt.items():
    if k > v:
        ans += v
    else:
        ans += v - k

print(ans)


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

int main(){
  int n; cin >> n;
  int a[n];
  map<int, int> mp;
  
  for(int i=0; i<n; i++){
    cin >> a[i];
    mp[a[i]]++;
  }

  int ans = 0;
  for(const auto& itr: mp){
    if(itr.first > itr.second){
      ans += itr.second;
    }
    else if(itr.first < itr.second){
      ans += itr.second-itr.first;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>L(N);
	rep(i, 0, N)cin >> L[i];
	sort(all(L), greater<int>());
	int cnt = 0;
	rep(i, 1, N)cnt += L[i];
	cout << (L[0] < cnt ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    int w = scanner.nextInt();
    int h = scanner.nextInt();
    int n = scanner.nextInt();
    
    int left = 0;
    int right = w;
    int bottom = 0;
    int top = h;
    
    for(int i = 0; i < n; i++) {
      int x = scanner.nextInt();
      int y = scanner.nextInt();
      int a = scanner.nextInt();
      
      switch(a) {
        case 1:
          // 処理
          if(left < x) {
            left = x;
          }
          break;
        case 2:
          // 処理
          if(right > x) {
            right = x;
          }
          break;
        case 3:
          // 処理
          if(bottom < y) {
            bottom = y;
          }
          break;
        case 4:
          // 処理
          if(top > y) {
            top = y;
          }
          break;
      }
    }
    if(left > right || bottom > top) {
      System.out.println(0);
    } else {
   	  System.out.println((right - left) * (top - bottom));
    }
  }
}

Measured memory_bytes: 36092