akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            while (true) {
                int n = in.nextInt();
                if (n == 0) break;

                int sum = 0;
                int min = 1000;
                int max = 0;

                for (int i = 0; i < n; i++) {
                    int point = in.nextInt();
                    max = Math.max(max, point);
                    min = Math.min(min, point);
                    sum += point;
                }
                out.println((sum - max - min) / (n - 2));
            }
        }
    }
}




Measured memory_bytes: 28988
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    int n;
    s(n);
    vi a(n);
    read_vec(a, in);
    int ans = 0;
    sort(range(a));
    f(i, 0, n){
        f(j, i + 1, n){
            f(k, j + 1, n){
                if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k]){continue;}
                if(a[i]+a[j]>a[k]){
                    ans++;
                }
            }
        }
    }
    p(ans);
    return;
}

class BMakingTriangle {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    BMakingTriangle solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3660
#include <deque>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;

int dist[100005];


int main()
{
	int n;
	cin >> n;
	memset(dist, -1, sizeof(dist));
	deque<int> dq;
	dq.push_back(1);
	dist[1] = 1;
	while (!dq.empty())
	{
		int now = dq.front();
		if (now == 0) {
			cout << dist[0];
			return 0;
		}
		dq.pop_front();
		int next = (now*10)%n;
		if (dist[next] == -1 || dist[next] > dist[now]) {
			dist[next] = dist[now];
			dq.push_front(next);
		}
		next = (now + 1) % n;
		if (dist[next] == -1 || dist[next] > dist[now]) {
			dist[next] = dist[now] + 1;
			dq.push_back(next);
		}
	}
}

Measured memory_bytes: 896
Num = [int(i) for i in range(2, 100001)]
Primes = [True for i in range(100001)]
Sim = [0 for i in range(100001)]

for i in range(2, 100001):
    if Primes[i] == True:
        j = i * 2
        while j < 100001:
            Primes[j] = False
            j += i

for i in range(3, 100001):
    if Primes[i] and Primes[(i+1)//2]:
        Sim[i] = Sim[i-1] + 1
    else:
        Sim[i] = Sim[i-1]

Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(Sim[r] - Sim[l-1])

Measured memory_bytes: 8984
#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
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
 
template<typename key> using ordered_set = tree <key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
 
int main () {
   IO;
   int n;
   bool flag = true;
   cin >> n;
   for(int i = 0; i < n; i++) {
      int a;
      cin >> a;
      if((a & 1 ^ 1) && (a % 3) && (a % 5))
         flag = false;
   }
   if(!flag)
      cout << "DENIED";
   else
      cout << "APPROVED";
   return 0;
}

Measured memory_bytes: 256
n = int(input())
v = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
d = [v[i]-c[i] for i in range(len(v))]
ans = 0
for i in range(len(v)):
    if d[i] > 0:
        ans += d[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    cout << fixed << setprecision(10);
    double A,B,C,D;
    cin>>A>>B>>C>>D;
    double a1,a2;
    a1=30*C+D/2;
    a2=6*D;
    double a3=0;
    if(a1<=a2){
    a3=min(360+a1-a2,a2-a1);}
    else {
    a3=min(360+a2-a1,a1-a2);}
    double pi=3.1415926535;
    double sita=a3*pi/180;
    double answer=sqrt(A*A+B*B-2*A*B*cos(sita));
    cout<<answer<<endl;}
    

Measured memory_bytes: 4224
# -*- coding: utf-8 -*-
 
# スペース区切りの整数の入力
c = input()

# 計算と出力
if (c == "a") or (c == "i") or (c == "u") or (c == "e") or (c == "o") :
    print("vowel")
else :
    print("consonant")

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll n,m,q;
int p[505][505];

/* add your algorithm here */

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

  rep(i,m) {
    int a,b;
    scanf("%d %d", &a, &b);
    p[a][b]++;
  }

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      p[i][j] += p[i-1][j];
      p[i][j] += p[i][j-1];
      p[i][j] -= p[i-1][j-1];
    }
  }

  for (int i = 0; i < q; ++i) {
    int tp,tq;
    scanf("%d %d", &tp, &tq);
    int ans = p[tq][tq] - p[tp-1][tq] - p[tq][tp-1] + p[tp-1][tp-1];
    cout << ans << endl;
  }
}


Measured memory_bytes: 1920
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#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 ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
#define LAST(X) X[X.size()-1]
#define MOD 1000000007
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	int X;
	cin >> X;
	if (X<1200 )
		cout << "ABC";
	else
		cout << "ARC";
}

