akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 100000
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

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

int modp(int a,int m,int n)
{
    n=n%(m-1);
    a=a%m;
    int res=1;
    while(n>0)
    {
        if(n&1) res=(res*a)%m;
        a=(a*a)%m;
        n>>=1;
    }
    return res;
}



void solve()
{
    int t,n,m,i,k,l,r,u,v,w,j,s,pos,sum=0,flag=0,count=0;
    string S,T,U;
    // int h1,m1,h2,m2;
    cin>>S;
    n=sz(S);
    rep(i,0,n)
    {
        if(S[i]!='?') 
        {
            cout<<S[i];
        }
        else
        {
            // if(i==0)
            // {
            //     cout<<"D";
            // }
            // else
            // {
            //     if(S[i-1]=='P')
            //     {
            //         cout<<"D";
            //     }
            //     else if(S[i+1]=='D')
            //     {
            //         cout<<"P";
            //     }
            // }
            cout<<"D";
        }
    }
}



signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  bool flag = true;
  int num = 0;
  string c[3];

  for (int i = 0; i < 3; ++i) {
    cin >> c[i];
  }

  for (int i = 0; i < 3; ++i) {
    cout << c[i][i];
  }
  cout << endl;

  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N, c = 0, tmp;
    int A[101];

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N - 1; j++){
            if(A[j] > A[j + 1]){
                tmp = A[j];
                A[j] = A[j + 1];
                A[j + 1] = tmp;
                c++;
            }  
        }
    }
    for(int i = 0; i < N; i++){
        cout << A[i];
        if(i == N - 1) cout << endl;
        else cout << " "; 
    }
    cout << c << endl;
}



Measured memory_bytes: 3084
n = int(input())
p_list = input().split()
p_list = map(int,p_list)
p_list = sorted(p_list,reverse=True)
ans_list = []
ans = 0
for i in range(0,len(p_list)):
  if i!=0:
    ans_list.append(p_list[i])
    ans_list.append(p_list[i])
  else:
    ans_list.append(p_list[i])
for i in range(0,n-1):
	ans += int(ans_list[i])
print(ans)

Measured memory_bytes: 31440
S=str(input())
l=len(S)
key='keyence'
if S=='keyence':
  print('YES')
  exit()
else:  
  for i in range(1,l):
    for j in range(l):
      if S[0:j]+S[i+j:l]==key:
        print('YES')
        exit()
print('NO')

Measured memory_bytes: 3060
if __name__ == '__main__':
	a,op,b = map(str, input().split())
	while op != '?':
		if op == '+':
			print("%d" % (int(a)+int(b)))
		elif op == '-':
			print("%d" % (int(a)-int(b)))
		elif op == '*':
			print("%d" % (int(a)*int(b)))
		elif op == '/':
			print("%d" % (int(a)/int(b)))
		a,op,b = map(str, input().split())


Measured memory_bytes: 5600
#include<stdio.h>
#include<stdlib.h>
int main(){
  int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
  int n;
  int l[2000];
  int ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  qsort(l, n, sizeof(int), compare_int);
  for(int i=2;i<n;i++){//maxの辺
    for(int j=0;j<i-1;j++){//下の候補
      for(int k=j+1;k<i;k++){//範囲増やすマン
        if(l[j]+l[k]>l[i]){
        ans=ans+i-k;
        //printf("i=%d j=%d ans=%d\n",i,j,ans);
        break;
        }
      }
    }
  }
  
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll n, m;
vector<ll> a;
vector<ld> p;
vector<ll> dp[(1ll << 20)];

ll lcm(ll bit) {
	if(bit == 0) return INF * INF + INF;
	bitset<31> bi(bit);
	vector<ll> v;
	REP(i,n) {
		if(bi[i]) v.pb(a[i]);
	}
	__int128 g = v[0];
	FOR(i,1,v.size()) {
		ll tmp = gcd(g, v[i]);
		g = tmp * (g / tmp) * (v[i] / tmp);
		if(g > INF * INF) return INF * INF + INF;
	}
	return g;
}

ld solve() {
	cin >> n >> m;
	a.resize(n); p.resize(n);
	REP(i,n) cin >> a[i]; REP(i,n) cin >> p[i]; REP(i,n) p[i] /= 100;
	ld ans = 0;
	FOR(bit,1,(1 << n)) {
		bitset<31> bi(bit);
		ld prob = 1;
		REP(i,n) {
			if(bi[i]) prob *= p[i];
			else prob *= (1 - p[i]);
		}
		ll g = lcm(bit);
		ll crt = 0;
		if(bi.count() % 2) crt = m / g;
		else crt = -(m / g);
		ll sum = 0;
		REP(i,n) {
			if(bi[i]) {
				if(sum != 0) {
					dp[bit].emplace_back(crt + dp[bit ^ (1 << i)][sum - 1]);
				} else {
					ll _g = 0;
					if(!(bi.count() % 2)) _g = (m / lcm(bit ^ (1 << i)));
					else _g = -(m / lcm(bit ^ (1 << i)));
					dp[bit].emplace_back(crt + _g);
				}
				crt = dp[bit].back();
				sum++;
			}
		}
		ans += prob * crt;
		dp[bit].shrink_to_fit();
	}
	return ans;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(39) << solve() << endl;
	return 0;
}



Measured memory_bytes: 122884
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
    class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
		public void Solve(ConsoleInput cin) {
			var num = new Dictionary<char, int>() 
			{ { 'I', 1 }, { 'V', 5 }, { 'X', 10 }, { 'L', 50 }, { 'C', 100 }, { 'D', 500 }, { 'M', 1000 } };
			while(true){
				int last =0;
				int sum = 0;
				var line = cin.ReadLine;
				if(line == null || line == "") break;
				foreach(var c in line) {
					var x = num[c];
					if(last < x) sum -= last;
					else sum += last;
					last = x;
				}
				sum += last;
				Console.WriteLine(sum);
			}
		}

	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
	}

}



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

