akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    M = [[None] * (N) for _ in range(N)]

    for k, v in A.items():
        for x, y in v:
            M[k-1][x-1] = y

    for i in range(N, 0, -1):
        for m in combinations(range(N), r=i):
            sm = set(m)
            f = True
            for j in m:
                for k, v in enumerate(M[j]):
                    if v == 1 and k not in sm:
                        f = False
                        break
                    elif v == 0 and k in sm:
                        f = False
                        break
                if not f:
                    break

            if f:
                return i
    return 0


def main():
    N = read_int()
    A = {}
    for i in range(1, N+1):
        n = read_int()
        XY = [read_int_n() for _ in range(n)]
        A[i] = XY
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6728
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	//5*10^15
	string s;
	cin >> s;
	ll K;
	cin >> K;
	if(s.length()==1){cout << s[0] << endl;return 0;}
	else if(K==1){cout<<s[0]<<endl;return 0;}
	else REP(i,s.length()){
      	if(s[i]!='1'){
			if(K>i){cout << s[i] <<endl;return 0;}
			else{cout << 1 << endl;return 0;}
		}
    }
	cout << 1 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int div2(int a){
    int res = 0;
    while(a>0&&a%2==0){
        res++;
        a/=2;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    int res = INT_MAX;
    REP(i,n){
        chmin(res,div2(a[i]));
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val n, k = sc.nextInt()
    val as = Array.fill(n)(sc.nextInt())

    val g = as.foldLeft(as.head)((a, b) => gcd(a, b))

    val ans = if (k % g == 0 && as.max >= k) "POSSIBLE" else "IMPOSSIBLE"

    println(ans)
  }

  @scala.annotation.tailrec
  def gcd(a: Int, b: Int): Int = {
    if (b == 0) a else gcd(b, a % b)
  }
  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


Measured memory_bytes: 54212
N=int(input())
T=list(map(int,input().split()))
V=list(map(int,input().split()))
need=[(0,0)]*(N+1)
now=0
for i in range(N-1):
    now+=T[i]
    need[i+1]=(now,min(V[i],V[i+1]))
need[N]=(now+T[N-1],0)
TN=need[N][0]
res=[float('inf')]*(TN+1)
for i in range(TN+1):
    for j in range(N+1):
        if j>0:
            if need[j-1][0]<=i<=need[j][0]:
                res[i]=min(res[i],V[j-1])
        res[i]=min(res[i],need[j][1]+abs(need[j][0]-i))
ans=0
for i in range(TN):
    if abs(res[i]-res[i+1])==1:
        ans+=0.5*(res[i]+res[i+1])
    else:
        for j in range(N):
            if need[j][0]<=i and i+1<=need[j+1][0]:
                vv=V[j]
                break
        if vv>res[i]:
            ans+=res[i]+0.25
        else:
            ans+=res[i]
print(ans)

Measured memory_bytes: 3316
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		if (arr.length == 2 && arr[0] == arr[1]) {
		    System.out.println("1 2");
		    return;
		}
		for (int i = 0; i < arr.length - 2; i++) {
		    if (arr[i] == arr[i + 1] || arr[i] == arr[i + 2] || arr[i + 1] == arr[i + 2]) {
		        System.out.println((i + 1) + " " + (i + 3));
		        return;
		    }
		}
		System.out.println("-1 -1");
   }
}




Measured memory_bytes: 25464
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <deque>
#include <vector>
#include <queue>
#include <math.h>
#include <map>
#include <stack>
#include <set>
#include <unordered_map>
 
#define gg exit(0)
#define pb push_back
#define mp make_pair
#define sz size
#define skip continue
#define fi first
#define se second
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int lli;
typedef long double ld;
typedef long long ll; 

 
const int N = 3e5+10;
const ll maxn = 1e9+7;


int main() {

	int k, a, b;
	cin >> k >> a >> b;
	if (a > b)
		swap(a, b);
	while (a <= b) {
		if (a%k==0)
			cout << "OK",gg;
		++a;
	}
	cout << "NG";

	return 0;
}





Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#include<list>
#include<map>

using namespace std;

int N, M;
int S, T;
int ans=-1;
int d[3][100001];

map<int, list<int>> e;
list<pair<int, int>> queue;

int f(int q, int steps, int count) {
  for (auto i = e[q].begin(); i != e[q].end(); ++i) {
    if (steps == 0 && d[1][*i] < 0) {
      d[1][*i] = 1;
      f(*i, 1, count);
    } else if (steps == 1 && d[2][*i] < 0) {
      d[2][*i] = 1;
      f(*i, 2, count);
    } else if (steps == 2) {
      if (d[0][*i] < 0) {
        queue.push_back(make_pair(*i, count+1));
        d[0][*i] = count+1;
      }
    }
  }
}

