akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      int N = in.nextInt();
      boolean canExactlyN = false;

      for (int i = 0; i <= N && canExactlyN == false; i += 4) {
        for (int j = 0; j <= N; j += 7) {
          if (i + j == N) {
            canExactlyN = true;
            break;
          }
        }
      }

      if (canExactlyN) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 23764
#include<cstdio>
#define mid (l+r>>1)
#define L root<<1
#define R root<<1|1 
#define re register signed 
const int inf=1<<29;
const int Maxn=1e5+5;
inline int max(int x,int y){return x>y?x:y;}
inline int min(int x,int y){return x<y?x:y;}
inline int RR()
{
	char c;int res;
	while((c=getchar())>'9'||c<'0');res=c-'0';
	while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
	return res;
}
int s[Maxn*4],a[Maxn],n,d,dp[Maxn];
char c[Maxn];
void build(int root,int l,int r)
{
	if(l==r) 
	{s[root]=a[l];return;}
	build(L,l,mid);build(R,mid+1,r);
	s[root]=max(s[L],s[R]);
}
int query(int root,int l,int r,int x,int y)
{
	if(l>y||r<x) return 0;
	if(l>=x&&r<=y) return s[root];
	return max(query(L,l,mid,x,y),query(R,mid+1,r,x,y));
}
int main()
{
	n=RR();d=RR();int x;
	scanf("%s",c+1);++n;
	for(re i=1;i<=n;i++)
	if(c[i]-'0'==0) a[i]=i;
	build(1,1,n);
	for(re i=n-1;i>=1;i--)
		if(c[i]-'0') dp[i]=inf;
		else 
		{
			x=query(1,1,n,i+1,min(n,i+d));
			if(!x) dp[i]=inf;
			else dp[i]=dp[x]+1;
		}
	if(dp[1]>=inf) 
	{
		puts("-1");
		return 0;
	}
	int pos=2,pre=1;
	while(pos<=n)
	{
		if(n>pre&&n-pre<=d) 
		{
			printf("%d\n",n-pre);
			return 0;
		}
		while(c[pos]-'0'||dp[pos]>=dp[pre]) pos++;
		printf("%d ",pos-pre);
		pre=pos;pos++;
	}
	return 0;
}

Measured memory_bytes: 2304
#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;

   cout << n*(n+1)/2 << endl;
 


   return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
const char dir[] = {'L', 'D', 'R', 'U'};

struct P {
    int x, y;
    int d;
    int cnt;
    vvb G;
    string moves;
};

int H, W;

int main() {
    cin >> H >> W;

    vvb G(H, vb(W, false));
    int sx, sy, d;
    int cnt = 0;
    REP(y, H) REP(x, W) {
        char c;
        cin >> c;
        if (c == 'o') {
            cnt++;
            G[y][x] = true;
        } else if (c != '.') {
            sx = x;
            sy = y;
            d = find(dir, dir+4, c) - dir;
        }
    }

    queue<P> que;
    string moves;
    que.push({sx, sy, d, 0, G, moves});

    while (!que.empty()) {
        P p = que.front(); que.pop();
        if (p.cnt >= 30) continue;
        if (p.cnt == cnt) {
            cout << p.moves << endl;
            break;
        }
        int x = p.x, y = p.y;
        if (p.d != 0) for (int x = p.x; x < W; x++) {
            if (p.G[y][x]) {
                vvb g = p.G;
                g[y][x] = false;
                que.push({x, y, 2, p.cnt+1, g, p.moves + "R"});
                break;
            }
        }
        if (p.d != 2) for (int x = p.x; x >= 0; x--) {
            if (p.G[y][x]) {
                vvb g = p.G;
                g[y][x] = false;
                que.push({x, y, 0, p.cnt+1, g, p.moves + "L"});
                break;
            }
        }
        if (p.d != 3) for (int y = p.y; y < H; y++) {
            if (p.G[y][x]) {
                vvb g = p.G;
                g[y][x] = false;
                que.push({x, y, 1, p.cnt+1, g, p.moves + "D"});
                break;
            }
        }
        if (p.d != 1) for (int y = p.y; y >= 0; y--) {
            if (p.G[y][x]) {
                vvb g = p.G;
                g[y][x] = false;
                que.push({x, y, 3, p.cnt+1, g, p.moves + "U"});
                break;
            }
        }
    }
}

Measured memory_bytes: 7476
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

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




