akhauriyash/Code-Regression huggingface dataset:
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#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>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    ll H;
    cin >> H;
    vector<ll> mons;
    mons.push_back(H);
    ll count = 0;
    ll atack = 0;
    while(H != 0){
        H /= 2; 
        count++;
    }
    //cout << count << endl;
    ll x = 1;
    rep(i, count){
        atack += x;
        x *= 2;
    }
    cout << atack << endl;
return 0;}
/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

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

void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }

    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
    
    
  int main(){
    string s;
    cin>>s;
    lint q;
    cin>>q;
    lint rev=0;
    vector<char> ans2;
    vector<char> ans3;
    rep(i,q){
            lint x;
            cin>>x;
            if(x==1)rev++;
            else if(x==2){
                lint y;
                char f;
                cin>>y>>f;
                if(y==1&&rev%2==0){
                    ans2.push_back(f);
                }
                 if(y==1&&rev%2==1){
                        ans3.push_back(f);
                }
                 if(y==2&&rev%2==0){
                        ans3.push_back(f);
                }
                 if(y==2&&rev%2==1){
                       ans2.push_back(f);
                }
                
            }
    }
    if(rev%2==1){reverse(all(s));
        reverse(all(ans3));
        rep(i,ans3.size()){
            cout<<ans3[i];
        }
        cout<<s;
         rep(i,ans2.size()){
            cout<<ans2[i];
        }
    }
  else  if(rev%2==0){reverse(all(ans2));
         rep(i,ans2.size()){
            cout<<ans2[i];
        }
        cout<<s;
          rep(i,ans3.size()){
            cout<<ans3[i];
        }
  }
  
  }
     
  


Measured memory_bytes: 1024
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

int main(void) {
    int K, A, B;
    cin >> K >> A >> B;
    if ((A - 1) / K < B / K) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

    private Scanner scan = new Scanner(System.in);
    private final int N;
    private final int K;
    private final int[] x;

    public Main() {
	N = Integer.parseInt(scan.next());
	K = Integer.parseInt(scan.next());
	x = new int[N];

	for (int i = 0; i < N; i++) {
	    x[i] = Integer.parseInt(scan.next());
	}

	scan.close();
    }

    public final void answer() {
	int ans = Arrays.stream(x).map(x -> 2 * Integer.min(x, K-x)).sum();
	System.out.println(ans);
    }
}


Measured memory_bytes: 27476
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
typedef long long ll;
const ll MOD = (1e+9)+7;

int main(){
    string S;cin>>S;
    ll S_length = S.size();
    ll dp[S_length][13]={};
    ll mul = 1;
    for(int i = S_length-1;i>=0;i--){
        //末尾から攻めたい.
        char target = S[i];
        if(target == '?'){
            rep(n,10){
                if(i == S_length-1){
                    dp[i][n] = 1;
                }else{
                    rep(j,13){
                        if(dp[i+1][j] == 0)continue;
                        ll xx = (n * (mul%13))+j;
                        xx %= 13;
                        dp[i][xx] += dp[i+1][j]%MOD;
                    }
                }
            }
        }else{
            int tg = target-'0';
            if(i == S_length-1){
                dp[i][tg] = 1;
            }else{
                rep(j,13){
                    if(dp[i+1][j] == 0)continue;
                    ll xx = (tg * (mul%13))+j;
                    xx %= 13;
                    dp[i][xx] += dp[i+1][j]%MOD;
                }
            }
        }
        mul *= 10;
        mul %= 13;
    }
    cout<<dp[0][5]%MOD<<endl;
    return 0;
}

Measured memory_bytes: 10624
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String s = in.next();
            String t = in.next();
            for (int c = 0; c < 3; c++) {
                if (s.charAt(c) != t.charAt(2 - c)) {
                    System.out.println("NO");
                    return;
                }
            }
            System.out.println("YES");
        }
    }
}


Measured memory_bytes: 23636
num_lines = int(input())
if num_lines<2 or num_lines>50:
	print ('Illegal')
	exit()
#print(num_lines)
a=list(map(int,input().split(" ")))
#print (a)
x=[]