int main(){
  scanf("%d %d", &N, &M);
  for (int i=0; i<N; i++)
    for (int j=0; j<3; j++)d[j][i] = -1;
  for (int i=0;i<M;i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    e[u-1].push_back(v-1);
  }
  scanf("%d %d", &S, &T);
  S--, T--;

  queue.push_back(make_pair(S, 0));
  d[0][S]=0;

  for (auto itr = queue.begin(); itr != queue.end(); itr++) {
    if (d[0][T]!=-1) break;
    f(itr->first, 0, itr->second);
  }
  cout << d[0][T] << endl;
  return 0;
}


Measured memory_bytes: 13952
#include <cstdio>

bool solve(int *A, int m, int i, int n){
	if(m==0){
		return true;
	}
	else{
		if(i==n){
			return false;
		}
		else{
			return (solve(A, m, i+1, n) || solve(A, m-A[i], i+1, n));
		}
	}
}


int main(){

	int n,q,i,m;
	int *A;

	std::scanf("%d", &n);
	A = new int[n];
	for(i=0;i<n;i++){
		std::scanf("%d", &A[i]);
	}
	
	std::scanf("%d", &q);
	for(i=0;i<q;i++){
		std::scanf("%d", &m);
		if(solve(A, m, 0, n)){
			std::printf("yes\n");
		}
		else{
			std::printf("no\n");
		}
	}

	delete[] A;
	return 0;
}

Measured memory_bytes: 2600
package main

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

var scanner = bufio.NewScanner(os.Stdin)
const INF = 1<<31

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	arr := make([][]int, n)
	for i := range arr {
		arr[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			arr[i][j] = INF
		}
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		buf := strings.Split(scanner.Text(), " ")
		input := make([]int, len(buf))
		for j := range input {
			input[j], _ = strconv.Atoi(buf[j])
		}
		x, k := input[0]-1, input[1]
		for j := 0; j < k; j++ {
			y := input[j+2]-1
			arr[x][y] = 1
		}
	}
	for k := 0; k < n; k++ {
		arr[k][k] = 0
		for i := 0; i < n; i++ {
			if arr[i][k] >= INF {
				continue
			}
			for j := 0; j < n; j++ {
				if arr[k][j] >= INF {
					continue
				}
				arr[i][j] = min(arr[i][j], arr[i][k]+arr[k][j])
			}
		}
	}
	scanner.Scan()
	p, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < p; i++ {
		scanner.Scan()
		buf := strings.Split(scanner.Text(), " ")
		input := make([]int, len(buf))
		for j := range input {
			input[j], _ = strconv.Atoi(buf[j])
		}
		s, d, v := input[0]-1, input[1]-1, input[2]
		if arr[s][d] < v {
			fmt.Println(arr[s][d]+1)
		} else {
			fmt.Println("NA")
		}
	}
}

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


