akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin >> h >> w;
    if (h == 1 || w == 1) PRINT(1);
    else if (h*w%2) PRINT(h*w/2+1);
    else PRINT(h*w/2);
}


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

int main()
{
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = 0;

    if (A + B < 2 * C)
        ans = A * X + B * Y;
    else
    {
        if (X >= Y)
        {
            ans += 2 *C * Y;
            if (A <= 2 * C)
            {
                ans += A * (X - Y);
            }
            else
            {
                ans += C * (X - Y) * 2;
            }
        }
        else
        {
            ans += 2 * C * X;
            if (B <= 2 * C)
            {
                ans += B * (Y - X);
            }
            else
            {
                ans += C * (Y - X) * 2;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int>A(N);
  rep(i,N){
    cin>>A[i];
  }
  int sum=0;
  rep(i,N){
    sum+=A[i];
  }
  int output=0;
  rep(i,N){
    if(A[i]*4*M>=sum){
      output++;
    }
  }
  if(output>=M){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main(){
  long long N;
  cin >> N;
  long long ans = 1000000000000000000;
  for (long long i = 1; i * i <= N; i++){
    if(N % i == 0){
      long long j = N / i;
      ans = min(ans, (i - 1) + (j - 1));
    }
  }
  cout << ans;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  int n = s.size();
  for(int i=0; i<26; ++i) for(int j=0; j<n; ++j){
    if(s[j] == 'a'+i){
      char cs = s[j], ct = t[j];
      for(int k=j; k<n; ++k){
        if(s[k] == cs && t[k] != ct){
          cout << "No" << endl;
          return 0;
        }
        if(t[k] == ct && s[k] != cs){
          cout << "No" << endl;
          return 0;
        }
      }
      break;
    }
  }
  cout << "Yes" << endl;
}

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

typedef long long ll;
typedef complex<double> Vec;

ll N;
const ll MOD = 998244353;
vector<ll> Pow;
vector<ll> Y;
vector<pair<ll, ll>> XY;
map<ll, ll> IY;
ll R;

void prepare() {
  Pow.push_back(0);
  for (ll i = 1; i <= N; ++i) {
    Pow.push_back((Pow.back() * 2 + 1) % MOD);
  }
}

vector<ll> BIT;
void init() {
  BIT.clear();
  BIT.resize(N + 1);
}
void add(ll i, ll x) {
  ++i;
  for (; i <= N; i += i & -i) BIT[i] += x;
}
ll sum(ll i) {
  ++i;
  ll res = 0;
  for (; i > 0; i -= i & -i) res += BIT[i];
  return res;
}
void solve() {
  R = N * Pow[N] % MOD;
  for (ll i = 0; i < N; ++i) {
    (R += MOD - 2 * (Pow[i] + Pow[N - 1 - i]) % MOD) %= MOD;
  }
  for (ll mode = 0; mode < 2; ++mode) {
    init();
    for (ll cnt = 0; cnt < N; ++cnt) {
      ll y = XY[mode == 0 ? cnt : N - 1 - cnt].second;
      ll i = IY.at(y);
      ll left = sum(i);
      ll right = cnt - left;
      assert(left >= 0 && right >= 0);
      (R += Pow[left]) %= MOD;
      (R += Pow[right]) %= MOD;
      add(i, 1);
    }
  }
}

int main() {
  cin >> N;
  prepare();
  for (ll i = 0; i < N; ++i) {
    ll x, y;
    cin >> x >> y;
    Y.push_back(y);
    XY.push_back(make_pair(x, y));
  }
  sort(Y.begin(), Y.end());
  for (ll i = 0; i < N; ++i) {
    IY[Y[i]] = i;
  }
  sort(XY.begin(), XY.end());
  solve();
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 21740
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] h = new int[n];
        boolean[] judge = new boolean[n];
        int ans = 0;
        for (int i = 0 ; i <n ; i++){
            h[i]= scan.nextInt();
        }
        for (int i = 0 ; i <m ; i++){
            int a = scan.nextInt()-1;
            int b = scan.nextInt()-1;
            if (h[a]<=h[b]){
                judge[a] = true;
            }
            if (h[a]>=h[b]){
                judge[b] = true;
            }
        }
        for (int i = 0; i<judge.length ; i++){
            if (!judge[i]){
                ans ++;
            }
        }
        System.out.println(ans);
            }
        }

Measured memory_bytes: 59432
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m);
  rep(i, m) cin >> a[i];

  ll sum=0;
  rep(i, m) sum+=a[i];
  if(sum>n)  cout << "-1" << endl;
  else       cout << n-sum << endl;

  return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  int res=0;
  vector<int>h(n),dh(n);
  rep(i,n)cin>>h[i];
  rep(i,n-1)
  {
    dh[i]=h[i+1]<=h[i];
  }
  int idx=0;
//  rep(i,n)cout<<dh[i];
  while(idx<n)
  {
    int tl=0;
    while(dh[idx])
    {
      tl++;
      idx++;
      if(idx>=n)break;
    }
    idx++;
    chmax(res,tl);
    tl=0;

  }
  cout<<res<<endl;

}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <iomanip>

using namespace std;

int main(int argc, char *argv[])
{
  double L;
  cin >> L;
  double r = L * L * L / 27;

  cout << fixed << setprecision(15) << r << endl;

  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int sx = Integer.parseInt(scanner.next());
	    int sy = Integer.parseInt(scanner.next());
	    int tx = Integer.parseInt(scanner.next());
	    int ty = Integer.parseInt(scanner.next());
	    out1(sx, sy, tx, ty);

	}

	public static void out1(int sx, int sy, int tx, int ty) {
		int tsx = tx - sx;
		int tsy = ty - sy;
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < tsx; i++) {
		    sb.append("R");
		}
		for (int i = 0; i < tsy; i++) {
		    sb.append("U");
		}
		for (int i = 0; i < tsx; i++) {
		    sb.append("L");
		}

		for (int i = 0; i < tsy + 1; i++) {
		    sb.append("D");
		}
		for (int i = 0; i < tsx + 1; i++) {
		    sb.append("R");
		}
		for (int i = 0; i < tsy + 1; i++) {
		    sb.append("U");
		}
		sb.append("L");
		sb.append("U");
		for (int i = 0; i < tsx + 1; i++) {
		    sb.append("L");
		}
		for (int i = 0; i < tsy + 1; i++) {
		    sb.append("D");
		}
		sb.append("R");
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 35868
#https://scrapbox.io/pocala-kyopro/B_-_Kleene_Inversion
MOD = 1000000007
N,K = map(int,input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
    migi = 0
    zentai = 0
    for j in range(i,N):
        if A[i] > A[j]:
            migi += 1
    for j in range(N):
        if A[i] > A[j]:
            zentai += 1
            
    ans += migi * K % MOD
    ans %= MOD
    ans += (K-1)*K//2 % MOD * zentai % MOD
    ans %= MOD
print(ans)


Measured memory_bytes: 9232
#include <stdio.h>

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


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

int n, a[202020];

int main(){
  cin >> n;
  rep(i, n) cin >> a[i];
  int m1 = -1, pos1 = -1;
  for(int i = 0; i < n; i++){
    if(a[i] > m1){
      m1 = a[i];
      pos1 = i;
    }
  }
  int m2 = -1, pos2 = -1;
  for(int i = 0; i < n; i++){
    if(i == pos1) continue;
    if(a[i] > m2){
      m2 = a[i];
      pos2 = i;
    }
  }
  //cout << m1 << " " << pos1 << endl;
  //cout << m2 << " " << pos2 << endl;
  
  for(int i = 0; i < n; i++){
    if(i == pos1){
      cout << m2 << endl;
    }else{
      cout << m1 << endl;
    }
  }
  //rep(i, n) cout << a[i] << ((i == n-1)? "\n" : " ");
  return 0;
}

Measured memory_bytes: 2432
n, m, k = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

a = []
a.append(0)
for i in range(n):
    a.append(a[i]+a_list[i])
    
b = []
b.append(0)
for i in range(m):
    b.append(b[i]+b_list[i])
    

ans = 0
for i in range(n+1):
    if a[i]>k:
        break
    while a[i] + b[m] > k:
        m -= 1
    ans = max(ans, i+m)
    
print(ans)
    
    
    
    
    

Measured memory_bytes: 47312
#include <iostream>

#define N 100010

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

	int n, m;
	std::cin >> n >> m;
	int boxes[N];
	bool possible[N];
	for (int i = 1; i <= n; ++i) {
		boxes[i] = 1;
		possible[i] = false;
	}
	possible[1] = true;
	for (int i = 0; i < m; ++i) {
		int x, y;
		std::cin >> x >> y;
		--boxes[x];
		++boxes[y];
		if (possible[x]) {
			possible[y] = true;
		}
		if (boxes[x] == 0) {
			possible[x] = false;
		}
	}

	int res = 0;
	for (int i = 1; i <= n; ++i) {
		if (possible[i]) {
			++res;
		}
	}
	std::cout << res << '\n';
	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

int main(void){
	 int x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0;
	 scanf("%d",&x1);
	 scanf("%d",&x2);
	 scanf("%d",&x3);
	 scanf("%d",&x4);
	 scanf("%d",&x5);
	 if (x1 == 0) {
		 printf("1");
	 }
	 else if (x2 == 0) {
		 printf("2");
	 }
	 else if (x3 == 0) {
		 printf("3");
	 }
	 else if (x4 == 0) {
		 printf("4");
	 }
	 else if (x5 == 0) {
		 printf("5");
	 }

	 return 0;
}

Measured memory_bytes: 1588
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    n = ri()
    n -= 1
    out = ""
    while n >= 0:
        n, r = divmod(n, 26)
        n -= 1
        out = chr(ord('a') + r) + out
    print (out)






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 65124
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		int n = ni();
		int[] a = na(n);
		boolean ok = true;
		for(int i:a) {
			if(i%2 ==0) {
				if(i%3 != 0 && i%5 != 0) {
					ok = false;
					break;
				}
			}
		}
		if(ok) {
			System.out.println("APPROVED");
		} else {
			System.out.println("DENIED");
		}
		
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<long long, long long>;
using T = tuple<long, long, long>;

long long MOD = 1000000007;
long long dp[100005][4];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {
	long long N, H;
	cin >> N >> H;

	vector<P>ab(N);
	long long aMax = -100;
	long long bSum = 0;
	for (int i = 0; i < N;++i) {
		cin >> ab[i].first >> ab[i].second;
		aMax = max(aMax,ab[i].first);
		bSum += ab[i].second;
	}
	sort(ab.begin(),ab.end(), compare_by_second);

	long long h = H;
	long long nageruKazu = 0;
	long long nageruSum = 0;
	for (int i = N - 1; 0 <= i; --i) {
		if (aMax <= ab[i].second) {
			nageruKazu++;
			h -= ab[i].second;
			if (h <= 0) {
				cout << nageruKazu << endl;
				return 0;
			}
		}
		else break;
	}

	long long ans = nageruKazu + (h + (aMax - 1)) / aMax;

	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	rep(i, h) {
		dunk(s[i]);
		dunk(s[i]);
	}
	return 0;
}

Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln endl
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inp freopen("input.txt", "r", stdin)
#define outp freopen("output.txt", "w", stdout)
#define dbgm(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 2e5+5, MOD = 1e9+7, EPS = 1e-9;
int t,n,m,k,x,y;
int main(){
	fastio;
	cin>>n;
	ll a[n];
	forn(i,n) cin>>a[i];
	ll ans[n][n][2];
	forn(i,n){
		forn(j,n){
			forn(k,2) ans[i][j][k]=0;
		}
	}
	forn(i,n){
		ans[i][i][0] = a[i];
		ans[i][i][1] = -a[i];
	}
	forsn(i,1,n+1){
		forn(j,n){
			if(j+i>=n) continue;
			ll mi = 1e18;
			ans[j][j+i][0] = max(a[j]+ans[j+1][j+i][1], a[j+i]+ans[j][j+i-1][1]);
			ans[j][j+i][1] = min(-a[j]+ans[j+1][j+i][0], -a[j+i]+ans[j][j+i-1][0]);
			//ans[j][j+i] = mi+sum[j][j+i];
		}
	}
	cout<<ans[0][n-1][0]<<ln;
	return 0;
}

Measured memory_bytes: 140928
#include<stdio.h>
#include<string.h>

int main(void){
    char a[16],b[16],c[16];
    scanf("%s%s%s",a,b,c);
    if(a[strlen(a)-1] == b[0] && b[strlen(b)-1] == c[0]){printf("YES\n");}else{printf("NO\n");}
    return 0;
}

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

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

const int MOD = 1e9 + 7;
int n;
string s;

bool double_check(int i1, int i2, int k) {
  while (k) {
    if (s[i1--] != s[i2--]) return false;
    --k;
  }
  return true;
}

bool check(int k) {
  // cout << "check: " << k << endl;
  ll sum = 0;
  ll base = 1;
  unordered_map<ll, int> mp;
  for (int i = 0; i < k; ++i) {
    sum = (sum * 26 + (s[i] - 'a')) % MOD;
    base = base * 26 % MOD; // next base
  }
  mp[sum] = k - 1;
  for (int i = k; i < n; ++i) {
    sum = (sum * 26 % MOD + (s[i] - 'a')) % MOD;
    sum = (sum - (base * (s[i - k] - 'a') % MOD)) % MOD;
    if (sum < 0) sum += MOD;
    // cout << i - k + 1 << ' ' << sum << endl;
    if (mp.count(sum)) {
      int right = mp[sum];
      if (i - k + 1 > right) {
        if (double_check(right, i, k))
          return true;
      }
    } else {
      mp[sum] = i;
    }
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> s;
  int l = 1;
  int r = n / 2;
  while (l < r) {
    int m = (l + r + 1) / 2;
    if (check(m)) {
      l = m;
    } else {
      r = m - 1;
    }
  }
  if (check(l)) {
    cout << l << endl;
  } else {
    cout << 0 << endl;
  }


  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  if (k % 2) {
    ll a = n / k;
    cout << a * a * a << endl;
  } else {
    ll a = n / k;
    ll b = n / (k / 2) - a;
    cout << a * a * a + b * b * b << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



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

	cin >> a >> b;
	int ans = 0;
	rep(i, a, b + 1) {
		int c = i / 10000;
		int d = i % 10;
		int e = i / 1000 % 10;
		int f = i / 10 % 10;

		if (c == d && e == f)ans++;
	}

	cout << ans << endl;

	
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int p = -1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a == 1)
      p = i;
  }

  int ret = (n - k + k - 2) / (k - 1) + 1;
  cout << ret << "\n";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

int main()
{
    string s;
    int ans = 0;
    while(getline(cin, s))
    {
        s += ".";
        int l = s.size(), t = 0;
        REP(l)
        {
            if(s[i]>='0' && s[i] <='9') t = t * 10 + (int)(s[i] - '0');
            else { ans += t; t = 0;}
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 0
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    auto H = aryread();
    foreach_reverse (i; 0 .. N - 1)
    {
        // writeln(i);
        if (H[i + 1] - H[i] < -1)
        {
            writeln("No");
            return;
        }
        if (H[i + 1] - H[i] == -1)
        {
            H[i]--;
        }
    }
    writeln("Yes");

}


Measured memory_bytes: 7092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll inf = numeric_limits<ll>::max()/3;

const int MAX_N = 100010;

int uf[MAX_N];

void init(int n){
  for(int i = 0;i < n;++i){
    uf[i] = -1;
  }
}

int find(int n){
  if(uf[n] < 0){
    return n;
  }else{
    return uf[n] = find(uf[n]);
  }
}

bool same(int a,int b){
  return find(a) == find(b);
}

void unite(int a,int b){
  int pa = find(a);
  int pb = find(b);
  
  if(pa == pb)return;
  
  if(uf[pa] < uf[pb]){
    uf[pb] = pa;
  }else if(uf[pa] > uf[pb]){
    uf[pa] = pb;
  }else{
    uf[pb] = pa;
    --uf[pa];
  }
}

int main(void){
  int n,m;
  vector<int> p;
  cin >> n >> m;
  p.resize(n);
  init(n);
  for(int i = 0;i < n;++i){
    cin >> p[i];
    --p[i];
  }
  for(int i = 0;i < m;++i){
    int a,b;
    cin >> a >> b;
    --a;--b;
    unite(a,b);
  }
  int res = 0;
  for(int i = 0;i < n;++i){
    if(same(i,p[i]))
      ++res;
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main(){
int n,i,count=0,j,temp,num[1000];
scanf("%d",&n);
for(i=0;i<n;i++)
{
	scanf("%d",&num[i]);
}
for(i=0;i<n-1;i++)
{
	for(j=n-1;j>i;j--){
		if(num[j-1]>num[j]){
			temp=num[j-1];
			num[j-1]=num[j];
			num[j]=temp;
			count++;
		}
	}
}
for(i=0;i<n;i++)
{
	printf("%d",num[i]);
	if(i!=n-1) printf(" ");
}
printf("\n");
printf("%d\n",count);
return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;


int main(){
    int n, m;
    cin >> n >> m;
    int left=1, right=n, t_left, t_right;
    for (int i = 0; i < m; i++){
        cin >> t_left >> t_right;
        left = max(left, t_left);
        right = min(right, t_right);
    }
    cout << max(right - left + 1, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
int a[maxn];
int f[maxn];
int fa(int x){
	return f[x]==x?x:(f[x]=fa(f[x]));
}
vector<int> vec[maxn];
int b[maxn],num;
int main(){
//	freopen("D.in","r",stdin);
//	freopen("D.out","w",stdout);
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		f[i]=i;
	}
	int s,t;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&s,&t);
		s++,t++;
		f[fa(s)]=fa(t);
	}
	for(int i=1;i<=n;i++)
		vec[fa(i)].push_back(a[i]);
	long long ans=0;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(f[i]!=i) continue;
		cnt++;
		sort(vec[i].begin(),vec[i].end());
		ans+=vec[i][0];
		for(int j=1;j<(int)vec[i].size();j++)
			b[++num]=vec[i][j];
	}
	if(cnt==1)
		printf("0\n");
	else if(num<cnt-2)
		printf("Impossible\n");
	else{
		sort(b+1,b+num+1);
		for(int i=1;i<=cnt-2;i++)
			ans+=b[i];
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define inf 1000000007

int main () {
	//Your code goes here//
	int x,i,j,a,b=0;
	scanf("%d",&x);
	for(i=2;i<=9;i++){
		for(j=1;j<=31;j++){
			a=pow(j,i);
			if (a>x) break;
			else {
				if (a>b) b=a;
			}
		}
	}
	printf("%d\n",b);
	return 0;
}

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

int main() {
  int N, tmp, maximums, minimums;
  cin >> N;
  
  if(N==1) {
    cin >> tmp;
    cout << tmp << endl;
    return 0;
  }
  
  vector<int> A(N,0);
  vector<int> B(N-1,0);
  
  bool inc = true;
  bool level_ini = true;
  maximums = minimums = 0;
  for(int i=0; i<N; i++) {
    cin >> A[i];
    
    if(i==0) {continue;}
    
    if(level_ini) {
      // all values are same
      if(i==N-1) {
        cout << A[i] << endl;
        return 0;
      }
      
      if(A[i]-A[i-1] < 0) {
        maximums += A[i-1];
        inc = false;
        level_ini = false;
      } else if(A[i]-A[i-1] > 0){
        inc = true;
        level_ini = false;
      } else {
        level_ini = true;
      }
      continue;
    }
    
    if(i==N-1) {
      if(A[i]-A[i-1] == 0 && inc==true) {
        maximums += A[i];
      } else if(A[i]-A[i-1] > 0)
        maximums += A[i];
    }
    
    if(A[i]-A[i-1]>0 && inc==true) {
      // nothing to do
    } else if(A[i]-A[i-1]>0 && inc==false) {
      minimums += A[i-1];
      inc = true;
    } else if(A[i]-A[i-1]<0 && inc==true) {
      maximums += A[i-1];
      inc = false;
    } else if(A[i]-A[i-1]<0 && inc==false){
      // nothing to do
    } else {
      // nothing to do
    }
    
  }
  
  cout << maximums - minimums << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,m,k,ans,sum,nxt[N],A[N],B[N];
char s[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,nxt=0;char c=gc();
    while(!isdigit(c)){if(c=='-')nxt=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(nxt)return -ret;return ret;
}
signed main()
{
	n=read();m=read();k=read();
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='x')
		{
			nxt[i]=nxt[i-1];
			A[i]=A[i-1];
			continue;
		}
		if(i>=nxt[i-1])
		{
			nxt[i]=i+k+1;
			A[i]=A[i-1]+1;
		}
		else{
			nxt[i]=nxt[i-1];
			A[i]=A[i-1];			
		}
	}
	for(int i=n;i;i--)
	{
		if(s[i]=='x')
		{
			B[i]=B[i+1];
			continue;
		}
		B[i]=B[i+k+1]+1;
	}
	for(int i=1;i<=n;i++)
	{
		if(s[i]=='x')continue;
		int x=max(nxt[i-1],i+1);
		if(A[i-1]+B[x]<m)printf("%d\n",i);
	}
	return 0;
}


Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
typedef struct{
    int to,nex,w;
}roa;
roa road[200007];
int cnt;
int head[100007];
int color[100007];
void add_edge(int u,int v,int w){
    road[++cnt].to=v;
    road[cnt].nex=head[u];
    road[cnt].w=w;
    head[u]=cnt;
}
void dfs(int x,int fa,int ans){
    if(ans&1)
        color[x]=1;
    for(int i=head[x];i;i=road[i].nex){
        if(road[i].to==fa)
            continue;
        dfs(road[i].to,x,ans+road[i].w);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;++i){
        int u,v,w;
        scanf("%d%d%d",&u,&v,&w);
        add_edge(u,v,w);
        add_edge(v,u,w);
    }
    dfs(1,0,0);
    for(int i=1;i<=n;++i)
        printf("%d\n",color[i]);
    return 0;
}



Measured memory_bytes: 5632
def main():
    s = input()
    t = input()

    len_s = len(s)
    len_t = len(t)

    if len_s == len_t:
        ans = 0
        for i in range(len_s):
            if s[i] != t[i]:
                ans += 1
        print(ans)
    else:
        ans = 1001
        for i in range(len_s - len_t + 1):
            cnt = 0
            for j in range(len_t):
                if s[i + j] != t[j]:
                    cnt += 1
            if cnt < ans:
                ans = cnt
        print(ans)


if __name__ == "__main__":
    main()


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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    bool check = true;
    for (int i = 0; i < N; i++) {
        if (S[i] != S[N-1-i]) check = false;
    }
    for (int i = 0; i < N/2; i++) {
        if (S[i] != S[N/2-1-i]) check = false;
    }
    for (int i = 0; i < N/2; i++) {
        if (S[N-1-i] != S[N-1-(N/2-1-i)]) check = false;
    }
    if (check) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        
        int n = sc.nextInt();
        int[] H = new int[n];
        for(int i=0;i<n;i++){
            H[i]=sc.nextInt();
        }

        int ans=0;
        int tmp=0;

        for(int j=1; j<n; j++){
            if(H[j-1]>=H[j]){
                tmp++;
            }
            else{
                tmp=0;
            }
            if(tmp>=ans){
                ans=tmp;
            }
        }

        System.out.println(ans);

    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 41352
//
// Created by zono on 18/10/27.
//

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

int main() {
	long a, b;
	int k;
	cin >> a >> b >> k;
	int cnt = 0;
	while (cnt < k) {
		if (!(cnt % 2)) {
			if (a % 2) a--;
			b += a / 2;
			a /= 2;
		} else {
			if (b % 2) b--;
			a += b / 2;
			b /= 2;
		}
		cnt++;
	}
	cout << a << ' ' << b << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n")[1];
  var count = 0;
  var preStack = [];
  var postStack = [];
  for (var c in input) {
    count += (input[c] == "(") ? 1 : -1;
    if (count < 0) {
      preStack.push("(");
      count++;
    }
  }
  while (count-- > 0) {
    input += ")";
  }
  while (preStack.length > 0) {
    input = preStack.pop() + input;
  }
	//出力
	console.log(input);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define int long long


const int INF = 1e9+7;

int n,x,y,z,i;

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

  cin>>n;
  int m = sqrt(10+n);
  vector<int> out(n+1,0);
  int ctr = 0;
  for(x=1;x<m+1;x++){
    for(y=1;y<m+1;y++){
      for(z=1;z<m+1;z++){
        if(x*x + y*y + z*z +x*y+y*z+z*x <= n){
          out[x*x + y*y + z*z +x*y+y*z+z*x]++;
        }
      }
    }
  }
  
  for(i=1;i<=n;i++)
    cout<<out[i]<<"\n";
}


Measured memory_bytes: 3672
from bisect import bisect

N, M, K = map(int, input().split())
A = [0]+list(map(int, input().split()))
B = list(map(int, input().split()))
R_B = [0]*(M+1)
i = 0
while i < M:
  R_B[i+1] = R_B[i]+B[i]
  i += 1 
ans = 0
i = 0
while i <= N and K >= A[i]:
  K -= A[i]
  idx = bisect(R_B, K)
  ans = max(ans, i+idx-1)
  i += 1
print(ans)



Measured memory_bytes: 113756
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, k, ans;

int main() {
	cin >> n >> k;
	REP(i, n) {
		ll a;
		cin >> a;
		if (a >= k)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数

# 入力を整数に変換して受け取る
def input_int(): return int(input())

def map_int_input(): return map(int, input())

MII = map_int_input

def MII_split(): return map(int, input().split())

def MII_to_index(): return map(to_index, input())

def MII_split_to_index(): return map(to_index, input().split())

# 入力全てを整数に変換したものの配列を受け取る
def list_int_inputs(): return list(map(int, input()))

LII = list_int_inputs

def LII_split(): return list(map(int, input().split()))

# 2次元リスト化
def LII_2D(rows_number): return [LII() for _ in range(rows_number)]

def LII_split_2D(rows_number): return [LII_split() for _ in range(rows_number)]

N = int(input())
As = LII_split()

subordinates = dict()
for i in range(N):
    subordinates[i] = 0

for A in As:
    subordinates[A-1] += 1

print_list_in_2D(list(subordinates.values()))


Measured memory_bytes: 39788
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        stack<int> S;
        int a, b;
        string s;

        while (cin >> s)
        {
                if (s[0] == '+')
                {
                        a = S.top();
                        S.pop();
                        b = S.top();
                        S.pop();
                        S.push(a + b);
                }
                else if (s[0] == '-')
                {
                        b = S.top();
                        S.pop();
                        a = S.top();
                        S.pop();
                        S.push(a - b);
                }
                else if (s[0] == '*')
                {
                        a = S.top();
                        S.pop();
                        b = S.top();
                        S.pop();
                        S.push(a * b);
                }
                else
                {
                        S.push(atoi(s.c_str()));
                }
        }
        cout << S.top() << endl;

        return 0;
}



Measured memory_bytes: 3152
#include <iostream>
using namespace std;
int main(){
  int n; cin >> n;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j < 10; j++){
      if(i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define dd double
#define ull unsigned long long
#define mes(x,y) memset(x,y,sizeof(x))
#define si(i) scanf("%d",&i)
#define ss(i) scanf("%s",(i))
#define sd(i) scanf("%lf",&i)
#define INF 0x3f3f3f3f
#define eps 1e-16
#define PI acos(-1)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int maxn=2e9+9;
const int mod=1e9+7;
ll GCD(ll a,ll b) {//最大公约数
    return b == 0 ? a : GCD(b, a % b);
}
int main() {
    //FAST_IO;
    ll n,i;
    while(cin>>n){
        double maxn=-1,minn=2000,x[100];
        for(i=0;i<n;i++) cin >> x[i];
        sort(x,x+n);
        double mid=x[0];
        for(i=1;i<n;i++){
            mid=(mid+x[i])/2.0;
        }
        printf("%.6lf\n",mid);
    }
}


Measured memory_bytes: 256
def main():
    N,Y=map(int,input().split())
    for i in range(N+1):
        for j in range(0,N-i+1):
            k=N-i-j
            if i*10000+j*5000+k*1000==Y:
                print(i,end=" ")
                print(j,end=" ")
                print(k)
                return 0
    print("-1 -1 -1")
main()

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N,D,X;
    cin>>N>>D>>X;
    vector<int> A(N);
    int ans =0;
    REP(i,N) cin>>A[i];
    REP(i,N){
      int j=0;
      while(j*A[i]+1<=D){
        ans++;
        j++;
      }
    }
    cout<<ans+X<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef unsigned long long ll;

bool eval(int n, const vector<ll>& h, ll a, ll b, ll x) {
    const ll bias = b * x;

    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        if (h[i] <= bias) {
            continue;
        }
        ll rest = h[i] - bias;
        cnt += (rest + (a - b - 1)) / (a - b);
    }
    return cnt <= x;
}

int main(void) {
    ll n, a, b;
    cin >> n >> a >> b;

    vector<ll> h(n);
    for (ll i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());

    // (lb, ub]
    ll ub = 1e10;
    ll lb = -1;
    while (ub - lb > 1) {
        const ll mid = lb + (ub - lb) / 2;
        if (eval(n, h, a, b, mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }

    cout << ub << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<climits>

using namespace std;

const long long MAX=LLONG_MAX>>1;

int main(){
	int v=0,e=0;
	long long dist[100][100]={0};
	cin>>v>>e;
	for(int i=0;i<v;i++){
		for(int j=0;j<v;j++){
			dist[i][j]=MAX;
		}
	}
	for(int i=0;i<v;i++){
		dist[i][i]=0;
	}
	for(int i=0;i<e;i++){
		int s=0,t=0,d=0;
		cin>>s>>t>>d;
		dist[s][t]=d;
	}
	for(int i=0;i<v;i++){
		for(int j=0;j<v;j++){
			for(int k=0;k<v;k++){
				if(dist[j][k]>dist[j][i]+dist[i][k] && dist[j][i]!=MAX && dist[i][k]!=MAX){dist[j][k]=dist[j][i]+dist[i][k];}
			}
		}
	}
	for(int i=0;i<v;i++){
		if(dist[i][i]<0){
			cout<<"NEGATIVE CYCLE"<<endl;
			return 0;
		}
	}
	for(int i=0;i<v;i++){
		for(int j=0;j<v;j++){
			if(dist[i][j]==MAX){cout<<"INF";}
			else{cout<<dist[i][j];}
			cout<<(j==v-1?"\n":" ");
		}
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int N = 200003, M = N << 1;

int n, k;
int a[N], b[N];
int s[N]/*i+a_i*/, t[N]/*i-a_i*/;
int ton[M];
LL ans;

int main()
{
    n = gi();
    for (int i = 1; i <= n; i+=1) 
        a[i] = gi(), s[i] = i + a[i], t[i] = i - a[i];
    for (int i = 1; i <= n; i+=1)
        if (s[i] <= 200000) ++ton[s[i]];
    for (int i = n; i >= 1; i-=1)
    {
        if (t[i] <= 0) continue;
        if (t[i] > 200000) continue;
        ans += ton[t[i]];
        if (s[i] <= 200000) --ton[s[i]];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6884