akhauriyash/Code-Regression huggingface dataset:
def main():
    a,b=map(int,input().split())

    i=1
    while True:
        if 0.08*i//1==a and 0.1*i//1==b:
            ans=i
            break
        
        if 0.08*i//1>a or 0.1*i//1>b:
            ans=-1
            break
        i+=1
    print(ans)  

if __name__=='__main__':
    main()

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

const double EPS = 1e-8;

int main()
{
    int n, pm, pe, pj;
    while(cin >> n && n) {
        for(int i = 0; i < n; i++) {
            cin >> pm >> pe >> pj;
            char cls = 'X';
            double ave_me, ave_all;
            ave_me = (double)(pm + pe) / 2;
            ave_all = (double)(pm + pe + pj) / 3;
            if(pm == 100 || pe == 100 || pj == 100)
                cls = 'A';
            else if(ave_me + EPS > 90)
                cls = 'A';
            else if(ave_all + EPS > 80) 
                cls = 'A';
            else if(ave_all + EPS > 70)
                cls = 'B';
            else if(ave_all + EPS > 50 && (pm>= 80 || pe >= 80))
                cls = 'B';
            else
                cls = 'C';
            
            cout << cls << endl;
        }
    }
}

Measured memory_bytes: 0
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,k = get_all_int()

# m桁の数値でf(n)=kとなる数の個数
# dp[k][m]
dp = [ [None]*101 for _ in range(4)]

for i in range(101):
    dp[0][i] = 1
dp[0][0] = 0
dp[1][0] = 0
dp[2][0] = 0
dp[3][0] = 0
dp[1][1] = 9
dp[2][1] = 0
dp[3][1] = 0

dp[1][2] = 1 * dp[1][1] + 9 * dp[0][1]
for i in range(2,101):
    dp[1][i] = 1 * dp[1][i-1] + 9 * dp[0][i-1]
    dp[2][i] = 1 * dp[2][i-1] + 9 * dp[1][i-1]
    dp[3][i] = 1 * dp[3][i-1] + 9 * dp[2][i-1]

# log(dp[1])
# log(dp[2])

ans = 0

keta = 0
x = n
while x > 0:
    keta += 1
    x //= 10

def sol(n, keta, k):
    if k == 0:
        return 1
    if k < 0:
        return 0
    if keta < k:
        return 0
    if keta == 0:
        return 1
    
    top = n//10**(keta-1)%10
    if keta==1:
        return top
    ans = 0
    # 0のとき
    if top == 0:
        ans += sol(n, keta-1, k)
    else:
        ans += 1 * (0 if keta==1 else dp[k][keta-1])
    # ans += sol(n, keta-1, k)
    log(keta,top,k,ans)

    # 1～top-1のとき
    if top != 0:
        if top == 1:
            ans += sol(n, keta-1, k-1)
        else:
            ans += (top-1) * (1 if keta==1 else dp[k-1][keta-1])
        # ans += (top-1) * sol(n, keta-1, k-1)
        log(keta,top,k,ans)

    # topのとき
    if top > 1:
        ans += sol(n, keta-1, k-1)
        log(keta,top,k,ans)
    return ans

if keta < k:
    print(0)
    exit()
ans += sol(n, keta, k)

print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

// const int maxn = 
// const int mo = 1e9 + 7;

// int n;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int r, d, v;
	cin >> r >> d >> v;
	for (int i = 0; i < 10; ++i) {
		v = r * v - d;
		cout << v << endl;
	}

	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const string YES = "Yes";