Measured memory_bytes: 1296
//%std
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
const int N = 300003, mod = 1e9 + 7;
void upd (int&a, int b) { a = (a + b) % mod; }
char s[N];
int n, dp[N][3][3];
int main ()
{
	// freopen ("x.in", "r", stdin);
	scanf("%s", s + 1);
	n = strlen(s + 1);
	dp[0][0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < 3; ++j) {//1
			for (int k = 0; k < 3; ++k) {//0
				if (s[i] != '0') {
					if (!k) upd (dp[i][min (j + 1, 2)][k], dp[i - 1][j][k]);
					else upd (dp[i][j][k - 1], dp[i - 1][j][k]);
				}
				if (s[i] != '1') {
					if (k == 2) upd (dp[i][j][1], dp[i - 1][j][k]);
					else upd (dp[i][j][k + 1], dp[i - 1][j][k]);
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 3; ++i) for (int j = 0; j <= i; ++j) upd (ans, dp[n][i][j]);
	printf ("%d\n", ans);
	// printf ("%d\n", dp[5][0][1]);
	return 0;
}

Measured memory_bytes: 11136
import bisect
n = int(input())
a = [int(input()) for _ in range(n)]

dp = [float('inf')]*n
for i in range(n):
    x = bisect.bisect_right(dp,-a[i])
    dp[x] = -a[i]
c = dp.count(float('inf'))
print(n-c)

Measured memory_bytes: 54872
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define WHITE 0
#define BLACK 1
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
string s;
int k;
int INFi=1000000000;
ll INFl=1000000000000000;

struct UnionFind{
    vector<int> par;//初期化
    vector<int> rank;//高さ
    UnionFind(int n=0):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);//経路圧縮
    }
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        if(rank[rx]<rank[ry]) rank[rx]=ry;
        else rank[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
struct edge{int from,to,cost;};
vector<edge> es(100); //辺の集合
vector<int> d(100,INFi);//最短距離
int V,E;//頂点数、辺数

int main(){
    int n;cin>>n;
    string s;cin>>s;
    for(int i=0;i<s.size();i++){
        if(char(s[i]+n)<='Z') s[i]=char(s[i]+n);
        else s[i]=char('A'+s[i]+n-1-'Z');
    }
    cout<<s<<endl;
}





Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007 
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int n;
int a[21][21];
int b[22];
vector<vector<ll>> dp(22,vector <ll> (2100000,-1ll));
ll solve(int i,int val){
    if(dp[i][val]!=-1ll)
        return dp[i][val];
    dp[i][val]=0ll;
    for(int j=0;j<n;j++){
        int val1=(b[j]|val);
        if(a[i][j]==1&&val1!=val)
            dp[i][val]+=solve(i+1,val1);
    }
    dp[i][val]%=MOD;
    return dp[i][val];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        cin>>n;
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                cin>>a[i][j];
        b[0]=1ll;
        for(int i=1;i<=21;i++)
            b[i]=b[i-1]*2;
        int val=(1<<(n))-1;
        dp[n][val]=1ll;
        cout<<solve(0,0);
    }
    return 0;
}

Measured memory_bytes: 377600
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5+4;
const int mod = 1e9+7;
int cnt[30];
int n;
string s;

signed main()
{
	cin>>n;
	cin>>s;

	for(int i=0;i<s.length();i++)
	{
		cnt[s[i]-'a']++;
	}
//	cout<<cnt[1];
	int ans = 1;
	for(int i=0;i<26;i++)
	{
		ans = (ans * (cnt[i] + 1) ) % mod;
	}
	cout<<(ans + mod-1) % mod;
}

Measured memory_bytes: 512
let count = ref 0

let loop k s =
  for x = 0 to k do
    for y = 0 to k do
      let z = s - x - y in
      if 0 <= z && z <= k then incr count
    done
  done

let () =
  Scanf.scanf "%d %d" loop ;
  Printf.printf "%d\n" !count


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<bool> primes(1005, true);
  primes[0] = primes[1] = false;
  for (int i = 2; i * i <= 1000; ++i) {
    if (not primes[i]) { continue; }
    for (int j = i * i; j <= 1000; j += i) {
      primes[j] = false;
    }
  }

  vector<int> factors(N + 1, 0);
  for (int i = 2; i <= N; ++i) {
    for (int j = 2; j <= N; ++j) {
      if (not primes[j]) { continue; }
      int cnt = 0, val = i;
      while (val > 1 and val % j == 0) {
        val /= j;
        ++cnt;
      }
      factors[j] += cnt;
    }
  }
  ll ans = 1;
  for (int i = 2; i <= N; ++i) {
    if (not primes[i]) { continue; }
    ans = (ans * (factors[i] + 1)) % MOD;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
int main() {
	int n; cin >> n;
	call(n);
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
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; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    string s, t; cin >> s >> t;
    rep(i, s.length()){
        if(s[i] != t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	string S; cin >> S;

	int ans = 0;
	FOR(i,1,N){
		map<char, int> left;
		map<char, int> right;
		string l = S.substr(0, i);
		string r = S.substr(i, N-i);

		REP(j,l.length()){
			left[l[j]]++;
		}
		REP(j,r.length()){
			right[r[j]]++;
		}

		int tmp = 0;
		for(char s = 'a'; s <= 'z'; ++s){
			if(left[s] > 0 and right[s] > 0) tmp++;
		}
		ans = max(ans, tmp);
	}

	cout << ans << endl;



	return 0;

}


Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}
/**
  * AOJ
  */

object Main {

  def main(args: Array[String]): Unit = {

    val dice = readLine().split(" ").map(_.toInt)
    val q =readInt()
    for(_ <- 1 to q){
      val sides = readLine().split(" ").map(_.toInt)
      println(findSouth(sides(1),findUp(sides(0),dice))(3))
    }
  }

  def findUp(up:Int,dice:Array[Int]) : Array[Int] = {
    if(dice(0) == up){return dice}
    var d = dice
    for(c <- "WNNNW".toCharArray){
      d = getNextStatus(c,d)
      if(d(0) == up){return d}
    }
    throw new Exception()
  }

  def findSouth(south:Int, dice:Array[Int]) : Array[Int] = {
    if(dice(4) == south){return dice}
    var d = dice
    for(c <- "HHH".toCharArray){
      d = getNextStatus(c,d)
      if(d(4) == south){return d}
    }
    throw new Exception()
  }

  def getNextStatus(cmd:Char,dice:Array[Int]): Array[Int] = cmd
    match {
      case 'N' => Array(dice(1),dice(5),dice(2),dice(3),dice(0),dice(4))
      case 'W' => Array(dice(2),dice(1),dice(5),dice(0),dice(4),dice(3))
      case 'H' => Array(dice(0),dice(3),dice(1),dice(4),dice(2),dice(5))
    }
}

Measured memory_bytes: 43960
n = int(input())
l = list(map(int, input().split()))
a = 1
for i in range(n):
  if l[i] == 0:
    a = 0
if a != 0:
  for i in range(n):
    a *= l[i]
    if a > 1000000000000000000:
      a = -1
      break
print(a)

Measured memory_bytes: 21584
#include <iostream>

using namespace std;

int main(){
  int n, d, x;
  cin >> n >> d >> x;
  int sum=x;
  
  for (int i=0; i<n; i++) {
    int a;
    cin >> a;
    if (d%a==0) sum+=d/a;
    else sum+=d/a+1;
  }

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

Measured memory_bytes: 256
import math

#N行,距離D
N,D = map(int, input().split())

num_list = []
for i in range(N):
    num_list.append(list(map(int,input().split())))

count = 0
for p,q in num_list:
  d = math.sqrt(p**2 + q**2)
  #print(d)
  if(d<=D):
    count += 1
    
print(int(count))

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a.at(i).at(j);
    }
  }
  vector<bool> gyou(h,false);
  vector<bool> retsu(w,false);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a.at(i).at(j)=='#'){
        gyou.at(i)=true;
        retsu.at(j)=true;
      }
    }
  }
  for(int i=0;i<h;i++){
    if(gyou.at(i)==true){
      for(int j=0;j<w;j++){
        if(retsu.at(j)==true){
          cout << a.at(i).at(j);
        }
      }
       cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
//#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    if(k % 2 == 1)
    {
        ll cnt = n / k;
        cout << cnt * cnt * cnt;
    }
    else
    {
        ll cnto = n / (k / 2) - (n / (k / 2)) / 2;
        ll cnte = (n / (k / 2)) / 2;
        cout << cnto * cnto * cnto + cnte * cnte * cnte;
    }

    return 0;
}


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

string s;
int p,flag;

bool check(P A){
  if(abs(A.real()) > N || abs(A.imag()) > N) return false;
  return true;
}

P bnf();

P get_num(){

  if(s[p]=='('){
    
    p++;
    
    P r=bnf();
    
    p++;

    return r;
  }

  if(s[p]=='i'){
    p++;
    return P(0,1);
  }
  
  ll num=0;

  while('0'<=s[p]&&s[p]<='9'){
    num=num*10+s[p]-'0';
    p++;
    if(!check(P(num,0))) flag=1;
  }
  
  return P(num,0);
}

P bnf2(){
  
  P res=get_num();
  
  while(p<s.size()&&!flag){
    
    if(s[p]=='*'){
      
      p++;
      
      P r=get_num();
      
      res*=r;

      if(!check(res)) flag=1;
      
    }else break;
    
  }
  
  return res; 
}

P bnf(){

  P res=bnf2();

  while(p<s.size()&&!flag){

    if(s[p]=='+'){

      p++;

      P r=bnf2();
      
      res+=r;
      
      if(!check(res)) flag=1;
      
    }
    else if(s[p]=='-'){

      p++;
      
      P r=bnf2();
      
      res-=r;

      if(!check(res)) flag=1;
      
    }else break;
    
  }
  
  return res;
}


int main(){

  while(cin>>s){

    p=0;
    
    flag=0;

    P ans=bnf();
    
    if(flag) cout<<"overflow"<<endl;
    else{
      
      ll A=ans.real(),B=ans.imag();

      if(A&&B){

	cout<<A;

	if(B>0) cout<<'+';

	cout<<B<<"i"<<endl;
      }

      if(!A&&B)	cout<<B<<"i"<<endl;

      if(A&&!B) cout<<A<<endl;

      if(!A&&!B) cout<<0<<endl;
      
    }

  }

  return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define F first
#define S second
  
#define ler freopen("inspection.in","r",stdin);freopen("inspection.out","w",stdout)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define sz(a) ((int)(a).size())
#define debug cout<<"ACM ICPC\n"
  
#define pdd pair<ld,ld> 
#define ll long long
#define ld long long
#define vi vector<int> 
#define pii pair<int,int>  

#define MAXN 400106
#define LOG 21
#define EPS 1e-8
#define INF 1e15L
#define LOGN 20

ll n, a;

int main(){
	cin >> n >> a;
	
	if(n%500 > a) cout << "No\n";
	else cout << "Yes\n";
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	for(;;){
	int H,W,i,l;
	cin >> H >> W;
		if(H==0 && W==0)break;
			for(i=0; i<H; i++){
				for(l=0; l<W; l++){
					cout  << "#";
				}
			cout << endl;
			}
		cout << endl;	
	}	
}

Measured memory_bytes: 3128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int n;int h;
int a[10000000];
void jiaohuan(int k)
{
    int l=k*2,r=k*2+1;
    int maxn;
    if(l<=h&&a[l]>a[k]){
        maxn=l;
    }else {
        maxn=k;
    }
    if(r<=h&&a[maxn]<a[r]){
        maxn=r;
    }
    if(maxn!=k){
        swap(a[k],a[maxn]);
        jiaohuan(maxn);
    }
    return;
}
void minsert(int k)
{
    h++;
    a[h]=k;
    int i=h;
    while(i>1&&a[i]>a[i/2]){
        swap(a[i],a[i/2]);
        i/=2;
    }
}
int shanchu()
{
    int maxv;
    maxv=a[1];
    a[1]=a[h--];
    jiaohuan(1);
    return maxv;
}
int main()
{
    char b[20];
    while(scanf("%s",b)!=EOF)
    {
        if(b[0]=='i'){
            scanf("%d",&n);
            minsert(n);
        }
        else if(b[0]=='e'&&b[1]=='x'){
           printf("%d\n",shanchu());
        }
        else if(b[0]=='e'&&b[1]=='n') return 0;
    }
    return 0;
}

Measured memory_bytes: 7032
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/range/numeric.hpp>

#ifdef _MSC_FULL_VER
#include"randomizer.hpp"
#include"debug_print.hpp"
#endif

#include<cstdlib>
#include<ctime>

namespace lib
{
	template<class T>using pair = std::pair<T, T>;
	template<class T>constexpr T pow(T base, std::uint64_t p)
	{
		T ret = T(1);
		for (std::uint64_t i = 0; i <= 63; ++i)
		{
			if (((1ull << i) & p) != 0)
			{
				ret *= base;
			}
			base *= base;
		}
		return ret;
	}
	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

	struct union_find
	{
		std::vector<int> upper;
		union_find(std::size_t size):upper(size, -1) {}

		int group(int index)
		{
			if (upper[index] == -1)
			{
				return index;
			}
			else
			{
				return upper[index] = group(upper[index]);
			}
		}

		bool merge(int x, int y)
		{
			auto gx = group(x);
			auto gy = group(y);
			if (gx != gy)
			{
				upper[gx] = gy;
				return true;
			}
			return false;
		}

		auto get()
		{
			std::map<int, std::set<int>> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret[group(i)].emplace(i);
			}
			return ret;
		}

		auto tops()
		{
			std::set<int> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret.emplace(group(i));
			}
			return ret;
		}

		bool is_same_group(int x, int y)
		{
			return group(x) == group(y);
		}
	};
}

