akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().ToInt();
        var axis = CRL().ArrayLongs();
        long count = 0;
        for (int i = 0; i < n; i++)
        {
            while (axis[i].IsEven())
            {
                count++;
                axis[i] /= 2;
            }
        }

        CWL(count);
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array)
    {
        var list = array.ToList();
        list.Sort();
        return list.ToArray();
    }
    //テンプレここまで
}


Measured memory_bytes: 14304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
const ll inf = 1001001001;
const ll inf2 = 1000000000000000000;
const ll mod = 1000000007;
ll cnt(ll x){
    int k=1;
    while(2*x >= k*(k+1)){
        k++;
    }
    return k-1;
}
int main() {
    ll n;
    cin >> n;
    vector<ll>v;
    sqrep(i, 2, n){
        ll p = 0;
        while(n%i == 0){
            n /= i;
            p++;
        }
        if(p!=0)v.push_back(p);
    }
    if(n != 1)v.push_back(1);
    ll ans = 0;
    lrep(i, 0, v.size()){
        //cout << v[i] << endl;
        ans += cnt(v[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int maxn=500010;
const int N=1<<20;
const int mod=1e9+7;
int n;
int a[maxn],f[maxn];
int flg[maxn];//1-i中异或和不为0的个数
int d1[N];//
int d0[N];//
int pre[N];//上一个异或和为i的数
signed main(){
	cin>>n;
	for(int i=0;i<(1<<20);i++)d0[i]=1;
	for(int i=0;i<n;i++)cin>>a[i],f[i]=(i>0?(f[i-1]^a[i]):a[i]);
	for(int i=0;i<n;i++){
		if(f[i]){
			int b=f[i];//当前的异或和
			d0[b]=(d0[b]+(flg[i]-flg[pre[b]])*d1[b])%mod;
			d1[b]=(d0[b]+d1[b])%mod;
			pre[b]=i;
		}else{
			flg[i]++;
			if(d1[0])d1[0]=(d1[0]*2)%mod;
			else d1[0]++;
		}
		flg[i+1]=flg[i];
	}
	int ans=0;
	if(f[n-1]==0){
		for(int i=0;i<(1<<20);i++)ans=(ans+d1[i])%mod;
	}else{
		ans=d0[f[n-1]];
	}
	cout<<ans<<endl;
	return 0;
}


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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N;

signed main()
{
    cin >> N;

    int ans = 0, mi = N+5, p;
    rep1(i, N) {
        cin >> p;
        if (mi >= p) {
            ans++;
            mi = p;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P


int main(){
	int N;
	long long A,B,C,D;

	scanf("%d %lld %lld %lld %lld", &N, &A, &B, &C, &D);

	for(int k=0;k<=N-1;k++){
		if(A-(N-1)*D+k*(C+D)<=B && B<=A-(N-1)*C+k*(C+D)){
			printf("YES\n");
			return 0;
		}
	}

	printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	using p=tuple<string,int,int>;
	vector<p> a;
	rep(i,n){
		string s;int q;
		cin>>s>>q;
		a.emplace_back(s,q,i+1);
	}
	sort(all(a),[](p x,p y){return get<0>(x)<get<0>(y) || (get<0>(x)==get<0>(y) && get<1>(x)>get<1>(y));});
	rep(i,n)puta(get<2>(a[i]));
	return 0;
}

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

#define INIT_CAP 10
#define INF 1000000000

#define min(a, b) (((a) < (b)) ? (a) : (b))

const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num, d;
} PNumDis;

VecEdge adj[30 * 30 * 4];
PNumDis heap[30 * 30 * 4 * 4];
int hsize;
int d[30 * 30 * 4];

int w, h;
int field[30][30];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

inline void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

void freeAll(int n) {
	while (n--)
		free(adj[n].elem);
}

inline void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PNumDis){num, d};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		const PNumDis fromP = delete();

		if (fromP.d > d[fromP.num])
			continue;

		for (i = 0; i < adj[fromP.num].size; i++) {
			const Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i, j, k, l;

	while (scanf("%d %d", &w, &h), w) {
		int c[4];

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				scanf("%d", field[i] + j);

		for (i = 0; i < 4; i++)
			scanf("%d", c + i);

		init(h * w * 4);

		for (i = 0; i < h; i++)
			for (j = 0; j < w; j++)
				for (k = 0; k < 4; k++)
					for (l = 0; l < 4; l++) {
						int nd = k + l & 3;
						int ni = i + di[nd], nj = j + dj[nd];
						if (ni >= 0 && ni < h && nj >= 0 && nj < w)
							add(i * w * 4 + j * 4 + k, ni * w * 4 + nj * 4 + nd, l == field[i][j] ? 0 : c[l]);
					}

		dijkstra(h * w * 4, 1);

		printf("%d\n", min(d[(h - 1) * w * 4 + (w - 1) * 4 + 1], d[(h - 1) * w * 4 + (w - 1) * 4 + 2]));

		freeAll(h * w * 4);
	}

	return 0;
}

Measured memory_bytes: 1036
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}



int main(){
    ll n, m, k;
    cin >> n >> m >> k;
    vll a(n);
    vll b(m);
    rep(i,n){
        int tmp;
        cin >> tmp;
        if(i ==0) a[i] = tmp;
        else a[i] = a[i-1] + tmp;
        if(a[i] > inf){
            a[i] = inf;
        }
        // cout << a[i] << " ";
    }
        // cout << endl;
    rep(i,m){
        int tmp;
        cin >> tmp;
        if(i ==0) b[i] = tmp;
        else b[i] = b[i-1] + tmp;
        if(b[i] > inf){
            b[i] = inf;
        }
        // cout << b[i] << " ";
    }
        // cout << endl;

    int ans = 0;
    rep(i,n+1){ // aでi本読む時を考える
        int rem = 0;
        int flag = 0;
        if(i != 0 && a[i-1] <= k){
            rem = k - a[i-1];
            flag = 1;
        }else if(i == 0){
            flag = 1;
            rem = k;
        }
        auto it = upper_bound(all(b), rem);
        int tmp = it - b.begin();
        // printf("i = %d, rem = %d, it = %d\n", i, rem, it - b.begin());
        if(flag) ans = max(ans,  i + tmp);
    }
    cout << ans << endl;
}



Measured memory_bytes: 6424
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int H=sc.nextInt();
    	int W=sc.nextInt();

    	for(int i=0;i<W+2;i++) {
    		System.out.print("#");
    	}
    	System.out.println();

    	for(int i=0;i<H;i++) {

    		System.out.print("#");
    		System.out.print(sc.next());
    		System.out.println("#");

    	}

    	for(int i=0;i<W+2;i++) {
    		System.out.print("#");
    	}
    	System.out.println();

    }

}



Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
int tot,head[200011],to[400011],nxt[400011],w[200011];
int n,q;
void addedge(int x,int y)
{
	tot++; nxt[tot]=head[x]; to[tot]=y; head[x]=tot;
	return;
}
void insert(int x,int y)
{
	addedge(x,y);addedge(y,x);return;
}
void dfs(int x,int fa)
{
	for(int i=head[x];i;i=nxt[i])
		if(to[i]!=fa)
		{
			w[to[i]]+=w[x];
			dfs(to[i],x);
		}
	return;
}
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1,x,y;i<n;i++) scanf("%d%d",&x,&y),insert(x,y);
	for(int i=1,x,y;i<=q;i++) scanf("%d%d",&x,&y),w[x]+=y;
	dfs(1,0);
	for(int i=1;i<n;i++) printf("%d ",w[i]); printf("%d\n",w[n]);
	return 0;
}