Measured memory_bytes: 256
#!/usr/bin/env python3

h, w, a, b = list(map(int, input().split()))

for h_tmp in range(h):
    for w_tmp in range(w):
        if (w_tmp < a and h_tmp < b) or (w_tmp >= a and h_tmp >= b):
            print(0, end="")
        else:
            print(1, end="")
    print()


Measured memory_bytes: 5364
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A) rep(i,0,A.size()){cout<<(i ? " ":"")<<A[i];}cout<<endl;
const int mod=1e9+7;
int main(){
	int N,A,B;cin>>N>>A>>B;
	cout<<min(N*A,B)<<endl;
}
/*
template<typename T> void print(T x){
	return;
}
1.*a/b int to double
(res+=dp[i])%=mod

Ctrl+F->input->Alt+Enter
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------

int main(){
    
    string inp;
    cin>>inp;
    if(inp=="ARC") cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;

}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#define fs first
#define sc second
using namespace std;
const int maxn = 5e5+10;
using pii = pair<int,int>;
typedef long long ll;

int N,Q;
string str;
struct node{
    int l,r;
    set<char> st;
}tr[maxn*4];

void pushup(node &fa,node &L,node &R){
    fa.st.clear();
    for(auto c:L.st) fa.st.insert(c);
    for(auto c:R.st) fa.st.insert(c);
}

void build(int u,int l,int r){
    if(l == r){
        tr[u] = {l,r};
        tr[u].st.insert(str[l-1]);
    }else{
        tr[u] = {l,r};
        int mid = l+r>>1;
        build(u*2,l,mid);
        build(u*2+1,mid+1,r);
        pushup(tr[u],tr[u*2],tr[u*2+1]);
    }
}
void modify(int u,int idx,char c){
    if(tr[u].l == idx && tr[u].r == idx){
        tr[u].st.clear();
        tr[u].st.insert(c);
    }else{
        int mid = (tr[u].l+tr[u].r)>>1;
        if(idx<=mid) modify(u*2,idx,c);
        else modify(u*2+1,idx,c);
        pushup(tr[u],tr[u*2],tr[u*2+1]);
    }
}
node query(int u,int l,int r){
    if(tr[u].l>=l && tr[u].r<=r){
        return tr[u];
    }else{
        int mid = (tr[u].l+tr[u].r)>>1;
        node n1,n2,n3;
        if(l<=mid) n2 = query(u*2,l,r);
        if(r>mid) n3 = query(u*2+1,l,r);
        pushup(n1,n2,n3);
        return n1;
    }
}
int main(){
    cin>>N>>str>>Q;
    build(1,1,N);
    while(Q--){
        int op,a,b;char c;
        scanf("%d",&op);
        if(op == 1){
            scanf("%d %c",&a,&c);
            modify(1,a,c);
        }else{
            scanf("%d %d",&a,&b);
            node res= query(1,a,b);
            printf("%lu\n",res.st.size());
        }
    }

    return 0;
}

Measured memory_bytes: 202488
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();

        int n = scanner.nextInt();
        int l = scanner.nextInt();
        int max = l + n - 1;
        int min = l;
        int sum = 0;

        for(int i=0;i<n;i++) {
        	sum += (l+i);
        }

        if(min<=0&&0<=max) {
        	System.out.println(sum);
        }else if(0<min) {
        	System.out.println(sum-min);
        }else {
        	System.out.println(sum-max);
        }
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    REP(n1, 10) REP(n2, 10) REP(n3, 10) {
        char c1 = '0' + n1;
        char c2 = '0' + n2;
        char c3 = '0' + n3;

        int cnt = 0;
        for (char ch : s) {
            if (cnt == 0 and ch == c1) {
                cnt = 1;
                continue;
            }
            if (cnt == 1 and ch == c2) {
                cnt = 2;
                continue;
            }
            if (cnt == 2 and ch == c3) {
                cnt = 3;
                continue;
            }
        }
        
        if (cnt == 3) {
            //cout << c1 << c2 << c3 << endl;
            ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int a,b,c;
	int ans;
	bool flg;
	int cnt=-1;
	
	while(cin>>a>>b){
		cnt++;flg=false;
		//-----test-----
		switch(cnt){
		case 0:
			if(!(900000<a)) flg=true; 
			break;
		}
		
		if(flg) break;
		
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int nr=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R') nr++;
  }
  
  int ans=0;
  for(int i=0;i<nr;i++){
    if(s[i]=='W') ans++;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define EPS 1e-6
#define INF 2147483647
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define llINF 9223372036854775807

using namespace std;
typedef struct E{
  ll to,cost;
}edge;
const int MAX_V=100100;
const ll Inf=1e15;
vector<vector<edge> >E(MAX_V);
ll d[MAX_V];
int V;
void dijkstra(int s){
  priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int> > >que;
  fill_n(d,V,Inf);
  d[s] = 0;
  que.push(pair<ll,int>(0,s));
  while(!que.empty()){
    pair<ll,int> p=que.top();que.pop();
    int v = p.second;
    if(d[v]<p.first)continue;
    for(int j=0;j<E[v].size();j++){
      edge t = E[v][j];
      if(d[t.to]>d[v]+t.cost){
	d[t.to]=d[v]+t.cost;
	que.push(pair<ll,int>(d[t.to],t.to));
      }
    }
  }
}
int main(){
  cin>>V;
  for(int i=0;i<V-1;i++){
    int a,b;
    int c;
    cin>>a>>b>>c;a--;b--;
    edge e;e.to=b;e.cost=c;
    E[a].pb(e);
    e.to=a;
    E[b].pb(e);
  }
  int q,k;
  cin>>q>>k;
  dijkstra(k-1);
  for(int i=0;i<q;i++){
    ll ans=0;
    int x,y;cin>>x>>y;
    //cout<<d[x-1]<<" "<<d[y-1]<<endl;
    cout<<(ll)(d[x-1]+d[y-1])<<endl;
  }
  return 0;
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define inp 20
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007 
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace __gnu_pbds;
using namespace std;
 
// Errichto ... ;)

void md(ll &a)
{
    a%=mod;
}
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
void sub_self(int& a, int b) {
    a -= b;
    if(a < 0) {
        a += mod;
    }
}

int main()
{
    jaldi

    int n,k;
    cin>>n>>k;
    vector<int> dp(k+1,0);
    dp[0]=1;

    for(int child=1;child<=n;child++)
    {
        int upto;
        cin>>upto;

        vector<ll> tmp(k+2,0);
        for(int ubho=k;ubho>=0;ubho--)
        {
            int toadd=dp[ubho];
            int l=ubho+1;
            int r=ubho+min(upto,k-ubho);
            if(l<=r)
            {
                tmp[l]+=toadd;
                if(tmp[l]>=mod) tmp[l]-=mod;
                tmp[r+1]-=toadd;
                if(tmp[r+1]<0) tmp[r+1]+=mod;
            }
        }
        int ps=0;
        for(int i=0;i<=k;i++)
        {
            ps+=tmp[i];
            ps%=mod;
            dp[i]+=ps;
            dp[i]%=mod;
            // add_self(ps,tmp[i]);
            // add_self(dp[i],ps);
        }
    }
    cout<<dp[k];

    return 0;
}

Measured memory_bytes: 4360
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		String str = sc.nextLine();

		str = str.toUpperCase();

		System.out.println(str);

		//	char[] c = sc.next().toCharArray();
		//
		//	for (int i = 0; i < c.length; i++) {
		//		c[i] -= 'a' - 'A';
		//	}
		//
		//	System.out.println(c);
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 17108
# 解説AC
N = int(input())
A = [int(i) for i in input().split()]

if sum(A) % (N * (N + 1) // 2) == 0:
    # 操作回数
    k = sum(A) // (N * (N + 1) // 2)
else:
    print("NO")
    exit()

sub = []
for i in range(N):
    sub.append(A[i] - A[i-1] - k)

flag,cnt = True,0
for i in range(N):
    # 負 かつ Nの倍数
    if sub[i] <= 0 and sub[i] % N == 0:
        cnt += abs(sub[i]) // N
    else:
        flag = False

if flag and k == cnt:
    print("YES")
else:
    print("NO")

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

int main()
{
    int n,m;
    cin>>n>>m;
    int arr[n];
    int sum=0;
    for(int i=0;i<m;i++){
        cin>>arr[i];
        sum+=arr[i];
    }
    if(sum>n)
    cout<<"-1";
    else 
    cout<<n-sum;
}

Measured memory_bytes: 3636
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll x[n];
  REP(i,n) cin >> x[i];
  ll ans = 0;
  REP(i,n-1){
    ans += min(b,a*(x[i+1]-x[i]));
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  vector<int>num(100001,0);
  int n,a,b,q,def;
  long long ans = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> a;
    num[a]++;
    ans+= a;
  }
  cin >> q;
  for(int i = 0;i < q;i++){
    cin >> a >> b;
    def = b - a;
    ans += def * num[a];
    num[b]+=num[a];
    num[a] = 0;
    cout << ans << endl;
  }
  
}

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

int main() {
    int A,B,C,SUM=0;
  	cin >> A >> B >> C;
  	SUM=A+B+C;
  	if (SUM>=22)
      cout << "bust" << endl;
    else 
      cout << "win" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define  int    long long int
 #define    sp(x)                 setprecision(x)
#define    bp(x)           __builtin_popcount(x)
 #define  ld         long double
 #define  f(i,j,n)            for(int i = j; i <= n; i++)
#define  r(i,n,j)       for(int i = n; i >= j; i--)
 #define  all(container)       container.begin() , container.end()
#define  sz(container)   (int)container.size()
 #define  ff         first
#define  ss    second
 #define  pii      pair <int , int>
#define  sp(x)       setprecision(x)
 #define  endl    "\n"
#define  mod  1000000007
 #define  pb    push_back
#define  mp    make_pair
 #define  T     int ttt; cin >> ttt; while(ttt--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);

int32_t main()
{
    fast
    int n;
    vector<int>v;
    cin>>n;
    while(n>0){
        v.pb(n%26);
        n=(n-1)/26;
    }
    r(i,sz(v)-1,0)
    {
        char c='a'+(v[i]-1+26)%26;
        cout<<c;
    }
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<assert.h>

typedef long long ull;
typedef unsigned long long ll;

#define mod 1000000007LL

int main()
{
    int n;
    ll* a;
    ll sum = 0, b, m;
    scanf("%d", &n);
    a = calloc(n, sizeof(ll));
    for (size_t i = 0; i < n; i++)
    {
        scanf("%lld", a + i);
    }

    b = 1;
    for (size_t i = 0; i < 61; i++)
    {
        m = 0;
        for (size_t j = 0; j < n; j++)
        {
            m += !!(a[j] & b);
        }
        sum += ((((b % mod) * (n - m)) % mod) * m);
        sum %= mod;
        b <<= 1;
    }

    printf("%lld", sum);

    return 0;
}



Measured memory_bytes: 2560
n = gets.to_i
book = Hash.new(0)
n.times do
  s = gets.chomp[/^(M|A|R|C|H)/]
  if !s.nil?
    book[s] += 1
  end
end

res = 0
cnt = "MARCH".chars.map{|c| book[c] }
cnt.combination(3).each do |i, j, k|
  res += i * j * k
end
puts res

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int x,a,b;
    cin>>x>>a>>b;
    b-=a;

    if(b<=0)cout<<"delicious"<<endl;
    else if(b<=x)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif

bool check(const string &s, const string &t)
{
    int N = s.size();
    for (int i = 0; i < N; ++i)
    {
        bool good = true;
        for (int j = 0; j < N; ++j)
        {
            auto c1 = s.at(j);
            auto c2 = t.at((i + j) % N);
            if (c1 != c2)
            {
                good = false;
                break;
            }
        }
        if (good)
            return true;
    }
    return false;
}

int main()
{
    string s, t;
    cin >> s >> t;

    cout << (check(s, t) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    if(a == b) ans += 1;
    if(b == c) ans += 1;
    if(c == a) ans += 1;
    if(ans == 1) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, a, b;

	scanf("%d", &n);

	if (n == 1) {
		printf("Hello World\n");
	}
	else {
		scanf("%d", &a);
		scanf("%d", &b);
		printf("%d\n", a + b);
	}



	return 0;
}

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

const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
int first = 0;
vector<int> pp;

int len(string n){
  int c = n.size();
  rep(i,c){
    pp.push_back(n.at(i)-'0');
  }
  first = pp[0];
  return c;
} 
  
 
int main() {
  int k;
  string n;
  cin >> n >> k;
  int c = len(n);
  vector<vector<vector<ll>>> dp(c,vector<vector<ll>>(4,vector<ll>(2,0)));
  dp.at(0).at(0).at(0) = 0;
  dp.at(0).at(0).at(1) = 1; 
  dp.at(0).at(1).at(0) = 1;
  dp.at(0).at(1).at(1) = first-1;
  for(int i=1;i<c;i++)for(int j=0;j<4;j++)rep(k,2){
    if(j==0 && k==1){
      dp.at(i).at(j).at(k) = 1;continue;
    }else if(j==0 && k==0) {
      dp.at(i).at(j).at(k) = 0;continue;
    }
    if(k==0){
      if(pp.at(i)==0){
        dp.at(i).at(j).at(k) = dp.at(i-1).at(j).at(k);
      }else{
        dp.at(i).at(j).at(k) = dp.at(i-1).at(j-1).at(k);
      }
    }else{
      dp.at(i).at(j).at(k) = dp.at(i-1).at(j).at(k)+dp.at(i-1).at(j-1).at(k)*9;
      if(pp.at(i)!=0){
        dp.at(i).at(j).at(k) += dp.at(i-1).at(j-1).at(k-1)*(pp.at(i)-1) + dp.at(i-1).at(j).at(k-1);
      }
    }
  }
  ll ans = 0;
  if(k==0) cout << ans << endl;
  else{
  rep(j,2){
   ans += dp.at(c-1).at(k).at(j);
  }
  cout << ans << endl;
  } 
  /*rep(i,pp.size()) cout << pp.at(i) << " ";
  rep(i,c){
    rep(j,4){
      rep(k,2) cout << dp.at(i).at(j).at(k) << " ";
    cout << endl;
    }
    cout << endl;
  }*/
    
    
                                 
  return 0;
}



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




