akhauriyash/Code-Regression huggingface dataset:
# -*- coding utf-8 -*-
import bisect
from collections import deque

N = int(input())

# c = [int(input())]
c = deque()
c.appendleft(int(input()))


for ai in range(1, N):
    a = int(input())
    if a <= c[0]:
        c.appendleft(a)
    else:
        i = bisect.bisect_left(c, a) - 1
        c[i] = a

print(len(c))

Measured memory_bytes: 7284
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : x)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
using namespace std;
signed main() {
    int n, m;
    cin >> n >> m;
    VE a;
    int al = 0;
    rep(i, n) {
        int enter;
        cin >> enter;
        a.pb(enter);
        al += enter;
    }
    sort(all(a), greater<int>());
    rep(i, m) {
        if(4 * m * a[i] < al) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main()
{
	int a[3];
	
	cin >> a[0] >> a[1] >> a[2];

	if (a[0] < a[1] && a[1] < a[2])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return (0);
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

struct range {
    int start;
    int end;
};

#define NUM_MAX 100000
#define NUM2_MAX  (1<<17)
#define QUERY_MAX 100000

enum type {
    COMMAND_ADD,
    COMMAND_FIND,
};

struct pair {
    int lazy;
    int val;
};

int is_overlap(struct range r1, struct range r2) {
    return r1.end > r2.start && r2.end > r1.start;
}

int is_contain(struct range this, struct range box) {
    return box.start <= this.start && this.end <= box.end;
}

#include <limits.h>
#define INF INT_MAX
void unlazy(struct pair *seg, int node, struct range nr) {
    int lazy = seg[node].lazy;
    seg[node].val += lazy;
    seg[node].lazy = 0;
    // propagate
    if(nr.end - nr.start > 1) {
        seg[node*2].lazy += lazy;
        seg[node*2+1].lazy += lazy;
    }
}

void add_range(struct pair *seg, int x, struct range r, int node, struct range nr) {
    unlazy(seg, node, nr);
    if(!is_overlap(r, nr)) return;
    if(is_contain(nr, r)) {
        seg[node].lazy += x;
        unlazy(seg, node, nr);
        return;
    }
    struct range left = { nr.start, (nr.start + nr.end)/2};
    struct range right = { (nr.start + nr.end)/2, nr.end};
    add_range(seg, x, r, node*2, left);
    add_range(seg, x, r, node*2+1, right);
    seg[node].val = min(seg[node*2].val, seg[node*2+1].val);
}

int find_min(struct pair *seg, struct range r, int node, struct range nr) {
    unlazy(seg, node, nr);
    if(!is_overlap(r, nr)) return INF;
    if(is_contain(nr, r)) {
        return seg[node].val;
    }
    struct range left = { nr.start, (nr.start + nr.end)/2};
    struct range right = { (nr.start + nr.end)/2, nr.end};
    int m1 = find_min(seg, r, node*2, left);
    int m2 = find_min(seg, r, node*2+1, right);
    return min(m1, m2);
}

#define ROOT_NODE 1
int main(void) {
    int num, queries;
    static int ans[QUERY_MAX];
    int aidx = 0;
    get_int2(&num, &queries);
    int num2 = 1;
    while(num > num2) num2 *= 2;

    // the initial values are 0
    static struct pair seg[NUM2_MAX*2];
    int q, i;
    struct range whole = {0, num2};
    for(q = 0; q < queries; q++) {
        int start, end;
        int type;
        get_int3(&type, &start, &end);
        // 0-indexed
        struct range r = {start, end+1};
        switch(type) {
            case COMMAND_ADD:
                {
                    int x = get_int();
                    add_range(seg, x, r, ROOT_NODE, whole);
                }
                break;
            case COMMAND_FIND:
                ans[aidx++] = find_min(seg, r, ROOT_NODE, whole);
                break;
            default:
                break;
        }
    }
    for(i = 0; i < aidx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


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

constexpr int INF = 1000000000;

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    vector<int> dict(n,INF),pre(n,-1);
    dict[0] = 0;
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        for(auto c : g[v]) {
            if(dict[c] != INF) {
                continue;
            }
            dict[c] = dict[v] + 1;
            pre[c] = v;
            q.push(c);
        }
    }
    cout << "Yes" << "\n";
    for(int i = 1; i < n; i++) {
        cout << pre[i] + 1 << "\n";
    }
    return 0;
}

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

int main(){
  int n,s,w,q;
  while(cin >> n >> s >> w >> q, n){
    vector<int> a(n);
    int g = s;
    rep(i,n){
      a[i] = (g/7) % 10;
      g = (g/2) ^ ((g%2)*w);
    }

    int ans = 0, non_zeros = 0;
    if(q==2 || q==5){
      rep(i,n){
	if(a[i])non_zeros++;
	if(a[i]%q == 0)ans += non_zeros;
      }
    }else{
      reverse(a.begin(),a.end());
      map<int,int> memo;
      memo[0] = 1;
      int rem = 0, k = 1;
      rep(i,n){
	rem = (rem + a[i] * k) % q;
	(k *= 10) %= q;
	if(a[i])ans += memo[rem];
	memo[rem]++;
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 5536
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
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 int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

int main(){
    int n;
     cin >> n;
     if (n%2==0) { cout << 0.5 << endl; }
     else { cout << (n/2+1)/double(n) << endl; }
}

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

double memo[3000][3000];

double dfs(vector<double> &p,ll index, ll ura_count){
    if(index >= p.size()){
        return 1.0;
    }
    if(memo[index][ura_count] != -1){
        return memo[index][ura_count];
    }

    double ret = 0;
    ret += dfs(p,index+1,ura_count) * p[index];
    if(ura_count < p.size()/2){
        ret += dfs(p,index+1,ura_count+1) * (1.0 - p[index]);
    }

    return memo[index][ura_count] = ret;
}

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

    ll n;
    cin >> n;
    vector<double> p(n);

    REP(i,n)cin >> p[i];
    REP(j,n)REP(i,n)memo[j][i] = -1;

    double ans = dfs(p,0,0);

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 70784
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p,int r){

	int x,i,j,t;
	x = A[r];
	i = p-1;
	for(j = p;j<r;j++){
		if(A[j] <= x){
		i++;
		t = A[i];
		A[i] = A[j];
		A[j] = t;
		}
	}
	
	t = A[i+1];
	A[i+1] = A[r];
	A[r] = t;
	return i+1;


}



int main(void){
	int i,q;

	scanf("%d",&n);
	for(i=0;i < n;i++){
	scanf("%d",&A[i]);
	}
	
	q = partition(0,n-1);
	
	for(i=0;i<n;i++){
	if(i>0)printf(" ");
	if(i == q)printf("[");
	printf("%d",A[i]);
	if(i == q)printf("]");
	}
	
	printf("\n");
	
	return 0;


}


Measured memory_bytes: 2108
# include <bits/stdc++.h>
///# include <ext/pb_ds/assoc_container.hpp>
///# include <ext/pb_ds/tree_policy.hpp>

///using namespace __gnu_pbds;
using namespace std;

# define ll long long
# define ld long double
# define pb push_back
# define ppb pop_back

const ll N = 1e5 + 10;
const ll M = 1e7 + 1000;
const ll mod = 998244353;
const ll INF = 1e18;
const ll inf = -1e18;

///typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> void_set;

bool isprime(ll x) {
    if(x == 1) return false;
    ll y = sqrt(x);
    for(int i = 2;i <= y;i++) {
        if(x % i == 0) {
            return false;
        }
    }
    return true;
}

ll bin_pow(ll a, ll b) {
    if(b == 0) return 1;
    if(b == 1) return a;
    if(a == 0) return 0;
    if(a == 1) return a;
    if(b % 2 == 0) {
        ll pw = bin_pow(a, b / 2);
        return pw * pw;
    } else {
        return bin_pow(a, b - 1) * a;
    }
}

const ld pi = acos(-1);

ll n;
double k;

int main() {
    ///ios_base::sync_with_stdio(false);
    ///cin.tie(NULL), cout.tie(NULL);
    ///setlocale(0,"RUS");
    ///ifstream cin("input.txt");
    ///ofstream cout("output.txt");
    cin >> n;
    k = (n / 2) + (n % 2 == 1);
    cout << fixed << setprecision(6) << (k / n);
}
/**
**/



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        // int n=sc.nextInt();
        char d[]=sc.nextString().toCharArray();
        int a=-1,c=-1,cc=0,x=0;
        for(int i=0; i<d.length; i++) {
            if(d[i]=='A'){a=i;}
            if(d[i]=='C'){c=i;}
            if('Z'>=d[i])x++;
        }
        String ans="WA";
db(a,c,x);
        if(a==0 && 2<=c && c<=d.length-2 && x==2){
            ans="AC";
        }

       
        out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return Integer.compare(d,p.d); //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 22612
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [list(map(int, input().split())) for _ in range(M)]
buy = [min(a)+min(b)]
for i in range(M):
  C = a[c[i][0]-1]+b[c[i][1]-1]-c[i][2]
  buy.append(C)
print(min(buy))


Measured memory_bytes: 101764
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    readln();
    auto T = aryread();
    long s = T.sum();
    long M;
    scan(M);
    foreach (_; 0 .. M)
    {
        long P, X;
        scan(P, X);
        writeln(s - T[P - 1] + X);
    }
}


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

const int INF = 1 << 30;

typedef struct
{
  int c, r;
} Subject;

int n, U;
Subject sub[20];
int memo[1 << 20];

int solve(int bit, int cnt)
{
  if (memo[bit] != -1)
    return memo[bit];

  if (cnt >= U) {
    memo[bit] = __builtin_popcount(bit);
    return memo[bit];
  }

  int ret = INF;
  for (int i = 0; i < n; ++i) {
    if (!(bit & (1 << i)) && (sub[i].r & bit) == sub[i].r)
      ret = min(ret, solve(bit | (1 << i), cnt+sub[i].c));
  }
  memo[bit] = ret;
  return ret;
}

int main()
{
  while (~scanf("%d %d", &n, &U)) {
    if (n == 0 && U == 0)
      break;

    for (int i = 0; i < (1 << 20); ++i)
      memo[i] = -1;

    for (int i = 0; i < n; ++i) {
      sub[i].r = 0;
      int k, r = 0;
      scanf("%d %d", &sub[i].c, &k);
      for (int j = 0; j < k; ++j) {
	int r;
	scanf("%d", &r);
	sub[i].r |= (1 << r);
      }
    }
    printf("%d\n", solve(0, 0));
  }
  return 0;
}

Measured memory_bytes: 4860
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
       int n=s.nextInt();
       double[] arr=new double[n+1];
       for(int i=1;i<=n;i++){arr[i]=s.nextDouble();}
        double[][] dp=new double[n+1][n+1];
      dp[0][0]=1;
      for(int i=1;i<=n;i++){
        dp[0][i]=dp[0][i-1]*(1-arr[i]);
      }
      for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
          if(i<=j){
            dp[i][j]=dp[i][j-1]*(1-arr[j])+dp[i-1][j-1]*arr[j];
          }
        }
      }
       double res=0;
       for(int i=n/2 +1;i<=n;i++){
        res+=dp[i][n];
       }
       System.out.println(res);
        }
    }


Measured memory_bytes: 122944
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    ll m = 0;
    Rep (i, N) {
        cin >> A[i];
        B[i] = A[i];
    }

    sort(B.begin(), B.end());
    Rep (i, N) {
        if (A[i] == B[N-1]) cout << B[N-2] << "\n";
        else cout << B[N-1] << "\n";
    }

}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a,b;
signed main(){
    cin>>n>>a>>b;
    init_fact();
    int ans=modpow(2,n)-1;
    int res=1;
    for(int i=n;i>n-a;i--){
        res*=i;
        res%=mod;
    }
    for(int i=1;i<=a;i++){
        res*=inv(i);
        res%=mod;
    }
    ans=(ans+mod-res)%mod;
    res=1;
    for(int i=n;i>n-b;i--){
        res*=i;
        res%=mod;
    }
    for(int i=1;i<=b;i++){
        res*=inv(i);
        res%=mod;
    }
    ans=(ans+mod-res)%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 15872
e = list(map(int,input().split()))
f = list(map(int,input().split()))
g = list(map(int,input().split()))

c = [e[0],e[1],e[2],f[0],f[1],f[2],g[0],g[1],g[2]]
d = [0,0,0,0,0,0,0,0,0]

n=int(input())

for i in range(n):
    b = int(input())
    for j in range(9):
        if c[j] == b:
            d[j] = 1

if (d[0]==1) and (d[1]==1) and (d[2]==1):
    print('Yes')
elif (d[3]==1) and (d[4]==1) and (d[5]==1):
    print('Yes')
elif (d[6]==1) and (d[7]==1) and (d[8]==1):
    print('Yes')
elif (d[0]==1) and (d[3]==1) and (d[6]==1):
    print('Yes')
elif (d[1]==1) and (d[4]==1) and (d[7]==1):
    print('Yes')
elif (d[2]==1) and (d[5]==1) and (d[8]==1):
    print('Yes')
elif (d[0]==1) and (d[4]==1) and (d[8]==1):
    print('Yes')
elif (d[2]==1) and (d[4]==1) and (d[6]==1):
    print('Yes')
else:
    print('No')    


Measured memory_bytes: 3188
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[15];

int main(){

	int A,B;

	scanf("%d %d",&A,&B);

	scanf("%s",buf);

	for(int i = 0; i < A+B+1; i++){

		if(i == A){

			if(buf[i] != '-'){

				printf("No\n");
				return 0;
			}

		}else{

			if(buf[i] < '0' || buf[i] > '9'){

				printf("No\n");
				return 0;
			}
		}
	}

	printf("Yes\n");

	return 0;
}


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

using namespace std;

int main()
{    
    int n;
    cin >> n;
    
    vector<int> c(n);
    
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        
        c[a-1]++;
    }
    
    sort(c.rbegin(), c.rend());
    
    vector<int> d(n + 1);
    
    int j = n - 1;
    int tot = 0;
    for (int i = 1; i <= n; i++) {
        while(j >= 0 && c[j] <= i) {
            tot += c[j];
            j--;
        }
        
        d[i] = ((j + 1) * i + tot) / i;
    }
    
    for (int i = 1; i <= n; i++) {
        int ok = 0, ng = n + 1;
        
        while(ng - ok > 1) {
            int m = (ok + ng) / 2;
            
            if (d[m] >= i) {
                ok = m;   
            } else {
                ng = m;
            }
        }
        
        cout << ok << endl;
    }
}