Measured memory_bytes: 16512
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
for num in range(1000):
    if m == 0:
        if n == 1:
            print(0)
            exit()
        else:
            print(10**(n-1))
            exit()    
    for i in range(m):
        if len(str(num)) < n:
            break
        if str(num)[int(l[i][0])-1] != l[i][1]:
            break
    else:
        print(num)
        exit()
print(-1)

Measured memory_bytes: 3064
import Data.List

solve :: Int -> Int -> [Int] -> Int
solve c k t = let (_,_,a) = foldl f (head t,1,0) (tail t) in a+1
  where
    f (y',c',a) y
      | c' == c  = (y,1,a+1)
      | y'+k < y = (y,1,a+1)
      | otherwise = (y',c'+1,a)

main :: IO ()
main = do
    [n,c,k] <- map read . words <$> getLine :: IO [Int]
    t <- sort . map read . lines <$> getContents :: IO [Int]
    print $ solve c k t

Measured memory_bytes: 17660
#include <stdio.h>
int main()
{
  int a, b, c, count=0;
  int i, j;
  scanf("%d %d %d" ,&a ,&b ,&c);

  if ((a<=b)&&(1<=a && a<=10000)&&(1<=b && b<=10000)&&(1<=c && c<=10000)) {
    for (i=a; i<=b; i++) {
      if (c%i==0) {
        count++;
      }
    }
  }
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 596
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#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++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> par(0);
vector<int> depth(0);
vector<int> heavy(0);
void init(int n){
   par.resize(n);
   depth.resize(n,0);
   heavy.resize(n,0);
   rep(i,n) par[i]=i;
}

int find(int x){
   if(par[x]==x) return x;
   int parent =find(par[x]);
   heavy[x]+=heavy[par[x]];
   return par[x]=parent;
}

int wei(int x){
    find(x);
    return heavy[x];
}

void unite(int x,int y,int z){//yはxよりz重い
    z +=wei(x)-wei(y);
   x=find(x);
   y=find(y);
   if(par[x]==par[y]) return;
   if(depth[x]<depth[y]){
       par[x]=y;
       heavy[x]=-z;
   }
   else{
      par[y]=par[x];
      heavy[y] =z;
   if(depth[x]==depth[y]) depth[x] ++;
   }
}

bool same(int x,int y){
   return find(x)==find(y);
}

int diff(int x,int y){//w[y]-w[x],比較不可なら-1
    if(!same(x,y)) return -1;
    return wei(y)-wei(x);
}

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m,l,r,d;
    cin>>n>>m;
    init(n);
    rep(i,m){
        cin>>l>>r>>d;
        r --;
        l --;
        if(diff(l,r)==d) continue;
        else if(same(l,r)){
            cout<<"No"<<endl;
            return 0;
        }
        else unite(l,r,d);
    }
    cout<<"Yes"<<endl;
}

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