int main(){
	
	int n;cin>>n;
	vector<int> swim(n), bugs(n), homework(n);
	for(int i=0;i<n;i++){
		cin>>swim[i]>>bugs[i]>>homework[i];
	}
	
	vector<int> dp(3), temp(3);
	
	for(int i=0;i<n;i++){
		temp = dp;
		temp[0] = swim[i] + max(dp[1],dp[2]);
		temp[1] = bugs[i] + max(dp[0],dp[2]);
		temp[2] = homework[i] + max(dp[1],dp[0]);
		dp = temp;
	}
	cout<<max({dp[0],dp[1],dp[2]});
}

Measured memory_bytes: 1408
/*

*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/hash_policy.hpp>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long 
#define LL long long 
#define ull unsigned long long 
#define rg register 
#define pt(x) printf("%d ", x);
//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1<<22, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 22)], *p1 = buf, *p2 = buf;
//char obuf[1<<24], *O = obuf;
//void print(int x) {if(x > 9) print(x / 10); *O++ = x % 10 + '0';}
//#define OS  *O++ = ' ';
using namespace std;
//using namespace __gnu_pbds;
const int MAXN = 1e6 + 10, INF = 1e9 + 10, mod = 1e9 + 7;
const double eps = 1e-9;
inline int read() {
    char c = getchar(); int x = 0, f = 1;
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
int check(int a, int b, int c) {
	return a * b * c & 1;
}
main() {
	int A = read(), B = read();
	if(check(1, A, B) || check(2, A, B) || check(3, A, B)) puts("Yes");
	else puts("No");




    return 0;
}
/*
2 2 1
1 1
2 1 1
*/