void solve(){
	int a,b;
	cin >> a >> b;
	cout << a * b << " " << a+a+b+b << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int main(){
  int n,a;
  cin>>n;
  vector<int> b(n),c(n);
  int d=1,s=0,e=1,t=0;
  rep(i,n){
    cin>>a;
    s+=a*d;
    d*=10;
  }
  rep(i,n){
    cin>>a;
    t+=a*e;
    b[i]=i+1;
    e*=10;
  }
  int x,y,z=0;
  do{
    int u=1,v=0;
    rep(i,n){
      v+=b[i]*u;
      u*=10;
    }
    if(v==s)x=z;
    if(v==t)y=z;
    z++;
  }while(next_permutation(all(b)));
  cout<<abs(x-y);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int a;
  int sum = 1;
  while(true){
    cin>>a;
    if(a == 0){
      break;
    }
    sum += 1;
  }
  cout<<sum<<'\n';
}

Measured memory_bytes: 3628
a,b,q = map(int,input().split())
tl=[]
qlist=[]
for i in range(a):tl.append((int(input()),0,i))
for i in range(b):tl.append((int(input()),1,i))
for i in range(q):
    q1=int(input())
    tl.append((q1,2,i))
    qlist.append(q1)
tl.sort()
prea=[-1]*q
preb=[-1]*q
ta=tb=-1
for i,c in enumerate(tl):
    if   c[1]==0:ta=c[0]
    elif c[1]==1:tb=c[0]
    elif c[1]==2:prea[c[2]],preb[c[2]]=ta,tb
posta=[-1]*q
postb=[-1]*q
ra=rb=-1
for i,c in enumerate(tl[::-1]):
    if   c[1]==0:ra=c[0]
    elif c[1]==1:rb=c[0]
    elif c[1]==2:posta[c[2]],postb[c[2]]=ra,rb

def cal(pra,poa,prb,pob,q):
    gmin = 999999999999
    if pra!=-1 and prb!=-1:
        if pra<prb:gmin=min(gmin,q-pra)
        else:      gmin=min(gmin,q-prb)
    if pra!=-1 and pob!=-1:gmin=min(gmin,pob-pra+min(q-pra,pob-q))
    if prb!=-1 and poa!=-1:gmin=min(gmin,poa-prb+min(poa-q,q-prb))
    if poa!=-1 and pob!=-1:
        if poa<pob:gmin=min(gmin,pob-q)
        else:      gmin=min(gmin,poa-q)
    return gmin
for a1,a2,b1,b2,q in zip(prea,posta,preb,postb,qlist):print(cal(a1,a2,b1,b2,q))

Measured memory_bytes: 52192
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

double pi = 3.14159265358979323846264338327;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    ll n, w;
    cin>>n>>w;
    vector<ll> val(n);
    vector<ll> wei(n);
    for(ll i=0; i<n; i++){
        cin>>wei[i]>>val[i];
    }
    vector<vector<ll> > dp(n+1, vector<ll>(w+1));
    for(ll i=1; i<=n; i++){
        for(ll j=1; j<=w; j++){
            dp[i][j] = dp[i-1][j];
            if(j>=wei[i-1]){
                dp[i][j]=max(dp[i][j], dp[i-1][j-wei[i-1]]+val[i-1]);
            }
        }
    }
    cout<<dp[n][w]<<endl;
    return 0;
}







Measured memory_bytes: 83196
n,s = map(int, input().split())
a = list(map(int, input().split()))

MOD = 998244353

dp = [[0]*(s+1) for i in range(n+1)] #動的計画法を用いる
dp[0][0] = 1

for i in range(n):
    for ss in range(s+1):
        if(ss >= a[i]):
            dp[i+1][ss] = (dp[i][ss]*2 + dp[i][ss-a[i]])%MOD #非常に大きな数になると考えられるため先にMOD計算を行う
        else:
            dp[i+1][ss] = dp[i][ss]*2 % MOD

print(dp[n][s])

