akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{ int N; cin >> N;
 vector<long long> A(N); vector<long long>B(N); vector<long long> C(N);
 
 for(int i = 0; i < N; i++){
   cin >> A[i];}
 for(int j = 0; j < N; j++){
   cin >> B[j];}
 for(int k = 0; k < N; k++){
   cin >> C[k];}
 
 long long total = 0;
 
 sort(A.begin(),A.end());
 sort(B.begin(),B.end());
 sort(C.begin(),C.end());
 
 
 for(int j = 0; j < N; j++){
   
   auto c1 = lower_bound(A.begin(),A.end(),B[j]);
   auto c2 = upper_bound(C.begin(),C.end(),B[j]);
   
   long long cnt1 = distance(A.begin(),c1);
   long long cnt2 = distance(c2,C.end());
   
   total += cnt1 * cnt2;}
 
 cout << total << endl;
 
 return 0;
}


Measured memory_bytes: 2560
N,M=map(int,input().split())
A=list(map(int,input().split()))

X = 0
for i in range(N):
    X += A[i]
Y = X / (4 * M)

cnt = 0
for j in range(N):
    if A[j] >= Y:
        cnt += 1

if M <= cnt:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
v = gets.chomp.split.map(&:to_i)

ans = 0
(k+1).times do |l|
  (k-l+1).times do |r|
    deletable_count = (k-l-r)
    ar = l+r >= n ? v.dup : v.slice(0,l) + v.slice(n-r,r)
    ar.sort!
    deletable_count.times do |i|
      break if ar[i].nil? || ar[i] >= 0
      ar[i] = 0
    end
    sum = ar.inject(&:+) || 0
    # p [l,r,deletable_count, ' ', sum]
    ans = sum if ans < sum
  end
end

puts ans


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

int main()
{
  char N[3];
  int res=0;
  cin >> N;

  if(N[0]=='9' || N[1]=='9') cout << "Yes" << endl;
  else cout << "No" << endl;

}


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

using namespace std;

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

	int N, C;
	cin >> N >> C;

	vector< pair<int, int> > shows[32];
	vector<int> delta(100005);

	for (int i = 0; i < N; ++i) {
		int s, t, c;
		cin >> s >> t >> c;
		shows[c].emplace_back(s, t);
	}

	for (int i = 1; i <= C; ++i) {
		sort(shows[i].begin(), shows[i].end());

		vector< pair<int, int> > tmp;

		for (auto pr : shows[i]) {
			if (tmp.empty() || tmp.back().second < pr.first) tmp.push_back(pr);
			else tmp.back().second = pr.second;
		}

		for (auto pr : tmp) {
			++delta[pr.first];
			--delta[pr.second + 1];
		}
	}

	int ans = 0;
	int current = 0;

	for (int i = 0; i < 100000; ++i) {
		current += delta[i];
		ans = max(ans, current);
	}

	cout << ans;

	//system("pause");

	return 0;
}

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


void solve(long long N, std::vector<long long> a){
    vector<ll> color(9, 0);
    for(ll i=0; i< N; i++){
        if(a[i]<= 399)      color[0]++;
        else if(a[i]<= 799) color[1]++;
        else if(a[i]<= 1199) color[2]++;
        else if(a[i]<= 1599) color[3]++;
        else if(a[i]<= 1999) color[4]++;
        else if(a[i]<= 2399) color[5]++;
        else if(a[i]<= 2799) color[6]++;
        else if(a[i]<= 3199) color[7]++;
        else color[8]++;
    }
    ll cnt = 0;
    for(ll i=0; i< 8; i++){
        if(color[i]>0) cnt++;
    }
    cout << max(cnt, 1LL) << " " << (cnt + color[8]) << endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

// #include "../../Template.cpp"

void solve() {
    int n; cin >> n;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i ++) cin >> arr[i];
    vector<vector<int>> dp(n+1, vector<int>(n+1, 0.0));
    dp[0][0] = 1.0;
    for(int32_t i = 1; i <= n; i ++) {
        for(int32_t j = 0; j <= n; j ++) {
            if(j<=i) {
                if(j == 0)
                    dp[i][j] = dp[i-1][j]*(1.0-arr[i-1]);
                else 
                    dp[i][j] = (dp[i-1][j]*(1.0-arr[i-1])) + (dp[i-1][j-1]*arr[i-1]);
            }
        }
    }
    // for(auto i:dp) {for(auto j:i) cout << j << " "; cout << endl;}
    int ans = 0;
    int32_t l = (n/2);
    for(int32_t i = l+1; i <= n; i ++) {
        ans += dp[n][i];
    }
    cout << ans << endl;
}