Measured memory_bytes: 3200
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define LL long long
#define N 110000
using namespace std;
int n;
LL a[N],d[N],k;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {scanf("%lld",&a[i]);k+=a[i];}
	LL t=1ll*n*(n+1)/2;
	if(k%t) {printf("NO\n");return 0;}
	k/=t;
	a[0]=a[n];
	for(int i=1;i<=n;i++) d[i]=a[i]-a[i-1];
	t=0;
	for(int i=1;i<=n;i++)
	{
		LL tmp=k-d[i];
		if(tmp<0 || tmp%n) {printf("NO\n");return 0;}
		t+=tmp/n;
	}
	if(t!=k) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
//const int MOD=1000000007;

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

int MOD;

int mod_inv(int X){
	int a = X, b = MOD, u = 1, v = 0;
	while(b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if(u < 0) u += MOD;
	return u;
}

vector<int> mul(vector<int> v1,vector<int> v2){
	int n = v1.size(),m = v2.size();
	vector<int> ret(n + m - 1);
	for(int i = 0;i < n;i++){
		for(int j = 0;j < m;j++){
			(ret[i + j] += v1[i] * v2[j]) %= MOD;
		}
	}
	return ret;
}

vector<int> div(vector<int> v1,vector<int> v2){
	int n = v1.size(),m = v2.size();
	vector<int> ret;
	for(int i = n - m;i >= 0;i--){
		ret.pb(v1[i + m - 1] * mod_inv(v2.back()) % MOD);
		for(int j = 0;j < m;j++){
			v1[i + j] = (v1[i + j] - v2[j] * ret.back() % MOD + MOD) % MOD;
		}
	}
	reverse(all(ret));
	return ret;
}

int f(vector<int> v,int x){
	int ret = 0,xpow = 1;
	for(int i = 0;i < v.size();i++){
		(ret += xpow * v[i]) %= MOD;
		(xpow *= x) %= MOD;
	}
	return ret;
}

signed main(){
	int n,a[3010];
	cin >> n;
	MOD = n;
	for(int i = 0;i < n;i++) cin >> a[i];
	vector<int> fact = {1},ans(n);
	for(int i = 0;i < n;i++){
		vector<int> tmp;
		tmp.pb(i); tmp.pb(1);
		fact = mul(fact,vector<int>{i,1});
	}
	for(int i = 0;i < n;i++){
		vector<int> tmp = div(fact,vector<int>{(MOD - i) % MOD,1});
		//for(int v : tmp) cout << v << " ";
		//cout << endl;
		if(a[i]){
			int multiplier = mod_inv(f(tmp,i));
			for(int j = 0;j < n;j++) (ans[j] += multiplier * tmp[j]) %= MOD;
		}
	}
	for(int i = 0;i < n;i++) cout << (i ? " " : "") << ans[i];
	cout << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N ,D;
    cin >> N >> D;
    vector<vector<int> > X(N,vector<int>(D)) ;
    for (int i= 0; i < N ;i++){
    for (int j= 0; j < D ;j++){
        cin >> X[i][j];
    }    
    }
    int ans=0;
    for (int i= 0; i < N ;i++){
    for (int j =i+1 ; j < N ;j++){
        int norm=0;
        for (int k= 0; k < D ;k++){
        int diff = abs(X[i][k]-X[j][k]);
        norm += diff * diff;
    }    
    bool flag=false;
    for (int k= 0; k <=norm; k++){
        if (k*k == norm){
            flag = true;
        }
    }
    if (flag){
        ans++;
    }    
    }}
    cout << ans << endl;
}


Measured memory_bytes: 256
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, p[200010], pos[200010];

// Range Minimum Query (区間最小クエリ、RMQ)
// Verified: AOJ DSL_2_A: Range Minimum Query (int型のみ)

template <typename T>
class rmq {
public:
    int n;
    vector<T> dat;

    // 要素数 m の RMQ を作る
    void resize(int m) {
        n = 1;
        while(n < m) n *= 2;
        dat.resize(2*n-1);
        rep(i,0,2*n-1) dat[i] = INT_MAX;
    }

    // k番目 (0-indexed) の値を a に更新
    void update(int k, T a) {
        k += n - 1;
        dat[k] = a;
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }

    // [a, b) の最小値を返す
    // 最初に呼び出すときは XX.query(a, b, 0, 0, -1) とする
    T query(int a, int b, int k, int l, int r) {
        if(r == -1) r = n;
        if(r <= a || b <= l) return INT_MAX;
        if(a <= l && r <= b) return dat[k];
        else {
            T vl = query(a, b, k*2+1, l, (l+r)/2);
            T vr = query(a, b, k*2+2, (l+r)/2, r);
            return min(vl, vr);
        }
    }
};

vector<pii> ans;
rmq<int> even, odd;
struct Elem {
    int x, y, val;
};
bool operator<(const Elem &a, const Elem &b) {
    return a.val > b.val;
}

// position [l, r)
void solve() {
    priority_queue<Elem> q;
    q.push(Elem{0, N, even.query(0, N, 0, 0, -1)});

    while(!q.empty()) {
        Elem t = q.top(); q.pop();
        int l = t.x, r = t.y;
        int mi = pos[(l%2 ? odd : even).query(l, r, 0, 0, -1)];
        int ma = pos[(l%2 ? even: odd).query(mi, r, 0, 0, -1)];
        ans.push_back(pii(p[mi], p[ma]));

        if(l < mi) q.push(Elem{l, mi, (l%2 ? odd : even).query(l, mi, 0, 0, -1)});
        if(mi+1 < ma) q.push(Elem{mi+1, ma, ((mi+1)%2 ? odd : even).query(mi+1, ma, 0, 0, -1)});
        if(ma+1 < r) q.push(Elem{ma+1, r, ((ma+1)%2 ? odd : even).query(ma+1, r, 0, 0, -1)});
    }
}

signed main() {
    cin >> N;
    even.resize(N), odd.resize(N);
    rep(i,0,N) {
        cin >> p[i];
        pos[ p[i] ] = i;
        if(i % 2) odd.update(i, p[i]);
        else even.update(i, p[i]);
    }
    solve();
    rep(i,0,ans.size()) {
        if(i != 0) cout << " ";
        printf("%lld %lld", ans[i].first, ans[i].second);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 14884
count = 0 

def merge(data, left, mid, right):
    global count
    n1 = mid - left
    n2 = right - mid 
    L = data[left : mid]
    R = data[mid : right]
    L.append(float('inf'))
    R.append(float('inf'))
    i = 0 
    j = 0 
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            data[k] = L[i]
            i += 1
        else:
            data[k] = R[j]
            j += 1

def merge_sort(data, left, right):
    if left + 1 < right:
        mid = (left + right) / 2 
        merge_sort(data, left, mid)
        merge_sort(data, mid, right)
        merge(data, left, mid, right)

def main():
    num = raw_input()
    num_list = raw_input().split()
    num_list = map(int, num_list)
    merge_sort(num_list, 0, len(num_list))
    num_list =  map(str, num_list)
    print " ".join(num_list)
    print count

if __name__ == '__main__':
    main()

Measured memory_bytes: 71028
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <bits/stdc++.h>
using namespace std;
/*inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}*/
int main()
{
    char s[200008];
    int a[100005];
    int n,q;
    cin>>n>>q;
    for(int i=1;i<=n;i++)
        cin>>s[i];
    int sum=0;
    for(int i=1;i<n;i++)
    {
        if(s[i]=='A'&&s[i+1]=='C')
        sum++;
        a[i+1]=sum;
    }
    while(q--)
    {
        int l,r;
        cin>>l>>r;
      cout<<a[r]-a[l]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#define TEST_MODE true
 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;		\
                               c > 0 ? i < b : i > b;	\
                               i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) a.begin(), a.end()
#define ifnot(a) if (not(a))
#define int long long
 
#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x) << " "
#define dumpl(x) cerr << #x << " = " << (x) << " " << endl;
#else
const bool test = false;
#define dump(x) 
#define dumpl(x) 
#endif
 
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }
 
//.....................
const int MAX = (int)2e5 + 5;
 
vector<string> split(const string &str, char sep)
{
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep))
    {
      v.push_back(buffer);
    }
  return v;
}
 
template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
  return accumulate(begin, end, 0ll);
}
 
