akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

vector<ll>prime_factorize(ll n){
    vector<ll>res;
    for(ll p = 2;p <= sqrt(n);p++){
      if (n%p != 0) continue;
      res.push_back(p);
      while(n % p == 0){
        n /= p;
        //res.push_back(p);
      }
      
    }
    if (n != 1) res.push_back(n);
    return res;
}

int main(){
    ll a,b; cin>>a>>b;
    vector<ll>A=prime_factorize(a);
    vector<ll>B=prime_factorize(b);
    ll ans=0;
    rep(i,A.size()){
        rep(j,B.size()){
            if(A[i]==B[j])ans++;
        }
    }
    ans++;
    cout<<ans<<endl;
}



























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

int main() {
    int N;
    long long int a[100]; 
    cin >> N;
    a[0] = 2, a[1] = 1; 
    for (int i = 2; i <= N; ++i) a[i] = a[i-1]+a[i-2] ;
    cout << a[N] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int m[111][111],W,H,N;
int main(){
    cin>>W>>H>>N;
    while(N--){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1){
            for(int i=0;i<x;i++){
                for(int j=0;j<H;j++){
                    m[i][j]=1;
                }
            }
        }
        else if(a==2){
            for(int i=x;i<W;i++){
                for(int j=0;j<H;j++){
                    m[i][j]=1;
                }
            }

        }
        else if(a==3){
            for(int i=0;i<W;i++){
                for(int j=0;j<y;j++){
                    m[i][j]=1;
                }
            }
        }
        else{
            for(int i=0;i<W;i++){
                for(int j=y;j<H;j++){
                    m[i][j]=1;
                }
            }
        }
    }
    int ans=W*H;
    for(int i=0;i<W;i++)
        for(int j=0;j<H;j++)
            ans-=m[i][j];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
typedef vector<int> vi;
typedef vector<ll> vii;
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
    return 0;
}


Measured memory_bytes: 256
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

#define N 100005

ll fac[N],inv[N],a[N];

ll fastexpo(ll b,ll p){
    ll res=1;
    while(p){
        if(p&1){
            res = (res * b)%mod;
        }
        p=p>>1ll;
        b=(b*b)%mod;
    }
    return res;
}

ll NCR(ll n,ll r){
    if(n==r or r==0) return 1;
    ll val = fac[n];
    val = (val * fastexpo(fac[n-r],mod-2))%mod;
    val = (val * fastexpo(fac[r],mod-2))%mod;
    return val;
}
int main(){
    fac[0]=1;
    for(ll i=1;i<=100000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    ll n,k;
    //cout << NCR(5,2) << endl;
    sfl(n),sfl(k);
    for(ll i=1;i<=n;i++){
        sfl(a[i]);
    }
    sort(a+1,a+n+1);
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        if(i-1>=k-1){
            ans += (NCR(i-1,k-1)*a[i])%mod;
            ans %= mod;
        }
        if(n-i>=k-1){
            ans -= (NCR(n-i,k-1)*a[i])%mod;
            (ans += mod)%=mod;
        }
    }
    pfl(ans);
    return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6)
h,w=map(int,input().split())
c=[list(input()) for i in range(h)]
dxy=((0,1),(0,-1),(1,0),(-1,0))
def dfs(y,x):
    flag=False
    for dx,dy in dxy:
        nx,ny=x+dx,y+dy
        if 0<=nx<=w-1 and 0<=ny<=h-1 and c[ny][nx]=="#":
            flag=True
    return flag
for i in range(w):
    for j in range(h):
        if c[j][i]=="#":
            if not dfs(j,i):
                print("No")
                sys.exit()
print("Yes")

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

int main() {
    ios::sync_with_stdio(false);
    int n, a[102] = {};
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    cout << a[n - 1] - a[0];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    char c[4];
    int i =0,j;
    for(j=0;j<4;j++){
        cin>>c[j];
        if(c[j]=='+'){
            i++;
        }
        else{
            i--;
        }
    }
    cout<<i;

}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--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 CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,k;
pii ps[52];
map<int,int> mapX, mapY;
int revX[52], revY[52];
int xm, ym;

int sum[52][52];

