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

int main()
{
    using namespace std;
    int32_t n, m;
    cin >> n;
    cin >> m;
    
    vector<tuple<int32_t, int32_t>> students(n), check(m);
    for (auto j = 0; j < n; ++j) {
        int32_t x, y;
        cin >> x;
        cin >> y;
        students[j] = make_tuple(x, y);
    }

    for (auto j = 0; j < m; ++j) {
        int32_t x, y;
        cin >> x;
        cin >> y;
        check[j] = make_tuple(x, y);
    }
    
    for (auto iter = students.begin(); iter != students.end(); ++iter) {
        int32_t x1, y1;
        tie(x1, y1) = *iter;
        int32_t nearest_diff = numeric_limits<int32_t>::max();
        auto nearest = -1;
        for (auto j = 0; j < m; ++j) {
            int32_t x2, y2;
            tie(x2, y2) = check[j];
            auto diff = abs(x1-x2) + abs(y1-y2);
            if (diff < nearest_diff) {
                nearest_diff = diff;
                nearest = j+1;
            }
        }
        cout << nearest << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean b[] = new boolean[150];
        b[4] = b[7] = true;
        for (int i = 0; i <= 100; i++) {
            if (b[i]) {
                b[i + 4] = b[i + 7] = true;
            }
        }
        System.out.println(b[N] ? "Yes" : "No");
    }
}


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

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
const int limit = 410;

int h,w;
vector<string>s;

ll numb=0,numw=0;
bool paint[limit][limit];
void dfs(int x, int y){
  paint[x][y]=true;
  if(s[x][y]=='#') numb++;
  else numw++;
  
  for(int i=0; i<4; i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    
    if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
    if(s[x][y] == s[nx][ny])continue;
    if(paint[nx][ny]) continue;
    
    dfs(nx,ny);
  }  
}

int main(){
  cin >> h >> w;
  s.resize(h);
  for(int i=0; i<h; i++) cin >> s[i];
  
  ll ans=0;
  for(int x=0; x<h; x++){
   for(int y=0; y<w; y++){
     if(paint[x][y]) continue;
     numb = numw = 0;
     dfs(x,y);
     ans+= numb*numw;
   }
  }
  
  
  cout << ans << endl;
  
  
  return 0;
  
  
  
}
  
  
  
  