Measured memory_bytes: 132524
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    scanf("%d %d",&a,&b);
    if (a<b) {//if：もし
        printf("a < b");
    }
    if (a>b) {
        printf("a > b");
    }
    if (a==b) {
        printf("a == b");
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);	
	int n;
	cin >> n;
	cout << int((n+1)/2) << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,b,f,r,v,cnt[5][4][11]={};
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> b >> f >> r >> v;
        cnt[b][f][r] += v;
    }
    for (int i = 1;i <= 4;i++){
        for (int j = 1;j <= 3;j++){
            for (int k = 1;k <= 10;k++){
                cout << " " << cnt[i][j][k];
            }
            cout << endl;
        }
        if (i != 4) cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>inline T lcm(T a,T b){return a*b/gcd(b,a%b);}

int graph[4][4],i,a,b;
bool used[4],flag;
void dfs(int v){
  flag=true;
  for(int i=0;i<4;i++){
    if(!used[i]){
      flag=false;
      break;
    }
  }
  if(flag){
    OUT("YES");
    exit(0);
  }
  for(int i=0;i<4;i++){
    if(!used[i]&&graph[v][i]){
      used[i]=true;
      dfs(i);
      used[i]=false;
    }
  }
}
inline void solve(){
  REP(i,3){
    IN2(a,b);
    graph[--a][--b]=1;
    graph[b][a]=1;
  }
  REP(i,4){
    if(!used[i]){
      used[i]=true;
      dfs(i);
      used[i]=false;
    }
  }
  OUT("NO");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main(){
	while(1){
		string s;
		int m;
		
		cin >> s;
		if(s == "-") break;
		cin >> m;
		for(int i=0; i<m; ++i){
			int a;
			cin >> a;
			
			string add = s.substr(0,a);
			s = s+add;
			s = s.substr(a, s.size());
		}
		cout << s << endl;
	}
	return 0;
	
}



Measured memory_bytes: 3188
#include <stdio.h>

int main(){

  int taro,jiro,saburo,siro,hanako,ave,n,i;
  ave=0;
  for(i=0;i<5;i++){
    scanf("%d",&taro);
    scanf("%d",&jiro);
    scanf("%d",&saburo);
    scanf("%d",&siro);
    scanf("%d",&hanako);
  }
  if(taro<40)taro=40;
  if(jiro<40)jiro=40;
  if(saburo<40)saburo=40;
  if(siro<40)siro=40;
  if(hanako<40)hanako=40;
  ave=(taro+jiro+saburo+siro+hanako)/5;
  printf("%d\n",ave);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
int main()
{
    int dp[155][15][88];
    int N, M;
    int K[155];

    while(cin >> N >> M, N || M) {
        vector < int > X[155], D[155];
        fill_n(**dp, 155 * 15 * 88, INF);
        for(int i = 0; i < N; i++) {
            cin >> K[i];
            for(int j = 0; j < K[i]; j++) {
                int x, d;
                cin >> x >> d;
                X[i].push_back(x);
                D[i].push_back(d);
            }
        } for(int i = 0; i < K[0]; i++) dp[0][i][0] = 0;
        for(int i = 0; i < K[1]; i++) dp[1][i][1] = 0;
        for(int i = 0; i < N - 1; i++) {
            for(int j = 0; j < K[i]; j++) {
                for(int k = 0; k <= M; k++) {
                    if(dp[i][j][k] == INF) continue;
                    for(int l = 0; l < K[i + 1]; l++) {
                        dp[i + 1][l][k] = min(dp[i + 1][l][k], dp[i][j][k] + (D[i][j] + D[i + 1][l]) * abs(X[i][j] - X[i + 1][l]));
                    }
                    if(k >= M || i >= N - 2) continue;
                    for(int l = 0; l < K[i + 2]; l++) {
                        dp[i + 2][l][k + 1] = min(dp[i + 2][l][k + 1], dp[i][j][k] + (D[i][j] + D[i + 2][l]) * abs(X[i][j] - X[i + 2][l]));
                    }
                }
            }
        }
        int minv = INF;
        for(int p = 0; p < 2; p++) {
            for(int i = 0; i < K[N - 2]; i++) {
                for(int j = 0; j < M + p; j++) {
                    minv = min(minv, dp[N - 2 + p][i][j]);
                }
            }
        }
        cout << minv << endl;
    }
    return (0);
}



Measured memory_bytes: 3892
package main

import "fmt"

func main() {
	var a, b, c, x, count int
	fmt.Scan(&a, &b, &c, &x)

	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if 500*i+100*j+50*k == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
<?php
$monster = explode(" ", trim(fgets(STDIN)));

while(true){
	$monster[2] -= $monster[1];
	if($monster[2] <= 0){
		echo "Yes";
		return;
	}
	$monster[0] -= $monster[3];
	if($monster[0] <= 0){
		echo "No";
		return;
	}
}

Measured memory_bytes: 16064
#include <stdio.h>

int main(int argc,char **argv)
{
	int x,y;

	scanf("%d%d",&x,&y);

	if (((x == 1) || (x == 3) || (x == 5) || (x == 7) || (x == 8) || (x == 10) || (x == 12)) && ((y == 1) || (y == 3) || (y == 5) || (y == 7) || (y == 8) || (y == 10) || (y == 12)))
	{
		printf("Yes\n");
	}

	else if (((x == 4) || (x == 6) || (x == 9) || (x == 11)) && ((y == 4) || (y == 6) || (y == 9) || (y == 11)))
		{
			printf("Yes\n");

		}

	else if((x == 2) && (y == 2))
		{
			printf("Yes\n");
		}

	else 
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
e = [tuple(map(int, input().split())) for _ in range(n)]
e.sort()  # 金額昇順
ans = 0
rest = m
for a, b in e:
    use = min(rest, b)
    ans += use * a
    rest -= use
    if rest == 0:
        break
print(ans)


Measured memory_bytes: 16984
N = int(input())
table = sorted(list(map(int, input().split())), reverse=True)
ans = table[0]
rst = N - 2

for ti in table[1:]:
    if rst == 0:
        break
    if rst == 1:
        ans = ans + ti
        break
    ans = ans + 2 * ti
    rst = rst - 2

print(ans)


Measured memory_bytes: 31376
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int n;
	cin >> n;
	int ans = n * 800 - (n / 15) * 200;
	cout << ans << endl;

	return 0;
}
 

Measured memory_bytes: 256
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> n;
	int ans = 0;
	int cn = 0;

	while( n )
	{
		 
		cn++;
		n /= 2;
		
	}
	cn--;
	ans = max( 0LL , 2*(1LL<<cn) - 1 );

	cout << ans << endl;
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}



Measured memory_bytes: 5504
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include <cassert>
using namespace std;
int main() {
	int N,D,X_beta;
	int X = 0;
	int count=0;
	cin >> N >> D;
	X_beta = 2*D + 1;
	while (N > X) {
		++count;
		X = X_beta * count;
	//cout << X << endl;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int N=1e5;
int n;
struct node
{
	int a,num;
}q[N+5];
long long ans[N+1];

bool cmp(node x,node y)
{
	if(x.a!=y.a)
	    return x.a>y.a;
	else
	    return x.num<y.num;
}
int main() 
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&q[i].a);
		q[i].num=i;
	}
	sort(q+1,q+1+n,cmp);
	int t=2,f=1;
	while(t<=n)
	{
		while(q[t].a==q[t-1].a)
		    t++;//因为要输出最小字典序，所以大一点的都要舍掉 
		ans[q[f].num]+=1ll*(q[f].a-q[t].a)*(t-1);
		if(q[f].num<q[t].num)
	        q[f].a=q[t].a;
	    else
	        f=t;
	    t++;
	}
	ans[q[f].num]+=1ll*q[f].a*n;
	for(int i=1;i<=n;i++)
	    printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 2688
N = int(input())
L = list(map(int, input().split()))

L.sort()

# print(L)
import bisect
ans = 0
for i in range(N-2):
    l1 = L[i]
    for j in range(i+1, N-1):
        l2 = L[j]
        l3_max = (l1 + l2)

        k = bisect.bisect_left(L, l3_max, lo=j+1)
        ans += max(0, k - j - 1)
print(ans)

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

int main()
{
    int n, m, t = 0, cnt = 0;
    cin >> n >> m;
    vector<int> v(n);

    for(int i = 0; i < n; ++i) 
    {
            cin >> v[i];
            t += v[i];
    }

    for(int i: v) if(i * 4 * m >= t) cnt++;
    
    cout << (cnt >= m ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char s[110];
char t[110];
int main(){
	scanf("%s%s",s,t);
	int n1=strlen(s);
	int n2=strlen(t);
	std::sort(s,s+n1);
	std::sort(t,t+n2);
	reverse(t,t+n2);
	for(int i=0;i<min(n1,n2);i++){
		if(s[i]<t[i]){
			printf("Yes\n");return 0;
		}
		if(s[i]>t[i]){
			printf("No\n");return 0;
		}
	}
	if(n1<n2)printf("Yes\n");
	else printf("No\n");
}

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

int main() {
    int n, k;
    cin >> n >> k;
    bool flag[k][n + 1];
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < n + 1; j++) {
            flag[i][j] = false;
        }
    }

    for (int i = 0; i < k; i++) {
        int m;
        cin >> m;
        for (int j = 0; j < m; j++) {
            int b;
            cin >> b;
            flag[i][b] = true;
        }
    }

    int r;
    cin >> r;
    pair<int, int> p[r];
    for (int i = 0; i < r; i++) {
        cin >> p[i].first >> p[i].second;
    }

    bool flag2[n + 1];
    for (int i = 0; i < n + 1; i++) {
        flag2[i] = false;
    }
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < r; j++) {
            if (flag[i][p[j].first] && flag[i][p[j].second]) {
                flag2[p[j].first] = true;
                flag2[p[j].second] = true;
            }
        }
    }
    int count = 0;
    for (int i = 0; i < n + 1; i++) {
        if (flag2[i]) count++;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << 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) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


bitset< 12801 > dp[80][80];

int main() {
  int H, W;
  cin >> H >> W;
  auto A = make_v< int >(H, W);
  auto B = make_v< int >(H, W);
  cin >> A >> B;
  dp[0][0][abs(A[0][0] - B[0][0]) + 6400] = true;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      int sa = abs(A[i][j] - B[i][j]);
      if(i) dp[i][j] |= dp[i - 1][j] >> sa;
      if(j) dp[i][j] |= dp[i][j - 1] >> sa;
      if(i) dp[i][j] |= dp[i - 1][j] << sa;
      if(j) dp[i][j] |= dp[i][j - 1] << sa;
    }
  }
  int ret = inf;
  for(int i = 0; i < 12801; i++) {
    if(dp[H - 1][W - 1][i]) chmin(ret, abs(6400 - i));
  }
  cout << ret << endl;
}






