akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<fstream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<cmath>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<stdio.h>
#include<queue>
#define pb push_back
#define ll long long
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
int a,b,c,d;
int main()
{
  cin>>a>>b;
  a=min(a,b);
  cin>>c>>d;
  c=min(c,d);
  cout<<a+c<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n;
    cin >> n;
    vector<ll> A(n+1, 0);
    vector<ll> B(n, 0);
    for(int i = 0; i < n+1; i++)
        cin >> A[i];
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> B[i];
        ans += min(A[i], B[i]);
        if (B[i] > A[i]) {
            B[i] -= A[i];
            if (A[i+1] >= B[i]) {
                A[i+1] -= B[i];
                ans += B[i];
            } else {
                ans += A[i+1];
                A[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
def count(k, s):
    answer = 0

    for a in range(s + 1):
        if a > k:
            # aは増える一方なので
            break

        if s - a > 2*k:
            continue

        for b in range(a, s + 1):
            x = a - 0
            y = b - a
            z = s - b

            if y > k:
                break

            if z <= k and x + y + z == s:
                answer += 1

    return answer

k, s = map(int, input().split())
print(count(k, s))

Measured memory_bytes: 39792
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k;
P a[MAXN];
int ans[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i].F);
		a[i].S=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		if(i<=n/2) ans[a[i].S]=a[n/2+1].F; else ans[a[i].S]=a[n/2].F;
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4480
#include <stdio.h>
#define GRAY  2 
#define WHITE 1
#define BLACK 3 
#define INF -1
int n,color[110],d[110],Q[110],adj[110][110];
int head=0,tail=0;
int judge(){
  if(tail==head) return 1;

  return 0;
}

void enQ(int s){
  Q[tail]=s;
  if(tail==110)tail=0;
  else tail++;
}
int deQ(){
  int a;
  a=Q[head];
  if(head==100)head==0;
  else head++;

  return a;
}

void bfs(int s){
  int i,j,u;
  for(i=2;i<=n;i++){
    color[i]=WHITE;
    d[i]=INF;
  }

  color[s]=GRAY;
  d[s]=0;
 
  enQ(s);

  while(judge() != 1){
 
    u = deQ();
 
    for( j = 1; j <= n; j++ ){
      if(color[j]==WHITE&&adj[u][j]==1){
 
	color[j] = GRAY;
 
	d[j] = d[u] + 1;
 
	enQ(j);
      }
    }
    color[u]=BLACK;
  }

}


int main(){

  int u,k,v,i,j;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      adj[u][v]=1;
    }
  } 
  bfs(1);

  for(i=1;i<=n;i++){
    printf("%d %d\n",i,d[i]);
  }
  return 0;



}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

int main(){
  int n;
  cin >> n;
  VI a(n);
  REP(i,n)cin >> a[i];

  int ans=0;
  FOR(i,1,n){
    if(i==1)ans=gcd(a[i],a[i-1]);
    else ans=gcd(ans,a[i]);
  }
  cout << ans << endl;

}



Measured memory_bytes: 640
import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]
# input
_ = int(input())
S = input()
s = deque([i for i in S])

count = 1
last = s.popleft()
for i in range(_-1):
    poped = s.popleft()
    if last == poped:
        continue
    else:
        count += 1
        last = poped
print(count)
    



