akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("-O3")

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

using l = long int;
using ll =long long int;
using u64 = uint64_t;
// using u128 = __uint128_t;
#define imax INT_MAX
#define lmax LLONG_MAX
#define pb push_back
#define ld long double
#define pii pair<l,l> 
#define pll pair<ll,ll>
#define v vector
#define vl vector<l>
#define vll vector<ll>
#define vvl vector<vector<l>>
#define vvll vector<vector<ll>>
#define vv(a) vector<vector<a>> 
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x)rend()
#define f first
#define s second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define rep(i, begin, end) \
        for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define tc l t=0;cin>>t;while(t--)

// ONLINE JUDGE START
#ifndef ONLINE_JUDGE
    // FILE

    #define file ofstream cout; ifstream cin; cout.open("output.txt"); cin.open("input.txt");  
    // DEBUG

    #define debug(x) cout<<"LINE NUMBER:     "<<__LINE__<<"\t :--> \t"<<#x<<"   =   "<<x<<endl;

#else 

    #define debug(x) 

#endif


// SYSTEM
#define DeBuG(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime=NULL;(blockTime==NULL?(blockTime=clock())!=NULL:false); \
            DeBuG("%s:%.4f s\n",d,(double)(clock()-blockTime)/CLOCKS_PER_SEC))

// OVERLOADING
istream& operator >> (istream& cin,vll &a){
    for(auto &i:a)cin>>i;
    return cin;
}
ostream& operator << (ostream& cout,pll &a){
    cout<<a.f<<" "<<a.s<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vl &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,vll &a){
    for(auto &i:a)cout<<i<<" ";
    return cout;
}
ostream& operator << (ostream& cout,v<pll> &a){
    for(auto &i:a)cout<<i<<"\t";
    return cout;
}
ostream& operator << (ostream& cout,vvl &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,vvll &a){
    for(auto &i:a){cout<<i<<endl;}
    return cout;
}
ostream& operator << (ostream& cout,map<l,l> &a){
    for(auto &i:a){
        cout<<i.f<<" ";
    }
    return cout;
}


// GLOBAL VARIABLE AND FUNTIONS
const ll inf = 1e9+7;