Measured memory_bytes: 10368
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, x, mini = MOD, ans = 0;
	cin >> n;
	vector<int> p;
	for (int i = 0; i < n; i++){
		cin >> x;
		p.push_back(x);
	}
	for (int i = 0; i < n; i++){
		if (mini >= p[i]) ans++;
		mini = min(mini, p[i]);  
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;
public class Main{ 
  
  	static long min=-1;
  	static int n, m, x;
	public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
       n =sc.nextInt();
       m=sc.nextInt();
       x=sc.nextInt();
      
      int skill[]=new int[m+1];
      int grid[][]=new int[n+1][m+1];
      for(int i=1;i<=n;i++){
      	for(int j=0;j<=m;j++){
        	grid[i][j]=sc.nextInt();       
        }
      }
      
      rec(1,skill,grid,0);
      System.out.println(min);
    }
  
  	static void rec(int i,int skill[],int grid[][],long cost){
    	if(i>n) return;
      	int skill2[]=new int[m+1];
      	boolean flag1=true;
      	for(int j=1;j<=m;j++){
          skill2[j]=skill[j]+grid[i][j];
          if(skill2[j]<x) flag1=false;
        }
      	if(flag1){
        	if(min == -1 || cost+grid[i][0] < min) min=cost+grid[i][0];
        }
      	//if i select this book
      	if(!flag1)
      	rec(i+1,skill2,grid,cost+grid[i][0]);
      
      	//don't select
      	rec(i+1,skill,grid,cost);    
    }
}

