akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

alias X = Tuple!(int, "i", long, "b");

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);
    auto BS = readln.split.to!(long[]);

    X[] xs;
    foreach (i; 0..N) xs ~= X(i, BS[i]);
    auto Q = heapify!"a.b < b.b"(xs);

    long res;
    auto prev = X(-1, -1);
    while (!Q.empty) {
        auto h = Q.front;
        Q.removeFront();

        if (h == prev) {
            writeln(-1);
            return;
        }
        prev = h;

        with (h) {
            auto a = BS[(i+N-1)%N];
            auto c = BS[(i+1)%N];
            auto n = b - AS[i];
            if (n == 0) continue;
            res += n/(a+c);
            b = AS[i] + n%(a+c);
            BS[i] = b;
            h.b = b;
            if (b != 0) Q.insert(h);
        }
    }
    foreach (i; 0..N) if (AS[i] != BS[i]) {
        writeln(-1);
        return;
    }
    writeln(res);
}

Measured memory_bytes: 22136
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,i,k,t=0;
	int max=0;
	scanf("%d",&n);
	if(n<2)
		printf("1");
	else if(n>=2&&n<4)
		printf("2");
	else if(n>=4&&n<8)
		printf("4");
	else if(n>=8&&n<16)
		printf("8");
	else if(n>=16&&n<32)
		printf("16");
	else if(n>=32&&n<64)
		printf("32");
	else if(n>=64)
		printf("64");
		

	return 0;
}
			



Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
static const int MAXn = 100;
static const int MAXw = 11000;

struct item{
    int v;
    int w;
};

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

    item I[MAXn];
    for (int i = 0; i < n; i++){
        cin >> I[i].v >> I[i].w;
    }

    int dp[MAXw];
    for (int i = 1; i <= w; i++){
        for (int j = 0; j < n; j++){
            if (i - I[j].w >= 0 && i -I[j].w <= MAXw){
                dp[i] = max(dp[i], dp[i - 1]);
                dp[i] = max(dp[i], dp[i - I[j].w] + I[j].v);
            }else dp[i] = max(dp[i], dp[i - 1]);
        }
    }
    cout << dp[w] << endl;
    return 0;
}


Measured memory_bytes: 3132
#include <iostream>

using namespace std;