const string NO = "No";
const ll mod = 1e9+7;



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

    ll n,m; 
    cin >> n >> m;

    vll wa(n+1);
    vll ac(n+1);
    REP(i,m){
        ll p; string s;
        cin >> p >> s;
        if (s == "AC") ac[p] = 1;
        if (s == "WA" && ac[p] == 0){
            wa[p]++;
        }
    }
    ll a=0, w=0;
    REP(i,n+1){
        if(ac[i]){
            a++;
            w += wa[i];
        }
    }

    cout << a << " " << w << endl;
    return 0;
    
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> x(N);
    rep(i, N) cin >> x[i];
    vector<int> q(N-1);
    rep(i, N-1) q[i] = x[i+1] - x[i];

    lint res = 0;

    lint factor = 0;
    for (int i = 1; i <= N-1; i++) {
        factor += modpow(i, MOD-2);
        factor %= MOD;
        res += factor * q[i-1];
        res %= MOD;
    }

    for (int i = 2; i <= N-1; i++) {
        res *= i;
        res %= MOD;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1148
/*
 * main.c
 *
 *  Created on: 2019/02/09
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>

int town[3][2] = {0};

int main()
{
	int i = 0;
    int val[4] = {0};
    int ans = 0;

	for (i = 0; i < 3; i++) {
		scanf("%d %d",&town[i][0], &town[i][1]);
		switch(town[i][0]) {
		case 1:
			val[0]++;
			break;
		case 2:
			val[1]++;
			break;
		case 3:
			val[2]++;
			break;
		case 4:
			val[3]++;
			break;
		}
		switch(town[i][1]) {
		case 1:
			val[0]++;
			break;
		case 2:
			val[1]++;
			break;
		case 3:
			val[2]++;
			break;
		case 4:
			val[3]++;
			break;
		}
	}

	for(i = 0; i < 4; i++) {
		if (val[i] > 2) {
			ans = 1;
		}
	}

	if (ans==1) {
		printf("NO\n");
	} else {
		printf("YES\n");
	}

	return 0;
}


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

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    ll ans = 1LL << 60;
    ll tmp;
    for(int i = 1; i < 100; i++) {
        tmp = 0;
        rep(j, n) {
            tmp += (x[j]-i)*(x[j]-i);
        } 
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

class CalculateSum {

    public function getAnswer()
    {
        $n = trim(fgets(STDIN));
        $count = 0;

        for ($i = 0; $i < $n; $i++) {
            $num = (int) fgets(STDIN);

            if ($this->isPrime($num)) {
                $count++;
            }
        }

        echo $count . PHP_EOL;
    }
}

class CheckPrimeNumbers extends CalculateSum {

    public function isPrime($num)
    {
        if ($num == 2) {
            return true;
        } elseif ( $num < 2 or $num % 2 == 0) {
            return false;
        } else {
            $start = 3;
            while ($start <= sqrt($num)) {
                if ($num % $start == 0) {
                    return false;
                }
                $start += 2;
            }
            return true;
        }
    }
}

$rate = new CheckPrimeNumbers();
$rate->getAnswer();



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

int main(){
  int N;
  string S;
  cin>>N>>S;
  int count=0;
  for(int i=0;i<N;i++){
  	if(i==0)
      count++;
    else{
      if(S.at(i)!=S.at(i-1))
        count++;
    }
  }
  cout<<count<<endl;
}

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

int main() {

	ll x; cin >> x;
	ll sum = 0;
	ll ans;
	for (ll i = 1; i <= x; i++) {
		sum += i;
		if (x <= sum) {
			ans = i;
			break;
		}
	}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 0;
		while(true) {
			if((a*count-(count -1)) >=b) {
				break;
			}else {
				count++;
			}
		}
		System.out.println(count);
		sc.close();

	}

}

Measured memory_bytes: 23380
def cd_generator(num):
    i=1
    lower=[]
    upper=[]
    while i*i<=num:
        if num%i==0:
            lower.append(i)
            if num!=i*i:
                upper.append(num//i)
        i+=1
    return reversed(lower+upper[::-1])
n,m=map(int,input().split())

for ele in cd_generator(m):
    if m/ele>=n:
        print(ele)
        exit()


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

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

    while(true)
    {
        c -= b;
        if(c <= 0)
        {
            cout << "Yes";
            break;
        }

        a -= d;
        if(a <= 0)
        {
            cout << "No";
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<=2^64-1 && x>0
#define int long long//used when x<=2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;


void solve()
{
    int n, w;
    cin>>n>>w;
    vector<pair<int, int>> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i].ff>>v[i].ss;
    }
    int dp[n+1][w+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
                continue;
            }
            dp[i][j]=dp[i-1][j];
            if(v[i-1].ff<=j)
            {
                dp[i][j]=max(dp[i][j], v[i-1].ss+dp[i-1][j-v[i-1].ff]);
            }
        }
    }
    cout<<dp[n][w]<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll dp[1 << 20][36] = {0};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<ll, ll>> ps(n);
  for (int i = 0; i < n; i++) cin >> ps[i].first;
  for (int i = 0; i < n; i++) cin >> ps[i].second;
  map<ll, int> mp;
  for (int i = 0; i < n; i++) {
    ps[i].first--;
    ps[i].second--;
    mp[ps[i].first] = mp[ps[i].second] = 0;
  }
  ll cc = 0;
  for (auto &it : mp) it.second = cc++;
  for (int i = 0; i < n; i++) {
    ps[i].first = mp[ps[i].first];
    ps[i].second = mp[ps[i].second];
  }
  ll bit = 1 << n;
  ll INF = 1LL << 50;
  for (int i = 0; i < bit; i++) for (int j = 0; j < 50; j++) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 0; i < bit; i++) {
    int setted = 0;
    for (int j = 0; j < n; j++) if (i & (1LL << j)) setted++;
    for (int j = 0; j < 36; j++) {
      if (dp[i][j] >= INF) continue;
      int c = 0;
      // k - setted + c -> setted
      for (int k = 0; k < n; k++) {
        ll b = 1LL << k;
        if (i & b) {
          c++;
          continue;
        }
        ll d = k - c;
        ll v = ps[k].first;
        if (abs(setted - k) % 2) {
          v = ps[k].second;
        }
        if (v < j) continue;
        dp[i | b][v] = min(dp[i | b][v], dp[i][j] + d);
      }
    }
  }

  ll ans = INF;
  for (int i = 0; i < 36; i++) {
    ans = min(ans, dp[bit - 1][i]);
  }
  if (ans < INF) cout << ans << endl;
  else cout << -1 << endl;

  return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll a,b,c;

int main(){
  cin >> a >> b >> c;
  if(a==b && a!=c){cout << "Yes";return 0;}
  if(a==c && a!=b){cout << "Yes";return 0;}
  if(c==b && b!=a){cout << "Yes";return 0;}
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<bool> x(n, false);
  vector<int> wa(n, 0);
  int ans = 0;
  int plt = 0;
  rep(i, m){
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (x[p]) continue;
    if (s == "AC"){
      ans++;
      plt += wa[p];
      x[p] = true;
    }
    else if (s == "WA") wa[p]++;
  }
  cout << ans << ' ' << plt << endl;
  
  return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
map<string,vector<int>> m;
signed main(){
	int n,ma=0;
	cin>>n;
	string s;
	cin>>s;
	for(int i=1-n;i<n;i++){
		int x=0;
		if(i==0)continue;
		f(j,n){
			if(j+i>=0&&j+i<n){
				if(s[j]==s[j+i]){
					x++;
					if(x==abs(i))ma=max(ma,x);
				}
				else{
					if(abs(i)>=x){
						ma=max(ma,x);
					}
					x=0;
				}
			}
			else{
				if(abs(i)>=x)ma=max(ma,x);
				x=0;
			}
		}
	}
	cout<<ma<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    int n,k; cin >> n;
    ll r=0,g=0,b=0;
    string s;cin >> s;
    for(const auto& c:s){
        if(c=='R') r+=1;
        if(c=='G') g+=1;
        if(c=='B') b+=1;
    }
    ll res=r*g*b;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;2*j-i<n;j++){
            k=2*j-i;
            if(s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k]){
                res-=1;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3656
q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

n = 10 ** 5
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

like_numbers = []
for prime in primes:
    if int((prime + 1) / 2) in primes:
        like_numbers.append(prime)

for i in range(q):
    l = lr[i][0]
    r = lr[i][1]
    print(sum((x >= l and x <= r) for x in like_numbers))


Measured memory_bytes: 86228
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;

int ans=0;

int main()
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(x<a||y<b)continue;
		ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
from collections import*
H,W=map(int,input().split());M=[input()for _ in"_"*H];C=[[1]*W for _ in"_"*H];q=deque([[0,0]])
while q:
  x,y=q.popleft()
  for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
    h,w=x+i,y+j
    if H>h>-1and W>w>-1and M[h][w]>'#'and C[h][w]<2:C[h][w]=C[x][y]+1;q.append([h,w])
c=C[H-1][W-1];print(-1*(c<2)or sum(m.count(".") for m in M)-c)

Measured memory_bytes: 9284
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<double, ii>  iii;
typedef pair<double, double>  iidb;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 3600000
#define offset 3000
#define ptr nodo*
const ll MOD=1e9+7;

using namespace std;
const ll inf=1e15;
int n;

int v[4][tam];
ll dp[4][tam];
ll go(int y)
{
	int pslide=0;
	ll tot=0;

	forr(j,0,n)
	{
		while(pslide<n && v[y-1][pslide]<v[y][j]){tot+=dp[y-1][pslide];if (y-1==0)assert(dp[y-1][pslide]==1);pslide++;}
		dp[y][j]=tot;
	}
	return 0;
}
int main()
{	
	
	cin>>n;
	forr(i,0,3)
	{
		forr(j,0,n){
			if (i==0)dp[i][j]=1;
			cin>>v[i][j];
		}
		sort(v[i],v[i]+n);
		
	}
	ll tot=0;
	go(1);
	go(2);
	forr(j,0,n)
		tot+=dp[2][j];
	cout<<tot<<endl;
}			

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

#define REP(i,n) for(ll i = 0;i < n;++i)
#define PB(s) push_back(s)
#define ST(n) sort(n.begin(),n.end())

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

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main(void){
  int N;
  cin >> N;
  vector<P> WORKS;
  REP(i,N){
    ll X,Y;
    cin >> X >> Y;
    WORKS.push_back(P(X,Y));
  }
  ll x=0;
  sort(WORKS.begin(), WORKS.end(), pairCompare);
  
  REP(i,N){
    //cout << WORKS[i].first << " " << WORKS[i].second  << endl;
    x+=WORKS[i].first;
    if(x>WORKS[i].second){
      cout<<"No" << endl;
      exit(0);
    }
  }
  cout<<"Yes" << endl;
}


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

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

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

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

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

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

void solve(void)
{
  ll a, b, k; cin >> a >> b >> k;
  set<ll> res{};
  for (ll i = a; i < a + k; ++i)
  {
    if(i > b)
      break;
    res.emplace(i);
  }
  for (ll i = b; i > b - k; --i)
  {
    if(i < a)
      break;
    res.emplace(i);
  }
  while (!res.empty())
  {
    auto it = res.begin();
    cout << *it << CRLF;
    res.erase(it);
  }
  
  return;
}

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

  solve();

  return 0;
}


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

int main() {
    int n;
    cin>>n;
    int max_num=0;
    int ans=0;
    

    rep(i,n){
        int cnt=0;
        int num=i;
        while(true){
            bool exist_odd=false;
            if(num%2!=0)exist_odd=true;
            if(exist_odd){
                //cout<<i;
                break;
            }
            num/=2;
            cnt++;
        }
        
        max_num=max(cnt,max_num);
        if(max_num==cnt)ans=i;

    }
    cout<<ans;
    return 0;
    }


Measured memory_bytes: 3644
/*
  Contest 109
  A - ABC333
  Rakesh Kumar --> 27/09/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0;
    std::cin >> a >> b;
    std::cout << (((a * b) & 1) ? "Yes" : "No") << std::endl;

    return 0;
}


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

def solve(N):
    if N == 0:
        return "0"
    result = ""
    n = N
    i = 0
    while n:
        k = (-2)**i
        if n & (1 << i):
            n -= k
            result = "1" + result
        else:
            result = "0" + result
        i += 1
    return result

print(solve(N))


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

int main() {
	int n_col;
	cin >> n_col;
	int* p_currency;
	p_currency = new int[n_col];

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

	int max_profit = p_currency[1] - p_currency[0];
	//cout << "first max_profit: " << max_profit << "\n";
	int min = p_currency[0];
	//cout << "first min: " << min << "\n";

	for(int i=1; i<n_col; i++){
		int diff = p_currency[i] - min;
		if(max_profit < diff){
			max_profit = diff;
		}

		if(min > p_currency[i]){
			min = p_currency[i];
		}

		//cout << "min:" << min << "\n";
		//cout << "max_profit: " << max_profit << "\n";
	}
	cout << max_profit << "\n";
	delete[] p_currency;
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
int INFTY = 1000000000;

int A[500001],cnt=0,n;

void merge(int left,int mid,int right)
{
int n1,n2,i,j,k;
n1 = mid - left;
n2 = right - mid;
int L[n1+1],R[n2+1];
for(i=0;i<n1;i++) L[i] = A[left + i];
for(i=0;i<n2;i++) R[i] = A[mid + i];
L[n1] = INFTY;
R[n2] = INFTY;
i = 0;
j = 0;
for(k=left;k<right;k++)
{
cnt++;
if( L[i] <= R[j] )
{
A[k] = L[i];
i = i+1;
}
else
{
A[k] = R[j];
j = j+1;
}
}
}


void mergeSort(int left,int right)
{
int mid;
if( left+1 < right)
{
mid = (left + right)/2;
mergeSort(left, mid);
mergeSort(mid, right);
merge(left,mid,right);
}
}

int main()
{

int i;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&A[i]);
mergeSort(0,n);
for(i=0;i<n;i++)
{
printf("%d",A[i]);
if(i==n-1) printf("\n");
else printf(" ");
}
printf("%d\n",cnt);
return 0;
}



Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<((double)(w*h))/2.0<<" ";
	if((x*2)==w && (y*2)==h){
		cout<<1;
	}
	else {
		cout<<0;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);


    int r;
    cin >> r;

    cout << fixed << setprecision(10) << 2 * PI * r << endl;
}


Measured memory_bytes: 3804
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n, k; cin >> n >> k;
    cout << ceil((double) (n-1) / (k-1)) << endl;
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e4+17;
const int MOD = 1e9+17;
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    string mp[10];
    int n,m;
    cin>>n>>m;
    for (int i = 0; i < n; ++i)
    {
    	cin>>mp[i];
    }
    int x = 0,cnt=0;
    bool can = true;
    for (int i = 0; i < n; ++i)
    {
    	for (int j = 0; j < m; ++j)
    	{
    		if(mp[i][j]=='#')
    			cnt++;
    	}
    }
    for (int i = 0; i < n; ++i)
    {
    	debug(x);
    	for (int j = x; j < m; ++j)
    	{
    		// debug(j);
    		// debug(mp[i][j]);
    		if(mp[i][j]!='#')
    		{
    			x = j-1;
    			break;
    		}
    		cnt--;
    		if(j==m-1)
    			x=j;
    	}
    }
    if(cnt==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;        
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,k=MI()
    print(pow(k-1,n-1)*k)

main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  vector<string> V(n);	//まあいいや
  for(int i=0;i<n;i++){
    cin >> V[i];
  }
  sort(V.begin(),V.end());

  for(int i=0;i<n;i++){
    cout<<V[i];
  }
  cout<<endl;
}


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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(is,1<<h) rep(js,1<<w) {
    int cnt = 0;
    rep(i,h) rep(j,w) {
      if (is>>i&1) continue;
      if (js>>j&1) continue;
      if (s[i][j] == '#') cnt++;
    }
    if (cnt == k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3192
N, M = map(int, input().split())
H_list = list(map(int, input().split()))
AB_list = []
for i in range(M):
    AB_list.append(list(map(int,input().split())))

tenboudai_dict = {}
for i in range(0,N):
    tenboudai_dict[i+1] = H_list[i]
#print(tenboudai_dict)

tenboudai_dict2 = {}
for way in AB_list:
    if tenboudai_dict[way[0]] == tenboudai_dict[way[1]]:
        tenboudai_dict2[way[0]] = 'NO'
        tenboudai_dict2[way[1]] = 'NO'
    elif tenboudai_dict[way[0]] < tenboudai_dict[way[1]]:
        tenboudai_dict2[way[0]] = 'NO'
    elif tenboudai_dict[way[0]] > tenboudai_dict[way[1]]:
        tenboudai_dict2[way[1]] = 'NO'


print(N - len(tenboudai_dict2))

Measured memory_bytes: 44544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
#include "math.h"
#include <complex>
#include <iomanip>
#include <map>
#define ifor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;
typedef long double ld;
typedef long long int  lli;
typedef complex <double> P;
const double eps = 1e-11;
int vex[4]={1,0,-1,0};
int vey[4]={0,1,0,-1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD=1000000007;
int main(){
  int N,A;
  int x[51];
  int total = 0;
  lli dp[2][2505][55];
  lli ans =0;
  cin >> N >> A;
  int now = 0;
  int next =1;
  rep(i,N)cin>>x[i];
  rep(i,N){
    rep(j,2501){
      for(int k = 1;k<=N;k++)
      {
        if(i>0&&j>x[i])dp[now][j][k]=dp[next][j][k]+dp[next][j-x[i]][k-1];
    else if (i>0)dp[now][j][k]=dp[next][j][k];

      }
    }
    dp[now][x[i]][1]++;
    swap(now,next);
  }
  for(int i = 1;i<=N;i++){
    ans += dp[next][A*i][i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vlll = vector<vll>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, LIS, digitDP, treeDP, Rerooting//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA, FordFulkerson//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q, T;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vector<vpll> path;

int main() {
	string S;
	cin >> S;
	N = S.length();
	for (i = 0; i < N; i++) {
		ans += ctoi(S[i]);
	}
	if (ans % 9 == 0) cout << "Yes";
	else cout << "No";
}







Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
# define ll long long int
bool sortinrev(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
       return (a.first > b.first);
}

ll query(ll tree[],ll index,ll qs,ll qe,ll s, ll e)
{
    if(qs<=s && e<=qe)
    {
      return tree[index];
    }

    if( e<qs || s>qe)
    {
      return 0;
    }

    ll mid=(s+e)/2;
    return max(query(tree,2*index,qs,qe,s,mid),query(tree,2*index+1,qs,qe,mid+1,e));
}


void build(ll tree[], ll s, ll e, ll index)
{
    if(s==e)
    {
      tree[index]=0;
    }
    else{
      int mid=(s+e)/2;
      build(tree,s,mid,2*index);
      build(tree,mid+1,e,2*index+1);
      tree[index]=max(tree[2*index] ,tree[2*index+1]);
    }
}

void update(ll tree[],ll s,ll e,ll value,ll hat,ll index)
{
  if(s==e)
  {
    //arr[value]=1;
    tree[index]+=hat;
  }
  else{
    ll mid=(s+e)/2;
    if(value<=mid)
    {
      update(tree,s,mid,value,hat,2*index);
    }
    else{
      update(tree,mid+1,e,value,hat,2*index+1);
    }
    tree[index]=max(tree[2*index],tree[2*index+1]);
  }

}


int main()
{
  ll n;
  cin>>n;
  ll height[n];
  ll value[200005];
  for(ll i=0;i<n;i++)
  {
    cin>>height[i];

  }
  for(ll i=0;i<n;i++)
  {
    cin>>value[height[i]];
  }

  ll tree[4*n+1];

  vector<pair<ll,ll>>v(n);
  for(ll i=0;i<n;i++)
  {
      v[i].first=height[i];
      v[i].second=i;
  }


build(tree, 0, n-1, 1);
//  sort(v.begin(),v.end());
sort(v.begin(), v.end(), sortinrev);

// for(int i=0;i<n;i++)
// {
//   cout<<v[i].first<<" "<<v[i].second<<endl;
// }
vector<ll>final;
for(ll i=0;i<n;i++)
{
    ll k= v[i].second;
    ll ans=query(tree,1,k,n-1,0, n-1);
    update(tree,0,n-1,k,ans+value[v[i].first],1);
    final.push_back(ans+value[v[i].first]);

}
ll bug= *max_element(final.begin(),final.end());
cout<<bug<<endl;

}


Measured memory_bytes: 15704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int		gcd(int a, int b);
int		gcdr(int a, int b);

int		main(void){
	int k;
	cin >> k;
	int a, b, c;
	a = 1;
	int		gcdt;
	int		sum;

	sum = 0;
	while (a <= k)
	{
		b = 1;
		while (b <= k)
		{
			gcdt = gcd(a, b);
			c = 1;
			while (c <= k)
			{
				sum += gcd(gcdt, c);
				c++;
			}
			b++;
		}
		a++;
	}		
	cout << sum << endl;
}

int		gcd(int a, int b)
{
	if (a < b)
		return (gcdr(b, a));
	return (gcdr(a, b));
}

int		gcdr(int a, int b)
{
	if (!b)
		return (a);
	return (gcdr(b, a % b));
}


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

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

int a[100];
for(int i=0;i<x;i++) cin>>a[i];

for(int i=0;i<x-1-i;i++) swap(a[i],a[x-1-i]);

for(int i=0;i<x;i++){
if(i) cout<<" ";
cout<<a[i];
}
cout<<endl;
return 0;
}




Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));
  if(A[0] == 0){
    cout << 0 << "\n";
    return 0;
  }

  int ans = 1;
  REP(i, N){
    if(A[i] > INF/ans){
      cout << -1 << "\n";
      return 0;
    }
    ans *= A[i];
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 3980
#include<cstdio>
#define int long long
int a,b,c,d,n;
signed main()
{
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&n);
	int w=a*8,x=b*4,y=c*2,z=d;
	if(z<=w&&z<=x&&z<=y)
	{
		int ans=n>>1;n&=1;
		if(!n)printf("%lld\n",ans*d);
		else if(w<=x&&w<=y)printf("%lld\n",ans*d+a*4);
		else if(x<=w&&x<=y)printf("%lld\n",ans*d+b*2);
		else printf("%lld\n",ans*d+c);
	}
	else if(w<=x&&w<=y&&w<=z)printf("%lld\n",a*4*n);
	else if(x<=w&&x<=y&&x<=z)printf("%lld\n",b*2*n);
	else printf("%lld\n",c*n);
	return 0;
}


Measured memory_bytes: 256
import sys
n, t = [int(i) for i in sys.stdin.readline().split()]
ls = []
for k in range(n):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    ls.append((a, b))
memo_ls = [[0 for i in range(t)] for j in range(n)]
another_memo_ls = [[-1 for i in range(t)] for j in range(n)]
ls = sorted(ls, key=lambda x:x[0])
a_ls, b_ls = zip(*ls)

for j in range(n):
    a, b = ls[j]
    for i in range(t):
        if j == 0:
            if a <= i:
                memo_ls[j][i] = b
                another_memo_ls[j][i] = j
            continue
        if a <= i:
            if memo_ls[j-1][i-a] + b > memo_ls[j-1][i]:
                memo_ls[j][i] = memo_ls[j-1][i-a] + b
                another_memo_ls[j][i] = j
            else:
                memo_ls[j][i] = memo_ls[j-1][i]
                another_memo_ls[j][i] = -1
        else:
            memo_ls[j][i] = memo_ls[j - 1][i]
            another_memo_ls[j][i] = -1
best = memo_ls[-1][-1]
for i in range(n-1):
    score = memo_ls[i][-1] + b_ls[i+1]
    best = max(best, score)
print(best)

Measured memory_bytes: 192392
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		mut h: usize,
		ab: [(usize, usize); n],
	}

	let mut a = vec![0; n];
	let mut b = vec![0; n];
	for i in 0..n {
		a[i] = ab[i].0;
		b[i] = ab[i].1;
	}

	a.sort();
	let amax = a[a.len()-1];

	let mut count = 0;
	b.sort_by_key(|&x| std::cmp::Reverse(x));
	for i in 0..b.len() {
		if b[i] < amax {
			break;
		}
		count += 1;
		if h <= b[i] {
			println!("{}", count);
			return;
		}
		h -= b[i];
	}

//	println!("h={}, count={}", h, count);

	count += (h-1)/amax + 1;
	println!("{}", count);
}



Measured memory_bytes: 7460
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <numeric>
#include <cfloat>

using namespace std;

#define MOD 1000000007

int main(int argc, char* argv[]){
  int N;
  cin >> N;

  vector<int> x(N);

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

  long long ans=1;
  int count = 1;

  for(int i=1; i<N; i++){
    count++;
    if(x[i] < 2*count-1){
      ans *= count;
      ans %= MOD;
      count--;
    }
  }
  for(int i=1; i<=count; i++){
    ans *= i;
    ans %= MOD;
  }

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

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long ll;

int L[MAX/2+2],R[MAX/2+2];

ll merge(int A[],int n, int left, int mid, int right){
    int i,j,k;
    ll cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i = 0; i<n1; i++){L[i] = A[left+i];}
    for (i = 0; i<n2;i++){R[i] = A[mid+i];}
    L[n1] = R[n2] = SENTINEL;
    i = j = 0;
    for (k = left;k<right;k++){
        if (L[i]<=R[j]){
            A[k] = L[i++];
            
        }
        else{
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

ll mergesort(int A[],int n,int left,int right){
    int mid;
    ll v1,v2,v3;
    if (left+1<right){
        mid = (left+right)/2;
        v1 = mergesort(A,n,left,mid);
        v2 = mergesort(A,n,mid,right);
        v3 = merge(A,n,left,mid,right);
        return v1+v2+v3;
    }
    else return 0;
}

int main(){
    int A[MAX],n,i;
    cin >> n;
    for (i =0;i<n;i++){
        cin >> A[i];
    }
    ll ans = mergesort(A,n,0,n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4680
#include<iostream>
#include<vector>
#include<map>
#include<sstream>
#include<cassert>

using namespace std;

typedef long long ll;

bool isnum(string s){
  for(int i = 0; i < s.length(); i++)
    if(s[i] < '0' || '9' < s[i]) return false;

  return true;
}

bool issep(string s){
  int p = 1;
  if(s[0] != '(') return false;
  for(int i = 1; i < s.length()-1; i++){
    if(s[i] == '(') p++;
    if(s[i] == ')') p--;
    if(p == 0) return false;
  }
  // cout << " test " << s[s.length()-1] << " " << p << endl;
  return ((s[s.length()-1] == ')') && (p == 1));
}

vector<ll> solve(string s){

  //  cout << "s " << s << endl;
  
  vector<ll> V;

  if(isnum(s)){
    stringstream ss(s);
    ll n;
    ss >> n;
    V.push_back(n);
    return V;
  }else if(issep(s)){
    return solve(s.substr(1,s.length()-2));
  }else{
    int para = 0;

    for(int i = 0; i < s.length(); i++){
      vector<ll> v1,v2;
      if(s[i] == '(') para++;
      if(s[i] == ')') para--;

      if(para == 0 && s[i] == '+'){
	v1 = solve(s.substr(0,i));
	v2 = solve(s.substr(i+1));

	for(int j = 0; j < v1.size(); j++)
	  for(int k = 0; k < v2.size(); k++)
	    V.push_back(v1[j]+v2[k]);
	  
      }

      if(para == 0 && s[i] == '-'){
	vector<ll> v1,v2;
	v1 = solve(s.substr(0,i));
	v2 = solve(s.substr(i+1));

	for(int j = 0; j < v1.size(); j++)
	  for(int k = 0; k < v2.size(); k++)
	    V.push_back(v1[j]-v2[k]);
      }

      if(para == 0 && s[i] == '*'){
	vector<ll> v1,v2;
	v1 = solve(s.substr(0,i));
	v2 = solve(s.substr(i+1));

	for(int j = 0; j < v1.size(); j++)
	  for(int k = 0; k < v2.size(); k++)
	    V.push_back(v1[j]*v2[k]);
      }

      if(para == 0 && s[i] == '/'){
	vector<ll> v1,v2;
	v1 = solve(s.substr(0,i));
	v2 = solve(s.substr(i+1));

	for(int j = 0; j < v1.size(); j++)
	  for(int k = 0; k < v2.size(); k++)
	    if(v2[k] != 0) V.push_back(v1[j]/v2[k]);

      }
    }
  }
  return V;
}

int main(){
  
  string in;
  while(getline(cin,in) && in != "#"){
    vector<ll> V = solve(in);
    map<ll,bool> M;
    ll ans = 0;
    for(int i = 0; i < V.size(); i++){
      if(M[V[i]] == false){
	M[V[i]] = true;
	ans++;
      }
    }
    
    cout << ans << endl;
  }
  return 0;
}

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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int a,b,x;

main() {
    cin >> a >> b >> x;
    if (a%x) a += x-a%x;
    if (b%x) b -= b%x;
    if(a>b) ct(0)
    else ct((b-a)/x+1)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string s, t; cin >> s >> t;
  bool ok = true;
  reverse(t.begin(), t.end());
  if (s != t) ok = false;
  reverse(t.begin(), t.end());
  reverse(s.begin(), s.end());
  if (s != t) ok = false;
  COUT( ok ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
N=int(input())
a = [[]*N]*N
for i in range(N):
    a[i]=input().rstrip().split()

#x+y > tの時は到達不可能
#x+yの偶奇とtが一致してなければ無理

bool = True


for i in range(0,N):
    if bool==False:
        break

    p=int(a[i][1])+int(a[i][2])
    q=int(a[i][0])
    if p>q:
        bool=False
    if p%2==0:
        if q%2!=0:
            bool=False
    else:
        if q%2==0:
            bool=False
        

if bool==True:
    print('Yes')

if bool==False:
    print('No')
        

Measured memory_bytes: 32168
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll p;cin>>p;
    string s;cin>>s;
    ll ans=0;
    if(p==2){
        rep(i,0,s.size()){
            int u=s[i]-'0';
            if(u%2==0)ans+=i+1;
        }
        cout<<ans<<endl;
        return 0;
    }
    else if(p==5){
        rep(i,0,s.size()){
            int u=s[i]-'0';
            if(u%5==0)ans+=i+1;
        }
        cout<<ans<<endl;
        return 0;
    }
    ll cnt[p];
    fill(cnt,cnt+p,0);
    ll sum=0;
    ll now=1;
    cnt[0]=1;
    rrep(i,n-1,0){
        ll u=s[i]-'0';
        sum+=now*u;
        sum%=p;
        ans+=cnt[sum];
        cnt[sum]++;
        now*=10;
        now%=p;
    }
    cout<<ans<<endl;
}








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

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int a,b,c;
    while(cin >> a >> b >> c){
        int ans = -1;
        rep(i,(a+b)*60){
            if(i%60==c){
                if(i%(a+b) <= a){
                    ans = i;
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef unsigned long long ll;


int main(void){
    int x;
    cin>>x;
    int i=0,count=0;
    while(1){
        ++i;
        count+=i;
        if(x<=count){
            cout<<i;
            return 0;
        }
    }
}
/*
1  1 >
2  2 ->
3  2 >>
4  3 >->
5  3 ->>
6  3 >>>
7  4 >>->
8  4 >->>
9  4 ->>>
10 4 >>>>
*/

Measured memory_bytes: 256