akhauriyash/Code-Regression huggingface dataset:
<?php

$sc = new Scanner();
$out = new out();

$n = $sc->nextInt();
for($i = 0; $i < $n; $i++) {
    $a[] = $sc->nextInt();
}
rsort($a);
$s = 0;
foreach($a as $i => $v) {
    if ($i % 2 === 0) {
        $s += $v; 
    } else {
        $s -= $v;
    }
}
$out->println($s);


class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

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

namespace AtCoder.DP
{
    class EDPC_F
    {
        public static void Main()
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            if (s.Length > t.Length)
            {
                var temp = s;
                s = t;
                t = temp;
            }

            var dp = new int[s.Length + 1, t.Length + 1];

            for (int i = 1; i <= s.Length; i++)
            {
                for (int j = 1; j <= t.Length; j++)
                {
                    dp[i, j] = Math.Max(dp[i - 1, j], dp[i, j - 1]);
                    if (s[i - 1] == t[j - 1])
                        dp[i, j] = Math.Max(dp[i, j], dp[i - 1, j - 1] + 1);
                }
            }

            Console.WriteLine(Restore(s, dp));
        }

        public static string Restore(string s, int[,] dp)
        {
            int y = dp.GetLength(0) - 1;
            int x = dp.GetLength(1) - 1;
            var d = dp[y, x];

            var str = new char[d];

            while (d > 0)
            {
                while (dp[y - 1, x] == d)
                    y--;
                while (dp[y, x - 1] == d)
                    x--;
                str[d-1] = s[y-1];
                d--;
                x--;
                y--;
            }
            return new string(str);
        }
    }
}



Measured memory_bytes: 46048
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

typedef struct{
  char suit;
  int value;
}Card;

Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(Card*, int, int, int, int);
void mergeSort(Card*, int, int, int);
int partition(Card*, int, int, int);
void quickSort(Card*, int, int, int);

int main()
{
  int n, i, v;
  Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for( i = 0; i < n; i++)
    {
      scanf("%s %d", S, &v);
      A[i].suit = B[i].suit = S[0];
      A[i].value = B[i].value = v;
    }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n - 1);

  for( i = 0; i < n; i++)
  {
    if( A[i].suit != B[i].suit ) stable = 0;
  }

  if( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for( i = 0; i < n; i++)
    {
      printf("%c %d\n", B[i].suit, B[i].value);
    }
  return 0;
}

void merge(Card A[], int n, int left, int mid, int right)
{
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;

  for( i=0; i < n1; i++)
    {
      L[i] = A[left + i];
    }
  for( i=0; i < n2; i++)
    {
      R[i] = A[mid + i];
    }

  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;

  for( k = left; k < right; k++)
    {
      if( L[i].value <= R[j].value ) A[k] = L[i++];
      else A[k] = R[j++];
    }
}

void mergeSort(Card A[], int n, int left, int right)
{
  int mid;
  if( left + 1 < right)
    {
      mid = (left + right) / 2;
      mergeSort(A, n, left, mid);
      mergeSort(A, n, mid, right);
      merge(A, n, left, mid, right);
    }
}

int partition(Card A[], int n, int p, int r)
{
  int i, j;
  Card t, x;
  x = A[r];
  i = p - 1;

  for( j = p; j < r; j++)
    {
      if( A[j].value <= x.value)
        {
          i++;
          t = A[i]; A[i] = A[j]; A[j] = t;
        }
    }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(Card A[], int n, int p, int r)
{
  int q;
  if( p < r )
    {
      q = partition(A, n, p, r);
      quickSort(A, n, p, q - 1);
      quickSort(A, n, q + 1, r);
    }
}



Measured memory_bytes: 4040
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sum = 0
for i in range(N):
    n = A[i]-1
    sum += B[n]
    if (A[i] == A[i-1]+1)and(0 < i):
        j = A[i-1] - 1
        sum += C[j]
print(sum)

Measured memory_bytes: 3064
def min(a, b):
    if(a < b):
        return a
    else:
        return b

dp = [0]
n = 1

for n in range(100010):
    dp.append(10000000)
    power = 1
    while(power <= n):
        dp[n] = min(dp[n], dp[n-power] + 1)
        power *= 6
    power = 1
    while(power <= n):
        dp[n] = min(dp[n], dp[n-power] + 1)
        power *= 9

N = int(input())
print(dp[N])

Measured memory_bytes: 3860
#include <stdio.h>

int  Sort(int n, int *a){
	int f = 1, i, cou = 0;
	
	while(f){
		f = 0;
		for(i = 0; n-1 > i; i++){
			if(a[i] > a[i+1]){
				int buf = a[i+1];
				a[i+1] = a[i];
				a[i] = buf;
				f = 1;
				cou++;
			}
		}
	}
	return cou;
}
int main(void) {
	int n, a[100], i;
	
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		scanf("%d", &a[i]);
	}
	
	int cou = Sort(n, a);
	
	for(i = 0; n > i; i++){
		printf("%d", a[i]);
		if(n - 1 > i) printf(" ");
	}
	printf("\n%d\n", cou);
	return 0;
}