namespace out
{
	namespace detail
	{
		template<class>struct void_out
		{
			typedef void type;
		};
		template<class T>auto write(std::ostream& ost, T const& val)
			->typename void_out<decltype(ost << val)>::type
		{
			ost << val;
		}
		template<class T, class... Ts>void write(std::ostream& ost, T const& val, Ts const&... nexts)
		{
			write(ost, val);
			ost << " ";
			write(ost, nexts...);
		}
	}
	void write_line()
	{
		std::cout << std::endl;
	}
	template<class...Ts>void write_line(Ts const&... args)
	{
		detail::write(std::cout, args...);
		write_line();
	}
	template<class Range>void write_range(Range const& rng)
	{
		for (auto const& v : rng)
		{
			write_line(v);
		}
	}
}

namespace adaptor = boost::adaptors;

void Main()
{
	std::string str;
	std::cin >> str;
	int N = str.size();
	std::vector<std::int64_t> sum(N);
	std::vector<int> target;
	std::int64_t s{};
	for (int i : boost::irange(0, N))
	{
		if (str[N - i - 1] == 'B')
		{
			target.emplace_back(i);
		}
		else
		{
			++s;
		}
		sum[i] = s;
	}
	std::int64_t result{};
	for (auto v : target)
	{
		result += sum[v];
	}
	out::write_line(result);
}