int main() {

	string S, T;
	cin >> S >> T;

	for (int i = 0; i < S.size(); ++i)
	{
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef int32_t i32;
typedef uint32_t u32;
typedef int64_t i64;
typedef uint64_t u64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int MAX_N = 100000;
int n;
int a[MAX_N];

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];

  int min_a = *min_element(a, a+n);
  int max_a = *max_element(a, a+n);

  if (max_a - min_a > 1) {
    cout << "No" << endl;
  } else if (max_a - min_a == 0) {
    if (all_of(a,a+n,[](int x) { return 2*x <= n; } ))
      cout << "Yes" << endl;
    else if (all_of(a,a+n,[](int x) { return x == n-1; }))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  } else {
    int alone = 0, not_alone = 0;
    for (int i = 0; i < n; i++)
      if (a[i] == max_a-1) alone++;
      else not_alone++;
    if (alone < max_a && 2*(max_a-alone) <= not_alone)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	as := intSliceScanner(n)
	ans := as[0] / 2
	as[0] %= 2
	for i := 1; i < n; i++ {
		ans += (as[i] + as[i-1]) / 2
		if (as[i]+as[i-1])%2 != 0 && as[i] > 0 {
			as[i] = 1
		} else {
			as[i] = 0
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int n, u, v;
vector<Int> edge[1080000];
Int a[1080000];
Int ans[1080000];
Int p;
void dfs(Int x, Int last = -1){
    ans[x] = a[p--];
    for(auto to:edge[x]){
        if(to == last)continue;
        dfs(to, x);
    }
}


int main(){
    cin >> n;
    for(int i = 0;i < n-1;i++){
        cin >> u >> v;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    for(int i = 0;i < n;i++)cin >> a[i];
    p = n-1;
    sort(a, a + n);
    dfs(1);
    Int res = 0;
    for(int i = 0;i < n-1;i++)res += a[i];
    cout << res << endl;
    for(int i = 1;i <= n;i++)cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 29056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define repn(a,b,c) for(int a=b; a>=c; a--)
#define ll long long
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))
#define loop(a,b,c) for(int  a=b ; a<c ; a++)
#define first fi
#define second se
#define INF (int)1e5


ll dp[100005];
ll a[100005];

int main(){

    mem(a,0);

     ios_base::sync_with_stdio(false);
     cin.tie(0);

     int n,k;
     cin>>n>>k;

     rep(i,1,n) cin>>a[i];
     rep(i,1,n){
        dp[i]=10000000001;
        //cout<<dp[i]<<endl; 
     } 
     dp[0]=0;
     dp[1]=0;

     rep(i,2,n){

        rep(j,1,k){

            if(i - j > 0){

                ll bam = dp[i-j]+abs(a[i-j]-a[i]);


                dp[i]=min(dp[i],bam);

            }

        }

     }


     cout<<dp[n]<<endl;

    return 0;
}





Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#define LL long long
using namespace std;
int const mod=1e9+7;
int const maxn=1e5+10;
int a[maxn];
int main()
{
    int i,j,k;
    int n,x;
    cin>>n;
    for (i=1;i<=n;i++)
    {
        cin>>x;
        a[x]++;
    }
    int mx=a[0]+a[1];
    for (i=1;i<=100000;i++)
    {
        int tmp=a[i]+a[i-1]+a[i+1];
        mx=max(mx,tmp);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
    long long N, K;
    cin >> N >> K;

    vector<pair<long long, long long>> AB(N);
    for (int i = 0; i < N; i++) {
        cin >> AB[i].first >> AB[i].second;
    }

    sort(AB.begin(), AB.end());
    long long res = 0;
    for (int i = 0; i < N; i++) {
        if (res + AB[i].second < K) {
            res += AB[i].second;
            continue;
        }
        else {
            cout << AB[i].first << endl;
            break;
        }
    }
}


Measured memory_bytes: 1792
package main

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

func main() {
	S := nextString()
	T := nextString()
	count := 0
	for i := 0; i < 3; i++ {
		if S[i] == T[i] {
			count += 1
		}
	}
	fmt.Println(count)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

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

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

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

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


Measured memory_bytes: 640
import sys
import math
def II():
	return int(sys.stdin.readline())

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

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
n = II()
print(n+n**2+n**3)

Measured memory_bytes: 61972
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int ball[100];
int main()
{
	int n,k,ans=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;++i)
		scanf("%d",&ball[i]);
	for(int i=0;i<n;++i)
		ans+=min(k-ball[i],ball[i]);
	ans*=2;
	printf("%d",ans);
	return 0;
}

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

int main() {
  int cnt = 0;
  char ch;
  for (int i = 0; i < 3; i++) {
    std::cin >> ch;
    if (ch == 'o') cnt++;
  }

  std::cout << 700 + 100 * cnt << std::endl;
}

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

using namespace std;

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

    vector<long long> a(n + 1);
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
    }

    vector<long long> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    long long sum = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            sum += a[i];

            if (a[i + 1] < b[i] - a[i]) {
                sum += a[i + 1];
                a[i + 1] = 0;
            } else {
                sum += b[i] - a[i];
                a[i + 1] -= b[i] - a[i];
            }
        } else {
            sum += b[i];
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;
const int AMAX = 100000;
ll cnt[AMAX + 1];
using namespace std;
int main(void) {
  int N;
  ll K;
  cin >> N >> K;

  for (int i = 0; i < N; ++i) {
  int A, B;
  cin >> A >> B;
  cnt[A] += B;
  }

  for (int ans = 1; ans <= AMAX; ++ans){
    if (K <= cnt[ans]) {
      cout << ans << endl;
      break;
    }
    K -= cnt[ans];
  }

}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=100001;
struct record
{
	int start,end,c;
}arr[MAXN];
int flag[50],last[50];
inline bool CMP(const record &a,const record &b)
{
	if(a.start<b.start) return true;
	if(a.start>b.start) return false;
	return a.c<b.c;
}
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
	return x*f;
}
int main()
{
	memset(flag,0,sizeof(flag));
	memset(last,0,sizeof(last));
	int n=read(),channel=read();
	for(int i=1;i<=n;++i)
		{arr[i].start=read();arr[i].end=read();arr[i].c=read();}
	sort(arr+1,arr+n+1,CMP);
	for(int i=1;i<=n;++i)
		for(int j=1;j<50;++j)
			if(flag[j]<arr[i].start||(last[j]==arr[i].c&&flag[j]==arr[i].start))
				{flag[j]=arr[i].end;last[j]=arr[i].c;break;}
	for(int i=1;i<=n;++i)
		if(flag[i+1]==0)
		{printf("%d",i);break;}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cstdint>
using namespace std;

#define N 5000

char s[N];
int k;
int cnt = 0;

int find( string *ss, string *sub, int istart )
{
	int ret = -1;
	int i;
	for( i = istart; i < 26; i++ ) {
		int c = 'a' + i;
		*sub += c;
		string::size_type pos = ss->find( *sub );
		if( pos != string::npos ) {
			break;
		}
		sub->pop_back();
	}
	if( i < 26 ) {
		ret = i;
	}
	return ret;
}

int main()
{
	cin >> s;
	cin >> k;

	string ss(s);

	string sub;
	int istart = 0;
	for( ;; ) {
		int idx = find( &ss, &sub, istart );
		if( idx >= 0 ) {
			cnt++;
			if( cnt >= k ) {
				break;
			}
			istart = 0;
		}
		else {
			char c = sub[ sub.size() - 1 ];
			istart = c - 'a' + 1;
			sub.pop_back();
			if( sub.size() <= 0 && istart >= 26 ) {
				return 0;
			}
		}
	}

	cout << sub << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> a(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end());
    int alice=0;
    for(int i=n-1;i>=0;i-=2){
        alice+=a[i];
    }
    cout<<alice-(sum-alice)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <sstream>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int ccw(Point a,Point b,Point c)
{
  b=b-a;
  c=c-a;
  if(b%c>0) return +1;
  else if(b%c<0)return -1;
  else if(b*c<0) return +2;
  else if(b.size()<c.size()) return -2;
  else return 0;
}

int n,w,h;
vector<int> h1(15);
vector<int> h2(15);

string cmp(string a,string b)
{
  if(a.size()>b.size()) return a;
  if(b.size()>a.size()) return b;
  return max(a,b);
}

int main(int argc,char const* argv[])
{
  cin >> n >> w >> h;
  int wboard[w+5];
  int hboard[h+5];
  memset(wboard,0,sizeof(wboard));
  memset(hboard,0,sizeof(hboard));
  for(int i=0;i<n;i++)
    {
      int x,y,weight;
      cin >> x >> y >> weight;
      wboard[max(0,x-weight)]++;
      wboard[min(w,x+weight)]--;
      hboard[max(0,y-weight)]++;
      hboard[min(h,y+weight)]--;
    }
  int wsum=0,hsum=0;
  bool hflag=true,wflag=true;
  for(int i=0;i<w;i++)
    {
      wsum+=wboard[i];
      if(wsum==0) wflag=false;
    }
  for(int i=0;i<h;i++)
    {
      hsum+=hboard[i];
      if(hsum==0) hflag=false;
    }
  if(hflag==true || wflag==true)
    {
      cout << "Yes" << endl;
      return 0;
    }
  else
    {
      cout << "No" << endl;
      return 0;
    }
}



Measured memory_bytes: 3888
#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long
int t,n,m;
ll ans;
int main()
{
	cin>>n;
	ll l=n/3,r=n/5,k=n/15;
	ans=(ll)(n+1)*n/2-(3+(l-1)*3+3)*l/2-(5+(r-1)*5+5)*r/2+(15+(k-1)*15+15)*k/2;
	cout<<ans; 
	return 0; 
}

Measured memory_bytes: 3636
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.Map
import scala.collection.mutable.Queue
import scala.collection.mutable.PriorityQueue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val tree = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 until N) {
    val a, b = in.next().toInt
    tree(a) = b :: tree(a)
    tree(b) = a :: tree(b)
  }  


  //
  val MOD = 1e9.toInt + 7
  val mc = new ModComb(1e5.toInt, MOD)

  val dp = new Array[Boolean](N+1)
  var ans = 1L


  val first = 1 + tree(1).length
  if (first > K)
    ans = 0
  else {
    ans = mc.perm(K, first)

    breakable {
      val q = new Queue[Int]()

      dp(1) = true
      for (e <- tree(1))
        q.enqueue(e)


      while(!q.isEmpty) {
        val i = q.dequeue()
        dp(i) = true

        val k = tree(i).length - 1
        if(k > K-2) {
          ans = 0
          break
        }
        ans *= mc.perm(K-2, k)
        ans %= MOD
        for (e <- tree(i) if !dp(e))
          q.enqueue(e)
      }
    }
  }

  println(ans)
}


class ModComb(maxNum: Int, mod: Long) {

  private def repeatSquares(x: Long, n: Long): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % mod, n/2)
    else
      (x * repeatSquares(x*x % mod, n/2)) % mod
  }

  private val fact = new Array[Long](maxNum + 1)

  fact(0) = 1
  for (i <- 1 to maxNum)
    fact(i) = (i * fact(i-1)) % mod

  private val factInv = new Array[Long](maxNum + 1)

  factInv(maxNum) = repeatSquares(fact(maxNum), mod-2)
  for (i <- (1 to maxNum).reverse)
    factInv(i-1) = (i * factInv(i)) % mod


  // nPk
  def perm(n: Int, k: Int): Long = {
    (fact(n) * factInv(n-k)) % mod
  }


  // nCk
  def comb(n: Int, k: Int): Long = {
    val numer = fact(n)
    val denom = (factInv(n-k) * factInv(k)) % mod

    (numer * denom) % mod
  }

}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 61248
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextInt;
            if (last >= h) cur++;
            else
            {
                if (max < cur) max = cur;
                cur = 0;
            }
            last = h;
        }
        Console.WriteLine(Max(max, cur));
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = 0;
    private static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; }  }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }

    public static int NextSInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; int sign = 1; while (Buffer[ptr] < 45) Move(); 
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }

    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }

    public static long NextSLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


