akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//----------------------------------------------------------------

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> rensou(m, vector<ll>(n + 1));
    ll k;
    ll s;
    ll cnt = 0;
    vector<ll> p(m);
    for (int i = 0; i < m; i++)
    {
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> s;
            rensou[i][s]++;
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> p[i];
    }

    for (int bit = 0; bit < (1 << n); bit++)
    {
        bool flag = true;
        for (int i = 0; i < m; i++)
        {
            int sum = 0;
            for (int j = 0; j < n; j++)
            {
                if (bit & (1 << j))
                {
                    sum += rensou[i][j + 1];
                }
            }
            if (sum % 2 != p[i])
            {
                flag = false;
            }
        }
        if (flag)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    tmp = [int(a) for a in input().split()]
    C.append(tmp[0])
    A.append(tmp[1:])

mi = 1 << 100
for i in range(1 << N):
    B = [0] * M
    c = 0
    for j in range(N):
        if i >> j & 1:
            a = A[j]
            c += C[j]
            for k in range(M):
                B[k] += a[k]
    if min(B) >= X:
        mi = min(mi, c)

print(mi if mi < 1 << 99 else -1)

Measured memory_bytes: 9232
n,q=[int(i) for i in input().split()]
s = input()
qs = []
for i in range(q):
    qs.append([int(i) for i in input().split()])

counts = [0] * n
count = 0
for i in range(1,n):
    if s[i] == "C" and s[i-1] == "A":
        count += 1
    counts[i] = count
counts = [0] + counts


for i in range(q):
    st, en = qs[i]
    print(counts[en] - counts[st])

Measured memory_bytes: 24464
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 #include<bits/stdc++.h>
 #define int long long
 using namespace std;


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif


// -------------------------------------Code starts here--------------------------------------------------------------------- 

    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int pre[n+1]={0};
    for(int i=1;i<=n;i++)
        pre[i]=pre[i-1]+a[i];
    int mn=1e18;
    for(int i=1;i<=n;i++)
    {
        mn=min(mn,abs(2*pre[i]-pre[n]));
        // cout<<mn<<"\n";
    }
    cout<<mn;

// -------------------------------------Code ends here------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

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

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);
        if (N - K + 1 >= 0) { Console.WriteLine(N - K + 1); }
        else { Console.WriteLine(0); }
    }
}

Measured memory_bytes: 13140
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; cin >> N;
    ll rem = 1;
    ll A[N+1];
    F0R(i, N+1) {
        cin >> A[i];
    }
    F0R(i, N+1) {
        rem -= A[i];
        if (rem < 0) {
            cout << -1 << nl; return 0;
        }
        rem *= 2; if (rem > 1e15) rem = 1e15;
    }
    rem = 0;
    F0R(i, N+1) rem += A[i];
    ll cur = 1;
    ll ans = 0;
    F0R(i, N+1) {
        ans += min(cur, rem);
        cur -= A[i];
        cur *= 2; if (cur > 1e15) cur = 1e15;
        rem -= A[i];
//        cout << ans << nl;
    }
    cout << ans << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 4432
