akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <cmath>
#include <chrono>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, ll> P;
struct edge { ll to, cost; };

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

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}



struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

/*int V;
vector<edge> G[MAX_V];
int d[MAX_V]:
void dijkstra(int s) {
priority_queue<P, vector<P>, greater<P>> q;
fill(d, d + V, INF);


}*/
#define MAX 200001

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

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

ll p[100001];
ll q[100001];
ll bo[200001];
int main(void) {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int 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 n, a, b, c;
	cin >> n >> a >> b >> c;
	bo[0] = 1;
	p[0] = 1;
	q[0] = 1;
	REP(i, 200000) bo[i + 1] = (bo[i] * (a+b)) % MOD;
	REP(i, 100000) {
		p[i + 1] = (p[i] * a) % MOD;
		q[i + 1] = (q[i] * b) % MOD;
	}
	ll res = 0;
	REP(i, n) {
		res += (((((p[n] * q[i]) % MOD)*(n + i)) % MOD*bo[n - i]) % MOD*COM(n + i - 1, i)) % MOD;
		res += (((((q[n] * p[i]) % MOD)*(n + i)) % MOD*bo[n - i]) % MOD*COM(n + i - 1, i)) % MOD;
		res %= MOD;
	}
	res *= minv(bo[2 * n]);
	res %= MOD;
	res *= 100;
	res %= MOD;
	res *= minv(100-c);
	res %= MOD;
	cout << res;
	return 0;
}


Measured memory_bytes: 8064
n = int(input())
A = []
cnt = 0
for i in range(n):
    a = int(input())
    A.append(a)
for i in range(1, n+1):
    if i == 1:
        now = A[i-1]
        cnt += 1
        if now == 2:
            print(cnt)
            exit()
    else:
        now = A[now-1]
        cnt += 1
        if now == 2:
            print(cnt)
            exit()
print(-1)

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    int n = 100*a+10*b+c;
    if(n%4==0)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

bool simu(ll point, vec E){
    if(E.size() == 0) return point == 0;
    ll sum = 0, es = E.size();
    rep(i, es) sum += E[i];
    vector<vector<bool> > dp(es+1, vector<bool>(sum+1,false));
    dp[0][0] = true;
    reps(i,1,es+1){
        rep(j,sum+1){
            dp[i][j] = dp[i-1][j];
            if(j >= E[i-1]){
                dp[i][j] = dp[i][j] || dp[i-1][j - E[i-1]];
            }
        }
    }
    return ((point&1) == (sum&1)) && dp[es][(sum + point)/2];
}

