akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define mod (int)1000000007
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = DBL_EPSILON;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
signed main() {
	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB")puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdio>
using namespace std;

int main(){
	double a,b,c,s,l,h;
	cin >> a >> b >> c;
	s=0.5*a*b*sin((M_PI*c*1.0)/180);
	l=a+b+sqrt(pow(a,2.0)+pow(b,2.0)-2*a*b*cos((M_PI*c*1.0)/180));
	h=b*sin((M_PI*c*1.0)/180);
	printf("%.8f\n%.8f\n%.8f\n",s,l,h);
}

Measured memory_bytes: 3564
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
	int a,b,c,ans=0;
	string S,T;
	cin>>a>>b;
	cout<<a*(a-1)/2+b*(b-1)/2;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int d,c[26],s[400][26],t[400];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>d;
    rep(i,26)cin>>c[i];
    rep(i,d){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int score=0;
    vector<pair<int,pair<vector<int>,vector<int>>>>last;
    rep(i,10)last.pb({0,{vector<int>(26,-1),{}}});
    rep(i,d){
        vector<pair<P,int>>ma;
        rep(l,10)ma.pb({{-INF,-1},-1});
        rep(j,26){
            rep(l,10){
            int score=s[i][j];
            int memo=last[l].se.fi[j];
            last[l].se.fi[j]=i;
            rep(k,26)score-=c[k]*(i-last[l].se.fi[k]);
            last[l].se.fi[j]=memo;
            ma.pb({{score,j},l});
            sort(all(ma),greater<>());
            ma.resize(10);
            }
        }
        vector<pair<int,pair<vector<int>,vector<int>>>>next;
        for(auto p:ma){
            vector<int>v=last[p.se].se.fi;
            vector<int>u=last[p.se].se.se;
            v[p.fi.se]=i;
            u.pb(p.fi.se);
            next.pb({last[p.se].fi+p.fi.fi,{v,u}});
        }
        sort(all(next));
        last=next;
    }
    for(auto i:last[0].se.se)cout<<i+1<<endl;
    return 0;
}

Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
int n,w[105];
int main()
{
    cin>>n;
    int sum=0,ans=0x3f3f3f3f,sum1=0,sum2=0;
    for(int i=0;i<n;i++){
        cin>>w[i];
        sum+=w[i];
    }
    for(int i=0;i<n;i++){
        sum1+=w[i];
        sum2=sum-sum1;
        int c=abs(sum1-sum2);
        ans=min(ans,c);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&k)

	if k > a+b {
		fmt.Println(a - (k - a - b))
	} else if k > a {
		fmt.Println(a)
	} else {
		fmt.Println(k)
	}
}


Measured memory_bytes: 1752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.ArrayList;


class Main {
	public static void main(String[] args) throws IOException {
		DecimalFormat df1 = new DecimalFormat("0.000000");
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> ss = new ArrayList<String>();
		while(true){
			String s = new String(in.readLine());
			if(s.split(" ")[1].equals("?")){
				break;
			}
			ss.add(s);
		}
		for(String s :ss){
			String[] sss = s.split(" ");
			int a = Integer.parseInt(sss[0]);
			int b = Integer.parseInt(sss[2]);
			if(sss[1].equals("+")){
				System.out.println(a+b);
			}
			else if(sss[1].equals("-")){
				System.out.println(a-b);
			}
			else if(sss[1].equals("*")){
				System.out.println(a*b);
			}
			else {
				System.out.println(a/b);
			}
		}
	}

}

Measured memory_bytes: 17152
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var x1 = cin.nextInt();
            var y1 = cin.nextInt();
            var x2 = cin.nextInt();
            var y2 = cin.nextInt();

            var x = x2 - x1;
            var y = y2 - y1;

            Console.WriteLine((x2-y)+" "+(y2+x)+" "+(x1-y)+" "+(y1+x));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

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

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

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

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


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

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli a[200000] = {};
int main(void) {

	lli N;
	cin >> N;


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

	//sort(a,a+N);

	lli count = 1,hit = 0;
	bool ok = false;


	for (int i = 0; i < N; i++) {
		if (a[i] == count) {
			count++;
			ok = true;
		}
		else {
			hit++;
		}
	}

	if (ok) {
		cout << hit << endl;
	}
	else {
		cout << -1 << endl;
	}


	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        long[] abcd = new long[4];
        try (Scanner s = new Scanner(System.in)) {
            for(int i = 0; i < 4; i++) {
                abcd[i] = s.nextLong();
            }
            System.out.println(max(abcd[0] * abcd[2], abcd[0] * abcd[3], abcd[1] * abcd[2], abcd[1] * abcd[3]));
        }
    }
    
    private static long max(long p, long q, long r, long s) {
        long m1 = Math.max(p, q);
        long m2 = Math.max(m1, r);
        return Math.max(m2, s);
    }
}