/*
    WRITER:kakitamasziru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1001001000;
const int MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long D[114514];
//toをfirst、costをsecondに取るグラフの辺を表す隣接リストE
vector<P> E[514514];

void dijkstra(int start){
    priority_queue<P,vector<P>,greater<P>> Q;
    for(int i = 0;i<114514;i++) D[i] = INF;
    D[start] = 0;
    //Qにはfirst:D[V]、second:V
    Q.push(make_pair(0,start));
    while(!Q.empty()){
        P p = Q.top(); Q.pop();
        int V = p.second;
        //取り出したstartからVまでの仮の最短距離>D[V]ならcontinue
        if(D[V] < p.first) continue;
        //Vについている辺を探索 E[V]はVの辺の隣接リスト
        for(int i = 0;i<E[V].size();i++){
            int to = E[V][i].first;
            int cost = E[V][i].second;
            if(D[to] > D[V] + cost){
                D[to] = D[V]+cost;
                //最短距離を更新したらQにpushする
                Q.push(make_pair(D[to],to));
            }
        }
    }
}

int main() {
    int N,M;cin >> N >> M;
    int S;cin >> S;
    for(int i = 0;i<M;i++){
        int from,to,cost;cin >> from >> to >> cost;
        E[from].push_back(make_pair(to,cost));
    }

    dijkstra(S);

    for(int i = 0;i<N;i++){
        if(D[i] == INF) cout << "INF" << endl;
        else cout << D[i] << endl;
    }
    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}


Measured memory_bytes: 23260
#include <bits/stdc++.h>
using namespace std;
#define ld long double
int main() {
    int n, k;
    ld ans, tmp;
    scanf("%d %d", &n, &k);
    ans = 0.0;
    for (int i = 1; i <= n; i++) {
        tmp = 1.0 / n;
        for (int j = i; j < k; j *= 2) {
            tmp *= 1.0/2.0;
        }
        ans += tmp;
    }
    printf("%11.10Lf\n", ans);
}

Measured memory_bytes: 3732
import java.util.Scanner;

class Main{

	public static void main(String[] args){

		int num1, num2, num3;

		//input numbers

		Scanner input = new Scanner(System.in);
		num1 = input.nextInt();
		num2 = input.nextInt();
		num3 = input.nextInt();
		
		input.close();

		//compute stats
		int min = Math.min(num1, Math.min(num2, num3));
		int max = Math.max(num1, Math.max(num2, num3));
		int median = num1 + num2 + num3 - min - max;

		//print stats
		System.out.printf("%d %d %d\n",min ,median, max);
	}

}


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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int GCD(int a,int b) {return b ? GCD(b,a%b):a;}

int main(){
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;++i)cin>>a[i];

    vector<int> left(N+1,0),right(N+1,0);
    for(int i=0;i<N;i++) left[i+1]=GCD(left[i],a[i]);
    for(int i=N-1;i>=0;--i) right[i]=GCD(right[i+1],a[i]);

    int res =0;
    for(int i=0;i<N;i++){
        int l=left[i];
        int r=right[i+1];
        chmax(res,GCD(l,r));
    }
    cout<<res<<endl;
}

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

typedef long long ll;

int main() {
    char a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = (a - '0') * 10 + b - '0';
    int y = (c - '0') * 10 + d - '0';
    if (x > 0 && x < 13) {
        if (y > 0 && y < 13) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if (y > 0 && y < 13) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 256
N,M,X = map(int,input().split())
list = []
skill=[0]*M
ans = -1
for i in range(N):
    item = input().split()
    list.append(item)
for i in range(2**N):
    skill = [0]*M
    sum = 0
    for j in range(N):
        if ((i >>j) & 1):
            for u in range(M):
                skill[u]+= int(list[j][u+1])
            sum += int(list[j][0])
    if min(skill)>=X:
        if ans == -1:
            ans =sum
        else:
            ans = min(ans,sum)
print(ans)

Measured memory_bytes: 9228
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

#define MOD 1000000007LL

struct Combinations {

    long long mod;
    vector< long long > inv;
    vector< long long > fact;
    vector< long long > inv_fact;

    Combinations (int n, int m) : inv(n), fact(n), inv_fact(n), mod(m) {
        inv[1] = 1;
        for (long long i = 2; i < n; i++) {
            inv[i] = inv[mod%i] * (mod - mod / i) % mod;
        }
        fact[0] = inv_fact[0] = 1;
        for (long long i = 1; i < n; i++) {
            fact[i] = (fact[i-1] * i) % mod;
            inv_fact[i] = (inv_fact[i-1] * inv[i]) % mod;
        }
    }

    long long nPr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return fact[n] * inv_fact[n-r] % mod;
    }

    long long nCr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return nPr(n,r) * inv_fact[r] % mod;
    }

    long long nHr(long long n, long long r) {
        return nCr(n+r-1,r);
    }

};


int main() {

    Combinations inst(200010,MOD);


    ll n; cin >> n;
    vector<ll> a(n+1);
    REP(i,n+1) cin >> a[i];

    ll d = -1;
    set<ll> used;
    REP(i,a.size()) {
        if(used.find(a[i]) != used.end()) d = a[i];
        used.insert(a[i]);
    }

    ll l = -1, r = -1;
    REP(i,a.size()) {
        if(a[i] == d && l == -1) l = i;
        else if(a[i] == d && l != -1) r = i; 
    }

   // cout << l << " " << r << endl;

    for (ll i = 1; i <= n + 1; i++) {
        ll ans = inst.nCr(n+1,i) - inst.nCr(n-r+l,i-1) + MOD;
        ans %= MOD;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 11392
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    int[] prime = new int[10000000];
    for(int i=0;i<10000000;i++) {
      prime[i]=0;
    }
    for(int i=2; i<10000000; i++) {
      if(prime[i]==1) {
        continue;
      }
      prime[i]=2;
      int j=i+i;
      while(j<10000000) {
        prime[j]=1;
        j+=i;
      }
    }
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()) {
      int n = sc.nextInt();
      if(n==0) {
        break;
      }
      int i=0;
      int j=0;
      int sum=0;
      while(i<n) {
        if(prime[j]==2) {
          sum+=j;
          i++;
        }
        j++;
      }
      System.out.println(sum);
    }
  }
}

Measured memory_bytes: 65720
#include <stdio.h>

	int p,q;
	int a[9999999];
	
int main() {
	int n;
	scanf("%d",&n);
	while(n--){
		char st[99];
		scanf("%s",st);
		if(st[0]=='i')scanf("%d",a+q++);
		else if(st[6]==0){
			int t;
			scanf("%d",&t);
			for(int idx=q-1;idx>=p;idx--)if(a[idx]==t){
				a[idx]=-1;
				break;
			}
		}else if(st[6]=='F')while(a[--q]==-1);
		else while(a[p++]==-1);
	}
	int f=0;
	for(int i=q-1;i>=p;i--)if(a[i]!=-1)printf(f++?" %d":"%d",a[i]);
	puts("");
}


Measured memory_bytes: 5640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;


int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  /*  double d,s,t;
    cin>>d>>t>>s;
    ll tt=d/s;
    if(tt<=t)cout<<"Yes";
    else cout<<"No";*/
    string s,t;
    cin>>s>>t;
    int ans=1e9,c;
    for(int i=0;i<=s.size()-t.size();i++){
        string tt=s.substr(i,(int)t.size());
        c=0;
      //  cout<<tt<<endl; 
        for(int j=0;j<tt.size();j++){
            if(tt[j]!=t[j])c++;
        }
        ans=min(ans,c);
    }
    cout<<ans;


    


    

}