const ll MOD = 1'000'000'007;

ll pow_mod(ll n, ll k) {
  if (k == 0) {
    return 1;
  }
  ll tmp = pow_mod(n, k / 2);
  ll res = tmp * tmp % MOD;
  if (k % 2 != 0) {
    res = n * res % MOD;
  }
  return res;
}

void init(vector<ll>& fact, vector<ll>& finv) {
  ll n = fact.size();
  fact[0] = 1;
  for (ll i = 1; i < n; ++i) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  finv[n - 1] = pow_mod(fact[n - 1], MOD - 2);
  for (ll i = n - 2; i > 0; --i) {
    finv[i] = finv[i + 1] * (i + 1) % MOD;
  }
}

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

  vector<ll> fact(n + k + 1);
  vector<ll> finv(n + k + 1);
  init(fact, finv);

  auto choose_mod = [&](ll a, ll b) {
    return a == b || b == 0 ? 1 : (fact[a] * finv[b] % MOD) * finv[a - b] % MOD;
  };

  int m = n - k;
  for (int i = 1; i <= k; ++i) {
    if (m > 1) {
      ll b = choose_mod(k - 1, i - 1);
      ll r = m + 1 >= i ? choose_mod(m + 1, i) : 0;
      cout << b * r % MOD << endl;
    } else {
      cout << (i == 1 ? 1 : 0) << endl;
    }
  }
}

Measured memory_bytes: 256
I = lambda: list(map(int, input().split()))

N, T = I()
ct = [I() for _ in range(N)]

minc = 9999

for i in range(N):
    if T >= ct[i][1] and minc >= ct[i][0]:
        minc = ct[i][0]

print(minc if minc != 9999 else 'TLE')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