int main()
{
	std::cin.tie(nullptr);
	std::cin.sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(5);
	Main();
}


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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int n, k; cin >> n >> k;
    ll ans = 0;
    for (int b = k+1; b <= n; b++) {
        int m1 = (n - k) / b;
        int m2 = (n - b + 1) / b;
        if (m1 == m2) ans += (m1 + 1) * (b - k) - (k == 0);
        else ans += (m2 + 1) * (b - k) + (n - (k + m1 * b) + 1) - (k == 0);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

class UnionFind {
public:
  UnionFind(int n) : tree(vector<ll>(n, -1)) {}

  // 木の頂点を探す
  int find(int x) {
    if (tree[x] < 0)
      return x;
    return tree[x] = find(tree[x]);
  }

  // 長さを返す
  ll length(int x) {
    if (tree[x] < 0)
      return abs(tree[x]);
    return length(tree[x]);
  }

  // 同じグループか
  bool same(int x, int y) { return find(x) == find(y); }

  // 点xを含む木と点yを含む木の融合
  // 既に同じ木だったらfalseを返す
  bool unite(int x, int y) {
    int r1 = find(x);
    int r2 = find(y);
    if (r1 == r2)
      return false;
    // 大きい方に小さい方をくっつけたほうがコストが低い
    if (abs(r1) < abs(r2))
      swap(r1, r2);
    tree[r1] += tree[r2];
    tree[r2] = r1;
    return true;
  }

private:
  vector<ll> tree;
};

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

  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }

  ll ans = 0;
  vector<bool> visit(n + 1, false);
  for (int i = 0; i < n; i++) {
    int root = uf.find(i);
    if (visit[root])
      continue;
    visit[root] = true;
    ans = max(ans, uf.length(root));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11112
#include <stdio.h>
#define M 101
#define t (1<<28);

int n;
int G[M][M];

int main() {
  int i, j, k;
  int id, v, c;
  int tmp;
  for(i=0; i<M; i++) {
    for(j=0; j<M;j++) {
      if( i== j)G[i][j]=0;
      else G[i][j]=t;
    }
  }
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d %d",&id,&k);
    while(1) {
      if(k==0)break;
      scanf("%d %d", &v, &c);
      G[id][v] = c;
      k--;
    }
  }

  for(k=0; k<n; k++) {
    for(i=0; i<n; i++) {
      for(j = 0; j < n; ++j) {
        tmp = G[i][k] + G[k][j];
        if(tmp < G[i][j]) G[i][j] = tmp;
      }
    }
  }

  for(i = 0; i < n; ++i) {
    printf("%d %d\n", i, G[0][i]);
  }

  return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int K,X,Y;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>K>>X>>Y;
	if(K%2==0 && (abs(X)+abs(Y))%2) {
		cout<<"-1"<<endl;
		return;
	}
	vector<pair<int,int>> V;
	if(K%2&&(abs(X)+abs(Y))%2) {
		V.push_back({X,Y});
		if(X==0) {
			if(Y>0) Y-=K;
			else Y+=K;
		}
		else if(Y==0) {
			if(X>0) X-=K;
			else X+=K;
		}
		else {
			x=min(K,abs(X));
			if(X>0) X-=x;
			else X+=x;
			int lef=K-x;
			if(Y>0) Y-=lef;
			else Y+=lef;
		}
	}
	
	if(K%2==0) {
		while(abs(X)+abs(Y)>=2*K) {
			V.push_back({X,Y});
			int lef=K;
			if(X>0) {
				i=min(X,lef);
				X-=i;
				lef-=i;
			}
			else if(X<0) {
				i=min(abs(X),lef);
				X+=i;
				lef-=i;
			}
			if(Y>0) {
				i=min(abs(Y),lef);
				Y-=i;
				lef-=i;
			}
			else if(Y<0) {
				i=min(abs(Y),lef);
				Y+=i;
				lef-=i;
			}
		}
	}
	else {
		while(abs(X)+abs(Y)>=2*K) {
			FOR(j,2) {
				V.push_back({X,Y});
				int lef=K;
				if(X>0) {
					i=min(X,lef);
					X-=i;
					lef-=i;
				}
				else if(X<0) {
					i=min(abs(X),lef);
					X+=i;
					lef-=i;
				}
				if(Y>0) {
					i=min(abs(Y),lef);
					Y-=i;
					lef-=i;
				}
				else if(Y<0) {
					i=min(abs(Y),lef);
					Y+=i;
					lef-=i;
				}
			}
		}
	}
	if(X==0 && Y==0) {
		;
	}
	else if(abs(X)+abs(Y)==K) {
		V.push_back({X,Y});
	}
	else {
		V.push_back({X,Y});
		if(abs(X)>abs(Y)) {
			x=(abs(X)+abs(Y))/2;
			y=K-abs(x);
			
			if(X>0) X=x;
			else X=-x;
			if(Y>=0) Y=-y;
			else Y=y;
		}
		else {
			y=(abs(X)+abs(Y))/2;
			x=K-abs(y);
			
			if(Y>0) Y=y;
			else Y=-y;
			if(X>=0) X=-x;
			else X=x;
		}
		V.push_back({X,Y});
	}
	
	reverse(ALL(V));
	x=y=0;
	FORR(v,V) {
		assert(abs(x-v.first)+abs(y-v.second)==K);
		x=v.first;
		y=v.second;
	}
	cout<<V.size()<<endl;
	FORR(v,V) cout<<v.first<<" "<<v.second<<endl;
}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3952
N = int(input())
# N = 4
stones = list(input())
# stones = ['W','R','R','R']
if not ('R' in stones and 'W' in stones):
    print('0')
    exit()