int main(){
  scanf("%d%d",&n,&k);
  REP(i,n){
    int x,y;
    scanf("%d%d",&x,&y);
    ps[i] = pii(x,y);
  }
  // zaatu
  {
    set<int> X, Y;
    REP(i,n){
      X.insert(ps[i].first);
      Y.insert(ps[i].second);
    }
    int it = 0;
    for(int x : X){
      mapX[x] = it;
      revX[it] = x;
      it++;
    }
    xm = it;
    it = 0;
    for(int y : Y){
      mapY[y] = it;
      revY[it] = y;
      it++;
    }
    ym = it;
  }
  REP(i,n){
    int x = ps[i].first;
    int y = ps[i].second;
    sum[mapX[x]+1][mapY[y]+1]++;
  }
  REP(i,52)REP(j,51)sum[i][j+1]+=sum[i][j];
  REP(i,51)REP(j,52)sum[i+1][j]+=sum[i][j];
  ll ans = (ll)(revX[xm-1]-revX[0]) * (revY[ym-1]-revY[0]);
  REP(r,xm)REP(l,r+1)REP(d,ym)REP(u,d+1){
    ll tmp = (ll)(revX[r]-revX[l]) * (revY[d]-revY[u]);
    if(tmp>=ans)continue;
    int cnt = sum[r+1][d+1] - sum[r+1][u] - sum[l][d+1] + sum[l][u];
    if(cnt>=k)ans=tmp;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  bool ok[101] = {};
  int n;
  cin >> n;
  REP(i, 10) {
    REP(j, 10) { ok[i * j] = true; }
  }
  if (ok[n]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int a = l[i];
            int b = l[j];
            int idx = lower_bound(l.begin(), l.end(), a + b) - l.begin();
            ans += max(idx - j - 1, 0);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
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;}

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
  ll N;
  cin >> N;
  int ans = 0;
  for(auto p : prime_factor(N)) {
    int k=1;
    while(k*(k+1)/2 <= p.second)k++;
    k--;
    ans += k;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
N=int(input())
S=input()
from collections import Counter
C=Counter(S)
ans=C['R']*C['G']*C['B']
for i in range(N):
    for j in range(i+1,N):
        if j+(j-i) >= N: break
        if S[i] != S[j] != S[j+(j-i)] != S[i]: ans-=1
print(ans)

Measured memory_bytes: 68752
# -*- coding: utf-8 -*-
"""
A - Zero-Sum Ranges
https://atcoder.jp/contests/agc023/tasks/agc023_a

"""
import sys


from itertools import accumulate
from collections import Counter

def solve(N, A):
    acc = [0] + list(accumulate(A))
    ans = 0
    for k, v in Counter(acc).items():
        if v > 1:
            ans += (v-1)*v//2
    return ans


def main(args):
    N = int(input())
    A = [int(a) for a in input().split()]
    ans = solve(N, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 41484
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    ll ret = 0;
    for(int i = 0;i < N - 1;i++) {
        ret += vec.at(i) / 2;
        vec.at(i) %= 2;
        if(vec.at(i) == 1 && vec.at(i + 1) != 0) {
            vec.at(i + 1)--;
            ret++;
        }
    }
    ret += vec.at(N - 1) / 2;
    cout << ret << endl;
}

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


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

    int n;
    cin>>n;
    vector<vector<int>> v(26);
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
        v[s[i][0]-'a'].push_back(i);
    }
    int dp[n+1];
    int INF = 1e9;
    for(int i=0;i<=n;i++) dp[i] = INF;
    int now[26]={};
    dp[0] = 0;
    for(int i=0;i<n;i++){
        dp[i+1] = dp[i]+1;
        int t = s[i][0]-'a';
        if(now[t]){
            int p = v[t][now[t]-1];
            dp[i+1] = min(dp[i+1], dp[p+1]);
        }
        now[t]++;

    }
    cout << dp[n] << endl;

}


Measured memory_bytes: 9216
# ARC087C - Good Sequence (ABC082C)
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    lst = list(map(int, input().rstrip().split()))
    cnt = {}
    for i in lst:
        if i not in cnt:
            cnt[i] = 0
        cnt[i] += 1
    ans = 0
    for i, j in cnt.items():
        if i > j:
            ans += j
        elif i < j:
            ans += j - i
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 18168
import std.stdio;

void main(){
	auto cin = new Cin();
	//auto j = new Joint();
	
	auto NK = cin.line();
	auto D = cin.line();
	
	auto N = NK[0];
	
	solve( N , D ).writeln();
	
	
}
auto solve( size_t n , size_t[] ng ){
	bool[10] nglist;
	nglist[] = true;
	bool up = false;
	
	foreach( elm ; ng ){
		nglist[elm] = false;
	}
	
	forD:foreach( i ; n..n+100_000 ){
		up = false;
		
		foreach_reverse( j ; 0..5 ){
			n = i%(10^^(j+1))/(10^^j);
			
			if( !up && n==0 ){
				continue;
			}else{
				up = true;
			}
			
			
			if( nglist[n] == false ){
				continue forD;
			}
		}
		return i;
	}
	return 0;
}
unittest{
	assert( solve(1111,[1,3,4,5,6,7,8,9]) == 2000 );
	assert( solve(9999,[0]) == 9999 );
	
	assert( solve(9999,[9]) == 10000 );
	assert( solve(10000,[0,9]) == 11111 );
	assert( solve(10000,[1,0]) == 22222 );
	assert( solve(5555,[5]) == 6000 );
	assert( solve(5959,[9]) == 6000 );
	
}


import std.stdio,std.conv,std.string;
import std.algorithm,std.array;

class Cin
{
	T[] line( T = size_t , string token = " " )( size_t m = 1 ){
		T[] arr = [];
		foreach( i ; 0..m ){
			arr ~= this.read!T();
		}
		return arr;
	}
	T[][] rect( T = real , string token = " " )( size_t m = 1 ){
		T[][] arr = new T[][]();
		foreach( i ; 0..m ){
			arr[i] = this.read!T(token);
		}
		return arr;
	}
	private T[] read( T = size_t )( string token = " " ){
		T[] arr;
		foreach( elm ; readln().chomp().split(token) ){
			arr ~= elm.to!T();
		}
		return arr;
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n),h(n);
    rep(i,n){
        cin >> a[i];
        h[i] = a[i];
    }
    sort(h.rbegin(),h.rend());
    rep(i,n){
        if(a[i] == h[0]) cout << h[1] << endl;
        else cout << h[0] << endl;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include<math.h>
typedef long long ll;
using namespace std;
vector<vector<int>>comp;
vector<int>onecycle;
vector<int>clength;
vector<int>v9;
vector<int>v8;
int cycle_start;
int cycle_end;
vector<int>vbip1;
vector<int>vbip2;
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
    int n,k;
    cin>>n>>k;
    int dp[n+1];
    dp[0]=0;
    int i;
    ll sum=0;
    int h[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
        dp[i+1]=INT_MAX;
    }
    dp[1]=0;
    dp[0]=0;
    for(i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-(j+1)>=0)
            {
                dp[i]=min(dp[i-j]+max(h[i-1]-h[i-j-1],h[i-j-1]-h[i-1]),dp[i]);
            }
        }
    }
    cout<<dp[n];
    
}