int A[251];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
    }

    for (int i = 1; i <= n; ++i) {
        cout << "node " << i << ": "
        << "key = " << A[i] << ", ";
        if (i > 1) {
            int parent = i / 2;
            cout << "parent key = " << A[parent] << ", ";
        }

        int left = i * 2;
        int right = i * 2 + 1;
        if (left <= n) {
            cout << "left key = " << A[left] << ", ";
        }
        if (right <= n) {
            cout << "right key = " << A[right] << ", ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {
    int N;
    string S;
    cin >> N >> S;

    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    string leftS = S.substr(0, N / 2);
    string rightS = S.substr(N / 2, N - 1);

    if (leftS == rightS) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vvint abc(26);
    int l = (int)s.size();
    for(int i=0;i<l-1;++i){
        if(s[i]==s[i+1]){
            printf("%d %d\n", i+1, i+2);
            return 0;
        }
        if(i+2<l&&s[i]==s[i+2]){
            printf("%d %d\n", i+1, i+3);
            return 0;
        }
    }
    printf("%d %d\n", -1, -1);
    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 2 * 1000 * 1000 + 47;

struct Item
{
	LL x, y, mult;
	Item() {}
	Item(LL x1, LL y1, LL mult1)
	{
		x = x1;
		y = y1;
		mult = mult1;
	}
};

LL F[MAX];
LL FR[MAX];
LL R[MAX];
LL X[6];
LL Y[6];
Item S[4];
Item E[4];

LL cc(int n, int k)
{
	if (k > n) return 0;
	LL res = (F[n] * FR[k]) % MOD;
	res = (res * FR[n - k]) % MOD;
	return res;
}

LL C(int x, int y)
{
	return cc(x + y, x);
}

void ADD(LL& key, LL val)
{
	key += val;
	if (key >= MOD) key -= MOD;

	if (key < 0) key += MOD;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	F[0] = F[1] = FR[0] = FR[1] = R[1] = 1;

	FOR(i, 2, MAX)
	{
		R[i] = MOD - (MOD / i * R[MOD % i]) % MOD;
		if (R[i] == MOD) R[i] = 0;
		F[i] = (F[i - 1] * i) % MOD;
		FR[i] = (FR[i - 1] * R[i]) % MOD;
	}

	FOR(i, 0, 6) cin >> X[i];
	FOR(i, 0, 6) cin >> Y[i];

	S[0] = Item(X[0] - 1, Y[0] - 1, 1);
	S[1] = Item(X[1], Y[1], 1);
	S[2] = Item(X[0] - 1, Y[1], -1);
	S[3] = Item(X[1], Y[0] - 1, -1);

	E[0] = Item(X[5] + 1, Y[5] + 1, 1);
	E[1] = Item(X[4], Y[4], 1);
	E[2] = Item(X[4], Y[5] + 1, -1);
	E[3] = Item(X[5] + 1, Y[4], -1);

	LL ans = 0;
	FOR(s, 0, 4)
	{
		FOR(e, 0, 4)
		{
			int mult = S[s].mult * E[e].mult;

			FOR(x, X[2], X[3] + 1)
			{
				LL val = C(E[e].x - x, E[e].y - Y[3] - 1) * (x + Y[3] + 1);
				val %= MOD;
				val *= C(x - S[s].x, Y[3] - S[s].y);
				val %= MOD;

				ADD(ans, mult * val);
			}

			FOR(y, Y[2], Y[3] + 1)
			{
				LL val = C(E[e].x - X[3] - 1, E[e].y - y) * (y + X[3] + 1);
				val %= MOD;
				val *= C(X[3] - S[s].x, y - S[s].y);
				val %= MOD;
				
				ADD(ans, mult * val);
			}

			FOR(x, X[2], X[3] + 1)
			{
				LL val = C(x - S[s].x, Y[2] - 1 - S[s].y) * (-(x + Y[2]));
				val %= MOD;
				val *= C(E[e].x - x, E[e].y - Y[2]);
				val %= MOD;

				ADD(ans, mult * val);
			}

			FOR(y, Y[2], Y[3] + 1)
			{
				LL val = C(X[2] - 1 - S[s].x, y - S[s].y) * (-(X[2] + y));
				val %= MOD;
				val *= C(E[e].x - X[2], E[e].y - y);
				val %= MOD;

				ADD(ans, mult * val);
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for(auto v:(V))cout<<v<<" "<<endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vs s(N);
    int x = 0, y = 0, z = 0;
    rep(i, N)
    {
        cin >> s[i];
    }
    ll ans = 0;
    rep(i, N)
    {
        rep(j, s[i].size() - 1)
        {
            if (s[i][j] == 'A' && s[i][j + 1] == 'B')
                ans++;
        }
        if (s[i][s[i].size() - 1] == 'A' && s[i][0] == 'B')
        {
            y++;
        }
        else if (s[i][s[i].size() - 1] == 'A')
        {
            x++;
        }
        else if (s[i][0] == 'B')
        {
            z++;
        }
    }
    if(x < y + z) ans += x;
    else
    {
        ans += y + z;
        cout << ans << endl;
        return 0;
    }
    if(x == 0)
    {
        if(z == 0)
        {
            ans += y - 1;
        }
        else
        {
            ans += y;
        }
    }
    else
    {
        ans += min(y, y + z - x);
    }
    cout << ans << endl;
}

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

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

Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))

add1 = []
sub1 = []
for i in range(n):
    add1.append(a[i] + i)
    sub1.append(i - a[i])

dict1 = {}
dict2 = {}
for i in add1:
    if i in dict1:
        dict1[i] += 1
    else:
        dict1[i] = 1
for i in sub1:
    if i in dict2:
        dict2[i] += 1
    else:
        dict2[i] = 1

ans = 0
for k,v in dict1.items():
    if k in dict2:
        ans += v * dict2[k]

print(ans)


Measured memory_bytes: 165844
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;

int main(){
    int n,l;
    cin >> n >> l;
    int sum = 0;
    int small = INT_MAX;
    int last  = -1;
    for(int i=l; i< l+n; i++){
        sum += i;
        if(abs(i) < small){
            small = abs(i);
            last = i;
        }
    }
    cout << sum - last << endl;
    return 0;
}


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

int main(){
  long long int n,i,k,min=0,max=0,kotae=0;
  cin>>n>>k;
  n++;
  for(i=0;i<n;i++){
    min+=i+1;
    max+=n-i;
    if(i+1>=k){
      kotae+=max-min+1;
      kotae%=1000000007;
    }
  }
  cout<<kotae;
}


Measured memory_bytes: 3652
import java.util.Scanner;

                public class Main{
                    public static void main(String[] args){
                        int a=0,b,ans;
                        String d;
                        char c;
                        Scanner sc = new Scanner(System.in);
                    while(true){  a = sc.nextInt();
                        d = sc.next();
                        b = sc.nextInt();
                        c = d.charAt(0);
                        if(c=='+')ans = a+b;
                        else if(c=='-')ans = a-b;
                        else if(c=='*')ans = a*b;
                        else if(c=='/')ans = a/b;
                        else break;
                    
                        System.out.println(ans);
            
                    }
                    }
                }


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

int main(){
	ll n;
	cin >> n;
	vector<ll> a(0);
	for(int i=0; i>=0; i++){
		ll b = pow(2, i) * (1-i%2*2);
		a.push_back(b);
		if(b > 400000000000 || b < -400000000000) break;
	}
	if(n == 0){
		cout << 0 << endl;
		return 0;
	}else if(n < 0){
		rep(i, a.size()) a.at(i) *= -1;
		n *= -1;
	}
	vector<int> b(64);
	rep(i, 64){
		if(n == 0) break;
		b.at(i) = n%2;
		n /= 2;
	}
	rep(i, 64){
		if(b.at(i) == 1 && a.at(i) < 0) b.at(i+1)++;
	}
	for(int j=0; j<=2; j++){
		int f = 0;
		rep(i, 64){
			if(b.at(i) == 2){
				f = 1;
				if(b.at(i+1) == 1){
					b.at(i) = 0;
					b.at(i+1) = 0;
				}else{
					b.at(i) = 0;
					b.at(i+1)++;
					b.at(i+2)++;
				}
			}
		}
		if(f == 0) break;
	}
	int k = 0;
	rep(i, 64) if(b.at(i) == 1) k = i;
	rep(i, k+1){
		cout << b.at(k-i);
	}
	cout << endl;
	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
int D[1000];
int C[1000];

int dp[1010];

signed main(){
    cin>>N>>M;
    rep(i,N)cin>>D[i];
    rep(i,M)cin>>C[i];

    fill_n(dp,1010,1001001001001001001ll);
    dp[0]=0;
    rep(i,M){
        for(int j=N-1;j>=0;j--){
            chmin(dp[j+1],dp[j]+C[i]*D[j]);
        }
    }
    cout<<dp[N]<<endl;
    return 0;
}

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

int main(){
 int a,b;
 cin>>a>>b;
 if(a>b){
  cout<<"a > b"<<'\n';
 }
 if(a==b){
  cout<<"a == b"<<'\n';
 }
 if(a<b){
  cout<<"a < b"<<'\n';
 }
 return 0;
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,T,A=0;
  cin >> N;
  vector<int> t;
  for (int i = 0; i < N; i++){
    cin >> T;
    t.push_back(T);
    A+=T;
  }
  int M;
  cin >> M;
  int P,X;
  for (int i = 0; i < M; i++){
    cin >> P >> X;
    cout << A-t[P-1]+X << endl;
  }
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int L = A + B;
  int R = C + D;
  if (L > R) {
    cout << "Left" << endl;
  } else if (L == R){
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import math

def calcAgree(n):
    [a,b,x] = n

    if a*a*b/2 >= x :
        # 傾けた時のbと直角を成す線分の長さを求める
        length1 = x/a/b*2
        length2 = (b**2+length1**2)**0.5

        target_angle = math.acos(length1/length2)
        
        return target_angle / (2*math.pi) * 360
    else:
        air_taiseki = a*a*b-x
        # 傾けた時のbと直角を成す線分の長さを求める
        length1 = air_taiseki/a/a*2
        length2 = (a**2+length1**2)**0.5
        target_angle = math.asin(length1/length2)
        
        return target_angle / (2*math.pi) * 360

input_data = [int(x) for x in input().split()]

print(calcAgree(input_data))

Measured memory_bytes: 3064
def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
			print(-1)
			return
	print(prod)
main ()

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll n,ans=0,i;
    cin>>n;
    ll a[n],b[n];
    forn(i,n) {cin>>a[i]; a[i]%=MOD;}
    b[n-1]=a[n-1];
    for(i=n-2;i>=0;i--) b[i]=(b[i+1]+a[i])%MOD;

    for(i=0;i<n-1;i++){
        ans+=(b[i+1]*a[i])%MOD;
        ans%=MOD;
    }
    cout<<ans el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 6776
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);
//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static int K;
	public static void main(String[] args) {
		long H=sc.nextLong();
		long W=sc.nextLong();
		long ans=0;
		if(H==1||W==1) {
			p(1);
		}
		else {
			ans=(long)Math.ceil((double)H*W/2);
			p(ans);
		}
		//p((double)H*W/2);
		
	}
}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> x(n,0);
    map<int,int> m;
    vector<int> d(k);
    for(int i=0;i<k;i++){
        cin >> d[i];
        for(int j=0;j<d[i];j++){
            int a;
            cin >> a;
            m[a]++;
        }
    }

    cout << n - m.size() << endl;

}

Measured memory_bytes: 3632
N = int(input())
h = list(map(int,input().split()))
dp = [0] * (N + 1)

dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])

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

const int mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x = 0) : x(x % mod){}
    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
};