Measured memory_bytes: 604
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Char8 as B
import Data.Attoparsec.ByteString.Char8
import Data.Bits

type Input  = (Int, Int)
type Output = Int

input :: Parser Input
input = do
  (_A, _B) <- decimalPair
  return (_A, _B)

decimalPair :: Parser (Int, Int)
decimalPair = (,) <$> decimal <* char ' ' <*> decimal <* endOfLine

main :: IO ()
main = B.interact
  $ B.pack . show . either (error "parse err") solve . parseOnly input

solve :: Input -> Output
solve (_A, _B) = f _A _B
  where
    f 0 b = g b
    f a b = g b `xor` g (a - 1)

    g x = case x `mod` 4 of
      0 -> x
      1 -> 1
      2 -> x `xor` 1
      3 -> 0

Measured memory_bytes: 508
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt();
		int b=stdIn.nextInt();
		int c=stdIn.nextInt();
		int i,s=0;
		for(i=a;i<=b;i++)if(c%i==0)s++;
		System.out.println(s);
	}
}


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

using namespace std;

using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

Graph G;
vector<int> res;
void dfs(int v, int p, int c){
    res[v] = c;
    for(auto e : G[v]){
    	if(e.first==p) continue;
        if(e.second & 1) dfs(e.first, v, 1-c);
        else dfs(e.first, v, c);
    }
}


int main(){
	int N;
  	cin >> N;
    G.assign(N, vector<Edge>());
  	for(int i=0; i<N-1; i++){
    	int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
      	G[u].push_back(Edge(v, w));
     	G[v].push_back(Edge(u, w));
    
    }
  
    res.assign(N, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;
    

	return 0;
}

Measured memory_bytes: 8960
#!python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ANS = 0
    i = 0
    while i + 1 < N:
        if A[i] == A[i + 1]:
            ANS += 1
            i += 1
        i += 1
    print(ANS)


if __name__ == '__main__':
    main()


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

int main()
{
    long long n;
    cin >> n;
    vector<signed long long> a(n);
    for (long long i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    long long even = 0;
    long long odd = 0;
    long long sum = 0;
    for (long long i = 0; i < n; ++i)
    {
        if (i % 2 == 0)
        {
            if (sum + a[i] > 0)
            {
                sum += a[i];
            }
            else
            {
                even += abs(sum + a[i] - 1);
                sum = 1;
            }
        }
        else
        {
            if (sum + a[i] < 0)
            {
                sum += a[i];
            }
            else
            {
                even += sum + a[i] + 1;
                sum = -1;
            }
        }
    }
    sum = 0;
    for (long long i = 0; i < n; ++i)
    {
        if (i % 2 == 0)
        {
            if (sum + a[i] < 0)
            {
                sum += a[i];
            }
            else
            {
                odd += sum + a[i] + 1;
                sum = -1;
            }
        }
        else
        {
            if (sum + a[i] > 0)
            {
                sum += a[i];
            }
            else
            {
                odd += abs(sum + a[i] - 1);
                sum = 1;
            }
        }
    }
    cout << min(even, odd) << endl;
}

Measured memory_bytes: 4024
s = list(input())

if s[0] == '1':
    s[0] = s[0].replace('1', '9')
elif s[0] == '9':
    s[0] = s[0].replace('9', '1')
if s[1] == '1':
    s[1] = s[1].replace('1', '9')
elif s[1] == '9':
    s[1] = s[1].replace('9', '1')
if s[2] == '1':
    s[2] = s[2].replace('1', '9')
elif s[2] == '9':
    s[2] = s[2].replace('9', '1')

print(''.join(s))

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
    char str[200000];
    int i = 0;
    int total=0;

    scanf("%s", str);

    while(str[i] != '\0')
    {
        total += (str[i] - '0');
        i++;
    }

    if(total % 9 == 0)
    {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 1856
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;



int main(){
	int N, A;
	scanf("%d\n%d", &N, &A);
	if(A >= 499){
		printf("Yes\n");
		return 0;
	}
	if(N % 500 <= A)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[list(map(int, input().split())) for _ in range(2)]
ans = 0
for i in range(N):
    tmp = 0
    for j in range(i+1):
        tmp += A[0][j]
    for j in range(i, N):
        tmp += A[1][j]
    ans = max(ans, tmp)
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define inin(a, n, i) memset(a, i, sizeof(a[0])*(n))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto &x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))
	
template<class T> bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template<class T> bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template<class A, class B> A cvt(B x) { stringstream s; s << x; A r; s >> r; return r; }

void read() {}
void print() {}
template<class T, class... Args> void read(T& a, Args&... args) { cin >> a; read(args...); }
template<class T, class... Args> void print(T a, Args... args) { cout << a << ' '; print(args...); }
template<class... Args> void println(Args... args) { print(args...); cout << endl; }

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	int n; read(n);
	string c; read(c);
	int l = 0, r = n-1;
	int ans = 0;
	while(l < r) {
		while(l <= r && c[l] != 'W') l++;
		while(r >= l && c[r] != 'R') r--;
		if(l < r) {
			swap(c[l], c[r]);
			ans++;
		}
	}
	println(ans);
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3772
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

long s(long n)
{
    long r;
    while (n) {
        r += n%10;
        n /= 10;
    }
    return r;
}

double sunuk(long n)
{
    return n.to!double / s(n).to!double;
}

void main()
{
    long[] r;
    foreach (i; 0..15) {
        auto b = 10L^^i;
        foreach (long j; 1..151) {
            r ~= b * j - 1;
        }
    }
    r = r.sort.uniq.array[1..$];
    long[] rr;
    foreach (i, n; r) {
        rr ~= n;
        foreach (m; r[i+1..$]) {
            if (sunuk(n) > sunuk(m)) {
                rr = rr[0..$-1];
                break;
            }
        }
    }

    auto K = readln.chomp.to!int;
    foreach (n; rr[0..K]) {
        writeln(n);
    }
}

Measured memory_bytes: 4472
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Map<String , Integer> map = new  HashMap<String, Integer>();
        map.put("a",0);
        map.put("b",0);
        map.put("c",0);
        map.put("d",0);
        map.put("e",0);
        map.put("f",0);
        map.put("g",0);
        map.put("h",0);
        map.put("i",0);
        map.put("j",0);
        map.put("k",0);
        map.put("l",0);
        map.put("m",0);
        map.put("n",0);
        map.put("o",0);
        map.put("p",0);
        map.put("q",0);
        map.put("r",0);
        map.put("s",0);
        map.put("t",0);
        map.put("u",0);
        map.put("v",0);
        map.put("w",0);
        map.put("x",0);
        map.put("y",0);
        map.put("z",0);
        while(sc.hasNext()){
            String s = sc.nextLine().toLowerCase();
            for(int i = 0;i<s.length();i++){
                String let = s.substring(i, i + 1);
                Optional<Integer>  val = Optional.ofNullable(map.get(let));
                if(val.isPresent()){
                    int val2 = val.get();
                    val2 = val2 + 1;
                    map.replace(let,val2);
                }
            }
        }
            for(String key : map.keySet()){    
            System.out.println(key + " : " + map.get(key));
        }
    }
}