template<typename T>
T gcd(T a, T b)
{
  T c;
  while (a != 0) {
    c = a; a = b%a;  b = c;
  }
  return b;
}

int pow(int a, int b) {
  int res = 1;
  rep(i, b) res *= a;
  return res;
}
 
class Solver {
public:
  string s;

  void solve() {
    cin >> s;
    sort(all(s));
    string res = (s == "abc" ? "Yes" : "No");
    cout << res << endl;
  }
};
 
signed main()
{
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  // while (true) {    
  //     auto ptr = new Solver();
  //     ptr->solve();
  //     delete ptr;
  // }
  return 0;
}
 
// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;
 
// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;
 
// #define cin mycin
// #define cout mycout
// #define endl '\n'


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;


int main(){
	ll x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl;
}



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

using namespace std;


int N;
vector<int> P,Pd;

int main()
{

	cin >> N;
	P = vector<int>(N + 1);
	Pd = vector<int>(N + 1);


	for (int i = 1;i<=N;i++) {
		cin >> P[i];
		Pd[P[i]] =i;
	}

	long long ans = 0;

	multiset<int> s;
	s.insert(0);
	s.insert(0);
	s.insert(N + 1);
	s.insert(N + 1);

	for (int i = N; i > 0; i--) {

		s.insert(Pd[i]);
		auto il = s.find(Pd[i]);
		auto ir = il;

		long long l1 = *(--il);
		long long l2 = *(--il);
		long long r1 = *(++ir);
		long long r2 = *(++ir);

		long long ls = (l1 - l2) * (r1 - Pd[i]);
		long long rs = (r2 - r1) * (Pd[i] - l1);

		ans += (ls + rs) * i;

	}


	cout << ans << endl;

	return 0;
}


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

