akhauriyash/Code-Regression huggingface dataset:
#%%
import collections

n = int(input())
v = list(input().split())
v1 = v[0::2]
v2 = v[1::2]

#print(v1)
#print(v2)


l1 = list(collections.Counter(v1).most_common())
l2 = list(collections.Counter(v2).most_common())


if l1[0][0] != l2[0][0]:
    tmp = l1[0][1] + l2[0][1]
else:
    if len(l1) > 1 and len(l2) > 1: 
        tmp = max(l1[1][1] + l2[0][1], l1[0][1] + l2[1][1])
    elif len(l1) == 1 and len(l2) > 1:
        tmp = max(l2[0][1], l1[0][1] + l2[1][1])
    elif len(l2) == 1 and len(l1) > 1:
        tmp = max(l1[1][1] + l2[0][1], l1[0][1])
    else:
        tmp = max(l2[0][1], l1[0][1])

ans = n - tmp
print(ans)


Measured memory_bytes: 23644
import itertools

N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for i in range(N)]

minW = items[0][0]
arrVs = [[] for i in range(4)]
for w, v in items:
    arrVs[w - minW].append(v)

acc = [[] for i in range(4)]
for i, arrV in enumerate(arrVs):
    arrV.sort(reverse=True)
    acc[i] = [0] + list(itertools.accumulate(arrV))

num = [range(len(acc[i])) for i in range(4)]

ans = 0
for n in itertools.product(num[0], num[1], num[2], num[3]):
    w = sum([n[i] * (minW + i) for i in range(4)])
    v = sum([acc[i][n[i]] for i in range(4)])
    if w <= W:
        ans = max(ans, v)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define prt_cs                  printf("Case %lld: ",cs)
#define sqr(x)                  (x)*(x)
#define ms(a,b)                 memset(a, b, sizeof(a))
#define db                      double
#define ll                      long long int
#define MOD                     1000000007
#define PI                      2*acos(0.0)
#define pii                     pair< int, int >
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
#define gcd(a, b)               __gcd(a, b)
#define lcm(a, b)               (((a)*(b))/gcd(a,b))
#define MAX                     100005

using namespace std;

int a[21][21];
ll dp[(1<<21)+3];

ll solve(int idx,int n,int mask)
{
    if(idx==n)
    {
        if(mask==(1<<n)-1)
            return 1;
        return 0;
    }
    if(dp[mask]!=-1)
        return dp[mask];
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        if(mask&(1<<i) || a[idx][i]==0)
            continue;
        ans+=solve(idx+1,n,mask|(1<<i));
        ans%=MOD;
    }
    return dp[mask]=ans%MOD;
}

