akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll dp[110][2];
char s1[110],s2[110];
int main(){
	int n;
	scanf("%d%s%s",&n,s1+1,s2+1);
	int i = 1;
	if(s1[1] == s2[1]){
		dp[1][1] = 3;
	}
	if(n > 1 && s1[1] == s1[2]){
		dp[2][0] = 6;
		i++;
	}
	for(i=i+1;i<=n;i++){
		if(s1[i] == s2[i]){
			dp[i][1] = (dp[i-1][1]*2 + dp[i-1][0]) % mod;
		}
		else{
			dp[i+1][0] = (dp[i-1][1] * 2 + dp[i-1][0] * 3) % mod ;
			i++;
		}
	}
	printf("%lld\n",dp[n][0] + dp[n][1]);
	return 0;
}





Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	a := getInts(3)
	sort.Ints(a)
	if a[0] == a[1] {
		out(a[2])
		return
	}
	out(a[0])
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
const int maxn=2000+10;
const int inf=0x3f3f3f3f;
int n,k,head[maxn],to[maxn<<1],nxt[maxn<<1],dep[maxn],tot,sum;

void add(int x,int y){
	to[++tot]=y;
	nxt[tot]=head[x];
	head[x]=tot;
}
void dfs(int x,int fa){
	if(dep[x]>k/2) sum++;
	for(int i=head[x],y;i;i=nxt[i]){
		y=to[i];
		if(y==fa) continue;
		dep[y]=dep[x]+1;
		dfs(y,x);
	}
}