mint c[4005][4005];
void init() {
    c[0][0] = 1;
    for (int i = 0; i <= 4000; i++) {
        for (int j = 0; j <= i; j++) {
            c[i+1][j] += c[i][j];
            c[i+1][j+1] += c[i][j];
        }
    }
}
mint comb(int n, int k) {
    return c[n][k];
}

int main() {
    init();
    int n, k;
    cin >> n >> k;
    rep(i,k) {
        mint red = comb(k-1,i);
        mint blue = comb(n-k+1,i+1);
        mint ans = red*blue;
        printf("%lld\n",ans.x);
    }
    return 0;
}

Measured memory_bytes: 125568
x, y = map(int, input().split())
mod = 1000000007
m = (x+y)//3
a = (m + x-y)//2
if (x+y)%3 != 0 or a<0 or a>m:
  print(0)
else:
  ans = 1
  for i in range(1, a+1):
    ans *= (m-a+i)*pow(i, mod-2, mod)
    ans %= mod
  print(ans)

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')


def main():
	n=II()
	A=[]
	B=[]
	for _ in range(n):
		a,b=MI()
		A.append(a)
		B.append(b)
	A.sort()
	B.sort()
	#print(A,B)

	r=n//2
	l=(n-1)//2
	#print(l,r)

	mi=A[l]+A[r]
	ma=B[l]+B[r]

	ans=(ma-mi)-(ma-mi)*(n%2)//2+1
	print(ans)