int main() {
    ll X, Y;
    cin >> S>>X>>Y;
    S.push_back('T');
    N = S.size();
    mat xy(2,vec(0));
    bool ify = false;
    ll I = 0;
    rep(i,N){
        if(S[i] == 'T'){
            X -= i;
            I = i;
            break;
        }
    }
    ll temp = 0;
    reps(i,I,N){
        if(S[i] == 'T'){
            if(temp != 0) xy[ify].push_back(temp);
            ify ^= 1;
            temp = 0;
        }else{
            ++temp;
        }
    }
    /*rep(i,2){
        rep(j,xy[i].size()) cout<<xy[i][j]<<' ';
        cout<<endl;
    }
    cout<<simu(abs(X), xy[0])<<' '<<simu(abs(Y), xy[1])<<endl;*/
    cout<<(simu(abs(X), xy[0]) && simu(abs(Y), xy[1]) ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int N, K;
    long long ans=0;
    cin >> N >> K;
    vector<long long> H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    sort(H.begin(), H.end());
    for(int i=0; i<N-K; i++){
        cin >> H[i];
        ans+=H[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var x = int.Parse(Console.ReadLine());
        for (int k = 1; true; k++)
        {
            if (x * k % 360 == 0)
            {
                Console.WriteLine(k);
                return;
            }
        }
    }
}

Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
int N;
int a,b,c;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin>>N;
    while(N--){
        int x;
        cin>>x;
        if(x%4==0)a++;
        else if(x%2==0)b++;
        else c++;
    }
    if(b==0){
        if(a>=c-1)cout<<"Yes";
        else cout<<"No";
    }
    else{
        if(a>=c)cout<<"Yes";
        else cout<<"No";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll ans=0;
    string s; cin>>s;
    rep1(L,N-1){
        ll tmp=0;
        rep(i,N-L){
            if(s[i]==s[i+L]){
                tmp++;
                chmax(ans,min(L,tmp));
            }
            else tmp=0;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<map>

using namespace std;

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

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

    long long r;
    long long a;
    long long sum =0;
    for(int i=0;i<N;i++){
        a = 0;
        r = 0;
        for(int j=0;j<i;j++){
            if(A[i] > A[j]) a++;
        }
        for(int j=i+1;j<N;j++){
            if(A[i] > A[j]){
                a++;
                r++;
            }
        }
        sum += (r*K%1000000007 + K*(K-1)/2%1000000007*a%1000000007)%1000000007;
    }
    cout << sum%1000000007 << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,i;

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

    cout<<N-i+1<<endl;
}

Measured memory_bytes: 256
import Foundation

/*
// 1
let N = Int(readLine()!)!

// 1 2
let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let S = Int(split[1])!

// 1 2 3 4 5
let array = readLine()!.componentsSeparatedByString(" ").map { Int($0)! }
*/

let split = readLine()!.componentsSeparatedByString(" ")
let N = Int(split[0])!
let R = Int(split[1])!

if N < 10 {
  print(R + (100 * (10 - N)))
} else {
  print(R)
}  

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int K;
    string S; 
    cin>>K>>S;
    if(S.size() <= K) cout << S << endl;
    else{
        REP(i, 0, K) cout << S[i];
        cout << "...";
        cout << endl;
    }

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX_N = 1<<17;

ll mod;
class BIT2{
public:
  int n;
  ll bit0[MAX_N+1],bit1[MAX_N+1];//1????????????

  BIT2(){n = MAX_N;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  BIT2(int n){this->n=n;memset(bit0,0,sizeof(bit0));memset(bit1,0,sizeof(bit1));}
  
  ll sum(ll *b,int i){
    ll s=0;
    while(i>0){
      s=(s+b[i])%mod;
      i-=i&-i;
    }
    return s;
  }

  void add(ll *b,int i,ll v){
    while(i<=n){
      b[i]=(b[i]+v)%mod;
      i+=i&-i;
    }
  }

  //[a,b]???x?????????(1<=a)
  void add (int a,int b,ll x){
    add(bit0,a,-x*(a-1));
    add(bit1,a,x);
    add(bit0,b+1,x*b);
    add(bit1,b+1,-x);
  }

  //[a,b]???sum?????????(1<=a)
  ll sum(int a,int b){
    ll res=0;
    res+=sum(bit0,b)+sum(bit1,b)*b;
    res-=sum(bit0,a-1)+sum(bit1,a-1)*(a-1);
    return (res+mod)%mod;    
  }
};

string i2S(ll num){
  string res;
  if(num==0)return "0";
  while(num) res=(char)(num%10+'0')+res,num/=10;
  return res;
}

int main(){
  while(1){
    ll A,B;
    cin>>A>>B>>mod;
    if(!A&&!B&&!mod)return 0;
    vector<string> num;
    for(ll i=A;i<=B;i++)num.push_back(i2S(i));
    sort(num.begin(),num.end());
  
    ll ans = 0, n = B-A+2;
    BIT2 T(n);
    T.add(1,n,1);
    
    for(ll i=A;i<=B;i++){
      int idx = lower_bound(num.begin(),num.end(),i2S(i))-num.begin()+1;
      ll val = T.sum(idx,idx);
      ans=(ans+val)%mod;
      T.add(idx,n,val);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 10536
let rec for_fold a b v f = if a > b then v else for_fold (a+1) b (f a v) f
let rec drop n = function [] -> [] | x::xs -> if n = 0 then x::xs else drop (n-1) xs
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  if n*(n-1)/2 - k < n-1 then print_endline "-1" else begin
    Printf.printf "%d\n" (n*(n-1)/2 - k);
    for_fold 1 n [] (fun i g -> (for_fold (i+1) n g (fun j g -> (j, i) :: g)))
    |> drop k |> List.iter (fun (a, b) -> Printf.printf "%d %d\n" a b)
  end

Measured memory_bytes: 2304
#include<stdio.h>
int main(){
    
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b && b<c && c>a){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}



Measured memory_bytes: 2704
n, k = [int(v) for v in input().split()]
r, s, p = [int(v) for v in input().split()]
t = input()


def get(seq, i):
    if i < 0:
        return None
    if i >= len(seq):
        return None
    return seq[i]

def get_win(c):
    if c == 'r':
        return 'p'
    elif c == 's':
        return 'r'
    else: # 'p'
        return 's'

def get_score(c):
    if c == 'r':
        return r 
    elif c == 's':
        return s
    else: # 'p':
        return p

score = 0
seq = [None] * n
for i in range(n):

    ti = t[i]
    win = get_win(ti)
    prev = get(seq, i-k)
    if win != prev:
        score += get_score(win)
        seq[i] = win
        continue

    n = get(t, i+k)
    if n is None:
        seq[i] = ti
    else:
        if prev is None:
            seq[i] = list(set('rsp') - set(n))[0]
        else:
            seq[i] = list(set('rsp') - set(n) - set(prev))
        
print(score)

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

#define llu             unsigned long long int
#define ll              long long int
#define s(n)            scanf("%lld",&n)
#define p(n)            printf("%lld\n",n)
#define f0(i, n)        for( i = 0 ; i <  n ; i++ )
#define f1(i, n)        for( i = 1 ; i <= n ; i++ )
#define ff(i, m, n)     for( i = m ; i <= n ; i++ )
#define sp(i)           fixed << setprecision( i )
#define pb              push_back
#define pf              push_front
#define nl              cout<<"\n";

///ELIN75ELIN75ELIN75ELIN75ELIN75ELIN75ELIN75ELIN75ELIN75
///                    ELIN(K-5)
///ELIN47ELIN47ELIN47ELIN47ELIN47ELIN47ELIN47ELIN47ELIN47

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

    ll n,i,j,k,a=0,b=0,c=0,s=0;
    string e;
    cin>>n>>e;
    f0(i,n)
    if(e[i]=='R') a++;
    else if(e[i]=='G') b++;
    else if(e[i]=='B') c++;
    s=a*b*c;
    f0(i,n-1) for(j=i-1,k=i+1;j>=0 && k<n;j--,k++)
    if(e[i]!=e[j] && e[j]!=e[k] && e[k]!=e[i]) s--;
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
const int MAXN=3e3+7;
int n;
double ans,p[MAXN],f[MAXN][MAXN];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>p[i];
	f[0][0]=1.0;
	for(int i=1;i<=n;i++)
	{
		f[i][0]=f[i-1][0]*(1-p[i]);
		for(int j=1;j<=n;j++)
			f[i][j]=f[i-1][j]*(1-p[i])+f[i-1][j-1]*p[i];
	}
	for(int i=n/2+1;i<=n;i++) ans+=f[n][i];
	printf("%.10lf",ans);
	return 0;
}

Measured memory_bytes: 74248
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    int a,b,c;
    cin >> a>>b>>c;
    int s = min(a,b);
    int l = max(a,b);
    if(s<c&&c<l){
        cout<< "Yes";
    }else{
        cout<< "No";
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c,d;
  int f,e;
  cin>>a>>b>>c>>d;
  f=c-a,e=d-b;
  cout<<c-e<<" "<<d+f<<" "<<a-e<<" "<<f+b<<"\n";
}
  


Measured memory_bytes: 256
#Coding:Utf-8
import sys
input=sys.stdin.readline
from heapq import heappop,heapify

N,K=map(int,input().split())
h=list(map(int,input().split()))

for i in range(N):
    h[i]=0-h[i]
heapify(h)
ans=0

while ans!=N:
    if heappop(h)<=(-K):
        ans+=1
    else:
        break

print(ans)


Measured memory_bytes: 12004
import java.math.BigDecimal;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){
 
		Scanner sc = new Scanner(System.in);
 
		// 整数の入力
		BigDecimal a = sc.nextBigDecimal();
		BigDecimal b = sc.nextBigDecimal();
		BigDecimal c = sc.nextBigDecimal();
		BigDecimal d = sc.nextBigDecimal();
		
		BigDecimal e = a.multiply(c);
 
		if (e.compareTo(a.multiply(d)) < 0) {
			e = a.multiply(d);
		}
		if (e.compareTo(b.multiply(c)) < 0) {
			e = b.multiply(c);
		}
		if (e.compareTo(b.multiply(d)) < 0) {
			e = b.multiply(d);
		}
      System.out.println(e);
	}
}

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

int64_t solve(int64_t a, int64_t b) {
    if (a > b)
        swap(a, b);
    int64_t q = b / a;
    if (b % a != 0)
        return 2LL * q * a + solve(a, b % a);
    return 2LL * (q - 1) * a + a;
}

int main() {
    int64_t n, x; cin >> n >> x;

    int64_t ans = n + solve(x, n - x);

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

Measured memory_bytes: 256
import java.util.*;

class Main
{
  public static void main(String[] args)
  {
    Scanner stdIn = new Scanner(System.in);
    int N;
    int M;
    
    N = stdIn.nextInt();
    M = stdIn.nextInt();
    
    int sum = 0;
    for(int i = 0; i < M; i++)
    {
      sum += stdIn.nextInt();
    }
    
    int ans = N - sum;
    if(ans < 0)
    {
      System.out.println(-1);
    }
    else
    {
      System.out.println(ans);
    }
      
  }
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)

int main() {
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> graph(n + 1);
	FOR(i, 1, n-1) {
		int a, b;
		cin >> a >> b;
		graph[a].push_back(MP(b, i));
		graph[b].push_back(MP(a, i));
	}
	queue<int> que;
	que.push(1);
	vector<int> color(n);
	vector<int>fromc(n+1);
	while (!que.empty()) {
		int start = que.front();
		que.pop();
		int cnt = 1;
		for (pair<int, int> dest : graph[start]) {
			if (color[dest.S] == 0) {
				if (fromc[start] == cnt)cnt++;
				color[dest.S] = cnt;
				que.push(dest.F);
				fromc[dest.F] = cnt;
				cnt++;
			}
		}
	}
	auto itr = max_element(ALL(color));
	int res = *itr;
	pv(res);
	FOR(i, 1, n - 1) {
		pv(color[i])
	}
	return(0);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

#define endl '\n'
#define mod 1000000007
#define PI 3.1415926535897932384626
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()

void io() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	io();
	
	int a,b;
	cin>>a>>b;
	cout<<a*b;
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define mod 2019
using namespace std;

int main(void){
  long long L, R; cin >> L >> R;

  long ans = mod-1;
  for(long i = L; i <= min(L+mod-1, R); i++){
    for(long j = i+1; j <= min(L+mod-1, R); j++){
      if((i*j)%mod < ans){
        ans = (i*j)%mod;
      }
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  
  int x,a,b;
  
  cin>>x>>a>>b;
  
  a=abs(x-a);
  b=abs(x-b);
  if(b>a)
    cout<<"A\n";
  else
    cout<<"B\n";
  
  return 0;
}

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

int main(){
  long N;
  cin >> N;
  long list[3]={};
  for(int i=0; i<N; i++){
    long a; cin >> a;
    if(a%4==0) list[0]++;
    else if(a%4==2) list[1]++;
    else list[2]++;
  }
  list[0]+=list[1]/2;
  list[1]-=list[1]/2;
  if(list[0]+1>=list[2]+list[1]){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << 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 N = sc.nextInt();
        int[] A = new int[N];

        for(int i = 0; i < N; i++)
            A[i] = sc.nextInt();


        int index;
        for(index = 0; index < N - 1; index++)
            System.out.print(A[index] + " ");
        System.out.println(A[index]);

        for(int i = 1; i < N; i++){
            int v = A[i];
            int j = i - 1;
            while(j >= 0 && A[j] > v){
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = v;

            for(index = 0; index < N - 1; index++)
                System.out.print(A[index] + " ");
            System.out.println(A[index]);
        }

    }
}



Measured memory_bytes: 31664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int a,b,c,d,e,k; cin>>a>>b>>c>>d>>e>>k;
	cout <<(e-a>k?":(":"Yay!")<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll h;
cin>>h;
ll num=1,count=0;
while(h){
    h/=2;
    count+=num;
    num*=2;
}
cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
struct Node {
    int index = -1;
    int depth = -1;
    int parent = -1;
    int *child;
    int ccnt = 0;
    int type = 0;
};
 
void depth(Node *node, int x, int d) {
    node[x].depth = d;
    for (int i = 0; i < node[x].ccnt; ++i) {
        depth(node, node[x].child[i], d+1);
    }
}
 
int Root(Node *node, int x) {
    if (node[x].parent > -1) {
        Root(node, node[x].parent);
    } else {
        return x;
    }
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, x, root;
    string type[] = {"leaf, [", "internal node, [", "root, ["};
    cin >> n;
    Node a[n];
    for (int i = 0; i < n; ++i) {
        cin >> x;
        cin >> a[x].ccnt;
        a[x].index = x;
        a[x].child = new int[a[x].ccnt];
        for (int j = 0; j < a[x].ccnt; ++j) {
            a[x].type = 1;
            cin >> a[x].child[j];
            a[a[x].child[j]].parent = x;
        }
    }
     
    root = Root(a, 0);
    a[root].type = 2;
    depth(a, root, 0);
     
    for (auto& i : a) {
        cout << "node " << i.index << ": ";
        cout << "parent = " << i.parent << ", ";
        cout << "depth = " << i.depth << ", ";
        cout << type[i.type];
        for (int j = 0; j < i.ccnt-1; ++j) {
            cout << i.child[j] << ", ";
        }
        if (i.ccnt) { 
            cout << i.child[i.ccnt-1] << "]\n";
        } else {
            cout << "]\n";
        }
    }
     
    return 0;
}

Measured memory_bytes: 9752
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int x = 0, y = 0;
  rep(i,n) {
    if(i % 2 == 0) x += a[i];
    if(i % 2 == 1) y += a[i];
  }

  cout << x-y << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << 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; }

string s;
char ans[10];
int now;

int main(){
    cin>>s;
    rep(i,s.length()){
        if(s[i]!='B'){
            ans[now]=s[i];
            now++;
        }
        else{
            if(now){
                ans[now-1]=' ';
                now--;
            }
        }
    }
    rep(i,now){
        if(ans[i]==' ')break;
        else cout<<ans[i];
    }
    out("");
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N;
  scanf("%d",&N);

  int a[N];
  for (int i = 0; i < N; i++) {
    scanf("%d",&a[i]);
  }

  int past = a[0];
  int ans = 0;
  for (int i = 1; i < N; i++) {
    if(a[i] == past){
      ans++;
      if(i+1 < N)
        past = a[i+1];
      i++;
    }
    past = a[i];
  }

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

  return 0;
}

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

int main(){
  bool ikeru=0;
  ll X, Y; cin>>X>>Y;
  ll A=0;
  while(A<=X){
    if(2*A+4*(X-A)==Y){
      ikeru=1;
      break;
    }
    A++;
  }
  if(ikeru) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,m,d,sum,temp,c;
	cin>>n>>m;
	vector<long long int> a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	vector<int> b(n,1);
	while(m--){
		cin>>c>>d;
		if(a[c-1]<=a[d-1])
		b[c-1]=0;
		if(a[d-1]<=a[c-1])
		b[d-1]=0;
	}
	sum=0;
	for(int i=0;i<n;i++){
		if(b[i]){
			//cout<<i+1<<endl;
			sum++;
		}
		
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 4580
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> ma;
    rep(i, N) {
        cin >> A[i];
        ma[A[i]] = i;
    }

    sort(all(A));
    ll ans = 0;
    rep(i, N) {
        if (abs(ma[A[i]] - i) % 2 == 1)
            ans++;
    }

    cout << ans / 2 << endl;

    return 0;
}

Measured memory_bytes: 8328
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
counter=0

for i in range(N):
    if A[i]<=B[i]:
        B[i]-=A[i]
        counter+=A[i]
        A[i]=0
    elif B[i]<A[i]:
        counter+=B[i]
        A[i]-=B[i]
        B[i]=0

    if A[i+1]<=B[i]:
        B[i]-=A[i+1]
        counter+=A[i+1]
        A[i+1]=0
    elif B[i]<A[i+1]:
        counter+=B[i]
        A[i+1]-=B[i]
        B[i]=0

print(counter)


Measured memory_bytes: 19004
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
ll ans = 0LL;
int i_index;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];

int main(){
    cin >> N;
    int maxt = 1;
    for(int i = N; i >= 1; i--){
        cnt = 0;
        while(i > 1){
            i = i / 2;
            cnt++;
        }
        cnt = pow(2, cnt);
        maxt = max(maxt, cnt);
    }
    cout << maxt << endl;
    return 0;
}

Measured memory_bytes: 512
from collections import deque
H, W = map(int, input().split())

area = [input() for _ in range(H)]

distance = [ [float('inf') for _ in range(W)] for _ in range(H)]
to_search = deque()
for i in range(H):
    for j in range(W):
        if area[i][j] == "#":
            to_search.appendleft((i, j, 0))
            distance[i][j] = 0
dist = [[1,0], [0,1], [-1,0], [0,-1]]
ans = 0
while len(to_search) > 0:
    nowi, nowj , nowd = to_search.pop()
    for di, dj in dist:
        nexti = nowi+di
        nextj = nowj+dj
        if 0<= nexti< H and 0<= nextj< W:
            if distance[nexti][nextj] > nowd+1:
                to_search.appendleft((nexti, nextj, nowd+1))
                distance[nexti][nextj] = nowd+1
                ans = max(ans, nowd+1)
print(ans)


Measured memory_bytes: 142940
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

const LL  INF=1<<31;
const LL MOD=1000000007;



int main(){
    int n,k;
    cin>>n>>k;
    int ans=(n+k)%24;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int INF = 1<<29;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする



int main(){
	int n,i;
	cin >> n;
	int a[100008];
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int ans = 0;
	for(i=0;i<n-1;i++){
		if(a[i]==a[i+1])ans += 1;
	}
	ans = (ans+1)/2;
	cout<<n-2*ans<<endl;
	return 0;
}

Measured memory_bytes: 640
import collections


a,b=map(int,input().split())

def gcd(x,y):
  if y==0:return x
  return gcd(y,x%y)

def tameshiwari(n):
  result=[]

  f=2
  if n==2:
    result.append(2)
  while f*f<=n:
    if n%f==0:
      result.append(f)
      n=n//f
    else:
      f+=1
  if n!=1:
    result.append(n)
  return result
  

c = collections.Counter(tameshiwari(gcd(a,b)))
print(len(c)+1)


Measured memory_bytes: 3572
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;
ll ans, n, m;

int main(){
	int i, j;
	while(~scanf("%lld", &n)){
		m = n / 11;
		if(m * 11 == n)  ans = n / 11 * 2;
		else{
			if(m * 11 + 6 >= n)  ans = n / 11 * 2 + 1;
			else  ans = n / 11 * 2 + 2;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    int N, X, Y;
    cin >> N >>  X >> Y;
    int A[N+1] = {};
    for(int i = 1; i < N; i++) {
        for(int j = i + 1; j <= N; j++) {
            int min_value = min(abs(j-i), abs(X-i) + 1 + abs(j-Y));
            A[min_value]++;
        }
    }
    for(int i = 1; i < N; i++) {
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
int a[MAXN];
int main()
{
	int n,m,i,j,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		a[l]++;
		a[r+1]--;
	}
	int ans=0;
	for(i=1;i<=n;i++){
		a[i]+=a[i-1];
		if(a[i]==m) ans++;
	}
	cout<<ans;
	return 0;
	 
}

Measured memory_bytes: 640
function ary2(y,x){x=x||y;return Array(y).fill(0).map(a=>Array(x).fill(0));}
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  one: function(f){return this.a(f);},
  single: function(f){return this.a(f);},
  l: function(f){
    var s = this._s, y = this._y;
    s[y] = typeof s[y] === "string" ? s[y].split(" ") : s[y].reverse();
    this._y++;
    return f?s[y]:s[y].map(a=>+a);
  },
  line: function(f){return this.l(f);},
  row: function(f){return this.l(f);},
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
  matrix: function(n,f){return this.m(n,f);},
  ary: function(n,m){
    var s = this._s, y = this._y, r = ary2(n+1);
    for(var i = 0; i < n; i++){
      var t = s[y+i].split(" ");
      r[t[0]][t[1]]++;
    }
    this._y += n;
    return r;
  },
};

var o = new gets(require("fs").readFileSync("/dev/stdin","utf8"));
console.log(main());
function main(){
  var n = o.a(), t = o.a();
  var a = o.l();
  var u = a[0], v = 0, ans = 0;
  for(var i = 1; i < n; i++){
    if(u > a[i]) u = a[i];
    else if(a[i] - u === v)ans++;
    else if(a[i] - u > v){
      ans = 1;
      v = a[i] - u;
    }
  }
  return ans;
}

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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class ARoundOne {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int A, B;
	    in >> A >> B;
	    REP(i,1,4) {
	        if (i != A && i != B) {
	            out << i << "\n";
	            return;
	        }
	    }
	}
};


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int min(int x, int y)
{
	return x<y?x:y;
}

int main()
{
	fastio;
	ll n, i;
	cin>>n;
	ll h[n];
	for(i=0;i<n;i++)
		cin>>h[i];
	ll dp[n];
	for(i=n-1; i>=0; i--)
	{
		if(i==n-1)
		{
			dp[i] = 0;
			continue;
		}
		if(i+1 > n-1)
			continue;
		dp[i] = abs(h[i]-h[i+1])+dp[i+1];
		if(i+2 > n-1)
			continue;
		dp[i] = min(dp[i], abs(h[i+2] - h[i])+dp[i+2]);
	}
	cout<<dp[0];
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int n;
ll m;
int v, p;
vector<ll> a;

bool check(int x) {
  if (x <= p) return true;
  if (a[x] + m < a[p]) return false;
  ll k = 0;
  for (int i = 0; i < n; ++i) {
    if (i < p || x <= i) {
      k += m;
    } else {
      k += a[x] + m - a[i];
    }
  }
  return m * v <= k;
}

int main() {
  cin >> n >> m >> v >> p;
  p--;
  a.resize(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.rbegin(), a.rend());
  int ok = 0, ng = n;
  while (1 < abs(ok - ng)) {
    int mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok + 1 << endl;
  return 0;
}

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

struct ab{int a; int b;};
bool cmp(ab A, ab B){
    int Asum = A.a + A.b;
    int Bsum = B.a + B.b;
    return Asum < Bsum;
}

// (K-1)を引いた状態でとりあえず解を作る

int main() {
    int N, K;
    cin >> N >> K;
    vector<ab>ans;

    // [1, 2N]から生成
    int L = 1;
    int R;
    while (L <= N){
        R = 2*N - L/2;
        ans.push_back({L, R});
        L += 2;
    }
    L = 2;
    R--;
    while (L <= N){
        ans.push_back({L, R});
        R--;
        L += 2;
    }

    sort(ans.begin(), ans.end(), cmp);

    int min = ans[0].a + ans[0].b;
    min += (K - 1) * 2;
    if((K + 2*N) < min){
        cout << -1 << "\n";
        return 0;
    }

    for (int i = 0; i < N; ++i) {
        int a = ans[i].a + K - 1;
        int b = ans[i].b + K - 1;
        cout << a << " ";
        cout << b << " ";
        cout << K + 2*N + i << "\n";
    }
    return 0;
}

Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#include<utility>
#include<algorithm>
#include<string>
using namespace std;

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

string s, t;

int main()
{
    cin >> s >> t;
    char sm = '|', tm = '0';
    int smc = 0, tmc = 0;

    rep(i, 0, s.size()) 
        if (s[i] < sm) sm = s[i];
    rep(i, 0, s.size())
        if (s[i] == sm) smc++;

    rep(i, 0, t.size())
        if (t[i] > tm) tm = t[i];
    rep(i, 0, t.size())
        if (t[i] == tm) tmc++;

    if (sm < tm) printf("Yes\n");
    else if (sm == tm && smc == s.size() && s.size() < t.size()) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	int all=0;
	int a;
	for(int i=0;i<m;i++){
		scanf("%d",&a);
		all+=a;
	}
	if(n-all>=0){
		printf("%d",n-all);
	}else{
		printf("-1");
	}
} 

Measured memory_bytes: 3820
#include "bits/stdc++.h"
using namespace std;

constexpr long long MOD = 998244353;

int main() {
	long long A, B, C, D;
	cin >> A >> B >> C >> D;
	static long long DP[3001][3001] = {};
	DP[A][B] = 1;
	for (int i = A; i < C; i++) {
		DP[i + 1][B] = (DP[i][B] * B) % MOD;
	}
	for (int i = B; i < D; i++) {
		DP[A][i + 1] = (DP[A][i] * A) % MOD;
	}
	for (int i = A + 1; i <= C; i++) {
		for (int j = B + 1; j <= D; j++) {
			DP[i][j] = ((DP[i - 1][j] * j + DP[i][j - 1] * i) % MOD - (DP[i - 1][j - 1] * (i - 1) * (j - 1)) % MOD + MOD) % MOD;
		}
	}
	cout << DP[C][D] << endl;
}

Measured memory_bytes: 73768
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, m, cnt = 0;
    double min = 0, minofvotes = 0;
    cin >> n >> m;
    int votes[n];
    for(int i = 0; i<n; i++){
        cin >> votes[i];
        minofvotes = minofvotes + votes[i];
    }
    min = 4.0*m;
    minofvotes = minofvotes / min;
    sort(votes, votes+n, greater<int>());
    if(votes[m-1]>=minofvotes){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[100001];
int a[100001];

int main()
{
  int n,k;cin>>n>>k;
  for(int i=0;i<k;i++)
    dp[i]=0;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];

  for(int i=0;i<=k;i++)
  {  

     for(int j=0;j<n;j++)
     {  
     	if(i>=a[j] && !dp[i-a[j]])
        dp[i]=1;
     }

  }
  
  if(dp[k])
  	cout<<"First";
  else
  	cout<<"Second";

  return 0; 
}

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
ll ans,n,a,b,x,y;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>a>>b>>x;
	while(--n){
		y=x;
		cin>>x;
		ans+=min(a*(x-y),b);
	}
	cout<<ans;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    for (int i = 1; i <= n; i++)
    {
        cin>>a[i];
        if (i == n)
        {
            for (int i = n; i > 0; i--)
            {
                if (i > 1)
                {
                    cout<<a[i]<<" ";
                }else
                {
                    cout<<a[i];
                }
            }
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3096
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
char n;
int main()
{
	cin>>n;
	if(n=='a'||n=='e'||n=='i'||n=='o'||n=='u')
	cout<<"vowel";
	else cout<<"consonant";
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	
	if(a==1&&b==1){
		printf("Open\n");
	}else if(c==1){
		printf("Open\n");
	}else{
		printf("Close\n");
	}
return 0;
}

Measured memory_bytes: 584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		try (Scanner sc = new Scanner(System.in)) {
			int n, a, b;
			n = sc.nextInt();
			a = sc.nextInt();
			b = sc.nextInt();
			
			int total = n * a;
			
			System.out.println(Math.min(total, b));
			
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
        StringTokenizer token = new StringTokenizer(S, ",");
        int K = scan.nextInt();
        for (int i = 0; i < K-1; i++) {
            token.nextToken();
        }
        System.out.println(token.nextToken().trim());
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <cmath>

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

int main() {
  int x, y;
  scanf("%d %d", &x, &y);
  if (x%y == 0)
    puts("-1");
  else
    printf("%d\n", x);
  return 0;
}

Measured memory_bytes: 128
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

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

const double EPS = 1.e-11;
using i64 = long long;

void plod(vector<int>& l, const vector<int>& r) {
    int n = l.size();
    vector<int> t(n, 0);
    iota(t.begin(), t.end(), 0);
    for(int i : in(n))
      t[i] = r[l[i]];
    l = t;
}

vector<int> calc(vector<int> a, i64 k) {
    vector<int> b(a.size(), 0);
    iota(b.begin(), b.end(), 0);
    while(k) {
        if(k & 1LL) plod(b, a);
        plod(a, a);
        k >>= 1LL;
    }
    return b;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> cd(n);
    for(auto& x : cd) cin >> x;
    int m; i64 k;
    cin >> m >> k;

    vector<int> sa(n - 1, 0);
    for(int i : in(n - 1))
      sa[i] = cd[i + 1] - cd[i];
    vector<int> perm(n - 1, 0);
    iota(perm.begin(), perm.end(), 0);
    for(int _ : in(m)) {
        int i;
        cin >> i;
        --i;
        swap(perm[i - 1], perm[i]);
    }

    auto ret = calc(perm, k);
    i64 cur = cd[0];
    for(int i : in(n)) {
        cout << cur << '\n';
        if(i < n - 1)
          cur += sa[ret[i]];
    }
    return 0;
}

Measured memory_bytes: 3184
#include<cstring>
#include<cstdio>
using namespace std;

#define M 1000000
#define L 13
char H[M][L];

int getChar(char ch) {
  if (ch=='A') {
    return 1;
  } else if (ch=='C') {
    return 2;
  } else if (ch=='G') {
    return 3;
  } else if (ch=='T') {
    return 4;
  } else {
    return 0;
  }
}

int getKey(char str[]) {
  int sum=0, p=1;
  for (int i=0; i<strlen(str); i++) {
    sum += p*getChar(str[i]);
    p *= 5;
  }
  return sum;
}

int h1(int key) {
  return key%M;
}

int h2(int key) {
  return 1+key%(M-1);
}

int find(char str[]) {
  int key = getKey(str);
  for (int i=0; ; i++) {
    int h = (h1(key) + i*h2(key))%M;
    if (strcmp(H[h], str)==0) {
      return 1;
    } else if (strlen(H[h])==0) {
      return 0;
    }
  }
  return 0;
}

void insert(char str[]) {
  int h;
  int key = getKey(str);
  for (int i=0; ; i++) {
    h = (h1(key) + i*h2(key))%M;
    if (strcmp(H[h], str)==0) {
      break;
    } else if (strlen(H[h])==0) {
      strcpy(H[h], str);
      break;
    }
  }
}

int main() {
  int n;
  char str[L], com[9];
  for (int i=0; i<M; i++) {
    H[i][0] = '\0';
  }
  scanf("%d", &n);
  for (int i=0; i<n; i++) {
    scanf("%s %s", com, str);
    if (com[0]=='i') {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define en '\n'

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll s, w;
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe" << en;
    }else{
        cout << "safe" << en;
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X, T;
  cin >> N >> X >> T;
  cout << (N+(X-1))/X*T << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;


int main(int argc, char **argv)
{
	ll x; cin >> x;

	double n = 100;
	ll res{0};
	while (true)
	{
		if (n >= x) break;
		n *= 1.01;
		n = floor(n);
		++res;
		
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define N 2000500
using namespace std;
typedef long long LL;
int a[N], b[N], n;
map<int,int> mp;
inline int rd() {int r;scanf("%d",&r);return r;}
int main() {
	n = rd();
	for (int i=1;i<=n;i++) a[i] = rd();
	for (int i=1;i<=n;i++) b[i] = a[i];
	sort(b+1, b+n+1);
	for (int i=1;i<=n;i++) mp[ b[i] ] = i&1;
	
	int ans = 0;
	for (int i=1;i<=n;i++) if (mp[a[i]] && ((i&1) == 0)) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9472
function Main(input) {
    var N = parseInt(input[0], 10);
    var L = parseInt(input[1], 10);

    var abs = 10000;
    var eat = 0;
    var sum = 0;

    for (var i = 0; i < N; i++) {
        if (Math.abs(L + i) < abs) {
            abs = Math.abs(L + i);
            eat = (L + i);
        }
        sum = sum + (L + i);
    }

    console.log(sum - eat);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 9420