akhauriyash/Code-Regression huggingface dataset:
// ==============================================
// Library
// ==============================================
#define _CRT_SECURE_NO_WARNINGS

// When you are using the gcc compiler, you need only the following lines.
// #include <bits/stdc++.h>

// When you are using other compilers, you need the following line instead.
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

// If you use this function, "cin" speeds up.
// However, you can not mix "cin" and "scanf", "cout" and "printf".
void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ==============================================
// ==============================================

int main()
{
	fastIOS();

	string s;
	cin >> s;

	LL sl = s.size();

	LL idxA, idxZ;
	REP(i, sl)
	{
		if (s[i] == 'A')
		{
			idxA = i;
			break;
		}
	}
	RREP(i, sl)
	{
		if (s[i] == 'Z')
		{
			idxZ = i;
			break;
		}
	}

	cout << (idxZ-idxA+1) << "\n";
}

Measured memory_bytes: 720
#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()

const int MAXN = 101;

int a[MAXN], b[MAXN];

int main()
{
    string s;
    int  n;
    while(cin >> n && n)
    {
        cin >> s;
        
        REP(n)
        {
            cin >> a[i] >> b[i]; a[i]--; b[i]--;
        }
        for(int i = n - 1;i>=0; i--)
        {
            s[a[i]] = ((s[a[i]] + (b[i] - a[i]) - 'a')%26 ) + 'a';
            s[b[i]] = ((s[b[i]] + (b[i] - a[i]) - 'a')%26 ) + 'a';
            swap(s[a[i]], s[b[i]]);
        }
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong(), a = scanner.nextLong(), b = scanner.nextLong();
        if (n <= a + b || a == 0){
            System.out.println(Math.min(n, a));
        }
        else {
            if (n % (a+b) <= a){
                System.out.println(n/(a + b) * a + n % (a+b));
            }else
                System.out.println(n/(a + b) * a + a);
        }
    }
}


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

int main(){
    int n, q; cin >> n >> q;
    string s; cin >> s;
    vector<int> ans;
    vector<int> cum(100000, 0);
    int cumsum = 0;
    for(int i=1; i<n; i++){  // AC数の累積和
        if(s[i-1]=='A' && s[i]=='C'){
            cumsum++;
        }
        cum[i] = cumsum;
    }
    for(int i=0; i<q; i++){
        int l, r; cin >> l >> r;
        l--; r--;
        ans.push_back(cum[r] - cum[l]);
    }

    for(int i=0; i<q; i++){
        cout << ans[i] << endl;
    }
    return 0;

}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL cnt[60];
LL solve(LL N, LL X){
  if(X <= 0) return 0;
  if(N == 0){
    return X ? 1 : 0;
  }

  if(cnt[N] <= X) return solve(N-1, X) * 2 + 1;
  if(cnt[N-1] >= X-1) return solve(N-1, X-1);
  LL ans = solve(N-1, cnt[N-1]) + 1;
  if(X - 2 - cnt[N-1] > 0)
    ans += solve(N-1, X - 2 - cnt[N-1]);

  return ans;
}

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

  LL N, X;
  cin >> N >> X;

  cnt[0] = 1;
  for(int i=1;i<=N;++i){
    cnt[i] = cnt[i-1] * 2 + 3;
  }

  cout << solve(N, X) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    int N, M;
    cin >> N >> M;
    priority_queue<ll> que;
    rep(i, N) {
        ll a;
        cin >> a;
        que.push(a);
    }

    rep(i, M) {
        ll q = que.top();
        que.pop();
        q /= 2;
        que.push(q);
    }

    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
n, y = map(int, input().split())
k = 0
y = y / 1000
for a in range(n+1):
    if(10*a+5*(n-a) < y):
        continue
    elif(10*a > y):
        break
    for b in range(n+1-a):
        c = n-a-b
        money_sum = 10*a+5*b+c
        if(money_sum == y):
            print(a, b, c)
            exit()
        elif(money_sum > y):
            break