Measured memory_bytes: 256
s=list(input())
o=['R','U','D']
e=['L','U','D']
n=len(s)
count=0
for i in range(n):
    if (1+i)%2==0:
        if s[i] in e:
            count+=1
    else:
        if s[i] in o:
            count+=1
if count==n:
    print('Yes')
else:
    print('No')

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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    ll ans = 0;;
    for(int i=0;i<n;++i){
        cin >> a[i];
        for(int j=0;j<i;++j) {
            ans += a[i] * a[j];
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
H,W,K = map(int, input().split())
s = []
for i in range(H):
    s.append(list(input()))

ans = [[0] * W for i in range(H)]
cnt = 0
flg = True
for i in range(H):
    if '#' in s[i]:
        cnt += 1
        sb = 0
        for j in range(W):
            if s[i][j] == '#':
                sb += 1
                if sb > 1:
                    cnt += 1
            ans[i][j] = cnt
            if flg == False:
                for k in range(i):
                    ans[k][j] = cnt
        flg = True
    else:
        if i == 0 or flg == False:
            flg = False
        else:
            for j in range(W):
                ans[i][j] = ans[i-1][j]
    #print(flg)
for i in range(H):
    print(' '.join(map(str,ans[i])))


Measured memory_bytes: 78268
# D - Coloring Edges on Tree

import sys

sys.setrecursionlimit(10 ** 5)

N = int(input())
G = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append((b, i))
    G[b].append((a, i))

ans = [-1] * (N - 1)

def dfs(key, color=-1, parent=-1):
    k = 1
    for i in range(len(G[key])):
        if G[key][i][0] == parent:
            continue
        if color == k:
            k += 1
        ans[G[key][i][1]] = k
        dfs(G[key][i][0], k, key)
        k += 1

dfs(0)

print(max(ans))
for a in ans:
    print(a)


Measured memory_bytes: 85180
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n,k = readInts()
if k == 1:
    print(0)
else:
    if n >= k:
        print(n-k)


Measured memory_bytes: 10388
/*
 * C.c
 *
 *  Created on: 2020/01/29
 *      Author: 113200
 */

#include <stdio.h>
#include <stdlib.h>

void swap(double* H, int right, int left){
	double tmp;
	tmp = H[right];
	H[right] = H[left];
	H[left] = tmp;
}

void quicksort(double* H, int left, int right){

	int center = H[(left+right)/2];
	int l = left;
	int r = right;

	while (1){
		while (H[l] < center) l++;
		while (H[r] > center) r--;
		if (l >= r) break;
		swap(H,r,l);

		l++;
		r--;
	}

	if (left < l-1) quicksort(H,left,l-1);
	if (right > r+1) quicksort(H,r+1,right);
}

int main(void){

	int N;
	int K;
	double *H;
	double count = 0;

	/* 入力値の格納 */
	scanf("%d %d\n",&N,&K);
	H = (double*)calloc(sizeof(double),N);
	for (int i = 0; i < N; ++i){
		scanf("%lf",&H[i]);
	}

	/* HPの多い順にソート */
	quicksort(H,0,N-1);

	/* 攻撃回数のカウント */
	for (int i = N-1-K; i >= 0; --i){
		count += H[i];
	}

	printf("%.lf\n",count);
	free(H);

	return 0;
}


Measured memory_bytes: 1664
# coding=utf-8
import math


def square(number: float) -> float:
    return number * number


if __name__ == '__main__':
    N = int(input())
    for i in range(N):
        xa, ya, ra, xb, yb, rb = map(float, input().split())
        distance = math.sqrt(square(xb - xa) + square(yb - ya))
        if distance > (ra + rb):
            print(0)
        elif distance >= math.fabs(ra - rb):
            print(1)
        elif distance < math.fabs(ra - rb):
            if ra > rb:
                print(2)
            elif ra < rb:
                print(-2)
        else:
            pass

Measured memory_bytes: 5668
#include<stdio.h>
int N;
long data[] = {[0 ... 1<<19] 0};
void fen_add(int p, long x){
	p++;
	while(p <= N){
		data[p-1] += x;
		p += p & -p;
	}
}
long fen_sum(int r){
	long s = 0;
	while(r > 0){
		s += data[r-1];
		r -= r & -r;
	}
	return s;
}
long fen_range(int l, int r){
	return fen_sum(r) - fen_sum(l);
}

int Q;
int main(){
	scanf("%d%d", &N, &Q);
	for(int i=0; i<N; i++){
		int a;
		scanf("%d", &a);
		fen_add(i, a);
	}
	while(Q--){
		int t, x, y;
		scanf("%d%d%d", &t, &x, &y);
		if(t) printf("%ld\n", fen_range(x, y));
		else fen_add(x, y);
	}
	return 0;
}

Measured memory_bytes: 8100
#include <bits/stdc++.h>
using namespace std;
map <long long, long long> used;
int main () {   
  long long n;
  cin >> n;
  used[0] = 1;
  long long asd = 0;
  long long ans = 0;
  for (long long i = 1;i <= n;i ++) {
 	long long x;
 	cin >> x;
 	asd += x;
	ans += used[asd];
	used[asd] ++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int MAX = 1000100;
bool prime[MAX];

void sieve(){
    fill(prime, prime+MAX, true);
    prime[0] = prime[1] = false;

    for(int i=0; i < MAX; i++){
	        if(!prime[i]) continue;
	        for(int j=i+i; j < MAX; j += i){
			            prime[j] = false;
			        }
	    }
}


int main(){
	int a, d, n;
	sieve();
	while(cin >> a >> d >> n, a+d+n){
		int count = 0;
		while(true){
			if(prime[a]) n--;
			if(n == 0) break;
			a+=d;
		}
		cout << a << endl;
	}
}

Measured memory_bytes: 2136
// Problem : Mix Juice
// Contest : Virtual Judge - AtCoder
// URL : https://vjudge.net/problem/AtCoder-abc171_b
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testcases \
    int tcc;      \
    cin >> tcc;   \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    fast_io;
    int n,k; cin>>n>>k;
    vi v(n); in(v); sort(all(v));
    ll sum=0;
    lp(i,0,k)
    	sum+=v[i];
    cout<<sum;
}

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

int main() {
  int mod = 1e9 + 7;
  int N, M;
  cin >> N >> M;

  vector<int> aa(M);
  for (int k = 0; k < M; k++) {
    cin >> aa[k];
  }

  vector<int> ans(N+1);
  ans[0] = 1;

  for (int k = 1, l = 0; k <= N; k++) {
    if (l < M and aa[l] == k) { l++; continue; }
    if (k == 1) {
      ans[k] = ans[k-1];
    }
    else {
      ans[k] = ans[k-2] + ans[k-1]; 
    }
    ans[k] %= mod;
  }
  cout << ans[N] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,total;
  vector<int> d(101);
  
  for (int i=0;i<101;i++){
    d.at(i)=-1;
  }
    
  cin >> N;
  for (int i=0; i<N;i++){
   cin >> d.at(i);
  }
  
  total=0;
  
  for (int i=0;i<N;i++){
    for (int ii=0;ii<N;ii++){
      if(i==ii){
      }else{
        total=d.at(i)*d.at(ii)+total;
      }
    }
  }

  cout << total/2 << endl;

}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7

template<typename T>
string printVector(const vector <T> &data) {
    stringstream ss;
    ostream_iterator <T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n, x, y;
    cin >> n;
    vector<int> ord;
    for (int i = 0; i < n; ++i) { ord.push_back(i); }
    vector <tuple<int, int>> positions;
    for (int i = 0; i < n; ++i) {
        cin >> x >> y;
        positions.push_back(make_tuple(x, y));
    }
    ld ans = 0, cnt = 1;
    for (int i = 1; i <= n; ++i) {
        cnt *= i;
    }
    do {
        ld tmp = 0;
        for (int i = 0; i < n - 1; ++i) {
            tmp += sqrt(pow((get<0>(positions[ord[i]]) - get<0>(positions[ord[i + 1]])), 2) +
                        pow((get<1>(positions[ord[i]]) - get<1>(positions[ord[i + 1]])), 2));
        }
        ans += tmp;
    } while (next_permutation(ALL(ord)));
    cout << ans / cnt << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
V = list(map(int,input().split()))
ans = 0
R = min(N,K)
for A in range(R+1):
    for B in range(R-A+1):
        s = V[:A]+V[N-B:]
        #print(s)
        s.sort()
        S = sum(s)
        for k in range(min(K-A-B,len(s))):
            if s[k] < 0:
                S -= s[k]
        ans = max(ans,S)
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		int ans=selectionSort(a,n);
		write(a,n);
		System.out.println(ans);
	}
	static void write(int[] a,int n){
		for(int i=0;i<n-1;i++){
			System.out.print(a[i]+" ");
		}
		System.out.println(a[n-1]);
	}
	static int selectionSort(int[] a, int n){
		int minj;
		int count=0;
		for(int i=0;i<n;i++){
			minj=i;
			for(int j=i;j<n;j++){
				if(a[j]<a[minj]){
					minj=j;
				}
			}
			if(minj!=i) count++;
			int temp=a[i];
			a[i]=a[minj];
			a[minj]=temp;
		}
		return count;
	}

}

Measured memory_bytes: 26272
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
int h, w, n;
int x, y;
char s[maxn], t[maxn];

bool solve1() {
    int L = 1, R = h;
    for (int i=n; i>=1; --i) {
        if(t[i] == 'U') R = min(h, R+1); else if(t[i] == 'D') L = max(1, L-1);
        if(s[i] == 'U') ++L; else if(s[i] == 'D') --R;
        if(L>R) return 1;
    } return x<L || x>R;
}

bool solve2() {
    int L = 1, R = w;
    for (int i=n; i>=1; --i) {
        if(t[i] == 'L') R = min(w, R+1); else if(t[i] == 'R') L = max(1, L-1);
        if(s[i] == 'L') ++L; else if(s[i] == 'R') --R;
        if(L>R) return 1;
    } return y<L || y>R;
}

int main() {
    scanf("%d%d%d", &h, &w, &n);
    scanf("%d%d", &x, &y);
    scanf("%s%s", s+1, t+1);
    puts((solve1()||solve2())? "NO": "YES");
    return 0;
}


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

using namespace std;

int main(void) {
	int n, h, w;
	cin >> n >> h >> w;
	vector<int>a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= h && b[i] >= w) {
			count++;
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
    int n;cin >> n;
    int ans;
    if(n==1)ans=1;
    else if(n<4)ans=2;
    else if(n<8)ans=4;
    else if(n<16)ans=8;
    else if(n<32)ans=16;
    else if(n<64)ans=32;
    else if(n<128)ans=64;
    printf("%d\n",ans);
}

Measured memory_bytes: 256
x,y=map(int,input().split())

if y<0<x or x<0<y:
    print(abs(abs(y)-abs(x))+1)
elif x<y and x!=0:
    print(y-x)
elif y<x and x!=0 and y!=0:
    print(x-y+2)
elif x<y and x==0:
    print(y-x)
elif y<x and x==0 or y==0:
    print(x-y+1)


Measured memory_bytes: 9076
import math
N = int(input())
l = -1
r = N+100
while r - l > 1:
    m = l + (r - l)//2

    if math.floor(1.08 * m) >= N:
        r = m
    else:
        l = m
print(r if math.floor(1.08 * r) == N else ':(')


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

int main()
{
    long long n,c=0,sum,n1;
    cin>>n;
    sum=n/500;
    n1=n%500;
    c+=sum;

    int y=c;
    int x=c*1000;
    if(n1!=0)
    {
        sum=n1/5;
        n1=n1%5;
        c+=sum;
    }

    int z=(c-y)*5;


    cout<<x+z<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,j,n,m,sum;
  
  int a[100][100],b[100],c[100];
  scanf("%d %d",&n,&m);
 
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      scanf("%d",&a[i][j]);
 
  for(i=0;i<m;i++)
    scanf("%d",&c[i]);

  for(i=0;i<n;i++){
     for(j=0;j<m;j++)
      sum+=a[i][j]*c[j];
       printf("%d\n",sum);
       sum=0;
  }
  return 0;
}



Measured memory_bytes: 2104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.OptionalInt;
import java.util.regex.Pattern;
import java.util.stream.Stream;

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

    new Main().run();
  }

  public void run() {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String line = br.readLine();
      final Pattern delim = Pattern.compile("\\s");
      int[] arrayS = delim
        .splitAsStream(line)
        .mapToInt(Integer::parseInt)
        .toArray();

      OptionalInt max =
        Arrays.stream(arrayS).max();

      dispIntArray( countingSort(arrayS, max.getAsInt()) );
    }
    catch ( IOException e ) {
      System.out.println("IOException!");
    }

  }

  public int[] countingSort(int[] a, int k) {

    int   aLength = a.length;
    int[] result  = new int[aLength];
    int[] counter = new int[k+1];

    for (int var : a) {
      counter[var]++;
    }

    for (int i=1, max=k+1; i < max; i++) {
      counter[i] += counter[i-1];
    }

    for (int i=aLength-1, val=0; i>=0; i--) {
      val = a[i];
      result[counter[val]-1] = val;
      counter[val]--;
    }

    return result;
  }

  public void dispIntArray(int[] target) {
    StringBuilder s = new StringBuilder();

    for (int i : target) { s.append(i).append(" "); }
    s.setLength(s.length()-1);

    System.out.println(s);
  }
}


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