Measured memory_bytes: 5016
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, K;
    cin >> N >> K;
    vec V(N);
    loop(i, N) cin >> V[i];
    ll ans = 0;
    loop(i, K + 1)
    {
        ll L = i; //左から取り出す個数
        if (L > N)
            continue;
        ll Limit = K - L; //右から取り出すことのできる上限
        loop(j, Limit + 1)
        {
            ll R = j;
            if (L + R > N)
                continue;
            vector<ll> select;
            loop(x, L)
            {
                select.push_back(V[x]);
            }
            loop(y, R)
            {
                select.push_back(V[N - 1 - y]);
            }
            sort(all(select));
            ll remain = K - (L + R);
            ll preans = 0;
            loop(k, L + R)
            {
                if (remain > 0 && select[k] < 0)
                {
                    remain--;
                    continue;
                }
                preans += select[k];
            }
            ans = max(ans, preans);
        }
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
//int t[100005] , x[100005] , y[100005];
ll exp(ll a , ll b){
	if(b == 0)	return 1;
	int x = b % 2 == 0 ?   ((exp(a , b/2)%mod)*(exp(a , b / 2)%mod))%mod :  (a%mod*exp(a , b - 1) % mod)%mod;
	return x;
}
ll dp[nax];
int main(){
	dhoom;
	ll n , k;
	cin >>n >> k;
	ll ans = 0;
	for(int i = k ; i >= 1 ; i--){
		dp[i] = (k / i); // that much multiples are there for i 
		dp[i] = exp(dp[i],n);
		for(int j = 2 * i ; j <= k ; j+=i){
			dp[i] = (dp[i] - dp[j] + mod)%mod;
		}
	//	cout << dp[i] << " " << i << endl;
		ans = ans + dp[i]*i;
		//cout << ans << endl;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
	
}


Measured memory_bytes: 4424
import java.util.*;

public class Main{
	public static void main(String[] args){

    Scanner scanner = new Scanner(System.in);

    String x = scanner.nextLine();
    String[] str = x.split("");
    int a = 0;
    for(String s : str){
    	if(s.equals("1")){a ++ ;}
    }
    System.out.println(a);
    }
}

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

// headers {{{
using namespace std;
// using namespace rel_ops;
 
const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x7FFFFFFF;
template<class T> inline bool checkmin(T &a,T b){return b<a?a=b,1:0;}
template<class T> inline bool checkmax(T &a,T b){return b>a?a=b,1:0;}
template<class T> inline T sqr(T x){return x*x;}
template<class T> inline bool bit(T a, int b) {return (a>>b)&1;}
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(long long n) { return __builtin_popcountll(n); }
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define eb(args...) emplace_back(args)
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ff first
#define ss second
#define sz(g) int(g.size())
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
#ifdef LOCAL
#define dout cerr 
void out() { dout << endl; }
template<typename A, typename... B> void out(A a, B... b) { dout << ' ' << a; out(b...); }
#define dbg(args...) dout << __LINE__ << ":(" << #args << ") -> ", out(args)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
constexpr bool local = true;
#else
#define dbg(...)
#define dout if(true);else cerr
#define out(...)
#define show(...)
constexpr bool local = false;
#endif
// }}}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    int x, n;
    while (cin >> x >> n) {
        VI a(n);
        set<int> st;
        rep(i, n) {
            cin >> a[i];
            st.insert(a[i]);
        }
        int ans = -1;
        rep(i, 102) {
            if (st.count(i)) continue;
            int d1 = abs(ans-x), d2 = abs(i-x);
            if (d2 < d1 || (d1 == d2 && i < ans)) 
                ans = i;
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
 using namespace std;
 int main(){
     int n,k,x,y,sum;
     cin>>n>>k>>x>>y;
     if(n>k){
        sum=(k*x)+((n-k)*y);
     }
     else{
        sum=(n*x);
     }
     cout<<sum<<endl;
     return 0;
 }


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=1e5;
int a[L];
int N;
bool f()
{
	if(abs(a[0]-a[N-1])>1){
		return false;
	}

	if(a[0]==1)
	{
		if (a[N-1]==1){
			return true;
		}
		return a[1]==2;
	}

	if(a[0]==a[N-1] && a[0]==N-1){
		return true;
	}


	int c=lower_bound(a,a+N,a[N-1])-a;
	return c+(N-c)/2>=a[N-1] && a[N-1]>=c+1;
}
int main() {
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	sort(a,a+N);
	if(f())
	{
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	

	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
using namespace std;
const int inf = 1<<30;
typedef long long ll;
const int mod = 1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint operator-() const { return mint(-x);}
  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 pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(int n, int a) {
  mint x = 1, y = 1;
  for(int i = 0; i < a; i++) {
    x *= n-i;
    y *= i+1;
  }
  return x/y;
}

int main() {
  int n, a, b; cin >> n >> a >> b;
  mint ans = mint(2).pow(n);
  ans -= 1;
  ans -= choose(n, a);
  ans -= choose(n, b);
  cout << ans.x << endl;

  return 0;
}


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

typedef pair<int,int> P;

int main() {
  int n;
  while(cin >> n && n!=0) {
    int h,w;
    cin >> h >> w;
    vector<P> a;
    for(int i=0; i<n; i++) {
      int x,y;
      cin >> x >> y;
      a.push_back(P(x,y));
    }
    sort(a.begin(), a.end());
    int s,t;
    cin >> s >> t;
    
    int max=0;
    for(int i=1; i+s<=h+1; i++) {
      for(int j=1; j+t<=w+1; j++) {
	int cnt=0;
	for(int k=0; k<a.size(); k++) {
	  if(a[k].first>=i && a[k].first<i+s && a[k].second>=j && a[k].second<j+t) {
	      cnt++;
	    }
	} 
	if(cnt>max) max=cnt;
      }
    }
    cout << max << endl;
  }
  return 0;
}


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

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

	int n; cin >> n;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	long long a_bigger = 0, b_bigger = 0;
	for(int i = 0; i < n; i++) {
		if(b[i] > a[i]) b_bigger += (b[i] - a[i]) / 2;
		if(a[i] > b[i]) a_bigger += a[i] - b[i];
	}
	if(b_bigger >= a_bigger) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;	
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
    int h,w;
    int i,j;

    while(1){
        scanf("%d %d",&h,&w);

        if(h==0 && w==0) break;

        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("#");
            }
         printf("\n");

      }  printf("\n");


    }

    return 0;
}



Measured memory_bytes: 2056
/*input
10 7 5
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, j, k)  for(int i = j; i <  k; ++i)
#define RREP(i, j, k) for(int i = j; i >= k; --i)
#define F first
#define S second
#define mp make_pair
#define pb emplace_back
#define PII pair<int , int>
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 
#define INF 0x3f3f3f3f

int n , a , b;

int32_t main(){
    IOS;
    cin >> n >> a >> b;
    cout << min(a , b) << " " << max(a + b - n , 0) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    ll f[m] = {};
    f[x] = 1;

    ll ans = 0;
    if(n <= 1000000){
        rep(i,n){
            ans += x;
            x = x * x % m;
        }
        cout << ans << endl;
        return 0;
    }

    ll xx = x;
    ll loop = 0;
    ll start = 0;
    while(true){
        ll nx = x * x % m;
        int now = f[x] + 1;
        if(f[nx] != 0){
            loop = now - f[nx];
            start = f[nx];
            break;
        }
        f[nx] = now;
        x = nx;
    }

    x = xx;
    rep(i,start-1){
        ans += x;
        x = x * x % m;
        n--;
    }

    ll sum = 0;
    rep(i,m) f[i] = 0;
    f[x] = 1;
    sum = x;
    rep(i,loop-1){
        ll nx = x * x % m;
        f[nx] = 1;
        x = nx;
        sum += x;
    }

    ans += (n/loop)*sum;
    n -= n/loop*loop;

    
    while(n>0){
        n--;
        x = x*x%m;
        ans += x;
    }

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




Measured memory_bytes: 4368
/*
	written by Pankaj Kumar.
	country:-INDIA
*/
#include<algorithm>
#include<string.h>
#include<iostream>
#include<vector>
#include<cmath>
#include<set>
using namespace std;
typedef long long ll ;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sl;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007;
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first;
#define second ss;
#define mk make_pair;
#define line cout<<endl;
#define pb push_back
#define INT_SIZE sizeof(int)
#define INT_BITS INT_SIZE*8-1
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  -----------------------------------------------------------------------------------*/


int main()
{
	pan;
	int r;
	cin>>r;
	printf("%0.9f\n",2*r*3.1415926535);
	// printf("%.9f\n",6.28318530717958623200/(2*r));
}

Measured memory_bytes: 3784
X, Y = map(int, input().split())
x = max(X, Y)
y = min(X, Y)
#計算量問題あり
'''
for i in range(y):
    if(x%(y-i)==0)and(y%(y-i)==0):
        print(y-i)
        exit()
'''
while x != y:
    if x > y:
        x -= y
    else:
        y -= x
print(x)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin>>N>>K;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  int ans=0;
  for(int i=0;i<K;i++){
    ans=ans+vec.at(i);
  }
  cout<<ans;
}


Measured memory_bytes: 3600
from math import factorial

N,P=map(int,input().split())
A=list(map(int,input().split()))

num_k=0
num_g=0
for i in range(N):
    if A[i]%2==0:
        num_g+=1
    else:
        num_k+=1

n=num_k//2
ans_k=0
for i in range(0,n*2+1,2):
    ans_k+=factorial(num_k)/factorial(i)/factorial(num_k-i)

ans_g=2**(num_g)

ans=int(ans_k*ans_g)

if P==0:
    print(ans)
else:
    ans=2**N-ans
    print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PAIR;
const int maxn = 2e5+5;
int a[maxn];
int main() {
	int n;
	double m;
	cin>>n>>m;
	int cnt = 0;
	ll sum = 0;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    	sum+=a[i];
	}
	for(int i=1;i<=n;i++){
		if(4*m*a[i]<sum){
			cnt++;
		}
	} 
	if((n-cnt)<m){
		cout<<"No\n";
	}
	else {
		cout<<"Yes\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cmath>
using namespace std;


int main(){
	

	int n;
	int ind=0;
	char arr[100000];
	
	int a,b,c;
	cin>>n>>a>>b>>c;
	string cur;
	cin>>cur;
	for(int i=0;i<n;i++){
		if(cur=="AB"){
			if(a>b){
				arr[ind++]='B';
				if(i<n-1)cin>>cur;
				a--;
				b++;
				continue;
			}
			if(a<b){
				arr[ind++]='A';
				if(i<n-1)cin>>cur;
				a++;
				b--;
				continue;
			}
			if(a==b&&a==0){
				cout<<"No"<<endl;
				return 0;
			}
			if(a==b&&a!=0){
				if(i<n-1)cin>>cur;
				else {arr[ind++]='A';break;}
				if(cur=="AB"){
					arr[ind++]='A';
					arr[ind++]='B';
				  i++;
				  if(i<n-1)cin>>cur;
				  continue;
				}
				if(cur=="AC"){
					arr[ind++]='A';
					a++;
					b--;
				  continue;
				}
				if(cur=="BC"){
					arr[ind++]='B';
					b++;
					a--;
					continue;
				}
				
			}
		}
		if(cur=="BC"){
			if(b>c){
				arr[ind++]='C';
				if(i<n-1)cin>>cur;
				c++;
				b--;
				continue;
			}
			if(c>b){
				arr[ind++]='B';
				if(i<n-1)cin>>cur;
				b++;
				c--;
				continue;
			}
			if(c==b&&c==0){
				cout<<"No"<<endl;
				return 0;
			}
			if(c==b&&c!=0){
				if(i<n-1)cin>>cur;
				else {arr[ind++]='C';break;}
				if(cur=="BC"){
					arr[ind++]='C';
					arr[ind++]='B';
				  i++;
				  if(i<n-1)cin>>cur;
				  continue;
				}
				if(cur=="AC"){
					arr[ind++]='C';
					c++;
					b--;
				  continue;
				}
				if(cur=="AB"){
					arr[ind++]='B';
					b++;
					c--;
					continue;
				}
			}
		}
		if(cur=="AC"){
			if(a>c){
				arr[ind++]='C';
				if(i<n-1)cin>>cur;
				c++;
				a--;
				continue;
			}
			if(c>a){
				arr[ind++]='A';
				if(i<n-1)cin>>cur;
				a++;
				c--;
				continue;
			}
			if(c==a&&c==0){
				cout<<"No"<<endl;
				return 0;
			}
			if(c==a&&c!=0){
				if(i<n-1)cin>>cur;
				else {arr[ind++]='A';break;}
				if(cur=="AC"){
					arr[ind++]='C';
					arr[ind++]='A';
				  i++;
				  if(i<n-1)cin>>cur;
				  continue;
				}
				if(cur=="BC"){
					arr[ind++]='C';
					c++;
					a--;
				  continue;
				}
				if(cur=="AB"){
					arr[ind++]='A';
					a++;
					c--;
					continue;
				}
			}
		}
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<ind;i++)cout<<arr[i]<<endl;
	return 0;
}


	


Measured memory_bytes: 3736
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
d = defaultdict(int)
a = LI()
for i in a:
    d[i] += 1
d = list(d.items())
d.sort(key = lambda x:-x[0])
l = 0
k = 0
for i,j in d:
    if j >= 2:
        if l == 0:
            l = i
        else:
            k = i
        if j >= 4:
            k = i
    if k != 0:break
print(l*k)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

int main(){
string S;
int N;
int size;
string alpha ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
cin >>N;
cin >> S;
size = S.length();
for(int i=0;i<size;i++){
    for(int j=0;j<26;j++){
        if(S[i]==alpha[j]){
            S[i]=alpha[(j+N)%26];
            break;
        }
    }
}
cout << S ;



return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


int pre[100005];

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+n+1);

    int sum=a[1];
    for(int i=2;i<=n;i++)
    {
        int z=a[i]-2*sum;
        int l=1,r=n;
        int mn=n+1;
        while (l<=r)
        {
            int  mid=l+(r-l)/2;
            if(a[mid]>=z)
            {
                r=mid-1;
                mn=min(mn,mid);
            }
            else
            {
                l=mid+1;
            }            
        }
        if(z>0)
        {
            pre[1]++;
            mn=max(mn,i);
            pre[mn]--;            
        }
        sum+=a[i];
    }
    int ans=0;
    if(a[1]*2>=a[2]&& pre[1]==0)
        ans++;
    for(int i=2;i<=n;i++)
    {
        pre[i]+=pre[i-1];
        if(pre[i]==0)
        {
            ans++;
        }
    }
    cout<<ans;

} 
    
 


Measured memory_bytes: 5212
#!/usr/bin/env python3
import sys
from itertools import chain


def gcd(a, b):
    """最大公約数
    """
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    """最小公倍数
    """
    return a * b // gcd(a, b)


def solve(A: int, B: int):
    answer = lcm(A, B)
    return answer


def main():
    A, B = map(int, input().split())
    answer = solve(A, B)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9016
def solve(s, q, query_list):
    flag = 1
    add_right = []
    add_left = []
    for i in range(q):
        query = query_list[i]
        if len(query) == 1:
            flag *= -1
        else:
            if query[1] == "1":
                if flag == 1:
                    add_left.append(query[2])
                else:
                    add_right.append(query[2])
            else:
                if flag == 1:
                    add_right.append(query[2])
                else:
                    add_left.append(query[2])
    s = "".join(list(reversed(add_left))) + s + "".join(add_right)
    # print(s, flag)
    if flag == 1:
        return s
    else:
        return "".join(list(reversed(s)))


def main():
    s = input()
    q = int(input())
    query_list = [list(input().split()) for _ in range(q)]
    res = solve(s, q, query_list)
    print(res)


def test():
    assert solve("a", 4, [["2", "1", "p"], ["1"], ["2", "2", "c"], ["1"]]) == "cpa"
    assert solve("a", 6, [["2", "2", "a"], ["2", "1", "b"], ["1"], ["2", "2", "c"], ["1"], ["1"]]) == "aabc"
    assert solve("y", 1, [["2", "1", "x"]]) == "xy"


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 33660
#include <stdio.h>

typedef struct{
	char suit;
	char value;
} card;

void bubble(card *p,int N);

int main(){
	card p1[50];
	card p2[50];
	card key;
	int i,j,N,min,f=0,l=0;

	scanf("%d",&N);

	for(i=0;i<N;i++){
		scanf(" %c%c",&p1[i].suit,&p1[i].value);
	}

	for(i=0;i<N;i++){
		p2[i]=p1[i];
	}

	bubble(p1,N);

	for(i=0;i<N;i++){
		printf("%c%c",p1[i].suit,p1[i].value);
		if(i!=N-1) printf(" ");
	}
	printf("\nStable\n");	

	for(i=0;i<N;i++){
		min=i;
		f=0;
		for(j=i+1;j<N;j++){
			if(p2[j].value==p2[min].value) f=1;
			if(p2[j].value<p2[min].value){
				min=j;
				if(f==1) l=1;
			}
		}
		if(min!=i){
			key=p2[i];
			p2[i]=p2[min];
			p2[min]=key;
		}
	}

	for(i=0;i<N;i++){
		printf("%c%c",p2[i].suit,p2[i].value);
		if(i!=N-1) printf(" ");
	}
	printf("\n");
	if(l==1) printf("Not stable\n");
	else printf("Stable\n");

	return 0;
}

void bubble(card *p,int N){
	card key;
	int i,j;
	for(i=0;i<N;i++){
		for(j=N-1;j>i;j--){
			if(p[j].value<p[j-1].value){
				key=p[j];
				p[j]=p[j-1];
				p[j-1]=key;
			}
		}
	}
}

Measured memory_bytes: 612
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;
const double INF=1000000000;
int main(){
  int n,m;
  cin>>n>>m;
  int a[100],b[100],c[100],d[100];
  rep(i,n)cin>>a[i]>>b[i];
  rep(i,m)cin>>c[i]>>d[i];
  int p;
  rep(i,n){
    double kyori=INF;
    rep(j,m){
      int  dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(kyori>dis){
	kyori=dis;
	p=j;
      }
    }
    cout<<p+1<<endl;
  }
  
  
    
	 
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int n,k,a,ans;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(k);
	for (int i=1;i<=n;i++) {
		read(a); if (a>=k) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    rep(i,n) {
        int a;
        cin >> a;
        pq.push(a);
    }
    for(int i = 0; i < m;i++) {
        int save = pq.top() / 2;
        pq.pop();
        pq.push(save);
    }
    ll ans = 0;
    while(!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream> 

using namespace std; 

int 

main () 

{ 

  

  int a = 1; 

  int b; 

  while (cin>>b && b) 

    { 

       

      cout << "Case " << a << ": " << b << endl; 

      a++; 

      

    } 
return 0;
   

} 


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int a = sc.nextInt();
			if(a==0)
				break;
			int[] sum = new int[a];
			int[] sum2 = new int[a];
			int sumA = 0;
			int[][] b = new int[a][a];
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < a; j++) {
					b[i][j] = sc.nextInt();
				}
			}
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < a; j++) {
					sum[i] += b[i][j];
					sum2[j] += b[i][j];
				}
				sumA += sum[i];
			}
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < a; j++) {
					System.out.printf("%5d", b[i][j]);
				}
				System.out.printf("%5d", sum[i]);
				System.out.println();
			}
			for (int i = 0; i < a; i++) {
				System.out.printf("%5d", sum2[i]);
			}
			System.out.printf("%5d", sumA);
			System.out.println();

		}
	}

}