Measured memory_bytes: 36232
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int a[110];
int n;
int res=1e9;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
	{
		cin >>a[i];
		if (i) a[i]+=a[i-1];
	}
	for (int i=0;i<n-1;i++)
	{
		int x=a[i];
		int y=a[n-1]-a[i];
		res=min(res,abs(x-y));
	}
	cout <<res;
	return 0;
}

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

int main(){
    int64_t n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(begin(h),end(h));
    int64_t sum = 0;
    rep(i,n-k) sum += h[i];
    cout << sum << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] b = new long[n];
		for(int i=0; i<n; i++){
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		sc.close();
		
		long num = 0;
		
		for(int i=n-1; i>=0; i--){
			long m = b[i] - (a[i] + num + b[i]) % b[i];
			if(m != b[i]){
				num += b[i] - (a[i] + num + b[i]) % b[i];
			}
		}
		System.out.println(num);
	}

}


Measured memory_bytes: 73996
import math

a, b, h, m = (int(x) for x in input().split())

ans = 0

angle = 0

angle_ji = h * 30 + 0.5 * m
angle_fun = 6 * m

angle = angle_ji - angle_fun

if 180 < angle :
    angle = 360 - angle 

x = a * a + b * b - 2 * a * b * math.cos(math.radians(angle))

ans = x**(1/2)

print(ans)

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