int main()
{
//    READ;
//    WRITE;
    ms(dp,-1);
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    ll ans=solve(0,n,0);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 16640
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1000000000000 ;
const ll mod=1000003 ;
 
int main(){
  int n;
  cin >> n;
  int a[n],b[n],c[n];
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> b[i];
  rep(i,n)cin >> c[i];
  ll ans=0;
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  rep(i,n){
    int x=lower_bound(a,a+n,b[i])-a;
    int y=upper_bound(c,c+n,b[i])-c;
    ans+=(lower_bound(a,a+n,b[i])-a)*(n-(upper_bound(c,c+n,b[i])-c));
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
//int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};


int main(){
    int d[3][3];
    bool c[3][3] ={false};
    REP(i, 3)REP(j, 3){
        cin >> d[i][j];
    }
    int N;
    cin >> N;
    REP(i, N){
        int x;
        cin >> x;
        REP(j, 3)REP(k, 3){
            if(x == d[j][k]) c[j][k] = true;
        }
    }
  
    REP(i, 3){
        bool w = true;
        REP(j, 3) if(c[i][j] == false) w = false;
        if(w){
            yes;
            return 0;
        }
    }

    REP(i, 3){
        bool h = true;
        REP(j, 3) if(c[j][i] == false) h = false;
        if(h){
            yes;
            return 0;
        }
    }

    if(c[0][0] && c[1][1] && c[2][2]){
        yes;
        return 0;
    }

    if(c[0][2] && c[1][1] && c[2][0]){
        yes;
        return 0;
    }

    no;
    return 0;

}

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

using namespace std;

int main()
{
    int a[100000];
    const int MAX = 2147483647;
    int n, q;
    cin >> n >> q;

    for (int i = 0; i < n; i++) {
        a[i] = MAX;
    }

    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            a[x] = y;
        }
        else {
            int mi = a[x];
            for (int j = x + 1; j <= y; j++) {
                mi = min(mi, a[j]);
            }
            cout << mi << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3428
#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> pii;

int main(){
  int N,L;
  cin >> N >> L;
  int ans=(L+(L+N-1))*N/2;
  if(L>0) ans-=L;
  if(L+N-1<0) ans-=L+N-1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import           Data.List                      ( (!!) )
import           Data.Char                      ( toLower )

main :: IO ()
main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    s      <- getLine
    putStrLn $ take (k - 1) s ++ [toLower (s !! (k - 1))] ++ drop k s


Measured memory_bytes: 508
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int X,K,Q;
int R[100009],T[100009],A[100009];
int low,hig,s;

int f(int n,int l,int h){
    if(n<l) n=l;
    if(n>h) n=h;
    return n;
}

void fanc(int nxt,int i){
    int d=(T[nxt]-R[i])*(i%2?1:-1);
    int l=low-s, h=hig-s;
    int val;
    if(A[nxt]<=l){
        val=low+d;
        //cout2(nxt,"low")
    }else if(A[nxt]>=h){
        val=hig+d;
        //cout2(nxt,"hig")
    }else{
        val=low+d;
        val+=(A[nxt]-l);
        //cout3(nxt,"else",low)
    }
    val=f(val,0,X);
    cout1(val)
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>X>>K;
    rep1(i,K) cin>>R[i];
    R[K+1]=2e9;
    
    cin>>Q;
    rep(i,Q) cin>>T[i]>>A[i];
    
    int nxt=0;
    low=s=0,hig=X;
    rep(i,K+1){
        while(T[nxt]<=R[i+1]){
            fanc(nxt,i);
            if(++nxt>=Q) break;
        }
        if(nxt>=Q) break;
        int d=(R[i+1]-R[i])*(i%2?1:-1);
        low=f(low+d,0,X);
        hig=f(hig+d,0,X);
        s=f(s+d,-X,X);
        //cout3(low,hig,s)
    }
    
}

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

using namespace std;

void printVecRv(vector<int> &v){
    vector<int>::reverse_iterator ite = v.rbegin();
    while(ite != v.rend()){
        cout << " " << *ite;
        ite++;
    }
    cout << endl;
}

int main(){
    string s;
    getline(cin, s);
    int sum = 0;
    stack<int> dist;
    stack<pair<int, int> > pools;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == '\\'){
            dist.push(i);
        }else if(s.at(i) == '/' && dist.size() > 0){
            int j = dist.top(); dist.pop();
            int d = i - j;
            sum += d;
            while(pools.size() > 0 && pools.top().first > j){
                d += pools.top().second; pools.pop();
            }
            pools.push(make_pair(j, d));
        }
    }
    cout << sum << endl << pools.size();
    vector<int> v;
    while(pools.size() > 0){
        v.push_back(pools.top().second);
        pools.pop();
    }
    printVecRv(v);
    return 0;
}

Measured memory_bytes: 1308
/*
 *
 * Copyright(c) 2016 Taikai Takeda <297.1951@gmail.com> All rights reserved.
 *
 */
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef vector< int > Edges;

void dfs (int node, int label, VI & dp, vector<Edges> & edges){
    if (dp[node] != 0)
        return;
    dp[node] = label;
    for (auto & to: edges[node]){
        dfs(to, label, dp, edges);
    }
}

void traverse_all(VI & dp, vector<Edges> & edges){
    int n = dp.size();

    int label = 1;

    REP(i, n){
        if(dp[i] == 0) {
            dfs(i, label, dp, edges);
            label ++;
        }
    }
}

void output(VI &dpa, VI &dpb) {
    int n = dpa.size();
    map<PII, int> m;

    REP(i, n){
        m[PII(dpa[i], dpb[i])] ++;
    }

    REP(i, n){
        cout << m[PII(dpa[i], dpb[i])]  << " ";
    }
    cout << endl;
}


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

    int n, k, l;

    cin >> n >> k >> l;

    vector<Edges> aedges(n), bedges(n);

    REP(i, k) {
        int p, q;
        cin >> p >> q;
        p--;q--;
        aedges[p].push_back(q);
        aedges[q].push_back(p);
    }

    REP(i, l) {
        int p, q;
        cin >> p >> q;
        p--;q--;
        bedges[p].push_back(q);
        bedges[q].push_back(p);
    }

    VI adp(n, 0), bdp(n, 0);

    traverse_all(adp, aedges);
    traverse_all(bdp, bedges);

    output(adp, bdp);
    return 0;
}


Measured memory_bytes: 27776
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

S = input()

if not ("R" in S):
    print(0)
elif S == "RRR":
    print(3)
elif "RR" in S:
    print(2)
elif "R" in S:
    print(1)
else:
    print("yo")


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

char *Whatday(int a,int b){
	char *day;
	int date=0;
	int month[]={
		0,31,29,31,30,31,30,31,31,30,31,30,31
	};
	
	for(int i=1;i<a;i++){
		date = date+month[i];
	}
	date += b;
	switch(date%7){
		case 0: day ="Wednesday"; break;
		case 1: day ="Thursday"; break;
		case 2: day ="Friday"; break;
		case 3: day ="Saturday"; break; 
		case 4: day ="Sunday"; break;
		case 5: day ="Monday"; break;
		case 6: day ="Tuesday"; break;
	}
	return day;
}

int main() {
	int m,d;
	while(1){
		cin >> m >> d;
		if(m==0) break;
		cout << Whatday(m,d) << endl;
	}
	return 0;
}


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

int N, A, B;
ll v[51];
ll comb[51][51];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> A >> B;
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  for (int n = 0; n <= N; n++) {
    comb[n][0] = comb[n][n] = 1;
    for (int k = 1; k < n; k++) {
      comb[n][k] = comb[n - 1][k - 1] + comb[n - 1][k];
    }
  }
  sort(v, v + N);
  reverse(v, v + N);
  int p = 0, q = 0;
  for (int i = 0; i < N; i++) {
    if (i < A) p += v[i] == v[A - 1];
    q += v[i] == v[A - 1];
  }
  cout << accumulate(v, v + A, 0.0) / A << endl;
  if (v[0] == v[A - 1]) {
    ll ans = 0;
    for (int i = A; i <= B; i++) {
      ans += comb[q][i];
    }
    cout << ans << endl;
  } else {
    cout << comb[q][p] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.math;

void main() {
	string[] inputs = split(readln());
	int A = to!int(inputs[0]);
	int B = to!int(inputs[1]);
	
	int result = A + B;
	if(result < 10) result.writeln;
	else "error".writeln;
}


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

int main(){
    int h,n;
    cin >>h>>n;
    int a;
    int sum=0;
    rep(i,n) {
        cin >>a;
        sum += a;
    }
    if(sum>=h) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int sum = 0;
    int temp = n;
    while (temp > 0)
    {
        sum += temp % 10;
        temp /= 10;
    }
    if(n % sum == 0) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define MAXSIZE 50

using namespace std;

int cnt;
int island[MAXSIZE][MAXSIZE];

int check(int x, int y, int w, int h);

int main(int argc, char const *argv[])
{
	int w, h;

	while(cin >> w >> h, w | h)
	{
		for(int i = 0; i < h; i++)
		{
			for(int j = 0; j < w; j++)
			{
				cin >> island[i][j];
			}
		}

		/* processor */	
		cnt = 0;

		for(int x = 0; x < w; x++)
		{
			for(int y = 0; y < h; y++)
			{
				if(check(x, y, w, h))
				{
					cnt++;
				}
			}
		}

		cout << cnt << endl;
	}	

	return 0;
}

int check(int x, int y, int w, int h)
{
	int dx[] = {-1, 0, 1, 1, 1, 0, -1, -1};
	int dy[] = {-1, -1, -1, 0, 1, 1, 1, 0};

	if(island[y][x])
	{
		island[y][x] = 0;

		for(int i = 0; i < 8; i++)
		{
			if(x + dx[i] < 0 || x + dx[i] >= w || y + dy[i] < 0 || y + dy[i] >= h)
			{
				continue;
			}

			check(x + dx[i], y + dy[i], w, h);
		}

		return 1;
	}

	return 0;
}

Measured memory_bytes: 1424
a = int(input())
b = int(input())
c = int(input())
x = int(input())

choice_count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50 == x:
                choice_count +=1
print(choice_count)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];

	int ma=INT_MIN;
	int ma_n;
	int mi=INT_MAX;
	int mi_n;

	rep(i,n)
	{
		if(ma<a[i])
		{
			ma=a[i];
			ma_n=i;
		}
		if(mi>a[i])
		{
			mi=a[i];
			mi_n=i;
		}
	}

	cout<<2*n-1<<endl;

	if(ma+mi<=0)
	{	
		rep(i,n)
		{
			cout<<mi_n+1<<' '<<i+1<<endl;
		}
		for(int i=n-1;i>0;i--)
		cout<<i+1<<' '<<i<<endl;
	}
	else
	{
		rep(i,n)
		{
			cout<<ma_n+1<<' '<<(i+1)<<endl;
		}
		for(int i=0;i<n-1;i++)
		{
			cout<<i+1<<' '<<i+2<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <queue>
 
using namespace std;
const int maxn = 2005;

char g[maxn][maxn];
int r[maxn][maxn];
int c[maxn][maxn];
int s[maxn][maxn];
int n,m,Q;
int main()
{
	#ifdef Amberframe
		freopen("agc015c.in","r",stdin);
		freopen("agc015c.out","w",stdout);
	#endif
	scanf("%d %d %d",&n,&m,&Q);
	for (int i=1;i<=n;i++) scanf("%s",g[i]+1);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=m;j++)
	{
		s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(g[i][j]=='1');
		r[i][j]=r[i-1][j]+r[i][j-1]-r[i-1][j-1]+(g[i][j]=='1'&&g[i][j-1]=='1');
		c[i][j]=c[i-1][j]+c[i][j-1]-c[i-1][j-1]+(g[i][j]=='1'&&g[i-1][j]=='1');
	}
	
	for (int x1,y1,x2,y2,i=1;i<=Q;i++)
	{
		int ans=0;scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		ans+=s[x2][y2]+s[x1-1][y1-1]-s[x1-1][y2]-s[x2][y1-1];
		ans-=r[x2][y2]+r[x1-1][y1]-r[x1-1][y2]-r[x2][y1];
		ans-=c[x2][y2]+c[x1][y1-1]-c[x1][y2]-c[x2][y1-1];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 52864
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define inStrAftInSome cin.ignore(numeric_limits<streamsize>::max(),'\n')		//input string(with whitespace) after input something(char, int, bool, str)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define mod 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<=n; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef pair<int, int> 		pii;

int main()
{
	//freopen("t.in","r",stdin);
	//freopen("t.out","w",stdout);
	IOS;
	int n;
	cin >> n;
	int a[n];
	rep(i, n)
		cin >> a[i];
	sort(a, a+n);
	double ans = a[0];
	repi(i, 1, n-1)
	{
		ans = (ans + a[i]) /2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct point
{
	double x,y;
	friend point operator -(point a,point b){return (point){a.x-b.x,a.y-b.y};}
	friend point operator +(point a,point b){return (point){a.x+b.x,a.y+b.y};}
	friend double operator *(point a,point b){return a.x*b.y-a.y*b.x;}
}a[2000010];
point gp(point p,point q,double x)
{
	return (point){x,(p.y*(q.x-x)+q.y*(x-p.x))/(q.x-p.x)};
}
int main()
{
	int n,l,head=1,tail=1;a[1]=(point){0.0,0.0};
	scanf("%d%d",&n,&l);
	for (int i=1;i<=n;i++)
	{
		point p;scanf("%lf%lf",&p.y,&p.x);p.y*=p.x;
		head++;a[head]=a[head-1]-p;
		while ((head!=tail)&&(a[tail+1].x-a[head].x>l)) tail++;
		if (a[tail].x-a[head].x>l) a[tail]=gp(a[tail],a[tail+1],a[head].x+l);	
		while ((tail+1<head)&&((a[head]-a[head-2])*(a[head-1]-a[head-2])>0)) {a[head-1]=a[head];head--;}
		printf("%.10lf\n",(a[tail].y-a[head].y)/l);
	}
}




Measured memory_bytes: 18688
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		int N = Integer.parseInt(W);
		W = in.readLine();

		String[] Ws = W.split(" ");

		int[] list = new int[N];
		for(int i=0;i<N;i++){
			list[i] = Integer.parseInt(Ws[i]);
		}

		int i=1;
		int ans = 0;

		for(int k=0;k<N;k++){
			if(list[k]==i){
				i++;
			}else{
				ans++;
			}
		}
		if(i==1){
			ans = -1;
		}
		System.out.println(ans);



	}
}


Measured memory_bytes: 51064
#include <bits/stdc++.h>
using namespace std;
int cost_function(int val1,int val2){
	int val = val1-val2;
	return val*val;
}
int main() {
	int n; scanf("%d",&n);
	int a[n+2],sum = 0;
	bool allEq = true;
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		sum+=a[i];
		if(!allEq) continue;
		if(i>0){
			if(a[i]!=a[i-1]) allEq = false;
		}
	}
	
	if(allEq) {
		printf("0\n"); return 0;
	}

	int cost = 0;
	int average_value = (int)round((double)sum/(double)n);
	for(int i=0;i<n;i++) cost+=cost_function(average_value,a[i]);
	printf("%d\n", cost);
	return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 a,b,c,k;
  cin >> a >> b >> c >> k;
  while(a >= b){
    if(k == 0){
      Yes(false);
      return 0;
    }
    k--;
    b *= 2;
  }
  while(b >= c){
    if(k == 0){
      Yes(false);
      return 0;
    }
    k--;
    c *= 2;
  }
  Yes(true);
  return 0;
}

Measured memory_bytes: 3688
h,w = map(int,input().split())
s = [[j for j in input()] for i in range(h)]
for i in range(h):
  for p in range(w):
    count = 0
    if s[i][p] =='.':
      for j in range(-1,2):
        for k in range(-1,2):
          if 0 <= i+j < h and 0<= p+k < w:
            if s[i+j][p+k] == '#':
              count += 1
      s[i][p] = str(count)
for i in s:
  print("".join(i))

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

int cache[1001][1001];
const int INF = 1 << 20;

int max(int x, int y) { if (x < y) return y; else return x; }

int lcs(char *x, char *y, int xl, int yl) {
	if (cache[xl][yl] != INF) {
		return cache[xl][yl];
	}
	if (xl == 0 || yl == 0) return 0;
	if (x[xl-1] == y[yl-1]) {
		return cache[xl][yl] = lcs(x, y, xl - 1, yl - 1) + 1;
	} else {
		return cache[xl][yl] = max(lcs(x, y, xl - 1, yl), lcs(x, y, xl, yl - 1));
	}
}

int main(void) {
	int q;
	scanf("%d\n", &q);
	for (int i = 0; i < q; i ++) {
		char X[1000];
		char Y[1000];
		for (int i = 0; i <= 1000; i ++) {
			for (int j = 0; j <= 1000; j ++) {
				cache[i][j] = INF;
			}
		}
		gets(X);
		gets(Y);
		printf("%d\n", lcs(X, Y, strlen(X), strlen(Y)));
	}
	return 0;
}

Measured memory_bytes: 5060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	int c[1024];
	CLEAR(c, 0);
	for (int i = 1; i < 1000; ++i)
	{
		int s = i;
		for (int j = i + 1; j + s <= 1000; ++j)
			++c[s += j];
	}
	int n;
	while (scanf("%d", &n), n)
		printf("%d\n", c[n]);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 

  // input
  string s,t;
  cin>>s>>t;

  // copy string to vector
  vector<char> s_c(s.size());
  vector<char> t_c(t.size());

  for(int i=0;i<s.size();i++){
    s_c.at(i)=s.at(i);
  }
  for(int i=0;i<t.size();i++){
    t_c.at(i)=t.at(i);
  }

  // arrange data
  sort(s_c.begin(),s_c.end());
  sort(t_c.begin(),t_c.end(),std::greater<char>());

  if(s.size()<t.size()){
    for(int i=s.size();i<t.size();i++){
      s_c.push_back('0');
    }
  }

  if(t.size()<s.size()){
    for(int i=t.size();i<s.size();i++){
      t_c.push_back('0');
    }
  }


  // check
  string s2,t2;

  for(int i=0;i<s_c.size();i++){
    s2.push_back(s_c.at(i));
    t2.push_back(t_c.at(i));
  }

#if 0
  for(int i=0;i<s_c.size();i++){
    cout<<s2.at(i);
  }
  cout<<endl;
  for(int i=0;i<t_c.size();i++){
    cout<<t2.at(i);
  }
  cout<<endl;
#endif

  // output
  if(s2<t2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 3652
//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
    int N;
    cin >> N;
    string S;
    vector<string> vec;
    bool same;
    for (int i = 0; i < N; i++) {
        cin >> S;
        same = false;
        for (int j = 0; j < vec.size(); j++) {
            if (vec.at(j) == S) {
                same = true;
                break;
            }
        }
        if (!same) {
            vec.push_back(S);
        }
    }
    if (vec.size() == 3) {
        cout << "Three" << endl;
    }
    else if (vec.size() == 4) {
        cout << "Four" << endl;
    }
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(1e5)+10;
int n,m,a[maxn];
ll t,z;
ll gcd(ll x,ll y) {
	if (!x||!y) return x+y;
	return gcd(y,x%y);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m); t=1;
	for (int i=1;i<=n;i++) {
		read(a[i]); a[i]/=2;
		z=gcd(t,a[i]);
		if (t/z>m/a[i]) { printf("0\n"); return 0; }
		t=t/z*a[i];
	}
	for (int i=1;i<=n;i++)
		if ((t/a[i])%2==0) { printf("0\n"); return 0; }
	t=m/t;
	if (t&1) t=t/2+1;
	else t/=2;
	printf("%lld\n",t);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			string s = cin.Next();
			int count = 0;
			for (int i = 0; i < n - 2; i++) {
				if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
					++count;
				}
			}

			Console.WriteLine(count);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int l,r,d;

    cin>>l>>r>>d;
    cout<<r/d-(l-1)/d<<'\n';
    
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        Long n = sc.nextLong();
        int min = Integer.MAX_VALUE;
        for(int i=1;i<Math.sqrt(n)+1;i++){
            if(n%i==0){
                min = Math.min(min,f(i,n/i));
            }
        }
        System.out.println(min);
    }

    private static int f(long a,long b){
        return Math.max(digit(a),digit(b));
    }

    private static int digit(long n){
        int i=1;
        while(true){
            if(n<10)return i;
            i++;
            n=n/10;
        }
    }

}


Measured memory_bytes: 23764
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int i = 0;
        do {
          h -= sc.nextInt();
          i++;
        } while (i<n && h>0);
        if (h>0){
          System.out.println("No");
        } else {
          System.out.println("Yes");
        }
        
    }
}


Measured memory_bytes: 46804
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    set<string> st;
    string tmp; cin >> tmp; st.insert(tmp);
    bool ok = 1;
    REP(i,n-1){
        string now; cin >> now;
        if(tmp.back()!=now[0] || (st.count(now)) ) ok = 0;
        st.insert(now);
        tmp = now;
    }
    Yn(ok);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll K, A, B;
  cin >> K >> A >> B;

  bool ok = false;
  REP(i, A, B+1) {
    if (i % K == 0) {
      ok = true;
      break;
    }
  }
  if (ok) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }


  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int f(int x) {
  if(x%2 != 0) return 0;
  else return f(x/2) + 1;
}