Measured memory_bytes: 31236
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//??????a[]?????¨??????????¶??????????????????°??????
  
public class Main {

  static int n ;
  
  static int a[] = new int[405];

  static  Set<Integer> d=new HashSet<Integer>();
 
  
  static int sum_idx; 

  static int m;

  //????????¢??°?????§a[cnt]????¶????????????????tmp = ????????£?????????
  public static void dfs(int cnt, int tmp) {
    if (cnt == n) {
      d.add(tmp);
      sum_idx++;
     
      m++;
      return; 
    }
    dfs(cnt+1, tmp);
    dfs(cnt+1, tmp + a[cnt]);
  }

  public static void main(String[] args) {
	Scanner sc=new Scanner(System.in);
	n=Integer.parseInt(sc.next());
	for(int i=0;i<n;i++){
		a[i]=Integer.parseInt(sc.next());
	}
	
    m = 0;
    sum_idx = 0;
    
    dfs(0, 0);
    
   
   
    
    int q=Integer.parseInt(sc.next());
    
    int x;
    for(int j=0;j<q;j++)
    {
    	x=Integer.parseInt(sc.next());
    	System.out.println((d.contains(x)) ? ("yes") : ("no"));
    }
    
  }
}

Measured memory_bytes: 59200
import java.lang.reflect.Array;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        boolean[] flags = new boolean[b];
        boolean ans = false;
        for (int i = 0; ; i++) {
            int num = (a * i) % b;
            if (num == c) {
                ans = true;
                break;
            }
            if (flags[num])
                break;
            flags[num] = true;
        }
        if (ans)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 21972
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <iostream>
#define ll long long
using namespace std;
ll x;