Measured memory_bytes: 4380
#include <iostream>
using namespace std;
int main(void){
    
    int x;
    
    for(int i = 1;i <=10000;i++){
        
        cin >>x;
        
        if(x == 0){
            break;
        }
        
        cout <<"Case "<<i<<": "<<x<<endl;
        
        
    }
    
}



Measured memory_bytes: 3052
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R


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

	string s;
	cin >> s;
	N = s.size();
	vector<int>v;
	if (N == 1) {
		cout << 0 << endl;
		return 0;
	}
	for (auto i : s)v.push_back(i - '0');
	L = -1;
	R = N;
	while (R - L > 1) {
		int mid = (R + L) / 2;
		auto w = v;
		w[N - 1] += mid * 10;
		w[N - 2] -= mid;
		if (w[N - 1] < w[N - 2]) {
			L = mid;
			continue;
		}
		bool flag = true;
		for (int i = N - 2; i; i--) {
			//int box = max(w[i + 1] - w[i], w[i - 1] - w[i] + 9);
			int box = w[i + 1] - w[i];
			if (box < 0)flag = false;
			box /= 10;
			w[i] += box * 10;
			w[i - 1] -= box;
		}
		//cout << mid << " " << w[0] << endl;
		for (int i = 1; i < N; i++) {
			if (w[i] < w[i - 1])flag = false;
		}
		if (w[1] > 0 && flag)R = mid;
		else L = mid;
	}
	cout << (v.back() + R * 10 + 8) / 9 << endl;
	return 0;
}


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