j=0
f=False
for i in range(num_lines):
	if(( i==0 or a[i]>=a[i-1]) and (i==num_lines-1 or a[i]<=a[i+1])):
		continue
	else:
		x.append(i)
		j+=1
#print(j)
if j>0 and j<=4 and j !=1:
	p=a[x[0]]
	a[x[0]]=a[x[j-1]]
	a[x[j-1]]=p
	for k in range(j):
		i=x[k]
		if(( i==0 or a[i]>=a[i-1]) and (i==num_lines-1 or a[i]<=a[i+1])):
			continue
		else:
			f=True
			break
elif j!=0:
	f=True
if f:
	print("NO")
else:
	print("YES")


Measured memory_bytes: 3064
#include<stdio.h>
 
int main(){
  int a,b,c,n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d %d",&a,&b,&c);
    if(a*a+b*b==c*c)
      printf("YES\n");
    else if(a*a+c*c==b*b)
      printf("YES\n");
    else if(b*b+c*c==a*a)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}

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


void testcase(){
    int n;
    cin >> n;
    vector<vector<int>> input(3, vector<int>(n));
    for(int i = 0; i < n; i++){
        cin >> input[0][i] >> input[1][i] >> input[2][i];
    }

    vector<vector<int>> dp(3, vector<int>(n));

    for(int i = 0; i < 3; i++) dp[i][0] = input[i][0];

    for(int i = 1; i < n; i++){
        dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + input[0][i];
        dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + input[1][i];
        dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + input[2][i];
    }
    cout << max({dp[0][n - 1], dp[1][n - 1], dp[2][n - 1]});
}

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

#ifdef AKP
    freopen("in.txt","r", stdin);