int main(){
    ll n,a[100005],b[100005],c[100005],ok,ng,m,p,cnt[100005],cntz[100005],ans=0;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n){
        cin>>b[i];
    }
    rep(i,n){
        cin>>c[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    rep(i,n){
        ng=-1;
        ok=n;
        while(ok-ng>1){
            m=(ok+ng)/2;
            if(c[m]>b[i]){
                ok=m;
            }else{
                ng=m;
            }
        }
        cnt[i]=n-ok;
    }
    cntz[n]=0;
    rep(i,n){
        cntz[n-i-1]=cntz[n-i]+cnt[n-i-1];
    }
    rep(i,n){
        ng=-1;
        ok=n;
        while(ok-ng>1){
            m=(ok+ng)/2;
            if(b[m]>a[i]){
                ok=m;
            }else{
                ng=m;
            }
        }
        ans+=cntz[ok];
    }
    cout<<ans;
}

Measured memory_bytes: 7568
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};
int h,w,d,q;
int a[400][400];


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll n;
  cin >> n;
  string s="";
  while(true){
    ll q=n/(-2);
    ll r=n-q*(-2);
    if(r==-1){
      q++;
      r=1;
    }
    s=char(r+'0')+s;
    n=q;
    if(n==1 ||n==0)break;
  }
  if(n==1)s=char(n+'0')+s;
  cout << s << endl;  
}


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

int main()
{
	int A, B;
	cin >> A;
	cin >> B;

	if (A == 1 && B == 2 || A == 2 && B == 1) {
		cout << 3;
	}
	else if (A == 2 && B == 3 || A == 3 && B == 2) {
		cout << 1;
	}
	else if (A == 1 && B == 3 || A == 3 && B == 1) {
		cout << 2;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1LL<<62

ll n, a[100010];

int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		int z;
		cin>>z;
		a[z]++;
	}
	ll ans=0;
	for(int i=1;i<100005;i++){
		ll now=a[i-1]+a[i]+a[i+1];
		ans=max(ans,now);
	}
	cout <<ans;
	return 0;
	
}

Measured memory_bytes: 1024
import math
n=int(input())
k=int(math.log10(n)//1+1)

if k%2==0:
    ans=0
    for i in range(1,k,2):
        ans+=10**i-10**(i-1)
    print(ans)
else:
    ans=n-10**(k-1)+1
    for i in range(1,k,2):
        ans+=10**i-10**(i-1)
    print(ans)

Measured memory_bytes: 3188
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.LinkedList;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        char n[]=new char[N.length()];
        for(int i=0;i<N.length();i++){
            n=N.toCharArray();
        }
        Arrays.sort(n);
        for(int i=1;i<N.length();i++){
            if(n[i]==n[i-1]){
                System.out.println("no");
                return;
            }
        }
        System.out.println("yes");
    }
}


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