int32_t main() {
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 141184
#include <cstdio>

int
main(void)
{
  int r, c, i, j;

  std::scanf("%d %d", &r, &c);

  int sheat[r+1][c+1];

  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      std::scanf("%d", &sheat[i][j]);
    }
  }

  sheat[r][c] = 0;
  for (i = 0; i < r; i++) {
    sheat[i][c] = 0;
  }
  for (j = 0; j < c; j++) {
    sheat[r][j] = 0;
  }

  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      sheat[i][c] += sheat[i][j];
      sheat[r][j] += sheat[i][j];
      sheat[r][c] += sheat[i][j];
    }
  }

  for (i = 0; i <= r; i++) {
    for (j = 0; j <= c; j++) {
      if (j == 0) {
        std::printf("%d", sheat[i][j]);
      } else {
        std::printf(" %d", sheat[i][j]);
      }
    }
    std::printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2736
n=input().split(' ')

for i in range(len(n)):
  n[i]=int(n[i])

k=n[3]
sum=0
if k > n[0]:
  sum+=n[0]
  k-=n[0]
else:
  sum=k
  k=0
k-=n[1]
if 0 < k:
  sum-=k
print(sum)

Measured memory_bytes: 9192
/*
ID: alec3
LANG: C++14
PROG:
*/

#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int pct(int x) { return __builtin_popcount(x); }


int main()
{
    io;
    ll n;
    cin >> n;
    // current set of names and their length
    ll curr = 26;
    int len = 1;

    // find the range of strings
    // n is in and their length
    while (n > curr){
        n -= curr;
        curr *= 26;
        len ++;
    }
    // ans is a string full of 0 of length len
    string ans(len, '0');
    n --;

    // start at the end of the string
    for (int i = len-1; i >= 0; i--){
        // the letter is the number of nums after 26 (pos in alphabet)
        // + 'a' to make it a proper char
        ans[i] = n % 26 + 'a';
        // look at the eariler set of numbers
        n /= 26;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3568
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool ff=0;for(auto outi:v){cout<<(ff?" ":"")<<outi;ff=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
int v[2000001];
char s[2000001],t[500002];
void Zalgorithm(int N){
  int i=1,j=0,k=0;
  v[0]=N;
  while(i<N){
    while(i+j<N&&s[i+j]==s[j])++j;
    v[i]=j;
    if(!j){
      ++i;
      continue;
    }
    k=1;
    while(v[k]+k<j){
      v[i+k]=v[k];
      ++k;
    }
    i+=k;
    j-=k;
  }
}
int i,j,K,quef[1000001],ques[1000001],size,ans;
int main(){
  int N,ng=500001,mid;
  fgets(t,1000000,stdin);
  fgets(s,1000000,stdin);
  while(ng-K>1){
    mid=(ng+K)>>1;
    (s[mid]?K:ng)=mid;
  }
  while(t[i]!='\n'){
    s[K+i]=t[i];++i;
  }
  N=i;
  i+=K;
  while(i<2000001){
    s[i++]=t[j++];
    j*=j<N;
  }
  N=(K+N-1)/N*N;
  Zalgorithm(N+K*2);
  rep(i,N){
    if(v[i+K]<K)ques[size++]=i+K-(i+K>=N)*N;
  }
  rep(i,N){
    if(i==size){
      puts("-1");
      return 0;
    }
    chmax(ans,quef[i]);
    if(v[ques[i]+=K]>=K){
      ques[size]=ques[i]-N*(ques[i]>=N);
      quef[size++]=quef[i]+1;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 16256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cstdlib>
#define N 3030
typedef long long ll;
template<typename T> inline void read(T &x) {
  x = 0; char c = getchar();
  while (!isdigit(c)) { c = getchar(); }
  while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
}
using namespace std;
const int P = 1e9 + 7;
int n, m;
int f[N][N][2];
inline void ADD(int &a, int b) {
  a += b;
  if (a >= P) a -= P;
}
inline void work() {
  for (int i = 0; i <= n; ++i)  f[0][i][0] = 1;
  for (int i = 0; i < m; ++i) {
    ADD(f[i][0][1], f[i][0][0]);
    f[i][0][0] = 0;
    for (int j = 0; j <= n; ++j) {
      for (int t = 0; t < 2; ++t) if (f[i][j][t]) {
        if (j != 0) {
          if (t == 0 && j == 1) ADD(f[i + 1][j][1], f[i][j][0]);
          else  ADD(f[i + 1][j][t], f[i][j][t]);
          ADD(f[i + 1][j - 1][t], f[i][j][t]);
        }
        if (j != n) {
          ADD(f[i + 1][j][t], f[i][j][t]);
          ADD(f[i + 1][j + 1][t], f[i][j][t]);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i)  ADD(ans, f[m][i][1]);
  ADD(ans, f[m][0][0]);
  printf("%d\n", ans);
}
int main() {
  read(n), read(m);
  work();
  return 0;
}


Measured memory_bytes: 73956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e4 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n;
    double cx=0.0,cy=0.0,x[55],y[55];
    bool used[55]{}, ok = true;
    cin >> n;
    REP(i,n){
        cin >> x[i] >> y[i];
        cx += x[i];
        cy += y[i];
    }
    cx /= double(n);
    cy /= double(n);
    REP(i,n){
        x[i] -= cx;
        y[i] -= cy;
    }
    REP(i,n){
        if(used[i])continue;
        REP(j,n){
            if(used[j] || i==j)continue;
            if(abs(x[i]+x[j])<EPS && abs(y[i]+y[j])<EPS){
                used[i] = used[j] = true;
            }
        }
    }
    REP(i,n) ok &= used[i];
    if(ok){
        printf("%.8lf %.8lf\n",cx,cy);
    }
    else{
        cout << "NA" << endl;
    }
    return 0;
}



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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back


int32_t main(){
sp;
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));

    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        tmp = 0
        if s[i][j] == '.':
            if i >= 1 and j >= 1:
                if s[i-1][j-1] == '#': tmp += 1
            if i >= 1:
                if s[i-1][j] == '#': tmp += 1
            if i >= 1 and j < w-1:
                if s[i-1][j+1] == '#': tmp += 1
            if j >= 1:
                if s[i][j-1] == '#': tmp += 1
            if j < w-1:
                if s[i][j+1] == '#': tmp += 1
            if i < h-1 and j >= 1:
                if s[i+1][j-1] == '#': tmp += 1
            if i < h-1:
                if s[i+1][j] == '#': tmp += 1
            if i < h-1 and j < w-1:
                if s[i+1][j+1] == '#': tmp += 1

            s[i][j] = str(tmp)

for i in range(h):
    print(''.join(s[i]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
#define FOR(i,a,b) for(int i=(int)a,c=(int)b;i<c;++i)
#define rep(i,b) FOR(i,0,b)
#define ROF(i,a,b) for(int i=b-1,c=(int)a;i>=c;--i)
#define per(i,b) ROF(i,0,b)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

signed main(){
  int n,K;
  cin>>n>>K;
  vector<int> v(n);
  int sum=0;
  rep(i,n){
    cin>>v[i];
    sum+=v[i];
  }
  int ans=0;
  rep(i,n+1)rep(j,n+1){
    if(i+j>n)continue;
    if(i+j>K)continue;
    priority_queue<int,vector<int>,greater<int> > que;
    //    cout<<i<<" "<<j<<endl;
    int msum=0;
    FOR(k,0,i){
	 que.push(v[k]);
	 msum+=v[k];
    }
    FOR(k,n-j,n){
	 que.push(v[k]);
	 msum+=v[k];
    }
    int tsum=0;
    rep(k,K-(i+j)){
	 if(que.empty())break;
	 if(que.top()>0)break;
	 tsum+=que.top();
	 que.pop();
    }
    ans=max(ans,msum-tsum);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 800 * n - 200 * (n / 15);
        System.out.println(sum);
    }

}

Measured memory_bytes: 21844
import scala.math._
import scala.collection.mutable.ListBuffer

object Main {
  //rt.gc()??§??¬??????????????¬?????????????????????
  //val rt = Runtime.getRuntime()
  val sc = new java.util.Scanner(System.in)
  def cutByK(c: List[Int], k: Int) = {
    c.drop(k) ::: c.take(k)
  }
  def riffle(c: List[Int]):List[Int] = c match {
    case Nil => Nil
    case _ => {
      val r = c.drop(c.size/2)
      c.head :: r.head :: riffle(c.take(c.size/2).tail ::: r.tail)
    }
  }
  def main(args: Array[String]) {
    val n = sc.nextInt
    val m = sc.nextInt
    var ans = (1 to 2*n).toList
    for(_ <- 1 to m) {
      val op = sc.nextInt
      if(op == 0) {
        ans = riffle(ans)
      } else {
        ans = cutByK(ans, op)
      }
    }
    ans.foreach(println)
  }
}

Measured memory_bytes: 268120
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;

public class Main 
{

	
	static class Node
	{
		int id;
		HashSet<Node> e = new HashSet<>();
		boolean visited = false;
		boolean marked = false;
		
		public Node(int i)
		{
			id = i;
		}
	}
	
	static Node[] nd;

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		nd = new Node[n];
		for(int i = 0; i < n; i++)
			nd[i] = new Node(i);
		
		for(int i = 0; i < m; i++)
		{
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			
			nd[a].e.add(nd[b]);
			nd[b].e.add(nd[a]);
		}
		
		LinkedList<Node> q = new LinkedList<>();
		q.add(nd[0]);
		
		int[] par = new int[n];
		int mar = 0;
		nd[0].marked = true;
		while(!q.isEmpty())
		{
			Node pos = q.poll();
			for(Node e : pos.e)
			{
				if(!e.marked)
				{
					mar++;
					e.marked = true;
					q.add(e);
					par[e.id] = pos.id+1;
//					System.out.println("mark " + e.id);
				}
			}
			if(mar == n-1)
				break;
		}
		
		System.out.println("Yes");
		for(int i = 1; i < n; i++)
		{
			System.out.println(par[i]);
		}
	}

}


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

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
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(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class BBalancedNeighbors {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<pii> ans;
        RREP(i, N) FOR(j, i+1, N+1){
            if(N%2 and j==N-i) continue;
            if(N%2==0 and j==N-i+1) continue;
            ans.eb(i, j);
        }
        out<<LEN(ans)<<'\n';
        for(auto& a : ans) out<<a.first<<' '<<a.second<<'\n';
    }
};


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


Measured memory_bytes: 3728
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;
ll fact(ll n)
{
ll    res=1;
    for(int i = 1; i <= n;i++){
    res = res * i ;
}
return res;
}



int main()
{   IOS;
    ll a;
    cin >> a;
    double res=0;
    for(int i=0;i<a;i++)
       {
           ll x;
           cin >> x;
           res+=(double)(1.0/x);
       }
       cout << 1/res;




    cout.precision(30);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
#define MOD 1000000007
ll powmod(ll p,ll q){
    ll x=1;
    while(q>0){
        if(q&1){
            x = x * p%MOD;
        }
        p=p*p%MOD;
        q>>= 1;
    }
    return x;
}

int main(){
    ll N,K;
    cin >> N >> K;
    ll i,j;
    ll num[K];
    ll ans=0;
    for(i=K;i>0;i--){
       j=2*i;
       num[i-1]=powmod(K/i,N);
       while(j<=K){
           num[i-1]=(num[i-1]+MOD-num[j-1])%MOD;
           j+=i;
       }
       ans=(ans+num[i-1]*i%MOD)%MOD;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 3972
/*
g++ -std=c++11 -o2 -Wall ABC101B.cpp -o ./out/ABC101B.out
./out/ABC101B.out
*/

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

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define tr(c, i) for (iter(c) != (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define mp make_pair

typedef long long ll;

int main(){
//    freopen("./input/input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int nn = n;
    int s = 0;
    for (int i = 0; i < 10; ++i) {
      if (nn == 0) {
      } else {
        s += nn % 10;
      }
      nn /= 10;
    }
//    cout << n << " " << s << "\n";
    if (n % s == 0) cout << "Yes\n";
    else cout << "No\n";
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

ans   = 0
count = 0


for j in range(N):
    if N == 1:
       break
 
    if H[j] >= H[j+1]:
        count += 1
    elif count > ans:
        ans   = count
        count = 0
    else:
        count = 0
      
    if j == N-2:
        if count > ans:
            ans   = count
        break

print(ans)


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

int main() {
  long long H; cin >> H;
  long long ans = 0;
  long long tmp = 1;
  while (H != 1) {
    H /= 2;
    ans += tmp;
    tmp *= 2;
  }
  ans += tmp;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, int, int>;
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; }
typedef int64_t lint;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;

template<typename T>
struct BIT {
	int n;
	vector<T> d;
	BIT(int n=0):n(n),d(n+1) {}
	void add(int i, T x=1) {
		for (i++; i <= n; i += i&-i) {
			d[i] += x;
		}
	}
	T sum(int i) {
		T x = 0;
		for (i++; i; i -= i&-i) {
			x += d[i];
		}
		return x;
	}
	T sum(int l, int r) {
		return sum(r) - sum(l);
	}
};

int main() {
	int N, Q;
	cin >> N >> Q;
	int a=0, b=0, c=0, x, y, z;
	vector<int> v(N);
	rep(i, N) {
		cin >> x;
		v.at(i) = x-1;
	}
	vector<tint> vv(Q);
	rep(i, Q) {
		cin >> x >> y;
		vv.at(i) = make_tuple(y-1, x-1, i);
	}
	sort(all(vv));
	BIT<int> bit(N);
	vector<int> t(N);
	vector<int> r(Q);
	fill(all(t), -1);
	rep(i, N) {
		x = v.at(i);
		if (t.at(x) != -1) bit.add(t.at(x), -1);
		bit.add(i);
		t.at(x) = i;
		while(get<0>(vv.at(a)) == i) {
			tie(y, x, z) = vv.at(a);
			r.at(z) = bit.sum(x-1, y);
			a++;
			if (a == Q) break;
		}
		if (a == Q) break;
	}
	rep(i, Q) {
		cout << r.at(i) << '\n';
	}
}


Measured memory_bytes: 17380
#include <bits/stdc++.h>
#ifdef dbg
#include "./printer.hpp"
#else
#define dump(x) void(0)
#endif

using namespace std;
#define ll long long
inline long  toInt(string s) {long  v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define INF 100000

int main(){
  ios_base::sync_with_stdio(0);
  ll a,b;
  while(cin >> a >> b){
    string s = to_string(a+b);
    cout << s.length() << '\n';
  }
  
  return 0;

}

Measured memory_bytes: 3240
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end
x, n = gets_i_list
p_list = gets_i_list

# diff_h = p_list.map do |p|
#   [p, (p - x).abs]
# end.to_h

# dpp diff_h

0.upto(100) do |i|
  a, b = nil, nil
  if !p_list.include?(x - i)
    a = x - i
  end
  if !p_list.include?(x + i)
    b = x + i
  end
  if a || b
    puts [a, b].compact.min
    exit
  end
end


Measured memory_bytes: 14536
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const long inf=1e9;
int main(){
	int N,K; cin>>N>>K;
	int A[N];
	rep(i,0,N) cin>>A[i];
	rep(i,K,N){
		if(A[i-K] < A[i]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define maxn 100005
#define pii pair<int,int>
#define INF 123456789
using namespace std;
using namespace __gnu_pbds;
struct edge {
	int v,col;
};
vector<edge> G[maxn];
gp_hash_table<int,int> ID[maxn];
struct new_edge {
	int v,cost;
};
vector<new_edge> nG[5*maxn];
int dis[5*maxn];
int Dijkstra(int st,int ed) {
	memset(dis,-1,sizeof dis);
	dis[st] = 0;
	
	priority_queue<pii> pq;
	pq.push(make_pair(-dis[st],st));
	
	while(!pq.empty()) {
		pii now = pq.top();
		pq.pop();
		int u = now.second;
		if(-now.first != dis[u])	continue;
		for(new_edge e : nG[u]) {
			int v = e.v , cost = e.cost;
			if(dis[v] == -1 || dis[u] + cost < dis[v]) {
				dis[v] = dis[u] + cost;
				pq.push(make_pair(-dis[v],v));
			}
		}
	}
	return dis[ed] == -1 ? -1 : dis[ed];
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin >> n >> m;
	int cnt = 0;
	for(int i=1,u,v,col;i<=m;i++) {
		cin >> u >> v >> col;
		G[u].emplace_back(edge{v,col});
		G[v].emplace_back(edge{u,col});
		ID[u][col] = cnt++;
		ID[v][col] = cnt++;
	}
	for(int i=1;i<=n;i++)
		ID[i][INF] = cnt++;
	for(int u=1;u<=n;u++)
		for(edge e : G[u]) {
			int v = e.v , col = e.col;
			int u_id = ID[u][col] , v_id = ID[v][col];
			nG[u_id].emplace_back(new_edge{v_id,0});
			int S = ID[u][INF];
			nG[u_id].emplace_back(new_edge{S,1});
			nG[S].emplace_back(new_edge{u_id,0});
		}
	
	int st = cnt++;
	int ed = cnt++;
	for(edge e : G[1])
		nG[st].emplace_back(new_edge{ID[1][e.col],1});
	for(edge e : G[n])
		nG[ID[n][e.col]].emplace_back(new_edge{ed,0});
		
	cout << Dijkstra(st,ed) << endl;
	return 0;
}


Measured memory_bytes: 73268
import Data.Bits (xor, shiftL, (.&.))
import Data.Array (listArray, (!))
import Data.Maybe (fromJust)

f as x = sum $ fmap (xor x) as

maxdigit = 50

main = do
  n:k:_ <- map read . words <$> getLine :: IO [Int]
  as <- map read . words <$> getLine :: IO [Int]
  let result = solv k n as
  print . fromJust $ max (result ! 0) (result ! 1)

dp f s n = result ! n where
  result = listArray (s,n) $ map nth [s..]
  nth i = f result i

solv k num as = dp f 0 maxdigit where
  f _ 0   = listArray (0,1) [Just 0, Nothing]
  f tab n =
    let mask  = shiftL 1 (maxdigit - n)

        d0    = tab ! (n-1) ! 0
        d1    = tab ! (n-1) ! 1

        cost0 = sum $ map (.&.mask) as
        cost1 = mask * num - cost0

        stos  = (+(max cost0 cost1)) <$> d1
        etos  = if k .&. mask > 0 then (+cost0) <$> d0 else Nothing
        etoe  = if k .&. mask > 0 then (+cost1) <$> d0 else (+cost0) <$> d0
    in
      listArray (0,1) [etoe, max stos etos]


Measured memory_bytes: 68988
#include<bits/stdc++.h>
using namespace std;
 
int seat[100000];

int ck(string s){
	if (s == "Vacant"){
		return 0;
	}
	if (s == "Male"){
		return 1;
	}
	return 2;
}
 
int main(){
	int n;
	cin >> n;
	int l = 0, r = n - 1, a;
	string ver;
	
	cout << l << endl;
	cout.flush();
	cin >> ver;
	seat[l] = ck(ver);
	if (!seat[l]){
		exit(0);
	}
	
	cout << r << endl;
	cout.flush();
	cin >> ver;
	seat[r] = ck(ver);
	if (!seat[r]){
		exit(0);
	}
	
	while (l != r - 1){
		int mid = (l + r) / 2;
		cout << mid << endl;
		cout.flush();
		cin >> ver;
		seat[mid] = ck(ver);
		
		if (!seat[mid]){
			exit(0);
		}
		if(abs(seat[mid] - seat[l]) != (mid - l) % 2){
			r = mid;
		}
		else{
			l = mid;
		}
	}
	cout << l << endl;
	cout.flush();
	cin >> ver;
	seat[l] = ck(ver);
	if (!seat[l]){
		exit(0);
	}
	
	cout << r << endl;
	cout.flush();
	cin >> ver;
	seat[r] = ck(ver);
	if (!seat[r]){
		exit(0);
	}
}
//combi

Measured memory_bytes: 852
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int a[3000], f[3010];
int n, s;

inline void work() {
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (s == a[i]) {
            f[s] += (i + 1) * (n - i);
            f[s] %= mod;
        }
        else if (s > a[i]) {
            f[s] += (LL)f[s - a[i]] * (n - i) % mod;
            f[s] %= mod;
            for (int j = s - 1; j > a[i]; --j) {
                f[j] += f[j - a[i]];
                f[j] %= mod;
            }
            f[a[i]] += i + 1;
            f[a[i]] %= mod;
        }
    }
    cout << f[s] << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string a;
	cin >> a;
	if ((a[0] == a[1])&&(a[1] == a[2]) || (a[1] == a[2])&&(a[2] == a[3]))cout << "Yes" << endl;
	else cout << "No" << endl;
	int x;
	cin >> x;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] a=br.readLine().split(" ");
        int r=Integer.parseInt(a[0]);
        int c=Integer.parseInt(a[1]);
        int[][] h=new int[r][c];
        for(int i=0;i<r;i++){
        	a=br.readLine().split(" ");
        	int s=0;
        	for(int j=0;j<c;j++){
        		h[i][j]=Integer.parseInt(a[j]);
        		System.out.print(h[i][j]+" ");
        		s+=h[i][j];
        	}
        	System.out.println(s);
        }
        int ts=0;
        for(int j=0;j<c;j++){
        	int s=0;
        	for(int i=0;i<r;i++){
        		s+=h[i][j];
        		ts+=h[i][j];
        	}
        	System.out.print(s+" ");
        }
        System.out.println(ts);
	}
}

Measured memory_bytes: 24768
#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> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 pb push_back
#define pp 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 INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;
    vi p(n);
    int  count = 0; 
    rep(i,n){
        cin >> p[i];
        if(p[i]!=i+1){ count++;}
    }

    if(count<=2)YES
    NO
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int n,m,a[100000],b[100000];
  int c[100000]={0};
  cin >> n >> m;
  for(int i=0; i<m; i++) cin >> a[i] >> b[i];
  for(int i=0; i<m; i++){
    c[a[i]]++;
    c[b[i]]++;
  }
  bool sw=1;
  for(int i=0; i<n; i++){
    if(c[i]%2==1) sw=0;
  }
  if(sw) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    int n; cin >> n;
    int mini = M, maxi = -1;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        mini = min(mini, a);
        maxi = max(maxi, a);
    }
    cout << maxi - mini << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    int h,w;
    cin >> h >> w;
    while(h||w) {
        for(int i=0; i<h; ++i) {
            for(int j=0; j<w; ++j) {
                if((i+j)%2) {
                    cout << ".";
                }
                else {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}



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

vector<char> v;

void C(){
	v.push_back(v[0]);
	v.erase(v.begin());
}

void J(){
	v.insert(v.begin(),v[v.size()-1]);
	v.pop_back();
}

void E(){
	stack<char> st[2];
	for(int i=0;i<v.size()/2;i++){
		st[0].push(v[i]);
		st[1].push(v[v.size()-1-i]);
	}
	for(int i=0;i<v.size()/2;i++){
		v[i]=st[1].top();
		v[v.size()-1-i]=st[0].top();
		st[0].pop(),st[1].pop();
	}
}

void A(){
	stack<char> st;
	for(int i=0;i<v.size();i++)st.push(v[i]);
	for(int i=0;i<v.size();i++){
		v[i]=st.top();
		st.pop();
	}
}

void M(){
	for(int i=0;i<v.size();i++){
		if(v[i]>='0'&&v[i]<='9'){
			v[i]=((v[i]-'0')+1)%10+'0';
		}
	}
}

void P(){
	for(int i=0;i<v.size();i++){
		if(v[i]>='0'&&v[i]<='9'){
			v[i]=((v[i]-'0')+9)%10+'0';
		}
	}
}

int main(){
	int n;
	string s,q;
	cin>>n;
	while(n--){
		cin>>s>>q;
		v.clear();
		for(int i=0;i<q.size();i++)v.push_back(q[i]);
		for(int i=s.size()-1;i>=0;i--){
			if(s[i]=='J')J();
			if(s[i]=='C')C();
			if(s[i]=='E')E();
			if(s[i]=='A')A();
			if(s[i]=='P')P();
			if(s[i]=='M')M();
		}
		for(int i=0;i<v.size();i++)cout<<v[i];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3020
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();
		for(int i=0; i<N; i++)
			B[i] = sc.nextInt();

		long ans = 0;
		boolean update = true;
		while(update) {
			update = false;
			for(int i=0; i<N; i++) {
				if(B[i]<A[i]) {
					update = false;
					break;
				}
				int i0 = (i-1+N)%N;
				int i2 = (i+1)%N;
				if(B[i0] < B[i] && B[i] > B[i2]) {
					int move = (B[i]-A[i])/(B[i0]+B[i2]);
					ans += move;
					B[i] -= move*(B[i0]+B[i2]);
					if(move>0)
						update = true;
				}
			}
		}
		boolean ok = true;
		for(int i=0; i<N; i++) {
			if(A[i]!=B[i]) {
				ok = false;
				break;
			}
		}
		
		System.out.println(ok ? ans : -1);
		sc.close();
	}
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

ll n,k;

int main(){
  scanf("%lld %lld",&n,&k);
  //n以下のaをbで割ったあまりがk以上である数字の個数
  ll cnt = 0;
  for(ll b = k+1;b<=n;b++){
    /*n >= b*i + k
    q = (n-k)/b 
    cnt += q*(b-k)
    cnt +- n-b*i-k
    */
    ll q = (n-k)/b;
    cnt += q*(b-k);
    if(n>=b*(q+1)) cnt += b-k;
    else{
     cnt += n - b*q-k+1;
     if(k==0) cnt--;
    }
  }
  printf("%lld\n",cnt);
}


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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;



int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    string s;
    cin >> s;
    int n=s.length();
    string t1,t2;
    rep(i,n){
        if(i%2==0){
            t1+='1';
            t2+='0';
        }else{
            t1+='0';
            t2+='1';
        }
    }

    int count1=0,count2=0;
    rep(i,n){
        if(s[i]!=t1[i]) count1++;
        if(s[i]!=t2[i]) count2++;
    }

    cout << min(count1,count2);


}

Measured memory_bytes: 720
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << '\n';
    return 0;
}


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

int main(){

    int N;
    cin >> N;
    vector<int> H(N, 0);
    vector<int> Hflag(N, 0);
    for(int i = 0; i < N; i++){
        cin >> H.at(i);
    }

    int ans = 0;
    int move = 0;
    for(int i = 1; i < N; i++){
        if(H.at(i) > H.at(i-1)){
            ans = max(ans, move);
            move = 0;
        }else if(i == N - 1){
            if(H.at(i) > H.at(i-1)){
                ans = max(ans, move);
            }else{
                ans = max(ans, move + 1);
            }
        }else{
            move++;
        }

        //cout << i << ":" << move << ":" << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  long long a,b,k;
  cin >> a >> b >> k;
  long long n=max(0ll,a-k);
  long long m=min(b,max(a+b-k,0ll));
  cout << n << " " << m << endl;
  return 0;
}

Measured memory_bytes: 3640
use std::collections::VecDeque;
use std::io::stdin;
use std::io::Error;
use std::io::Read;

#[derive(Debug)]
struct Edge {
    u: usize,
    v: usize,
    w: u32,
}

#[derive(Debug)]
struct Node {
    edge: Vec<usize>,
}

#[derive(Debug)]
struct Input {
    node: Vec<Node>,
    edge: Vec<Edge>,
}

fn handle_input(input_str: String) -> Result<Input, Error> {
    let mut iter = input_str.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut node = Vec::with_capacity(n);
    for _ in 0..n {
        node.push(Node { edge: Vec::new() });
    }
    let mut edge = Vec::new();
    for _ in 0..n - 1 {
        let u: usize = iter.next().unwrap().parse().unwrap();
        let v: usize = iter.next().unwrap().parse().unwrap();
        let w: u32 = iter.next().unwrap().parse().unwrap();
        let index = edge.len();
        node[u - 1].edge.push(index);
        node[v - 1].edge.push(index);
        edge.push(Edge { u: u, v: v, w: w })
    }
    let input = Input {
        node: node,
        edge: edge,
    };
    Ok(input)
}

fn handle_output(input: Input) -> Result<String, Error> {
    let mut queue = VecDeque::new();
    let mut colors = vec![-1; input.node.len()];
    queue.push_back((0, 0));
    while let Some((node_index, color)) = queue.pop_front() {
        let node = &input.node[node_index];
        if colors[node_index] != -1 {
            continue;
        }
        colors[node_index] = color;
        for edge_index in 0..node.edge.len() {
            let edge = &input.edge[node.edge[edge_index]];
            if edge.w % 2 == 0 {
                queue.push_back((edge.u - 1, color));
                queue.push_back((edge.v - 1, color));
            } else {
                if color == 0 {
                    queue.push_back((edge.u - 1, 1));
                    queue.push_back((edge.v - 1, 1));
                } else if color == 1 {
                    queue.push_back((edge.u - 1, 0));
                    queue.push_back((edge.v - 1, 0));
                }
            }
        }
    }
    Ok(colors
        .iter()
        .map(|a| a.to_string())
        .collect::<Vec<String>>()
        .join("\n"))
}

fn main() {
    let mut input_str = String::new();
    stdin().read_to_string(&mut input_str).unwrap();
    let input = handle_input(input_str).unwrap();
    let output = handle_output(input).unwrap();
    println!("{}", output);
}

Measured memory_bytes: 20656
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
using namespace std;
using ll = long long;
typedef pair <int, int> pii;

int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	string s[101];
	//long long n, A[1000000000];
	int n, m, q;
	//int   y[100001], z[100001], x[10001] = {};
	//pii y[100001];
	//pair<int, float> pii[100001];
	ll A[101] = {};
	ll B[101] = {};
	cin >> a;
	cin >> b;
	for (c = 0; c < a; c++)
	{
		cin >> s[c];
	}
	for (c = 0; c < a; c++)
	{
		for (d = 0; d < b; d++)
		{
			if (s[c][d] == '#')
			{
				break;
			}
			if (d == b - 1)
			{
				A[c] = 1;
			}
		}
	}
	for (c = 0; c < b; c++)
	{
		for (d = 0; d < a; d++)
		{
			if (s[d][c] == '#')
			{
				break;
			}
			if (d == a - 1)
			{
				B[c] = 1;
			}
		}
	}
	for (c = 0; c < a; c++)
	{
		for (d = 0; d < b; d++)
		{
			if (A[c] != 1 && B[d] != 1)
			{
				cout << s[c][d];
			}
		}
		if (A[c] != 1)
		{
			cout << endl;
		}
	}
	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;

int n, a[2010], ans, t[2010], sum[2010], maxx, minn, b[2010];

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

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

int main(){

	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &a[i]), t[a[i]]++;
	for(int i = 1; i <= 2000; i++)
		sum[i] = sum[i - 1] + t[i];
	std::sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++)
		if(a[i] != a[i - 1])
			b[a[i]] = i;
	for(int i = 1; i < n; i++)
		for(int j = i + 1; j <= n; j++){
			maxx = a[i] + a[j] - 1;
			minn = a[j] - a[i] + 1;
			ans += max(0, sum[maxx] - sum[a[j] - 1] - (j - b[a[j]] + 1));
		}
//	for(int i = 1; i <= n; i++)
//		ans -= sum[a[i] + a[i] - 1] - t[a[i]];
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll x;
    cin >> x;
    cout << (x / 500) * 1000 + ((x % 500) / 5 )*5<< endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int f[n] = {};
    rep(i,n){
        int a; cin >> a;
        a--;
        f[a]++;
    }
    sort(f,f+n,greater<int>());
    int m = 0;
    rep(i,n){
        if(f[i] > 0)m++;
    }
    int a[m];
    rep(i,m)a[i] = f[i];
    sort(a,a+m);
    int sum[m+1] = {};
    srep(i,1,m+1){
        sum[i] = sum[i-1] + a[i-1];
    }

    srep(i,1,n+1){
        ll k = i;
        int l = 0;
        int r = n + 1;
        while(l + 1 < r){
            ll x = (l + r) / 2;
            int tmp = 0;
            int ite = lower_bound(a, a+m, x) - a;
            tmp += (ll)(m - ite) * x + sum[ite];
            if(tmp >= x * k){
                l = x;
            }else{
                r = x;
            }
        }
        cout << l << endl;
    }


    return 0;
}
 
 


Measured memory_bytes: 4224
#include<stdio.h>

#define MAX 200000

int max(int a,int b){
    if(a > b){
        return a;
    }else{
        return b;
    }
}

int min(int a,int b){
    if(a < b){
        return a;
    }else{
        return b;
    }
}

int main(void){

    int n,R[MAX],min_R,max_R,i,dif;

    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%d",&R[i]);
    }

    min_R = R[0];
    max_R = -2000000000;

    for(i = 1;i < n;i++){
        max_R = max(max_R , R[i] - min_R);
        min_R = min(min_R,R[i]);
    }

    printf("%d\n",max_R);
    return 0;
}



Measured memory_bytes: 2540
#include <iostream>
#include <set>
#include <cstring>
using namespace std;
#define HIT(a,b) ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)<(a.r+b.r)*(a.r+b.r))

struct DISK{
	int x,y,r,c,o;
} D[25];
int n;
set<int> dp;

int main(){
	int i,j,ans;
	set <int>::iterator it;
	while(cin>>n,n){
		memset(D, 0, sizeof(D));
		dp.clear();
		ans=0;
		
		for(i=0;i<n;i++) cin>>D[i].x>>D[i].y>>D[i].r>>D[i].c;

		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++)
				if(HIT(D[i],D[j])) D[j].o |= 1<<i;
		}

		dp.insert(0);
		for(it=dp.begin();it!=dp.end();it++){
			for(i=0;i<n-1;i++){
				if((*it >> i) & 1) continue;
				for(j=i+1;j<n;j++){
					if((*it>>j) & 1 || D[i].c != D[j].c
					||~*it & D[i].o || ~*it & D[j].o) continue;
					dp.insert(*it|1<<i|1<<j);
				}
			}
			ans = max(ans, __builtin_popcount(*it));
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 24000