#endif

    int t = 1;
    //cin >> t;
    while(t--){
        testcase();
        cout << '\n';
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool db[n];
  for (int i = 0; i < n; i++) {
    int d1,d2;
    cin >> d1 >> d2;
    if (d1==d2) db[i]=true;
    else db[i]=false;
  }
  int cnt=0;
  bool ans=false;
  for (int i = 0; i < n; i++) {
    if (db[i]==true) cnt++;
    else cnt = 0;
    if (cnt==3) {
      ans = true;
      break;
    }
  }
  if (ans == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int pow (int a, int b) {
    int result = 1;
    rep(i, b) {
        result *= a;
    }
    return result;
}

int main() {
    long long H;
    cin >> H;
    long int counter = 1;
    long long answer = 1;
    while (H > 1) {
        H /= 2;
        answer += pow(2,counter);
        counter++;
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
n = int(sys.stdin.readline().split()[0])
A = defaultdict(list)
ans = []
for query in sys.stdin:
    if query[0] == '0':
        t, x = query[2:].split()
        A[t].append(x)
    elif query[0] == '1':
        ans.append(' '.join(A[query[2:-1]]) + '\n')
    else:
        A[query[2:-1]] = []
sys.stdout.writelines(ans)


Measured memory_bytes: 44308
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      x: usize,
      ls: [usize; n]
    }
    let mut d = 0;
    let mut ans = 1;
    for i in 0..n {
        d = d + ls[i];
        if d <= x {
            ans += 1;
        } else {
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
using namespace std;

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

	if (c<=a+b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
int main()
{
	ll N; cin >> N;
	ll max = 0;
	for (int i = 1; i*i <= N; i++) {
		max = i * i;
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;

	int N = S.size();
	int cnt = 0,ans=INF;
	REP(i, S.size() - 1) {
		if (S[i] != S[i + 1]) {
			ans = min(ans, max(i + 1, N - (i + 1)));
		}
	}
	if (ans == INF)ans = N;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 512
process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/));
});

// 解答
function main(inputs:Array<string>) : void {

    let numList: number[] = inputs[0].split(' ').map(Number);

    let isCheck = false;

    for (let i = 0; i < numList.length; i++) {

        if (numList.indexOf(numList[i], i + 1) != -1) {

            if (!isCheck) isCheck = true;
            else isCheck = false;
        }
    }


    if (isCheck) console.log('Yes')
    else console.log('No');
}


Measured memory_bytes: 7500
n,m = map(int, input().split())
a = list(map(int, input().split()))

rui=[0]
last=0
for i in range(n):
    last+=a[i]
    rui.append(last)
from collections import defaultdict
mod = defaultdict(int)
for num in rui:
    mod[num%m]+=1

ans=0
for v in mod.values():
    ans+=(v*(v-1))//2
print(ans)

Measured memory_bytes: 63000
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  vector<vector<int>> path(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    path[a].push_back(b);
    path[b].push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    bool flag = true;
    for (int j = 0; j < path[i].size(); j++) {
      if (h[path[i][j]] >= h[i]) flag = false;
    }
    ans += flag;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8668
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
	ll n, a, b, p, ans = 0, t;
	cin >> n >> a >> b >> p;
	for (int i = 1; i < n; ++i, p = t) {
		cin >> t; ans += min((t - p) * a, b);
	} cout << ans << endl;
	return 0;	
}


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

#define int long long
typedef unsigned long long ull;
typedef vector<ull> vec;
typedef vector<vec> mat;
typedef pair<int,ull> P;
#define N 4

ull po[N*N+10];
ull m2i(mat m){
  int res=0;
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      res+=m[i][j]*po[i*N+j];
  return res;
}
mat i2m(ull x){
  mat res(N,vec(N));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      if(i==N-1&&j==N-1) res[i][j]=x/po[i*N+j];
      else res[i][j]=(x%po[i*N+j+1])/po[i*N+j];
  return res;
}
int dist(mat m){
  int res=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(!m[i][j]) continue;
      int k=m[i][j]-1;
      int y=k/N,x=k%N;
      res+=abs(i-y)+abs(j-x);
    }
  }
  return res;
}
signed main(){
  po[0]=1;
  for(int i=0;i<N*N;i++) po[i+1]=po[i]*(N*N);
  mat p(N,vec(N));
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      cin>>p[i][j];
  mat e(p);
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
      e[i][j]=i*N+j+1;
  e[N-1][N-1]=0;
  ull ans=m2i(e);
  priority_queue<P,vector<P>,greater<P> > q;
  map<ull,int> m;
  q.push(P(dist(p),m2i(p)));
  m[m2i(p)]=0;
  int ax[]={1,0,-1,0};
  int ay[]={0,1,0,-1};
  while(!q.empty()){
    P y=q.top();q.pop();
    ull x=y.second;
    if(x==ans) break;
    p=i2m(x);
    int zy,zx;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
        if(p[i][j]==0) zy=i,zx=j;
    for(int k=0;k<4;k++){
      int ny=zy+ay[k],nx=zx+ax[k];
      if(ny<0||N<=ny||nx<0||N<=nx) continue;
      swap(p[zy][zx],p[ny][nx]);
      ull t=m2i(p);
      if(!m.count(t)||m[x]+1<m[t]){
        m[t]=m[x]+1;
        q.push(P(m[t]+dist(p),t));
      }
      swap(p[zy][zx],p[ny][nx]);
    }
  }
  cout<<m[ans]<<endl;
  return 0;
}



Measured memory_bytes: 177636
X, N = map(int, input().split())
p = list(map(int, input().split()))

candidates = []

x = X
while(True):
    if not x in p:
        candidates.append(x)
        break
    else:
        x += 1
x = X
while(True):
    if not x in p:
        candidates.append(x)
        break
    else:
        x -= 1

if abs(X-candidates[0]) == abs(X-candidates[1]):
    print(min(candidates))
elif abs(X-candidates[0]) > abs(X-candidates[1]):
    print(candidates[1])
else:
    print(candidates[0])


Measured memory_bytes: 9180
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = new String[3];
		for (int i = 0; i < 3; i++) {
			s[i] = sc.next();
		}
		int i = 0;

		while (s[i].length()!=0) {
			int n = s[i].charAt(0) - 'a';
			s[i] = s[i].substring(1);
			i=n;
		}
		System.out.println((char)('A'+i));

	}

}

Measured memory_bytes: 8916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define PI (acos(-1))
#define mod (1000000007)
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; }

const int MAX_N = 105;
const int MAX_V = 100005;
const long long INF = 1LL<<60;

int N;
ll W, weight[MAX_N], value[MAX_N]; 