int main()
{
	int u,v,val,ans=inf,flag1,flag2;
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		add(u,v);add(v,u);
	}
	if(!(k&1)){
		for(int rt=1;rt<=n;rt++){
			dep[rt]=0;
			sum=0;
			dfs(rt,0);
			ans=min(ans,sum);
		}
		printf("%d\n",ans);
	}
	else {
		for(int rt=1;rt<=n;rt++){
			for(int i=head[rt];i;i=nxt[i]){
				sum=0;
				dep[rt]=0;
				dfs(rt,to[i]);
				dep[to[i]]=0;
				dfs(to[i],rt);
				ans=min(ans,sum);
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

char S[200000];

int one_move(int *p, int *o, int target)
{
  int P = *p;
  int O = *o;

//  printf("P=%d target=%d\n", P, target);

  if (P < (target - 1)) {
    if (((P+2) != O) &&
        (S[P+2] == '.')) {
      P += 2;
      *p = P;
//      printf("P=%d target=%d (moved)\n", P, target);
      return 0;
    }
  }

  if (P < (target - 0)) {
    if (((P+1) != O) &&
        (S[P+1] == '.')) {
      P += 1;
      *p = P;
//      printf("P=%d target=%d (moved)\n", P, target);
      return 0;
    }
  }
  return 1;
}

int move_to_wait(int *p, int *o, int target)
{
  int P = *p;
  int O = *o;

//  printf("P=%d target=%d\n", P, target);

  while (1) {
    if ((S[P - 1] == '.') && (S[P + 1] == '.')) return 0;

    if (P < (target - 0)) {
      if (((P+1) != O) &&
          (S[P+1] == '.')) {
        P += 1;
        *p = P;
//        printf("P=%d target=%d (moved)\n", P, target);
        continue;
      }
    }
    if (P < (target - 1)) {
      if (((P+2) != O) &&
          (S[P+2] == '.')) {
        P += 2;
        *p = P;
//        printf("P=%d target=%d (moved)\n", P, target);
        continue;
      }
    }
    
    break;
    
  }//while

  return 1;
}

int main()
{
  int cnt;
  int i;
  int N,A,B,C,D;
  int comp = 0;
  int ret;

  cnt = scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
  cnt = scanf("%s", S);
//  printf("%s\n", S);
  A--;
  B--;
  C--;
  D--;

  if (C > D) {
    move_to_wait(&B, &A, D);
  }

  while (comp == 0) {
    if ((A == C) && (B == D)) {
      printf("Yes");
      return 0;
    }

    if (A < C) {
      ret = one_move(&A, &B, C);
      if (ret == 0) continue;
      ret = one_move(&B, &A, D);
      if (ret == 0) continue;
      printf("No");
      return 0;
    }

    if (B < D) {
      ret = one_move(&B, &A, D);
      if (ret == 0) continue;
      ret = one_move(&A, &B, C);
      if (ret == 0) continue;
      printf("No");
      return 0;
    }

  }// while

  printf("No");

  return 0;
}



Measured memory_bytes: 384
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.Char
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

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

main :: IO ()
main = do
  n <- readLn
  wss <- replicateM n (words <$> getLine)
  let (p1,p2) = solve wss
  printf "%d %d\n" p1 p2

solve :: [[String]] -> (Int, Int)
solve = foldl f (0, 0)
 where
  f (p1,p2) [w1,w2] = case (compare w1 w2) of
    LT -> (p1, p2 + 3)
    EQ -> (p1 + 1, p2 + 1)
    GT -> (p1 + 3, p2)



Measured memory_bytes: 4604
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

void swap(int& i,int& j){
    int t=i;i=j;j=t;
}
int main(){
    int n[5][6]={{0,3,5,2,4,0},{0,0,1,6,0,3},{0,0,0,0,1,5},
                 {0,0,0,0,6,2},{0,0,0,0,0,4}};
    int a[6];
    F(i,0,6) cin >> a[i];
    int q;
    cin >> q;
    int x,y;
    int ans[q];
    F(i,0,q){
        cin >> x >> y;
        F(j,0,6){
            if(a[j]==x){
                F(k,0,6){
                    if(j!=k && a[k]==y){
                        if(j>k){
                            swap(j,k);
                            ans[i]=a[7-n[j][k]-1];
                        }
                        else ans[i]=a[n[j][k]-1];
                    }
                }
            break;
            }
        }
    }
    F(i,0,q) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3056
import collections

def main(): 
    N = int(input())
    A = list(map(int, input().split()))
    cnt = [0]*(N+1)
    C = collections.Counter(A)
    
    for k, v in C.items():
        cnt[k] = v*(v-1)//2
    S = sum(cnt)
    
    for i in A:
        print(S - cnt[i] + (C[i]-1)*(C[i]-2)//2)
        
main()

Measured memory_bytes: 26772
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Nikkei2019
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nab = ReadInts();
            int max = Math.Min(nab[1], nab[2]);
            int min = Math.Max(nab[1] + nab[2] - nab[0], 0);
            Console.WriteLine(max + " " + min);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main() {
	string str;
	cin >> str;
	vector<ll> cnt(3, 0);
	for (size_t i = 0; i < str.size(); i++)
	{
		if (str[i] == 'a') {
			cnt[0]++;
		}
		else if (str[i] == 'b') {
			cnt[1]++;
		}
		else {
			cnt[2]++;
		}
	}
	sort(cnt.begin(), cnt.end());
	reverse(cnt.begin(), cnt.end());

	if (cnt[0] - cnt[2] <= 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
	
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define read(x) scanf("%d",&x)
using namespace std;
const int maxn = 1e5 + 10;

int n;
ll a[maxn];
int zero[64], tot;
ll p[64];

void insert(ll x){
	for(int i=0;i<tot;i++){
		if((x>>zero[i])&1){  
			if(!p[i]){
				p[i] = x;
				break;
			}else{
				x^=p[i];
			}
		}
	}
}

int main()
{   
	cin>>n;
	cout<<n*n*n<<endl;
	return 0;
}

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

int main(){
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  
  vector<int> cnt(N);
  for(int i = 1;i < N;i++) cnt.at(i) = cnt.at(i-1) + (S.at(i-1) == 'A' && S.at(i) == 'C'); 
  
  for(int i = 0;i < Q;i++){
    int l, r;
    cin >> l >> r;
    
    cout << cnt.at(r-1) - cnt.at(l-1) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    string s,t;
    cin >>s >>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),std::greater<char>());

   // cout << s<<"\t"<<t<<endl;

    rep(i,min(s.size(),t.size())){
     //   cout << s[i] <<"\t" << t[i] <<endl; 
        if(s[i]==t[i]) continue;

        if(s[i]<t[i]){
            cout << "Yes" <<endl;
            return 0;
        }else{
            cout<< "No" <<endl;
            return 0; 
        }
    }

    if(s.size()<t.size()){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int len;
char s[100005],s1[100005];
bool ok=1;
int main()
{
    cin>>s;
    len=strlen(s);
    for(register int i=0;i<len;i++)
    {
        s1[i]=s[len-i-1];
        if(s1[i]=='b')
        	s1[i]='d';
        else if(s1[i]=='d')
        	s1[i]='b';
        else if(s1[i]=='p')
        	s1[i]='q';
        else
        	s1[i]='p';
    }
    for(register int i=0;i<len;i++)
    {
    	if(s[i]!=s1[i])
    	{
    		ok=0;
    		break;
		}
	}
    if(ok)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 1e9 + 7;
vector<long long int> fac;
long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res = res * a % mod;
    return res;
}


long long int myc(long long int a, long long int b) {
    return fac[a] * mypow(fac[b], mod - 2) % mod * mypow(fac[a - b], mod - 2) % mod;
}

int main() {
	int n, k;
    cin >> n >> k;
    vector<long long int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    fac.push_back(1);
    for (int i = 1; i <= n; i++) {
        fac.push_back(fac.back() * i % mod);
    }
    sort(v.begin(), v.end());
    long long int res = 0;
    for (int i = k - 1; i < n; i++) {
        res += myc(i, k - 1) * v[i] % mod;
        res %= mod;
    }
    reverse(v.begin(), v.end());
    for (int i = k - 1; i < n; i++) {
        res -= myc(i, k - 1) * v[i] % mod;
        res %= mod;
    }
    res += mod;
    res %= mod;
    cout << res << endl;
}


Measured memory_bytes: 5080
import numpy as np

def solve(N, Z, W, A):
    # dp_x[n] := y さんが n 枚目を引いて x さんに手番が回ったときの最大値
    dp_x = np.full(N+1, 1<<61, dtype=np.int64)
    dp_y = np.zeros(N+1, dtype=np.int64)
    for i in range(N-1, 0, -1):
        dp_x[i] = max(dp_y[i+1:].max(), abs(A[-1]-A[i-1]))
        dp_y[i] = min(dp_x[i+1:].min(), abs(A[-1]-A[i-1]))
    ans = max(abs(A[-1]-W), dp_y[1:].max())
    return ans

N, Z, W = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
ans = solve(N, Z, W, A)
print(ans)

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a%2==0&&a==b&&b==c){
        cout << -1 << endl;
        return 0;
    }

    if(a%2!=0||b%2!=0||c%2!=0){
        cout << 0 << endl;
        return 0;
    }
    
    int ans = 0;

    while(true){
        int aa = a,bb= b,cc=c;
        a = bb/2 + cc/2;
        b = aa/2 + cc/2;
        c = aa/2 + bb/2;
        ans++;
        if(a%2!=0||b%2!=0||c%2!=0){
            break;
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    float x1,y1,x2,y2,x3,y3,xp,yp;
    float z1,z2,z3;
    
    while (scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) != EOF) {
        z1 = (x2 - x1) * (yp - y2) - (y2 - y1) * (xp - x2);
        z2 = (x3 - x2) * (yp - y3) - (y3 - y2) * (xp - x3);
        z3 = (x1 - x3) * (yp - y1) - (y1 - y3) * (xp - x1);
        
        if ( (z1 > 0 && z2 > 0 && z3 > 0) || (z1 < 0 && z2 < 0 && z3 < 0) ) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	int c=min(a,b),d=max(a,b);
	for(int i=0;i<d;i++)
	{
		cout<<c;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
T = list(map(int, input().split()))
ans = t
for i in range(1, n):
    m = T[i] - T[i-1]
    if m < t:
        ans +=  T[i] - T[i-1]
    else:
        ans += t
print(ans)

Measured memory_bytes: 26708
import java.util.Scanner;
public class Main {
	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);	
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a * b % 2 == 0) {
			System.out.println("Even");
		}
		else {
			System.out.println("Odd");
		}	
	}

}

Measured memory_bytes: 25044
#include <iostream>
#include <string>
using namespace std;
int main() {
	string O, E;
	cin >> O >> E;
	if (O.size()==E.size())
	{
		for (int i = 0; i < O.size() && i < E.size(); i++) {
			cout << O[i];
			cout << E[i];
		}
}

	else if (O.size() != E.size()) {
		for (int i = 0; i < O.size() - 1; i++) {
			cout << O[i];
			cout << E[i];
		}

	
			cout << O[O.size()-1];

	}

	cout << endl;

	return 0;
}

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

const int MAXN = 3005;

struct node {
	int to, next;
} edge[MAXN*2];
int head[MAXN], top = 0;
inline void push(int i, int j)
{ edge[++top] = (node) {j, head[i]}, head[i] = top; }

int dp[MAXN], n, a[MAXN], u, v;

int dfs(int nd)
{
	if (dp[nd] != -1) return dp[nd];
	dp[nd] = 0;
	for (int i = head[nd]; i; i = edge[i].next) {
		int to = edge[i].to;
		if (dfs(to) == 0) dp[nd] = 1; 
	}
	return dp[nd];
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i < n; i++) {
		cin >> u >> v;
		if (a[u] > a[v]) push(u, v);
		if (a[v] > a[u]) push(v, u);
	}
	memset(dp, -1, sizeof dp);
	for (int i = 1; i <= n; i++)
		if (dfs(i) == 1)
			cout << i << " ";
	cout << endl;
	return 0;
}



Measured memory_bytes: 384
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [0]*n
    for i in reversed(range(n)):
        x = n//(i+1)
        now = 0
        for j in range(1,x+1):
            now += b[j*(i+1)-1]
        if a[i] != now%2:
            b[i]=1
    m = b.count(1)
    print(m)
    if not m==0:
        for i in range(n):
            if b[i]==1:
                print(str(i+1),end=" ")
    
if __name__ == '__main__':
    main()

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

using namespace std;

int a,z;

int main()
{
	cin >> z >> a;
	for (int i = 0; i <= z; i++)
	{
		if (i * 10000 == a && i == z)
		{
			cout << i << " 0 0\n";
			return 0;
		}
		for (int j = 0; j <= z - i; j++)
		{
			if (i * 10000 + j * 5000 == a && i + j == z)
			{
				cout << i << " " << j << " 0\n";
				return 0;
			}
			if (i * 10000 + j * 5000 + (z - i - j) * 1000 == a)
			{
				cout << i << " " << j << " " << z - i - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1\n";
	return 0;
}

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

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//FILE *fin = freopen("in","r",stdin);
//FILE *fout = freopen("out","w",stdout);

int len;
LL ans;
string s;
LL get(LL mask){
  LL ret = 0;
  LL cno = 0;
  for(int i=0;i<SZ(s)-1;i++){
    cno = cno*10 + s[i]-'0';
    if((1<<i)&mask){
      ret += cno;
      cno = 0;
    }
  }
  cno = cno*10 + s.back()-'0';
  ret += cno;
  return ret;
}
void func(int mask,int pos)
{
  if(pos==SZ(s)-1)
  {
    ans += get(mask);
    return;
  } 
  func(mask,pos+1);
  func(mask|(1<<pos),pos+1);
}
int main()
{
  cin>> s;
  func(0,0);
  lldout(ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [(a, i) for i, a in enumerate(map(int, input().split()), start=1)]#(Ai,i)を作成 iはスタート位置
A.sort(reverse=True)#Aiが大きい順にソート

dp = [[0] * (N + 1) for _ in range(N + 1)]
#dp[l][r]=l人は左、r人は右に配置した時の最大スコア

for s, (a, i) in enumerate(A):#Ai大きい順にs人動かした場合
    for l in range(s + 1):#0~s人うごかした時を考える s=l+r。
        r = s - l
        L = dp[l][r] + a * (i - (l + 1))
        R = dp[l][r] + a * (N - r - i)

        if dp[l + 1][r] < L:#最大値の更新
            dp[l + 1][r] = L
        if dp[l][r + 1] < R:
            dp[l][r + 1] = R

ans = 0
for i in range(N + 1):#Ansは左にi,右にN-i動かしたときの最大値、の中の最大値
    ans = max(ans, dp[i][N - i])
print(ans)

Measured memory_bytes: 96312
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    if((N-2)%10==0||(N-4)%10==0||(N-5)%10==0||(N-7)%10==0||(N-9)%10==0){
        cout << "hon";
    }
    if((N-0)%10==0||(N-1)%10==0||(N-6)%10==0||(N-8)%10==0){
        cout << "pon";
    }
    if((N-3)%10==0){
        cout << "bon";
    }
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		sc.close();
		for (int i = 97; i < 123; i++) {
			char c = (char) i;
			for (int j = 0; j < s.length(); j++) {
				char c2 = s.charAt(j);
				if (c == c2) {
					break;
				} else if (j + 1 == s.length() && c != c2) {
					System.out.println(c);
					return;
				}
			}
		}
		System.out.println("None");
	}
}


Measured memory_bytes: 26308
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n;
    cin >> n;
    vector<int> a(n + 1);
    rep(i, n) cin >> a[i+1];

    vector<int> b(n + 1);

    for(int i = n; i >= 1; i--){
        int cnt = 0;
        for(int j = i * 2; j <= n; j += i){
            if(b[j]){
                cnt++;
            }
        }

        if(cnt % 2 != a[i]){
            b[i] = 1;
        }
    }

    vector<int> ans;
    for(int i = 1; i <= n; i++){
        if(b[i]){
            ans.push_back(i);
        }
    }

    cout << SZ(ans) << endl;
    if(SZ(ans) > 0){
        rep(i, SZ(ans)){
            cout << ans[i] << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int A, B, Q; cin >> A >> B >> Q;
    vec s(A); readv(s);
    vec t(B); readv(t);
    vec x(Q); readv(x);

    REP(i, Q){
        int ans = INF;
        int i0 = Lower_bound(s, x[i]);
        int i1 = Lower_bound(t, x[i]);
        if(i0 < A && i1 < B) Min(ans, max(s[i0], t[i1]) - x[i]);
        if(i0 > 0 && i1 > 0) Min(ans, x[i] - min(s[i0 - 1], t[i1 - 1]));
        if(i0 < A && i1 > 0) Min(ans, s[i0] - t[i1 - 1] + min(s[i0] - x[i], x[i] - t[i1 - 1]));
        if(i0 > 0 && i1 < B) Min(ans, t[i1] - s[i0 - 1] + min(t[i1] - x[i], x[i] - s[i0 - 1]));
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;
    ll mod=998244353;
ll pr( ll x , ll y)
{
    ll ans=1;
    if(y==0) return ans;
    while(y>1)
    {
        if(y&1) ans*=x;
        x*=x;
        y/=2;
        x%=mod;
        ans%=mod;
    }
    ans*=x;
    ans%=mod;
    return ans;
}
ll fact( ll n)
{
    ll ans=1,i;
    rep(i,1,n+1)
    {
        ans*=i;
        ans%=mod;
    }
    return ans;
}
ll in(ll x) { return  pr(x,mod-2);}
bool ok(string s)
{
    int i,n=s.size();
    rep(i,1,n)
    {
        if(s[i]-s[i-1]>1) return false;
    }
    return true;
}
void solve()
{
 ll i,j=1,k,n,m=0,f,s1=0,x,c=1,y=0,a=0,b=0,d;
 cin>>n;
  queue < ll > qu;
  vector < ll > dp;
  rep(i,1,10) qu.push(i);
  dp.pb(1);

      while(!qu.empty())
      {
          k=qu.front();
          qu.pop();
          dp.pb(k);
          c=k%10;
          k*=10;
          if(c<9) {qu.push(k+c+1);}
          if(c>0) {qu.push(k+c-1);}
          qu.push(k+c);
          if(dp.size()>2*n) break;
      }
    sort(all(dp));

    cout<<dp[n];

}


 //}

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


Measured memory_bytes: 4976
N, K = map(int, input().split())
towns = list(map(int, input().split()))
towns.insert(0, -1)
p = 1
tmp_move, first_move, roop_move = [1], [], []
visited = [False for _ in range(N + 1)]
res = -1

while not visited[p]:
    visited[p] = True
    tmp_move.append(towns[p])
    p = towns[p]

index = tmp_move.index(p)
roop_move = tmp_move[index:-1]
first_move = tmp_move[:index]

if K < len(first_move):
    res = first_move[K]
else:
    index = (K - len(first_move)) % len(roop_move)
    res = roop_move[index]

print(res)

Measured memory_bytes: 32288
use std::io;

#[allow(unused_macros)]
#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn main() {
    let s = str2vec(&input_line_str());
    let mut ans = 700;
    for z in s {
        if z == 'o' {
            ans += 100;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#import sys
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
#n,m=map(int,input().split())
a=input()
if a.isupper():
    print("A")
else:
    print("a")

Measured memory_bytes: 9336
import numpy as np

N = int(input())
A = list(map(int, input().split()))


A = np.array([0, 0] + A)

cum_0 = A[::2].cumsum()
cum_1 = A[1::2].cumsum()


ans = -float("inf")

if N % 2:
    cum_10 = cum_1.copy()
    cum_10 -= cum_0[1:]
    cum_01 = cum_0[:-1].copy()
    cum_01 -= cum_1

    cum_max_01 = np.zeros_like(cum_01)
    for i in range(1, len(cum_max_01)):
        cum_max_01[i] = max(cum_max_01[i - 1], cum_01[i])

    ans = (cum_max_01 + cum_10).max()
    ans += cum_0[-1]
else:
    for i in range(0, N // 2 + 1):
        tmp = cum_0[i] + (cum_1[-1] - cum_1[i])
        ans = max(ans, tmp)
print(ans)

pass


Measured memory_bytes: 51044
n,k=map(int,input().split())
if n>=k:
    ans=(n-k+1)/n
        
else:
    ans=0.0
for i in range(1,min(n,k)+1):
        tmp=1.0
        while i<k:
            i=i*2
            tmp=tmp*0.5
        if tmp<1:
            ans+=tmp/n
print('{:.17g}'.format(ans))
    

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

cnt=0
tail=0
sec=0
for head in range(n):
    while(tail<n and sec^a[tail]==sec+a[tail]):
        sec^=a[tail]
        tail+=1
    cnt+=(tail-head)
    sec^=a[head]
print(cnt)    


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

int main() {
  int A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;
  long wayA = A * X + B * Y;
  long wayB = C * max(X,Y) * 2;
  long wayC;
  if (X > Y) {
    wayC = C * Y * 2 + (X - Y) * A;
  } else {
    wayC = C * X * 2 + (Y - X) * B;
  } 
  long ans = min(wayA,min(wayB,wayC));
  cout << ans << endl;  
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    int n, k;
    cin >> n >> k;
    if(k > (n - 1) * (n - 2) / 2){
        cout << -1 << endl;
    }
    else{
        int m = (n * (n - 1) / 2) - k;
        cout << m << endl;
        for(int i = 1; i <= n-1; i++){
            // ab.push(P(i, n));
            cout << i << " " << n << endl;
        }
        queue<P> ab;
        for(int i = 1; i <= n-1; i++){
            for(int j = i + 1; j <= n-1; j++){
                ab.push(P(i, j));
            }
        }
        for(int i = 0; i < ((n - 1) * (n - 2) / 2) - k; i++){
            cout << ab.front().first << " " << ab.front().second << endl;
            ab.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 3680
# 初期入力
a,b,X = map(int, input().split())

#
suito_taiseki = a*a*b #水筒の体積
h_wate = X/a/a #水面の高さ

from math import atan,degrees
if suito_taiseki/2 <=X:
    y = (b-h_wate)*2
    kakudo =degrees( atan(y/a) )
else:
    y =2*X/b/a
    kakudo =90-degrees(atan(y/b))


print(kakudo)

Measured memory_bytes: 3060
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


a, b, c, d = na()
print("Yes" if abs(a - b) <= d and abs(b - c)
      <= d or abs(c - a) <= d else "No")


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    if (2 <= abs(N - M)) {
        puts("0");
        return 0;
    }

    ll ans = 1;
    rep(i, N) {
        ans *= i + 1;
        ans %= MOD;
    }
    rep(i, M) {
        ans *= i + 1;
        ans %= MOD;
    }

    if (N == M) {
        ans *= 2;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
var 
	i,j,k,sum: longint;
    loop,loop_2,loop_3,ans: integer;
begin
	readln(loop);
    readln(loop_2);
    readln(loop_3);
    readln(ans);
	for i := 0 to loop do begin
        for j:= 0 to loop_2 do begin
            for k:= 0 to loop_3 do begin
            	//writeln(i * 500);
                //writeln(j * 100);
                //writeln(k * 50);
               	if (i * 500 + j * 100 + k * 50 = ans) then inc(sum); //インクリメント 
            end;
        end; 
     end;
     
     writeln(sum);
     
     //writeln(loop);
     //writeln(loop_2);
     //writeln(loop_3);
 
 
 end.

Measured memory_bytes: 128
import java.util.Scanner;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x,y;
        while(true){
            x = sc.nextInt();
            y = sc.nextInt();        
            if ( x == 0 && y == 0 ) break;
            System.out.printf("%d %d\n", Math.min(x, y),Math.max(x, y));
        }
    }
}



Measured memory_bytes: 39868
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int N;
    long long p1,p2;
    long long d,D;
    int a = 0;
    cin >> N >>D;
    for(int i = 0; i < N; i++)
    {
      cin >> p1 >> p2;
      d=(p1*p1)+(p2*p2);
      if(d<=D*D)
      {
          a++;
      }
    }
    cout <<a<< endl;
    return 0;
}


Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (b % a == 0) {
            System.out.println(a + b);
        } else {
            System.out.println(b - a);
        }

        sc.close();
        //        System.out.println("NO");
    }
}


Measured memory_bytes: 21716
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7

## nCkのmodを求める関数
# テーブルを作る(前処理)
max = 1 * 10**5 + 100
fac, finv, inv = [0]*max, [0]*max, [0]*max

def comInit(max):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1

    for i in range(2,max):
      fac[i] = fac[i-1]* i% mod
      inv[i] = mod - inv[mod%i] * (mod // i) % mod
      finv[i] = finv[i-1] * inv[i] % mod

comInit(max)

# 二項係数の計算
def com(n,k):
    if(n < k):
        return 0
    if( (n<0) | (k < 0)):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

ind = [-1] * (1+n)
for i,ai in enumerate(a,1):
    if(ind[ai]==-1):
        ind[ai] = i
    else:
        left = ind[ai]
        right = i
        break

ans = [0] * (n+2)
for k in range(1,n+2):
    cnt = com(n+1,k)
    if(n -(right-left) >= k-1 ):
        cnt -= com(n-(right-left),k-1)
    ans[k] = cnt%mod

print('\n'.join(map(str,ans[1:])))

Measured memory_bytes: 100264
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	abc := ScanText(scanner)
	
	flg := 0
	for _, r := range abc {
	    for j := 0; j < 3; j++ {
	        if r == rune('a' + j) {
	            if flg & (1 << uint(j)) != 1 {
	                flg += (1 << uint(j))
	            }
	        }
	    }
	}
	
	if flg == 7 {
	    fmt.Println("Yes")
	} else {
	    fmt.Println("No")
	}
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
#include <iostream>

using namespace std;


int main(){

    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a >= b) {
        ans += a;
        a--;
    }
    else {
        ans += b;
        b--;
    }
    if (a >= b) {
        ans += a;
        a--;
    }
    else {
        ans += b;
        b--;
    }
    cout << ans << '\n';


}


Measured memory_bytes: 256
use std::io::{Read, stdin};
use std::str::FromStr;
use std::cmp::max;


fn main() {
    let n: usize = read();
    let mut v: Vec<[i64; 2]> = Vec::new();
    for i in 0..101 {
        for j in 0..101 {
            v.push([i, j])
        }
    }
    let mut x: Vec<i64> = vec![0; n];
    let mut y: Vec<i64> = vec![0; n];
    let mut h: Vec<i64> = vec![0; n];
    for i in 0..n {
        x[i] = read();
        y[i] = read();
        h[i] = read();
    }
    for u in v {
        let mut hh = -1;
        for i in 0..n{
            if h[i] != 0{
                hh = h[i] + (u[0] - x[i]).abs() + (u[1] - y[i]).abs();
                break;
            }
        }
        let mut f: bool = true;
        for i in 0..n{
            if max(hh - (x[i] - u[0]).abs() - (y[i] - u[1]).abs(), 0) != h[i]{
                f = false;
                break;
            }
        }
        if f{
            println!("{} {} {}", u[0], u[1], hh);
            break;
        }
    }
}


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
from math import*
def fact_p(n):
  m=n
  i=2
  a=0
  while n>1:
    if i>m**.5:
      a=n
      break
    while n%i==0:
      n//=i
      a=i
    i+=1  
  return a
n=int(input())
x2=y1=ceil(n**.5+.5) if ceil(n**.5+.5)<=10**9 else 10**9
x1=fact_p(x2*y1-n)
y2=(x2*y1-n)//x1 if x1 else 0
print(0,0,x1,y1,x2,y2)

Measured memory_bytes: 64280
#include <stdio.h>
#include <stdlib.h>

int main(void){
  long long int a,b,v,w,c,x;
  int t;
  int i;
  
  scanf("%lld %lld", &a, &v);
  scanf("%lld %lld", &b, &w);
  scanf("%d", &t);
  
  c=abs(b-a);
  x=abs(w-v);
  
  if(w<v){
  for(i=1;i<=t;i++){
    c=c-x;
    
    if(c<=0){printf("YES"); goto flag;}
    
  }
  }
  
  printf("NO");
  flag:
  
  return 0;
}




Measured memory_bytes: 1688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var l = Console.ReadLine()
               .Split(' ')
               .Select(int.Parse)
               .ToArray();

            var n = l[0];
            var k = l[1];

            var result = 0.0;
            for (int dice = 1; dice <= n; dice++)
            {
                double pow;
                if (dice >= k)
                {
                    pow = 0;
                }
                else
                {
                    var log = Log((double)k / dice, 2);
                    pow = Ceiling(log);
                }
                result += 1.0 / n * Pow(0.5, pow);
            }

            Console.WriteLine($"{result:F12}");
        }
    }
}


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

typedef long long ll;
using namespace std;

#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll h, w, m;	cin >> h >> w >> m;
	set<pair<int, int>> target;
	int sumH[h] = {0};
	int sumW[w] = {0};
	vector<int> cH;
	vector<int> cW;
	int mh, mw;
	int ans = 0;
	REP(i, m){
		ll x, y;	cin >> x >> y;
		x--; y--;
		sumH[x]++;
		sumW[y]++;
		target.insert(make_pair(x, y));
	}

	mh = *max_element(sumH, sumH + h);
	mw = *max_element(sumW, sumW + w);
	REP(i, h){
		if( sumH[i] == mh )	cH.push_back(i);
	}
	REP(i, w){
		if( sumW[i] == mw )	cW.push_back(i);
	}

	REP(i, cH.size()) REP(j, cW.size()){
		int dup = 0;
		if( target.find( make_pair(cH[i], cW[j]) ) == target.end() ){
			cout << mh + mw << endl;
			return 0;
		}
	}

	cout << mh + mw - 1 << endl;

	return 0;
}


Measured memory_bytes: 23784
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 510000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A=INF,B=0,C=INF,D=INF,E,F,N,M,K,sum=0,num=0,cnt=1,next=0;
  cin >> N;
  Vec(P,lli,N,0);
  rep(i,0,N)cin >> P[i];
  rep(i,0,N-1){
    if(P[i]>=P[i+1])sum++;
    num=max(sum,num);
    if(P[i]<P[i+1])sum=0;
    }
  Out(num);
}


Measured memory_bytes: 1024
#include <stdio.h>
 
int main() {
 
  int a,b;
  char op;
 
  scanf("%d %c %d",&a,&op,&b);
 
  while(op != '?') {
    if(op == '+') {
      printf("%d\n",a+b);
    } else if(op == '-') {
      printf("%d\n",a-b);
    } else if (op == '*'){ 
      printf("%d\n",a*b);
    } else if(op == '/') {
      printf("%d\n",a/b);
    } 
    scanf("%d %c %d",&a ,&op, &b);
 
  }
 
  return 0;
 
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define ten(n) ((int)1e##n)
#define fst first
#define snd second
using ll=long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pil=pair<int,ll>;using pli=pair<ll,int>;
using vs=vector<string>;using vvs=vector<vs>;using vvvs=vector<vvs>;
using vb=vector<bool>;using vvb=vector<vb>;using vvvb=vector<vvb>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<class T> bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
ll ri(){ll l;cin>>l;return l;} string rs(){string s;cin>>s;return s;}
template<class T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<'('<<p.fst<<", "<<p.snd<<')';}
template<class T>ostream&operator<<(ostream&o,const vector<T>&t){o<<"{";rep(i,sz(t))o<<t[i]<<",";o<<"}"<<endl;return o;}
#ifdef LOCAL
vs s_p_l_i_t(const string&s,char c){vs v;stringstream ss(s);string x;while(getline(ss,x,c))v.emplace_back(x);return move(v);}
void e_r_r(vs::iterator it){cerr<<endl;}
template<class T,class... Args>void e_r_r(vs::iterator it,T a,Args... args){cerr<<it->substr((*it)[0]==' ',it->length())<<" = "<<a<<", ";e_r_r(++it,args...);}
#define out(args...){vs a_r_g_s=s_p_l_i_t(#args,',');e_r_r(a_r_g_s.begin(),args);}
#else
#define out(args...)
#endif

void Main() {
  int n = ri();
  int c = ri();
  ll k = ri();
  vector<int> T(n);
  rep(i, n) T[i] = ri();

  sort(all(T));

  // OK な下限を探すパターン
  int ok = n;  // check が絶対trueになる値
  int ng = 0;  // check が絶対falseになる値

  auto check = [&](int x) -> bool {
    int i = 0;
    int bus = 0;
    for (; i < n;) {
      bus++;
      int a = 0;
      int t = T[i];
      ll lim = t + k;
      while (i < n && T[i] <= lim && a < c) {
        //out(bus, i, t, lim, a, c);
        i++;
        a++;
      }
    }

    return bus <= x;
  };

  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    bool c = check(mid);
    //cout << "ok: " << ok << ", ng: " << ng << ", ";
    //cout << "check(" << mid << ") -> " << c << endl;
    if (c) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n,r;
  cin>>n>>r;
  cout<<(n<=10 ? r+100*(10-n) : r )<<'\n';
  return(0);
}


Measured memory_bytes: 256
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10**9)
n,m = map(int,input().split())
s = list(input())
s.reverse()
list1 = []
def maze(mass,times): #今いるマス、現状の手数
  if mass+m >= n:
    list1.append(str(n-mass))
    return
  for i in range(m,0,-1):
    if s[mass+i] == "0":
      list1.append(str(i))
      maze(mass+i,times+1)
      return
    elif i == 1:
      print("-1")
      exit()
  return

a = maze(0,0)
list1.reverse()
print(" ".join(list1))

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

int main() {
	int n;
	cin >> n;
	vector<int>a(n+10),h(n+10);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	a[0] = 0;
	a[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		a[i] = min(a[i - 2] + abs(h[i] - h[i - 2]), a[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << a[n - 1];
	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define MOD 1000000007 
#define MOD2 3571
#define INF 100000000
//#define MOD 922337203685419LL
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <functional>
#include <algorithm>
#include <iterator>
#include <cstdio>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <chrono>
#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)
#define ALL(obj) (obj).begin(), (obj).end()

inline ll madd(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a + b) % MOD;
}
inline ll msub(ll a, ll b) {
	a %= MOD;b %= MOD;
	a += MOD;
	return (a - b) % MOD;
}
inline ll mmul(ll a, ll b) {
	a %= MOD;b %= MOD;
	return (a*b) % MOD;
}
inline ll mpow(ll a, ll r) {
	long long res = 1;
	while (r > 0) {
		if (r & 1) res = res * a % MOD;
		a = a * a % MOD;
		r >>= 1;
	}
	return res;
}
inline ll minv(ll a) {
	a %= MOD;
	ll b = MOD, u = 0, v = 1;
	while (a) {
		ll t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += MOD;
	return u;
}
inline ll mdiv(ll a, ll b) {
	a %= MOD;
	a *= minv(b);
	return a%MOD;
}


//ll fact[]
//inline ll combi(int a, int b) {
//	return mmul(fact[a], mmul(fact_inv[b], fact_inv[a - b]));
//}

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

struct edge { ll to, cost; };


int main() {
	ll power[2501];
	power[0] = 1;
	ll power2[2501];
	power2[0] = 1;
	REP(i, 2500) {
		power[i + 1] = (power[i] * 29) % MOD;
		power2[i + 1] = (power2[i] * 29) % MOD2;
	}

	int n;
	cin >> n;
	char s[5001];
	scanf("%s", s);

	vll hash_list(n + 1);
	vll hash_list2(n + 1);
	ll ha = 0;
	ll ha2 = 0;
	REP(i, n) {
		ha *= 29;
		ha += s[i] - 'a' + 2;
		ha %= MOD;
		ha2 *= 29;
		ha2 += s[i] - 'a' + 2;
		ha2 %= MOD2;
		hash_list[i+1]=ha;
		hash_list2[i+1]=ha2;
	}


	RFOR(j, n/2, 0) {
		unordered_map<ll, int> ma;
		REP(i, n - j + 1) {
			ll x = (hash_list[i + j]+MOD-(hash_list[i]*power[j])%MOD)%MOD;
			if (ma.find(x) == ma.end()) ma[x] = i;
			else if (i >= ma[x] + j) {
				if(((hash_list2[i + j]+MOD2-(hash_list2[i]*power2[j])%MOD2)%MOD2)==((hash_list2[ma[x] + j]+MOD2-(hash_list2[ma[x]]*power2[j])%MOD2)%MOD2)){
					cout << j;
					return 0;
				}
			}
		}
	}

	cout << "0";
	return 0;
}

Measured memory_bytes: 688