Measured memory_bytes: 3660
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define ll long long
#define ull unsigned long long
#define MAXN 100010
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define min(a, b) (a) < (b) ? (a) : (b)
#define max(a, b) (a) < (b) ? (b) : (a)
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second
#define mii map<int, int>
#define umii unordered_map<int, int>
#define allof(x) x.begin(), x.end()
#define DEBUG 1
// #define NOT_DMOJ 0
#ifdef DEBUG
	#define D(x...) printf(x)
#else
	#define D(x...)
#endif
using namespace std;

inline int GCD (int a, int b) { return b == 0 ? a : GCD(b, a % b); }
inline int LCM (int a, int b) { return a * b / GCD(a, b); }
inline ll PowMod (ll a, ll b, ll mod) { ll val = 1; while (b) { if (b & 1) val = (val * a) % mod; a = (a * a) % mod; b >>= 1; } return val; }

int N, M, ans;
int x[MAXN], y[MAXN], DP[MAXN];
vi adj[MAXN];

inline int Solve (int node) {
	int &res = DP[node];
	if (~res) return res;
	int maxx = 0;
	for (auto i : adj[node]) {
		maxx = max(maxx, Solve(i) + 1);
	}
	return res = maxx;
}

int main (int argc, char const *argv[]) {
	#ifdef NOT_DMOJ
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif // NOT_DMOJ
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M;
	memset(DP, -1, sizeof(DP));
	for (int i=0; i<M; i++) {
		cin >> x[i] >> y[i];
		adj[x[i]].pb(y[i]);
	}
	for (int i=1; i<=N; i++) {
		ans = max(ans, Solve(i));
	}
	cout << ans << "\n";
	return 0;
}

/*
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
Ans: 3
*/

/* 
 * Look for:
 * the exact constraints (multiple sets are too slow for n=10^6 :( ) 
 * special cases (n=1?)
 * overflow (ll vs int?)
 * array bounds
 */

Measured memory_bytes: 9728
import java.util.Scanner;
class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
int[] sum=new int[101];

int[][] h=new int[101][101];
int[]  m=new int[101];
int a=scan.nextInt();
for(int d=0;d<a;d++){
sum[d]=0;
}
int b=scan.nextInt();
for(int c=0;c<a;c++){
for(int d=0;d<b;d++){
h[c][d]=scan.nextInt();
}
}
for(int d=0;d<b;d++){
m[d]=scan.nextInt();
}
for(int c=0;c<a;c++){
for(int d=0;d<b;d++){
sum[c]+=h[c][d]*m[d];

}
}
for(int c=0;c<a;c++){
System.out.println(sum[c]);
}
}
}

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

int main() {
	int N, X, m, min = 1000, count = 0;
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> m;
		count += m;
		if (min > m) min = m;
	}
	cout << N + (X - count) / min << endl;
}


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

bool isprime(int x)
{
    if(x == 2)
        return true;
    if(x < 2)
        return false;
    if(x % 2 == 0)
        return false;
    
    int qx = (int)sqrt(x);
    int i=3;
    while(i <= qx)
    {
        if(x % i == 0)
            return false;
        i += 2;
    }
    return true;
}