ll dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    rep(i,N) cin >> weight[i] >> value[i];

    rep(i,MAX_N) rep(j,MAX_V) dp[i][j] = INF;

    dp[0][0] = 0;

    rep(i,N) rep(sum_v, MAX_V) {
            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
    }

    ll res = 0;
    rep(sum_v, MAX_V) if (dp[N][sum_v] <= W) res = sum_v;
    cout << res << endl;
}
    


Measured memory_bytes: 82304
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
Int N;
Int limit;
Int ans;
int dfs(int level, Int num){
    if (level >= limit){
        int flag[4] = {0};
        flag[3] = 1;
        Int tmp = num;
        while (tmp > 0){
            Int check = tmp%10;
            tmp /= 10;
            if (check == 7){
                flag[0] = 1;
            }else if (check == 5){
                flag[1] = 1;
            }else if (check == 3){
                flag[2] = 1;
            }else{
                flag[3] = 0;
                break;
            }
        }
        for (int i = 0; i < 3; i++){
            if (!flag[i] || num > N){
                flag[3] = 0;
            } 
        }
        if (flag[3]) ans++;
        return 0;
    }

    Int sichigo[4] = {7, 5, 3, 0};
    for (int i = 0; i < 4; i++){
        num += mod_pow(10, level) * sichigo[i];
        dfs(level+1, num);
        num -= mod_pow(10, level) * sichigo[i];
    }
    return 0;
}