int main()
{
#ifndef ONLINE_JUDGE
    // file;
#endif 
	fast;

    ll n;cin>>n;
    ll min;
    l count=1;
    for(l i=0;i<n;i++){
        ll x;cin>>x;
        if(!i)min=x;
        if(x<min){
            count++;
            min=x;
        }
    }
    cout<<count;

#ifndef ONLINE_JUDGE
    // cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
ans = set()

def point(x):
    temp = 0
    for i in range(Q):
        a, b, c, d = abcd[i]
        if x[b-1] - x[a-1] == c:
            temp += d
    return temp

def maker(x):
    dig = len(x)
    if  dig == N:
        ans.add(point(x))
    else:
        for i in range(x[-1], M+1):
            maker(x + [i])

for i in range(1, M+1):
    maker([i])
print(max(ans))

Measured memory_bytes: 9188
//Code By PMD
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define whatis(a) cout << #a " is " << (a) << endl;
using namespace std;

typedef long long i64;
const int N = 100005;
const i64 mod = 1e9+7;
const i64 inf = 1e18+7;

void solve() {
	int k , x;
	cin >> k >> x;
	int minn = x - k + 1;
	//cout << minn << endl;
	for(int i = 0 ; i < 2*k - 1 ; i++){
		cout << minn <<' ';
		minn++;
	}
	
}
main(){
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}
//Code By PMD




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

using namespace std;
using ll = long long;

int main(){
    ll n,q;
    cin >> n >> q;
    string str;
    cin >> str;
    vector<ll> l(q),r(q),nums(n);
    for(ll i=0;i<q;i++) cin >> l[i] >> r[i];
    ll cnt=0;
    nums[0]=0;
    for(ll i=0;i<n-1;i++){
        if(str[i]=='A'&&str[i+1]=='C')  cnt++;
        nums[i+1]=cnt;
    }
    for(ll i=0;i<q;i++){
        cout<< nums[r[i]-1]-nums[l[i]-1]<< endl;
    }
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long D, T, S;
  cin >> D >> T >> S;
  cout << (T * S >= D ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct S {
    ll minus, tot;
    bool used;
};

bool f(const S &a, const S &b) {
    return a.minus > b.minus;
}

bool g(const S &a, const S &b) {
    return (a.tot - a.minus) > (b.tot - b.minus);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    vector<S> vs(n, (S){0, 0, false});
    rep(i, n) {
        rep(j, len(s[i])) {
            vs[i].tot += (s[i][j] == '(') ? 1 : -1;
            vs[i].minus = min(vs[i].minus, vs[i].tot);
        }
    }
    sort(all(vs), f);
    ll sum = 0;
    rep(i, n) {
        if (vs[i].tot < 0) continue;
        if ((sum + vs[i].minus) < 0) {
            cout << "No" << endl;
            return 0;
        }
        sum += vs[i].tot;
        vs[i].used = true;
    }
    sort(all(vs), g);
    rep(i, n) {
        if (vs[i].used) continue;
        if ((sum + vs[i].minus) < 0) {
            cout << "No" << endl;
            return 0;
        }
        sum += vs[i].tot;
        if (sum < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << ((sum == 0) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 57712
#include <iostream>
#include <cmath>
#include <cstdio>

//#define M_PI 3.14159265358979 /* ?????¨??? */
#define rad2deg(a) ( (a) / M_PI * 180.0 ) /* rad ??? deg ??????????????????????????¢??° */
#define deg2rad(a) ( (a) / 180.0 * M_PI ) /* deg ??? rad ??????????????????????????¢??° */

using namespace std;



int main() {
	double a,b,d;
	
	cin >> a >> b >> d;
	
	printf("%lf\n%lf\n%lf\n", (a*b*sin(deg2rad(d)))/2, a + b + sqrt(a*a + b*b - 2*a*b*cos(deg2rad(d))), b*sin(deg2rad(d)));
	
	return 0;
}

Measured memory_bytes: 1260
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            var ans = long.MaxValue;

            for (long i = 1; i * i <= N ; i++)
            {
                if(N % i == 0)
                {
                    ans = Math.Min(Math.Max(i.ToString().Length, (N / i).ToString().Length), ans);
                }
            }

            Console.WriteLine(ans);
        }
    }
}


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

int main(void){
   long long H,W;
   cin>>H>>W;
   if(H==1||W==1){
      cout<<1<<endl;
      return 0;
   }
   if(H%2==0||W%2==0){
      cout<<(H*W)/2<<endl;
   }else{
      cout<<(H*W+1)/2<<endl;
   }
   return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
#define WHITE 0
#define GRAY -1
#define BLACK -2

typedef struct{
  int u;
  int k;
  int v[10];
  int vi;
  int d;
  int f;
}DFS;

int S[101];
int time = 0;
int color[101];
int top = 0;

void push(int a){
  S[top] = a;
  top++;
  color[a] = GRAY;
}

void pop(){
  top--;
}

int main()
{
  int i,j,n,p;
  
  scanf("%d",&n);
  
  DFS a[n+1];
  
  for(i=1; i<=n; i++){
    scanf("%d%d",&a[i].u,&a[i].k);
    a[i].d = 0;
    a[i].f = 0;
    a[i].vi = 0;
    color[i] = WHITE;
    for(j=0; j<a[i].k; j++){
      scanf("%d",&a[i].v[j]);
    }
  }
  
  for(i=1; i<=n; i++){
    if(color[i] == WHITE){
      push(a[i].u);
      a[i].d = ++time;
      while(1){
	if(top == 0)  break;
	
	p = S[top-1];
	
	if(a[p].k != 0 && a[p].vi < a[p].k){
	  if(color[a[p].v[a[p].vi]] == WHITE){
	    push(a[p].v[a[p].vi]);
	    a[a[p].v[a[p].vi]].d = ++time;
	  }
	  a[p].vi++;
	}
	
	
	else{
	  pop();
	  color[p] = BLACK;
	  a[p].f = ++time;
	}
      }
    }
  }
  
  for(i=1; i<=n; i++){
    printf("%d %d %d\n",a[i].u,a[i].d,a[i].f);
  }
  return 0;
}


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

#define vi vector<int>
#define vii vector<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...) 42
#endif

const int MOD = 1000000007;

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

    int count = 0;
    int found = s.find("ABC", 0);

    while(found != string::npos){
        count++;
        found = s.find("ABC", found + 1);
    }

    cout << count << endl;


    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}



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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};


vector<int> graph[2010];
int tmp[2010],dist[2010],dist2[2010];
bool ban[2010];

void dfs(int v,int p,int d,int* dist){
	if(ban[v]) return;
	dist[v]=d;
	for(auto &v2:graph[v]){
		if(v2==p) continue;
		dfs(v2,v,d+1,dist);
	}
	return;
}


int main(void){
	int n,k;
	cin >> n >> k;
	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		graph[a-1].push_back(b-1);
		graph[b-1].push_back(a-1);
	}

	int ans=0;
	
	while(1){
		int u=0,v=0,cmax=0;
		
		dfs(0,-1,0,tmp);
		cmax=0;
		rep(i,n) if(!ban[i] && chmax(cmax,tmp[i])) u=i;
		
		dfs(u,-1,0,dist);
		cmax=0;
		rep(i,n) if(!ban[i] && chmax(cmax,dist[i])) v=i;

		dfs(v,-1,0,dist2);
		cmax=0;
		rep(i,n) if(!ban[i]) chmax(cmax,dist2[i]);		

		if(cmax<=k) break;

		int unum=0,vnum=0;
		rep(i,n) if(!ban[i] && dist[i]>k) unum++;		
		rep(i,n) if(!ban[i] && dist2[i]>k) vnum++;		

		if(unum>vnum)
			ban[u]=true;
		else
			ban[v]=true;

		ans++;
	}	

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

Measured memory_bytes: 512
if __name__ == '__main__':
    N, M = map(int, input().split())
    # 初項 *　1/(1-r)**2
    shoko = (1900 * M + 100 * (N - M)) / (2 ** M)
    r = (2 ** M - 1) / (2 ** M)

    # print(shoko)
    # print(r)
    print(int(shoko / ((1 - r) ** 2)))


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
typedef struct {
  char name[20];
  int speed;
}  Process;
#define MAX 100001
Process S[MAX];
int s_top=0,s_tail=0;
int num;

void Enqueue(Process );
Process Dequeue(void );
int main()
{
  Process in;
  int i;
  int qua=0;
  int time_spend=0;
  
  scanf("%d %d",&num,&qua);
  //printf("%d %d\n",num,qua);
  for(i=0;i<num;i++)
    {
      scanf("%s %d",in.name,&in.speed);
      //printf("%s %d\n",in.name,in.speed);
      Enqueue(in);
    }

  while(s_top != s_tail)  
  {
      in=Dequeue();
      //printf("%s %d\n",in.name,in.speed);
      if(qua >= in.speed)
    {
      time_spend+=in.speed;
      printf("%s %d\n",in.name,time_spend);
    }
      else
     {
      time_spend+= qua;
      in.speed -= qua;
      Enqueue(in);
      //printf("%s %d\n",in.name,in.speed);
     }
    }
   return 0;
}
void Enqueue(Process in)
{
   S[s_tail] = in;
   //printf("%s %d\n",S[s_tail].name,S[s_tail].speed);
   if(s_tail == MAX-1) s_tail =0;
   else s_tail++;
}

Process Dequeue()
{
   Process out;
   out=S[s_top];
   if(s_top == MAX-1) s_top =0;
   else s_top++;
   return out;
}

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

int main() {
  int count=0,countb=0;
  int N,M;
  cin>>N>>M;
  if(N==M){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
}


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

int MAX = 101010;
vector<int> is_prime(MAX, 1);

void fill_is_prime() {
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j+= i) {
            is_prime[j] = 0;
        }
    }
}

vector<int> a(MAX, 0);
void is_2017_like() {
    for (int i = 0; i < MAX; ++i) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) {
            a[i] = 1;
        }
    }
}