Measured memory_bytes: 13140
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int ans=0;
for(int i=0;i<=25;i++){
    for(int j=0;j<=14;j++){
    if(4*i+7*j==n){ans=1;break;}
    }
    if(ans==1)break;
}
if(ans==1){
System.out.println("Yes");
}
else{System.out.println("No");}
}}

Measured memory_bytes: 21972
#include <iostream>

using namespace std;

const string YES = "Yes";
const string NO = "No";

int main() {
  int N;
  cin >> N;
  bool pred = false;

  for (; N >= 0; N -= 7) {
    if (N % 4 == 0) {
      pred = true;
      break;
    }
  }

  cout << (pred ? YES : NO) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
    int n; long long k;
    cin>>n>>k;
    vector<pair<int,int> >ab(n);
    rep(i,n){
        int a,b;
        cin>>a>>b;
        ab.at(i)=make_pair(a,b);
    }
    sort(all(ab));
    rep(i,n){
        k-=ab.at(i).second;
        if(k<=0){
            cout<<ab.at(i).first<<endl;
            break;
        }
    }
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		int cnt = 1;
		int n = sc.nextInt();
		int max = sc.nextInt();
		for(int i = 1; i < n; i++) {
			int h = sc.nextInt();
			if(max <= h) {
				max = h;
				cnt++;
			}
		}
		System.out.println(cnt);
		
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

int calc(int N){
  int i;
  for(i=0;i*(i+1)*(i+2)/6<=N;i++){
  }
  i--;
  return i*(i+1)*(i+2)/6;
}

int solve(){
  int res=0;
  for(int i=0;i*i*i<=n;i++){
    res=max(res, i*i*i + calc( n-i*i*i ) );
  }
  return res;
}

int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    printf("%d\n",solve());
  }
  return 0;
}