Measured memory_bytes: 26196
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int ans = 0;
bool dp[1 << 24];

typedef struct
{
  bool used;
  int color, piled;
} Circle;

void solve(vector<Circle>& circle, int bit)
{
  ans = max(ans, __builtin_popcount(bit));
  if (dp[bit])
    return;

  dp[bit] = true;
  for (unsigned int i = 0; i < circle.size(); ++i) {
    if ((circle[i].piled & bit) == circle[i].piled && (~bit & (1 << i))) {

      for (unsigned int j = i+1; j < circle.size(); ++j) {
	if ((circle[j].piled & bit) == circle[j].piled && (~bit & (1 << j)) && circle[i].color == circle[j].color) {
	  solve(circle, bit | (1 << i) | (1 << j));
	}
      }

    }
  }
}

int main()
{
  int n;
  while (~scanf("%d", &n)) {
    if (n == 0)
      break;

    vector<int> x(n), y(n), r(n), c(n);
    for (int i = 0; i < n; ++i)
      scanf("%d %d %d %d", &x[i], &y[i], &r[i], &c[i]);

    vector<Circle> circle(n);
    for (int i = n-1; i >= 0; --i) {
      circle[i].color = c[i];
      circle[i].piled = 0;
      for (int j = i-1; j >= 0; --j) {
	if ((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]) < (r[i]+r[j])*(r[i]+r[j]))
	  circle[i].piled |= (1 << j);
      }
    }

    ans = 0;
    for (int i = 0; i < (1 << 24); ++i)
      dp[i] = false;
    solve(circle, 0);
    printf("%d\n", ans);
  }
  return 0;
}

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