print(-1, -1, -1)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
int compare_pair(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

long long int a, b;
long long int now, ans, f, g;
char i;

int main(){
	scanf("%lld%lld", &a, &b);
	{
		now = (b+1)/2 + (a)/2;
		now &= 1;
		ans = now;
	}
	for(i=1; i<=40; i++){
		g = (long long int) 1<<i;
		now = 0;
		now += (b+1) / (g<<1) * (g<<1);
		f = (b+1) % (g<<1);
		if(f >= g){
			now += f-g;
		}
		now += (a) / (g<<1) * (g<<1);
		f = (a) % (g<<1);
		if(f >= g){
			now += f-g;
		}
		now &= 1;
		ans = ans | now<<i;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
using namespace std;
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if (b >= a)
		printf("%d", a );
	else
		printf("%d", a-1);
	getchar();
	getchar();
	return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n; cin >> n;
    vector<double> a(n);
    double avg = 0, mindist = 1e100;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) avg += a[i] / n;
    rep(i, 0, n) mindist = min(mindist, abs(a[i] - avg));
    double eps = 1e-6;
    rep(i, 0, n) if (abs(abs(a[i] - avg) - mindist) < eps) {
        cout << i << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[310000];
long long L[310000];
long long R[310000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<3*a;i++)scanf("%d",p+i);
	priority_queue<int>Q;
	long long cur=0;
	for(int i=0;i<a;i++){
		cur+=p[i];
		Q.push(-p[i]);
	}
	for(int i=a;i<=2*a;i++){
		L[i]=cur;
		cur+=p[i];
		Q.push(-p[i]);
		cur+=Q.top();
		Q.pop();
	//	printf("%d: %lld\n",i,L[i]);
	}
	while(Q.size())Q.pop();
	cur=0;
	for(int i=2*a;i<3*a;i++){
		cur+=p[i];
		Q.push(p[i]);
	}
	for(int i=2*a;i>=a;i--){
		R[i]=cur;
		cur+=p[i-1];
		Q.push(p[i-1]);
		cur-=Q.top();
		Q.pop();
	//	printf("%d: %lld\n",i,R[i]);
	}
	long long ret=-inf;
	for(int i=a;i<=2*a;i++)ret=max(ret,L[i]-R[i]);
	printf("%lld\n",ret);
}

Measured memory_bytes: 4728
//Thin.cpp (B)
#include <iostream>
#include <string>
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  char C[H][W];
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++) cin >> C[i][j];
  }
  for(int i = 0; i < 2*H; i++){
    for(int j = 0; j < W-1; j++) cout << C[i/2][j];
    cout << C[i/2][W-1] << endl;
  }
  return 0;

}


Measured memory_bytes: 256
s = input()
t = input()
rs = [-1] * 26
rt = [-1] * 26 
n = len(s)

for i in range(n):
    chrnum = rs[ord(s[i]) - 97]
    if chrnum != -1:
        if t[i] == chr(chrnum + 97):
            continue
        else:
            print("No")
            exit()
    else:
        rs[ord(s[i]) - 97] = ord(t[i]) - 97

for i in range(n):
    chrnum = rt[ord(t[i]) - 97]
    if chrnum != -1:
        if s[i] == chr(chrnum + 97):
            continue
        else:
            print("No")
            exit()
    else:
        rt[ord(t[i]) - 97] = ord(s[i]) - 97
print("Yes")


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