int main() {
    scanf("%lld", &x);
    ll ans = 0;
    ans += 1000 * (x / 500);
    x %= 500;
    ans += 5 * (x / 5);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define maxn 1000000000000000000LL
#define pi 3.1415926535898
#define eps 1e-6
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,m,nb,i,j,x,y,a[100005],b[100005],du[100005],flag,sum;
int top2,zhan1[100005],zhan2[100005],dp[100005][2],ans,max1,max2;
int top,nex[200005],to[200005],fir[100005];
char s[100005];
void lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
void ss(int u,int v){
	a[v]=1;
	if(s[v]=='B')
		b[v]=1;
	for(int top1=fir[v];top1;top1=nex[top1])
		if(to[top1]!=u){
			ss(v,to[top1]);
			a[v]+=a[to[top1]];
			b[v]+=b[to[top1]];
		}
	if(u!=v){
		if(a[v]!=b[v]&&n-a[v]!=nb-b[v]){
			top2++;
			zhan1[top2]=u;
			zhan2[top2]=v;
		}
	}
}
void ss2(int u,int v,int w){
	w+=1+(du[v]==1)-(du[v]==0);
	if(w>max1){
		max1=w;
		max2=v;
	}
	for(int top1=fir[v];top1;top1=nex[top1])
		if(to[top1]!=u)
			ss2(v,to[top1],w);
}
int main(){
	n=read();
	for(i=1;i<n;i++){
		x=read();y=read();
		lj(x,y);
		lj(y,x);
	}
	scanf("%s",s+1);
	for(i=1;i<=n;i++)
		if(s[i]=='B')
			nb++;
		else
			flag=i;
	if(nb==n){
		pus(0,2);
		return 0;
	}
	if(nb==n-1){
		pus(1,2);
		return 0;
	}
	ss(1,1);
	for(i=1;i<=top;i++){
		to[i]=0;
		nex[i]=0;
	}
	for(i=1;i<=n;i++){
		fir[i]=0;
		a[i]=0;
		b[i]=0;
	}
	top=0;
	for(i=1;i<=top2;i++){
		lj(zhan1[i],zhan2[i]);
		lj(zhan2[i],zhan1[i]);
		du[zhan1[i]]++;
		du[zhan2[i]]++;
	}
	for(i=1;i<=n;i++){
		if(du[i]>=1)
			m++;
		if(s[i]=='W'&&(du[i]&1)==0||s[i]=='B'&&(du[i]&1))
			du[i]=1;
		else
			du[i]=0;		
	}
	nb=0;
	for(i=1;i<=n;i++)
		nb+=du[i];
	ans=(m-1)*2+nb;
	ss2(flag,flag,0);
	ss2(max2,max2,0);
	ans-=max1;
	pus(ans,2);
    return 0;
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
#define maxc 1000010
#define ll long long
int main()
{
    int a[110];
    ll n,x;
    cin>>n>>x;
    ll add=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        add+=a[i];
    }
    if(add<x){
        cout<<n-1<<endl;
        return 0;
    }
    sort(a,a+n);
    ll sum=0;
    for(int i=0;i<n;i++){
        x-=a[i];
        if(x<0)
            break;
        else
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli T[800030];
// void build(int p, int i, int j){
// 	if(i==j) {T[p] = A[i]; return;}
// 	int mid = i+(j-i)/2;
// 	build(2*p+1, i, mid);
// 	build(2*p+2, mid+1, j);
// 	T[p] = max(T[2*p+1],T[2*p+2]);
// }
void update(int p, int L, lli value, int i, int j){
	if(i>L || j<L) return;
	if(i==j and i==L){
		// cout<<"updated at p:"<<p<<" with"<<value<<endl;
		T[p]=value;
		return;
	}
	int mid = i+(j-i)/2;
	update(2*p+1, L, value, i, mid);
	update(2*p+2, L, value, mid+1, j);
	T[p] = max(T[2*p+1], T[2*p+2]);
}
lli query(int p, int L, int R, int i, int j){
	if(i>R || j<L) return 0;
	if(L<=i and j<=R){
		return T[p];
	}
	int mid = i+(j-i)/2;
	lli x = query(2*p+1, L, R, i, mid);
	lli y = query(2*p+2, L, R, mid+1, j);
	return max(x, y);
}
int main(int argc, char const *argv[])
{
    int N, x, y;
    int height;
    lli m;
    
    cin>>N;
    vector<int> H(N);
    vector<lli> B(N);
    for (int i = 0; i < N; ++i)	cin>>H[i];
    for (int i = 0; i < N; ++i) cin>>B[i];

    update(0, H[0], B[0], 0, N);
    for (int i = 1; i < N; ++i)
    {
    	height = H[i];
    	m = query(0, 0, height-1, 0, N);
    	// cout<<"i:"<<i<<" m:"<<m<<endl;
    	update(0, height, B[i]+m, 0, N);
    }

    cout<<query(0, 0, N, 0, N);
    return 0;
}

Measured memory_bytes: 8704
def p(x):
 if 2 in[x,pow(2,x,x)]:
  for i in range(7,int(x**.5+1),2):
   if x%i==0:return 0
  else:return 1
def f():
 n,c=map(int,input().split())
 if c<0:return(11,'9'*n*2)[n>1]
 for h in'9731':
  if n-1:
   for m in range(int(10**(n-1)),0,-1):
    if((int(h)+m-1)*2+c)%3:
     t=h+str(m-1).zfill(n-1)
     a=int(t+str(c)+t[::-1])
     if p(a):return a
  else:
   a=int(h+str(c)+h)
   if p(a):return a
 return'9'*n+b+'9'*n
print(f())


Measured memory_bytes: 5648
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <vector>
#include <list>
#include <map>
using namespace std;
int main() {
	int n, m;
	map<string, int> c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		c[s]++;
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		string t;
		cin >> t;
		c[t]--;
	}
    int res =0;
      for (auto &sc : c) {
      res = max(res, sc.second);
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,p,cnt=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p;
		if(i+1!=p)
			cnt++;
	}
	cout<<(cnt>2?"NO":"YES")<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, ll t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll mod) {
	if (a > 0) return a % mod;
	if (a % mod == 0) return 0;
	ll x = -a / mod + 1;
	a += x * mod;
	return a % mod;
}
ll powm(ll a, ll b, ll m) {
	if (b == 0) {
		return 1;
	} else if (b % 2 == 0) {
		ll d = powm(a, b / 2, m);
		return (d * d) % m;
	} else {
		return (powm(a, b - 1, m) * a) % m;
	}
}
// 本体

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	vector<ll> p(n);
	for (int i = 0; i < n;i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	ll sum = 0;
	for (int i = 0; i < k;i++) {
		sum += p[i];
	}
	dump(sum);
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N];
int n, m;
int main(){
	int t;
	int a, b, c, k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	int ans=0;
	while(b<=a){
		++ans;
		b*=2;
	}
	while(c<=b){
		++ans;
		c*=2;
	}
	if(ans<=k){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3756
N,K = (int(i) for i in input().split())
V = [int(i) for i in input().split()]
dashi = min([N,K])
result2 = 0
for i in range(dashi + 1):
    modoseru = K - i
    for leftdashi in range(i + 1):
        values = [0]
        for k in range(leftdashi):
            values.append(V[k])
        for J in range(i - leftdashi):
            if J >= 0:
                values.append(V[-1 * J - 1])

        values.sort()
        for n in range(modoseru):
            if len(values) >= 1 and values[0] <= 0:
                values.pop(0)
        result = sum(values)
        if result2 < result:
            result2 = result
            
print(result2)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <atcoder/all>
#include <set>
using namespace std;
using namespace atcoder;

using mint = static_modint<998244353>;

vector<vector<mint>> Mods(10, vector<mint>(200001));

struct S {
	mint a;
	int size;
};

struct F {
	bool id;
	int N;
};

S op(S l, S r) {
	mint k = 10;
	return S{ l.a * k.pow(r.size) + r.a, l.size + r.size };
}

S e() {
	return S{ 0,0 };
}

S mapping(F l, S r) {
	if (l.id) return r;
	return S{ Mods[l.N][r.size], r.size };
}

F composition(F l, F r) {
	if (l.id) return r;
	else return l;
}

F id() {
	return F{ true,0 };
}

int main() {
	for (int i = 1; i <= 9; i++) {
		Mods[i][0] = 0;
		for (int j = 1; j <= 200000; j++) {
			Mods[i][j] = Mods[i][j - 1] * 10 + i;
		}
	}

	int N, Q;
	cin >> N >> Q;
	vector<S> A(N);
	for (int i = 0; i < N; i++) A[i] = S{ 1,1 };
	lazy_segtree<S, op, e, F, mapping, composition, id> seg(A);
	for (int q = 0; q < Q; q++) {
		int l, r, d;
		cin >> l >> r >> d;
		seg.apply(l - 1, r, F{ false, d });
		cout << seg.all_prod().a.val() << endl;
	}
}


Measured memory_bytes: 18868
def main():
    N,K,S = map(int,input().split())
    A = []
    if N >= K:
        for i in range(K):
            A.append(S)
        tmp = N-K
        for i in range(tmp):
            if S != 1000000000:
                A.append(S+1)
            else:
                A.append(1)
    else:
        for i in range(N):
            A.append(S)

    return A

A = main()
A = map(str,A)
print(' '.join(A))


Measured memory_bytes: 19900
#include <stdio.h>

int main() {
    int a,b=0;
    scanf("%d %d", &a,&b);
    
    if (a == b) {
        printf("a == b\n");
    } else if (a < b) {
        printf("a < b\n");
    } else if (a > b) {
        printf("a > b\n");
    }
    
    return 0;
}


Measured memory_bytes: 2080
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/



int main() {


	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == t[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;





	

	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

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

    vector<int> nums(n+2);
    nums[0] = 0;
    rep(i, n) cin >> nums[i+1];
    nums[n+1] = 0;

    vector<int> dists(n+1), dists_skip2(n);
    rep(i, n){
        dists[i] = abs(nums[i] - nums[i+1]);
        dists_skip2[i] = abs(nums[i] - nums[i+2]);
    }
    dists[n] = abs(nums[n] - nums[n+1]);

    vector<int> all_sum(n+1, 0);
    rep(i, n+1) all_sum[i] = all_sum[max(0, i-1)] + dists[i];

    rep(i, n){
        cout << all_sum[i] - dists[i] + dists_skip2[i] + all_sum[n]-all_sum[i+1] << endl;
    }
}

Measured memory_bytes: 2816
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

using Weight=long long;
static const Weight INF=1LL<<57;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

struct Arc {
    // accessible to the reverse edge
    size_t src, dst;
    Weight capacity, cost, flow;
    size_t rev;
    Arc() {}
    Arc(size_t src, size_t dst, Weight capacity, Weight cost=0):
        src(src), dst(dst), capacity(capacity), cost(cost), flow(0), rev(-1)
    {}
    Weight residue() const {
        return capacity - flow;
    }
};

bool operator<(const Arc &e, const Arc &f) {
    if (e.cost != f.cost) {
        return e.cost > f.cost;
    } else if (e.capacity != f.capacity) {
        return e.capacity > f.capacity;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Arcs=vector<Arc>;
using Node=vector<Arc>;
using FlowNetwork=vector<Node>;

void connect(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, 0, -k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

void join(FlowNetwork &g, size_t s, size_t d, Weight c=1, Weight k=0) {
    g[s].push_back(Arc(s, d, c, k));
    g[d].push_back(Arc(d, s, c, k));

    g[s].back().rev = g[d].size()-1;
    g[d].back().rev = g[s].size()-1;
}

Weight mincost_flow(FlowNetwork &g, size_t s, size_t t, Weight F=INF) {
    size_t V=g.size();
    vector<Arc *> prev(V, NULL);

    Weight mcost=0;
    while (F > 0) {
        vector<Weight> d(V, INF); d[s]=0;
        for (bool updated=true; updated;) {
            updated = false;
            for (size_t v=0; v<V; ++v) {
                if (d[v] == INF) continue;

                for (Arc &e: g[v]) {
                    if (e.capacity <= 0) continue;

                    if (d[e.dst] > d[e.src] + e.cost) {
                        d[e.dst] = d[e.src] + e.cost;
                        prev[e.dst] = &e;
                        updated = true;
                    }
                }
            }
        }

        if (d[t] == INF)
            return -1;

        Weight f=F;
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src])
            f = min(f, e->capacity);

        F -= f;
        mcost += f * d[t];
        for (Arc *e=prev[t]; e!=NULL; e=prev[e->src]) {
            e->capacity -= f;
            g[e->dst][e->rev].capacity += f;
        }
    }

    return mcost;
}

int main() {
    size_t V, E;
    Weight F;
    scanf("%zu %zu %lld", &V, &E, &F);

    FlowNetwork g(V);
    for (size_t i=0; i<E; ++i) {
        size_t u, v;
        Weight c, d;
        scanf("%zu %zu %lld %lld", &u, &v, &c, &d);

        connect(g, u, v, c, d);
    }

    printf("%lld\n", mincost_flow(g, 0, V-1, F));
    return 0;
}

Measured memory_bytes: 2788
#include <stdio.h>
int main(){
  int a, b, c;
  scanf("%d %d %d",&a,&b,&c);
  int f = 0, s = 0;
  if(a == 5) ++f;
  if(b == 5) ++f;
  if(c == 5) ++f;
  if(a == 7) ++s;
  if(b == 7) ++s;
  if(c == 7) ++s;
  if(f == 2 && s == 1) printf("YES\n");
  else printf("NO\n");
}

Measured memory_bytes: 128