vector<int> s(MAX+1, 0);
void fill_s() {
    for (int i = 0; i < MAX; ++i) {
        s[i+1] = s[i] + a[i];
    }
}

void querry() {
    int Q; cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        ++r;

        cout << s[r] - s[l] << endl;
    }
}

int main() {
    fill_is_prime();
    is_2017_like();
    fill_s();
    querry();

    return 0;
}

Measured memory_bytes: 1792
from operator import itemgetter
import bisect
n,m = map(int, input().split())
a = list(map(int, input().split()))
now = 0
a.sort()
bc = [list(map(int, input().split())) for i in range(m)]
bc.sort(key = itemgetter(1), reverse = True)
ans = 0
for i in bc:
  b,c = i[0],i[1]
  d = bisect.bisect_left(a,c) - now
  if d > b:
    ans += b * c
    now += b 
  else:
    now += d
    ans += d * c 
    break
ans += sum(a[now:])    
print(ans)

Measured memory_bytes: 32972
#include<stdio.h>

int n,i,j,a,b,k,c,x;
char s[1010][1010];

int main(){
	while(scanf("%d",&n)!=EOF){
		if(n==0)break;
		for(i=0;i<n;i++)scanf("%s",s[i]);
		k=n;x=0;
		while(k--){
			for(i=0;i<k+1;i++){
				for(j=0;j<k+1;j++){
					c=0;
					for(a=0;a<n-k;a++)for(b=0;b<n-k;b++)if(s[i+a][j+b]=='.')c++;
					if(c==(n-k)*(n-k)){
						x=n-k;
						break;
					}
				}
			}
			if(x!=n-k)break;
		}
		printf("%d\n",x);
	}
	return 0;
}

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

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    vector<P> l;
    rep(i, N) l.pb(P(A[i], i));
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    
    multiset<int> s = {-1, -1, N, N};
    int ans = 0;
    rep(i, N) {
        P p = l[i];
        int value = p.first, idx = p.second;
        if (i>0) {
            int prepre = *----s.lower_bound(idx);
            int pre = *--s.lower_bound(idx);
            int nex = *s.lower_bound(idx);
            int nexnex = *++s.lower_bound(idx);
            ans += value*((idx-pre)*(nexnex-nex)+(nex-idx)*(pre-prepre));
        }
        s.insert(idx);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 7280
#include <stdio.h>

#define MAX_N 100

int selectionSort(int A[], int N);

int main() {
  int N;
  int A[MAX_N];
  int cnt;
  int i;

  scanf("%d", &N);
  for(i = 0; i < N; ++i) scanf("%d", A+i);

  cnt = selectionSort(A, N);
  for(i = 0; i < N; ++i) printf("%d%c", A[i], " \n"[i==N-1]);
  printf("%d\n", cnt);

  return 0;
}

int selectionSort(int A[], int N) {
  int cnt = 0;
  int minj, tmp;
  int i, j;

  for(i = 0; i < N; ++i) {
    minj = i;
    for(j = i; j < N; ++j) {
      if(A[j] < A[minj]) minj = j;
    }
    tmp = A[i];
    A[i] = A[minj];
    A[minj] = tmp;
    cnt += minj != i;
  }
  return cnt;
}
    


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    int n, m, in;
    string key;
    set<int> A;
    set<int> B;
    vector<int> result;
    cin >> n;
    rep(i, n)
    {
        cin >> in;
        A.insert(in);
    }
    cin >> m;
    rep(i, m)
    {
        cin >> in;
        B.insert(in);
    }
    set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(result, result.end()));
    
    rep(i, result.size())
    {
        cout << result[i] << endl;
    }
}