int main(){
    int i, j, ans;

    for(i = 1; i < 10; i++){
        for(j = 1; j < 10; j++){
            ans = i * j;
            /* output */
            cout << i << "x" << j << "=" << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2908
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi;
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;
}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_C() {}

int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    ll K; cin >> K;
    vector<pii> p(N);
    REP(i, N) cin >> p[i].first >> p[i].second;    
    sort(p.begin(), p.end());

    int ans = 0;
    REP(i,N) {
        if (p[i].second >= K){
            ans = p[i].first;
            break;
        } else {
            K -= p[i].second;
        }
    }

    cout << ans << endl;  

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) {
        bool is_ok = true;
        for (int j = 0; j < s.length() - i; j++) {
            if (s[i + j] != t[j]) is_ok = false;
        }
        if (is_ok) {
            cout << N + i << endl;
            return 0;
        }
    }
    cout << 2 * N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main(){
    int ch[40]={0},in;
    
    for(int i=0;i<28;i++){
        scanf("%d",&in);
        ch[in]=1;
    }
    
    for(int i=1;i<=30;i++){
        if(!ch[i])printf("%d\n",i);
    }
    
    return 0;
}

Measured memory_bytes: 1188
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		String cards[] = new String[times];
		String[] bubbleCards =new String[times];
		int bubbleNum[] = new int[times];
		int temp = 0;
		String tempSt = "";
		int min = 0;
		int banchi = 0;
		int finir = 0;
		int irekae = 0;
		int i = 0;
		char suit = ' ';
		
		for(i=0;i<times;i++){
			cards[i] = scan.next();
		}
		for(i=0;i<times;i++){
			suit = cards[i].charAt(1);
			num[i] = Character.getNumericValue(suit);
		}
		i = 0;
		
//		??????????????????
		bubbleNum = num.clone();
		bubbleCards = cards.clone();
		for(i=0;i<times;i++){
			for(int j=times-1;j>i; j--){
				if(bubbleNum[j] < bubbleNum[j-1]){
					temp = bubbleNum[j];
					bubbleNum[j] = bubbleNum[j-1];
					bubbleNum[j-1] = temp;
					tempSt = bubbleCards[j];
					bubbleCards[j] = bubbleCards[j-1];
					bubbleCards[j-1] = tempSt;
				}
			}
		}
//		???????????????????????? ??????????????¶???Stable
		
		for(i=0;i<times;i++){
			System.out.print(bubbleCards[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println("Stable");
			}
			else{
				System.out.print(" ");
			}
		}
		
		
//		?????¬????????§????????????
		for(i=0;i<times;i++){
			min = i;
			for(int j=i;j<times;j++){
				if(num[j] < num[min]){
					min = j;
				}
			}
			temp = num[i];
			num[i] = num[min];
			num[min] = temp;
			tempSt = cards[i];
			cards[i] = cards[min];
			cards[min] = tempSt;
		}
//		?????¬????????§??????????????????
		for(i=0;i<times;i++){
			System.out.print(cards[i]);
			if(i == times-1){
				System.out.println("");
			}
			else{
				System.out.print(" ");
			}
		}
		
		
//		???????????¨?????¬????????§????????????
		boolean tf = true;
		for(i=0; i<times;i++){
			if(bubbleCards[i] != cards[i]){
				System.out.println("Not stable");
				tf = false;
				break;
			}
		}
		if(tf == true){
			System.out.println("Stable");
		}
	}
}

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

int main(){
    double a,b;
    cin>>a>>b;

    if(a>0 && b>0){
        cout<<"Positive"<<"\n";
        return 0;
    }
    else if(a*b<=0){
        cout<<"Zero"<<"\n";
        return 0;
    }
    else{
        int n=(b-a)+1;
        if(n%2==0) cout<<"Positive"<<"\n";
        else cout<<"Negative"<<"\n";
        return 0;
    }
}

Measured memory_bytes: 3740
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
d = Counter()
for n in range(N):
    tmp = input()
    d[tmp] += 1
for key in ['AC', 'WA', 'TLE', 'RE']:
    print("{} x {}".format(key, d[key]))



Measured memory_bytes: 10852
#include <stdio.h>
#include <string.h>

int main(void)
{
	char map[1024];
	int i;
	int flag;


	flag = 0;
	while (1) {
		if (flag == 1){
			if (getchar() == EOF) break;
		}
		else {
			flag = 1;
		}

		for (i = 0; i < 8; i++){
			fgets(&map[i * 8], 16, stdin);
		}

		if (strstr(map, "1000000010000000100000001") != NULL) puts("B");
		else if (strstr(map, "1111") != NULL) puts("C");
		else if (strstr(map, "1000000110000001") != NULL) puts("D");
		else if (strstr(map, "11000000011") != NULL) puts("E");
		else if (strstr(map, "100000001100000001") != NULL) puts("F");
		else if (strstr(map, "110000011") != NULL) puts("G");
		else puts("A");
	}

	return (0);
}

Measured memory_bytes: 524
A_count = int(input());
A = [int(n) for n in input().split()];
M_count = int(input());
M = [int(n) for n in input().split()];

memo = [[None for i in range(2000)] for j in range(A_count + 1)];