int main(){
	string key;
	int n;
	int ans = 0;
	cin >> key >> n;
	for(int i=0 ; i<n ; ++i ){
		string s;
		cin >> s;
		s += s.substr(0,key.size()-1);
		int pos = 0;
		bool flag;
		flag = ( s.find(key,0) != string::npos)? true : false;
		if( flag )
			ans++;
	}
	cout << ans << endl;
}

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

int main() {
    while (true) {
        int n, k;
        cin >> n >> k;
        if (!n & !k) break;
        int a[10], use[10] = {};
        for (int i = 0; i < n; ++i) cin >> a[i];
        sort(a, a + n);
        for (int i = 0; i < k; ++i) use[i] = 1;
        vector<string> v;
        do {
            int choise[k];
            for (int i = 0, j = 0; i < n; ++i) {
                if (use[i]) choise[j++] = a[i];
            }
            do {
                string s;
                for (int i = 0; i < k; ++i) s += to_string(choise[i]);
                bool can = true;
                for (int i = 0; i < v.size(); ++i) {
                    if (s == v[i]) {
                        can = false;
                        break;
                    }
                }
                if (can) v.push_back(s);
            } while (next_permutation(choise, choise + k));
        } while (prev_permutation(use, use + n));
        cout << v.size() << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3428
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, List<String>> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String S = sc.next();
            String top = S.substring(0,1);
            if (top.matches("[MARCH]")) {
                if (map.containsKey(top)) {
                    map.get(top).add(S);
                } else {
                    List<String> list = new ArrayList<String>();
                    list.add(S);
                    map.put(top, list);                    
                }
            }
        }
        List<String> keys = new ArrayList<>(map.keySet());
        long count = 0;
        if (keys.size() < 3) {
            System.out.println(0);
        } else {
            for (int i = 0; i < keys.size()-2; i++) {
                String key1 = keys.get(i);
                for (int j = i+1; j < keys.size()-1; j++) {
                    String key2 = keys.get(j);
                    for (int k = j+1; k < keys.size(); k++) {
                        String key3 = keys.get(k);
                        long size1 = map.get(key1).size();
                        long size2 = map.get(key2).size();
                        long size3 = map.get(key3).size();
                        count += size1*size2*size3;
                    }
                }
            }
            System.out.println(count);
        }
    }    
}


Measured memory_bytes: 65420
object Main extends App {
  val sr = new StdinReader
  val h, w, d = sr.nextInt
  val table: Map[Int, (Int, Int)] = (for {
        y <- 0 until h
        x <- 0 until w
      } yield sr.nextInt -> (x, y)).toMap

  val tbl = new Array[Int](h * w + 1)
  (1 to d).flatMap{dd =>
    ((dd + d) to (h * w) by d).map {p => 
      val lPos = table(p - d)
      val rPos = table(p)
      val mp = Math.abs(lPos._1 - rPos._1) + Math.abs(lPos._2 - rPos._2)
      tbl(p) = mp + tbl(p - d)
    }
  }