struct UnionFind {
    vector<ll> d;
    UnionFind(ll n=0): d(n, -1) {}

    ll find(ll x) {
        if (d[x] < 0) return x;
        else {
            d[x] = find(d[x]);
            return d[x];
        }
    }

    bool unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (d[x] > d[y]) swap(x, y);
        if (x == y) return false;
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(ll x, ll y) { return find(x) == find(y); }
    ll size(ll x) { return -d[find(x)]; }
};

int main() {

    ll N, M;
    cin >> N >> M;

    UnionFind uf(N);
    ll a, b;
    rep(m, M) {
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a, b);
    }

    ll ans = 0;
    rep(i, N) {
        ans = max(uf.size(i), ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4824
n = int(input())
a = [int(input()) for _ in range(n)]
left_l = [0]
right_l = [0]
for i in range(1, n):
    maxVal = max(left_l[i-1], a[i-1])
    left_l.append(maxVal)
for j in range(1, n):
    maxVal = max(right_l[j-1], a[-j])
    right_l.append(maxVal)
right_l.reverse()
for k in range(n):
    maxVal = max(left_l[k],right_l[k])
    print(maxVal)

Measured memory_bytes: 15656
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> vec;
	for(int i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		vec.push_back(x);
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	int num = 0;
	ll ans = 1;
	ll tmp = -1;
	bool ok = false;
	for(int i = 0; i < n; i++)
	{
		if(vec[i] == tmp)
		{
			num++;
			ans *= vec[i];
			tmp = -1;
		}
		else tmp = vec[i];
		if(num == 2)
		{
			ok = true;
		   	break;
		}
	}
	cout << (ok ? ans : ans - 1)<< endl;
	return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;

void initrand() {
    srand((ll)time(NULL));
}

ll dp[4][46];

int main() {
    ll N, K;
    cin >> N >> K;
    ll A[N];
    ll num[45];
    fill(num, num + 45, 0);
    REP(i, 0, N) {
        cin >> A[i];
        REP(j, 0, 45) {
            if (A[i] & ((ll)1 << j)) {
                num[j]++;
            }
        }
    }
    REP(i, 0, 4) {
        fill(dp[i], dp[i] + 46, 0);
    }
    REP(i, 0, 45) {
        ll po = (ll)1 << (44 - i);
        if (K & po) {
            dp[0][i + 1] = max(dp[0][i], dp[1][i]) + (N - num[44 - i]) * po;
            dp[3][i + 1] = max(dp[0][i], dp[1][i]) + num[44 - i] * po;
            if (dp[2][i] != 0) {
                dp[2][i + 1] = max(dp[2][i + 1], dp[2][i] + (N - num[44 - i]) * po);
                dp[3][i + 1] = max(dp[3][i + 1], dp[2][i] + num[44 - i] * po);
            }
            if (dp[3][i] != 0) {
                dp[2][i + 1] = max(dp[2][i + 1], dp[3][i] + (N - num[44 - i]) * po);
                dp[3][i + 1] = max(dp[3][i + 1], dp[3][i] + num[44 - i] * po);
            }
        } else {
            dp[1][i + 1] = max(dp[0][i], dp[1][i]) + num[44 - i] * po;
            if (dp[2][i] != 0) {
                dp[2][i + 1] = max(dp[2][i + 1], dp[2][i] + (N - num[44 - i]) * po);
                dp[3][i + 1] = max(dp[3][i + 1], dp[2][i] + num[44 - i] * po);
            }
            if (dp[3][i] != 0) {
                dp[2][i + 1] = max(dp[2][i + 1], dp[3][i] + (N - num[44 - i]) * po);
                dp[3][i + 1] = max(dp[3][i + 1], dp[3][i] + num[44 - i] * po);
            }
        }
    }
    ll ans = 0;
    REP(i, 0, 4) {
        ans = max(ans, dp[i][45]);
    }
    // initrand();
    // if ((rand() % 100) >= 8) {
    //     usleep(3000000);
    // }
    // if (((rand() * 2) % 100) >= 8) {
    //         ans = 0;
    // }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,b[10];
    vector<int> v(9);
    vector<bool> vb(9);
    for(int i=0;i<9;i++){
        cin>>v[i];
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    
    for(int i=0;i<9;i++){
        for(int j=0;j<n;j++){
            if(v[i]==b[j]){
               vb[i]=true;
               continue;
            }
        }
    }
    
    bool b0=vb[0]&vb[1]&vb[2];
    bool b1=vb[3]&vb[4]&vb[5];
    bool b2=vb[6]&vb[7]&vb[8];
    bool b3=vb[0]&vb[3]&vb[6];
    bool b4=vb[1]&vb[4]&vb[7];
    bool b5=vb[2]&vb[5]&vb[8];
    bool b6=vb[0]&vb[4]&vb[8];
    bool b7=vb[2]&vb[4]&vb[6];
    if(b0||b1||b2||b3||b4||b5||b6||b7){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input_string = "";
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  input_string = line;
});
reader.on('close', () => {
  const array = input_string.split(/\s/).map(x => Number(x));
  const a = array[0];
  const b = array[1];
  const c = array[2];

  if(a < b && b < c){
    console.log('Yes');
  } else {
    console.log('No');
  }
});




Measured memory_bytes: 16228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int toridasi = 0;
    string x;
    cin >> x;
    int cnts = 0;
    for (int i = 0; i < x.size(); ++i) {
        if(x[i] == 'S') cnts++;
        else if(cnts > 0) cnts--,toridasi++;
    }
    cout << x.size() - 2*toridasi << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
typedef long long ll;

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

    int n, k;
    cin >> n >> k;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = max(a[i], (ll)0);
    }
    vector<ll> sum1(n + 1), sum2(n + 1);
    sum1[0] = 0;
    sum2[0] = 0;
    for (int i = 0; i < n; i++)
    {
        sum2[i + 1] = sum2[i] + b[i];
        sum1[i + 1] = sum1[i] + a[i];
    }
    ll ans = 0;
    for (int i = 0; i + k <= n; i++)
    {
        ll tmp1 = max((ll)0, sum1[i + k] - sum1[i]);
        ll tmp2 = sum2[i] + sum2[n] - sum2[i + k];
        ans = max(ans, tmp1 + tmp2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k % 2 == 0) cout << a - b << endl;
  else cout << b - a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>rabbit(n);
  for(int i=0;i<n;i++){
  	cin>>rabbit[i];
  }
  int tot = 0;
  for(int i=0;i<n;i++){
  	if(rabbit[rabbit[i]-1]==i+1){
  		tot++;
  		rabbit[rabbit[i]-1]=-1;
  	}
  }
  cout<<tot<<endl;
} 






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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

const int MAX=2e5+9;
int n, m, k;
ll pref1[MAX], pref2[MAX];

int BSFind(int rest) {
    int low=0, high=m, res=0;

    while (low<=high) {
        int mid=((low+high)/2);

        if (pref2[mid]<=rest) {
            res=mid;
            low=mid+1;
        }
        else {
            high=mid-1;
        }
    }

    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m >> k;
    for (int i=1; i<=n; ++i) {
        int x;
        cin >> x;
        pref1[i]=x+pref1[i-1];
    }

    for (int i=1; i<=m; ++i) {
        int x;
        cin >> x;
        pref2[i]=x+pref2[i-1];
    }

    int ans=0;
    for (int i=0; i<=n; ++i) {
        int rest=k-pref1[i];
        if (rest<0) {
            break;
        }

        int can=BSFind(rest);
        ans=max(ans, i+can);
    }

    cout << ans;

    return 0;
}


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

int main(){
  int N;
  cin>>N;
  bool finished=false;
  while(true){
  	for(int i=1;i<N-1;i++){
  	  if(N%(i+1)==0){
      	finished=true;
      	break;
      }
  	}
    if(finished==true){
      N++;
      finished=false;
    }
    else
      break;
  }
  cout<<N<<endl;
}

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

using namespace std;
/*
#define ll long long
#define vi vector<ll>
vi primeFactors(ll N) { // remember: vi is vector<int>, ll is long long
vi factors;
ll PF_idx = 0, PF = primes[PF_idx]; // primes has been populated by sieve
while (PF * PF <= N) { // stop at sqrt(N); N can get smaller
while (N % PF == 0) { N /= PF; factors.push_back(PF); } // remove PF
PF = primes[++PF_idx]; // only consider primes!
}
if (N != 1) factors.push_back(N); // special case if N is a prime
return factors; // if N does not fit in 32-bit integer and is a prime
} // then ‘factors’ will have to be changed to vector<ll>
// inside int main(), assuming sieve(1000000) has been called before
vi r = primeFactors(2147483647); // slowest, 2147483647 is a prime
for (vi::iterator i = r.begin(); i != r.end(); i++) printf("> %d\n", *i);
r = primeFactors(136117223861LL); // slow, 104729*1299709
for (vi::iterator i = r.begin(); i != r.end(); i++) printf("# %d\n", *i);
r = primeFactors(142391208960LL); // faster, 2^10*3^4*5*7^4*11*13
for (vi::iterator i = r.begin(); i != r.end(); i++) printf("! %d\n", *i);
*/
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
printf("%d",(a-b)%c);
    /*
    int n,coun=0,ans=0;
    long long unsigned int fac=1;
    scanf("%d",&n);
    int c=1;
        int m=pow(2,c);
        while(m<n){
            c++;
            coun=n/m;
            ans+=coun;
            m=pow(2,c);
        }
        printf("%d",ans);
        */

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            for(int j=i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int main(){
    ios;
    string s;
    cin>>s;
    ll sum=0;
    for(int i=0;i<len(s);i++){
        sum+=s[i]-'0';
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

int main(){
    int N, Y;
    cin >> N >> Y;

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            int k = N - i - j;
            int total = i*10000 + j*5000 + k*1000;
            if(total == Y && k >= 0){
                cout << i << ' ' << j << ' ' << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << ' ' << -1 << ' ' << -1 << endl;

    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int n, k; cin >> n >> k;
	ll dp[55][55][2555];
	dp[0][0][0] = 1LL;
	rep(i, n) {
		rep(j, i + 1) {
			rep(l, n * n + 1) {
				(dp[i + 1][j + 1][l + 2 * (j + 1)] += dp[i][j][l]) %= mod;
				(dp[i + 1][j][l + 2 * j] += dp[i][j][l]) %= mod;
				(dp[i + 1][j][l + 2 * j] += dp[i][j][l] * 2 * j) %= mod;
				(dp[i + 1][j - 1][l + 2 * (j - 1)] += dp[i][j][l] * j * j) %= mod;
			}
		}
	}
	cout << dp[n][0][k] << endl;
	return 0;
}

Measured memory_bytes: 55680
#!/usr/bin/env python3
import sys

def method_1(N, Z, W, a):
    return abs(a[-1]-W)


def method_2(N, Z, W, a):
    return abs(a[-2]-a[-1])




def solve(N: int, Z: int, W: int, a: "List[int]"):
    res = 0
    
    res = max(res,method_1(N,Z,W,a))
    if N >= 2:
        res = max(res,method_2(N,Z,W,a))

    print(res)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, Z, W, a)

if __name__ == '__main__':
    main()


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


def main():
    N = int(input())
    result = 'No'
    for i in range(1, 10):
        if (N / i).is_integer()and (N / i) < 10:
            result = 'Yes'
            break
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
s = int(input())

def f(n):
    if n % 2 == 0:
        return n/2
    else:
        return 3*n + 1

history = {s}
a = s
i = 1
while True:
    i += 1
    a = f(a)
    if a in history:
        print(i)
        break
    history.add(a)

Measured memory_bytes: 3060
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s
}

fn main() {
	let s = read_line().split_whitespace().map(|e|e.parse().unwrap())
	.collect::<Vec<i32>>();
	let r = s[0] + s[1];
	if  r < 10 {
		println!("{}",r);
	}else{
		println!("error");
	}
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  string S;
  cin>>S;
  bool ok1=true;
  bool ok2=true;
  if(S[0]=='0'){
    if(S[1]=='0') ok1=false;
  }
  if(S[0]=='1'){
    if(S[1]!='0'&&S[1]!='1'&&S[1]!='2') ok1=false;
  }
  if(S[0]!='0'&&S[0]!='1') ok1=false;
  if(S[2]=='0'){
    if(S[3]=='0') ok2=false;
  }
  if(S[2]=='1'){
    if(S[3]!='0'&&S[3]!='1'&&S[3]!='2') ok2=false;
  }
  if(S[2]!='0'&&S[2]!='1') ok2=false;
  
  if(ok1){
    if(ok2) cout<<"AMBIGUOUS"<<endl;
    else cout<<"MMYY"<<endl;
  }
  else{
    if(ok2) cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
  }
}
 
  
    

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
#define INFTY 1000000001

typedef struct{
  char c;
  int x;
}card;

int part(card A[],int p,int r){
  int f,i,j;
  card tmp;

  f=A[r].x;
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].x<=f){
      i=i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;

  return i+1;
}

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

void merge(card *C,int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int i,j,k;
  card L[n1+N],R[n2+N];
  for(i=0;i<n1;i++) L[i]=C[left + i];
  for(i=0;i<n2;i++) R[i]=C[mid + i];
  L[n1].x=INFTY;
  R[n2].x=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++)
  {
    if(L[i].x<=R[j].x){
      C[k]=L[i];
      i=i+1;
    }
    else{
      C[k]=R[j];
      j=j+1;
    }
  }
}

void  mergeSort(card *C,int left,int right){
  int mid;

  if (left+1<right){
    mid=(left+right)/2;
    mergeSort(C,left,mid);
    mergeSort(C,mid,right);
    merge(C,left,mid,right);
  }
}

int main(){

  int i,j,n,x,stable=0;
  card A[N],B[N];

  scanf("%d",&n);

  for(i=0;i<n;i++) {
    scanf(" %c%d",&A[i].c,&A[i].x);
    B[i].c=A[i].c;
    B[i].x=A[i].x;
  }

  quickSort(A,0,n-1);

  mergeSort(B,0,n);

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

  if(stable==1)printf("Not stable\n");
  else printf("Stable\n");

  for(i=0;i<n;i++){
    printf("%c %d\n",A[i].c,A[i].x);
  }

  return 0;
}



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

using namespace std;
const int maxn = 1e5 + 100;

int cnt[maxn];

int main() {
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    int x, m = -1;
    for (int i = 0; i < n; i++) {
        cin >> x;
        cnt[x]++;
        m = max(m, x);
    }
    if ((cnt[m] == n && m == n - 1) ||
        (cnt[m] + cnt[m - 1] == n && cnt[m - 1] <m &&
         (m - cnt[m - 1]) * 2 <= cnt[m]))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var k = int.Parse(line[1]);
        string[] line2 = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line2, int.Parse);
        var res = a.OrderByDescending(x => x).Take(k).Sum();
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13396
/*
      author  : nishi5451
      created : 15.08.2020 13:47:48
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    if(a>b){
        rep(i,a){
            cout << b ;
        }
        cout << endl;
    }
    else if(b>a){
        rep(i,b){
            cout << a;
        }
        cout << endl;
    }
    else {
        rep(i,min(a,b)){
            cout << a;
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
  int N,M,f=0;
  cin >> N;
  int i=1;
  M=N;
  
  for(i;M!=0;i++){
    f+=M%10;
    M=(M-(M%10))/10;
  }
  if(N%f==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pcase cout<<"Case "<<++cs<<":"
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define inf 10000000000

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    int arr[3][n+5];
    for(i = 1; i <= n; i++) cin>>arr[0][i]>>arr[1][i]>>arr[2][i];
    int dp[3][n+5]; mem(dp,0);
    dp[0][1] = arr[0][1]; dp[1][1] = arr[1][1]; dp[2][1] = arr[2][1];
    for(i = 2; i <= n; i++){
        dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + arr[0][i];
        dp[1][i] = max(dp[0][i-1],dp[2][i-1]) + arr[1][i];
        dp[2][i] = max(dp[0][i-1],dp[1][i-1]) + arr[2][i];
    }
    cout << max3(dp[0][n], dp[1][n], dp[2][n]) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
#define YAKU_MAX 31623

int n, arr[YAKU_MAX], sosu[YAKU_MAX], nn, sosu_ko;

void Eratosthenes() {
	for (int i = 0; i < nn; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(nn); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < nn; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < nn; i++) {
		if (arr[i]) {
			sosu[sosu_ko] = i;
			sosu_ko++;
		}
	}
}

int main() {
	scanf("%d", &n);
	printf("%d:", n);
	nn = sqrt(n) + 1;
	Eratosthenes();


	while (1) {
		bool comp = false;
		for (int i = 0; sosu_ko > i; i++) {
			if (n == sosu[i]) {
				printf(" %d\n", sosu[i]);
				return 0;
			}

			else if (!(n % sosu[i])) {
				printf(" %d", sosu[i]);
				n /= sosu[i];
				comp = true;
				break;
			}
		}
		if (!comp) {
			printf(" %d\n", n);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1320
#include <cstdlib>
#include <cstdio>

int N=5e5;
int main(int argc, char* argv[])
{
  int64_t m,n,s=0;
  int c=getchar();
  while (1) {
    for(m=0;c=='<';m++,c=getchar());
    for(n=0;c=='>';n++,c=getchar());
    if (!(m|n)) break;
    s += (m>n?m:n) + m*(m-1)/2 + n*(n-1)/2;
  }
  printf("%ld\n",s);
}

Measured memory_bytes: 128
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

inline ll sqr(ll x)
{
	ll l=0,r=1e9,ans=0;
	while(l<=r)
	{
		ll mid=(l+r)>>1;
		if(mid*mid<=x) l=mid+1,ans=mid;
		else r=mid-1;
	}
	return ans;
}

int main()
{
	int Q=read();
	while(Q--)
	{
		ll a=read(),b=read(),ans; if(a>b) swap(a,b);
		if(a==1&&b==1) {puts("0"); continue;}
		ll tmp=(ll)sqr(a*b-1),p=sqrt(a*b-1); ans=tmp*2;
		if((ll)((a*b-1)/p)==p) ans--;
		if(a!=b) ans--; printf("%lld\n",max(ans,0ll));
	}
	return 0;
}

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


int main(){
	rep(i,5){
		int n;cin >> n;
		if(n==0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}







Measured memory_bytes: 3580
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    // メンバ変数---
    int N;
    int K;
    int[] H;
    // -------------

    void calc()
    {
        N = cin.nextInt();
        K = cin.nextInt();
        H = cin.ArrayInt(N);
        int ret = 0;
        foreach(var i in H)
        {
            if(i >= K)
            {
                ret++;
            }
        }
        Write(ret);
    }

    void Write(string v)
    {
        Console.WriteLine(v);
    }

    void Write(int v)
    {
        Console.WriteLine(v);
    }

    void Write(double v)
    {
        Console.WriteLine(v);
    }
    void Write(long v)
    {
        Console.WriteLine(v);
    }

    int Pow(int x, int y)
    {
        return (int)Math.Pow(double.Parse(x.ToString()), double.Parse(y.ToString()));
    }

    double Pow(double x, double y)
    {
        return Math.Pow(x, y);
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

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

        public long nextLong()
        {
            return long.Parse(next());
        }

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

        public double nextDouble()
        {
            return double.Parse(next());
        }


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

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

using namespace std;

const int Nmax = 2e5 + 10;
const int Mod = 1e9 + 7;
const int oo = 1e9;

int a, b, c, k;

int main()
{
/**
    #ifndef ONLINE_JUDGE
        ifstream cin("test.in");
        ofstream cout("test.out");
    #endif // ONLINE_JUDGE
*/

    cin >> a >> b >> c >> k;

    int s = 0;
    if(k > a)
    {
        k -= a;
        s = a;
        if(k > b)
        {
            k-= b;
            if(k > c)
            {
                s -= c;
            }
            else s -= k;
        }
    }
    else s = k;

    cout << s;
    return 0;
}


Measured memory_bytes: 3632