def solve(start, target):
    if memo[start][target] is not None:
        return memo[start][target];
    if target == 0:
        return True;
    elif start >= A_count:
        return False;
    else:
        result = solve(start + 1, target) or solve(start + 1, target - A[start]);
        if result:
            memo[start][target] = True;
            return True;
        else:
            memo[start][target] = False;
            return False;

for m in M:
    if solve(0, m):
        print("yes");
    else:
        print("no");


Measured memory_bytes: 5984
from sys  import stdin,stdout
 
import bisect
 
import math
 
from collections import deque
 
mod=10**9 +7 
 
def st():
    return list(stdin.readline().strip())
 
def inp():
    return int(stdin.readline())
 
def li():
    return list(map(int,stdin.readline().split()))
 
def mp():
    return map(int,stdin.readline().split())
 
def pr(n):
    stdout.write(str(n)+"\n")
    
def DFS(dictionary,vertex,visited):
    visited[vertex]=True
    stack=[vertex]
    print(vertex)
    while stack:
        a=stack.pop()
        for i in dictionary[a]:
            if not visited[i]:
                print(i)
                visited[i]=True
                stack.append(i)
 
 
def BFS(dictionary, vertex,visited):
    visited[vertex]=True
    q=deque()
    q.append(vertex)
    while q:
        a=q.popleft()
        for i in dictionary[a]:
            if not visited[i]:
                visited[i]=True
                q.append(i)
                print(i)
 
                
 
 
def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0
    
    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime
 
def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a
 
def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

x=soe(10**6)
 
def prime(n):
    d={}
    i=0
    while x[i]*x[i]<=n:
        if n%x[i]==0:
            d[x[i]]=0
            while n%x[i]==0:
                n=n//x[i]
                d[x[i]]+=1
        i+=1
    if n>1:
        d[n]=1
        
    mi=-10
    ans=float('inf')
    
    for i in d:
        if d[i]>mi:
            ans=i
            mi=d[i]
        elif d[i]==mi:
            ans=min(ans,i)
    return ans
    
def solve():
    a,b,x=mp()
    z=b//x
    c=a//x
    if a%x==0:
        pr(z-c+1)
    else:
        pr(z-c)
 
 
 
for _ in range(1):
    solve()
    


Measured memory_bytes: 20308
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

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

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	S := sc.nextStr()
	dp := make([][]int, N)
	for i := 0; i < N; i++ {
		dp[i] = make([]int, N)
	}
	ans := 0
	for i := N - 1; i >= 0; i-- {
		for j := i - 1; j >= 0; j-- {
			if S[i] == S[j] {
				if i < N-1 && j < i-1 {
					//fmt.Fprintln(wtr, i, j, dp[i+1][j+1]+1, i-j)
					dp[i][j] = min(dp[i+1][j+1]+1, i-j)
				} else {
					dp[i][j] = 1
				}
			} else {
				dp[i][j] = 0
			}
			ans = max(ans, dp[i][j])
		}
	}
	//for i := 0; i < N; i++ {
	//	fmt.Fprintln(wtr, dp[i])
	//}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 204800
def main():
    def calc_x_y(mi):
        """取り除いた要素の最小値がmiとなるように
        操作をQ回行えるか
        行える -> Q回の操作で取り除いた要素の最大値 - mi
        行えない -> -1
        """

        cont = 0
        removed = []
        for i, x in enumerate(a):
            if x < mi:
                if cont >= K:
                    removed += sorted(a[i - cont:i])[:cont - K + 1]
                cont = 0
                continue
            cont += 1
        else:
            if cont >= K:
                removed += sorted(a[-cont:])[:cont - K + 1]

        if len(removed) >= Q:
            removed.sort()
            return removed[Q - 1] - mi
        else:
            return -1

    N, K, Q = map(int, input().split())
    *a, = map(int, input().split())

    mi_cands = sorted(set(a))

    ans = 10 ** 9
    for mi in mi_cands:
        res = calc_x_y(mi)
        if ~res:
            ans = min(ans, res)

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

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

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

int main(void){
  int N,K,X,Y; cin>>N>>K>>X>>Y;
  int ans=0;
  rep(i,N){
    if(i<K) ans+=X;
    else ans+=Y;
  }
  cout<<ans<<endl;
}














Measured memory_bytes: 256
def check_pa(word)
    #word = word.to_s
      size = word.length / 2
        return ( word[0..size] == word.reverse[0..size] )
end

a = gets.chomp.split("")#.map(&:to_i)
if check_pa(a)
  p 0
  exit
elsif !a.include?("x")
  p -1
  exit
end


tmp = 0
head = 0
tail = a.size-1

while tail - head > 0
  if a[head]== "x" && a[tail] != "x" 
    tmp += 1
    head+=1
  elsif a[head] != "x" && a[tail] == "x" 
    tmp += 1
    tail -= 1
  elsif a[head] != a[tail] 
    p -1
    exit
  else
    head+=1
    tail -=1
  end
