akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 110
#define M 10
ll n, f[N][M], p[N][M+1];

int main(){
	cin>>n;
	rep(i, n) rep(j, M) cin>>f[i][j];
	rep(i, n) rep(j, M+1) cin>>p[i][j];
	ll res = -1e16;
	for(int i = 1; i < 1<<M; i++){
		ll sum = 0;
		rep(j, n){
			ll s = 0;
			rep(k, M){
				if((1&(i>>k)) && f[j][k]){
					s++;
				}
			}
			sum += p[j][s];
		}
		res = max(res, sum);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
D, N = map(int, input().split())

l0 = []
for i in range(1, 102):
    if i != 100:
        l0.append(i)
l1 = []
for i in range(1, 102):
    if i != 100:
        l1.append(100 * i)
l2 = []
for i in range(1, 102):
    if i != 100:
        l2.append(10000 * i)

if D == 0:
    print(l0[N - 1])
elif D == 1:
    print(l1[N - 1])
elif D == 2:
    print(l2[N - 1])


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

int c[33], s[444][33];
int sco(int t, const vector<int> &v) {
    int r = 0, l = 0, d = v.size();
    for(int i = 0; i < d; i++)
        if(v[i] == t)
            r += s[i][t] - c[t] * (i + 1 - l) * (i - l) / 2, l = i + 1;
    r -= c[t] * (d + 1 - l) * (d - l) / 2;
    return r;
}
int main() {
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    random_device rd;
    mt19937 mt(rd());
    uniform_int_distribution<> rc(0, 25), r0(0, d - 1), r2(1, 6);
    uniform_real_distribution<> ru(0, 1);
    vector<int> tt(d);
    for(int &i : tt)
        i = rc(mt);
    int cnt = 0;
    auto ti = clock();
    for(;;) {
        auto T = (clock() - ti) / 1.9 / CLOCKS_PER_SEC;
        if(T > 1)
            break;
        auto U = pow(2e3, 1 - T) * pow(6e2, T);
        for(int cn = 0; cn < 100; cn++, cnt++) {
            auto uu = tt;
            int di;
            if(rc(mt) < 13) {
                int x0 = r0(mt), xc = rc(mt);
                uu[x0] = xc;
                di = sco(tt[x0], uu) + sco(xc, uu) - sco(tt[x0], tt) -
                     sco(xc, tt);
            } else {
                int x2 = r2(mt);
                uniform_int_distribution<> r1(0, d - 1 - x2);
                int x1 = r1(mt);
                x2 += x1;
                swap(uu[x1], uu[x2]);
                di = sco(tt[x1], uu) + sco(tt[x2], uu) - sco(tt[x1], tt) -
                     sco(tt[x2], tt);
            }
            if(ru(mt) <= exp(di / U))
                tt.swap(uu);
        }
    }
    int M = 0;
    for(int j = 0; j < 26; j++)
        M += sco(j, tt);
    for(int i : tt)
        cout << i + 1 << '\n';
    cerr << M << endl;
    cerr << cnt << endl;
    return 0;
}


Measured memory_bytes: 4308
#include<bits/stdc++.h>
using namespace std;
//using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int n,m;
  cin >> n >> m;
  cout<< n*(n-1)/2 + m*(m-1)/2 <<endl;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	string s;

	cin>>s;

	cout<<s.at(0)<<s.size()-2<<s.at(s.size()-1)<<endl;

	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.List
import qualified Data.IntMap as IM

type Map = IM.IntMap Int

countUp :: Int -> Int -> Map -> Map
countUp = IM.insertWithKey f
  where f _ new old = old + new

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: [Int] -> Map -> Map
solve [] m = m
solve (a:as) m = solve as $ countUp (a `div` 400) 1 m

main :: IO ()
main = do
  getLine
  as <- readIntsLine
  let c = length . IM.toList $ solve (filter (<3200) as) IM.empty
  let n = length (filter (>=3200) as)
  putStrLn $ (if c >= 1 then show c else "1") ++ " " ++ show (n+c)

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll MAX=2030;
const ll MOD=1000000007;
int H,W;
char S[MAX][MAX];
int conn[MAX][MAX],ans;
int f(int x,int y1,int y2){
    if(y2-y1==1) return H-x;
    int p=(y1+y2)/2,q1=p-1,q2=p+1,len=conn[x][p-1],val=2*conn[x][p-1];
    while(q1!=y1||q2!=y2){
        int t=0;
        if(q1==y1) t=1;
        else if(q2==y2) t=0;
        else if(conn[x][q1-1]<conn[x][q2-1]) t=1;
        else t=0;
        if(t) len=min(conn[x][q2-1],len),q2++,val=max(len*(q2-q1),val);
        else len=min(conn[x][q1-1],len),q1--,val=max(len*(q2-q1),val);
    }
    return max(max(f(x,y1,p),f(x,p,y2)),val);
}
main(){
    scanf(" %d %d",&H,&W);
    for(int i=0;i<H;i++) scanf(" %s",&S[i]);
    for(int j=0;j<W-1;j++){
        conn[0][j]=1;
        for(int i=1;i<H;i++) {
            if((S[i][j]==S[i][j+1])==(S[i-1][j]==S[i-1][j+1])) conn[i][j]=conn[i-1][j]+1;
            else conn[i][j]=1;
        }
    }
    for(int i=0;i<H;i++) ans=max(ans,f(i,0,W));
    printf("%d\n",ans);
}


Measured memory_bytes: 20352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int k;
    cin >> k;
    int ans = 0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            if(i%2 == 0 && j%2 == 1){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

typedef long long ll;

using namespace std;

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

int main(){
    int N,count=0;
    cin >> N;
    for(int i=1;i<=N;i++){
        if(i%2 == 1){
            int sum=0;
            for(int j=1;j<=i;j++){
                if(i%j == 0) sum++;
            }
            if(sum == 8) count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

int a, b, c, k;

void read_input()
{
    cin >> a >> b >> c >> k;
}

void solve()
{
    int ans = 0, tmp;
    tmp = min(a, k);
    ans += tmp;
    k -= tmp;
    tmp = min(b, k);
    k -= tmp;
    tmp = min(c, k);
    ans -= tmp;
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



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

using namespace std;
typedef long long ll;
int main()
{
    ll n,q,b,c;ll count;ll sum=0;
    cin>>n;
    ll a[n];
    ll i;
    ll cnt[100001]={0};
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
        sum+=a[i];
        
    }
    cin>>q;
    while(q--)
    {
        cin>>b>>c;
        count=cnt[b];
        sum=sum-count*b+count*c;
        cout<<sum<<'\n';
        cnt[c]+=cnt[b];
        cnt[b]=0;
    }
   
   
   return 0;
}

Measured memory_bytes: 5184
main :: IO ()
main = do
  a <- readLn :: IO Int
  b <- readLn :: IO Int
  c <- readLn :: IO Int
  x <- readLn :: IO Int
  print $ length [True | i <- [0..a], j <- [0..b], k <- [0..c], 500 * i + 100 * j + 50 * k == x]


Measured memory_bytes: 508
#include <cstdio>
#include <algorithm>
#define maxn 100010
using namespace std;
char in[3];
int n,v[3],p[maxn],q[maxn],ans[maxn];
int main(){
	int i;
	scanf("%d",&n);
	for(i=0;i<3;i++)scanf("%d",&v[i]);
	for(i=1;i<=n;i++)scanf("%s",in),p[i]=in[0]-'A',q[i]=in[1]-'A';
	for(i=1;i<=n;i++){
		if(v[p[i]]>v[q[i]])swap(p[i],q[i]);
		else if(v[p[i]]==v[q[i]]){
			if(i+1<=n&&(q[i]==p[i+1]||q[i]==q[i+1]))swap(p[i],q[i]);
		}
		if(!v[q[i]])return 0*printf("No\n");
		v[p[i]]++,v[q[i]]--,ans[i]=p[i];
	}
	printf("Yes\n");
	for(i=1;i<=n;i++)printf("%c\n",'A'+ans[i]);
	return 0;
}

Measured memory_bytes: 2880
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

struct segtree {
public:
	const int SIZE = 1 << 18;
	VI seg, lazy;
	//seg:区間の合計値 lazy:区間に対して、加える値でまだ遅延しているもの

	segtree() :seg(SIZE * 2), lazy(SIZE * 2) {}
	void lazy_evaluate(int k, int l, int r) {
		if (lazy[k] != 0) {
			seg[k] += lazy[k];
			//区間[l,r)にすべて同じ値を追加することになっていて、
			//segには合計値が入っているので、加える値を足す
			if (r - l > 1) {
				lazy[k * 2 + 1] += lazy[k];
				lazy[k * 2 + 2] += lazy[k];
			}
			lazy[k] = 0;
		}
	}

	void update(int a, int b, int k, int l, int r, int x) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l && r <= b) {
			lazy[k] += x;
			lazy_evaluate(k, l, r);
		}
		else {
			update(a, b, k * 2 + 1, l, (l + r) / 2, x);
			update(a, b, k * 2 + 2, (l + r) / 2, r, x);
			seg[k] = seg[k * 2 + 1] + seg[k * 2 + 2];
		}
	}
	int query(int a, int b, int k, int l, int r) {
		lazy_evaluate(k, l, r);
		if (r <= a || b <= l)return 0;
		if (a <= l && r <= b)return seg[k];
		int x = query(a, b, k * 2 + 1, l, (l + r) / 2);
		int y = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return x + y;
	}

	void update(int a, int b, int x) { update(a, b, 0, 0, SIZE, x); }
	//update(a,b,x) := [a,b)を全てxを加える
	int query(int a, int b) { return query(a, b, 0, 0, SIZE); }
	//query(a,b) := [a,b)に対する合計値を求める

};

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

	int N, M, X;
	segtree seg;
	cin >> N >> M >> X;
	REP(i, M) {
		int a; cin >> a;
		seg.update(a, a + 1, 1);
	}
	cout << min(seg.query(0, X), seg.query(X + 1, N)) << endl;;
	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 1000000000
#define MOD 1000000007
#define ll long long int

using namespace std;

string S;

bool ifSafe2(ll left,ll right){
	for(int i = left; i<right;i++){
		if(S[i] == '#' and S[i+1] == '#') return false;
	}

	return true;
}

bool orSafe3(ll left,ll right){
	for(int i = left; i<right-1;i++){
		if(S[i] == '.' and S[i+1] == '.' and S[i+2] == '.') {return true;}
		//else {cout<<i<<endl;return false;}
	}

	return false;
}


int main(){
	ll N; cin>>N;
	ll A,B,C,D;
	cin>>A>>B>>C>>D;
	A--;
	B--;
	C--;
	D--;
	 cin>>S;

	 if(ifSafe2(A,max(C,D)) == false) {cout<<"No"<<endl; return 0;}
	 if(C<D) {cout<<"Yes"<<endl;return 0;}

	 if( orSafe3(B-1,D+1) == true) {cout<<"Yes"<<endl;return 0;}
	 else {cout<<"No"<<endl;return 0;}

	 



	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int Judge(int *,int,int,int);
int main(){
  int q,n,A[20],m[200],i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
    if(Judge(A,m[i],0,n))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int Judge(int *A,int m,int i,int n){
  if(m==0)return 1;
  else if(i>=n)return 0;
  return  Judge(A,m,i+1,n)||Judge(A,m-A[i],i+1,n);
}




Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

int main(){
  int n,q;
  string s;
  cin >> n >> q >> s;
  vector<int> ac(111111);
  int t=0;
  for(int i=1;i<n;i++){
    if(s[i-1]=='A'&&s[i]=='C'){
      t++;
      }
    ac[i]=t;
    }
  for(int i=0;i<q;i++){
    int l,r;
    cin >> l >> r;
    cout << ac[r-1] - ac[l-1] << endl;
  }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) { cin >> a[i]; }
  vector<int> b = a;
  sort(RALL(b));
  REP(i, n) {
    if (a[i] == b[0]) {
      cout << b[1] << endl;
    } else {
      cout << b[0] << endl;
    }
  }
  return 0;
}

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

using namespace std;

#define pb push_back

const int maxi = 1e6+10;
int a[300][300];
vector<int> v[maxi];
string s;
int col[maxi];
int n;
int ok = 1;
int ans;
int d[maxi];
const int inf = 100000;
void dfs(int x, int y, int lev)
{
    ans = max(lev, ans);
    col[x] = y;

    for (int j=1;j<=n;j++)
        if (a[x][j] && !col[j]) dfs(j, 3 - y, lev + 1); else
            if (a[x][j] && col[j] == y) ok = 0;
}
int main()
{
    cin>>n;

    for (int i=1;i<=n;i++)
    {
        cin>>s;

        for (int j=1;j<=n;j++)
            if (s[j-1]=='1') a[i][j] = 1;
    }

    dfs(1,1, 1);
    if (!ok) return !printf("-1\n");

    queue<int> q;

    int ans = 0;

    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=n;j++)
            d[j] = inf;

        while(!q.empty()) q.pop();

        d[i] = 1;
        q.push(i);

        while(!q.empty())
        {
            int node = q.front();
            q.pop();
            ans = max(ans, d[node]);

            for (int j=1;j<=n;j++)
                if (a[node][j] && d[j]==inf)
            {
                d[j] = d[node] + 1;
                q.push(j);
            }
        }

    }

    cout<<ans<<endl;
    return 0;
}
//odlazim (da da da), a volim te (ne ne ne)


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

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

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

const int INF = 1000005;

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

  vector<int> sieve(INF);
  for (auto x : a) {
    if (sieve[x] != 0) {
      sieve[x] = 2;
      continue;
    }
    for (int i = x; i < INF; i += x) {
      ++sieve[i];
    }
  }

  int ans = 0;
  for (auto x : a) {
    if (sieve[x] == 1) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7920
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.PB({N, 1});
    return res;
}

int main() {
    ll N;
    cin >> N;
    map<ll, ll> memo;
    for(int i=1; i<=N; i++){
        const auto &res = prime_factorize(i);
        rep(j,res.size()){
            memo[res[j].F]+=res[j].S;
        }
    }
    ll sum=1;
    stl_rep(itr, memo){
        sum*=((itr->S+1)%MOD);
        sum%=MOD;
    }
    cout << sum%MOD << endl;
}

Measured memory_bytes: 3600
a,b,c,x = [int(input()) for i in range(4)]
ans = 0

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

Measured memory_bytes: 2568
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 25555
	#define mod 1000000007ll
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n,m,K;
int a[sz];
ll dp[sz][411],sum[sz][411];

int cnt[sz];
bool check()
{
	int l=1,r=0;
	while (r<m)
	{
		++r;++cnt[a[r]];
		while (cnt[a[r]]>1) --cnt[a[l]],++l;
		if (r-l+1==K) return 1;
	}
	return 0;
}

ll fac[sz],_fac[sz];
void init(){_fac[0]=fac[0]=1;rep(i,1,sz-1) _fac[i]=inv(fac[i]=fac[i-1]*i%mod);}
ll C(int n,int m){return n>=m&&m>=0?fac[n]*_fac[m]%mod*_fac[n-m]%mod:0;}

int main()
{
	file();
	init();
	read(n,K,m);
	rep(i,1,m) read(a[i]);
	rep(i,1,K-1) dp[0][i]=1,sum[0][i]=i;
	rep(i,1,n) rep(j,1,K-1) dp[i][j]=(sum[i-1][j]+dp[i-1][j+1]*(K-j)%mod)%mod,sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
	if (check()) return printf("%lld\n",ksm(K,n-m)*(n-m+1)%mod),0;
	ll ans=0;
	rep(i,1,K) cnt[i]=0;
	int r=0;while (r<m&&!cnt[a[r+1]]) ++r,++cnt[a[r]];
	rep(i,0,n-m) (ans+=(ksm(K,i)-dp[i][r]+mod)*ksm(K,n-m-i)%mod)%=mod;
	rep(i,1,K) cnt[i]=0;
	int l=m+1;while (l>1&&!cnt[a[l-1]]) --l,++cnt[a[l]];
	rep(i,0,n-m) (ans+=(ksm(K,i)-dp[i][m-l+1]+mod)*dp[n-m-i][r]%mod)%=mod;
	if (r==m) rep(i,1,K-m-1) rep(j,0,n-K) (ans+=fac[K-m]%mod*(j?sum[j-1][K-1]:1)%mod*dp[n-K-j][K-i]%mod)%=mod;
	cout<<ans;
	return 0;
}

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

#define MAXH 2000001

void maxHeapify(int *, int, int);
void insert(int *, int, int *);
int extract(int *, int *);
void heapIncreaseKey(int *, int, int);

int main()
{
  int i, key, H = 0;
  int A[MAXH];
  char com[8];

  while(1) {
    scanf("%s",com);
    if(strcmp(com,"end") == 0) break;
    
    if(strcmp(com,"insert") == 0) {
      scanf("%d",&key);
      insert(A,key,&H);
    }
    else if(strcmp(com,"extract") == 0) {
      key = extract(A,&H);
      printf("%d\n",key);
    }
  }

  return 0;
}

void maxHeapify(int *A, int i, int H)
{
  int l, r, largest, tmp;

  l = i*2;
  r = i*2 + 1;

  if(l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest]) largest = r;

  if(largest != i) {
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest, H);
  }
}

void insert(int *A, int key, int *H)
{
  (*H)++;  
  heapIncreaseKey(A,key,*H);  
}

int extract(int *A, int *H)
{
  int max;

  max = A[1];

  A[1] = A[*H];
  (*H)--;
  maxHeapify(A,1,*H);

  return max;
}

void heapIncreaseKey(int *A, int key, int i)
{
  int tmp;
  
  A[i] = key;
  while(i > 1 && A[i/2] < A[i]) {
    tmp = A[i];
    A[i] = A[i/2];
    A[i/2] = tmp;
    i /= 2;
  }
}



Measured memory_bytes: 5608
/*
構造化プログラム
*/

#include<stdio.h>
int main(void){
  int num;
  int i,j;
  scanf("%d",&num);
  i =1;
  while(num >=i){
    j =i;
    if(j %3 == 0)
      printf(" %d",i);
    else{
      do{
	if(j%10 == 3){
	  printf(" %d",i);
	  break;
	}
	else{
	  j /= 10;
	}
      }while(j);
    }
    i++;
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2040
//#include <bits/stdc++.h>
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

signed main() {
  string s, t;
  while (cin >> s >> t) {
    if (s == ".") return 0;
    if (s == t)
      cout << "IDENTICAL" << endl;
    else {
      vector<int> sq, tq;
      vector<string> S, T;
      string ns = "", nt = "";
      rep(i, s.size()) {
        if (s[i] == '"') {
          ns += " ";
          sq.push_back(i);
          int start = i++;
          while (s[i] != '"') i++;
          S.push_back(s.substr(start, i - start + 1));
          // cout << s.substr(start, i - start + 1) << endl;
        } else {
          ns += s[i];
        }
      }
      rep(i, t.size()) {
        if (t[i] == '"') {
          nt += " ";
          tq.push_back(i);
          int start = i++;
          while (t[i] != '"') i++;
          T.push_back(t.substr(start, i - start + 1));
        } else {
          nt += t[i];
        }
      }
      // rep(i, S.size()) cout << S[i] << ' ';
      // cout << endl;
      // rep(i, T.size()) cout << T[i] << ' ';
      // cout << endl;
      // cout << "ns=" << ' ' << ns << ' ' << "nt=" << ' ' << nt << endl;
      if (ns != nt) {
        cout << "DIFFERENT" << endl;
        goto at;
      }
      if (sq.size() != tq.size()) {
        cout << "DIFFERENT" << endl;
      } else {
        // rep(i, sq.size()) cout << sq[i] << ' ';
        // cout << endl;
        // rep(i, tq.size()) cout << tq[i] << ' ';
        // cout << endl;
        int cnt = 0;
        rep(i, S.size()) if (S[i] != T[i]) cnt++;
        // cout << cnt << endl;
        cout << (cnt == 1 ? "CLOSE" : "DIFFERENT") << endl;
      }
    at:;
    }
  }
  return 0;
}



Measured memory_bytes: 3160
// Aaradhya Beri
//#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
 

signed main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
     ll a;
    double b;
    cin >> a >> b;
    ll B = b * 100 + 0.5;
    cout << a * B / 100 << '\n';
    return 0;
}

Measured memory_bytes: 3752
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import math


N = int(input())
S = str(input())
K = int(input())


ans = ""

for i in range(N):
    if S[K-1] == S[i]:
        ans += S[K-1]
    else:
        ans += "*"

print(ans)


Measured memory_bytes: 24304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace ConsoleApplication
{
    public class main
    {
        static void Main()
        {
            string [] vals = Console.ReadLine().Split(' ');
            int N = int.Parse(vals[0]);
            int M = int.Parse(vals[1]);
            string [] A = new string [N];
            string [] B = new string [M];

            for (int i =0; i< N ; i++) 
                A [i] = Console.ReadLine();
            for (int i = 0; i < M; i++) 
                B[i] = Console.ReadLine();
            for (int y = 0; y<= N-M; y++)
            {
                for (int x = 0; x<= N-M; x++)
                {
                    bool match = true;
                    for (int j = 0; j < M; j++)
                    {
                        for (int i = 0; i < M; i++)
                        {
                            if ( A[y + j][x + i] != B[j][i])
                            {
                                match = false;
                            }
                        }
                    
                    }
                    if (match)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
            }
            Console.WriteLine("No");
        }

    }
}   

Measured memory_bytes: 2648
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	int x,n;
	cin>>x>>n;
	vector<int> v(n);
	set<int> s;
	for(int i=-200;i<=200;i++)
		s.insert(i);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
		s.erase(v[i]);
	}
	auto it = s.lower_bound(x);
	int val1 = *(it);
	--it;
	int val2 = *(it);
	if(abs(val1-x) < abs(val2-x))
		cout<<val1;
	else if(abs(val1-x) > abs(val2-x))
		cout<<val2;
	else
		cout<<min(val1,val2);
	return 0;
}


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

const int MAX = 1e5+1;
int A[MAX];

int main(){
    int n, l; cin >> n >> l;
    for (int i = 1; i <= n; i++)
    {
        cin >> A[i];
    }
    int mx = 0;
    int tie = 0;
    for (int i = 1; i < n; i++)
    {
        if (mx < A[i]+A[i+1])
        {
            mx = A[i]+A[i+1];
            tie = i;
        }
    }
    if (mx < l)
    {
        cout << "Impossible" << endl;
        return 0;
    }
    cout << "Possible" << endl;
    for (int i = 1; i < tie; i++)
    {
        cout << i << endl;
    }
    for (int i = n-1; i > tie; i--)
    {
        cout << i << endl;
    }
    cout << tie << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
int N;

void f(int& count, ll cur = 0, int flg = 0){
  if(cur > N) return;
  if(flg == 0b111) count++;
  f(count, cur*10+3, flg|0b100);
  f(count, cur*10+5, flg|0b010);
  f(count, cur*10+7, flg|0b001);
}

int main(void){
  cin >> N;
  int ans = 0;
  f(ans);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 01/Mar/20 05:31:34 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	int n;
	cin >> n;
	int ans = ceil (n / (2 * 1.0));
	pr (ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt();
        int[][] red = new int[n][2];
        int[][] blue = new int[n][2];

        for (int i = 0; i < n; i++) {
            red[i][0] = sc.nextInt();
            red[i][1] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            blue[i][0] = sc.nextInt();
            blue[i][1] = sc.nextInt();
        }

        int count = 0;
        boolean[] r = new boolean[n];
        boolean[] b = new boolean[n];

        Arrays.sort(blue, Comparator.comparingInt(o1 -> o1[0])); // xが小さい順
        Arrays.sort(red, Comparator.comparingInt(o1 -> -o1[1])); // yが大きい順

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (!b[i] && !r[j] && blue[i][0] > red[j][0] && blue[i][1] > red[j][1]) {
                    count++;
                    b[i] = true;
                    r[j] = true;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 28884
#include <bits/stdc++.h>
#include <map>
#include <cmath>
#include <array>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <iostream>
#include <ctype.h>
#include <string>

typedef long long ll;
using namespace std;



int main(){
  string st;
  int n,m;
  cin>>n;
  n%=10;
  if(n==3) cout<<"bon";
  else if(n==0||n==1||n==6||n==8) cout<<"pon";
  else cout<<"hon";
  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef int64_t ll;
typedef long double ld;
using namespace std;
const ll mod=1000000007;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int main(){
  init();
  ll N,M;cin>>N>>M;
  WeightedGraph<ll>G(3*N);
  vector<ll>g[N];
  rep(i,M){
    ll u,v;cin>>u>>v;
    u--;v--;
    G[3*u+0].emplace_back(3*v+1,0);
    G[3*u+1].emplace_back(3*v+2,0);
    G[3*u+2].emplace_back(3*v+0,1);
  }
  ll s,t;cin>>s>>t;s--;t--;
  auto v=dijkstra(G,3*s);
  if(v[3*t]==numeric_limits<ll>::max())cout<<-1<<endl;
  else cout<<v[3*t]<<endl;
}

Measured memory_bytes: 21376
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn grundy(cur: usize, parent: usize, graph: &Vec<Vec<usize>>) -> i64 {
    let mut temp = 0;
    for &to in graph[cur].iter() {
        if to == parent {
            continue;
        }
        temp ^= 1 + grundy(to, cur, graph);
    }
    temp
}

fn main() {
    let n = read::<usize>();
    let mut graph = vec![vec![]; n];
    for _ in 0..n - 1 {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        graph[a].push(b);
        graph[b].push(a);
    }
    if grundy(0, 0, &graph) == 0 {
        println!("Bob");
    } else {
        println!("Alice");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 16636
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.length(); i++) {
     // cout<<ans<<endl;
		if (s[i] == 'A'||s[i] == 'C'||s[i] == 'G'||s[i] == 'T') { 
			int a = 1;
			for (int j = i + 1; j < s.length(); j++) {
              //cout<<a<<endl;
				if (s[j] == 'A'||s[j] == 'C'||s[j] == 'G'||s[j] == 'T')a++;
				else break;
			}
			ans = max(ans, a);
		}
		
	}
	cout << ans << endl;

	return 0;
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	sort(arr,arr+n,greater<int>());
	int result{};
	for(int i=0;i<k;i++)
		result += arr[i];
	cout<<result;
	return 0;
}

Measured memory_bytes: 3544
n,m=map(int,input().split())
temp=[0]*(n+1)
for i in range(m):
  l,r=map(int,input().split())
  temp[l-1]=temp[l-1]+1
  temp[r]=temp[r]-1
for i in range(n):
  temp[i+1]=temp[i+1]+temp[i]
print(temp.count(m))

Measured memory_bytes: 6980
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    if (!(cin >> N)) { return; }
    ll K;
//    cin >> K;
    K = 2;
    vector<ll> h;
    for (int i = 0; i < N; ++i) {
        ll tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    vector<ll> cost(N, INF);
    cost[0] = 0;
    for (ll i = 1; i < N; ++i) {
        for (ll j = max(ll{0}, i-K); j < i; ++j) {
            cost[i] = min(cost[i], cost[j] + abs(h[j] - h[i]));
        }
    }
    cout << cost.back() << endl;

}

int main(int argc, char *argv[]) {
    string FileName("EDPC"), Modifier("MEPH_");
    string ExecutionName = Modifier + FileName;
    string sub(argv[0]);
    // /home/USER/.../MEPH_X -> MEPH_X
    if (sub.size() > ExecutionName.size())
        sub = sub.substr(sub.size() - ExecutionName.size(), ExecutionName.size());

    cout << setprecision(16) << scientific;
    if (sub != ExecutionName) {
        cin.tie(0);
        ios::sync_with_stdio(false);
        while (cin) { solve(cin); }
    } else {
        cerr << sub << " test" << endl;
        string inFile = FileName + ".txt";
        auto fs = fstream(inFile, fstream::in);
        while (fs) { solve(fs); }
    }
}


Measured memory_bytes: 1908
NY = input().split()
N, Y = int(NY[0]), int(NY[1])

end = 0

for i in range(N+1):
    for j in range(N+1-i):
        k = N - (i+j)
        if i*10000+j*5000+k*1000==Y:
            print(i, j, k)
            end = 1
            
            break
    
    if end == 1:
        break
        
else:
    print(-1, -1, -1)

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

int main() {
    int N, div, dig_sum = 0;
    cin >> N;
    div = N;

    while (div > 0) {
        dig_sum += div % 10;
        div = div / 10;
    }
    if (N % dig_sum)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

Measured memory_bytes: 3632
sum=0
s=0
A=input().split()
n=(int)(A[0])
m=(int)(A[1])
x=[0 for i in range(2*n)]
for i in range(n):
    B=input().split()
    k=2*i
    x[k]=(B[0])
    x[k+1]=(int)(B[1])
while len(x)>0:
    s=x[1]-m
    if s>0:
        sum+=m
        x.append(x[0])
        x.append(s)
        del x[0]
        del x[0]
    if s<=0:
        sum+=x[1]
        print( x[0],sum)
        del x[0]
        del x[0]


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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int infi = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);
constexpr long long MOD(long long in) {
	return in % mod;
}

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

	auto maxk = (n - 1) * (n - 2) / 2;

	if (k > maxk)
		std::cout << -1 << std::endl;
	else {
		auto disk = maxk - k;
		std::cout << n - 1 + disk << std::endl;

		for (int i = 2; i <= n; ++i)
			std::cout << 1 << " " << i << std::endl;

		int num = 0;
		for (int i = 2; i <= n; ++i)
			for (int j = i + 1; j <= n; ++j) {
				if (num >= disk)
					break;
				std::cout << i << " " << j << std::endl;
				++num;
			}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
	int x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
int n; 
int main() {
	cin>>n;
	cout<<360/__gcd(n,360);
}


Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
void dfs(graph &G, vector< int > &level, int x, int p) {
	rep(i, G[x].size()) {
		edge e = G[x][i];
		if (e.to == p)
			continue;
		level[e.to] = level[x] + e.d;
		dfs(G, level, e.to, x);
	}
}
signed main() {
	cin >> N;
	graph G(N);
	rep(i, N - 1) {
		int a, b, c;
		cin >> a >> b >> c;
		--a;
		--b;
		G[a].push_back(edge(a, b, c));
		G[b].push_back(edge(b, a, c));
	}
	cin >> Q >> K;
	--K;
	vector< int > level(N, 0);
	dfs(G, level, K, -1);
	//cout << level;
	while (Q--) {
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		cout << level[x] + level[y] << endl;
	}
	return 0;
}

Measured memory_bytes: 20608
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a==b && b==c){
    printf("No\n");
  }else if(a!=b && a!=c && b!=c){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


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

int main() {
    int p, q;
    cin >> p >> q;
    int k = __gcd(p, q);
    p /= k;
    q /= k;
    int q_ = q;
    vector<pair<int, int>> ans;
    for (int i=2; i<=sqrt(q); ++i) {
        if (q_%i == 0) {
            pair<int, int> p = make_pair(i, 1);
            q_ /= i;
            while (q_%i == 0) {
                p.second++;
                q_ /= i;
            }
            ans.push_back(p);
        }
    }
    if (q_ > 1) ans.push_back(make_pair(q_, 1));
    int a = 1;
    for (int i = 0; i < ans.size(); ++i) {
        a *= ans[i].first;
    }
    cout << a << endl;
    return 0;
}



Measured memory_bytes: 3124