int main() {
  int n;
  cin >> n;
  int p = 0;
  int ans = 1;
  for(int i = 1; i<=n; i++) {
    if(p < f(i)) {
      p = f(i);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def readinput():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    return n,k,a

def main(n,k,a):
    for i in range(n-k):
        if a[i]<a[i+k]:
            print('Yes')
        else:
            print('No')

if __name__=='__main__':
    n,k,a=readinput()
    main(n,k,a)


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
const ld PI=3.141592653589793;



vector<int> edges[110000];
int root[110000];

int main(){
    int N,M; cin>>N>>M;
    REP(count,M){
        int a,b; cin>>a>>b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    FILL(root,N+1,-1);
    int num_visit = 0;
    queue<int> q;
    q.push(1);
    root[1] = 0;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        
        for(int next:edges[x]){
            if(root[next]>0){continue;}
            else{
                root[next] = x;
                q.push(next);
                ++num_visit;
            }
            
        }   
    }
    if(num_visit==N){
        cout << Liny;
        for(int i=2;i<=N;++i){
            cout << root[i] << "\n";
        }
    }else{
        cout << Linn;
    }
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string s;
  cin>>s;
  int m;
  int l;
  for(int i=0;i<s.length();i++){
    if(s[i]=='A'){
         m=i;
         i=s.length();
    }
  }
  for(int i=s.length()-1;i>=m+1;i--)
  {
    if(s[i]=='Z'){
      l=i;
      i=-1;
    }
  }
  cout<<l-m+1;
  
}

Measured memory_bytes: 720
#include <iostream>
using namespace std;
int main(){ 
    int a, b;
    cin >> a >> b;
    int sum = 0;
    int g1, g2, g4, g5;
    
    for (int i = a; i < b + 1; i++){
        g1 = i % 10;
        g2 = i / 10 % 10;
        g4 = i / 1000 % 10;
        g5 = i / 10000 % 10;
        if (g1 == g5 && g2 == g4) {
            sum += 1;
        }
    }
    
    cout << sum;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N,W,H,max,shot=0,sum;
	scanf("%d",&H);
	scanf("%d",&W);
	scanf("%d",&N);
	if(H>W) max = H;
	else max = W;
	while(1){
		if(N<=sum) break;
		sum += max;
		++shot;
	}
	printf("%d\n",shot);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int llint;

int main(){
	int n, i=6;
	cin>>n;
	int a[]={1,2,4,8,16,32,64};
	while(true){
		if(a[i]<=n){
			break;
		}
		i--;
	}
	cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
    N, K, *x = map(int, open(0).read().split())
    
    ans = 10 ** 9
    for l in range(N - K + 1):
        r = l + K - 1
        ans = min(ans, abs(x[l]) + abs(x[r] - x[l]), abs(x[r]) + abs(x[r] - x[l]))
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 14052
# https://atcoder.jp/contests/abc091/tasks/arc092_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())
    red = [list(map(int, input().split())) for _ in range(N)]
    red.sort(key=lambda x: x[0])

    blue = [list(map(int, input().split())) for _ in range(N)]
    blue.sort(key=lambda x: x[0])

    ans = 0
    for bx, by in blue:
        p_red = None
        for i in range(len(red)):
            rx, ry = red[i][0], red[i][1]
            if rx > bx:
                break
            if ry < by:
                if not p_red:
                    p_red = red[i]
                else:
                    if p_red[1] < ry:
                        p_red = red[i]
        if p_red:
            ans += 1
            red.remove(p_red)

    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

ll n;

vector<ll> good;
set<ll> tmp[20];

map<ll,ll> dp;
ll dfs(ll x){
  if(x==1)return 0;
  if(dp.count(x))return dp[x];
  int mx = lower_bound(ALL(good),x)-good.begin();
  if(mx >= good.size()) mx = good.size()-1;
  ll res = -1ll;
  while(mx>=0){
    if(x%good[mx]==0){
      ll d = dfs(x/good[mx]);
      if(d!=-1)res = max(res,d+1);
    }
    --mx;
  }
  return dp[x] = res;
}

int main(){
  cin>>n;
  if(n==1){
    cout<<-1<<endl;
    return 0;
  }
  // init good number
  tmp[0].insert(2);
  tmp[0].insert(8);
  set<ll>::iterator iter;
  REP(i,16){
    iter = tmp[i].begin();
    while(iter!=tmp[i].end()){
      ll x = *iter;
      tmp[i+1].insert(x*10ll+2ll);
      tmp[i+1].insert(x*10ll+8ll);
      ++iter;
    }
  }
  REP(i,17){
    // int i = 16-_i;
    iter = tmp[i].end(); --iter;
    tmp[i].erase(iter);
    iter = tmp[i].begin();
    while(iter!=tmp[i].end()){
      good.push_back(*iter);
      ++iter;
    }
  }
  // solve

  // select.push_back(2);
  // REPR(i,good.size()){
  //   ll x = __gcd(n,good[i]);
  //   if(__builtin_popcount(x)>1)select.push_back(good[i]);
  // }
  // DEBUG(good.size());
  // DEBUG(select.size());

  // ll res = 0;
  // REP(i,good.size()){
  //   // int i = good.size()-1-_i;
  //   ll val = good[i];
  //   while(n%val==0){
  //     res++;
  //     n/=val;
  //   }
  // }
  // if(n!=1)res=-1;
  // cout<<res<<endl;

  cout<<dfs(n)<<endl;
  return 0;
}

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

const int INF = 2e9;

int main(){
    int n;
    string s;
    cin >> n >> s;
    queue<char> a;
    a.push(s[0]);
    for(int i = 1;i < n;i++){
        if(s[i-1] == s[i]) continue;
        a.push(s[i]);
    }
    cout << a.size() << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_tap_dance(void) {
	string s;
	cin >> s;

	string ans = "Yes";

	for (int i = 0; i < s.size(); i++) {
		if ((i & 0x1) == 0x1) {
			if (s[i] == 'R') ans = "No";
		}
		else {
			if (s[i] == 'L') ans = "No";
		}
	}

	cout << ans << endl;
}

int main()
{
    b_tap_dance();

    return 0;
}

Measured memory_bytes: 3656