end

p tmp

#if check_pa(a.select{|t| t != "x"})
#  p (a.select{|t| t== "x"}.size - tmp)
#else
#  p -1
#end


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

int main() {
  int n,x=0;
  cin>>n;
  vector<int> a(n), b(n), c(n-1);
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) {
    cin>>b[i];
    x+=b[i];
  }
  for(int i=0;i<n-1;i++) cin>>c[i];
  int k=0;
  for(int i=1;i<n;i++) {
    if(a[i]-a[i-1]==1) 
      x+=c[a[i-1]-1];
  }
  cout<<x;
  return 0;
}

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

int main() {
  int S;
  cin >> S;
  int F = S / 100;
  int B = S - F * 100;
  if ((F == 0 || F > 12) && (B == 0 || B > 12)) {cout << "NA" << endl;}
  else if ((F == 0) || (F > 12)) {cout << "YYMM" << endl;}
  else if ((B == 0) || (B > 12)) {cout << "MMYY" << endl;}
  else {cout << "AMBIGUOUS" << endl;}
  return 0;
}


Measured memory_bytes: 256
n,m = gets.chomp.split(" ").map(&:to_i)
a = n.times.map{gets.chomp.split(" ").map(&:to_i)}
c = m.times.map{gets.chomp.split(" ").map(&:to_i)}
for i in 0..n-1
  x,y = 1000000000,1000000000
  z = -1
  for j in 0..m-1
    if (a[i][0]-c[j][0]).abs+(a[i][1]-c[j][1]).abs < (a[i][0]-x).abs+(a[i][1]-y).abs
      x,y = c[j][0],c[j][1]
      z = j
    end
  end
  puts z+1
end

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

int main() {
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  if(s == "abc"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
x,k,d = map(int, input().split())
if k*d <= abs(x):
  print(abs(x)-k*d)
else:
  a = abs(x)%d
  b = abs(a-d)
  if (k-(abs(x)//d))%2 == 0:
    print(a)
  else:
    print(b)

Measured memory_bytes: 8956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  int m;
  for(int i = 0;i < 10000;i++){
    int g;
    g = 1;
    for(int j = 2;j < min(a-1,1000);j++){
      if( (a+i) % j == 0){
        g = 0;}
    }
    if(g == 1){m = a+i;
              break;}
  }
    
      cout << m << endl;
      
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    H=[0]+list(map(int,input().split()))

    dp=[[INF]*(n-k+1) for _ in range(n+1)]
    dp[0][0]=0

    for x in range(1,n+1):
        for y in range(1,n-k+1):
            dp[x][y]=min(dp[x0][y-1]+max(0,H[x]-H[x0]) for x0 in range(x))

    print(min(dp[x][n-k] for x in range(n+1)))
resolve()

Measured memory_bytes: 48100
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
int N,K;
int root(int N,int K,int A){
    if(N < K){
        return A;
    } else {
        return root(N/K,K,A+1);
    }
}
int main(){
    int ans;
    cin >> N >> K;
    ans = root(N,K,1);
    cout << ans << endl;
}

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

int main(){
	int count[4][3][10];
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				count[i][j][k]=0;
			}
		}
	}
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int b, f ,r, v;
		cin >> b >> f >> r >> v;
		count[b-1][f-1][r-1]+=v;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				cout << " " << count[i][j][k];
			}
			cout << endl;
		}
		if(i!=3) cout<< "####################" << endl;
	}
	return 0;
}

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

using namespace std;