Measured memory_bytes: 3184
#include<stdio.h>
#define MAX 100000
#define NIL -1
typedef struct{
  int p;
  int l;
  int r;
}Node;

Node T[MAX];
int n;//深さを代入

void prewalk(int s){
  if(s!=NIL){
  printf(" %d",s);
  prewalk(T[s].l);
  prewalk(T[s].r);
}
}
void inwalk(int s){
  if(s!=NIL){
  inwalk(T[s].l);
  printf(" %d", s);
  inwalk(T[s].r);
}
}
void postwalk(int s){
  if(s!=NIL){
  postwalk(T[s].l);
  postwalk(T[s].r);
  printf(" %d",s);
}
}


int main(){
  int i,j,left,right,node_num,root;//dは次数
  scanf("%d",&n);
    for(i=0;i<n;i++){
      T[i].l=T[i].r=T[i].p=NIL;
    }
    for(i=0;i<n;i++){//ノードの個数
      scanf("%d",&node_num);
      scanf("%d",&left);
      scanf("%d",&right);
      T[node_num].l=left;
      T[node_num].r=right;
      if(left !=NIL)T[left].p=node_num;
      if(right !=NIL)T[right].p=node_num;
      }
    for(i=0;i<n;i++){
      if(T[i].p==NIL)root=i;//root探し
    }
    printf("Preorder\n");
    prewalk(root);
    printf("\n");
    printf("Inorder\n");
    inwalk(root);
    printf("\n");
    printf("Postorder\n");
    postwalk(root);
    printf("\n");
    return 0;
  }



Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 1000000000
#define MOD 1000000007
#define ll long long
using namespace std;