line=[]

for i in range(n):
    a,b=map(int,input().split( ))
    line.append((b,a))

line.sort()

s=0
t=0

for i in range(n):
    t=line[i][0]
    s+=line[i][1]
    if s>t:
        print('No')
        break
    if i==n-1:
        print('Yes')

Measured memory_bytes: 65880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC106_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var primeList = new List<int>();
            var ans = 0;
            if (N > 1)
            {
                primeList = Prime(N);
            }
            for (int i = 1; i <= N; i++)
            {
                var divisor = 1;
                for (int j = 1; j < primeList.Count && primeList[j] <= i; j++) //Nは奇数であるため素数の2はあらかじめ除く
                {
                    var dividCount = 0;
                    var nowNum = i;
                    bool dividOn = false;
                    while (nowNum % primeList[j] == 0)
                    {
                        dividOn = true; //一度でも割り切れるとき、約数に+1する
                        nowNum /= primeList[j];
                        dividCount++;
                    }
                    if (dividOn)
                    {
                        divisor *= dividCount + 1;
                    }
                }
                if (divisor == 8)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
        static List<int> Prime(int n)
        {
            var primeArray = new List<int>();
            if (n == 2)
            {
                primeArray.Add(2);
                return primeArray;
            }
            primeArray.Add(2);
            for (int i = 3; i <= n; i++)
            {
                if (i % 2 != 0)
                {
                    bool divid = false;
                    foreach (var PrePrime in primeArray)
                    {
                        if (i % PrePrime == 0)
                        {
                            divid = true;
                        }
                    }
                    if (!divid)
                    {
                        primeArray.Add(i);
                    }

                }
            }
            return primeArray;
        }
    }
}