int main(void)
{
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;

  vector<int> vx(N);
  vector<int> vy(M);

  for(int i = 0; i < N; i++){
    cin >> vx[i];
  }
  for(int i = 0; i < M; i++){
    cin >> vy[i];
  }

  bool xflag = false;
  bool yflag = false;
  for(int i = X+1; i <= Y; i++){
    bool xflag = true;
    bool yflag = true;
    for(int j = 0; j < N; j++){
      if(vx[j] >= i){
        xflag = false;
      }
    }
    for(int j = 0; j < M; j++){
      if(vy[j] < i){
        yflag = false;
      }
    }
    if(xflag && yflag){
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
import collections

H, W, K = [int(x) for x in input().split()]
X1, Y1, X2, Y2 = [int(x) for x in input().split()]
C = [input().strip() for _ in range(H)]

ans = [[float("inf")] * W for j in range(H)]

q = collections.deque()
q.append((X1 - 1, Y1 - 1))

ans[X1 - 1][Y1 - 1] = 0

while q:
    cx, cy = q.popleft()
    cc = ans[cx][cy]
    nc = cc + 1

    # right
    for i in range(1, K + 1):
        if cy + i >= W or C[cx][cy + i] == "@":
            break
        if ans[cx][cy + i] <= nc - 1:
            break
        if ans[cx][cy + i] <= nc:
            continue
        ans[cx][cy + i] = nc
        q.append((cx, cy + i))
    # left
    for i in range(1, K + 1):
        if cy - i <= -1 or C[cx][cy - i] == "@":
            break
        if ans[cx][cy - i] <= nc - 1:
            break
        if ans[cx][cy - i] <= nc:
            continue
        ans[cx][cy - i] = nc
        q.append((cx, cy - i))
    # up
    for i in range(1, K + 1):
        if cx - i <= -1 or C[cx - i][cy] == "@":
            break
        if ans[cx - i][cy] <= nc - 1:
            break
        if ans[cx - i][cy] <= nc:
            continue
        ans[cx - i][cy] = nc
        q.append((cx - i, cy))
    # down
    for i in range(1, K + 1):
        if cx + i >= H or C[cx + i][cy] == "@":
            break
        if ans[cx + i][cy] <= nc - 1:
            break
        if ans[cx + i][cy] <= nc:
            continue
        ans[cx + i][cy] = nc
        q.append((cx + i, cy))

if ans[X2 - 1][Y2 - 1] == float("inf"):
    print(-1)
else:
    print(ans[X2 - 1][Y2 - 1])


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
typedef vector<string> vecst;

int main(){
    ll W, H, N;
    cin >> W >> H >> N;
    ll xmax = W, xmin = 0, ymax = H, ymin = 0;
    for(ll i = 0; i < N; i++){
        ll x, y, a;
        cin >> x >> y >> a;
        if(a == 1 && xmin < x) xmin = x;
        if(a == 2 && xmax > x) xmax = x;
        if(a == 3 && ymin < y) ymin = y;
        if(a == 4 && ymax > y) ymax = y;
    }
    ll lenx = xmax - xmin, leny = ymax - ymin;
    if(lenx < 0 || leny < 0) cout << 0 << endl;
    else cout << lenx * leny << endl;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int getDigit(int x) {
  int cnt = 0;
  while (x > 0) {
    x /= 10;
    cnt++;
  }
  return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;  cin >> n;
    int ans = 0;
    FOR(i, 1, n + 1) {
      if (getDigit(i) % 2 == 1) {
        ans++;
      }
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

enum {
     MAX_BUFFER = 16,
     LENGTH_MAP = 8
};

int main(void)
{
     char map[LENGTH_MAP][LENGTH_MAP + 1];
     int px, py;
     int i, j;
     bool flag;

     while (scanf("%s", map[0]) != EOF) {

          flag = false;
          
          for (i = 1; i < 8; i++) {
               scanf("%s", map[i]);
          }

          for (i = 0; i < 8; i++) {
               for (j = 0; j < 8; j++) {
                    if (map[i][j] == '1') {
                         py = i;
                         px = j;
                         flag = true;
                         break;
                    }
               }
               if (flag == true) break;
          }

          if (map[py][px + 1] == '1') {
               if (map[py][px + 2] == '1') {
                    puts("C");
               } else {
                    if (map[py + 1][px - 1] == '1') {
                         puts("G");
                    } else if (map[py + 1][px] == '1') {
                         puts("A");
                    } else {
                         puts("E");
                    }
               }
          } else {
               if (map[py + 3][px] == '1') {
                    puts("B");
               } else {
                    if (map[py + 1][px - 1] == '1') {
                         puts("D");
                    } else {
                         puts("F");
                    }
               }
          }
     }

     return 0;
}               

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1e+7
int main()
{
    int n;
    cin>>n;
    int count=0;
    int flag=0;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
        if(a==b)
        {
            count++;
            if(count==3)
            {
                flag=1;
            }
        }
        else{
            count=0;
        }
    }
    if(flag==0)
    {
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

struct fin {
	vector<int> T;
	fin() = default;
	fin(int N) : T(N+10, OVER9000) {}

	int lastone(int x) {return x&(x^(x-1));}

	void put(int pos, int val) {
		for(int i = pos+1; i < (int)T.size(); i += lastone(i))
			T[i] = min(T[i], val);
	}

	int get(int pos) {
		int ret = OVER9000;
		for(int i = pos+1; i > 0; i -= lastone(i)) ret = min(ret, T[i]);
		return ret;
	}
};

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, MX = 1000;
	cin >> N;
	vector<int> A(N);
	vector<int> sum[2] = {vector<int>(N+1, 0), vector<int>(N+1, 0)};
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		sum[1-i%2][i+1] = sum[1-i%2][i];
		sum[i%2][i+1] = sum[i%2][i] + A[i];
	}
	if(N%2 == 0) {
		cout << max(sum[0][N], sum[1][N]) << " " << min(sum[0][N], sum[1][N]) << "\n";
		return 0;
	}
	A.push_back(0);
	int ans_l = abs(sum[0][N]-sum[1][N]), ans_r = abs(sum[0][N]-sum[1][N])+2*MX;
	map<int, int> X;
	X[sum[1][N]-sum[0][N]] = 0;
	for(int i = 2; i < N; i += 2) X[sum[1][i+1]-sum[0][i]] = 0;
	int x_mx = 0;
	ALL_THE(X, it) it->ss = x_mx++;
	vector<int> X_id(N), X_val(x_mx+1, OVER9000);
	ALL_THE(X, it) X_val[it->ss] = it->ff;
	for(int i = 2; i < N; i += 2) X_id[i] = X[sum[1][i+1]-sum[0][i]];
	while(ans_r-ans_l > 1) {
		int ans_m = (ans_l + ans_r) / 2;
		vector<int> valid(N+2, 0);
		valid[0] = 1;
		fin Fl(x_mx), Fr(x_mx);
		for(int i = 2; i <= N+1; i += 2) {
			int d = sum[0][i-1]-sum[1][i-2]+sum[1][1];
			if(sum[1][N]-sum[0][N]+2*d >= ans_m && valid[0] && d < A[i-1]) valid[i] = 1;
			auto it = X.lower_bound((ans_m+sum[0][N]-sum[1][N]+1)/2+sum[1][i-2]-sum[0][i-1]);
			int id = x_mx;
			if(it != X.end()) id = it->ss;
			if(Fr.get(x_mx-id) < A[i-1]+sum[1][i-2]-sum[0][i-1]) valid[i] = 1;
			else if(Fl.get(x_mx-id) < sum[1][i-2]-sum[0][i-1]) valid[i] = 1;
			if(i < N && valid[i]) {
				Fl.put(x_mx-X_id[i], sum[1][i+1]-sum[0][i]-A[i-1]);
				Fr.put(x_mx-X_id[i], sum[1][i+1]-sum[0][i]);
			}
		}
		if(valid[N+1]) ans_l = ans_m;
		else ans_r = ans_m;
	}
	cout << (ans_l+sum[0][N]+sum[1][N])/2 << " " << (-ans_l+sum[0][N]+sum[1][N])/2 << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 14836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	//std::ifstream in("01-08.txt");
  	//std::cin.rdbuf(in.rdbuf());

	ll n, k; cin >> n >> k;
	ll a[n]; zep(i, 0, n){cin >> a[i];}

	//if(n == 1){if(k%2)cout << a[0]; cout << endl; return 0;}

	ll nx[n], nxi[200010];
	memset(nx, -1, sizeof(nx));
	memset(nxi, -1, sizeof(nxi));

	zep(t, 0, 2){
		rrep(i, n-1, 0){
			nx[i] = nxi[a[i]];
			nxi[a[i]] = i;
		}
	}
	
	ll m = 1;
	ll at = 0;
	do{
		if(at >= nx[at])m++;
		at = (nx[at] + 1)%n;
		//cout << at << " " << m << " " << nx[at] << endl;
	}while(at != 0);
	
	k %= m;
	if(k == 0){cout << endl; return 0;}

	at = 0;
	while(k > 1 || at < nx[at]){
		if(at >= nx[at])k--;
		at = nx[at] + 1;
	}
	
	deque<ll> s;
	bool use[200010]; memset(use, 0, sizeof(use));
	zep(i, at, n){
		if(use[a[i]]){
			while(use[a[i]]){
				use[s.back()] = false;
				s.pop_back();
			}
		}else{
			s.push_back(a[i]);
			use[a[i]] = true;
		}
	}

	for(auto it = s.begin(); it != s.end(); it++){
		cout << *it << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 8064
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	r1,c1,r2,c2=MI()
	m=10**9+7

	ff=[1]

	for i in range(1,2*10**6+5):
		ff.append(ff[-1]*i%m)


	def f(r,c):
		return (ff[r+c]*pow(ff[r],m-2,m)*pow(ff[c],m-2,m))%m

	ans=0
	ans+=f(r2+1,c2+1)
	ans+=f(r1,c1)
	ans-=f(r2+1,c1)
	ans-=f(r1,c2+1)

	print(ans%m)



if __name__ == "__main__":
	main()


Measured memory_bytes: 88376
import java.util.*;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String str = sc.next();
        int N = sc.nextInt();
        int[] h = new int[N];
        int count = 0;
        int max = 0;
        
        for(int i=0; i<N; i++){
            h[i] = sc.nextInt();
            if(i>0){
                if(h[i-1] >= h[i]){
                    count++;
                    if(max < count){
                        max = count;
                    }
                }else{
                    count = 0;
                }
            }
        }
        
        System.out.println(max);
        
    }
}


Measured memory_bytes: 49124