Measured memory_bytes: 35680
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

map<int,int> factors;

void factorize(int n){
	for(int i=2;i*i<=n;i++){
		if((n%i)==0){
			factors[i]++;
			return factorize(n/i);
		}
	}
	factors[n]++;
}

int32_t main(){
	int n,p;
	cin>>n>>p;
	factorize(p);
	factors[1]=1e15;
	int ans = 1;
	for(auto x: factors){
		if(x.second>=n){
			ans *= pow(x.first,x.second/n);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

main = do
  s <- BS.getLine
  let s' = BS.reverse s
      d = sum $ map (\(x, y) -> if x == y then 0 else 1) $ BS.zip s s'
  print $ d `div` 2

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define INF 1<<30
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;

int mat[maxn+2][4], ans[maxn+2][4] , n;
const int k = 3;

void init(int n){
    for(int i = 0; i <= n; i++) 
        ans[i][0] = ans[i][1] = ans[i][2] = -1;
}

int solve(int day, int option){
    if(day >= n) return 0;

    if(ans[day][option] != -1) return ans[day][option];

    int res = -1;
    for(int next_option = 0; next_option < k; next_option++) {
        if(next_option != option) res = max(res, mat[day][option] + solve(day + 1, next_option));
    }

    return ans[day][option] = res;
}

int main() {
    
    while(scanf("%d",&n)==1){
        init(n);
        
        for(int i=0;i<n;i++) {
            for(int j = 0;j < k; j++) scanf("%d",&mat[i][j]);
        }

        int res = -1;
        for(int option = 0; option < k; option++) {
            res = max(res, solve(0, option));
        }

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

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

using namespace std;

int main() {
  while(true) {
    int x, y, s;
    cin >> x >> y >> s;
    if (x + y + s == 0) {
      break;
    }
    
    int as, as_max = -1;
    for (int i = 1; i < s; i++) {
      for (int j = 1; j < s; j++) {
        if (i * (100 + x) / 100 + j * (100 + x) / 100 != s) {
          continue;
        }
        as = (i * (100 + y) / 100) + (j * (100 + y) / 100);
        if (as > as_max) {
          as_max = as;
        }
      }
    }  
    cout << as_max << endl;
  }
  
  return 0;
}

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

int main() {
    int x , n;
    cin >> x >> n;
    vi p(102);
    rep(i, n) {
        int d;
        cin >> d;
        p.at(d) = 1; 
    }

    pii ans(99999, -1);

    for (int i = 0; i <= 101; i++) {
        if (p.at(i) == 1) continue;
        int dif = abs(x - i);
        ans = min(ans, pii(dif, i));
    }

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

Measured memory_bytes: 3576
use proconio::input;

fn main() {
    input! {
        A: i32,
        B: i32,
        C: i32,
        mut cards: i32
    }

    if (cards - A) < 0 {
        println!("{}", cards);
        return;
    }

    let mut points = A;
    cards -= A;

    if (cards - B) < 0 {
        println!("{}", points);
        return;
    }

    cards -= B;
    println!("{}", points - cards);
}


Measured memory_bytes: 2160
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
* * WRITER:kakitamasziru/OxOmisosiru * *
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1001001001001001;
const long long MOD = 1000000007;
typedef pair<long long,long long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
 
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

long long A,B;
bool ok(long long key,long long index){
    string S = to_string(index);
    long long nagasa = S.size();
    if(index*A+nagasa*B > key) return true;
    else if(index*A+nagasa*B <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    int N,K;cin >> N >> K;
    vector<double> retu(N);
    for(int i = 0;i<N;i++)cin >> retu.at(i);
    vector<double> rui(N+1);
    rui.at(0) = 0.000000;
    for(int i = 0;i<N;i++){
        rui.at(i+1) = rui.at(i) + (retu.at(i)/2.000000)+0.500000;
    }
    double ans = 0.000000;
    for(int i = 0;i<N-K+1;i++){
        ans = max(ans,rui.at(i+K)-rui.at(i));
    }

    cout << fixed << setprecision(7) << ans << endl;

    // PLEASE GIVE ME THE "ACCEPTED" !
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll a, b;
    cin >> a >> b;
    ll res;
    if (b % a) res = b - a;
    else res = a + b;

    cout << res << endl; 
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in reversed(range(n)):
    tmp=b[i]-a[i+1]
    if tmp>=0:
        if a[i]-tmp>=0:
            cnt+=b[i]
            a[i]=a[i]-tmp
        else:
            cnt+=a[i+1]
            cnt+=a[i]
            a[i]=0
    else:
        cnt+=b[i]
print(cnt)


Measured memory_bytes: 18476
/**
 *   created: 21 July 2019  12:00:05
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		vi v(n);
		rep(i,0,n)
			cin>>v[i];
		int res = 0;
		rep(i,1,n-1){
			if(v[i]>min(v[i-1],min(v[i+1],v[i])) && v[i]<max(v[i-1],max(v[i+1],v[i])) )
				res++;
		}
		cout<<res;
	}

	return 0;
}


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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    while(C-B>0 && A-D>0){
        C -= B;
        A -= D;
    }

    if(C-B>0 && A-D<=0) cout << "No" << endl;
    else if(C-B<=0 && A-D>0) cout << "Yes" << endl;
    else if(C-B<=0 && A-D<=0) cout << "Yes" << endl;
    else cout << "有り得ない" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return sums.back();
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) ^ getSum(start - 1);
    }

    void build() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) ^ numbers[i];
        }
    }

};


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

    ll sum = 0;
    for (ll l : v) sum ^= l;

//    cout << sum << endl;

    for (ll l : v) cout << (sum ^ l) << endl;

//    CumulativeSum cs(n);
//    rep(i, n) cs.set(i, v[i] % 2);
//    cs.build();

    // s[0] = 1と仮定する



}

Measured memory_bytes: 4832
H, W = map(int, input().split())
mod = 10**9 + 7
field = []
for i in range(H):
    S = input()
    field.append(S)

dp = [[0]*W for i in range(H)]

#端っこ
dp[0][0] = 1
# 縦
for i in range(1,H):
    if field[i][0] == ".":
        dp[i][0] = dp[i-1][0]
    else:dp[i][0] = 0
# 横
for j in range(1,W):
    if field[0][j] == ".":
        dp[0][j] = dp[0][j-1]
    else:
        dp[0][j] = 0

for i in range(1,H):
    for j in range(1,W):
        if field[i][j] == ".":
            dp[i][j] = dp[i][j-1]+dp[i-1][j]
            
print(dp[H-1][W-1]%mod)
# print(dp)

Measured memory_bytes: 157428
import math

def is_prime(x):
    ans = True
    for i in range(2, int(math.sqrt(x))+1):
        if x%i == 0:
            ans = False
            break
    return ans

def next_prime(x):
    while True:
        if is_prime(x):
            break
        else:
            x += 1
    return x

x = int(input())

print(next_prime(x))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N, P; cin >> N >> P;
  vector<ll> A(N);
  bool odd = false;
  rep(i, 0, N) {
  	cin >> A[i];
    if (A[i] % 2) odd = true;
  }
  if (!odd) {
  	if (P) {
    	cout << 0 << endl;
    } else {
    	cout << ((ll) 1 << N) << endl;
    }
  } else {
  	cout << ((ll) 1 << (N - 1)) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    ll ans=0;
    rep(i,1,n){
        ans+=((n-1)/i);
    }
    cout<<ans<<endl;
    
    return 0;
}





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

up_streaks = []
i = 1
while i < n:
    if a[i] > a[i-1]:
        # 上がっている
        st = i-1
        en = i
        i+=1
        while i < n:
            if a[i] < a[i-1]:
                break
            else:
                en = i
            i+=1
        up_streaks.append([st, en])
    i+=1

cur = 1000
for st, en in up_streaks:
    cur = cur +  (a[en] - a[st]) * (cur//a[st])
print(cur)

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


typedef long long ll;
#define reg register
#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)


char IO;
inline ll rd(){
	ll s=0,f=0;
	while(!isdigit(IO=getchar())) if(IO=='-') f=1;
	do s=(s<<1)+(s<<3)+(IO^'0');
	while(isdigit(IO=getchar()));
	return f?-s:s;
}


const int N=3100;

int P,a[N];

int po[N]={1},Inv[N]={1,1};
int b[N];
int C(int n,int m){
	if(n<0||m<0||n<m) return 0;
	return po[n]*Inv[m]%P*Inv[n-m]%P;
}

int fl=0;
int main(){
	P=rd();
	rep(i,1,P+1) po[i]=po[i-1]*i%P;
	rep(i,2,P-1) Inv[i]=(P-P/i)*Inv[P%i]%P;
	rep(i,2,P+1) Inv[i]=Inv[i]*Inv[i-1]%P;
	//rep(i,1,1) {
		//int t=1;
		//rep(j,0,P-1) cout<<C(P-1,j)*t%P<<' ',t=t*(P-i)%P;
	//}
	//puts("");
	rep(i,0,P-1) {
		if(rd()) {
			fl=1;
			int t=1;
			drep(j,P-1,0) b[j]=b[j]+C(P-1,j)%P*t%P,t=t*(P-i)%P;
			//t=1; drep(j,P-1,0) cout<<C(P-1,j)*t<<' ',t*=(-i);puts("");
		} else b[0]++;
	}
	//if(!fl) rep(i,0,P-1) printf("0%c",i==P-1?'\n':' ');
	//else {
		rep(i,0,P-1) {
			int x=(P-b[i])%P;
			x=(x%P+P)%P;
			printf("%d%c",x,(i==P-1)?'\n':' ');
		}
	//}
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int n; cin >> n;

    //何文字？
    int i=1;
    int tmp=1;
    int num=0;
    while(i++){
        tmp*=26;
        if(n<=tmp){
            num=i-1;
            break;
        }
        tmp++;
    }
    int bottom=1;
    while(bottom<=n){
        bottom*=26;
        bottom++;
    }
    bottom=(bottom-1)/26;
    //cout<<bottom<<endl;
    vint add(num,0);
    int diff=n-bottom;
    //cout<<diff<<endl;
    rep(i,num){
        add[i]=diff%26;
        diff/=26;
    }
    rep(i,num){
        cout<<char('a'+add[num-1-i]); 
    }
    cout<<endl;
    //rep(i,num) cout<<add[i];

}

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

int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0) break;

    int s[1000],p[1000],q[1000],r[1000],c[1000];

    for(int i = 0;i < n;i++){
      cin >> s[i] >> p[i] >> q[i] >> r[i];
      c[i] = p[i] * 4 + q[i] * 9 + r[i] * 4;
    }

    int P,Q,R,C;
    cin >> P >> Q >> R >> C;

    bool flag = false;
    for(int i = 0;i < n;i++){
      if(p[i] <= P && q[i] <= Q && r[i] <= R && c[i] <= C){
        flag = true;
        cout << s[i] << endl;
      }
    }

    if(!flag) cout << "NA" << endl;
  }

  return 0;
}



Measured memory_bytes: 3128
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */

/** Problem0202 : At Boss's Expense **/
const int MAX = 1000010;
int main()
{
	int N, P;
	bool isPrime[MAX];
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0]=false, isPrime[1]=false;
	for (int i=2; i<MAX; i++) {
		if (isPrime[i]) {
			for (int j=2; i*j<MAX; j++) {
				isPrime[i*j]=false;
			}
		}
	}
	
	while (cin>>N>>P, N||P) {
		vector<int> price(N);
		bool can[MAX]={0};
		
		rep(i, N) {
			cin>>price[i];
			can[price[i]] = true;
		}
		
		for (int i=0; i<N; i++) {
			for (int j=0; j<MAX; j++) {
				if (can[j] && j+price[i]<=MAX) {
					can[j+price[i]] = true;
				}
			}
		}
		
		int ans=0;
		for (int i=0; i<=P; i++) {
			if (can[i] && isPrime[i])
				ans = i;
		}
		
		if (ans>0) {
			cout << ans << endl;
		} else {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(void){
    int n;
    ll p=((ll)1<<50);
    cin>>n;
    vector<ll> ar(n+1,0);
    for(int i=1;i<=n;i++)cin>>ar[i];
    for(int i=1;i<=n;i++){
        ar[i]+=ar[i-1];
    }
    for(int i=1;i<n;i++){
        //cout<<ar[i]<<","<<ar[n]-ar[i]<<endl;
        if(p>llabs(ar[n]-ar[i]*2))p=llabs(ar[n]-ar[i]*2);
    }
    cout<<p;
}


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

using namespace std;
using ll = long long;

const long long inf = 1e9;
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;
typedef priority_queue<int> Pqi;
typedef priority_queue<ll> Pql;

ll n, m, k;


int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	ll e = 1e18;
	ll ans = 1;
	bool of = 0, z = 0;
	fr(i,0,n) {
		ll x;
		cin >> x;
		if (!x)
			z = 1;
		else if (ans <= e / x)
			ans *= x;
		else
			of = 1;
	}
	if (of && !z) {
		cout << -1 << endl;
		return 0;
	} 
	if (z) {
		cout << 0 << endl;
		return 0;
	}
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 3644
N,M,X,Y = map(int,input().split())
area_x= list(map(int,input().split()))
area_x.append(X)
area_y= list(map(int,input().split()))
area_y.append(Y)

if max(area_x) < min(area_y):
  print("No War")
else:
  print("War")

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            int n = Convert.ToInt32(N);
            int a = 0;
            int b = 0;
            int c = 0;
            int d = 0;

            string[] vs = new string[n];

            for (int i = 0; i < n; i++)
            {
                vs[i] = Console.ReadLine();

                switch ( vs[i] )
                {
                    case "AC":
                        a++;
                        break;
                    case "WA":
                        b++;
                        break;
                    case "TLE":
                        c++;
                        break;
                    case "RE":
                        d++;
                        break;
                }
            }

            Console.WriteLine("AC x " + a);
            Console.WriteLine("WA x " + b);
            Console.WriteLine("TLE x " + c);
            Console.WriteLine("RE x " + d);
        }
    }
}

Measured memory_bytes: 20964
#include<iostream>
using namespace std;
/*
bool sw[1000001];
int i;
 
void sws(int k){
        if(k==1){
                sw[i]=true;
                return;
        }
        if(k%2==0) sws(k/2);
        else if(k%3==0) sws(k/3);
        else if(k%5==0) sws(k/5);
        return;
}
*/
// korenisuru
int dp[1000001];
int f(int n){
        if(~dp[n]) return dp[n];
        int ans = 0;
        if(n%2==0) ans |= f(n/2);
        else if(n%3==0) ans |= f(n/3);
        else if(n%5==0) ans |= f(n/5);
        return dp[n] = ans;
}
 
int main() {
        int m,n;
        for(int i = 0 ; i <= 1000000 ; i++) dp[i] = -1;
        dp[1] = 1;
        for(int i = 1000000 ; i >= 1 ; i--) f(i);
        while(cin >> m && m){
                cin >> n;
                int ans = 0;
                for(int i = m ; i <= n ; i++) ans += dp[i];
                cout << ans << endl;
        }
        return 0;
}

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

int main() {
  string c;
  int n, a=0, b=0, i, ans;
  cin >> n;
  cin >> c;
  
  for(int i=0; i<n; i++) {
    if(c[i] == 'R')a++;
  }
  if(a==0||a==n)cout << 0;
  else {
    for(int i=0;i<a;i++) {
      if(c[i] == 'W')b++;
    }
    cout << b;
  }
}

Measured memory_bytes: 3752
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int n=sc.nextInt();
            int r=sc.nextInt();
            if(n==0 && r==0){
                break;
            }
            int []num=new int[n];
            
            for(int i=0;i<n;i++){
                num[i]=n-i;
            }
            for(int i=0;i<r;i++){
                int p=sc.nextInt();
                int c=sc.nextInt();
                for(int j=0;j<c;j++){
                    for(int k=0;k<=p-1;k++){
                        int temp=num[p-1+j];
                        num[p-1+j]=num[k+j];
                        num[k+j]=temp;
                    }
                }
            }
            System.out.println(num[0]);
        }
    }
}

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

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

    int n, k;
    cin >> n >> k;
    int res = 0;
    rep(i, n)
    {
        int h;
        cin >> h;
        if (h >= k) res++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int a, b, c;
  scan(a, b, c);
  print(min(b / a, c));

  return 0;
}


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

int n;
int bs, ae, both, ans;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<string> a(n);
    for (auto& i : a) {
		cin >> i;
		for (int j = 0; j < i.size() - 1; j++) {
			ans += (i[j] == 'A' && i[j + 1] == 'B');
		}
		if (i[0] == 'B' && i[i.size() - 1] == 'A') {
			both++;
		} else if (i[0] == 'B') { 
			bs++; 
		} else if (i[i.size() - 1] == 'A') {
			ae++;
		}
	}
    if (ae) {
		ae--;
		ans += both;
		if (bs) {
			ans++;
			bs--;
		}
		ans += min(ae, bs);
	} else {
		if (both) ans += both - 1 + min(bs, 1);
	}
    cout << ans;
    return 0;
}


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

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < K; i++) ans += l[i];
  cout << ans << endl;
  return 0;
}

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

int main () {
  int a,b;
  cin >> a >> b;
  if(a + b >= 10) {
    cout << "error";
  } else {
    cout << a + b;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
#define int long long
const int inf=1e16;

int func(int b, int n){

   if(b<2) return inf;
   if(n<b) return n;
   return func(b, n/b)+(n%b);
}

int f1(int n, int s){

   int b=2;
   while(b*b<=n){
      if(func(b, n)==s) return b;
      b++;
   }
   return inf;
}

int f2(int n, int s){

   int b=inf;
   int p=1;
   while(p*p<=n){
      if((n-s+p)%p==0){
         int _b=(n-s)/p+1;
         if(func(_b, n)==s) b=min(b, _b);
      }
      p++;
   }
   return b;
}

signed main(){

   int n, s;
   cin>> n>> s;

   if(n==s){
      cout<< n+1<< endl;
      return 0;
   }
   int b=f1(n, s);
   b=min(b, f2(n, s));

   cout<< (b==inf? -1: b)<< endl;

   return 0;
}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, L, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N >> L;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    for(int i=0;i<N-1;i++) {
        tmp = max(tmp, A[i]+A[i+1]);
    }
    if(tmp<L) {
        cout << "Impossible" << endl;
        return 0;
    }
    else {
        cout << "Possible" << endl;
        for(int i=0;i<N-1;i++) {
            if(tmp==A[i]+A[i+1]) {
                ans = i+1;
            }
        }
        for(int i=0;i<N-1;i++) {
            if(i+1==ans) break;
            cout << i+1 << endl;
        }
        for(int i=0;i<N-1;i++) {
            if(N-1-i==ans) break;
            cout << N-1-i << endl;
        }
        cout << ans << endl;
        return 0;

    } 
    return 0;
}

Measured memory_bytes: 4264
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


#line 1 "lib/union_find.hpp"



#include <vector>

class UnionFind {
public:
    UnionFind(int n) : par(n, -1), ran(n, -1) {}

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;

        if (ran[x] < ran[y]) {
            par[find_root(y)] += par[find_root(x)];
            par[x] = y;
        }
        else {
            par[find_root(x)] += par[find_root(y)];
            par[y] = x;
            if (ran[x] == ran[y]) ran[x]++;
        }
    }

    int size(int x) {
        return -par[find_root(x)];
    }

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

    int find_root(int x) {
        if (par[x] < 0) {
            return x;
        }
        else {
            return par[x] = find_root(par[x]);
        }
    }

private:
    std::vector<int> par, ran;
};


int main() {
    int n, m; std::cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int a, b, c; std::cin >> a >> b >> c;
        uf.unite(a - 1, b - 1);
    }
    std::vector<int> cnt(n);
    for (int i = 0; i < n; i++) {
        cnt[i] = uf.find_root(i) == i;
    }
    std::cout << std::accumulate(cnt.begin(), cnt.end(), 0) << std::endl;
    return 0;
}