int main(){
    int N;
    string S, T;
    std::cin >> N;
    vector<char> ans(2 * N);
    char c;
    for(int i = 0; i < N; i++){
        std::cin >> c;
        ans[0 + i * 2] = c;
    }

    for(int i = 0; i < N; i++){
        std::cin >> c;
        ans[1 + i * 2] = c;
    }

    for(int i = 0; i < ans.size(); i++){
        std::cout << ans[i];
    }

}

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

/*
a[1]以上の全ての値について, a[i]*a[0..i-1]の累積和を求め, それらを足すと答えが出る.
詳しくは解説動画参照.
このとき, 計算過程で出た値や最終値がとても大きい場合があるので, mod10e9+7で小さくする.
ちなみに, 足し算, 引き算, 掛け算においては全ての計算が終わった後にあまりをとっても,
途中過程で逐一あまりをとっても最終的な値は変わらない.
例えば(a*b*c)%dと((a*b)%d)*cは同じ値を出力する.ただし引き算は要注意.
詳しくはdrkenさんの記事参照.
*/

const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  int ans = 0;
  int x = 0;
  rep(i, n) {
    ans = (ans + ((ll)a[i] * x)) % mod;
    x = (x + a[i]) % mod;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3964
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    if(str.charAt(0)==str.charAt(2)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21716