right = 0
left = N - 1
white_idx = -1
red_idx = -1
ans = 0
while right < left:
    while right < N and right < left:
        if stones[right] == 'W':
            white_idx = right
            break
        right += 1
    while 0 < left and right < left:
        if stones[left] == 'R':
            red_idx = left
            break
        left -= 1
    if left == right:
        break
    if 0 <= white_idx and 0 <= red_idx:
        ans += 1
    right += 1
    left -= 1
print(ans)

Measured memory_bytes: 10652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	long N = rel();
	long ans = 0;
	for(long x = 1;x <= min(1000000LL,N-1);x++){
		long bf = x+1;
		long bl = N;
		while(bf != bl){
			long bc = (bf+bl)/2;
			if(N <= bc*x+x){
				bl = bc;
			}
			else{
				bf = bc+1;
			}
		}
		if(N == bf*x+x){
			ans += bf;
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    int n, arr[105];
    ll ans = 1e18;
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    for(int i = 0; i < 1000; i++)
    {
        ll tot = 0;
        for(int j = 0; j < n; j++)
            tot += ((arr[j] - i)*(arr[j] - i));
        ans = min(ans, tot);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
c=list(map(int,input().split()))
c.sort()
connection=[[] for i in range(n)]
ans=[0 for i in range(n)]
for i in range(n-1):
  connection[l[i][0]-1].append(l[i][1]-1)
  connection[l[i][1]-1].append(l[i][0]-1)
next=[0]
next=deque(next)
check=[-1 for i in range(n)]
check[0]=1
ct=n
while ct>0:
  ct-=1
  x=next.popleft()
  ans[x]=str(c[ct])
  for i in range(len(connection[x])):
    if check[connection[x][i]]==-1:
      next.append(connection[x][i])
      check[connection[x][i]]=1
print(sum(c)-c[n-1])
print(' '.join(ans))

Measured memory_bytes: 8532
// https://atcoder.jp/contests/abc125/tasks/abc125_a

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;

    return 0;
}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    int n, k;
    cin >> n >> k;
    vector<bool> check;
    rep(i, n){
        check.push_back(false);
    }
    rep(i, k){
        int d;
        cin >> d;
        rep(j, d){
            int a;
            cin >> a;
            check[a-1] = true;
        }
    }
    //cout << "OK";
    int cnt = 0;
    rep(i, n){
        if(!check[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
//#include <boost/algorithm/string.hpp>
using namespace std;


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}


#define Vec(a) vector<a>

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define Filein(N) freopen("N", "r", stdin);
#define Fileout(N) freopen("N", "w", stdout);

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define en "\n"
#define sp " "
#define eps 1.0E-14
#define l length()
#define preci(x) cout << fixed<<setprecision(x)
#define inf LONG_LONG_MAX
#define ninf LONG_LONG_MIN


void odd(int n)
    {
    bool b=1;
        int x = sqrt(n);
    for (int i=2 ; i<=x ; ++i)

    {
        if(n%i == 0) {cout << "NO" << sp; b = 0;  break;}
    }
    if (b)
    cout << "Yes" << sp;
    b=1;
    }
ll fact(int n ){

long long fact =1;

for (int i =2 ;i<=n;++i)

{
    fact*=i;
}
return fact;
}


ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main()
{
    init();

    string s , m ; cin>>s>>m;

    if (s+m[m.size() -1] == m ) cout << "Yes";
    else cout << "No";
}



Measured memory_bytes: 3624
import sys
import math

N = int(input())
M = 10 ** 9 + 7

factor = {}

for n in range(2, N + 1):
    p = 2
    root_n = math.sqrt(n)

    while n > 1 and p <= root_n:
        if n % p == 0:
            if p not in factor:
                factor[p] = 0

            while n % p == 0:
                n //= p
                factor[p] += 1

        p += 1

    if n > 1:
        if n not in factor:
            factor[n] = 1
        else:
            factor[n] += 1

# print(factor)

ans = 1

for v in factor.values():
    ans *= (v + 1)

ans %= M

print(ans)

Measured memory_bytes: 3064
//
// Created by yamunaku on 2019/09/15.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.util.Arrays;

public class Main{
        
    public static void main(String[] args)throws IOException{
	br = new BufferedReader(new InputStreamReader(System.in));
	PrintWriter out = new PrintWriter(System.out);
	int n = nextInt();
	int v[] = new int[n];
        for(int  i = 0; i<n;i++){
	    v[i] = nextInt();
        }
	int ans = 0,r = 0;
	int c = 0;
	for(int i=1;i<n;i++){
	    if(v[i]<=v[i-1]){
		ans++;
            }else{
		r = ans>r?ans:r;
		ans = 0;
	    }
	    
	}
	out.println(r>ans?r:ans);
	out.close();
    }
    
    static BufferedReader br;
    static StringTokenizer st = new StringTokenizer("");
    static String next()throws IOException{
	while(!st.hasMoreTokens()){
	    st = new StringTokenizer(br.readLine());
	}
	return st.nextToken();
    }
    static int nextInt()throws IOException{
	return Integer.parseInt(next());
    }
    static long nextLong()throws IOException{
	return Long.parseLong(next());
    }
}

Measured memory_bytes: 39636
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

signed main() {
	ll n, m, b, c;

	cin >> n >> m;

	vector<ll> v(n, 0);
	vector<pair<ll, ll>> vv;

	REP(i, n) {
		cin >> v[i];
	}

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

	REP(i, m) {
		cin >> b >> c;
		vv.push_back(make_pair(c, b));
	}

	sort(vv.begin(), vv.end(), greater<pair<ll, ll>>());

	ll now = 0;
	ll cnt;

	REP(i, m) {
		cnt = 0;
		REP(j, vv[i].second) {
			if (now + j < n && vv[i].first > v[now + j]) {
				v[now + j] = vv[i].first;
				cnt++;
			}
			else {
				break;
			}
		}
		now += cnt;
	}

	ll ans = 0;

	REP(i, n) {
		ans += v[i];
	}

	cout << ans << endl;
}

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		int[] v = new int[n];
		int[] c = new int[n];
		int[] k = new int[n];
		
		string[] inputs = Console.ReadLine().Split(' ');
		for(int i = 0; i < n; i++)
		{
			v[i] = int.Parse(inputs[i]);
		}
		inputs = Console.ReadLine().Split(' ');
		for(int i = 0; i < n; i++)
		{
			c[i] = int.Parse(inputs[i]);
			k[i] = v[i]-c[i];
		}
		Array.Sort(k);
		int r = 0;
		for(int i = 0; i < n; i++)
		{
			if(k[i]<=0) continue;
			r+=k[i];
		}
		Console.WriteLine(r);
	}

	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}


}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define F first
#define S second

typedef long long ll;
const ll MOD = 1e9+7;
const int inf = 1000000;
const int minf = -1000000;
const ll lnf = 1e12;
const ll mlnf = -1e12;


void debug_vector(vector<int>& v){
    int n = v.size();
    for (int i = 0; i < n; i++){
        cout << v[i] << " ";
    }
    cout << endl;
}

void solve();

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

void solve(){
    // 入力
    int N, M;
    cin >> N >> M;
    vector<vector<int>> switches(N);
    for (int i = 0; i < N; i++){
        int k; cin >> k;
        vector<int> tmp(k+1);
        tmp[0] = k;
        for (int j = 0; j < k; ++j){
            cin >> tmp[j+1];
        }
        switches[i] = tmp;
    }
    vector<int> P(M);
    rep(i, M) cin >> P[i];

    // bit 全探索でスイッチの状態を決め，その状態で電球が全てつくか確認する
    int ans = 0;
    for (int bit = 0; bit < (1 << N); ++bit){
        // 変数の準備
        vector<bool> onoff(N, false);   // スイッチの状態
        bool flag = true;   // 全ての電球がついてるかチェックする

        // スイッチの状態を調べる
        for (int i = 0; i < N; i++){
            if ((bit >> i) & 1) onoff[i] = true;
        }

        // それぞれの電球について，スイッチがonになってる個数を調べる
        for (int i = 0; i < M; i++){
            int oncount = 0;
            for (int j = 0; j < switches[i][0]; j++){
                if (onoff[switches[i][j+1]-1]) oncount++;
            }
            if (oncount%2 == P[i]){
                continue;
            }else{
                flag = false;
                break;
            }
        }
        if (flag) ans++;
    }
    
    printf("%d\n", ans);

}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static long mod = 1000000007;
        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = NK[0];
            var K = NK[1];
            //var S = Console.ReadLine();

            long ans = 0L;
            for (long i = K; i <= N+1; i++)
            {
                var min = i * (i - 1) / 2;
                var max = i * (2 * N - i + 1) / 2;
                //max %= mod;
                //min %= mod;
                //ans += (max - min + 1);
                var add = max - min+1;
                add %= mod;
                ans += add;
                ans %= mod;
            }

            

            Console.WriteLine(ans);
            
        }
    }


}


Measured memory_bytes: 28216
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

#print(h)
l = [0]*n

for i in range(n):
	l[i] = abs((t-h[i]*0.006)-a)

#最小値のインデックスを出力
#print(l.index(min(l)))

print(l.index(min(l))+1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int main() {
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        vector<int> s(n);
        rep(i, n) cin >> s.at(i);
        double m = 0;
        rep(i, n) m += s.at(i) ;
        m /= n;
        double a = 0;
        rep(i, n) a += ((s.at(i) - m)*(s.at(i) - m)) / n;
        cout << fixed;
        cout << setprecision(10) << sqrt(a) << endl;
    }
}


Measured memory_bytes: 3268
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int K = sc.nextInt();
    int S = sc.nextInt();

    sc.close();

    int count = 0;

    for (int i = 0; i <= K; i++) {
      for (int j = 0; j <= K; j++) {
        if ((S - i - j) <= K && 0 <= (S - i - j)) {
          count ++;
        }
      } 
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 22612