int n;
int list[100001];
int main(){
    cin>>n;
    int a;
    rep(i,n){
        cin>>a;
        list[a]++;
    }
    int cnt=0;
    int s=0;
    rep(i,100001){
        if (list[i]!=0){
            s++;
            if (list[i]%2==0){
                cnt++;
            }
        }
    }
    cout<<s-(cnt)%2<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int n,t[1010];
int c[1010],d[1010];
main()
{
	int m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r;cin>>l>>r;
		t[l]++;t[r]--;
	}
	for(int i=1;i<=n;i++)t[i]+=t[i-1];
	int ans=n+1;
	for(int i=1;i<=n;i++)ans+=!!t[i]*2;
	cout<<ans<<endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int V[N];
  for (int i = 0; i < N; i++) cin >> V[i];
  for (int i = 0; i < N; i++) {
    int C;
    cin >> C;
    V[i] -= C;
  }
  sort(V, V + N);
  int ans = 0;
  for (int i = N - 1; i >= 0 && V[i] > 0; i--) ans += V[i];
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

int cover[500005];
const int SHIFT = 200005;

void add(int k, int x)
{
  cover[k + SHIFT] += x;
}

int query(int k)
{
  return (cover[k + SHIFT]);
}

int main()
{
  int N, M, A[200000], B[200000] = {};
  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    --A[i];
    B[A[i]]++;
  }

  for(int j = 0; j < N; j++) {
    --B[j];
    int sz = j - B[j];
    add(sz, 1);
    add(j + 1, -1);
  }
  for(int j = 1; j < 500005; j++) {
    cover[j] += cover[j - 1];
  }
  int ret = 0;
  for(int j = 0; j < N; j++) {
    if(query(j) <= 0) ++ret;
  }
  
  for(int i = 0; i < M; i++) {
    int X, Y;
    scanf("%d %d", &X, &Y);
    --X, --Y;
    add(A[X] - B[A[X]], -1);
    if(A[X] - B[A[X]] >= 0 && query(A[X] - B[A[X]]) == 0) {
      ++ret;
    }
    --B[A[X]];
    A[X] = Y;
    ++B[A[X]];
    add(A[X] - B[A[X]], 1);
    if(A[X] - B[A[X]] >= 0 && query(A[X] - B[A[X]]) == 1) {
      --ret;
    }

    printf("%d\n", ret);
  }
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<pair<int,int>> dish(5);
  for(int i=0; i<5; i++){
    int V;
    int k;
    cin >> V;
    if(V>99){
      k=V%100%10;
    }
    else if(V>9){
      k=V%10;
    }
    else{
      k=V;
    }
    if(k==0)
      k=100;
    dish.at(i)=make_pair(k,V);
    }
    sort(dish.begin(),dish.end());
    reverse(dish.begin(),dish.end());
  int sum=0;
  for(int i=0; i<4; i++){
    if(dish.at(i).second%10==0)
      sum+=dish.at(i).second;
    else
      sum+=((dish.at(i).second/10)+1)*10;
  }
  sum+=dish.at(4).second;
  cout << sum << endl;
}


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