  println(
    (1 to sr.nextInt).map{i =>
      val l, r = sr.nextInt
      tbl(r) - tbl(l)
    }.mkString("\n"))
}


class StdinReader {
  val is = System.in
  val buffer = new Array[Byte](1024 * 1024)
  var size = 0
  var pos = 0

  private def readByte: Byte = {
    if (pos >= size) {
      pos = 0;
      size = is.read(buffer);
    }
    if (size < 0) -1
    else {
      val ret = buffer(pos)
      pos += 1
      ret
    }
  }

  // support single byte char only
  def next: String = {
    def r(sb: StringBuilder, reading: Boolean): String = {
      readByte match {
        case b if ('!' <= b && b <= '~') => r(sb.append(b.asInstanceOf[Char]), true)
        case _ => if (reading) sb.toString else r(sb, false)
      }
    }
    r(new StringBuilder, false)
  }

  def nextInt: Int = Integer.parseInt(next)
  def nextInt2: Int = {
    @scala.annotation.tailrec
    def r(i: Int, reading: Boolean): Int = {
      readByte match {
        case '-' => r(i * -1, true)
        case b if '0' <= b && b <= '9' => r(i * 10 + (b - '0'), true)
        case _ => if (reading) i else r(i, false)
      }
    }
    r(0, false)
  }
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

ll n,K;
ll a[300000],b[300000];

bool C(ll t){
	ll cnt=0;
	rep(i,n){
		ll A=t/b[i];
		cnt+=max(0LL,a[i]-A);
	}
	return cnt<=K;
}
int main(){
	cin>>n>>K;
	rep(i,n)scanf("%lld",&a[i]);
	rep(i,n)scanf("%lld",&b[i]);
	sort(a,a+n);
	sort(b,b+n,greater<>());
	ll ok=LLONG_MAX/2,ng=-1;
	while(ok-ng>1){
		ll t=(ok+ng)/2;
		if(C(t))ok=t;
		else ng=t;
	}
	cout<<ok<<endl;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cnt = 0;
    while(a > 0 && c > 0){
        if(cnt%2 == 0){
            c -= b;
            cnt++;
        }
        else{
            a -= d;
            cnt++;
        }
    }
    if(a > 0)   cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int a[100001];
vector<vector<int> > v(100001);
int fn(int n)
{
	if(a[n] != -1) {
		return a[n];
	}
	int max = 0;
	for (int i = 0; i < v[n].size(); ++i)
	{
		int z = fn(v[n][i]);
		if(max < z) max = z;
	}
	a[n] = max + 1;
	return max + 1;
	
}

int main()
{
	int n,m;
	cin>>n>>m;
	memset(a,-1,sizeof(a));
	for (int i = 0; i < m; ++i)
	{
		int a,b;
		cin>>a>>b;
		v[a - 1].push_back(b - 1);
	}
	for (int i = 0; i < n; ++i)
	{
		fn(i);
	}
	int max = 0;
	for (int i = 0; i < n; ++i)
	{
		if(max < a[i]) max = a[i]; 
	}
	cout<<max - 1<<endl;
	return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

const int N = 10;
int x[N], y[N];
double d[N][N];

double dist(int i, int j) {
	double xx = x[i] - x[j];
	double yy = y[i] - y[j];
	return sqrt(xx * xx + yy * yy);
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d%d", &x[i], &y[i]);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			d[i][j] = dist(i, j);
		}
	}

	vi p(n);
	for (int i = 0; i < n; i++) p[i] = i;
	double total = 0;
	do {
		double path = 0;
		for (int i = 1; i < n; i++) path += d[p[i-1]][p[i]];
		total += path;
	} while (next_permutation(all(p)));

	int f = 1;
	while (n > 0) {
		f *= n;
		n--;
	}
	total /= (double)f;
	printf("%.10f\n", total);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/


int main(){
  int n,m,t;
  int a;
  int time[20005];
  rep(i,20005)time[i]=0;
  cin>>n>>m>>t;
  rep(i,n){cin>>a;time[a-m]+=1;time[a+m]-=1;}
  for(int i=1;i<=t;i++)time[i]+=time[i-1];
  int ans=0;
  for(int i=0;i<t;i++)if(time[i]==0)ans++;
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3176
#include <stdio.h>

char *S[]={"No","Yes"};
char f;

int n, m, o;
int main(){
  scanf("%d", &n);
  m=n;
  while(m){
  	o+=m%10;
  	m=m/10;
  }
  f = (n%o==0);
  puts(S[f]);
}


Measured memory_bytes: 128
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int main(){
    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        int y,m,d;
        cin >> y >> m >>d;
        int p= y % 3;
        if (p==1) {
            y+=2;
        }
        if (p==2) {
            y+=1;
        }
        int yy = ((999-y)/3)*((19*5+20*5)*2+20*10);
        int mm = 0;
        if (p==1) {
            for (int j=m+1; j<=10; j++) {
                if (j%2==0) {
                    mm+=19;
                }else{
                    mm+=20;
                }
            }
            mm += (19*5+20*5+20*10);
            mm += (20-d+1);
            if(m%2==0) mm--;
        }
        if (p==2) {
            for (int j=m; j<=10; j++) {
                if (j%2==0) {
                    mm+=19;
                }else{
                    mm+=20;
                }
            }
            mm += 20*10;
            mm -= (d-1);
        }
        if (p==0) {
            for (int j=m; j<=10; j++) {
                mm+=20;
            }
            mm -= (d-1);
        }
        cout << yy+mm <<endl;
    }
}

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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;

const long long max_n = 1011, inf = 1000111222;

int a[max_n];

int main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	pair<int, int> mn = {a[0], 0};
	for (int i = 0; i < n; ++i) {
		if (abs(mn.F * n - sum) > abs(a[i] * n - sum)) {
			mn = {a[i], i};
		}
	}
	cout << mn.S << endl;
	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
    exit()

ans = min(H, W)
for w1 in [W // 3, W // 3 + 1]:
    w23 = W - w1
    for h2 in [H // 2, H // 2 + 1]:
        h3 = H - h2

        S1 = w1 * H
        S2 = h2 * w23
        S3 = h3 * w23

        ans = min(ans, max(S1, S2, S3) - min(S1, S2, S3))

for h1 in [H // 3, H // 3 + 1]:
    h23 = H - h1
    for w2 in [W // 2, W // 2 + 1]:
        w3 = W - w2

        S1 = h1 * W
        S2 = w2 * h23
        S3 = w3 * h23

        ans = min(ans, max(S1, S2, S3) - min(S1, S2, S3))

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int dig(int n){
	int digsum = 0;
	while(n > 0){
		digsum += (n % 10);
		n /= 10;
	}
	return digsum;
}

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0;
	for(int i = 1; i <= n; i++){
		if(dig(i) >= a && dig(i) <= b) sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	char c;
	char p = 'A';
	for (char a, b; cin >> a >> c >> b; ) {
		if (p == a) p = b;
		else if(p == b) p = a; 
	}
	cout << p << endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <cstring>

#define ll long long
#define pb push_back
	#define forn(i,n) for (ll i=0; i<(n); ++i)
using namespace std; 

void solve()
	{
		string A,B;
		cin>>A>>B;
		ll n=A.length();
		ll m=B.length();
		ll dp[n+1][m+1];
		memset(dp,0, sizeof(dp));
		forn(i,n+1)
		{
			forn(j,m+1)
			{
				if(i==0||j==0)
					dp[i][j]=0;
				else if(A[i-1]==B[j-1])
					dp[i][j]=dp[i-1][j-1]+1;
				else
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
		ll ind=dp[n][m];
		string ans;
		ll i=n,j=m;
		while(i>0&&j>0)
		{
			if(A[i-1]==B[j-1])
			{
				ans.pb(A[i-1]);
				i--;j--;ind--;
			}
			else if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
		reverse(ans.begin(), ans.end());
		cout<<ans<<endl;
		//cout<<dp[n][m]<<endl;
	}

int main(){
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
 return 0;
}

Measured memory_bytes: 73440
import sys

while True:
	xy=sys.stdin.readline()
	nums=xy.split( ' ' )
	for i in range( len( nums) ):
		nums[i] = int( nums[i] )
	if nums[0] == 0 and nums[1] == 0:
		break
	else:
		if nums[1] < nums[0]:
			t=nums[0]
			nums[0]=nums[1]
			nums[1]=t
		print( "{} {}".format( nums[0], nums[1] ) )

Measured memory_bytes: 6720
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  int c, d, e;
  c = d = e = 0;
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if(x <= a) c++;
    else if(x <= b) d++;
    else e++;
  }
  cout << (min({c,d,e})) << endl;
  return 0;
}


Measured memory_bytes: 256
object Main {
  trait Monoid[A]{
    def op(a1: A, a2: A): A
    def zero: A
  }

  class SegmentTree[A](val numOfNode: Int, val M: Monoid[A]){

    sealed trait Tree{ val value: A }
    case object Leaf extends Tree{ val value: A = M.zero }
    case class Node(value: A, left: Tree, right: Tree) extends Tree
    object Node {
        def apply(value: A) = new Node(value, Leaf, Leaf)
        def apply(l: Tree, r: Tree) = new Node(M.op(l.value,r.value),l,r)
    }

    private val empty: Node = Node(M.zero,Leaf,Leaf)
    private[this] var root: Tree = empty

    private def updateRec(id: Int, x:A, l: Int = 0, r: Int = numOfNode, t: Tree = root): Tree = {
        def branch(now: Node): Node = {
            val m = (l + r)>>1
            if(r-l<=1)Node(x)
            else if(id < m)Node(updateRec(id,x,l,m, now.left), now.right)
            else Node(now.left,updateRec(id,x,m,r,now.right))
        }
        t match {
            case now: Node => branch(now)
            case _ => branch(empty)
        }
    }

    def update(id: Int, x: A): Unit = {
        root = updateRec(id, x)
    }

    def query(a: Int, b: Int, l: Int = 0, r: Int = numOfNode, t: Tree = root): A = {
      val m = (l + r)/2
      t match {
        case now: Node =>
          if(b<=l || r<=a)M.zero
          else if(a<=l && r<=b)now.value
          else M.op(query(a,b,l,m,now.left),query(a,b,m,r,now.right))
        case _ => M.zero
      }
    }
  }

  def main(args: Array[String]): Unit = {
    val line = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val n = line(0)
    val q = line(1)
    val m = new Monoid[Int]{
        def op(a1: Int, a2: Int): Int = a1 min a2
        def zero: Int = Int.MaxValue
    }

    val segtree = new SegmentTree[Int](n,m)

    for(i <- 1 to q){
        val input = scala.io.StdIn.readLine.split(" ").map(_.toInt)
        val x = input(1)
        val y = input(2)
        if(input(0)==0)segtree.update(x,y)
        else println(segtree.query(x,y+1))
    }
  }
}

Measured memory_bytes: 193144
#include <stdio.h>

int main(void)
{
  int n,q,m,i,j,sum,max,ans,date[50][50];

  for(;;){
    scanf("%d %d", &n, &q);
    if(!(n|q)) break;

    int con[101]={0};
    max=0;
    sum=0;
    ans=500;
    for(i=0;i<n;i++){
      scanf("%d", &m);
      for(j=0;j<m;j++){
	scanf("%d", &date[i][j]);
	con[date[i][j]]++;
	if(date[i][j]>max) max=date[i][j];
      }
    }
    for(i=max;i>0;i--){
      if(con[i]>=sum){
	sum=con[i];
	ans=i;
      }
    }
    if(sum>=q) printf("%d\n", ans);
    if(sum<q) printf("0\n");
  }

  return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s,s2;
  rep(i,n){
    ll k = 0;
    cin >> s;
    cin >> s2;
    k = s2.size();
    for(int j = s.size()-1; j >=0 ; --j){
      if(s[j] == 'C'){
        s2 += s2;
        s2 = s2.substr(1,k);
      }
      else if(s[j] == 'J'){
        s2 += s2;
        s2 = s2.substr(k-1,k);
      }
      else if(s[j] == 'E'){
        if(s2.size() % 2 == 0)
          rotate(s2.begin(),s2.begin()+s2.size()/2,s2.end());
        else{
          s2 = s2.substr(s2.size()/2+1) + s2[s2.size()/2] + s2.substr(0,s2.size()/2);
        }
      }
      else if(s[j] == 'A'){
        reverse(all(s2));
      }
      else if(s[j] == 'M'){
        rep(l,s2.size()){
          if(isdigit(s2[l])){
            if(s2[l] != '9'){
              s2[l]++;
            }
            else{
              s2[l] = '0';
            }
          }
        }
      }
      else if(s[j] == 'P'){
        rep(l,s2.size()){
          if(isdigit(s2[l])){
            if(s2[l] != '0'){
              s2[l]--;
            }
            else{
              s2[l] = '9';
            }
          }
        }
      }
    }
    cout << s2 << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> a >> b;
	if (a == 1)a = 14;

	if (b == 1)b = 14;
	if (a < b)cout << "Bob" << rt;
	else if (a>b)cout << "Alice" << rt;
	else cout << "Draw" << rt;
	please AC;
}

Measured memory_bytes: 256
from itertools import accumulate
def run_length(data, init=''):
    length = []
    tmp = init
    cnt = 0
    for c in data:
        if tmp != c:
            length.append(cnt)
            cnt = 0
        tmp = c
        cnt += 1
    length.append(cnt)
    return length

s = input()
x = run_length(s)
acc = list(accumulate(x))
# print(x)
# print(acc)
# print(alf)
if len(x) == 2:
    print(1, 2)
    exit()
for i in range(1,len(acc)):
    if x[i] > 1:
        print(acc[i-1]+1, acc[i])
        break
else:
    for i in range(1,len(s)-1):
        if s[i-1] == s[i+1]:
            print(i, i+2)
            break
    else:
        print(-1, -1)

Measured memory_bytes: 7932
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, k = inintm()
P = inintl()

s = [0]*(n+1)
ans = 0

for i in range(n):
    s[i+1] = s[i]+(1 + (P[i]-1)*0.5)

for i in range(n-k+1):
    if s[i+k] - s[i] > ans:
        ans = s[i+k] - s[i]

print(ans)

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n;
    string s,t;
    cin >>n >>s >>t;

    int ans=2*n;
    for(int i=1; i<=n; ++i)
    {
        if(t.substr(0,i)==s.substr(n-i)) ans=min(ans,2*n-i);
    }

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


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int h[n];
  for(int i = 0; i<n ; i++){
    cin >> h[i];
  }
  int biggest = 0;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(h[i] >= biggest){
      cnt++;
      biggest = h[i];
    }
  }
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
    int n,k,q;
    cin >> n>>k>>q;
    int i,a[n];
    for(i=0;i<n;i++){
        a[i]=k-q;
    }
    int z;
    for(i=0;i<q;i++){
        cin >>z;
        a[z-1]+=1;
    }
    for(i=0;i<n;i++){
        if(a[i]>0)
        cout << "Yes"<< endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

long long int fib_memo[86];
long long int fib(int n) {
  int i;
  fib_memo[0] = 2;
  fib_memo[1] = 1;
  for (i = 2; i <= n; ++i) {
    fib_memo[i] = fib_memo[i - 1] + fib_memo[i - 2];
  }
  return fib_memo[n];
}

int main() {
  int num;
  scanf("%d", &num);
  printf("%lld\n", fib(num));
  return 0;
}


Measured memory_bytes: 256
/*
      author : Nishikawa
      created: 05.08.2020 15:00:14
*/

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


int main(){
    int H,W,K;
    cin >> H >> W >> K;
    vector<vector<char> > vv(H,vector<char>(W));
    vector<vector<char> > vv_tmp(H,vector<char>(W));
    rep(i,H)rep(j,W) cin >> vv[i][j];
//    rep(i,H){rep(j,W){ cout << vv[i][j];} cout << endl;}

    int tot=0;
    int _H=1,_W=1;
    for(int i=0; i<H; i++){
        _H*=2;
    }
    for(int i=0; i<W; i++){
        _W*=2;
    }

    for(int i=0; i<_H; i++){
        for(int j=0; j<_W; j++){
            rep(i,H)rep(j,W) vv_tmp[i][j]=vv[i][j];
            for(int k=0; k<H; k++){
                if(i>>k & 1){
                    for(int l=0; l<W; l++){
                        vv_tmp[k][l]='r';
                    }
                }
            }
            for(int k=0; k<W; k++){
                if(j>>k & 1){
                    for(int l=0; l<H; l++){
                        vv_tmp[l][k]='r';
                    }
                }
            }
            int count=0;
            for(int k=0; k<H; k++){
                for(int l=0; l<W; l++){
                    if(vv_tmp[k][l]=='#') count++;
                }
            }
            if(count==K) {
                tot++;
                /*rep(i,H){rep(j,W){ 
                    cout << vv_tmp[i][j];
                } 
                cout << endl;}*/
            }
        }
    }
    cout << tot << endl;
    
    return 0;
}

Measured memory_bytes: 3588
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int H=sc.nextInt();
        int W=sc.nextInt();
        char[][] a=new char[H][W];
        for (int i = 0; i < H; i++) {
            String s=sc.next();
            for (int j = 0; j < W; j++) {
                a[i][j]=s.charAt(j);
            }
        }
        for (int i = 0; i < H; i++) {
            int c=0;
            for (int j = 0; j < W; j++) {
                if(a[i][j]=='.')c++;
            }
            if(c==W){
                for (int j = 0; j < W; j++) {
                    a[i][j]='-';
                }
            }
        }
        for (int i = 0; i < W; i++) {
            int c=0;
            for (int j = 0; j < H; j++) {
                if(a[j][i]=='.'||a[j][i]=='-')c++;
            }
            if(c==H){
                for (int j = 0; j <H; j++) {
                    a[j][i]='-';
                }
            }
        }
        String[] ans=new String[H];
        for (int i = 0; i <H; i++) {
            ans[i]="";
        }
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                ans[i]+=Character.toString(a[i][j]);
            }
        }
        for (int i = 0; i < H; i++) {
            ans[i]=ans[i].replaceAll("-", "");
        }
        for (int i = 0; i < H; i++) {
            if(!ans[i].equals(""))out.println(ans[i]);
        }
    }
    static long power(long x,int n){
        long mod=1000000007;
        long ans=1;
        while (n>0) {
            if((n&1)==1){
                ans=(ans*x)%mod;
            }
            x=(x*x)%mod;
            n>>=1;
        }
        return ans;
    }
    //最大公約数
    static int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
//※最小公倍数はa*b/gcd(a,b)である
}


Measured memory_bytes: 30448
// https://atcoder.jp/contests/tdpc/tasks/tdpc_iwi

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

void add_mod(ll& t, ll& v) {
	t = (t + v) % 1000000007ll;
}

int main (int argc, char* argv[]) {
	ll n, m;
	cin >> n >> m;
	n++;
	vector<bool> broken(n);
	for (ll i = 0; i < m; i++) {
		ll broken_pos;
		cin >> broken_pos;
		broken[broken_pos] = true;
	}

	vector<ll> steps(n);
	steps[0] = 1;
	for (ll i = 0; i < n - 1; i++) {
		if (!broken[i + 1]) {
			add_mod(steps[i + 1], steps[i]);
		}
		if (i + 2 < n && !broken[i + 2]) {
			add_mod(steps[i + 2], steps[i]);
		}
	}
	cout << steps.back() << endl;
}


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

int main(){
  int K, X;
  cin >> K >> X;

  int max_idx = 0;
  if (X + K - 1 >= 1000000){
    max_idx = 1000000;
  } else{
    max_idx = X + K - 1;
  }

  int min_idx = 0;
  if (X - K + 1 <= -1000000){
    min_idx = -1000000;
  } else{
    min_idx = X - K + 1;
  }

  for (int i = min_idx; i<= max_idx; i++){
    cout << i << " ";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  char S[110000];
  int res=0;
  cin >> S;

  char prev=S[0];
  rep(i,strlen(S)){
    if(prev!=S[i]) res++;
    prev = S[i];
  }

  cout << res << endl;
}

Measured memory_bytes: 384
/// However long the night,
///     The dawn will break
/// ICPC next year

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;

int n ,arr[N] ,cnt ,prv ,best ;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i) scanf("%d",arr+i);
    for(int i=n-1;i>=0;--i){
        if(arr[i]>=prv) ++cnt ;
        else cnt = 1 ;
        prv = arr[i] ;
        best = max(best,cnt);
    }
    cout << best-1;
    return 0;
}


Measured memory_bytes: 640
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#define MOD 100000007LL
#define INF 100000000LL
#define MAX 100001
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
ll C[51][51];
void comb(int n){
    for(int i=0;i<=n;i++){
        for(int j=0;j<=i;j++){
            if(j==0||j==i){
                C[i][j]=1LL;
            }else{
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}
int main() {    
    int n,a,b;
    cin>>n>>a>>b;
    ll v[51];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    sort(v,v+n,greater<ll>());
    ll ans=0;
    for(int i=0;i<a;i++){
        ans+=v[i];
    }
    cout<<fixed<<setprecision(7)<<(double)ans/a<<endl;
    comb(n);
    int x=0;
    int y=0;
    for(int i=0;i<n;i++){
        if(v[a-1]==v[i]){
            x++;
            if(i<a){
                y++;
            }
        }
    }
    ll c=0LL;
    if(v[0]==v[a-1]){
        for(int i=a;i<=min(b,x);i++){
            c+=C[x][i];
        }
    }else{
        c+=C[x][y];
    }
    cout<<c<<endl;
}

                           


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int a,b,ta,tb,tc;
	while(cin >> a>>b){
		ta=a;
		tb=b;
		while(1){
			if(ta<tb){
				tc=ta;
				ta=tb;
				tb=tc;
			}
			tc=ta%tb;
			if(tc==0)break;
			ta=tb;
			tb=tc;
		}
		cout << tb<< " "<< a/tb*b <<endl;
	}
	return 0;
}

Measured memory_bytes: 2936
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CDistinctOrNot {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        set<int> s;
        bool ok = true;
        REP(i, N) {
            int a;
            cin >> a;
            if (s.count(a)) ok = false;
            s.insert(a);
        }
        cout << (ok ? "YES" : "NO") << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CDistinctOrNot solver;
    solver.solve(in, out);
    return 0;
}


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

#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define _parr(a, n) for(int __i = 0; __i < (int )n; __i++) cout << a[__i] << ' '; cout << '\n'
#define fr(i, p, n) for(int i = (int )p; i < (int )n; i++)
#define frn(i, p, n) for(int i = (int )p; i <= (int )n; i++)
#define rev(i, n, p) for(int i = (int )n; i >= (int )p; i--)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).begin(), (c).end()
#define sci(n) scanf("%d", &n)
#define scl(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define mp make_pair
#define F first
#define S second
#define pb push_back

typedef long long int LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef pair< int, int> ii;
typedef vector< int> vi;

const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const int N = 2e5 + 22;
const double eps = 1e-10;

int n, m;
ii a[N];
ii sum[N];

/*
* https://en.wikipedia.org/wiki/Minkowski_addition
* https://codeforces.com/blog/entry/69485?#comment-539986
*/
LL sqr(int x) {
    return 1LL * x * x;
}
void _solve() {
    cin >> n;
    fr(i, 0, n) cin >> a[i].F >> a[i].S;
    sort(a, a + n, [](ii x, ii y) {
        return atan2(x.S, x.F) < atan2(y.S, y.F);
    });
    fr(i, n, n + n) a[i] = a[i - n];
    fr(i, 0, n + n) sum[i + 1] = {a[i].F + sum[i].F, a[i].S + sum[i].S};
    double ans = 0.0;
    frn(i, 1, n) fr(j, i, i + n) ans = max(ans, (double )sqrt(sqr(sum[j].F - sum[i - 1].F) + sqr(sum[j].S - sum[i - 1].S)));
    cout << setprecision(12) << ans;
}

int main() {
    fastio;
    //t_times
    _solve();
    return 0;
}



Measured memory_bytes: 256
target = "AB"
N = int(input())
ans = 0
finish_A = set()
start_B = set()
for i in range(N):
    s = input()
    lens = len(s)
    index = 0
    if s[-1] == "A":
        finish_A.add(i)
    if s[0] == "B":
        start_B.add(i)
    while index <= lens-2:
        if s[index:index+2] == target:
            ans += 1
            index += 2
            continue
        index += 1
both = len(finish_A & start_B)
onlyA = len(finish_A) - both
onlyB = len(start_B) - both
if onlyA < onlyB:
    print(str(ans + onlyA + both))
elif onlyB < onlyA:
    print(str(ans + onlyB + both))
elif both == 0:
    print(str(ans + onlyA))
elif onlyA > 0:
    print(str(ans + onlyA + both))
else:
    print(str(ans + onlyA + both - 1))

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

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(ulong.Parse).ToArray();
        ulong count = n[1];
        for(ulong i = 1; i < n[0]; i++)
        {
            count *= n[1] - 1;
        }
        WriteLine($"{count}");
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0; i<N; i++)
#define lint long long
#define square_vector(name,N,M) vector<vector<lint>>name(N,vector<lint>(M,0))
#define sort(V) sort(V.begin(),V.end())

lint gcd(lint A,lint B) {
  if (A > B) {
    swap(A,B);
  }
  if (B % A == 0) {
    return A;
  }
  else {
    return gcd(A,B%A);
  }
}

int main() {
  lint N;
  cin >> N;
  
  vector<lint> A(N);
  rep(i,N) {
    cin >> A[i];
  }
  
  int ans = 0;
  rep(i,N) {
    if (A[i] == ans+1) {
      ans++;
    }
  }
  
  if (ans == 0) {
    cout << -1 << endl;
  }
  else {
    cout << N-ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    int n=in,x=in,t=in;
    out(((n+x-1)/x)*t);
    
}

Measured memory_bytes: 3588