Measured memory_bytes: 18176
<?php
/*
    http://agc006.contest.atcoder.jp/tasks/agc006_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d", $N, $x);

// echo "{$N} {$x}\n";
// exit;

$len = $N * 2 - 1;

if ($x == 1 || $x == $len) {
	echo "No" . PHP_EOL;
	exit;
}


$stock = array();
for ($i = 1; $i < $x - 1; $i++) {
	$stock[] = $i;
}
for ($i = $x + 2; $i <= $len; $i++) {
	$stock[] = $i;
}
// var_dump($stock);

$ans = array();
$ans[$N - 1] = $x;
$ans[$N - 2] = $x-1;
$ans[$N] = $x+1;
// var_dump($ans);

for ($i = 0; $i < $N - 2; $i++) {
	// echo "count1 = " . count($stock) . PHP_EOL;
	$ans[$i] = array_pop($stock);
	// var_dump($ans);
}
for ($i = 0; $i < $N - 2; $i++) {
	// echo "count2 = " . count($stock) . PHP_EOL;
	$ans[$i + $N + 1] = array_pop($stock);
	// var_dump($ans);
}
ksort($ans);
echo "Yes\n";
echo implode(" ", $ans) . PHP_EOL;
// echo kenzan($ans) . PHP_EOL;
exit;

for ($i = 1; $i <= 9; $i++) {
	$arr[$i] = $i;
}

$mmin = PHP_INT_MAX;
$mmax = 0;

for ($loop = 0; $loop < 10000; $loop++) {

	$arr2 = $arr;
	shuffle($arr2);
	$orig = $arr2;
	// echo implode(" ", $arr2) . " -> ";
	while (count($arr2) > 1) {
		$arr3 = array();
		for ($i = 0; $i < count($arr2) - 2; $i++) {
			$arr3[$i] = med($arr2[$i], $arr2[$i+1], $arr2[$i+2]);
		}
		// echo implode(" ", $arr3) . PHP_EOL;
		$arr2 = $arr3;
	}
if ($arr2[0] == 2) echo "[2] " . implode(" ", $orig) . PHP_EOL;
if ($arr2[0] == 8) echo "[8] " . implode(" ", $orig) . PHP_EOL;
// echo $arr2[0] . PHP_EOL;
	$mmin = min($mmin, $arr2[0]);
	$mmax = max($mmax, $arr2[0]);
}

// echo "{$mmin} {$mmax}\n";

function med($a, $b, $c) {
	return ($a + $b + $c) - max($a, $b, $c) - min($a, $b, $c);

	if ($a >= $b && $b >= $c) {
		return $b; 
	} elseif ($a >= $c && $c >= $b ) {
		return $c;
	} else {
		return $a;
	}
}

function kenzan($a) {
	var_dump($a);
	$arr2 = $a;
	while (count($arr2) > 1) {
		// echo "count:" . count($arr2). PHP_EOL;
		$arr3 = array();
		for ($i = 0; $i < count($arr2) - 2; $i++) {
			$arr3[$i] = med($arr2[$i], $arr2[$i+1], $arr2[$i+2]);
		}
		// echo implode(" ", $arr3) . PHP_EOL;
		$arr2 = $arr3;
	}
	// echo "kenzan: " . $arr2[0] . PHP_EOL;	
}

Measured memory_bytes: 22004
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll P;
#define N_MAX 10000000
typedef long long int ll;
ll fac[N_MAX+1];
ll inv[N_MAX+1];
ll finv[N_MAX+1];

ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}
ll perm(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (fac[n]*finv[n-k])%P;
}

void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n >> P;
  init();
  ll th = 3*n;
  vvl dp = VV(3*n+1, 6*n+1, 0, ll);
  dp[0][th] = 1;

  for(int i=0;i<3*n;i++){
    for(int j=-3*n;j<=3*n;j++){
      if(dp[i][j+th]==0) continue;
      if(i+3<=3*n) dp[i+3][j+th] = (dp[i+3][j+th] + pp(dp[i][j+th], inv[i+3]))%P;
      if(i+2<=3*n) dp[i+2][j+th-1] = (dp[i+2][j+th-1] + pp(dp[i][j+th], inv[i+2]))%P;
      dp[i+1][j+th+1] = (dp[i+1][j+th+1] + pp(dp[i][j+th], inv[i+1]))%P;
    }
  }

  ll ans = 0;
  for(int i=0;i<=3*n;i++) ans = (ans + dp[3*n][i+th])%P;
  ans = (ans * fac[3*n])%P;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 800280
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int m;

    vector<int> X;
    long long int ans=(1e18)+1;

    int C;
    int i;
    cin >> m ;
    long long int sum=0;

    X.resize(m);

    for(i=0;i<m;i++){
        cin >> X.at(i);
    }

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

    int a=X.front(); //最初を格納
    int b=X.back(); //最後を格納

    for (C=a;C<=b;C++) { //話を計算
        sum = 0;
        for(i=0;i<X.size();i++){
            sum+=pow(X[i]-C,2);
        }
        ans = min(sum,ans);
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int main()
{
    long long n, m;
    cin >> n >> m;
    vector<vector<long long>> ks(m, vector<long long>(n + 1));
    vector<long long> p(m);
    long long ans = 0;
    for (long long i = 0; i < m; i++)
    {
        long long s;
        cin >> ks.at(i).at(0);
        for (int j = 1; j < ks.at(i).at(0) + 1; j++)
        {
            cin >> ks.at(i).at(j);
        }
    }

    for (long long i = 0; i < m; i++)
    {
        cin >> p.at(i);
    }

    for (int bit = 0; bit < (1 << n); ++bit)
    {
        vector<long long> c(m, 0);
        for (int i = 0; i < n; ++i)
        {
            if (bit & (1 << i))
            {
                for (long long k = 0; k < m; k++)
                {
                    for (int j = 1; j < ks.at(k).at(0) + 1; j++)
                    {
                        if (i + 1 == ks.at(k).at(j))
                        {
                            c.at(k)++;
                        }
                    }
                }
            }
        }

        bool flag = true;
        for (long long i = 0; i < m; i++)
        {
            if ((c.at(i) % 2) != p.at(i))
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
<?php
list($S)=sscanf(trim(fgets(STDIN)),"%s");
for($i=0;$i<strlen($S);$i++){
    if($i % 2 == 0){
        if($S[$i] == "L"){
            printf("No");
            exit;
        }
    }else{
        if($S[$i] == "R"){
            printf("No");
            exit;
        }
    }
}
printf("Yes");

Measured memory_bytes: 4604
// "include" {{{
#include <deque>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
// }}}
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 pii pair<int,int> 
#define int long long
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	cout << a[0] * a[1] / 2<< '\n';
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

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

    ll pp = P;
    map<ll, ll> ma;
    for(ll i = 2; i*i <= P; i++){
        while(P%i == 0){
            ma[i]++;
            P /= i;
        }
    }
    if(P != 1) ma[P]++;

    ll ans = 1;
    for(pair<ll, ll> p : ma){
        ll x = p.first;
        ll y = p.second;
        //printf("%d, %d\n", x, y);
        ll num = y/N;
        if(num > 0) ans *= pow(x, num);
    }
    //for(int i = 2; i*i < pp; i++){
    //    printf("%d\n", i);
    //    if(ma.find(i) == ma.end()) continue;
    //    int num = ma[i]/N;
    //    if(num > 0) ans *= pow(i, num);
    //}

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i, n) repr(i, 0, n)
#define repr(i, a, t) reps(i, a, t, 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr(i, (n - 1), 0)
#define rrepr(i, a, t) rreps(i, a, t, 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
using namespace std;
using namespace boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = cpp_int;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (getenv("LOCAL") != nullptr) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N, X;
  cin >> N >> X;

  vector<ll> A;
  rep (i, N) {
    ll a;
    cin >> a;
    A.push_back(a);
  }

  ll ans = 0;
  if (A[0] > X) {
    ans = A[0] - X;
    A[0] = X;
  }
  repr (i, 1, N) {
    if (A[i] + A[i - 1] > X) {
      ans += A[i] + A[i - 1] - X;
      A[i] -= A[i] + A[i - 1] - X;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1400
n, k = map(int, input().split())

b = [False for _ in range(n)]

for i in range(k):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        b[a-1] = True
        
ans = 0

for bb in b:
    if(bb == False):
        ans += 1
        
print(ans)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k,n;
    cin>>k>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans = INT_MAX;
    for(int i=0;i<n-1;i++){
        ans = min(ans,k-abs(a[i+1]-a[i]));
    }
    ans = min(ans,abs(a[n-1]-a[0]));
    cout<<ans<<"\n";
    return 0;
}

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


int main(){
  int N;
  cin >> N;
  int A[N]={};
  for (int i=0;i<N;i++) cin >> A[i];
  
  bool checked[N] = {false};
  int next_button=0, cnt=0;
  //checked[0] = true;
  while (checked[next_button]==false){
    checked[next_button] = true;
    next_button = A[next_button]-1;
    cnt++;
    if (next_button==1) break;
  }

  cout << (next_button==1? cnt : -1) << endl;
}
 

Measured memory_bytes: 768
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;
typedef long long ll;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif

int main(){
    string str;
    while(cin>>str && str!="#"){
        int n = str.size();
        int num=0;
        int p=0;
        for(int i=n-1;i>=0;i--){
            if(str[i] != 'n'&&str[i] != 'w') continue;
            int d = str[i] == 'w';
            if(!p)num=d*90;
            else num += (d * 2 - 1) * 90;
            p++;
            num*=2;
        }
        int den=1<<p;
        {
            int g = __gcd(num, den);
            num/=g;
            den/=g;
        }
        if(den==1)printf("%d\n", num);
        else printf("%d/%d\n", num, den);
    }
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  string S;
  int N;
  cin >> S;
  N = S.size();
  int l=0,r=N-1;
  int cnt = 0;
  while(l < r){
    if(S[l]=='x' && S[r]!='x'){
      l++;
      cnt++;
      continue;
    }
    if(S[r]=='x' && S[l]!='x'){
      r--;
      cnt++;
      continue;
    }
    if(S[l] != S[r]){
      cout << -1 << endl;
      return 0;
    }
    l++;
    r--;
  }
  cout << cnt << endl;
  return 0;
}


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

#include <atcoder/all>
typedef long long lint;
using namespace std;
using namespace atcoder;

int main() {
    int t;
    cin >> t;
    while (t--) {
        lint n, m, a, b;
        cin >> n >> m >> a >> b;
        lint ans = floor_sum(n, m, a, b);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3564
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        mut n: usize,
    }
    let mut ans = 0;
    for f in (2..).into_iter() {
        let mut cnt = 0;
        while n % f == 0 {
            cnt += 1;
            n /= f;
        }
        for i in (1..).into_iter() {
            if i > cnt {
                break;
            }
            cnt -= i;
            ans += 1;
        }
        if f * f > n {
            break;
        }
    }
    println!("{}", if n > 1 { ans + 1 } else { ans });
}


Measured memory_bytes: 2196
#include<iostream>
#include<algorithm>


using namespace std;

int n,vis[101][101];
struct point{int x,y;};
point grid[101][101];

int dfs(int x,int y,int fg){

	vis[y][x]=fg;
	point nx=grid[y][x];
	int res=vis[nx.y][nx.x];
	
	if(vis[nx.y][nx.x]==0)res=dfs(nx.x,nx.y,fg);
	vis[y][x]=res;
	
	return res;
}

int main(void){

	point p;
	
	while(cin >> n,n){
		fill(vis[0],vis[101],0);
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin >> p.x >> p.y;
				grid[i][j]=p;
			}
		}
		
		int cnt=1;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(!vis[i][j]){
					cnt++;
					int tmp=dfs(j,i,cnt);
					if(tmp!=cnt)cnt--;	
				}
			}
		}

		cout << cnt-1 << endl;
	}

return 0;
}

Measured memory_bytes: 1280
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	p := 0
	q := 0
	r := 0
	for _,x := range a {
		if x%4 == 0 {
			p++
		} else if x%2 == 0 {
			q = 1
		} else {
			r++
		}
	}
	if q+r-p <= 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 6528
#include<cstdio>
#include<stdlib.h>
#include<iostream>
using namespace std;
#define MAX 27
#define NIL -1

struct Node { int parent, left, right;};

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
    if ( u == NIL ) return;
    D[u] = d;
    setDepth(T[u].left, d + 1);
    setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
    int h1, h2;
    h1 = h2 = 0;
    if ( T[u].left != NIL ) h1 = setHeight(T[u].left) + 1;
    if ( T[u].right != NIL ) h2 = setHeight(T[u].right) + 1;

    return H[u] = max(h1, h2);

}

int getSibling(int u) {
    if ( T[u].parent == NIL ) return NIL;
    if ( T[T[u].parent].left != u && T[T[u].parent].left != NIL ) return T[T[u].parent].left;
    if ( T[T[u].parent].right != u && T[T[u].parent].right != NIL ) return T[T[u].parent].right;

    return NIL;

}

void type(int u) {
    if ( T[u].parent == NIL ) cout << "root" << endl;
    else if ( T[u].left == NIL && T[u].right == NIL ) cout << "leaf" << endl;
    else cout << "internal node" << endl;
}
void print(int u) {
    int deg = 0;
    cout << "node " << u <<':';
    cout << " parent = " << T[u].parent << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    if ( T[u].left != NIL ) deg++;
    if ( T[u].right != NIL ) deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";
    type(u);
}

int main() {
    cin >> n;
    int i, j, d, v, c, l, r;

    for ( i = 0; i < n; i++ ) T[i].parent = -1;
    for ( i = 0; i < n; i++ ) {
        cin >> j >> d >>v;
        T[j].left = d;
        T[j].right = v;
        if ( d != NIL ) T[d].parent = j;
        if ( v != NIL ) T[v].parent = j;
    }
    for ( i = 0; i < n; i++ ) {
        if ( T[i].parent == NIL)
            break;
    }
    setHeight(i);
    setDepth(i,0);
    for ( i = 0; i < n; i++ ) print(i);
}



Measured memory_bytes: 3088
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<stack>
#include<cstdio>
#include <algorithm>
using namespace std;
int abs(int x)
{
	return x>0?x:-x;
}
int main()
{
    int n;
    cin>>n;
    int* dp=new int[n+1];
    int* h=new int[n+1];
    for(int i=1;i<=n;++i) cin>>h[i];
    dp[1]=0;dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;++i)
    {
    	dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
    cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
    int n,i,a,s=0,m=0;
    vector<int> h;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        h.push_back(a);
    }
    for(i=0;i<n-1;i++){
        if(h[i+1]<=h[i]){
            s=s+1;
        }
        else if (h[i+1]>h[i]){
            s=0;
        }
        m=max(m,s);
    }
    cout<<m;
    return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
#define db double 
#define maxn 200005 
#define mod 998244353
#define vi vector<double>
#define pb push_back
#define ll long long
#define iter set<th>::iterator
using namespace std;
ll ksm(ll a, ll b) {
	if (!b) return 1;
	ll ns = ksm(a, b >> 1);
	ns = ns * ns % mod;
	if (b & 1) ns = ns * a % mod;
	return ns;
}
inline int add(int a, int b) {
	a += b;
	return (a < mod) ? a : (a - mod);
}
inline int sub(int a, int b) {
	a -= b;
	return (a < 0) ? a + mod : a;
}
inline int mul(int a, int b) {
	return (ll)a * b % mod;
}
// head
struct th{
	int tp, pl, num, l, r;
	th(){
	}
	th(int u, int a, int b) {
		tp = u, pl = a, num = b;
		l = r = 1;
	}
	bool operator < (const th &b)const {
		if (tp == 0) return pl < b.pl;
		else  {
			if (num != b.num) return num < b.num;
			return pl < b.pl;
		}
	}
}; 
int n, l;
ll ans = 0;
set<th> ps, qs;
ll cal(vector<th> u) {
	int n = u.size();
	vi sm(n);
	sm[0] = u[0].r;
	for (int i = 1; i < n; i++)
		sm[i] = sm[i - 1] + u[i].r;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		int nx = i + l - 1;
		int ns = sm[n - 1];
		nx--;
		if (nx >= 0) ns -= sm[min(nx, n - 1)];
		ans += 1ll * u[i].l * ns;
	}
	return  ans;
}
void otp(set<th> r) {
	cout << "QQQ" << endl;
	iter q = r.begin();
	while (q != r.end()) {
		cout << (*q).pl << " " << (*q).num << endl;
		q++;
	}
}
int sum[maxn];
int main() {
	cin >> n >> l;
	int inf = 2e9;
	for (int i = 1; i <= n; i++) {
		int a;
		scanf("%d", &a);
		ps.insert(th(0, i, a)), 
		qs.insert(th(1, i, a));
	}
	ans = n;
	while(1) {
		th u1 = *qs.begin();
		if (u1.num >= inf) break;
		iter it = ps.find(th(0, u1.pl, u1.num)), ft = it;
		vector<th> ns;
		while (it != ps.end() && (*it).num == u1.num)
			ns.pb(*it), it++;
		int cnt = ns.size();
		for (int i = 0; i < cnt; i++)
			ps.erase(ns[i]), 
			qs.erase(th(1, ns[i].pl, ns[i].num));
		if (cnt < l) {
		//	ans += cnt;
			ps.insert(th(0, u1.pl, inf)), 
			qs.insert(th(1, u1.pl, inf));
		}
		else {
			vector<th> gr(cnt / l);
			ans += cal(ns);
			int pl = 0;
			for (int i = 0; i < cnt / l; i++) {
				gr[i] = th(1, ns[pl].pl, ns[pl].num + 1);
				gr[i].l = gr[i].r = 0;
				for (int j = pl + l - 1; j < min(pl + 2 * l - 1, cnt); j++)	
					gr[i].r += ns[j].r;
				pl += l;
			}
			pl = cnt - 1;
			for (int i = cnt / l - 1; i >= 0; i--) {
				for (int j = pl - l + 1; j >= max(0, pl - 2 * l + 2); j--)
					gr[i].l += ns[j].l; 
				pl -= l;
			}
			ans -= cal(gr);
			for (int i = 0; i < cnt / l; i++) {
				qs.insert(gr[i]);
				gr[i].tp = 0, ps.insert(gr[i]);
			}
		}
	
	//	otp(ps);
		//otp(qs);
	//	cout << ans << endl;
	////	system("pause");
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 27648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

int main() {
  ll Q;
  cin >> Q;
  ll ans=0;
  priority_queue<ll> s;
  priority_queue<ll,vector<ll>,greater<ll>> l;
  while(Q--) {
    ll q;
    cin >> q;
    if(q==1) {
      ll a,b;
      cin >> a >> b;
      ans+=b;
      s.push(a);
      l.push(a);
      ll x=s.top();s.pop();
      ll y=l.top();l.pop();
      if(x>y) {
        ans+=x-y;
        ll tmp=x;
        x=y;
        y=tmp;
      }
      s.push(x);
      l.push(y);
    }
    else {
      cout << s.top() << " " << ans << endl;
    }
  }
}

Measured memory_bytes: 4588
#include <stdio.h>

int main(void)
{
	char c[1024];
	int i;
	
	for(i = 0; ; i++) {
		scanf("%c", &c[i]);
		if(c[i] == '\n') break;
		if(islower(c[i])) printf("%c", toupper(c[i]));
		else printf("%c", c[i]);
	}
	putchar('\n');
	
	return 0;
}


Measured memory_bytes: 524
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int h,w,k,t,th,tw,i,j,mh,mw,hh,ww,res=0;
  int c[6][6],fh[6],fw[6];
  string s;
  cin >> h >> w >> k;
  for(i=0;i<h;i++){
    cin >> s;
    for(j=0;j<w;j++){
      if(s[j]=='.')
        c[i][j]=0;
      else
        c[i][j]=1;
    }
  }
  mh=1<<h;
  mw=1<<w;
  for(hh=0;hh<mh;hh++){
    th=hh;
    for(i=0;i<h;i++){
      fh[i]=th%2;
      th/=2;
    }
    for(ww=0;ww<mw;ww++){
      tw=ww;
      for(j=0;j<w;j++){
        fw[j]=tw%2;
        tw/=2;
      }
      t=0;
      for(i=0;i<h;i++)
        for(j=0;j<w;j++)
          if(fh[i]==0&&fw[j]==0)
            t+=c[i][j];
      if(t==k)
        res++;
    }
  }
  cout << res << endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

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

ll fac[200010],finv[200010];

ll comb(ll n,ll r){
  if(n<0||r<0||n<r)return 0;
  else return (fac[n]*finv[n-r]%mod)*finv[r]%mod;
}

ll N,M,K;

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

  fac[0]=1;
  rep(i,200000)fac[i+1]=fac[i]*(i+1)%mod;
  rep(i,200001)finv[i]=mod_pow(fac[i],mod-2);

  cin>>N>>M>>K;

  ll suma=0,sumb=0;
  repl(i,1,N){
  	ll cnt=N-i;
  	suma+=cnt*i;
  	suma%=mod;
  }
  suma*=M; suma%=mod;
  suma*=M; suma%=mod;

  repl(i,1,M){
  	ll cnt=M-i;
  	sumb+=cnt*i;
  	sumb%=mod;
  }
  sumb*=N; sumb%=mod;
  sumb*=N; sumb%=mod;

  cout<<(suma+sumb)*comb(N*M-2,K-2)%mod<<endl;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <tuple>

using namespace std;

using lint = long long;
using ldouble = long double;

const int dx[6] = {-1, 1, 0, 0, 0, 0},
          dy[6] = {0, 0, -1, 1, 0, 0},
          dz[6] = {0, 0, 0, 0, -1, 1};

int main() {
    lint A, B, C;
    int N;
    cin >> A >> B >> C >> N;

    lint S = (A * B + B * C + C * A) * 2;

    set<tuple<int, int, int>> emp;
    for (int i = 0; i < N; ++i) {
        int x, y, z;
        cin >> x >> y >> z;
        emp.emplace(x, y, z);
    }

    for (auto t : emp) {
        int x, y, z;
        tie(x, y, z) = t;

        S -= (x == 0) + (x == A - 1) +
             (y == 0) + (y == B - 1) +
             (z == 0) + (z == C - 1);

        for (int i = 0; i < 6; ++i) {
            int nx = x + dx[i], ny = y + dy[i], nz = z + dz[i];
            if (nx < 0 || A <= nx || ny < 0 || B <= ny || nz < 0 || C <= nz) continue;

            if (!emp.count(make_tuple(nx, ny, nz))) ++S;
        }
    }

    cout << S << endl;
    return 0;
}



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

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int sum=0;
    for(int i=1;i<=n;i++){
        int tmp=i;
        int num=0;
        while(tmp!=0){
            num+=tmp%10;
            tmp/=10;
        }
        if(num>=a && num<=b) sum+=i;
    }
    cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 3596
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) = IO().exec {
    val n = int()
    val s = string()
    val cp = compress(s.toCharArray())
    var sum =
            if (cp[0].second == '.') cp.drop(1).filter { it.second == '.' } .map { it.first }.sum()
            else cp.filter { it.second == '.' }.map { it.first }.sum()
    var ret = sum
    var i = if (cp[0].second == '.') 1 else 0
    while (i + 1 < cp.size) {
        sum += cp[i].first
        sum -= cp[i+1].first
        ret = Math.min(ret, sum)
        i += 2
    }
    println(ret)
}

fun compress(s: CharArray): MutableList<Pair<Int, Char>> {
    val acc = mutableListOf<Pair<Int, Char>>()
    var current = s[0]
    var cnt = 1
    for (i in 1 until s.size) {
        if (current != s[i]) {
            acc.add(Pair(cnt, current))
            cnt = 0
        }
        current = s[i]
        cnt++
    }
    acc.add(Pair(cnt, current))
    return acc
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

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

int solve(int n, int* h, int k)
{
  int dp[n];
  dp[0] = 0;
  for (int i = 1; i < n; i++)
  {
    dp[i] = INT_MAX;
    for (int j = 1; j <= k && i-j >= 0; j++)
    {
      dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
    }
  }
  return dp[n-1];
}

int main()
{
  int n, k;
  cin >> n;
  cin >> k;
  int h[n];
  for (int i=0; i<n; i++)
  {
    cin >> h[i];
  }
  int r = solve(n, h, k);
  cout << r << endl;
}


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

int p[10010];

void init(int n)
{
    rep(i, n) p[i] = i;
}

int root(int a)
{
    if (p[a] == a)
        return a;
    return (p[a] = root(p[a]));
}

bool is_same_set(int a, int b)
{
    return root(a) == root(b);
}

void unite(int a, int b)
{
    p[root(a)] = root(b);
}

int main()
{
    int n, q;
    cin >> n >> q;
    init(n);
    rep(i, q)
    {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 1)
            cout << is_same_set(x, y) << endl;
        else
            unite(x, y);
    }
    return 0;
}


Measured memory_bytes: 3164
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
s = 0
s += a[0]
if len(a)%2 == 0:
    s += sum(a[1:len(a)//2]) * 2
else:
    s += sum(a[1:len(a)//2]) * 2 + a[len(a)//2]
print(s)


Measured memory_bytes: 31448
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
int n,a[200010];
long long ans;
signed main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
	for(int i=2;i<=n;i++) {
	    if(a[i]>=a[i-1])
	        continue;
	    ans+=a[i-1]-a[i];
	    a[i]=a[i-1];
	}       
	printf("%lld\n",ans);
}

Measured memory_bytes: 4024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

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

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	int i, j, k, l, m, n;

	cin >> n;
	k = n;

	rep(i, n + 1) {
		l = 0;
		m = i;
		while (m > 0) {
			l += m % 6;
			m /= 6;
		}
		m = n - i;
		while (m > 0) {
			l += m % 9;
			m /= 9;
		}
		if (k > l)k = l;
	}

	cout << k;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int num[100010];
vector<int> g[100010];
vector<int> vec[100010];
set<int> st;

void dfs(int p, int q){
	if(st.count(p)) return ; st.insert(p);
	vec[q].push_back(num[p]);
	
	for(auto e:g[p]) dfs(e, q);
}

int main(){
	int n,m; cin >> n >> m;
	REP(i,0,n) cin >> num[i];
	REP(i,0,m){
		int a,b; cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	int cou = 0; ll s = 0;
	pq<int, vector<int>, greater<int>> qu;
	REP(i,0,n) if(!st.count(i)) dfs(i, cou++);
	REP(i,0,cou) sort(vec[i].begin(), vec[i].end());
	REP(i,0,cou) s += vec[i][0];
	REP(i,0,cou) REP(j,1,vec[i].size()) qu.push(vec[i][j]);
	
	int count = cou - 2;
	while(count and !qu.empty()){
		s += qu.top(); qu.pop();
		count--;
	}
	
	if(cou == 1) cout << 0 << endl;
	else if(count) cout << "Impossible" << endl;
	else cout << s << endl;
	return 0;
}


Measured memory_bytes: 14456
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

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

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (b - a == c - b ? "YES" : "NO") << endl;
}



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

using namespace std;

int main()
{
	int cell[11][11], n;

	while (cin >> n, n){
		for (int i = 0; i < 11; i++){
			for (int j = 0; j < 11; j++){
				cell[i][j] = 0;
			}
		}

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

		for (int i = 0; i < n + 1; i++){
			for (int j = 0; j < n + 1; j++){
				printf("%5d", cell[i][j]);
			}
			printf("\n");
		}
	}
	return (0);
}

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

int main()
{
    int K, A, B;
    cin >> K >> A >> B;
    for(int i=A; i<=B; i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);++i)
#define rep(i,n) REP(i, 0, n)
typedef long long int i64;
typedef pair<int, int> pint;
i64 tate(i64 y, i64 t, i64 d);
i64 yoko(i64 y, i64 t, i64 d) {
    i64 M = y % t, x = y / t;
    if(M == 0)
      return d + (x - 1) * 2 * t + t;
    else {
        d += x * 2 * t;
        return tate(M, t, d);
    }
}
i64 tate(i64 y, i64 t, i64 d) {
    i64 M = t % y, x = t / y;
    if(M == 0)
      return d + (x - 1) * 2 * y + y;
    else {
        d += x * 2 * y;
        return yoko(y, M, d);
    }
}
int main() {
    i64 N, X; cin >> N >> X;
    cout << tate(X, N - X, N) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a;
	scanf("%d",&n);
	a=n%10;
	if(a==2||a==4||a==5||a==7||a==9){
		printf("hon\n");
	}
	if(a==0||a==1||a==6||a==8){
		printf("pon\n");
	}
	if(a==3){
		printf("bon\n");
	}
	return 0;
}

Measured memory_bytes: 1576
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;




int main(){
int a;
  cin>>a;
vector<int>food(a);
  vector<int>score(a);
  vector<int>extra(a-1);
  for(int i=0;i<a;i++)
  {
  int b;
    cin>>b;
    food.at(i)=b;
  }
    for(int i=0;i<a;i++)
  {
  int b;
    cin>>b;
    score.at(i)=b;
  }
    for(int i=0;i<a-1;i++)
  {
  int b;
    cin>>b;
    extra.at(i)=b;
  }
  int t=0;
  for(int i=0;i<a;i++)
  {
  t=t+score.at(food.at(i)-1);
  
  
  }
    for(int i=0;i<a-1;i++)
  {
  
  if(food.at(i)==food.at(i+1)-1)  t=t+extra.at(food.at(i)-1);
  
  }
  cout<<t;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

VL p, c;

ll dfs(VL &acc, VB &st, ll cur, ll i){
    if(st[cur]) return i-1;
    acc[i] = acc[i-1] + c[p[cur]];
    st[cur] = true;
    return dfs(acc, st, p[cur], i+1);
}

int main(){
    // input
    ll n, k;
    cin >> n >> k;
    p.resize(n);
    c.resize(n);
    rep(i, 0, n){
        cin >> p[i];
        p[i]--;
    }
    rep(i, 0, n) cin >> c[i];

    // full-search
    ll ans = *max_element(ALL(c));
    rep(i, 0, n) {
        VL acc(n+10, 0);
        VB st(n+10, false);
        ll sz = dfs(acc, st, i, 1);
        ll sum = acc[sz];
        ll rem = k % sz;
        // cerr << sz << " " << rem << " " << sum << endl;
        ll tmp1 = -1e18;
        if((k / sz) > 0) {
            tmp1 = sum * (k / sz);
            ll off = 0;
            rep(j, 1, rem+1) off = max(off, acc[j]);
            tmp1 += off;
        }
        ll tmp2 = -1e18;
        rep(j, 1, min(sz, k)+1) tmp2 = max(tmp2, acc[j]);
        ll tmp3 = -1e18;
        if((k / sz) > 1) {
            tmp3 = sum * ((k / sz) - 1);
            ll off = 0;
            rep(j, 1, sz + 1) off = max(off, acc[j]);
            tmp3 += off;
        }
        ans = max({ans, tmp1, tmp2, tmp3});
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

const int N = 1e4 + 10, MOD = 1e9 + 7;

int a[N], b[N];

int fpow(int a, int b) {
  int ans = 1;
  for(; b; b >>= 1, a = 1ll * a * a % MOD) {
    if(b & 1) {
      ans = 1ll * ans * a % MOD;
    }
  }
  return ans;
}

map<int, int> mp;

void insert(int x, int c) {
  auto it = mp.find(x);
  if(it == mp.end()) {
    mp[x] = c;
  } else {
    it->second = max(it->second, c);
  }
}

void Main() {
  int n; cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
    int t = a[i];
    for(int j = 2; j * j <= t; j++) {
      if(t % j == 0) {
        int cnt = 0;
        while(t % j == 0) {
          t /= j;
          cnt++;
        }
        insert(j, cnt);
      }
    }
    if(t > 1) {
      insert(t, 1);
    }
  }
  int sum = 1;
  for(auto &x: mp) {
    sum = 1ll * sum * fpow(x.first, x.second) % MOD;
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    int t = fpow(a[i], MOD - 2);
    ans += 1ll * t * sum % MOD;
    if(ans >= MOD) ans -= MOD;
  }
  cout << ans << "\n";
}

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

int main() {
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);
  vector<bool> primes, primes2;
  vector<int> counts;
  int q, l, r, numbers = 0;
  cin >> q;
  for (int i=0; i<100001; i++) {
    primes.push_back(true);
  }
  primes[0]=false;
  primes[1]=false;
  
  for (int i=2; i<100001; i++) {
    if (!primes[i]) continue;
    for (int j=2; j<int(sqrt(i))+1; j++) {
      if (i%j==0) {
        primes[i]=false;
        for (int k=2*i; k<100001; k+=i) primes[k]=false;
        break;
      }
    }
  }
  /*
  primes2 = primes;
  for (int i=1; i<100001; i+=2) {
    if (!(primes[i] && primes[(i+1)/2])) primes2[i]=false;
  }
  primes2[1]=false;
  */
  for (int i=0; i<100001; i++) {
    if (primes[i] && primes[int((i+1)/2)]) numbers+=1;
    counts.push_back(numbers);
  }
  
  for (int i=0; i<q; i++) {
    cin >> l >> r;
    cout << counts[r]-counts[l-1] << '\n';
  }
   return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,x;
    cin>>n>>x;
    int l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    int cnt=1,d=0;
    for(int i=0;i<n;i++){
        d=d+l[i];
        if(d<=x)cnt++;
    }
    cout<<cnt<<endl;
}


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