if __name__ == "__main__":
	main()


Measured memory_bytes: 25560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	int n, k;
	cin>>n>>k;
	vector<int> a;
	a.resize(n);
	vector<int> occ;
	occ.resize(200001);

	for(int i = 0; i < 200001; i++){
		occ[i] = 0;
	}
	int diffs = 0;
	for(int i = 0; i < n; i++){
		cin>>a[i];
		if (occ[a[i]] == 0) diffs ++;
		occ[a[i]]++;
	}
	sort(occ.begin(),occ.end());
	
	int changes = 0;
	for(int i = 0; i < 200001; i++){
		if (occ[i] ==0) continue;
		if (diffs <=k){
			cout<<changes<<endl;
			return 0;
		}
		changes += occ[i];
		diffs --;
	}
	return 0;
}

Measured memory_bytes: 1792
n = int(input())
pl = [int(i) for i in input().split()]

for i in range(n):
    if i == 0:
        count = 0
    elif i < n-1:
        if pl[i-1]<pl[i]<pl[i+1]:
            count = count + 1
        elif pl[i-1]>pl[i]>pl[i+1]:
            count = count + 1
            
print(count)


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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++){
    cin >> l.at(i);
  }
  
  sort(l.begin(), l.end() );
  
  int ans = 0;
  for (int i = 0; i < n; i++){
    for (int j = i+1; j < n; j++){
      for (int k = j+1; k < n; k++){
        if (l.at(i) < l.at(j) && l.at(j) < l.at(k) && l.at(k) < (l.at(i) + l.at(j))){
          ans += 1;
        }
      }
    }
  }
  cout << ans << endl;
}
          