std::vector<int> calc(int start, int end)
{
    std::vector<int> r;
    for(int j=start; j<=end; j+=2)
    {
        if(isprime((j+1)/2) && isprime(j))
            r.push_back(j);
    }
    return r;
}

int main(void)
{
    int Q;
    std::vector<int> primes = calc(1, 100000);
    std::cin >> Q;
    for(int i=0; i<Q; ++i)
    {
        int start, end;
        std::cin >> start >> end;
        auto p_start = std::lower_bound(primes.begin(), primes.end(), start);
        auto p_end = std::upper_bound(primes.begin(), primes.end(), end);
        std::cout << p_end - p_start << std::endl;
    }
    return 0;
}


Measured memory_bytes: 640
N = int(input().strip())
S = input().strip()

dp = [[0 for j in range(N+1)] for i in range(N+1)]

for i in range(N - 1, -1, -1):
    for j in range(N - 1, -1, -1):
        if S[i] != S[j]:
            dp[i][j] = 0
        else:
            dp[i][j] = dp[i + 1][j + 1] + 1

max_length = 0
for i in range(N):
    for j in range(N):
        if i < j:
            length = min(j - i, dp[i][j])
            max_length = max(length, max_length)

print(max_length)


Measured memory_bytes: 245768
#include <iostream>
#include <vector>
#include <queue>
#include <stack>

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
#pragma GCC target("avx,avx2,fma")

using namespace std;
using ll = long long;
int n,k,tree[2222222],mxn=300005;
int update(int node,int s,int e,int pos,int v){
    if(pos > e || s > pos) return tree[node];
    if(s == e) return tree[node] = v;
    return tree[node] = max(update(node*2,s,s+e>>1,pos,v),update(node*2+1,(s+e>>1)+1,e,pos,v));
}
int query(int node,int s,int e,int l,int r){
    if(s > r || e < l) return 0;
    if(l <= s && e <= r) return tree[node];
    return max(query(node*2,s,s+e>>1,l,r),query(node*2+1,(s+e>>1)+1,e,l,r));
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>k;
    for(int i=1; i<=n; i++){
        int x;
        cin>>x;
        ++x;
        int l = max(1,x-k),r = min(mxn,x+k);
        int q = query(1,1,mxn,l,r);
        update(1,1,mxn,x,q+1);
    }
    cout<<query(1,1,mxn,1,mxn);
}

Measured memory_bytes: 7772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    int k,a,b;
    cin>>k>>a>>b;
    bool flag = false;
    rep(i,a,b+1){
        if(i%k == 0)flag = true;
    }
    if(flag)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <cstdio>

bool skipr[100];
bool skipc[100];