Measured memory_bytes: 1408
//NTL_1B
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef unsigned long long ull;

ull mod_pow(ull x,ull n,ull mod){
 ull res=1LL;
 while(n>0){
  if(n%2==1) res=res*x%mod;
  x=x*x%mod;
  n/=2;
 }
 return res;
}

int main(){
 ull m,n;
 cin>>m>>n;
 cout<<mod_pow(m,n,1000000007)<<endl;
 return 0;
}

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

int main() {
    vector<int> a(3);
    for (int i = 0; i < 3; i++) { cin >> a.at(i); }
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        int score = 0;
        for (int j = 0; j < 3; j++) {
            if (j == i) score += 10 * a.at(j);
            else score += a.at(j);
        }
        ans = max(ans, score);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
string s,t;
int dp[3005][3005];
pair<int,int> nextState[3005][3005];
int solve(int i,int j)
{
    if(i == s.length() || j == t.length())
        return 0;
    if(dp[i][j] != -1)
        return dp[i][j];
    int C = solve(i+1,j);
    nextState[i][j] = {i+1,j};
    if(solve(i,j+1) > C)
    {
        C = solve(i,j+1);
        nextState[i][j] = {i,j+1};
    }
    if(s[i] == t[j])
    {
        if(1 + solve(i+1,j+1) > C)
        {
            C = 1 + solve(i+1,j+1);
            nextState[i][j] = {i+1,j+1};
        }
    }
    return dp[i][j] = C;
}
void printans(int i,int j)
{
    if(i == s.length() || j == t.length())
        return;
    if(nextState[i][j].first != i && nextState[i][j].second != j)
        cout << s[i];
    printans(nextState[i][j].first,nextState[i][j].second);
}
int main()
{
    IO;
    memset(dp,-1,sizeof dp);
    cin >> s >> t;
    solve(0,0);
    printans(0,0);
    return 0;
}


Measured memory_bytes: 106624
#include <iostream>

int main() {
    int a[30][30] = {};
    int N, M, cnt, hoge;
    std::cin >> N >> M;
    for (int i = 0 ; i < N ; ++i) {
        cnt = 0;
        std::cin >> cnt;
        for (int j = 0 ; j < cnt ; ++j) {
            std::cin >> hoge;
            a[i][hoge-1] = 1;
        }
    }
    int sum, ans = 0;
    for (int i = 0 ; i < M ; ++i) {
        sum = 0;
        for (int j = 0 ; j < N ; ++j) {
            if (a[j][i] == 1) {
                ++sum;
            } else {
                break;
            }
        }
        if (sum == N) {
            ++ans;
        }
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256