Measured memory_bytes: 3636
package main

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

func main() {
    var fp *os.File = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)
    N, _ := strconv.Atoi(readLine(reader))
    var arr []int = make([]int, N)
    var arr2 []int = make([]int, N)

    for i := 0; i < N; i++ {
        num, _ := strconv.Atoi(readLine(reader))
        arr[i] = num
        arr2[i] = num
    }

    sort.Sort(sort.Reverse(sort.IntSlice(arr2)))

    max := 0

    for i := 0; i < N; i++ {
        for k, v := range arr2 {
            if arr[i] != v || (k != N - 1 && arr[i] == arr2[k+1]) {
                max = v
                break
            }
        }

        fmt.Println(max)
    }
}

func readLine(reader *bufio.Reader) string {
    buf := make([]byte, 0, 1024)

    for {
        l, p, _ := reader.ReadLine()

        buf = append(buf, l...)

        if !p {
            break
        }
    }

    return string(buf)
}

Measured memory_bytes: 7680
#include <stdio.h>
#include <iostream>


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

  int h[n];
  for (int i = 0; i < n; i++) scanf("%d",&h[i]);

  int cnt = 0;
  int max = 0;
  for(int i = 0; i < n-1; i++){
    if(h[i] >= h[i+1]){
      cnt++;
      if(cnt > max) max = cnt;
    }
    else cnt = 0;
  }

  std::cout << max << std::endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>

#define PI 3.1415926535
using namespace std;

int main()
{
	int a,b,arg;
	scanf("%d %d %d",&a,&b,&arg);
	double rad = (arg / 180.0) * PI;
	printf("%5lf\n",(a * b * sin(rad)) / 2);
	printf("%5lf\n",a + b + sqrt(a*a + b*b - 2*a*b*cos(rad)));
	printf("%5lf\n",b*sin(rad));
	return 0;
	
}

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

int main() {
  
  int N; cin >> N;
  
  int64_t sum = 0, leftSide = 0, dif = int64_t(pow(10, 16));
  
  vector<int64_t> vec(N);
  
  for (int i = 0; i < N; i++) {
    
    int64_t a; cin >> a;
    
    vec[i] = a; sum += a;
    
  }
  
  for (int i = 0; i < N - 1; i++) {
    
    leftSide += vec[i];
    
    int64_t rightSide = sum - leftSide;
    
    int64_t tmpDif = abs(leftSide - rightSide);
    
    dif = min(dif, tmpDif);
    
  }
  
  cout << dif << endl;
  
}

Measured memory_bytes: 4844
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

struct Jinfo{
	int start;
	int len;
};

