akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> E;
const LL MOD = 1000000007LL;
LL A[300][300];
bool use[300][300];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) cin >> A[i][j];
	}
	memset(use, -1, sizeof(use));
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (A[i][k] + A[k][j] < A[i][j]) {
					cout << -1 << endl;
					return 0;
				}
				else if (k != i && k != j && A[i][k] + A[k][j] == A[i][j]) {
					use[i][j] = 0;
				}
			}
		}
	}
	LL ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (use[i][j]) ans += A[i][j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
n, k = map(int, input().split())
s, p, r = map(int, input().split())
t = input()
t = list(t)
ans = 0
for i in range(k):
 if t[i] == 'r':
  ans += r
 elif t[i] == 's':
  ans += s
 else:
  ans += p
for i in range(k, n):
 if t[i-k] == t[i]:
  t[i] = 'a'
 if t[i] == 'r':
  ans += r
 elif t[i] == 's':
  ans += s
 elif t[i] == 'p':
  ans += p

print(ans)



Measured memory_bytes: 4084
#include<cstdio>
#include<cstring>
#include<cassert>
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define Divhim() cout<<">>>>>>>>>>>>>>>"<<endl
#define Divher() cout<<"<<<<<<<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl

template<typename T> bool GetMin(T &a,T b)
{
	return ((a<=b)?false:(a=b,true));
}

template<typename T> bool GetMax(T &a,T b)
{
	return ((a>=b)?false:(a=b,true));
}

/*
	 -<Unlimited Blade Works>-
 */

#define LL long long

const int N=1e6+10;
const int H=1e5+10;
const LL INF=0x3f3f3f3f3f3f3f3f;

struct Heap
{

	priority_queue<LL,vector<LL>,greater<LL> > P,Q;

	void Push(LL x)
	{
		P.push(x);
	}

	void Del(LL x)
	{
		Q.push(x);
	}

	LL Top()
	{
		while(!Q.empty()&&P.top()==Q.top())
		{
			P.pop();
			Q.pop();
		}
		return P.empty()?INF:P.top();
	}

};

LL tr0[H<<2],tr1[H<<2];
Heap hp0[H<<2],hp1[H<<2];

void Insert(int p,LL w0,LL w1,int o=1,int l=1,int r=H)
{
	if(l==r)
	{
		hp0[o].Push(w0);
		hp1[o].Push(w1);
		GetMin(tr0[o],w0);
		GetMin(tr1[o],w1);
		return;
	}
	int mid=(l+r)>>1,lc=o<<1,rc=lc^1;
	if(p<=mid)
		Insert(p,w0,w1,lc,l,mid);
	else
		Insert(p,w0,w1,rc,mid+1,r);
	tr0[o]=min(tr0[lc],tr0[rc]);
	tr1[o]=min(tr1[lc],tr1[rc]);
}

void Del(int p,LL w0,LL w1,int o=1,int l=1,int r=H)
{
	if(l==r)
	{
		hp0[o].Del(w0);
		hp1[o].Del(w1);
		tr0[o]=hp0[o].Top();
		tr1[o]=hp1[o].Top();
		//Whats(tr0[o]);
		//Whats(tr1[o]);
		return;
	}
	int mid=(l+r)>>1,lc=o<<1,rc=lc^1;
	if(p<=mid)
		Del(p,w0,w1,lc,l,mid);
	else
		Del(p,w0,w1,rc,mid+1,r);
	tr0[o]=min(tr0[lc],tr0[rc]);
	//cout<<l<<","<<r<<endl;
	tr1[o]=min(tr1[lc],tr1[rc]);
}

LL Ask(int ql,int qr,LL *tr,int o=1,int l=1,int r=H)
{
	if(ql<=l&&r<=qr)
		return tr[o];
	int mid=(l+r)>>1,lc=o<<1,rc=lc^1;
	LL res=INF;
	if(ql<=mid)
		GetMin(res,Ask(ql,qr,tr,lc,l,mid));
	if(qr>mid)
		GetMin(res,Ask(ql,qr,tr,rc,mid+1,r));
	return res;
}

int n,ki,h[N];
LL dp[N];

void Insert(int x)
{
	Insert(h[x],dp[x]-h[x],dp[x]+h[x]);
}

void Del(int x)
{
	Del(h[x],dp[x]-h[x],dp[x]+h[x]);
}

int main()
{
	memset(tr0,0x3f,sizeof tr0);
	memset(tr1,0x3f,sizeof tr1);
	scanf("%d%d",&n,&ki);
	for(int i=1;i<=n;++i)
		scanf("%d",h+i);
	for(int i=1;i<=n;++i)
	{
		if(i>1)
			dp[i]=min(Ask(1,h[i],tr0)+h[i],Ask(h[i],H,tr1)-h[i]);
		if(i<n)
		{
			Insert(i);
			if(i>ki)
				Del(i-ki);
		}
		//Whats(i);
		//Whats(dp[i]);
	}
	printf("%lld",dp[n]);
	return 0;
}

Measured memory_bytes: 64128
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int main() {
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    unordered_set<int> X, Y;
    for (int i = 0;i < M;i++) {
    	int a, b;
    	cin >> a >> b;
    	if (a > b) swap(a, b);
    	if (a == 1) X.insert(b);
    	if (b == N) Y.insert(a);
    }
    bool ok = 0;
    for (int i = 1;i <= M && !ok;i++) {
    	if (X.count(i) && Y.count (i)) ok = 1;
    }
    if (ok) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

int main() {
    int n,m;
    int p=31;
    long long mod = 1e9 + 9;
    long long pi[51];
    pi[0]=1;
    for(int i=1;i<=50;i++)pi[i]=pi[i-1]*p %mod;
    string s;
    cin>>n>>m;
    int ha[n][n+1];
    int hb[m][m+1];
    for(int i=0;i<n;i++)
    {
        cin>>s;
        ha[i][0]=0;
        for(int j=0;j<n;j++)
        {
            ha[i][j+1]= (ha[i][j] + (s[j]=='.'?2:3) * pi[j]) %mod;
        }
    }
    for(int i=0;i<m;i++)
    {
        cin>>s;
        hb[i][0]=0;
        for(int j=0;j<m;j++)
        {
            hb[i][j+1]= (hb[i][j] + (s[j]=='.'?2:3) * pi[j]) %mod;
        }
    }
    bool ok = 0;
    int inner;
    for(int i=0;i+m<=n;i++)
    {


        for(int j=0;j+m<=n;j++)
        {
            long long curAval = (ha[i][j+m] - ha[i][j] +mod)%mod;
            curAval = curAval * pi[n-1-j] %mod;
            long long curBval = (hb[0][0+m] +mod)%mod;
            curBval = curBval * pi[n-1] %mod;
            if(curAval==curBval)
            {
                inner = 1;
                for(inner = i+1;inner<i+m;inner++)
                {
                    curAval = (ha[inner][j+m] - ha[inner][j] +mod)%mod;
                    curAval = curAval * pi[n-1-j] %mod;
                    curBval = (hb[inner-i][0+m] +mod)%mod;
                    curBval = curBval * pi[n-1] %mod;
                    if(curAval!=curBval)break;
                }
                if(inner==i+m)ok=1;
            }
        }

    }


    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int count = 700;
    if (s[0] == 'o') count += 100;
    if (s[1] == 'o') count += 100;
    if (s[2] == 'o') count += 100;
    cout << count << endl;
}

Measured memory_bytes: 256
<?php
int();
$a = ints();
$max = max($a);
$minDiff = 10**18;
$i = array_search($max, $a);
unset($a[$i]);
foreach($a as $b){
  $diff = abs($max / 2 - $b);
  if($minDiff > $diff){
    $minDiff = $diff;
    $ans = $b;
  }
}
echo $max." ".$ans,"\n";

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}

Measured memory_bytes: 16884
N, M = map(int, input().split())
a = [False] * N
w = [0] * N
for i in range(M):
    p, S = input().split()
    if S == 'AC':
        a[int(p)-1] = True
    elif not a[int(p)-1]:
        w[int(p)-1] += 1
print(a.count(True), sum([w[i] if a[i] else 0 for i in range(N)]))


Measured memory_bytes: 77432
import sys
sys.setrecursionlimit(1000000000)

n,m = map(int,input().split())
G = [[] for _ in range(n)]
INF = float("INF")
pos = [INF]*n
for _ in range(m):
    l,r,d = map(int,input().split())
    l -= 1
    r -= 1
    G[l].append((r,d))
    G[r].append((l,-d))

def dfs(now):
    for nxt,d in G[now]:
        if pos[nxt] == INF:
            pos[nxt] = pos[now]+d
            dfs(nxt)
        elif pos[nxt] != pos[now]+d:
            print("No")
            exit()

for i in range(n):
    if pos[i] == INF:
        pos[i] = 0
        dfs(i)
print("Yes")

Measured memory_bytes: 128980
/* ex4_2
    sak_Citrus*/

#include <stdio.h>
#include <math.h>

int main(void){
    //時針・分針の長さとその指す位置
    int hourLength,minuteLength,hour,minute;
    //0時方向から時計回りに測った角
    double hourAngle,minuteAngle;
    //解(の2乗)、角の差(cosの性質から負値も許容)
    double ans,diff;
    scanf("%d %d %d %d",&hourLength,&minuteLength,&hour,&minute);
    minuteAngle = 6 * minute * M_PI / 180; 
    hourAngle = (30 * hour + minute / 2.0) * M_PI / 180;
    diff = minuteAngle - hourAngle;
    //余弦定理
    ans = hourLength*hourLength + minuteLength*minuteLength - 2 * hourLength*minuteLength * cos(diff);
    //ansの平方根を小数点以下10桁まで出力
    printf("%.10lf\n",sqrt(ans));

    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int> a(N),sum(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum[i]=sum[i-1]+a[i];
  }
  for(int i=0;i<N;i++){
    if(sum[i]>sum[N-1]/2){
      cout<<min(2*sum[i]-sum[N-1],sum[N-1]-2*sum[i-1]);
      break;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int d, w;
int e[11][11];

int main(void) {
    while (1) {
        cin >> d >> w;
        if (d == 0 && w == 0) {
            break;
        }
        for (int i = 0; i < d; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> e[i][j];
            }
        }

        long long maxcap = 0;
        for (int ymin = 0; ymin < d; ++ymin) {
            for (int ymax = 0; ymax < d; ++ymax) {
                for (int xmin = 0; xmin < w; ++xmin) {
                    for (int xmax = 0; xmax < w; ++xmax) {

                        if (ymin + 2 <= ymax && xmin + 2 <= xmax) {
//                        printf("%d %d %d %d\n", ymin, ymax, xmin, xmax);
                            int exminheight = 11;
                            for (int i = ymin; i <= ymax; ++i) {
                                for (int j = xmin; j <= xmax; ++j) {
                                    if (i == ymin || i == ymax || j == xmin || j == xmax) {
                                        exminheight = min(e[i][j], exminheight);
                                    }
                                }
                            }
//                        cout << exminheight << endl;

                            long long cap = 0;
                            bool flood = false;
                            for (int i = ymin + 1; i <= ymax - 1; ++i) {
                                for (int j = xmin + 1; j <= xmax - 1; ++j) {
                                    if (e[i][j] >= exminheight) {
                                        flood = true;
                                        break;
                                    }
                                    cap += exminheight - e[i][j];
                                }
                                if (flood) {
                                    break;
                                }
                            }
                            if (!flood) {
                                maxcap = max(maxcap, cap);
                            }
                        }

                    }
                }
            }
        }

        cout << maxcap << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n;
	cin >> n;
	function<void(int, int, string)> solve;
	solve = [&] (int ch, int dep, string s) {
		if (dep == 0) {
			cout << s << endl;
			return;
		}
		rep (chr, 'a', ch + 1) {
			solve(max(ch, chr), dep - 1, s + (char) chr);
		}
	};
	solve('a', n - 1, "a");
	return 0;
}

Measured memory_bytes: 1536
/**
    AUTHOR:JUNSH
    TIME:19/5/25
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define rev(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const ll inf=0x3f3f3f3f;
ll n,m;
const ll maxn=15;
ll a[maxn];
ll st[maxn];
ll solve(ll pos,ll bit){
    if(pos>n){
        for(int i=1;i<=m;++i){
            if(((__builtin_popcount(bit&a[i]))&1)!=st[i])
                return 0;
        }
        return 1;
    }
    return solve(pos+1,bit)+solve(pos+1,bit|(1<<pos));
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(ll i=1;i<=m;++i){
        ll k;
        cin>>k;
        ll bit=0;
        ll tmp;
        for(ll j=1;j<=k;++j){
            cin>>tmp;
            bit|=(1<<tmp);
        }
        a[i]=bit;
    }
    for(ll i=1;i<=m;++i){
        cin>>st[i];
    }
    ll ans=solve(1,0);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main (void) {
    int a, b, sum;
    while (1) {
        cin >> a;
        cin >> b;
        if (cin.eof()) break;
        sum = a + b;
        if (sum == 0) cout << 1 << endl;
        else cout << (int)(log10(sum) + 1) << endl;
    }
    return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  string w;
  cin >> w;
  map<char, int> mp;
  REP(i, w.size()) {
    mp[w[i]]++;
  }
  string ans = "Yes";
  for(auto m : mp) {
    if(m.second % 2 == 1) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


const int N_MAX = 200001;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VI hash(N_MAX);
    REP(i, n){
        int a;
        cin >> a;
        hash[a]++;
    }
    sort(ALL(hash));

    int type_cnt = 0;
    REP(i, N_MAX){
        if(hash[i] != 0){
            type_cnt = N_MAX - i;
            break;
        }
    }
    int ans = 0;
    FOR(i, N_MAX - type_cnt, N_MAX - k - 1){
        ans += hash[i];
    }

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


Measured memory_bytes: 1024
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int n, t;
	{
		int[] tmp = readln.chomp.split.map!(to!int).array;
		n = tmp[0], t = tmp[1];
		}
	int[] as = readln.chomp.split.map!(to!int).array;
	
	int[] bs;
	bs.length = as.length;
	int b = bs[$ - 1];
	for(int i = as.length.to!int - 1; i >= 0; i --){
		if(b < as[i]) b = as[i];
		bs[i] = b;
		}
	
	int[] cs;
	cs.length = as.length;
	for(int i = 0; i < cs.length; i ++) cs[i] = bs[i] - as[i];
	
	int ans;
	int max = -1;
	foreach(c; cs){
		if(c > max) max = c, ans = 1;
		else if(c == max) ans += 1;
		}
	
	ans.writeln;
	
	}

Measured memory_bytes: 4148
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n;
int l[10];

bool ok(int p, int q){
    f(i, n){
        if(((p >> i) & 1) && ((q >> i) & 1)) return false;
    }
    return true;
}

int compute(int p, int a){
    int ret = (__builtin_popcount(p) - 1) * 10;
    int len = 0;
    f(i, n){
        if((p >> i) & 1) len += l[i];
    }
    ret += abs(len - a);
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int a, b, c;
    cin>>n>>a>>b>>c;
    f(i, n) cin>>l[i];
    int ans = INT_MAX;
    rep(i, 1, (1 << n) - 1){
        rep(j, 1, (1 << n) - 1){
            rep(k, 1, (1 << n) - 1){
                if(ok(i, j) && ok(i, k) && ok(j, k)){
                    int to = compute(i, a) + compute(j, b) + compute(k, c);
                    ans = min(ans, to);
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int x=a[1],N=1;
	for(;x!=2;N++)
	{
		x=a[x];
		if(N>n)
		{
			cout<<-1;
			break;	
		}
	}
	if(N<=n)
	  cout<<N;
 } 

Measured memory_bytes: 640
#include <iostream>
using namespace std;
bool judge(int a,int b){
	if(a == b){
		return true;
	}else{
		return false;
	}
}

bool answer(int a,int b, int c){
	int count = 0;
	if(judge(a,b)) count++;
	if(judge(c,b)) count++;
	if(judge(a,c)) count++;
	if(count == 1){
		return false;
	}else{
		return true;
	}
}

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	if(answer(A,B,C)){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

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

int main() {
  int n; cin>>n;
  vector<pii> v(n);
  rep(i,n){
    cin>>v[i].second>>v[i].first;
  }
  sort(v.begin(), v.end());
  rep(i,n-1){
    v[i+1].second+=v[i].second;
  }
  bool b=true;
  rep(i,n){
    if(v[i].first<v[i].second){b=false;break;}
  }
  if(b){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
    int n;
    long long int m;
    int d[10005]={};
    int p[10005]={};
    int dd[10005]={};
    int pp[10005]={};
    int point=0;
    int count=0;
    int keepd,keepp,keepx;
    while(1==1)
    {
        point=0;
        count=0;
        scanf("%d %lld\n",&n,&m);
        if(n==0&&m==0)break;
        for(int q=0;q<n;q++)scanf("%d %d\n",&d[q],&p[q]);
        while(count<n)
        {
            keepp=0;
            for(int x=0;x<n;x++)
            {
                if(keepp<p[x])
                {
                    keepp=p[x];
                    keepd=d[x];
                    keepx=x;
                }
            }
            dd[point]=keepd;
            pp[point]=keepp;
            point++;
            p[keepx]=0;
            count++;
        }
        point=0;
        while(m>0 && point<n)
        {
            if(m>dd[point])
            {
                m-=dd[point];
                dd[point]=0;
                point++;
            }
            else
            {
                dd[point]-=m;
                m=0;
            }
        }
        long long int ans=0;
        for(int y=0;y<n;y++)
        {
            ans+=dd[y]*pp[y];
        }
        //for(int z=0;z<n;z++)printf("##%d %d##\n",dd[z],pp[z]);
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 2036
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	op := make([]int, 100)
	p := 0

	list := strings.Split(getNextLine(scanner), " ")
	n := len(list)
	for i := 0; i < n; i++ {
		switch list[i] {
		case "+":
			op[p-2] += op[p-1]
			p--
		case "-":
			op[p-2] -= op[p-1]
			p--
		case "*":
			op[p-2] *= op[p-1]
			p--
		default:
			op[p], _ = strconv.Atoi(list[i])
			p++
		}
	}
	fmt.Fprintln(writer, op[0])
	writer.Flush()
}

func insertionSort(aa []int, n, g int) int {
	cnt := 0
	for i := g; i < n; i++ {
		v := aa[i]
		j := i - g
		for j >= 0 && aa[j] > v {
			aa[j+g] = aa[j]
			j -= g
			cnt++
		}
		aa[j+g] = v
	}

	return cnt
}

func shellSort(aa []int, n int) (int, []int) {
	cnt := 0
	gg := make([]int, 0)
	for g := 1; g <= n; g = 3*g + 1 {
		gg = append(gg, g)
	}
	l := len(gg)
	for i := 0; i*2 < l; i++ {
		gg[i], gg[l-1-i] = gg[l-1-i], gg[i]
	}
	for i := 0; i < l; i++ {
		cnt += insertionSort(aa, n, gg[i])
	}

	return cnt, gg
}



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

int main(){
  int N,K;
  int sum=0;
  cin>>N>>K;
  vector<int> A(N);
  
  for(int i=0; i<N; i++){
    cin>>A.at(i);
  }
  
  for(int i=0; i<N; i++){
    if(A.at(i)>=K){
      sum++;
    }
  }
  cout<<sum<<endl;
}

    

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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    for (int i = n - 1; i > 0; i--)
    {
        if (v[i] < v[i - 1] - 1)
        {
            cout << "No" << endl;
            return 0;
        }
        if (v[i] == v[i - 1] - 1)
        {
            v[i - 1]--;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;
typedef  pair<LL,LL> P;


const LL INF=1<<30;
const LL MOD=1000000007;


LL ruijo(int n){
    LL ret=0;
    while(n%2==0){
        n/=2;
        ret++;
    }
    return ret;
}


int main(){
    int n;
    cin>>n;
    LL a;
    LL counte=INF;
    for(int i=0;i<n;++i){
        cin>>a;
        counte=min(counte,ruijo(a));
        
    }
    cout<<counte<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define P pair<int, int>

using namespace std;

int dp[100][10001] = {};
int w[100];
int v[100];


int main(){
	int N, W;
	cin >> N >> W;
	rep(i, N){
		cin >> v[i] >> w[i];
	}

	rep(j, W+1){
		if (w[0] <= j){
			dp[0][j] = v[0];
		}
	}

	for (int i = 1; i < N; i++){
		for (int j = 0; j <= W; j++){
			if (w[i]>j){
				dp[i][j] = dp[i - 1][j];
			}
			else{
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			}
		}
	}
	cout << dp[N - 1][W] << endl;

}

Measured memory_bytes: 5068
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Curtain(void) {

	int A, B; cin >> A >> B;
	
	cout << ((A > B * 2) ? A - B * 2 : 0) << flush;
	return;
}

int main(void) {

	A_Curtain();
	return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		String S = sc.next();
		String T = sc.next();

		System.out.println(T+S);

	}

	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23508
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

h, w = MAP()
a = ''
for _ in range(h):
    a += STR()
a = list(a)
b = Counter(a)
c = list(set(a))
n4 = 0
n2 = 0
n1 = 0
for i in c:
    if b[i] % 2:
        n1 += 1
    elif b[i] % 4 == 0:
        n4 += 1
    elif b[i] % 2 == 0:
        n2 += 1
if h % 2 and w % 2:#奇数が一個あって良い。2の倍数が5//2*2コあってもよい
    if n1 == 1 and n2 <= h // 2 + w // 2:
        print('Yes')
    else:
        print('No')
elif h % 2:
    if n1 == 0 and n2 <= w // 2:
        print('Yes')
    else:
        print('No')
elif w % 2:
    if n1 == 0 and n2 <= h // 2:
        print('Yes')
    else:
        print('No')
else:
    if n1 == 0 and n2 == 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 60140
#include <bits/stdc++.h>
using namespace std;
// a??????b?????§?????´??°?????????,c????´???°?????????????????????
int main(){
	int a, b, c;
	int divisor;
	int count = 0;
	cin >> a >> b >> c;
	for(int i = a; i <= b; i++){
		if(c%i == 0) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 1164
use std::io;
use std::cmp::Ordering;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    let mut i: i32 = 0;

    loop {
//        input!{
//            value: i32,
//        }
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let value: i32 = s.trim().parse().ok().unwrap();

        i = i + 1;
        if value == 0 {
            break;
        }
        else
        {
            println!("Case {}: {}", i, value);
        }
    }
}




Measured memory_bytes: 5036
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 lli power(lli x,lli y,lli p)
{
  lli res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    //y must be even now
    y=y>>1; //y=y/2
    x=(x*x)%p;
  }
  return res;
}
 
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli max(lli a, lli b)
{
  if (a > b)
    return a;
  return b;
}
lli min(lli a, lli b)
{
  if (a < b)
    return a;
  return b;
}
using namespace std;

int main()
{  
    kira;
    //freopen("input.txt","r",stdin);
    lli n;
    cin>>n;
    double p,s=0.0;
    for(lli i=0;i<n;i++)
    {
      cin>>p;
      s=s+(1.0/p);
    }
   double q=1.0/s;
   cout<<fixed<<setprecision(10);
   cout<<q<<endl;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> ans(n, -1);
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int cur = que.front();
        que.pop();
        for (int i = 0; i < g[cur].size(); i++) {
            if (ans[g[cur][i]] == -1) {
                ans[g[cur][i]] = cur + 1;
                que.push(g[cur][i]);
            }
        }
    }
    bool f = true;
    for (int i = 1; i < n; i++) {
        if (ans[i] == -1) f = false;
    }
    if (f) {
        cout << "Yes" << endl;
        for (int i = 1; i < n; i++) cout << ans[i] << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

void call(int n);

int main()
{
    int n;
    cin >> n;
    call(n);
    return 0;
}

void call(int n)
{
    int x;    
    for(int i=1;i<=n;i++)
    {
        x = i;
        if(x % 3 == 0)
        {
            cout << " " << i;
            continue;
        }
        do
        {
            if(x % 10 == 3)
            {
                cout << " " << i;
                break;
            }
        } while(x /= 10);
    }   
    cout << endl;
}


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

int main(void){
  int x;
  cin >> x;
  for(int i = 0; i < 1000; i++){
    for(int j = -1000; j < 1000; j++){
      ll a = pow(i,5);
      ll b = pow(j,5);
      if(a - b == x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

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

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

vector<pair<ll, ll>> factorize(ll n) {
    vector<pair<ll, ll>> res;
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);

    return res;
}

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

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

    ll g = gcd(A,B);
    auto f = factorize(g);
    cout << f.size() + 1LL << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int N;
	scanf("%d", &N);
	int A[N];
	int B[N];
	int C[N - 1];
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	for(int i = 0; i < N; i++){
		scanf("%d", &B[i]);
	}
	for(int i = 0; i < N - 1; i++){
		scanf("%d", &C[i]);
	}
	int gains = B[A[0] - 1];
	int prev_eat = A[0];
	for(int i = 1; i < N; i++){
		if((prev_eat + 1) == (A[i])){
			if(prev_eat <= (N - 1)){
				// printf("YES\n");
				gains += C[prev_eat - 1];
			}
		}
		gains += B[A[i] - 1];
		prev_eat = A[i];
	}
	printf("%d\n", gains);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 500000

int a[MAX], cp[MAX], count = 0;

void merge_sort(int a[], int left, int right) {
	int i, j, k, mid;

	if (left < right) {
		mid = (left + right) / 2; 
		merge_sort(a, left, mid);  
		merge_sort(a, mid + 1, right);
		for (i = mid; i >= left; i--) { cp[i] = a[i]; } 
		for (j = mid + 1; j <= right; j++) {
			cp[right - (j - (mid + 1))] = a[j]; 
		}

		i = left;
		j = right;

		for (k = left; k <= right; k++) {
			if (cp[i] < cp[j]) { a[k] = cp[i++]; }
			else { a[k] = cp[j--]; }
			count++;
		}
	}
}

int main(void) {
	int i, n;

	scanf("%d", &n);
	for (i = 0; i < n; i++) { scanf("%d", &a[i]); }

	merge_sort(a, 0, n - 1);

	for (i = 0; i < n; i++) { 
		printf("%d", a[i]);  
		if(i != n-1) printf(" ");
	}
	printf("\n");
	printf("%d\n", count);

	return 0;
}



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


const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main() {
    int N,Q; cin >> N >> Q;
    string S; cin >> S;
    vector<int> a(N);
    vector<int> c(N);
    int counta=0; int countc=0;
    for(int i=0;i<N;i++){
        if(S[i]=='A'&&S[i+1]=='C')counta++;
        if(S[N-1-i]=='C'&&S[N-2-i]=='A')countc++;
        a[i]=counta; c[N-1-i]=countc;
    }
    int SUM = counta;
    for(int i=0;i<Q;i++){
        int l,r; cin >> l >> r;
        cout << SUM-a[l-2]-c[r] << endl;
    }
}



Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author zhangyong
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = in.nextInt();
            }
            Arrays.sort(arr);
            int sum = 0;
            for (int i = n - 1; i >= (n - m); i--) {
                sum += arr[i];
            }
            out.println(sum);
        }

    }
}



Measured memory_bytes: 23124
# AtCoder Regular Contest 080
# C - 4-adjacent

N=int(input())
alist=list(map(int,input().split()))

oddcount=0
mod40=0
other=0

for a in alist:
    if a%2==1:
        oddcount+=1
    elif a%4==0:
        mod40+=1
    else:
        other+=1

if N==1:
    if mod40==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
if N==2 or N==3:
    if mod40>0 or other==N:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
# ↑ここまではあってそう。

if N%2==1:  # N>3 ,Nが奇数の時
    if (N-((other//2)*2))//2 <= mod40:
        print("Yes")
        exit()
    else:
        print("No")
        exit()

else:   # N>3 ,Nが偶数の時
    if other%2==1:  #かつ、要素が偶数である数が奇数の時  
        if (N-((other//2)*2))//2 <= mod40:
            print("Yes")
            exit()
        else:
            print("No")
            exit()
    else:
        if (N-((other//2)*2))//2 <= mod40:
            print("Yes")
            exit()
        else:
            print("No")
            exit()

Measured memory_bytes: 20344
#include <stdio.h>

int main(void){
	int a,b,c,d,i;
	scanf("%d %d",&a,&d);
	int e = 1001;
	for(i = 0;i < a;i++){
		scanf("%d %d",&b,&c);
		if(b < e && c <= d){
			e = b;
		}
	}
	if(e != 1001){
		printf("%d\n",e);
	} else { 
		printf("TLE\n");
	}
	return 0;
}

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

bool sor(long long a, long long b){
	return abs(a)>abs(b);
}

int main(){
	long long n,z[100],tol;
		tol = 1;
		cin >> n;
		for(int i=0; i<n; i++){
			cin >> z[i];
		}
		sort(z, z+n, sor);
		for(int i=0; i<n-1; i++){
			if(z[i+1]<z[i])
				tol++;
		}
		cout << tol << endl;
}

Measured memory_bytes: 256
#![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 main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let mut count = vec![0; 100000];
    for num in a {
        count[num] += 1;
    }
    let mut ans = 0;
    for i in 1..100000 - 1 {
        ans = max(ans, count[i - 1] + count[i] + count[i + 1]);
    }
    println!("{}", ans);
}

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: 6396
#include <cstdio>
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int a, b;

int main() {
	while(1) {
		cin >> a >> b;
		if(a == 0 &&  b == 0) break;
		rep(i,a) {
			rep(j,b) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
n,m=map(int,input().split())
x=list(map(int,input().split()))
if n>=m:
    print(0)
else:
    y=[]
    x=sorted(x)
    for i in range(m-1):
        y.append(x[i+1]-x[i])
    ans=0
    y=sorted(y)
    for i in range(n-1):
        ans+=y[-i-1]
    print(sum(y)-ans)
        
    


Measured memory_bytes: 20316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    
    int arr[n],brr[n],crr[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&brr[i]);
        sum=sum+brr[i];
    }
    
    for(int i=0;i<n;i++)
    {
        crr[i]=sum+arr[i];
        sum=sum-brr[i]+arr[i];
    }
    
    sort(crr,crr+n);
    cout<<crr[n-1];
    
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int();
    A = read_ints();
    B = [0]*(N+1)
    B[N] = A[N]
    for i in range(N-1, -1, -1):
        B[i] = B[i+1]+A[i]
    nodes, answer = 1, 0
    for i in range(N+1):
        if nodes < A[i]:
            return -1
        answer += nodes
        nodes -= A[i]
        if i<N:
            nodes = min(2*nodes, B[i+1])
    return answer


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 78440
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
    return 0;
  } else {
    int A, B; cin >> A >> B;
    cout << A + B << endl;
  }
}


Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            checked
            {
                string[] s;
#if false
                int N = int.Parse(Console.ReadLine());
#else
                s = Console.ReadLine().Split(' ');
                int A = int.Parse(s[0]);
                int B = int.Parse(s[1]);
                int C = int.Parse(s[2]);
#endif


#if true
                /*
                s = Console.ReadLine().Split(' ');
                for (int i = 0; i < N; i++)
                {
                    v[i] = int.Parse(s[i]);
                }
                */
#else
                for (int i = 0; i < N; i++)
                {
                    v[i] = int.Parse(Console.ReadLine());
                }
#endif

                Console.WriteLine(Math.Max(0, C - (A - B)));
            }
        }
    }
}


Measured memory_bytes: 13140
N, T = map(int, input().split(' '))

min_c = 1001 

for i in range(N):
    c, t = map(int, input().split(' '))
    if t <= T :
        if min_c > c :
            min_c = c 
if min_c == 1001 :
    print('TLE')
else :
    print(min_c)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;

typedef pair<int,int> pii;
const int maxn = 2e5 + 100;
#define int ll
int32_t main(){
    int a,b,c;
    cin >> a >> b >> c;
    int a1 = a +b;
    if (a1 >= c) cout << b + c << endl;
    else cout << a1 + 1 + b << endl;
}


Measured memory_bytes: 256
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[102];
    gets(a);
    int x=strlen(a),i,j;
    for(i=0,j=x-1 ; i<=x/2,j>=x/2 ; i++,j--)
    {
        if(a[i]!=a[j])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(i=0,j=x/2-1 ; i<=x/2-1,j>=0 ; i++,j--)
    {
        if(a[i]!=a[j])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(i=x/2+1,j=x-1 ; i<=x-1,j>=x/2+1 ; i++,j--)
    {
        if(a[i]!=a[j])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
 
cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256