Measured memory_bytes: 23748
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in(),k=in();
    vec a(n),l(n),r(n);
    rep(i,n){
        a[i]=in();
        l[i] = i - a[i];
        r[i] = i + a[i];
    }
    int cnt=0;
    for(int i=0;i<k; i++){
        cnt++;
        bool flag=true;
        REP(e,a)if(e!=n)flag=false;
        if(flag)break;
        vec plus(n+1);
        rep(i,n){
            plus[max(0,i-a[i])]++;
            plus[min(n,i+a[i]+1)]--;
        }
        a[0]=plus[0];
        rep(i,n-1){
            a[i+1]=a[i]+plus[i+1];
        }
        /*REP(e,a){
            cout<<e<<" ";
        }
        cout<<endl;*/
    }
    REP(e,a){
        cout<<e<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 6436
#include<bits/stdc++.h>
#define ri register int
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef vector<int> poly;
#define pb push_back
const int rlen=1<<18|1,inf=0x3f3f3f3f;
const ll Inf=1e18;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline ll readl() {
  ll ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline int Read(char*s) {
  int tp=0;
  char ch=gc();
  while(!isdigit(ch)&&!isalpha(ch)) ch=gc();
  while(isdigit(ch)||isalpha(ch)) s[++tp]=ch,ch=gc();
  return tp;
}
namespace modular {
  int mod;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
  inline int sqr(int a) { return mul(a,a); }
  inline int cub(int a) { return (ll)a*a%mod*a%mod; }
}
using namespace modular;
template<typename T> inline void ckmax(T&a,T b) { a<b?a=b:0; }
template<typename T> inline void ckmin(T&a,T b) { a>b?a=b:0; }
template<typename T> inline T gcd(T a,T b) { T t;while(b)t=a,a=b,b=t-t/a*a;return a; }
template<typename T> inline T Abs(T x) { return x<0?-x:x; }
const int N=6005;
int C[N][3],n,f[N][N+3005];
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read()*3,mod=read();
  for(ri i=0;i<=n;++i) for(ri j=C[i][0]=1;j<=3&&j<=i;++j) C[i][j]=add(C[i-1][j],C[i-1][j-1]);
  f[0][3000]=1;
  for(ri i=0,trs;i<n;++i) {
    for(ri j=-i/2;j<=i;++j) if((trs=f[i][j+3000])) {
      for(ri k=1;k<=3&&i+k<=n;++k) {
        Add(f[i+k][j+3000+(k<3?(k==1?1:-1):0)],mul(trs,k<3?(k==1?1:(n-i-1)):(n-i-1)*(n-i-2)));
      }
    }
  }
  int res=0;
  for(ri i=3000;i<=3000+n;++i) Add(res,f[n][i]);
  cout<<res;
  return 0;
}

Measured memory_bytes: 209792
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int dp[100010][15];
string s;
int a[100010];
int dfs(int pos,int pre){
//    cout<<pos<<" "<<pre<<endl;
    if(pos==s.length())return pre==5;
    if(dp[pos][pre]!=-1)return dp[pos][pre];
    int ans=0;
    int f=0;
    if(a[pos]==-1)f=1;
    if(f){
        for(int i=0;i<=9;++i){
            ans=(ans+dfs(pos+1,(pre*10+i)%13))%mod;
        }
    }
    else ans=(ans+dfs(pos+1,(pre*10+a[pos])%13))%mod;
    dp[pos][pre]=ans;
    return ans;
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    memset(dp,-1,sizeof(dp));
    for(int i=s.length()-1;i>=0;--i){
        if(s[i]=='?')a[i]=-1;
        else a[i]=s[i]-'0';
    }
    cout<<dfs(0,0)<<endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    for (int i = 0; i < n; ++i) cin >> p.at(i);
    for (int j = 0; j < n; ++j) cin >> q.at(j);
    vector<int> target(n);
    for (int k = 1; k <= n; ++k) target.at(k - 1) = k;
    int turn = 1;
    int p_turn = -1, q_turn = -1;
    do {
        if (target == p) p_turn = turn;
        if (target == q) q_turn = turn;
        turn++;
    } while (next_permutation(target.begin(), target.end()));
    cout << abs(p_turn - q_turn) << endl;
}


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

vector<int> onoff(int id, int num)
{
    vector<int> result(num);
    for (int i=num-1; i>=0; i--)
    {
        int tmp = pow(2, i);
        result[i] = id / tmp;
        id = id % tmp;
    }
    return result;
}

int main()
{
    int N,M;
    cin >> N >> M;
    vector<vector<int>> active_switches(M, vector<int>(N, 0));
    vector<int> activate_when(M, 0);
    for (int i=0; i<M; i++)
    {
        int k;
        cin >>k;
        for (int j=0; j<k; j++)
        {
            int swc;
            cin >> swc;
            active_switches[i][swc-1] = 1;
        }
    }
    for (int i=0; i<M; i++)
    {
        cin >> activate_when[i];
    }

    int count = 0;
    for (int comb=0; comb<pow(2, N); comb++)
    {
        vector<int> comb_vec = onoff(comb, N);
        
        bool all_active = true;

        for (int i=0; i<M; i++)
        {
            int sum=0;
            for (int j=0; j<N; j++)
            {
                sum += active_switches[i][j] * comb_vec[j];
            }
            if (sum%2 != activate_when[i])
            {
                all_active=false;
            }
        }
        if (all_active)
        {
            //cout << comb_vec[0] << comb_vec[1] << endl;
            count ++;
        }
    }
    cout << count << endl;

    
}

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

using namespace std;


#define tie() ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long


int32_t main()
{
    int t = 1;
    //cin >> t;
    while(t--)
    {
    	int a , b , c , k;
        cin >> a >> b >> c >> k;

        int sum = 0;

        sum += min(k , a) , k -= min(k , a);
        k -= min(k , b);
        sum -= min(k , c) , k -= min(c , k);

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


Measured memory_bytes: 3632
local n = io.read("*n")
local t = {}
for i = 1, 81 do
  t[i] = 0
end
for i = 1, n do
  local ri = i
  local btm = i % 10
  if btm ~= 0 then
    local top = btm
    while 10 <= i do
      i = i // 10
    end
    local top = i
    local idx = (top - 1) * 9 + btm
    t[idx] = t[idx] + 1
  end
end
local ret = 0
for i = 1, 9 do
  local idx = (i - 1) * 9 + i
  for j = 1, 9 do
    local idx1, idx2 = (i - 1) * 9 + j, (j - 1) * 9 + i
    ret = ret + t[idx1] * t[idx2]
  end
end
print(ret)


Measured memory_bytes: 760
n = int(input())
stairs = [int(x) for x in input(). split()]
 
minHeight = max(stairs[0] - 1, 0)
result = True

for i in stairs:
    if i < minHeight:
        result = False
        break
    else:
        if i > minHeight:
    	    minHeight = i - 1
 
if result:
    print("Yes")
else:
    print("No")

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

int n,U,tmp,sum;
int c[30],k[30],r[30],low[30];
int ans;
bool f;

int main(){
  while(scanf("%d%d",&n,&U),(n||U)){
    for(int i=0;i<n;i++){
      scanf("%d%d",&c[i],&k[i]);
      low[i] = c[i];
      r[i] = 0;
      for(int j=0;j<k[i];j++){
	scanf("%d",&tmp);
	r[i] |= 1<<tmp;
      }
    }

    sort(low,low+n,greater<int>());

    int l; sum = 0;
    for(l=0;l<n;l++){
      sum += low[l];
      if(U<=sum)break;
    }

    f = false;;
    for(ans=l+1;ans<n;ans++){
      int comb = (1<<ans) -1;
      while(comb < (1<<n)){
	sum = 0; f = true;
	for(int i=0;i<n;i++){
	  if((comb>>i)&1){
	    if( (comb&r[i]) != r[i]){
	      f = false;
	      break;
	    }
	    sum += c[i];
	  }
	}

	if(f && U<=sum){
	  break;
	}
	f = false;
      
	int x = comb & -comb, y = comb + x;
	comb = ( ( (comb & ~y) /x ) >> 1) | y;
      }
      if(f)break;
    }

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

Measured memory_bytes: 884
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long power = 1;
		for(int i = 1;i <= N;i++){
			power = (int)(power * i % (Math.pow(10, 9) + 7));
		};
		System.out.println(power);
	}
}


Measured memory_bytes: 21844
from math import factorial

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

mod = 10**9+7
nCr = {}

def cmb(n,r):
    return factorial(n)//(factorial(r)*factorial(n-r))

b = k
r = n - k


for i in range(1,k+1):
    r2 = r - i + 1
    if r2 < 0:
        print(0)
    else:
        print(int(cmb(b-1,i-1)*cmb(r2+i,i))%mod)


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

ans = 0
i = 1

if n % 2 == 1:
  print(0)
else:
  while True:
    k = n // (2 * (5 ** i))
      
    if k >= 1:
      ans += int(k)
    else:
      break
    i += 1
  
  print(ans)

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

ll solve() {
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M), sa(N+1), sb(M+1);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
        sa[i+1] = sa[i] + A[i];
    }
    for ( int i = 0; i < M; i++ ) {
        cin >> B[i];
        sb[i+1] = sb[i] + B[i];
    }
    int ia = 0, ib = 0;
    while ( ia+1 <= N && sa[ia+1] <= K ) ia++;
    while( ib+1 <= M && sa[ia] + sb[ib+1] <= K ) ib++;
    ll ans = ia + ib;
    while ( ia > 0 ) {
        ia--;
        while( ib+1 <= M && sa[ia] + sb[ib+1] <= K ) ib++;
        ans = max(ans, (ll)(ia + ib));
    }
    
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9592
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
     

int main() {
  ll x,y,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> n >> k;
  if(n >= k){
    if(n%k==0)
      cout << 0 << endl;
    else{
      x = n%k;
      if(n-k > k-x)
        cout << k-x << endl;
      else
        cout << n-k << endl;
    }
  }
  else{
    if(k-n > n)
      cout << n << endl;
    else
      cout << k-n << endl;
  }
  return 0;
}

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

int main(int argc, const char * argv[]) {
    int x, y;
    cin >> x >> y;
    int dai = x > y ? x : y;
    int sho = x > y ? y : x;
    int ama;
    
    while(sho){
        ama = dai % sho;
        dai = sho;
        sho = ama;
    }
    
    cout << dai << endl;
    return 0;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  int a[n];
  for(int i = 0; i<n;++i) cin >> a[i];
  sort(a, a+n);
  int m = 0;
  for(int i = 0; i < k; ++i) m+=a[i];
  cout << m << endl;
}


Measured memory_bytes: 3636
n,l=map(int,input().split())
d=abs(l)
pie=(n*(n+1)//2)+(n-1)*(l-1)-1
for k in range(2,n+1):
    t_pie=((n*(n+1))//2)+n*(l-1)
    p_pie=((n*(n+1))//2)+(n-1)*(l-1)-k
    xd=abs(t_pie-p_pie)
    if xd <= d:
        d=xd
        pie=p_pie
print(pie)

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

static const int MAX = 1e+5;
vector<int> adj[MAX];
int n, d1[MAX], d2[MAX];

void bfs(int s, int d[]){
	bool visited[n];
	rep(i, n){
		visited[i] = false;
	}
	d[s] = 0;
	queue<int> qq;
	qq.push(s);
	while(!qq.empty()){
		int u = qq.front();
		qq.pop();
		visited[u] = true;
		for(int x : adj[u]){
			if(visited[x]) continue;
			qq.push(x);
			d[x] = d[u] + 1;
		}
	}
	return;
}

int main(){
	int a, b;
	scanf("%d", &n);
	rep(_, n-1){
		scanf("%d %d", &a, &b);
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	bfs(0, d1);
	bfs(n-1, d2);
	int bl = 0, wh = 0;
	rep(i, n){
		if(d1[i] <= d2[i]) bl++;
		else wh++;
	}
	printf(bl > wh ? "Fennec\n" : "Snuke\n");
	return 0;
}

Measured memory_bytes: 6784
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			HashSet<Integer> set = new HashSet<>();
			set.add(sc.nextInt());
			set.add(sc.nextInt());
			set.add(sc.nextInt());
			if (set.size() == 2) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}

}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end(), greater<int>());

  int alice = 0, bob = 0;

  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice += a.at(i);
    }
    else {
      bob += a.at(i);
    }
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
road=[list(map(int,input().split())) for _ in range(M)]
result={i:0 for i in range(1, N+1)}
for i,j in road:
  result[i] += 1
  result[j] += 1
[print(result[i]) for i in range(1, N+1)]

Measured memory_bytes: 9204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double x1=sc.nextDouble(),y1=sc.nextDouble();
		double x2=sc.nextDouble(),y2=sc.nextDouble();
		System.out.printf("%.9f\n",Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
	}

}



Measured memory_bytes: 28172
#pragma GCC optimize("Ofast")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define SZ(n)       ((int)(n).size())
#define all(n)      (n).begin(), (n).end()
#define anal           '\n'
#define mod         1000000007
#define fst         first
#define sec         second
#define pr(n)       cerr << n  << " ";
#define pfor(a)       for(auto (w) : (a)) pr(w)
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
int main(){
I_AM_SPEED;
#ifndef ONLINE_JUDGE  
        freopen("input.in", "r", stdin);
        freopen("output.in", "w", stdout);
#endif 
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
     
     int n;
     cin >> n;
     vector<ll> v(n);
     for(int i = 0; i < n; i++) cin >> v[i];
     vector<ll> H;
     ll ph = 0;
     for(int i = 0; i < n; i++){
         if(v[i] >= ph){
               ph = v[i];
         }
         else{
             H.eb(abs(v[i] - ph));
             ph = v[i] + abs(v[i] - ph);
         }
     }
     ll ans = 0;
     for(auto w : H) ans += w;
     cout << ans << anal;
     
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
//printclock; 
return  0 ;      
}        



      

Measured memory_bytes: 6892
#include <stdio.h>
int main()
{
    long int X, Y, N;
    long int x, y, t;
    long int i, j, k;
    scanf ("%ld%ld%ld", &X, &Y, &N);
    long int a[102][102]={0};
    for(i=0;i<N;i++)
    {
        scanf("%ld%ld%ld", &x, &y, &t);
        if(t==1)
        {
            for(int j=1;j<=x;j++)
            {
                for(int k=1;k<=Y;k++)
                {
                    a[j][k] = 1;
                }
            }
        }
        if(t==2)
        {
            for(int j=x+1;j<=X;j++)
            {
                for(int k=1;k<=Y;k++)
                {
                    a[j][k] = 1;
                }
            }
        }
        if(t==3)
        {
            for(int j=1;j<=X;j++)
            {
                for(int k=1;k<=y;k++)
                {
                    a[j][k] = 1;
                }
            }
        }
        if(t==4)
        {
            for(int j=1;j<=X;j++)
            {
                for(int k=y+1;k<=Y;k++)
                {
                    a[j][k] = 1;
                }
            }
        }
    }
    long int S = 0;
    for(i=1;i<=X;i++)
    {
        for(int j=1;j<=Y;j++)
        {
            if(a[i][j]==0)
            {
                S++;
            }
        }
    }
    printf ("%ld", S);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int a;
 cin >> a;
 int count =0;
 for(int i=1;i<=a;i++){
   if(i>=1&&i<=9){
     count ++;
   }else if(i>=100&&i<=999){
     count ++;
   }else if(i>=10000&&i<=99999){
     count ++;
   }
 }
 cout <<count << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = n;
  int res = 1;
  rep(i, n) {
    if(a[i] == res) res++, ans--;
  }
  cout << (ans == n ? -1 : ans) << endl;
  return 0;
}


Measured memory_bytes: 1024
s = input()
s = s[-1::-1]
pattern_list = ["dream"[-1::-1],"dreamer"[-1::-1],"erase"[-1::-1],"eraser"[-1::-1]]
flg = True
ret = "YES"
while flg:
    bad_loop = True
    for pattern in pattern_list:
        if s==pattern:
            flg=False
            bad_loop = False
        elif s.startswith(pattern):
            s = s[len(pattern)::]
            bad_loop = False
    if bad_loop:
        ret="NO"
        flg=False
print(ret)

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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll a[3];
    for(ll i = 0; i < 3; i++) {
        cin >> a[i];
    }
    sort(a, a+3);
    ll A = a[0];
    ll B = a[1];
    ll C = a[2];


    ll k = C - B;
    ll j = A + k;
    ll l = C - j;
    ll p;
    if(l % 2 == 0) {
         p = ceil(l / 2.0);
    }
    else {
         p = ceil(l / 2.0) + 1;
    }
    ll g = p + k;
    cout << g << endl;
    return 0;
}


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