void solve(long long A, long long B){

    long long ans;
    double ax_min, ax_max;
    ax_min = double(A) / 0.08;
    ax_max = double(A+1) / 0.08 - 0.0001;

    double bx_min, bx_max;
    bx_min = double(B) / 0.1;
    bx_max = double(B+1) / 0.1 - 0.0001;

    //cout << ax_min << " " << ax_max << endl;
    //cout << bx_min << " " << bx_max << endl;
    
    if( (ax_min < bx_min) && (ax_max < bx_min)){
        ans = -1;
        //cout << "a" << endl;
    }else if( (bx_min < ax_min) && (bx_max < ax_min)){
        ans = -1;
        //cout << "b" << endl;
    }else if( (ax_min < bx_max) && (bx_min < ax_min) ){
        ans = long(ax_min+0.5);
        //cout << "c" << endl;
    }else if( (bx_min < ax_max) && (ax_min < bx_min)){
        ans = long(bx_min+0.5);
        //cout << "d" << endl;
    }else if( ax_min < bx_min ){
        ans = long(bx_min+0.5);
        //cout << "e" << endl;
    }else{
        ans = long(ax_min+0.5);
        //cout << "f" << endl;
    }

    cout << ans << endl;


}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int r;
    cin>>r;
    cout<<fixed<<setprecision(5)<<3.141592*2*r<<endl;

    return 0;
}

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

int main(void){
    int a,b,c,d,e,f;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);

    vector<bool> suger(f+1,false);
    vector<bool> water(f+1,false);

    int w,g=0;

    for(int i=0;i<=f;i++){
        for(int j=0;j<=f;j++){
            int y = i*c+j*d;
            if(y<=f){
                suger.at(y) = true;
                //g = y;
            }
        }
    }
    for(int i=0;i<=f;i++){
        for(int j=0;j<=f;j++){
            int x = 100*a*i+100*b*j;
            if(x<=f){
                water.at(x) = true;
                w = x;
            }
        }
    }


    for(int i=0;i<=f;i++){
        for(int j=f;j>0;j--){
            if(!suger.at(i) || !water.at(j)) continue;
            if(i+j<=f && i*(w+g)>g*(i+j) && 100*i<=j*e){
                g = i; w = j;
            }
        }
    }

    cout << w+g << " " << g << endl;
}

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    sa=STR()
    sb=STR()
    sc=STR()
    sa=list(reversed(sa))
    sb=list(reversed(sb))
    sc=list(reversed(sc))
    temp=sa.pop()
    while True:
        if temp=='a':
            if len(sa)>0:
                temp=sa.pop()
            else:
                flag='A'
                break
        elif temp=='b':
            if len(sb)>0:
                temp=sb.pop()
            else:
                flag='B'
                break
        if temp=='c':
            if len(sc)>0:
                temp=sc.pop()
            else:
                flag='C'
                break
    print(flag)
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <vector>
#define MAX 150

std::vector<std::vector<int> > makeArray(); 
void search(std::vector<std::vector<int> > v, int h, int w);

int main(void) {
    std::vector<std::vector<int> > v = makeArray();
    int h;
    int w;
    std::cin >> h >> w;
    while (h != 0 || w != 0) {
        search(v, h, w);
        std::cin >> h >> w;
    }
    return EXIT_SUCCESS;;
}

std::vector<std::vector<int> > makeArray() {
    std::vector<std::vector<int> > v(MAX, std::vector<int>(MAX, 0)); 
    for (int i = 0; i < MAX; i++) {
        for (int j = 0; j < MAX; j++) {
            v[i][j] = (i+1)*(i+1)+(j+1)*(j+1);
        }
    }
    return v;
}

void search(std::vector<std::vector<int> > v, int h, int w) {
    int value = h * h + w * w;
    int res_v = 1000000000;
    int res_h = h;
    int res_w = w;
    int max_j = MAX;

    for (int i = 0; i < MAX; i++) {
        for (int j = i + 1; j < max_j; j++) {
            if (v[i][j] > value) {
                if( v[i][j] < res_v) {
                    res_v = v[i][j];
                    res_h = i;
                    res_w = j;
                    max_j = j;
                }
                break; 
            } else if (v[i][j] == value && i > h) {
                res_v = v[i][j];
                res_h = i;
                res_w = j;
                max_j = j;
                std::cout << res_h + 1 << " " << res_w  + 1 << std::endl;
                return;;
            }
        }
    }
    std::cout << res_h + 1 << " " << res_w  + 1 << std::endl;
    return;
}