Measured memory_bytes: 13268
from functools import reduce
n = list(map(int,input().split()))
ans = 0
for i in range(n[0]+1):
  s = list(map(int,str(i)))
  sum = reduce(lambda a,b: a+b, s)
  if n[1]<= sum and sum <= n[2]:
    ans+=i
print(ans)

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
bool prime[100005];
int cnt[100005];
int main(void)
{
    memset(prime,0,sizeof(prime));
    for(int i = 2;i < 1000;i++)
    {
        for(int j = i;(i*j) <= 100000;j++)
        {
            prime[i*j] = true;
        }
    }
    memset(cnt,0,sizeof(cnt));
    prime[1] = true;
    for(int i = 2;i <= 100000;i++)
    {
        if(!prime[i]&&!prime[(i+1)/2])
        {
            cnt[i] = 1;
        }
    }
    for(int i = 2;i <= 100000;i++)
    {
        cnt[i] += cnt[i-1];
    }
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int l,r;
        scanf("%d %d",&l,&r);
        printf("%d\n",cnt[r] - cnt[l-1]);
    }
    return 0;
}


Measured memory_bytes: 1152
# ＤＦＳ, パターン列挙_各竹の使用パターンを列挙

n, a, b, c = map(int, input().split())
l = [int(input()) for _ in range(n)]