f=[]
for m in range(1,int(M**(1/2))+3):
    if M % m == 0:
        f.extend([m,M//m])
f.sort(reverse=True)

for f_ in f:
    if N <= M/f_:
        ans=f_
        break
print(ans)

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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    int a;
    std::cin >> a;
    if(a>=2100)std::cout << 1 << std::endl;
    else{
        int n=a/100;
        if(a%100>n*5)std::cout << 0 << std::endl;
        else std::cout << 1 << std::endl;
    }
}

Measured memory_bytes: 256
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;


#define FORA(i, a, n) for (int i = (a); i < (n); ++i)


typedef int64_t i64;


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


template <class T>
inline T set_bit(T mask, int bit) {
    assert(0 <= bit && bit < numeric_limits<T>::digits);
    return mask | ((T)(1) << bit);
}


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}

template<class T>
vector<T> next_vec(istream& in, size_t n) {
  vector<T> ret(n);
  for (size_t i = 0; i < n; ++i) {
    ret[i] = next<T>(in);
  }
  return ret;
}


i64 X, S;
i64 res = -1;
i64 lim;

void rec(int b, i64 a) {
  if (b == 41) {
    return;
  }
  if ((a + (a ^ X)) == S) {
//    i64 b = (a ^ X);
//    if (b > lim) {
//      if (a < res) {
//        return;
//      }
//    }
//    dbg(a, a ^ X, S);
    if (a < lim) {
      res = max(res, a);
    }
    if ((a ^ X) < lim) {
      res = max(res, (a ^ X));
    }
//    return;
  }

  i64 A = set_bit(a, b);
  i64 M = (1LL << (b + 1)) - 1;
  i64 S2 = (S & M);

  if (((A + (A ^ X)) & M) == S2) {
    rec(b + 1, A);
  }
  if (((a + (a ^ X)) & M) == S2) {
    rec(b + 1, a);
  }

}