int main(){
  int N;
  cin>>N;
  int X=N/2+1;
  double p[N];
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  double dp[N+1][N+1];
  for(int i=0;i<N+1;i++){
    for(int j=0;j<N+1;j++){
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1.0;
  for(int i=1;i<N+1;i++){
    for(int j=0;j<i+1;j++){
      if(j>0) dp[i][j] = dp[i-1][j-1]*p[i-1]+dp[i-1][j]*(1-p[i-1]);
      else dp[i][0] = dp[i-1][0]*(1-p[i-1]);
    }
  }
  
  double ans=0.0;
  for(int j=X;j<N+1;j++){
    ans += dp[N][j];
  }
  cout << setprecision(10);
  cout <<ans << endl;
}
  

Measured memory_bytes: 70528
class PriorityQueue
  MIN = -(1 << 60)

  attr_reader :size

  def initialize(&block)
    @size = 0
    @heap = Array.new
    @get_key = block || :itself.to_proc
  end

  def empty?
    size == 0
  end

  def pop
    return nil if @size <= 0
    max = @heap[1]
    @heap[1] = @heap[@size]
    @size -= 1
    max_heapify(1)
    max
  end

  def push(x)
    @size += 1
    i = @size
    @heap[i] = x
    while i > 1 && (@get_key.call(@heap[i / 2]) <=> @get_key.call(@heap[i])) < 0
      t = @heap[i / 2]
      @heap[i / 2] = @heap[i]
      @heap[i] = t
      i = i / 2
    end
  end

  def top
    return nil if @size <= 0
    @heap[1]
  end

  def to_a
    return [] if @size == 0
    @heap[1..@size]
  end

  private

  def max_heapify(i)
    l = 2 * i
    r = 2 * i + 1
    largest =
      l <= @size && (@get_key.call(@heap[l]) <=> @get_key.call(@heap[i])) > 0 ? l : i
    largest = r \
      if r <= @size && (@get_key.call(@heap[r]) <=> @get_key.call(@heap[largest])) > 0
    unless largest == i
      t = @heap[i]
      @heap[i] = @heap[largest]
      @heap[largest] = t
      max_heapify(largest)
    end
  end
end

require 'set'
N, K = gets.split.map(&:to_i)
tds = N.times.map { gets.split.map(&:to_i) }

sorted = tds.sort_by { |(t, d)| -d }
tset = Set.new
pq = PriorityQueue.new { |d| -d }
sum = 0
K.times do |i|
  t, d = sorted[i]
  if tset.include?(t)
    pq.push(d)
  else
    tset.add(t)
  end
  sum += d
end
ans = sum + tset.size * tset.size

sorted.drop(K).each do |t, d|
  break if tset.size == K
  next if tset.include?(t)
  tset.add(t)
  d2 = pq.pop
  sum -= (d2 - d)
  n = sum + tset.size * tset.size
  ans = n if n > ans
end

puts ans


Measured memory_bytes: 15696
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, m, k = tin()
	#s = input()
	for ni in range(n+1):
		for mi in range(m+1):
			bn = ni*(m-mi) + (n-ni)*(mi)
			if bn == k:
				return 'Yes'
	return 'No'
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 9240
#include<iostream>
using namespace std;
int main(void){
  int k,s;
  cin >> k>>s;
  int cnt = 0;
  for (int i = 0; i <= k; i++)
  {
    for (int j = 0; j <= k;j++){
        if(0<=s-i-j&&s-i-j<=k){
          cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	wMax := nextInt()

	v := make([]int, n)
	w := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = nextInt()
		w[i] = nextInt()
	}

	dp := make([]int, wMax+1)
	for i := 0; i <= wMax; i++ {
		for j := 0; j < n; j++ {
			k := i - w[j]
			if k >= 0 {
				c := dp[k] + v[j]
				if c > dp[i] {
					dp[i] = c
				}
			}
		}
		// fmt.Println(dp)
	}
	fmt.Println(dp[wMax])
}



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

int m1,d1,m2,d2;

int main(void){
    // Your code here!
    cin>>m1>>d1>>m2>>d2;
    
    if(m1+1==m2){
        cout<<1<<endl;
    }
    else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int n;
    string s;
    int num_front=0;
    int num_back=0;

    cin >> n;
    cin >> s;
    for(int i=0; i<n; i++){
        if(s[i]=='('){
            num_front++;
        }
        if(s[i]==')'){
            if(num_front!=0){
                num_front--;
            }else{
                num_back++;
            }
        }
    }

    for(int i=0; i<num_back; i++){
        cout << '(';
    }
    cout << s;

    for(int i=0; i<num_front; i++){
        cout << ')';
    }
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
using Graph = vector<vector<pair<ll, ll>>>;


int main()
{
    ll Q; cin >> Q;
    vll l(Q), r(Q); rep(i, Q) cin >> l[i] >> r[i];

    ll N = 1e5+10;
    vector<bool> is_prime(N, true);
    is_prime[1] = false;
    for (ll i = 2; i < N; i++) {
        if (is_prime[i]) for (ll j = 2 * i; j < N; j += i) is_prime[j] = false;
    }

    vector<bool> is_like(N, false);
    for (ll i = 1; i < N; i += 2) {
        is_like[i] = (is_prime[i] && is_prime[(i + 1) / 2]);
    }

    vll sum(N);
    rep(i, N) if (i == 0) sum[i] = is_like[i]; else sum[i] = sum[i-1] + is_like[i];

    //rep(i, 60) cout << i << ": " << sum[i] << endl;

    rep(i, Q) {
        cout << sum[r[i]] - sum[l[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>

using namespace std;

bool isCat(int &i,string &S){
    if(S.size()<=i) return false;
    if(S[i]!='m') return false;
    i++;
    if(S.size()<=i) return false;
    if(S[i]!='e'){
        if(!isCat(i,S)) return false;
    }
    if(S.size()<=i) return false;
    if(S[i]!='e'){
        return false;
    }
    i++;
    if(S.size()<=i) return false;
    if(S[i]!='w'){
        if(!isCat(i,S)) return false;
    }
    if(S.size()<=i) return false;
    if(S[i++]=='w'){
        return true;
    }else{
        return false;
    }
}

int main(){
    string S;
    cin>>S;
    int i=0;
    if(isCat(i,S)&&i==S.size()){
        cout<<"Cat"<<endl;
    }else{
        cout<<"Rabbit"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3224
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#define int 		long long
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
using namespace std;

void solve(){
	int N,A,B;
	cin>>N>>A>>B;
	vi x(N);
	rep(i,0,N)cin>>x[i];
	int ans=0;
	rep(i,1,N){
		ans+=min(B,A*(x[i]-x[i-1]));
	}
	cout<<ans;
}

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

Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;

    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<ll> sum(N);
    sum[0] = A[0] % M;
    for (ll i = 1; i < N; i++) {
        sum[i] = (sum[i - 1] + A[i]) % M;
    }

    map<ll, ll> num;
    num[0]++;
    for (ll i = 0; i < N; i++) {
        num[sum[i]]++;
    }

    ll ans = 0;
    for (auto p : num) {
        ans += p.second * (p.second - 1) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
n = int(input())
s = len(input())
mod = 10**9+7
dp = [[0]*(n+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(1,n+1):
  dp[i][0] = (dp[i-1][0] + dp[i-1][1])%mod
  for j in range(1,n):
    dp[i][j] = (dp[i-1][j-1]*2 + dp[i-1][j+1])%mod
  dp[i][n] = dp[i-1][n-1]*2%mod
s2 = pow(2,s,mod)
rev = pow(s2,mod-2,mod)
print(dp[n][s]*rev%mod)


Measured memory_bytes: 229640
// 1-indexedで、i番目の要素は必ずi以上になる。なので、
// i < b[i] のとき、そのような数列は作れない
// そうでないなら、任意に作れそう？
// 逆順に見ると、挿入する数が一意に求まる
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> b(N);
    for (int i = 0; i < N; ++i) {
        cin >> b[i];
        --b[i];
    }
    vector<int> res;
    //for (auto p : b) cout << p << " ";
    //cout << endl;
    while (N) {
        int i = N - 1;
        while (i >= 0) {
            if (b[i] == i) break;
            --i;
        }
        if (i < 0) break;
        res.push_back(i);
        //cout << "i: " << i << " b[i]:" << b[i] << endl;
        b.erase(b.begin() + i);
        //for (auto p : b) cout << p << " ";
        //cout << endl;
        --N;
    }
    //cout << "N: " << N << endl;
    if (N > 0) {
        cout << -1 << endl;
    } else {
        for (int i = res.size() - 1; i >= 0; --i) {
            cout << res[i] + 1 << endl;
        }
    }
    return 0;
}

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

visit_flag=[[0]*2 for i in [1]*N]
visit_count=0
first_visit=0
last_visit=0
next_town=1
visit_flag[0][0]=1
visit_flag[0][1]=0

for i in range(K):
    visit_count+=1
    next_town = TO[next_town-1]
    if visit_flag[next_town-1][0]==0:
        visit_flag[next_town-1][0]=1
        visit_flag[next_town-1][1]=visit_count
    else:
        first_visit=visit_flag[next_town-1][1]
        last_visit=visit_count
        break

roop=last_visit-first_visit
span=visit_flag[next_town-1][1]

if K<=roop:
    next_town = 1
    for i in range(K):     
        next_town = TO[next_town-1]
    ans=next_town
else:
    if roop==0:
        ans=next_town
    else:
        for i in range((K-span)%roop):
            next_town = TO[next_town-1]
        ans=next_town

print(ans)

Measured memory_bytes: 40876
#include<iostream>
#include<string>
using namespace std;
int main() {
	string a;
	cin >> a;
	int b = a.length();
	for (int i = 0; i < b; i++) {
		if (a[i] == '?') {
			a[i] = 'D';
		}
	}
	cout << a;

	return 0;
}

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

public class Main
{
    
    
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
        map.clear();
        
        
        int N=sc.nextInt();
        
        int sum = 0;
        
        for (int i = 0; i < N; i++){
            int temp = sc.nextInt();
            if (map.containsKey(temp)){
                //int temp2 = map.get(temp);
                //temp2 = temp2;
                //map.put(temp,temp2);
            }else{
                map.put(temp,1);
            }
        }        
        
        int q=sc.nextInt();
        
        for (int i = 0; i < q; i++){
            int temp = sc.nextInt();
            if (map.containsKey(temp)){
                sum = sum +map.get(temp);
            }
        }
     
        System.out.println(sum);
    }
}

Measured memory_bytes: 40268
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <math.h>

using namespace std;

int main (){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> SC(M,vector<int>(2));
    for(int i = 0; i<M; i++) cin >> SC[i][0] >> SC[i][1];
    int NUM_max, NUM_start, NUM_end;

    if(N==1) {
        NUM_max = 9;
        NUM_start = 0;
    }else if(N==2){
        NUM_max = 99;
        NUM_start = 10;
    }else{
        NUM_max = 999;
        NUM_start = 100;
    }
    int num;
    bool ans_flag = 0;
    int ans = 0;
    int ans_jdg;
    vector<int> res(N);
    int i = NUM_start;
    while ( ans_flag == 0 && i<=NUM_max){
        ans_jdg = 0;
        num = i;
        for(int j = 0; j<N; j++) {
            res[j] = num%10;
            num = num/10;
        }
        
        for(int k=0; k<M; k++){
            if(res[N - SC[k][0]] == SC[k][1]) {
                ans_jdg++;
            };
        }
        if(ans_jdg == M){
            ans_flag = 1;
            ans = i;
        }
        i++;
    }

    if (ans_flag == 0) ans = -1;

    cout << ans << endl;

}

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

void solution() {
   int h, w, k;
   cin>>h>>w>>k;
   vector<string>g(h);
   for(int i=0; i<h; i++){
       for(int j=0; j<w; j++)
           cin>>g[i][j];
   }
   int sc=0, cnt;
   for(int i=0; i<(1<<h); i++){
       for(int j=0; j<(1<<w); j++){
           cnt=0;
           for(int x=0; x<h; x++){
               for(int y=0; y<w; y++){
                   if(g[x][y]=='#' && !(i&(1<<x)) && !(j&(1<<y)))
                       cnt++;
               }
           }
           if(cnt==k) sc++;
       }
   }
   cout<<sc<<'\n';
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
    int t;
    t=1;
    while(t--) solution();
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int A, B, C; cin>>A>>B>>C;
  cout << min(B/A,C) << endl;
  return 0;
}


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

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

	int n , k;
	cin >> n >> k;
	int h[n];
	for(int i = 0; i < n; i++) cin >> h[i];
	sort(h , h+n);
	for(int i = n-1 , j = 0; j < min(n , k); j++ , i--) {
		h[i] = 0;
	}
	int ans = 0;
	for(int i = 0; i < n; i++) ans += h[i];
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a[] = new long[6];
		long mini = -5;
		for (int i = 1; i <= 5; i++) {
			a[i] = sc.nextLong();

		}
		mini = a[1];
		for (int i = 1; i <= 5; i++) {

			if (mini > a[i]) {
				mini = a[i];
			}
		}


		if(n%mini!=0){
			n=n+(mini-n%mini);
		}
System.out.println(n/mini+4);

	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{
    //ABC139 A

    string A,B;
    cin>>A>>B;
    int n = A.size();
    int count =0 ;

    for (int i = 0; i < n; i++)
    {
        if(A[i] == B[i]) count++;
    }

    cout<<count;
    

}


Measured memory_bytes: 384
S = input()
T = input()


tmp = -1
for i in range(len(S) - len(T) + 1):
    start = -1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            start = i
        else:
            start = -1
            break
                       
    if start != -1:
                tmp = i
if tmp == -1:
    print('UNRESTORABLE')
    
else:
    res = ''
    count = 0
    for i in range(len(S)):
        if tmp <= i < tmp + len(T):
            res += T[count]
            count += 1
            
        elif S[i] == '?':
            res += 'a'
            
        else:
            res += S[i]

    print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;
 
#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif

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

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

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

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

#define int long long
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    vector<int> xx(N), yy(N);
    rep(i,N){
        cin >> x[i] >> y[i];
        xx[i] = x[i] + y[i];
        yy[i] = x[i] - y[i];
    }
    sort(ALL(xx));
    sort(ALL(yy));
    cout << max(xx[N-1]-xx[0], yy[N-1]-yy[0]) << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed;
    solve();
}


Measured memory_bytes: 9592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            List<char> lstInp = sS.ToList();
            List<int> lstOut = new List<int>();
            List<List<char>> lstIti = new List<List<char>>() { new List<char>() { '0', '1' }, new List<char>() { '1', '0' }, };
            for (int j = 0; j <= 1; j++)
            {
                int iOut = 0;
                for (int i = 0; i < lstInp.Count; i++)
                {
                    if (lstInp[i] != lstIti[j][i % 2]) { iOut += 1; }
                }
                lstOut.Add(iOut);
            }
            lstOut.Sort();

            // 出力
            System.Console.WriteLine("{0}", lstOut[0].ToString());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 14048
// C++ program of a space optimized DP solution for 
// 0-1 knapsack problem. 
#include<bits/stdc++.h> 
#define ll long long int
using namespace std; 

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

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

// Driver program to test the cases 
int main() 
{ 
	ll n,W,i,j;
    cin>> n >> W;
    ll val[n+1],wt[n+1];
    for(i=0;i<n;i++) 
    cin >> wt[i] >> val[i];
    
    ll sum=0;
	for(int i=0;i<n;i++)
	sum+=val[i];
	
	ll dp[sum+1]; 
	
	for(ll i=0;i<=sum;i++)
	dp[i] = INT_MAX;
	
	dp[0] = 0;

	// iterate through all items 
	for(ll i=0; i < n; i++) {
		//traverse dp array from right to left 
		for(ll j=sum; j>=val[i]; j--)  
			dp[j] = min(dp[j], wt[i] + dp[j-val[i]]);
	}

	ll ans=0;
	for(ll i=0;i<=sum;i++) {
	    if(dp[i]<=W)  {
	    ans=max(ans,i);
	    }
	}
	cout << ans; 
    
    
} 


Measured memory_bytes: 1024
public class Main {

  private static void solve() {
    int n = ni();
    int x = ni();
    int t = ni();

    int m = (n + x - 1) / x;

    System.out.println(m * t);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 36596
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10


def main():
	H, W = MAP()
	Ch, Cw = MAP()
	Dh, Dw = MAP()
	S = [input() for _ in range(H)]

	cnt = [[INF]*W for _ in range(H)]
	cnt[Ch-1][Cw-1] = 0

	dy = [1, 0, -1, 0, 1, 1, -1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2]
	dx = [0, -1, 0, 1, 1, -1, -1, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2, 2, 2, 2, 1]

	q = deque([(Ch-1, Cw-1, 0)])
	while q:
		y, x, c = q.popleft()
		if cnt[y][x] != c:
			continue
		flg = True
		for i in range(24):
			if i == 4 and flg:
				break
			ny = y + dy[i]
			nx = x + dx[i]
			if ny < 0 or nx < 0 or H <= ny or W <= nx:
				continue
			elif i < 4:
				if S[ny][nx] == "." and c < cnt[ny][nx]:
					cnt[ny][nx] = c
					q.appendleft((ny, nx, c))
				elif S[ny][nx] == "#":
					flg = False
			elif 4 <= i and S[ny][nx] == "." and c+1 < cnt[ny][nx]:
				cnt[ny][nx] = c+1
				q.append((ny, nx, c+1))


	if cnt[Dh-1][Dw-1] == INF:
		print(-1)
	else:
		print(cnt[Dh-1][Dw-1])

if __name__ == '__main__':
	main()

Measured memory_bytes: 118560
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }

    (1..p.lastIndex-1).count { i ->
        p[i-1] < p[i] && p[i] < p[i+1] || p[i-1] > p[i] && p[i] > p[i+1]
    }

})

Measured memory_bytes: 37600
import java.util.*;
import java.math.BigDecimal;
import java.math.MathContext;

public class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int x=sc.nextInt();
    double tt=1.0;
    double ans=1.0;
    if(x<=(a*a*b/2)){
      BigDecimal aa=BigDecimal.valueOf(a*b);
      BigDecimal xx=BigDecimal.valueOf(x*2);
      BigDecimal ttt=xx.divide(aa,8,BigDecimal.ROUND_HALF_UP);
      tt=ttt.doubleValue();
      ans=Math.atan2(b,tt);
      ans=Math.toDegrees(ans);
    }else{
      BigDecimal aa=BigDecimal.valueOf(a*a);
      BigDecimal xx=BigDecimal.valueOf((a*a*b-x)*2);
      BigDecimal ttt=xx.divide(aa,8,BigDecimal.ROUND_HALF_UP);
      tt=ttt.doubleValue();
      ans=Math.atan2(tt,a);
      ans=Math.toDegrees(ans);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 27372
N,x=map(int,input().split())
a=sorted([int(i) for i in input().split()])
S=sum(a)
if S==x:
    print(N)
elif S<x:
    print(N-1)
else:
    ans=0
    tmp=0
    for i in range(N):
        if tmp+a[i]<=x:
            ans+=1
            tmp+=a[i]
        else:
            break
    print(ans)


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        int sec = Integer.parseInt(scanner.nextLine());
        int hour = sec / (60 * 60);
        sec -= hour * 60 * 60;
        int min = sec / 60;
        sec -= min * 60;

        System.out.println(hour + ":" + min + ":" + sec);
    }
}

Measured memory_bytes: 26292
module Main where

import Data.Functor
import Data.List

main :: IO ()
main =  do
 { [n] <- getInts
 ; cs  <- loop n
 ; putStr $ unlines $ map show $ sort $ cards \\ cs
 }

loop :: Int -> IO [Card]
loop 0 = return []
loop m = do { c  <- read <$> getLine
            ; cs <- loop (m-1)
            ; return (c:cs)
            }

data Card = S Int | H Int | C Int | D Int deriving (Eq,Ord,Show,Read)

cards = [ c n | c <- [S,H,C,D], n <- [1..13]]

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 4048
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::string s;
  cin >> s;
  int64_t result = 0;
  for (int i = 0; i < (1 << (s.size() - 1)); i++) {
    int64_t sum = 0;
    int index   = 0;
    for (int j = 0; j < s.size(); j++) {
      int mask = (1 << j);
      if ((mask & i)) {
        sum += (s[s.size() - 1 - j] - '0') * std::pow(10, index);
        index = 0;
      } else {
        sum += (s[s.size() - 1 - j] - '0') * std::pow(10, index);
        index++;
      }
    }
    // cout << sum << endl;
    result += sum;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin>>N;
    vector<long long> vt(N,0);
    for(long long i=0;i<N;i++){
        cin>>vt[i];
    }
    long long curr=vt[0];
    long long count=0;
    long long ans=0;
    for(long long i=1;i<N;i++){
        if(vt[i]<=curr){
            count++;
            curr=vt[i];
            ans=max(ans,count);
        }else{
            count=0;
            curr=vt[i];
            ans=max(ans,count);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

vector<short> out;
short N, M, Q;
vector< tuple<short,short,short,int> > dat;
int ans = 0;
int a, b, c, d;

void findStrictlyIncreasingNum(short start, short n) { 
	if (n == 0) { 
		int tmp = 0;
		for (short i = 0; i < Q; ++i) {
			tie(a, b, c, d) = dat[i];
			if (out[b] - out[a] == c) tmp += d;
		}
		ans = max(ans, tmp);
		return; 
	} 
  
	for (short i = start; i <= M; i++) { 
		out[N-n+1] = i;
		findStrictlyIncreasingNum(i, n - 1); 
	} 
}

int main() {
	cin >> N >> M >> Q;
	out.resize(N+1);
	dat.resize(Q);
	for (int i = 0; i < Q; ++i) {
		cin >> get<0>(dat[i]) >> get<1>(dat[i]) >> get<2>(dat[i]) >> get<3>(dat[i]);
	}
	findStrictlyIncreasingNum(1, N);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3756
N, K = map(int, input().split())
x = 1000000007
 
A = N * (N * (N + 1) - K * (K - 1)) // 2
B = (N * (N + 1) * (2 * N + 1) - K * (K - 1) * (2 * K - 1)) // 6
C = N - K + 2
D = (N * (N + 1) - K * (K - 1)) // 2

Ans = (A - B + C + D) % x
 
print(Ans)

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

namespace aziz
{
    class Program
    {
        static void Main(string[] args)
        {
          int A = int.Parse(Console.ReadLine());
          
          double result = A + Math.Pow(A, 2) + Math.Pow(A, 3); 
          Console.WriteLine(result); 
        }
    }
}

Measured memory_bytes: 27828
n = int(input())
w = list(map(int,input().split(" ")))
min = 100000
for i in range(n):
    a = 0
    b = 0
    for j in range(n):
        if j <= i:
            a+=w[j]
        else:
            b+=w[j]
    if abs(a-b)<min:
        min = abs(a-b) 
print(min)  
    

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

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

int main(){
  int64_t N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;

  vector<vector<char>> group(K);
  for(int i=0; i<K; i++){
    for(int j=0; i+K*j<N; j++){
      char s = T.at(i+j*K);
      group.at(i).push_back(s);      
    }
  } 
  

  for(int j=0; j<K; j++){
    group.at(j).push_back('n');
  }

  int64_t c_r=0, c_s=0, c_p=0;
  for(int i=0; i<K; i++){
    char last = group.at(i).at(0);
    int64_t same_count = 0;
    for(int j=0; j<group.at(i).size(); j++){
      char now = group.at(i).at(j);
      if(now==last) same_count++;
      else if(last=='r') {c_r += (same_count+1)/2; same_count=1; last=now;}
      else if(last=='s') {c_s += (same_count+1)/2; same_count=1; last=now;}
      else if(last=='p') {c_p += (same_count+1)/2; same_count=1; last=now;}
    }
  }

  int64_t ans = P*c_r + R*c_s + S*c_p;
  cout << ans << endl;
  //rep(i,group.at(0).size()) cout << group.at(0).at(i);
  //cout << endl;
  //rep(i, group.at(0).size()-1) cout << T.at(i*5);
}

Measured memory_bytes: 5120
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    LL A,B,C;
    cin >> A >> B >> C;
    LL tmp1,tmp2,tmp3;
    LL ans=0;
    if(A%2!=0 || B%2!=0 || C%2!=0){
        ans=0;
    }
    else{
        if(A==B && B==C){
            ans=-1;
        }
        else{
            while(A%2==0 && B%2==0 && C%2==0){
                tmp1=A/2;
                tmp2=B/2;
                tmp3=C/2;
                A=A/2+tmp3;
                B=B/2+tmp1;
                C=C/2+tmp2;
                ++ans;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256