int main()
{
  char s[100][101];
  int h, w;
  scanf("%d %d", &h, &w);
  for (int i = 0; i < h; ++i)
  {
    scanf("%s", s[i]);
    int j = 0;
    for (; j < w; ++j)
    {
      if (s[i][j] != '.')
      {
        break;
      }
    }
    if (j == w)
    {
      skipr[i] = true;
    }
  }
  
  for (int i = 0; i < w; ++i)
  {
    int j = 0;
    for (; j < h; ++j)
    {
      if (s[j][i] != '.')
      {
        break;
      }
    }
    if (j == h)
    {
      skipc[i] = true;
    }
  }
  
  for (int i = 0; i < h; ++i)
  {
    if (skipr[i]) continue;
    for (int j = 0; j < w; ++j)
    {
      if (skipc[j]) continue;
      printf("%c", s[i][j]);
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 128
unittest
{
	assert( [ "11 2" ].parse.expand.solve == 4 );
	assert( [ "1010101 10" ].parse.expand.solve == 7 );
	assert( [ "314159265 3" ].parse.expand.solve == 18 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	auto ans = 0L;
	while( 0 < n )
	{
		n /= k;
		ans++;
	}
	return ans;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1000005

ll n;
ll k;

int main()
{
    _FastIO;
    cin >> n >> k;
    for(ll i = 0; i < k; i++){
        ll x;
        cin >> x;
        n -= x;
    }
    if(n < 0)   n = -1;
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <functional>
#include <unordered_map>
#define int long long 
#define pi pair<int,int> 
#define endl "\n"
//using namespace std ;

const int inf = 1e15 ;
const int size = 100005;
const int mod = 1e9 + 7 ;
int dp[101][size] , a[size] , pre[101][size] , n , k  ;

inline int add ( int a , int b )
{
     a += b ;
     if(a >= mod ) a-=mod ;
     return a ;
}
inline int sub(int a , int b )
{
     a-=b ;
     if(a < 0 ) a += mod ;
     return a ;
}


int32_t main() 
{


     /*#ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif*/

     scanf("%lld %lld",&n,&k);
     for(int i = 1 ; i <= n ;i ++ )scanf("%lld",&a[i]);
     for(int i = 0 ; i <=k ; i++ ) pre[0][i] = 1  ;
     // pre[0][i] - pre[0][k] = 0 , thats what we require ;
     for(int i = 0 ; i <=n ; i++ ) pre[i][0] = dp[i][0] = 1 ;

     for(int i = 1 ; i <=n ; i++ )
     {
         for(int j =1 ; j <= k ; j++ )
         {
             int first = (j-a[i]-1 >= 0 )?pre[i-1][j-a[i]-1] : 0 ;
             int last  = pre[i-1][j] ; 
             dp[i][j] = add(dp[i][j],sub(last,first));
             pre[i][j] = add(pre[i][j-1],dp[i][j]);
         }

     }
     std::cout<<dp[n][k]<<endl;
}


Measured memory_bytes: 158080
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

int main(void){
  int a,b,c; cin>>a>>b>>c;
  cout<<((a==b+c||b==c+a||c==a+b)?"Yes":"No")<<endl;
}














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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    unsigned long cnt{0};
    for(unsigned long i = 1; i <= N; ++i){
        if(A[i - 1] != i)++cnt;
    }
    puts(cnt <= 2 ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

long long POW(long long x,long long n,long long mod){
  long long ans = 1;
  while(n){
    if(n%2)ans *= x;
    x *= x;
    x %= mod;
    ans %= mod;
    n >>= 1;
  }
  return ans;
}
vector<long long> factorial(2,1);
long long nckmodp(long long n,long long k,long long p){
  if(n < k || n <= 0 || k < 0)return 0;
  while(factorial.size() <= n){
    long long i = factorial.size();
    factorial.push_back(i*factorial[i-1]%p);
  }
  return ((factorial[n]*POW(factorial[k],p-2,p))%p)*POW(factorial[n-k],p-2,p)%p;
}
long long TwelvefoldWay4(long long n,long long k,long long MOD){
  return nckmodp(n+k-1,n,MOD);
}

signed main(){
  ll n,k;
  cin >> n >> k;
  cout << TwelvefoldWay4(n,k,INF) << endl;
}


Measured memory_bytes: 3184
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>

using namespace std;

int min(int a, int b){
    return (a > b) ? b : a;
}

int main(){

    int n;
    long long k;

    cin >> n >> k;

    int destinations[n];

    for(int i = 0; i < n; i++){
        cin >> destinations[i];
        // cout << destinations[i] << " ";
    }


    vector<int> path(n, -1);

    vector<int> order;

    long long count = 0;

    int current = 1;

    bool repeated = false;

    while(path[current-1] == -1 && count <= k){

        order.push_back(current);

        path[current-1] = count;
        count++;
        current = destinations[current-1]; 
        // cout << count << " "  <<  order[count-1] << endl;
    }

    // cout << path[current-1] << endl;

    long long startLoop = 0;
    long long cycle = 0;

    for(int i= 0; i < order.size(); i++){
        // cout << order[i] << "=>";
    }
    // cout << endl;

    if(path[current-1] != -1){

        repeated = true;

        cycle = count - path[current-1];

        // cout << "cycle == " <<  cycle << endl;

        startLoop = path[current-1];

        // cout << "startLoop == " << startLoop << endl;
    }

    if(!repeated || k < startLoop ){
        cout << order[k] << endl;
    }
    else{
        count = k - startLoop;
        count = count % cycle;
        // cout << cycle << endl;

        
        cout << order[startLoop + count] << endl;
    }
    
    return 0;

}


Measured memory_bytes: 5880
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> v(N);
    map<int, int> e;
    map<int, int> o;
    //配列代入（偶配列と奇配列に分ける）
    for(int i = 0; i < N; i++){
        cin >> v[i];
        if(i % 2 == 0) o[v[i]]++;
        if(i % 2 == 1) e[v[i]]++;
    }
    //すべての値が一致している場合はコーナーケースとして処理
    bool is = true;
    for(int i = 1; i < N; i++){
        if(v[i] != v[i-1]) is = false;
    }
    if(is){
        cout << N/2 << endl;
        return 0;
    }
    //処理部分
    int f_mx_e = 0;
    int f_mx_o = 0;
    int s_mx_e = 0;
    int s_mx_o = 0;
    int e_num;
    int o_num;
    for(auto p : e){
        if(f_mx_e < p.second) s_mx_e = f_mx_e, f_mx_e = p.second, e_num = p.first;
        else if(s_mx_e < p.second) s_mx_e = p.second;
    }
    for(auto p : o){
        if(f_mx_o < p.second) s_mx_o = f_mx_o, f_mx_o = p.second, o_num = p.first;
        else if(s_mx_o < p.second) s_mx_o = p.second;
    }
    int ans = 0;
    if(e_num != o_num){
        ans = N - (f_mx_e + f_mx_o);
    }else{
        int ans1 = N - (f_mx_e + s_mx_o);
        int ans2 = N - (s_mx_e + f_mx_o);
        ans = min(ans1, ans2);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define PIE 3.14159265358979

int main(){
  double a,b;
  int h,m;
  cin >> a >> b >> h >> m;
  
  double ha,ma;
  ha=h*PIE/6+m*PIE/360;
  ma=m*PIE/30;
  
  double arc=max(ha-ma,ma-ha);
  
  double ans=sqrt(a*a+b*b-2*a*b*cos(arc));
  
  cout << fixed;
  cout << setprecision(15) << ans << endl;
  
  return 0;
}


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

int main(void) {
    int n;
    cin >> n;
    vector<long long> d(n);
    for (int i = 0; i < n; i++)
        cin >> d[i];
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
main(){
  char str[100];
  int upper,lower,right,left,back,current,i=0,tmp[4],kaisu,tmp2[25][2],hoge,flag=0;
  int upper2,lower2,right2,left2,back2,current2;
  srand((unsigned)time(NULL));
  scanf("%d%d%d%d%d%d",&current,&lower,&right,&left,&upper,&back);
  scanf("%d%d%d%d%d%d",&current2,&lower2,&right2,&left2,&upper2,&back2);
  while(i++<500){
    hoge=rand()%4;
      if(hoge==0){
	tmp[0]=current;
	tmp[1]=upper;
	tmp[2]=back;
	tmp[3]=lower;
	current=tmp[1];
	upper=tmp[2];
	back=tmp[3];
	lower=tmp[0];
      }
      if(hoge==1){
	tmp[0]=current;
	tmp[1]=upper;
	tmp[2]=back;
	tmp[3]=lower;
	current=tmp[3];
	upper=tmp[0];
	back=tmp[1];
	lower=tmp[2];
      }
      if(hoge==2){
	tmp[0]=current;
	tmp[1]=right;
	tmp[2]=left;
	tmp[3]=back;
	current=tmp[2];
	right=tmp[0];
	left=tmp[3];
	back=tmp[1];
      }
      if(hoge==3){
	tmp[0]=current;
	tmp[1]=right;
	tmp[2]=left;
	tmp[3]=back;
	current=tmp[1];
	right=tmp[3];
	left=tmp[0];
	back=tmp[2];
      }
      if(current==current2&&lower==lower2&&upper==upper2&&back==back2&&left==left2&&right==right2){
	flag=1;
	break;
      }
  }
  if(flag==1)
    printf("Yes\n");
  else 
    printf("No\n");
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

const int maxN = 2e5; int n, q;
vector<int> tree[maxN];
int cnt[maxN];

void dfs(int u = 0, int prv = -1)
{
  if (prv != -1) cnt[u] += cnt[prv];
  for (int v: tree[u])
    if (v != prv)
      dfs(v, u);
}

int main()
{
  scanf("%d %d", &n, &q);
  for (int i = 0, u, v; i < n - 1; i ++)
  {
    scanf("%d %d", &u, &v); u --, v --;
    tree[u].push_back(v), tree[v].push_back(u);
  }

  while (q --)
  {
    int p, x; scanf("%d %d", &p, &x); p --;
    cnt[p] += x;
  }
  dfs();

  for (int i = 0; i < n; i ++)
    printf("%d%c", cnt[i], i < n - 1 ? ' ' : '\n');

  return(0);
}

Measured memory_bytes: 23424
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

using namespace std;
typedef long long ll;

# define MAX_N 100000

vector<vector<pair<ll, ll>>> yen(MAX_N); // pair<cost, num>
vector<vector<pair<ll, ll>>> snook(MAX_N);


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, t; cin >> n >> m >> s >> t;
    s--;
    t--;
    for (int i = 0; i < m; i++) {
        int u, v, a, b; cin >> u >> v >> a >> b;
        u--;
        v--;
        yen[u].push_back(make_pair(a, v));
        yen[v].push_back(make_pair(a, u));
        snook[u].push_back(make_pair(b, v));
        snook[v].push_back(make_pair(b, u));
    }

    const ll maxCost = 1LL<<60;
    priority_queue<
        pair<ll, ll>,
        vector<pair<ll, ll>>,
        greater<pair<ll, ll>>
    > yenQ, snookQ; // pair<cost, num>

    // i 番目までかかる金額
    vector<ll> snookCost(n, maxCost);
    vector<ll> yenCost(n, maxCost);

    for (auto& y : yen[s]) {
        yenQ.push(y);
        yenCost[y.second] = y.first;
    }
    yenCost[s] = 0;

    while (yenQ.size()) {
        pair<ll, ll> yt = yenQ.top();
        yenQ.pop();
        for (auto& y : yen[yt.second]) {
            if (yenCost[y.second] > yenCost[yt.second] + y.first) {
                yenCost[y.second] = yenCost[yt.second] + y.first;
                yenQ.push(y);
            }
        }
    }

    for (auto& sn : snook[t]) {
        snookQ.push(sn);
        snookCost[sn.second] = sn.first;
    }
    snookCost[t] = 0;

    while (snookQ.size()) {
        pair<ll, ll> st = snookQ.top();
        snookQ.pop();
        for (auto& sn : snook[st.second]) {
            if (snookCost[sn.second] > snookCost[st.second] + sn.first) {
                snookCost[sn.second] = snookCost[st.second] + sn.first;
                snookQ.push(sn);
            }
        }
    }

    ll v = 0;
    vector<ll> ans(n);
    for (int i = n-1; i >= 0; i--) {
        v = max(v, ll(1000000000000000 - snookCost[i] - yenCost[i]));
        ans[i] = v;
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 25324
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<int> As(N), Bs(N), Cs(N-1);
    for (int i = 0; i < N; i++) cin >> As[i];
    for (int i = 0; i < N; i++) cin >> Bs[i];
    for (int i = 0; i < N - 1; i++) cin >> Cs[i];
    
    int sum = Bs[As[0] - 1];
    for (int i = 1; i < N; i++) {
        sum += Bs[As[i] - 1];
        if (As[i] == As[i-1] + 1) {
            sum += Cs[As[i-1] - 1];
        }
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   cin >> n;
   bool flg = 0;
   for(int i=1;i<=9;i++){
      for(int j=0;j<=9;j++){
         if(n == i*j) {
            cout << "Yes" << endl;
            flg = 1;
         }
      }
      if(flg) break;
   }

   if(!flg) cout << "No" << endl;

   return 0;
}

Measured memory_bytes: 256
import numpy as np
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a,b,n=INTM()
    if b>n:
        print(int(a*n/b)-a*int(n/b))
    else:
        print(int(a*(b-1)/b)-a*int((b-1)/b))
if __name__ == '__main__':
    do()

Measured memory_bytes: 27140
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	bool ok=false;
	int str=0;
	rep(i,n){
		int d,e;
		cin>>d>>e;

		if(d==e){
			str++;
		}else{
		
			str=0;
		}
		if(str>=3){
				ok=true;
		}
	}
	if(ok){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

double combination(int n, int k){
	if(n < k)
		return 0.0;
	if(k == 0)
		return 1.0;

	return combination(n-1, k-1) * n / k;
}

int main(){
	int h, n, p, m, k;
	cin >> h >> n >> p >> m >> k;

	vector<int> line(h, -1);
	for(int i=0; i<m; ++i){
		int a, b;
		cin >> a >> b;
		line[a-1] = b-1;
	}

	int rest = (h - m);
	vector<vector<double> > prob(k+1, vector<double>(n, 0.0));
	prob[k][p-1] = 1.0;
	for(int l=h-1; l>=0; --l){
		if(line[l] != -1){
			for(int j=0; j<k+1; ++j)
				swap(prob[j][line[l]], prob[j][line[l]+1]);
			continue;
		}

		vector<vector<double> > nextProb(k+1, vector<double>(n, 0.0));
		for(int i=0; i<k+1; ++i){
			double noChange = 0.0;
			if(i < rest)
				noChange = combination(rest-1, i) / combination(rest, i);
			for(int j=0; j<n; ++j)
				nextProb[i][j] += prob[i][j] * noChange;

			if(i == 0)
				continue;

			for(int j=0; j<n; ++j){
				nextProb[i-1][j] += prob[i][j] * (1.0 - noChange) * (n - 3) / (n - 1);
				nextProb[i-1][max(0, j-1)] += prob[i][j] * (1.0 - noChange) * 1 / (n - 1);
				nextProb[i-1][min(n-1, j+1)] += prob[i][j] * (1.0 - noChange) * 1 / (n - 1);
			}
		}

		prob.swap(nextProb);
		-- rest;
	}

	double ret = 0.0;
	for(int i=0; i<n; ++i)
		ret = max(ret, prob[0][i]);

	printf("%.10f\n", ret);

    return 0;
}

Measured memory_bytes: 0
def make_num(n):
    if int(n) > N:
        return 0
    elif "3" in n and "5" in n and "7" in n:
        ans = 1
    else:
        ans = 0
    for i in "357":
        ans += make_num(n+i)
    return ans
N = int(input())
print(make_num("0"))

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();

		int r = 0;
		int b = 0;

		for(int i = 0;i<N;i++) {
			switch(s.charAt(i)) {
			case 'R':
				r++;
				break;
			case 'B':
				b++;
				break;
			default:
				break;
			}
		}

		if(r>b) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

void mainsolve(){

    ll n,k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i,n) cin >> f[i];
    sort(f.rbegin(), f.rend());

    ll asum = 0;
    rep(i,n) asum += a[i];
    if(asum <= k){
        cout << 0 << endl;
        return;
    }


    auto isOK = [&](ll c){
        ll sum = 0;
        rep(i,n) sum += max(0ll,a[i] - c/f[i]);
        return sum <= k;
    };

    auto bs = [&]{
        ll ng = -1;
        ll ok = 1e12+1;
        ll mid = (ng+ok)/2;

        while(abs(ng-ok)>1){
            if(isOK(mid)) ok = mid;
            else ng = mid;
            mid = (ng+ok)/2;
        }
        return ok;
    };

    cout << bs() << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		String S = scan.next();
		String T = scan.next();
		
		System.out.println(T+S);
		
	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 107;
 
template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}
 
int n, m;
int a[maxN];
int cnt, c[2];
 
int main() {
 
	n = ri(), m = ri();
 
	if (m == 1) {
		int x = ri();
		if (x != 1) printf("%d\n2\n1 %d\n", x, x - 1);
		else printf("%d\n1\n%d\n", x, x);
		return 0;
	}
 
	rep (i, 1, m) {
		a[i] = ri();
		if (a[i] & 1) {
			if (cnt == 2) {
				puts("Impossible");
				return 0;
			}
			c[cnt++] = i;
		}
	}
 
	if (cnt >= 1) swap(a[1], a[c[0]]);
	if (cnt >= 2) swap(a[m], a[c[1]]);
 
	rep (i, 1, m) printf("%d%c", a[i], " \n"[i == m]);
	printf("%d\n", m - (a[1] == 1));
	rep (i, 1, m) {
		if (i == 1) {if (a[i] != 1) printf("%d ", a[i] - 1);}
		else if (i == m) printf("%d\n", a[i] + 1);
		else printf("%d ", a[i]);
	}
 
	return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	
	vector<int> water;
	for(int i = 0; i <= 30; ++i){
		for(int j = 0; j <= 30; ++j){
			int water_tmp = (a * i + b * j) * 100;
			if(water_tmp <= f && water_tmp != 0){
				water.push_back(water_tmp);
			}
		}
	}
	
	water.erase(unique(water.begin(), water.end()), water.end());
	
	vector<int> sugar;
	for(int i = 0; i <= 100; ++i){
		for(int j = 0; j <= 100; ++j){
			int sugar_tmp = c * i + d * j;
			if(sugar_tmp <= f){
				sugar.push_back(sugar_tmp);
			}
		}
	}
	
	sugar.erase(unique(sugar.begin(), sugar.end()), sugar.end());
	
  	//rep(i, water.size()) cout << water[i] << " ";
    //cout << endl;
    //rep(i, sugar.size()) cout << sugar[i] << " ";
    //cout << endl;
  
	double noudo = -1.0;
	int ans_water = 0;
	int ans_sugar = 0;
	for(int i = 0; i < water.size(); ++i){
		for(int j = 0; j < sugar.size(); ++j){
			if(water[i] + sugar[j] > f) continue;
			if(100 * sugar[j] > water[i] * e) continue;
			if(noudo < (double)sugar[j] * 100.0 / ((double)water[i] + (double)sugar[j])){
				noudo = (double)sugar[j] * 100.0 / ((double)water[i] + (double)sugar[j]);
				ans_water = water[i];
				ans_sugar = sugar[j];
			}
		}
	}
	
	cout << ans_water+ans_sugar << " " << ans_sugar << endl;
	
	return 0;
}



Measured memory_bytes: 384
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int x,a;
    cin>>x>>a;
    if(x<a)cout<<0<<endl;
    else if(x>=a)cout<<10<<endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int D,N; cin >> D >> N;
  int k=1;
  for(int i=0;i<D;i++){
    k*=100;
  }
  if(N==100){
    N++;
  }
  cout << k*N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[100010];
long long res;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++){
		res+=a[i]/2;
		a[i]%=2;
		if(a[i]&&a[i+1]){
			res++;
			a[i]--;
			a[i+1]--;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024