stack = [[0],[1],[2],[-1]]

ans = 10**9
while stack:
    tmp = stack.pop()
    if len(tmp) == n:
        if 0 not in tmp or 1 not in tmp or 2 not in tmp:
            continue
        abc = [0, 0, 0, -30]
        for j in range(n):
            if tmp[j] >= 0:
                abc[tmp[j]] += l[j]
                abc[3] += 10
        mp = abc[3]
        mp += abs(abc[0] - a)
        mp += abs(abc[1] - b)
        mp += abs(abc[2] - c)
        ans = min(ans, mp)

    elif len(tmp) < n:
        w = tmp + [0]
        x = tmp + [1]
        y = tmp + [2]
        z = tmp + [-1]
        stack += [w, x, y, z]

print(ans)


Measured memory_bytes: 3188
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
  
    result = 0
    for a in range(1, x // 3):
        for b in range(a + 1,  x // 2):
            c = x - a - b
            if b < c <= n:
                result += 1    
    print(result)

Measured memory_bytes: 7700
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i=0; i<n; i++){
	  cin >> a[i];
  }
  
  long long result = 0;
  long long _max = a[0];

  for(int i=1; i<n; i++){
    //cout << "xx " << a[i] << endl;
    if(a[i] < _max){
      result += _max - a[i];
      //cout << "Add: " << a[i] << " + " << _max - a[i] << endl;
    }else{
      _max = a[i];      
    }
  }
  
  cout << result << endl;
  return 0;
}


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