int main() {
  string s;
  cin >> s;
  int n;
  n = s.length();
  int count = 0;
  string curr,prev;
  rep(i,n){
    curr += s[i];
    if (curr != prev) {
      count++;
      prev = curr;
      curr = "";
    }
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int r[MAX_N];
vector<iP> vec[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,K,q;
    cin >> x >> K;
    r[0] = 0;
    rep(i,K){
        cin >> r[i+1];
    }
    cin >> q;
    vi ans(q);
    rep(i,q){
        int t,a;
        cin >> t >> a;
        vec[upper_bound(r,r+K+1,t)-r-1].pb(iP(i,P(t,a)));
    }
    int a = 0,b = x,c = 0;
    rep(i,K+1){
        each(val, vec[i]){
            P p = val.se;
            int nh = min(b-a,max(0,p.se-a))+a+c, tm = p.fi-r[i];
            if(i % 2){
                ans[val.fi] = min(x,nh+tm);
            }else{
                ans[val.fi] = max(0,nh-tm);
            }
        }
        if(i == K) break;
        if(i % 2){
            int cri = x-(r[i+1]-r[i]);
            if(cri <= a+c){
                a = 0, b = 0, c = x;
            }else if(b+c <= cri){
                c += r[i+1]-r[i];
            }else{
                b = cri-c, c = x-b;
            }
        }else{
            int cri = r[i+1]-r[i];
            if(cri <= a+c){
                c -= cri;
            }else if(b+c <= cri){
                a = 0, b = 0, c = 0;
            }else{
                a = cri-c, c = -a;
            }
        }
    }
    rep(i,q){
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

/**
 * TITLE : Dice in Line
 * URL : https://atcoder.jp/contests/abc154/tasks/abc154_d
 */
public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] P = new int[N];
        Range r = new Range();
    	int sum = 0;
        for (int i = 0; i < N; i++) {
            P[i] = sc.nextInt();
            sum += P[i];
            if (i > K-1) {
            	sum -= P[i-K];
            	if (sum > r.sum) {
            		r.sum = sum;
            		r.index = i-K+1;
            	}
            } else if (i == K-1) {
            	r.sum = sum;
            	r.index = 0;
            }

        }


        double answer = 0;
        for (int i = r.index; i < r.index + K; i++) {
        	sum = 0;
            for (int j = 1; j <= P[i]; j++) {
            	sum += j;
            }
            answer += (double)sum / P[i];
        }
        System.out.println(answer);
        sc.close();
    }

    private static class Range {
    	int sum = 0;
    	int index = 0;
    }
}

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

int main()
{
	int mod = 1e9+7;
	int h,w;
	cin >> h  >> w;
	vector<vector<char> > a(h+1,vector<char>(w+1));
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin >> a[i][j];
		}
	}
	vector<vector<int> > dp(h+1, vector<int>(w+1,0));
	dp[1][1]=1;
	for(int i=2;i<=h;i++)
	{
		if(a[i][1]!='#')
			dp[i][1] = dp[i-1][1];
		else
			dp[i][1] = 0;

	}
	for(int i=2;i<=w;i++)
	{
		if(a[1][i]!='#')
			dp[1][i] = dp[1][i-1];
		else
			dp[1][i] = 0;

	}
	for(int i=2;i<=h;i++)
	{
		for(int j=2;j<=w;j++)
		{
			if(a[i][j]!='#')
				dp[i][j] = (dp[i-1][j] +dp[i][j-1])%mod;
			else
				dp[i][j]=0;
		}
	}
	// for(int i=1;i<=h;i++)
	// {
	// 	for(int j=1;j<=w;j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << dp[h][w] << endl;
	
	return 0;
}

Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
typedef long long ll;
int MAXN = 3*1e6 + 5;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
struct node{
    int p1,p2 ;
    int index ;
} ;