void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  auto a = next_vec<i64>(in, n);
  auto x = a[0];
  auto y = a[1];
  i64 z = 0;
  FORA(i, 2, n) {
    z ^= a[i];
  }

  if ((x ^ y) == z) {
    out << 0 << "\n";
    return;
  }

  lim = x;
  S = x + y;
  X = z;
  res = -1;
  rec(0, 0);

  if (res == 0 || res == -1) {
    out << "-1\n";
    return;
  }
  out << x - res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



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

int main() {
	int k,s,x,y,z;
	cin>>k>>s;
	int ans=0;
	
	for(x=0;x<k+1;x++){
		for(y=0;y<k+1;y++){
			if(s-x-y>-1&&s-x-y<k+1)ans++;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<atcoder/convolution.hpp>
using namespace atcoder;
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> a(N), b(M);
    rep(i, N)cin >> a[i];
    rep(i, M)cin >> b[i];
    auto res = convolution(a, b);
    for (auto num : res)cout << num << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 27288
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010000
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int n,s;
  cin>>n>>s;
  if(n<s){cout<<-1<<endl;return 0;}
  if(n==s){cout<<n+1<<endl;return 0;}
  repi(i,2,sqrt(n)+1){
    int a=n;
    int num=0;
    while(a){
      num+=a%i;
      a/=i;
    }
    if(num==s){cout<<i<<endl;return 0;}
  }
  int ans=BIG;
  int p=min(s+1,(int)sqrt(n)+1);
  // cout<<p<<endl;
  repi(i,1,(int)sqrt(n)){
    int b=((n-s)/i) + 1 ;
    // cout<<b<<endl;
    if(i + (n%b) == s){ans=min(ans,b);}
  }
  if(ans==BIG) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
int rd() {
	int f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
	int x = 0; for (; isdigit(c); c = getchar()) x = x*10+c-'0'; return x*f;
}

const int N = 300000;

int n;
struct R {
	int i, x;
	friend int operator < (R a, R b) { return a.x < b.x; }
}r[N];
int a[N], m;

void run() { for (m++; a[m] > 0; m++); }

int main() {
	n = rd();
	F(i, 1, n) {
		int x = rd();
		r[i] = (R){i, x};
		a[x] = i;
	}
	sort(r+1, r+n+1);
	
	F(c, 1, n) {
		int i = r[c].i, x = r[c].x;
		F(j, 1, i-1)
			run(), a[m] = i;
		if (m > x) return puts("No"), 0;
	}
	
	run();
	F(c, 1, n) {
		int i = r[c].i, x = r[c].x;
		if (m < x) return puts("No"), 0;
		F(j, i+1, n)
			a[m] = i, run();
	}
	m--;
	
	puts("Yes");
	F(i, 1, m) printf("%d ", a[i]); puts("");
		
	return 0;
}

Measured memory_bytes: 2176
#include<cstdio>
#include<map>
using namespace std;

int main(){
  int n,m;
  char a,b;

  while(scanf(" %d ",&n),n){
    map<char,char> t;
    for(int i=0;i<n;i++){
      scanf(" %c %c ",&a,&b);
      t[a] = b;
    }

    scanf(" %d ",&m);
    for(int i=0;i<m;i++){
      scanf(" %c ",&a);
      if(t.find(a)!=t.end())putchar(t[a]);
      else putchar(a);
    }
    putchar('\n');
  }
}
    

Measured memory_bytes: 1008