int main()
{
    int H, W;

    cin >> H >> W;

    vector<string> a(H);

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

    vector<bool> row(H, false);
    vector<bool> col(W, false);
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (a.at(i).at(j) == '#')
            {
                row.at(i) = true;
                col.at(j) = true;
            }
        }
        
    }

    for (int i = 0; i < H; i++)
    {
        if(row.at(i))
        {
            for (int j = 0; j < W; j++)
            {
                if (col.at(j))
                {
                    cout << a.at(i).at(j);
                }
            }
            cout << endl; 
        }
    }
    
       
}


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

int main(){
    // 制約見て！！！デカかったらlong longにすること！

    int N;
    cin >> N;
    int p[N];
    int maxim = -1;
    int sum = 0;
    rep(i,N){
        cin >> p[i];
        if(maxim < p[i]){
            maxim = p[i];
        }
        sum +=p[i];
    }
    sum -= maxim / 2;
    cout << sum<<endl;
}

Measured memory_bytes: 3644
A,B,C = map(int,input().split())

L = []
l = set(L)
M = A%B
l.add(M)
i = 2
while True:
  if M*i%B == C:
    print("YES")
    break
  else:
    if M*i%B in l:
      print("NO")
      break
    else:
      l.add(M*i%B)
  i += 1
      
    
  
  
  

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  rep(i,N)cin >> d.at(i);

  sort(d.begin(),d.end());
  int K = d.at(N/2) - d.at(N/2-1);

  cout << K << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
using namespace std;
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v) for (auto i : v)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second
#define setp(x) setprecision(x)
#define mset(m, v) memset(m, v, sizeof(m))
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

//static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//#define int ll

int main() { 
        string a, b, c;
        cin >> a >> b >> c;
        puts(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0] ? "YES" : "NO");
        return 0;
}



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