int main (){
    int a,b ;
    cin >>a>>b ;
    cout<<a + (a <= b ? 0 : -1)<<endl;
    return 0;
}


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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main()
{
    string S, T;
    cin >> S >> T;
    int pos, previous_pos=-1;
    int xpos;
    int s_len = S.length();
    ll ans = 0;
    FORV(t, T)
    {
        pos = S.find(t);
        if (pos == string::npos)
        {
            cout << -1 << endl;
            return;
        }
        if (pos <= previous_pos)
        {
            xpos = S.substr(previous_pos+1, s_len).find(t);
            if (xpos==string::npos)
                ans += s_len;
            else
                pos = xpos+previous_pos+1;
        }
        ans += pos - previous_pos;
        previous_pos = pos;
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

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

using namespace std;

int main()
{
  int A,B,Q;
  cin >> A>>B>>Q;
  vector<long long> s(A);
  vector<long long> t(B);
  for( int i=0;i<A;i++ )
    cin >> s[i];
  for( int i=0;i<B;i++ )  
    cin >> t[i];

  for( int i=0;i<Q;i++ )
    {
      long long x;
      cin >> x;
      auto s_it = lower_bound(s.begin(), s.end(), x);
      auto t_it = lower_bound(t.begin(), t.end(), x);

      long long s0, s1;
      long long t0, t1;
      
      if( s_it == s.begin() )
	{
	  s0 = -100000000000L;	  
	  s1 = s[0];
	}
      else if( s_it == s.end() )
	{
	  s0 = s[A-1];
	  s1 = 100000000000L;
	}
      else
	{
	  s0 = *(s_it-1);
	  s1 = *s_it;
	}

      if( t_it == t.begin() )
	{
	  t0 = -100000000000L;
          t1 = t[0];
	}
      else if( t_it == t.end() )
	{
	  t0 = t[B-1];
      	  t1 = 100000000000L;
	}
      else
        {
          t0 = *(t_it-1);
          t1 = *t_it;
        }

      //      cout << t0 << " " << t1 << endl;
      //      cout << s0 << " " << s1 << endl;      
	
      long long dist = min(max(t1, s1)-x,
			   min(x-min(t0, s0),
			       min(2*(t1-x)+x-s0,
				   min(2*(s1-x)+x-t0,
				       min(2*(x-t0)+s1-x,
					   2*(x-s0)+t1-x)))));
      cout << dist << endl;
    }

}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
    #define ll          long long
    #define pb          push_back
    #define eb          emplace_back
    #define c(P)        cout<<P<<"\n"
    #define pii         pair<ll,ll>
    #define mi          map<ll,ll>
    #define mii         map<pii,ll>
    #define mp(x,y)     make_pair(x,y) 
    #define exit(x)     cout<<x<<"\n",return
    #define mem(a,val)  memset(a,val,sizeof(a))
    #define fr(i,a,n)   for(ll i=a;i<n;i++)
    #define frr(i,a,n)  for(ll i=n-1;i>=a;i--)
    const ll N=500005;
    const ll mod = 1e9 + 7;
    using namespace std;
    std::vector<ll> adj[N];
    std::vector<bool> vis(N);
    std::vector<ll> in_degree(N);
    ll dp[N];
    void dfs(ll x)
    {
      assert(!vis[x]);
      vis[x] = 1;
      for(ll i : adj[x])
      {
        dp[i] = max(dp[i],dp[x]+1);
        in_degree[i]--;
        if(in_degree[i]==0)
          dfs(i);
      }
    }
    void solve()
    {
      ll T=1;
      //cin>>T;
      while(T--)
      {
     // string s;
      ll n,m,k,x=0,y=0,c=0,q,ans=0;
      cin>>n>>m;
      
      for (ll i = 0; i < m; ++i)
      {
      cin>>x>>y;
      adj[x].pb(y);
      in_degree[y]++;
      }
      queue<ll> nodes;
    for (ll i = 1; i <= n; ++i)
    {
      if(!vis[i] and in_degree[i]==0)
      {
        dfs(i);
      }
    }
      for (ll i = 1; i <= n; ++i)
        ans = max(ans, dp[i]); 
      c(ans);
     
     }
    }
     
    signed main(){

            ios_base::sync_with_stdio(false);   
            cin.tie(NULL);
           solve();
        return 0;
        }

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

using namespace std;

int main(){
    int N, M;
    vector<int> K;
    vector<vector<int>> S;
    vector<int> P;
    cin >> N >> M;
    for (int m = 0; m < M;m++){
        int k;
        int ss;
        vector<int> s;
        cin >> k;
        K.push_back(k);
        for (int kk = 0; kk < k; kk++)
        {
            cin >> ss;
            s.push_back(ss);
        }
        S.push_back(s);
    }
    for (int i = 0; i < M;i++){
        int p;
        cin >> p;
        P.push_back(p);
    }
    int result = 0;
    for (int bit = 0; bit < (1 << N); bit++)
    {
        bool ok = true;
        for (int m = 0; m < M; m++)
        {
            int count = 0;
            for (int k = 0; k < K[m]; k++)
            {
                if(bit & (1<<S.at(m).at(k)-1)){
                    count++;
                }
            }
            if(count%2 != P.at(m)){
                ok = false;
                break;
            }
        }
        if(ok){
            result++;
        }
    }
    cout << result << "\n";
}


Measured memory_bytes: 3636
from numpy import*
M=10**9+7
n,k,*a=map(int,open(0).read().split())
b=int64([1]+[0]*k)
for i in a:
  b[i+1:]-=b[:~i].copy()
  b=cumsum(b)%(10**9+7)
print(b[k])

Measured memory_bytes: 14764
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.21 00:30:05
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    vector<pair<int,int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    a.push_back(make_pair(0,n));
    sort(a.begin(), a.end(), [](pair<int,int> a, pair<int,int> b){
        if (a.first == b.first) {
            return a.second < b.second;
        }
        else {
            return a.first > b.first;
        }
    });
    ll now = a[0].first,idx = a[0].second;
    vector<ll> ans(n,0);
    for (int i = 0; i < a.size(); i++) {
        ans[idx] += (now - a[i].first) * i;
        now = a[i].first;
        if (idx > a[i].second) {
            idx = a[i].second;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
    vector<int> vec = {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};
    int k;
    cin >> k;
    cout << vec.at(k-1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	cin >> str;
	auto pre = str.begin();
	int cnt = 0;
	for (auto itr = str.begin(); itr != str.end(); ++itr)
	{
		if (*itr != *pre)
		{
			cnt++;
			str.erase(itr);
			str.erase(pre);
			if (str.empty())
				break;
			itr = str.begin();
		}
	}
	cout << cnt * 2;
	return 0;
}

Measured memory_bytes: 512