Measured memory_bytes: 3248
// 解答参照済
#include <iostream>
#include <vector>
#include <algorithm>

int N, A, B, C;
std::vector<int> L;

int dfs(int cur, int a, int b, int c) {
    if (cur == N) {
        return (std::min({a, b, c}) > 0) ? std::abs(A-a) + std::abs(B-b) + std::abs(C-c) -30 : 100000;
    }
    int ret0 = dfs(cur+1, a, b, c);
    int ret1 = dfs(cur+1, a+L[cur], b, c) + 10;
    int ret2 = dfs(cur+1, a, b+L[cur], c) + 10;
    int ret3 = dfs(cur+1, a, b, c+L[cur]) + 10;
    return std::min({ret0, ret1, ret2, ret3});
}

int main() {
    std::cin >> N >> A >> B >> C;
    
    for (int temp, i=0; i<N; ++i) {
        std::cin >> temp;
        L.push_back(temp);
    }
    std::cout << dfs(0,0,0,0) << std::endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-26 13:24:14 +0900
# LastModified: 2020-07-30 16:53:52 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import sqrt
from collections import Counter


def prime_factors(p, prime_box):
    while p % 2 == 0:
        prime_box.append(2)
        p //= 2

    for i in range(3, int(sqrt(p))+1, 2):
        while p % i == 0:
            prime_box.append(i)
            p //= i
    if p > 2:
        prime_box.append(p)


def main():
    n, p = map(int, input().split())
    if n == 1:
        print(p)
        return
    prime_box = []
    prime_factors(p, prime_box)
    prime_box = list(map(list, Counter(prime_box).items()))
    prime_box = [[s, t//n] for s, t in prime_box]
    ans = 1
    for s, t in prime_box:
        ans *= s**t
    print(ans)


if __name__ == "__main__":
    main()


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

long long dp[105][100005];
//map <long long,long long> cek[105];
long long weight[105];
long long value[105];
long long z,x;

long long rekur(int a,long long s)
{
	if(a>z)return 0;
	if(dp[a][s]!=-1)return dp[a][s];
//	cek[a][s]=1;
	long long temp;
	if(s-weight[a]>=0)
	{
		dp[a][s]=max(value[a]+rekur(a+1,s-weight[a]),rekur(a+1,s));
	}
	else dp[a][s]=rekur(a+1,s);
//	asd[a][s]=temp;
	return dp[a][s];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin>>z>>x;
	for(int q=1;q<=z;q++)
	{
		cin>>weight[q]>>value[q];
	}
	long long ans=rekur(1,x);
	cout<<ans<<endl;
}

Measured memory_bytes: 82304
X,K,D = (abs(int(T)) for T in input().split())
if K<=(X//D):
    Now = X-K*D
    Count = 0
    print(Now)
else:
    Now = X-(X//D)*D
    Count = K-(X//D)
    if abs(Now)<abs(Now-D):
        if Count%2==0:
            print(abs(Now))
        else:
            print(abs(Now-D))
    else:
        if Count%2==1:
            print(abs(Now-D))
        else:
            print(abs(Now))

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

using namespace std;
#define INF 100000000

int main(void){

    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }

    vector<int> disp(n,0);
    for(int i = 0;i < n-1;i++){
        if(i == 0) disp[i] += a[i+1] - a[i];
        else disp[i] += a[i+1] - a[i] + disp[i-1];
    }
    disp[n-1] = k + (a[0] - a[n-1]) + disp[n-2];

    int ans = INF;
    for(int i = 0;i < n;i++){
        int temp;
        if(i == 0) temp = disp[n+i-2];
        else {
            if(n+i-2 < n) temp = abs(disp[n+i-2] - disp[i-1]);
            else temp = abs(disp[(n+i-2)%n]+k - disp[i-1]);
        }

        ans = min(ans, temp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int p[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int A[100010];
    rep(i, n) cin >> A[i];
    int cnt = 0;
    rep(i, 100010) p[i] = -1;
    rep(i, n) {
        int ok = cnt;
        int ng = -1;
        while(abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if(p[mid] < A[i]) ok = mid;
            else ng = mid;
        }
        p[ok] = A[i];
        cnt = max(cnt, ok + 1);

    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <set>
#

using namespace std;

int main(){
    int n;
    char c[] = {'S','H','C','D'};
    cin >> n;
    map<char, set<int>> m;
    for(auto&& i : c){
        for(int j = 1; j <= 13; j++){
            m[i].insert(j);
        }
    }
    for(int i = 0; i < n; i++){
        char mark;
        do{
            cin >> mark;
        }while(mark < 'A' || 'Z' < mark);
        int num;
        cin >> num;
        m[mark].erase(num);
    }
    for(auto&& i : c){
        for(auto&& j : m[i]){
            cout << i << " " << j << "\n";
        }
    }
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc161/tasks/abc161_b>
 問題文============================================================
 B - Popular Vote
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N,M; cin >> N >> M;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    ll sum = accumulate(A.begin(),A.end(),0LL);
    int cnt = 0;
    for(auto a:A){
        if(a*4*M >= sum) cnt++;
    }
    if(cnt >= M) return "Yes";
    else return "No";
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int D;
vector<int> c;
vector<vector<int>> s;

int compute_score(vector<int> &out){
  int score = 0;
  vector<int> last(26, 0);
  REP(d, out.size()){
    last[out[d]] = d+1;
    score += s[d][out[d]];
    REP(i, 26){
      score -= (d+1-last[i])*c[i];
    }
  }
  return score;
}

signed main() {
  cin >> D;

  c.resize(26);
  REP(i, 26) cin >> c[i];

  s = vector<vector<int>>(D, vector<int>(26));
  REP(i, D) REP(j, 26) cin >> s[i][j];

  vector<int> out;
  REP(_, D){
    int max_score = -INF;
    int best_i = 0;

    REP(i, 26){
      out.emplace_back(i);
      int score = compute_score(out);
      if(chmax(max_score, score)){
        best_i = i;
      }
      out.pop_back();
    }
    out.emplace_back(best_i);
  }

  REP(i, out.size()){
    cout << out[i]+1 << "\n";
  }


  return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    
    int ans = 0;
    if(n >= 900){
        ans += 100;
    }else{
        ans += 900;
    }
    if(n%100 >= 90){
        ans += 10;
    }else{
        ans += 90;
    }
    if(n%10 >= 9){
        ans += 1;
    }else{
        ans += 9;
    }
    
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
A = np.array(list(map(int,input().split())))

balls = np.array([0]*(n+1))

for i in range(1,n+1):
    s = sum(balls[n+1-i::n+1-i])
    if s%2 != A[-i]:
        balls[-i] += 1

#print(balls)

ans = np.where(balls==1)[0].tolist()
if sum(balls):
    print(sum(balls))
    print(*ans)
else:
    print(0)

Measured memory_bytes: 36220
import scala.io.StdIn.readLine
import scala.math.{max,min}

object Main extends App {

  var m = readLine.split(" ").map(_.toInt)
  while( (m(0),m(1)) != (0,0) ){
    val Array(n,x) = m
    println( ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) => sum + (max(i+1,x-i-n) until min(n,(x-i+1)/2)).length })

    m = readLine.split(" ").map(_.toInt)
  }
}

Measured memory_bytes: 43892
#pragma region Macros

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

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N;
    cin >> N;
    map<int, int> a;
    REP(i, N) {
        int aaa = 0;
        cin >> aaa;
        a[i + 1] = aaa;
    }
    int on = 1;
    REP(i, N) {
        on = a[on];
        if (on == 2) {
            cout << i + 1;
            return;
        }
    }
    cout << -1;
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 9908
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long int LL;
LL ans=0;
int gcd(LL a,LL b){
    if(b==0){
       ans-=a;
       return 0;
    }
    if(a<b){
         gcd(b,a);
         return 0;
    }

    ans+=b*((a/b)*2);
    gcd(b,a%b);

    return 0;
}

int main(){
	LL N,X;
	cin>>N>>X;
        LL a=X;
        LL b=N-X;
        if(a%b==0){
           cout<<3*X<<endl;
           return 0;
        }
        ans=a+b;
        gcd(a,b);
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 256