int main(void){
  int r, g, b, N;
  int nr,ng,nb;
  int c[3];
  int a = 0;

  cin >> c[0] >> c[1] >> c[2] >> N;
  sort(c,c+3);
  r = c[2];
  g = c[1];
  b = c[0];

  for(nr = 0; nr < (N/r)+1;nr++)
    for(ng = 0;ng < (N/g)+1;ng++)
      if( (N -r*nr - g*ng)%b == 0 && (N -r*nr - g*ng) >= 0){
        a++;
      }

  cout << a << endl;
}



Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

N = int(input())
xs = list(map(int, input().split()))
L = int(input())
Q = int(input())
ABs = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(Q)]

logN = ((N-1).bit_length())
parentss = [[N-1]*(logN+1) for _ in range(N)]
for i in range(N-1):
    iL = bisect_right(xs, xs[i]+L)
    parentss[i][0] = iL-1

for d in range(1, logN+1):
    for i in range(N-1):
        parentss[i][d] = parentss[parentss[i][d-1]][d-1]

anss = []
for A, B in ABs:
    if A > B:
        A, B = B, A
    i = A
    ans = 1
    for d in reversed(range(logN+1)):
        if parentss[i][d] < B:
            i = parentss[i][d]
            ans += 2**d
    anss.append(ans)

print('\n'.join(map(str, anss)))


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

int main(){

int n = 0, a = 0, b = 0; cin >> n >> a >> b;

int x =  abs (a-b);

if (x >= 1) x-=1;
else x = 0;

if (x%2 == 0) cout << "Borys" << endl;
else cout << "Alice" << endl;


return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=998244353, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

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() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, s;
    cin >> n >> s;
    ll a[n+1];
    for(int i=1;i<=n;i++){
    	cin >> a[i];
    }
    vector<vector<ll> > dp(n+1, vector<ll> (s+1, 0));
    dp[0][0] = modpow(2LL, n);
    for(int i=1;i<=n;i++){
    	for(int j=0;j<=s;j++){
    		if(j>=a[i]) dp[i][j] += (dp[i-1][j - a[i]] * modpow(2LL, mod - 2)) % mod;
    		dp[i][j] %= mod;
    		dp[i][j] += dp[i-1][j];
    		dp[i][j] %= mod;
    	}
    }
    cout << dp[n][s] << endl;
    return 0;
}


Measured memory_bytes: 73660
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
const ll MAX = 2000010;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void init_ncr() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll modncr(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    init_ncr();
    ll K; cin >> K;
    string S; cin >> S;
    ll L = S.size();

    ll sum = 0;
    for (int x = 0; x <= K; x++) {
        ll tmp = 0;
        tmp = modncr(L-1 + K-x, L-1) * modpow(25, K-x, MOD) % MOD;
        tmp = tmp * modpow(26, x, MOD) % MOD;
        sum = (sum + tmp) % MOD;
    }
    cout << sum << endl;
}


Measured memory_bytes: 52148
// Airport Bus
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    for (int i = 0; i < N; i++) cin >> T[i];
    sort(T.begin(), T.end());

    int bus = 0;
    for (int i = 0; i < N;) {
        int j = 0;
        while (j < C) {
            if (T[i+j] - T[i] <= K) {
                j++;
            } else {
                break;
            }
        }
        bus++;
        i += j;
    }
    cout << bus << endl;
}

Measured memory_bytes: 640
n, a, b = list(map(int, input().split(' ')))
blueBall = 0
answer = []

if a == 0:
    print(a)
else:
    if n / (a + b):
        answer = divmod(n, (a + b))
        blueBall = answer[0] * a
        if answer[1] > a:
            blueBall = blueBall + a
        else:
            blueBall = blueBall + answer[1]

        print(blueBall)
    else:
        if n <= a:
            print(n)
        elif n <= b:
            print(a)


Measured memory_bytes: 3060
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<set>
#include<regex>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<map>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
  
    int a, b, k;
    cin >> a >> b >> k;
    map<int, int> v;
    for(int i = a; i < min(a + k, b); ++i) {
        cout << i << endl;
        ++v[i];
    }
    for(int i = max(a, b - k + 1); i <= b; ++i) {
        if(v[i] == 0)
            cout << i << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main implements Runnable{
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException{
        new Thread(null, new Main(), "", 32 * 1024 * 1024).start();
        Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        out.flush();
    }
    public void run() {
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());
        while(true){
            C = C - B;
            if(C <= 0){
                System.out.println("Yes");
                break;
            }else{

            }
            A = A - D;
            if(A <= 0){
                System.out.println("No");
                break;
            }else{

            }
        }
    }
} 

Measured memory_bytes: 35696