int main(){
    cin.tie(0);

    cin >> N;
    Int tmp = N;
    while (tmp > 0){
        tmp /= 10;
        limit++;
    }
    dfs(0, 0);
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define N 100009
#define M 400009
using namespace std;

int n,m,tot,sz,fst[N],pnt[M],nxt[M],vis[N]; bool flag;
void add(int x,int y){
	pnt[++tot]=y; nxt[tot]=fst[x]; fst[x]=tot;
}
void dfs(int x,int t){
	if (!vis[x]){
		sz++; vis[x]=t;
	} else{
		if (vis[x]!=t) flag=1; 
		return;
	}
	int i;
	for (i=fst[x]; i; i=nxt[i])
		dfs(pnt[i],t^3);
}
int main(){
	scanf("%d%d",&n,&m);
	int i,x,y;
	for (i=1; i<=m; i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	ll t1=0,t2=0,t3=0;
	for (i=1; i<=n; i++) if (!vis[i]){
		sz=0; flag=0;
		dfs(i,1);
		if (sz==1) t1++; else
		if (flag) t2++; else t3++;
	}
	printf("%lld\n",t1*(n-t1)*2+t2*t3*2+t1*t1+t2*t2+t3*t3*2);
	return 0;
}


Measured memory_bytes: 6016
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



long long N, K;
int main() {
    while (cin >> N >> K) {
        double res = 0.0;
        for (long long n = 1; n <= N; ++n) {
            double tmp = 1.0;
            long long nn = n;
            while (nn < K) nn *= 2, tmp /= 2.0;
            res += tmp;
        }
        res /= N;
        cout << fixed << setprecision(10) << res << endl;
    }
}









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

using namespace std;

int main() {
  string S;
  cin >> S;
  
  string words[4] = {"dream", "dreamer", "erase", "eraser"};

  while (S.size() > 0) {
    int len = S.size();
    bool noMatch = true;
    for (int i = 0; i < 4; i++) {
      string w = words[i];
      int w_len = w.size();
      if (len - w_len >=0 && S.substr(len - w_len, len) == w) {
        noMatch = false;
		S = S.substr(0,len - w_len);
        break;
      }
    }

    if (noMatch) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

}

Measured memory_bytes: 512
#include<stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d", &a, &b);
	if(a<b)
	{
		printf("a < b\n");
	}
	else if(a>b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2068
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <iomanip>   //setprecision(10) 

using namespace std;

int main() {
    int A, B, C = 0;

    cin >> A >> B >> C;
    if (A==B&&A!=C) {
        cout <<"Yes";
    } 
    else if (A==C&&A!=B) {
        cout <<"Yes";
    }
    else if (B==C&&B!=A) {
        cout <<"Yes";
        // exit(1);
    }
    else cout << "No";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

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

    vector<ll> a(n);
    for(auto &x:a)cin >> x;

    sort(a.begin(),a.end());

    if(a[0]>x){
        cout << 0 << endl;
        return 0;
    }

    vector<ll> asum(n);
    asum[0]=a[0];
    int ans=-1;
    for(int i=1;i<a.size();i++){
        asum[i]=asum[i-1]+a[i];
        if(asum[i]==x){
            ans=i+1;
            break;
        }else if(asum[i]>x){
            ans=i;
            break;
        }
    }

    if(ans==-1){
        ans=n-1;
    }

    cout << ans << endl;

    return 0;
}


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

void disp(vector<vector<int>> v) {
    for(auto i:v) {
        for(auto j:i) {
            cout<<j<<" ";
        }
        cout<<endl;
    }
}

int main() {
  int n=0,k=0,tmp=0;
  vector<int> stones;
  vector<int> dp;
  cin>>n>>k;
  for(int i=0;i<n;i++) {
    cin>>tmp;
    stones.push_back(tmp);
  }
  if(n<=1) {
    cout<<0<<endl;
    return 0;
  }
  dp.push_back(0);
  for(int i=1;i<n;i++) {
      int mini=INT_MAX;
      for(int j=i-1;j>=max(i-k,0);j--) {
          mini=min(mini,dp[j]+abs(stones[i]-stones[j]));
      }
      dp.push_back(mini);
      //cout<<mini<<" ";
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <unordered_map>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>

using namespace std;

int main() {
	int c;
	cin >> c;
	unordered_set<int> set;

	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			set.insert(i * j);
		}
	}

	if (set.find(c) != set.end()) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

template< typename T>
T getDigit(T num) {
    T digit = 0;
    while (num != 0) {
        num /= 10;
        digit++;
    }
    return digit;
}

int64_t F(int64_t a, int64_t b) {
    return std::max(getDigit(a), getDigit(b));
}

int main()
{
    int64_t N;
    std::cin >> N;

    int64_t ans = INT64_MAX;

    int64_t sq = sqrt(N)+1;
    for (int64_t a = 1; a < sq; ++a) {
        if (N % a == 0) {
            int64_t b = N / a;
            ans = std::min(ans, F(a, b));
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ZYCSwing
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = in.nextInt();
            int n = in.nextInt();

            if (k % 2 == 0) {
                out.print(k / 2);
                for (int i = 1; i < n; ++i) {
                    out.print(" " + k);
                }
                out.println();
            } else {
                List<Integer> res = new ArrayList<>();
                for (int i = 0; i < n; ++i) res.add((k + 1) / 2);
                int cnt = n / 2;

                for (int i = 0; i < cnt; ++i) {
                    if (res.get(res.size() - 1) > 1) {
                        res.set(res.size() - 1, res.get(res.size() - 1) - 1);
                        while (res.size() < n) res.add(k);
                    } else {
                        res.remove(res.size() - 1);
                    }
                }

                for (int i = 0; i < res.size(); ++i) {
                    out.print(res.get(i));
                    if (i < res.size() - 1) {
                        out.print(" ");
                    } else {
                        out.println();
                    }
                }
            }
        }

    }
}



Measured memory_bytes: 47700
#include <stdio.h>

int main(int argc, char const *argv[])
{
  int a;
  scanf("%d", &a);
  int b;
  scanf("%d", &b);

  int c = (int)(((double)(a + b) / 2) + 0.5);

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

  return 0;
}


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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

bool is_eight(int num){
    int cnt = 0;
    FORS(i, 1, num){
        if(num%i==0) cnt++;
    }
    if (cnt == 8) return true;
    else return false;
}

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

    int cnt =0;
    for (int i=1; i <= N; i+=2){
        if (is_eight(i)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
def main(n, y):
    for n1000 in range(n + 1):
        for n5000 in range(n - n1000 + 1):
            n10000 = n - n1000 - n5000
            if (1000 * n1000 + 5000 * n5000 + 10000 * n10000) == y:
                return [n10000, n5000, n1000]

    return [-1, -1, -1]

n, y = map(int, input().split())
print(' '.join(map(str, main(n, y))))




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

#define all(v) begin(v), end(v)
#define endl '\n';
#define int long long
#define pii pair<int, int>

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

    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    set<int> st;
    for (int& xx : p) {
        cin >> xx;
        st.insert(xx);
    }
    if (st.count(x) == 0) {
        cout << x << endl;
    }
    else {
        for (int i = 1; i <= 100; i++) {
            if (st.count(x - i) == 0) {
                cout << x - i << endl;
                break;
            }
            else if (st.count(x + i) == 0) {
                cout << x + i << endl;
                break;
            }
        }
    }

}

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

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Solve();
            System.Console.WriteLine(Result);
        }

        public static string Result { get; set; }

        private static void Solve()
        {
            var sa = Console.ReadLine();
            var sb = Console.ReadLine();
            var sc = Console.ReadLine();
            int idxOfA = 0, idxOfB = 0, idxOfC = 0;
            var currentTurn = 'a';

            while (true)
            {
                switch (currentTurn)
                {
                    case 'a':
                        if (idxOfA == sa.Length)
                        {
                            Result = "A";
                            return;
                        }
                        currentTurn = sa[idxOfA++];
                        break;
                    case 'b':
                        if (idxOfB == sb.Length)
                        {
                            Result = "B";
                            return;
                        }
                        currentTurn = sb[idxOfB++];
                        break;
                    case 'c':
                        if (idxOfC == sc.Length)
                        {
                            Result = "C";
                            return;
                        }
                        currentTurn = sc[idxOfC++];
                        break;
                    default:
                        break;
                }
            }
        }
    }

    public static class Utils
    {
        #region Extensions for IO

        public static int ReadInt()
            => ReadInts().First();

        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static IEnumerable<String> ReadStrings()
            => Console.ReadLine().Split(' ');

        #endregion

        #region Extensions of int

        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;
        
        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;

        #endregion

        #region Extensions of string

        public static int ToInt(this string str)
        => int.Parse(str);

        public static bool IsNullOrEmpty(this string str)
            => string.IsNullOrEmpty(str);

        #endregion
    }
}


Measured memory_bytes: 2648
s = input()

if s == "SSS":
    print(0)
    exit()

cnt = 1
if s[0] == "R" and s[1] == "R":
    cnt += 1
if s[2] == "R" and s[1] == "R":
    cnt += 1

if cnt == 1:
    print(cnt)
else:
    print(cnt)

Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int a,b,c;cin>>a>>b>>c;
    cout << min(b/a, c) << endl;
    return 0;
}


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

int main(){
    int N;
    int A[1000];
    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> A[i];
        if (A[i] % 2 == 0){
            if (A[i] % 3 == 0 || A[i] % 5 == 0){
                continue;
            }else{
                cout << "DENIED" <<endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main()
{
int n,t;
cin>>n>>t;
int a,b;
int mn=100000;
for(int i=0;i<n;i++)
{
cin>>a>>b;
if(b<=t)
{
mn=min(a,mn);
}
}
if(mn==100000)
{
cout<<"TLE";
}
else
{
cout<<mn<<endl;
}
}


Measured memory_bytes: 256
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int long long
#define P make_pair
#define F first
#define S second
signed main(void){
    int n,m,ans,p,q;
    ans=0;
    string s,t,u;
    cin>>s>>t;
    cin>>n>>m;
    cin>>u;
    rep(i,0,s.size()){
        if(s[i]!=u[i]||s.size()!=u.size()){
            cout<<n<<" "<<m-1<<endl;
            return 0;
        }
    }
    cout<<n-1<<" "<<m<<endl;
    return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main(){
	ll n;
	cin>>n;
	ll p=n%10;
	if(p==2||p==4||p==5||p==7||p==9){
		cout<<"hon"<<"\n";
	}
	else if(p==0||p==1||p==6||p==8){
		cout<<"pon"<<"\n";
	}
	else{cout<<"bon"<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3624
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])
const p = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = () => {
  if (isUpperOrder(p)) 'YES'

  for (let i = 0; i < n; i++) {
    for (let j = 0; j < n; j++) {
      const arr = [...p]

      arr[i] = p[j]
      arr[j] = p[i]

      if (isUpperOrder(arr)) {
        return 'YES'
      }
    }
  }

  return 'NO'
}

const isUpperOrder = ar => {
  for (let i = 1; i < n; i++) {
    if (ar[i - 1] > ar[i]) {
      return false
    }
  }

  return true
}

console.log(ans())


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

int H, W;
vector<int> V[400];
string S[20];
vector<int> isVisited;

int id(int i, int j){
  return i*W + j;
}

void gen_map(){
  rep(i, H){
    rep(j, W){
      if(S[i][j]=='.'){
        if(i-1>=0)if(S[i-1][j]=='.')V[id(i-1, j)].push_back(id(i, j));
        if(i+1<H)if(S[i+1][j]=='.')V[id(i+1, j)].push_back(id(i, j));
        if(j-1>=0)if(S[i][j-1]=='.')V[id(i, j-1)].push_back(id(i, j));
        if(j+1<W)if(S[i][j+1]=='.')V[id(i, j+1)].push_back(id(i, j));
      }
    }
  }
}

ll bfs(ll current){
  ll s = V[current].size();
  isVisited[current]=1;
  vector<pair<ll, ll>> way;
  way.push_back({current, 0});
  ll pos = 0;
  ll maxlen = 0;
  while(true){
    if(pos>=way.size())break;
    ll curpos = way[pos].first;
    ll curlen = way[pos].second;
    //isVisited[curpos]=1;
    s = V[curpos].size();
    rep(i, s){
      ll a = V[curpos][i];
      if(isVisited[a]==1)continue;
      way.push_back({a, curlen+1});
      maxlen = max(maxlen, curlen+1);
      isVisited[a]=1;
    }
    pos++;
  }
  return maxlen;
}

/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  cin >> H >> W;
  rep(i, H) cin >> S[i];
  gen_map();

  ll ans = 0;
  rep(i, H*W){
    isVisited = vector<int>(H*W, 0);
    //isVisited[i]=1;
    ans = max(ans, bfs(i));
  }

  cout << ans;
  /*
  rep(i, H*W){
    rep(j, V[i].size()) cout << V[i][j] << " ";
    cout << endl;
  }*/
  
  
  return 0;
}


Measured memory_bytes: 256
function main(input){
	const length = parseInt(input.split("\n")[0]);
	var input_str = input.split("\n")[1];

	if(length >= input_str.length){
		console.log(input_str);
	}
	else{
		console.log(input_str.substr(0,length)+"...");
	}
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29620
// Problem link : 
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<=n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}}cout<<endl;
int n;
void stringEq(char *a,int i,char c)
{
	//base case
	if(i==n)
	{
		a[i]='\0';
		cout<<a<<endl;
		return;
	}
	//recrsive case
	for(char ch='a';ch<=c;ch++)
	{
		a[i]=ch;
		if(ch==c)
		stringEq(a,i+1,c+1);//index1 = a
		else				//index2 = a/b
		stringEq(a,i+1,c);	//index3 = a/b/c and so on

	}
}
int main()
{
	// int n;
	cin>>n;
	char a[100];
	stringEq(a,0,'a');
	return 0;
}

Measured memory_bytes: 1536
# coding: -utf8

N = int(input())
A = input().split(" ")
Alice = []
Bob = []

max = 0
mnum = 0
turn = 0
for i in range(N):
  A[i] = int(A[i])
  if(max < A[i]):
    max = A[i]
    mnum = i

Alice.append(max)
A.pop(mnum)
turn = 1

N = N -1

for i in range(N):
  max = 0
  mnum = 0
  for j in range(N):
    if(max < A[j]):
      max = A[j]
      mnum = j
  if(turn == 0):
    Alice.append(max)
    A.pop(mnum)
    turn = 1
  elif(turn == 1):
    Bob.append(max)
    A.pop(mnum)
    turn = 0
  N = N - 1

print(sum(Alice)-sum(Bob))

Measured memory_bytes: 3064
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int l,r,d;
		cin>>l>>r>>d;
		int ct = 0;
		for(int i=l;i<=r;++i)
		{
			if(i%d==0)
			++ct;
		}
		cout<<ct;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
#define enl << endl
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, k;
    cin >> n >> k;
    
    ll res = 0;
    if(k == 0) res = n*n;
    else{
        reps(b, k+1, n){
            res += n/b * (b-k) - (k-1)/b * (b-k);
            res += n%b < k ? 0 : n%b-k+1;
        }
    }
    
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256