int main(){
	string str;
	while(cin >> str){
		int res = 0;

		deque<char> jdeq;
		deque<char> odeq;
		deque<char> ideq;

		int onum=0;
		for(int i=0;i<str.size();i++){
			if(str[i]=='J'){
				if(odeq.size() > 0
					|| ideq.size() > 0){
						odeq.clear();
						ideq.clear();
						jdeq.clear();
				}
				
				jdeq.push_back(str[i]);
			}

			else if(str[i]=='O'){
				if(ideq.size() > 0){				
					jdeq.clear();
					odeq.clear();
					ideq.clear();
				}
				odeq.push_back(str[i]);
			}

			else if(str[i]=='I'){
				ideq.push_back(str[i]);
			}

			if(ideq.size() > 0
				&& odeq.size() > 0
				&& jdeq.size() > 0
				&& jdeq.size() >= odeq.size()
				&& ideq.size() >= odeq.size()){
					res = max(res,(int)odeq.size());
					jdeq.clear();
					ideq.clear();
					odeq.clear();
			}



		}

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

Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll al = pow(3,n);
    ll od = 1;
    rep(i,n){
        ll cnt = 0;
        if(a[i]%2!=0) cnt++;
        if((a[i]-1)%2!=0) cnt++;
        if((a[i]+1)%2!=0) cnt++;
        od*=cnt;
    }
    cout<<al-od<<endl;
    return 0;
}


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

const int MAXN = 1e5 + 10;
const int INF = 0x3f3f3f3f;

using namespace std;

int n, ans, mina, maxa;
int a[MAXN], dp[MAXN];

int main(){
    cin >> n;
    for (int i = 0;i < n;i ++) cin >> a[i];
    for (int i = 0;i < n;i ++) dp[i] = INF;
    reverse(a, a + n);
    dp[++ ans] = a[0];
    for (int i = 1;i < n;i ++){
        if (a[i] >= dp[ans]) dp[++ ans] = a[i];
        else *upper_bound(dp + 1, dp + ans + 1, a[i]) = a[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#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 each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string X; cin >> X;

    stack<char> S;
    rep(i, X.size()) {
        if (S.empty()) {
            S.push(X[i]);
            continue;
        }
        if (X[i] == 'S') {
            S.push(X[i]);
        } else {
            char s = S.top();
            if (s == 'S') S.pop();
            else S.push(X[i]);
        }
    }

    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define LL long long

void print() { std::cout << std::endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    std::cout << head;
    if(sizeof...(tail) != 0)
        std::cout << " ";
    print(std::forward<Tail>(tail)...);
}
template <class T> void print(std::vector<T> &vec) {
    for(auto &a : vec) {
        std::cout << a;
        if(&a != &vec.back())
            std::cout << " ";
    }
    std::cout << std::endl;
}
template <class T> void print(std::vector<std::vector<T>> &df) {
    for(auto &vec : df) {
        print(vec);
    }
}

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }

    int move_max = 0;
    int i = 0;

    while(i < N) {
        int test = i;
        int move = 0;
        while(test < N - 1 && H[test] >= H[test + 1]) {
            test++;
            move++;
        }

        i = test + 1;
        if(move_max < move) {
            move_max = move;
        }
    }

    print(move_max);
}

Measured memory_bytes: 640
using System;

namespace ABC_121_A
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			string[] grids = Console.ReadLine().Split();
			int H = int.Parse(grids[0]);
			int W = int.Parse(grids[1]);
			grids = Console.ReadLine().Split();
			int h = int.Parse(grids[0]);
			int w = int.Parse(grids[1]);
			
			Console.WriteLine((H - h) * (W - w));
		}
	}
}

Measured memory_bytes: 11092
<?php
class Era{
  public $start=0;
  public $end=0;
  public $name='';
  function __construct($in){
    list($en,$ey,$y)=explode(' ',$in);
    $this->start=$y-$ey+1;
    $this->name=$en;
    $this->end=$y;
  }
  function isIn($y){
    if($y<$this->start) return 0;
    if($y>$this->end) return 0;
    return 1;
  }
  function str($y){
    return $this->name.' '.($y-$this->start+1);
  }
}

while(1){
  list($N,$Q)=explode(' ',trim(fgets(STDIN)));
  if(!$N && !$Q) break;

  $eras=[];
  for($i=0;$i<$N;$i++) $eras[]=new Era(trim(fgets(STDIN)));

  for($i=0;$i<$Q;$i++){
    $y=trim(fgets(STDIN));
    $f='';
    foreach($eras as $era){
      if($era->isIn($y)){$f=$era->str($y);break;}
    }
    echo ($f)? $f:'Unknown',PHP_EOL;
  }
}

Measured memory_bytes: 15932