typedef long long ll;

int main () {
    int n;
    cin >> n;
    int col[9] = {0};
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        if (k <= 3199) {
            col[k/400] = 1;
        }
        else {
            col[8] += 1;
        }
    }
    for (int i = 0; i < 8; i++) {
        sum += col[i];
    }
    if (col[8] == 0) {
        cout << sum << " " << sum << endl;
    }
    else {
        cout << max(1, sum) << " " << sum + col[8] << endl;
    }
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
macro_rules! chmax {
    ($x:expr, $e:expr) => {
        $x = max($x, $e);
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        $x = min($x, $e);
    };
}

const INF: usize = 1 << 60;

fn main() {
    input!{
        N: usize,
        mut h: [usize; N],
    }
    let mut ans = 0;
    h.push(0);
    loop {
        let mut min = INF;
        let mut previ = 0;
        for i in 0..(N+1) {
            if h[i] == 0 {
                if min == INF {
                    continue;
                }
                for j in previ..i {
                    h[j] -= min;
                }
                ans += min;
                min = INF;
                continue;
            } else if min == INF {
                previ = i;
            }
            chmin!(min, h[i]);
        }
        if h.iter().all(|&x| x == 0) {
            break;
        }
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {
    def main(args: Array[String]): Unit = { 
        digit(readLine().split(" ").map(_.toDouble))
    }   

    @tailrec
    def digit(n: Seq[Double]): Unit = {
       val d: Double = n(1) * n(3) - n(0) * n(4)
       val x: Double = zero((n(1) * n(5) - n(4) * n(2)) / d)
       val y: Double = zero((n(2) * n(3) - n(0) * n(5)) / d)
       println(f"$x%.3f $y%.3f")
       val next: String = readLine()
       if(next == null) Unit else digit(next.split(" ").map(_.toDouble))
    }

    def zero(n: Double): Double = if(n == -0) 0 else n
}

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

using namespace std;

#define LL long long

set < string > st;
map < string, LL > mp;

LL calc (LL x) {
	return ((x - 1) * x) / 2LL;
}

int main () {

	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n;
	cin >> n;

	string s;

	for (int i = 0; i < n; ++i) {
		cin >> s;
	
		sort (s.begin(), s.end());	
		
		st.insert (s);
		mp[s]++;
	}

	LL pairs = 0;
	
	for (string x : st) {
		pairs += calc (mp[x]);

		//cout << x << ' ' << mp[x] << '\n';
	}


	cout << pairs << '\n';



	return 0;
}

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

using namespace std;

#define int long long
int mod = 998244353;
int const maxn = 1e5 + 5;
int a[maxn];

int st(int a, int b) {
    if (b == 0) return 1;
    if (b % 2 == 0) {
        int x = st(a, b / 2);
        return x * x % mod;
    }
    return a * st(a, b - 1) % mod;
}

main() {
#ifdef HOME
    //freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    if (a[1] != 0) {
        cout << 0 << '\n';
        return 0;
    }
    sort(a + 1, a + n + 1);
    int ans = 1, h = -1, cnt = 0, i = 1;
    while (i <= n) {
        int lst_cnt = cnt;
        cnt = 0;
        while (i <= n && a[i] == h + 1) {
            i++;
            cnt++;
        }
        if (h == -1 && cnt > 1) {
            cout << 0;
            return 0;
        }
        if (cnt == 0) ans = 0;
        //cout << cnt << '\n';
        if (h != -1) {
            ans = ans * st(lst_cnt, cnt) % mod;
        }
        h++;
        //cout << ans << " " << cnt << '\n';
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 1024
N = int(input())
A = [int(x) for x in input().split()]
flag = True
for i in range(len(A)):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            continue
        else:
            flag = False
            break
if flag == True:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
def main():
    n = int(input())
    a = list(map(int, input().split()))

    a.append(0)

    ans = 0
    cnt = 1
    for i in range(n):
        if a[i] == a[i+1]:
            cnt += 1
        else:
            ans += cnt // 2
            cnt = 1

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  int a,b;
  cin>>a>>b;
  if (a>b) {
    cout<<a*2-1<<endl;
  }
  else if (a<b) {
    cout<<b*2-1<<endl;
  }
  else {
    cout<<a*2<<endl;
  }
  
}



Measured memory_bytes: 764