akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, m, k;
    cin >> n >> m >> k;

    vector<int> a(n), b(m);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int j = 0; j < m; j++) {
        cin >> b[j];
    }

    int s = 0, l = 0;
    int i0 = n;
    for (int i = 0; i < n; i++) {
        s += a[i];
        l++;
        if (s > k) {
            i0 = i;
            s -= a[i];
            l--;
            break;
        }
    }

    int r = l, j = 0;
    for (int i = i0 - 1;;) {
        while (j < m && s + b[j] <= k) s += b[j++], l++;
        r = max(r, l);
        if (i < 0) break;
        s -= a[i--];
        l--;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 4784
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
string s;
cin>>s;
int n=s.size();
for(int i=0;i<s.size();i++)
{
	if(s[i]=='?')
	{
		s[i]='D';
		
	}
}
cout<<s;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    int a[n];
    map<int,int> mp;
    set<int> st;
    rep(i,0,n){
        cin>>a[i];
        st.insert(a[i]);
        mp[a[i]]++;
    }
    int cnt[3];
    fill(cnt,cnt+3,0);
    for(auto itr=st.begin();itr!=st.end();itr++){
        int u=*itr;
        int y=mp[u];
        if(y%2==0)y=2;
        else y=1;
        cnt[y]++;
    }
    int ans=cnt[1]+cnt[2];
    if(cnt[2]%2==1)ans--;
    cout<<ans<<endl;
}


Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <map>
#include <deque>
#include <queue>
#include <set>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>8||b>8) cout<<":("<<endl;
	else cout<<"Yay!"<<endl; 
	return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
N, M = map(int,input().split())
lists = []
num = 0
amount = 0

for i in range(N):
    lists.append(list(map(int, input().split())))

lists = sorted(lists, key=itemgetter(0))

for i in range(N):
    if num + lists[i][1] < M:
        num = num + lists[i][1]
        amount = amount + lists[i][0]*lists[i][1]
    else:
        balance = M - num
        amount = amount + lists[i][0] * balance
        break

print(amount)

Measured memory_bytes: 29868
#include <vector>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <map>
#include <complex>
#include <ctime>
#include <numeric>
#include <set>
 
using namespace std;
 
typedef long long ll;
 
typedef struct node{
    int s, e, val, pos;
    bool operator<(const node& n) const{
        if(e != n.e) return e < n.e;
        return val > n.val;
    }
    node(){};
    node(int ss, int ee, int v, int p){
        s = ss, e = ee, val = v, pos = p;
    }
}node;
 
int occs[(int)1e6 + 5], tree[500005], n, ans[500005];
 
void update(int x, int val){
    while(x <= n){
        tree[x] += val;
        x += x & -x;
    }
}
 
int query(int x){
    int ret = 0;
    while(x > 0){
        ret += tree[x];
        x -= x & -x;
    }
    return ret;
}
 
int main()
{
	
    int q, s, e;
    vector<node> v;
    scanf("%d", &n);
    scanf("%d", &q);
    for(int i = 1; i <= n; i++){
        scanf("%d", &s);
        v.push_back(node(i, i, s, -1));
    }
    for(int i = 0; i < q; i++){
        scanf("%d %d", &s, &e);
        v.push_back(node(s, e, 0, i));
    }
 
    sort(v.begin(), v.end());
 
    for(int i = 0;i < v.size(); i++){
        if(v[i].val == 0){
            ans[v[i].pos] = query(v[i].e) - query(v[i].s - 1);
        }else{
            if(occs[v[i].val] != 0) update(occs[v[i].val], -1);
            update(v[i].s, 1);
            occs[v[i].val] = v[i].s;
        }
    }
 
    for(int i = 0; i < q; i++){
        printf("%d\n", ans[i]);
    }
 
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int gatos, animais, posgatos;
    cin >> gatos >> animais >> posgatos;
    if (gatos > posgatos)
    {
        cout << "NO" << endl;
    }
    else if (gatos + animais < posgatos)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
count = 0
colors = [False]*8
for a in A:
    q, r = divmod(a, 400)
    if q < 8:
        colors[q] = True
    else:
        count += 1
ans = sum(colors)
if ans > 0:
    print(ans, ans + count)
else:
    print(1, ans + count)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000003;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int N;
double dp[310][310][310];
double act(int i,int j,int k){
    if (dp[i][j][k]>=0.0) return dp[i][j][k];
    if (i+j+k==0) return 0.0;
    double res=N;
    if (i>0) res+=act(i-1,j,k)*i;
    if (j>0) res+=act(i+1,j-1,k)*j;
    if (k>0) res+=act(i,j+1,k-1)*k;
    res/=i+j+k;
    return dp[i][j][k]=res;
}

int main(){
    cin >> N;
    vector<int> cnt(3);
    rep(i,N){
        int a;
        cin >> a;
        cnt[--a]++;
    }
    rep(i,N+1){
        rep(j,N+1){
            rep(k,N+1){
                dp[i][j][k]=-1.0;
            }
        }
    }
    cout << fixed << setprecision(10) << act(cnt[0],cnt[1],cnt[2]) << endl;
}

Measured memory_bytes: 227584
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(in);
	int n=sc.nextInt();
	int k=sc.nextInt();
	String[] d=new String[k];
	for(int i=0;i<k;i++){
	    d[i]=sc.next();
	}
	int ans=n;
	int c=0;
	while(c!=k){
	    String ansstr=Integer.toString(ans);
	    for(int i=0;i<k;i++){
		if(!ansstr.contains(d[i]))c++;
	    }
	    if(c!=k){
		c=0;
		ans++;
	    }
	}
	out.println(ans);
    }
}


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

// A
int main() {
    int K, X;
    cin >> K >> X;

    if (500 * K >= X) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;


void solve() {
    int N, M; cin >> N >> M;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A.begin(), A.end(), greater<int>());

    int sum = accumulate(A.begin(), A.end(), 0);

    if (double(A[M - 1]) < sum / double((4*M))) cout << "No" << endl;
    else cout << "Yes" << endl;
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3632
///////////////////////////////////
//            ___				 //
//      _..--"\  `|`""--.._		 //
//   .-'       \  |        `'-.  //
//  /           \_|___...----'`\ //
// |__,,..--""``(_)--..__      | //
// '\     _.--'`.I._     ''--..' //
//   `''"`,#JGS/_|_\###,---'`    //
//     ,#'  _.:`___`:-._ '#,     //
//    #'  ,~'-;(oIo);-'~, '#     //
//    #   `~-(  |    )=~`  #     //
//    #       | |_  |      #     //
//    #       ; ._. ;      #     //
//    #  _..-;|\ - /|;-._  #     //
//    #-'   /_ \\_// _\  '-#     //
//  /`#    ; /__\-'__\;    #`\   //
// ;  #\.--|  |O  O   |'-./#  ;  //
// |__#/   \ _;O__O___/   \#__|  //
//  | #\    [I_[_]__I]    /# |   //
//  \_(#   /  |O  O   \   #)_/   //
//        /   |        \         //
//       /    |         \        //
//      /    /\          \       //
//     /     | `\         ;      //
//    ;      \   '.       |      //
//     \-._.__\     \_..-'/      //
//      '.\  \-.._.-/  /'`       //
//         \_.\    /._/          //
//          \_.;  ;._/           //
//        .-'-./  \.-'-.         //
//       (___.'    '.___)        //
///////////////////////////////////
#include <bits/stdc++.h>
using namespace std;

#define all(x) begin(x), end(x)
#define cina(s, n, a) for(int quer = s; quer < n; quer++) cin >> a[quer]
#define mod(a, b) (abs(b) + (a % abs(b))) % abs(b)
#define setp(x) fixed << setprecision(x)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
ll MOD = 1e9 + 7;
void mul(ll &x, ll y){
	x *= y;
	if(x >= MOD) x %= MOD;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= MOD) x -= MOD;
	if(x < 0) x += MOD;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
/////////////////////////////////////////////////////////////////////////////////////
void solve(){
	int n, m;
	cin >> n >> m;
	vi a(n);
	cina(0, n, a);
	int sum = 0;
	for(int i = 0; i < n; i++) sum += a[i];
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if((double)a[i] >= sum / (4.0 * m)) cnt++;
	}	
	cout << (cnt >= m ? "Yes" : "No");
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
		//cout << "Case #" << i << ": ";
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	ll n, x;
	cin >> n >> x;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> b(n - 1);
	rep(i, n - 1)b[i] = a[i] + a[i + 1];
	ll ans = 0;
	if (a[0]>x)
	{
		ans += a[0] - x;
		b[0] -= a[0] - x;
	}
	rep(i, n - 1)
	{
		if (b[i] > x)
		{
			if (i < n - 2)
			{
				ll diff = b[i] - x;
				b[i] -= diff;
				b[i + 1] -= diff;
				ans += diff;
			}
			else
			{
				ll diff = b[i] - x;
				ans += diff;
			}
		}
	}
	co(ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define mod 1000000007
#define endl ("\n")
#define pi (3.141592653589)
#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,a,n) for(int i=(a);i<n;i++)
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0);
int t=1;
//cin>>t;
while(t--){
        ll n,k,d;
        cin>>n>>k>>d;
        n=abs(n);
        ll mi=n/d;
        if(n>0&&mi>=k)//If the number of moves that can be made is greater then or equal to k then we will do that directly.
        {
            cout<<abs(n-(d*k));//We moved all possible moves.
        }
        else
        {
            n=n-mi*d;//Number of moves that will be moved initially.
            k=k-mi;//Number of moves that will be reduced.

            if(k%2==0)
            {
                cout<<abs(n);
            }
            else
            {
                cout<<abs(min((n-d),(n+d)));
            }
        }
}
}




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

const int highest=100;

int gerden[11][11];

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

        int ans=0;
        for(int i=3; i<=d; i++){
            for(int j=3; j<=w; j++){    // 縦i横jの池候補
                for(int k=0; k<=d-i; k++){
                    for(int l=0; l<=w-j; l++){   // 池候補を縦横に動かす

                        int min_out=100, max_in=-1, capacity=0;
                        for(int m=k; m<i+k; m++){
                            for(int n=l; n<j+l; n++){   // 池かどうかを調べる(ついでに容量)
                                if(m==k || n==l || m==k+i-1 || n==l+j-1){
                                    if(gerden[m][n]<min_out){
                                        min_out = gerden[m][n];
                                    }
                                }else{
                                    capacity += highest - gerden[m][n];
                                    if(gerden[m][n]>max_in){
                                        max_in = gerden[m][n];
                                    }
                                }
                            }
                        }
                        if(max_in < min_out){
                            if(capacity-((100-min_out)*(i-2)*(j-2)) > ans ){
                                ans = capacity - ((100-min_out)*(i-2)*(j-2));
                            }
                        }

                    }
                }
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
priority_queue<P, vector<P>, greater<P>> que;
vector<vector<int>> v;
vector<P> pv;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> m;
  v.reserve(n + 1);

  REP(i, m) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    pv.push_back(make_pair(a, b));
  }

  FOR(i, 1, n + 1) {
    if(v[i].size() > 0) {
      sort(v[i].begin(), v[i].end());
    }
  }

  REP(i, m) {
    P p = pv[i];
    auto pp = lower_bound(v[p.first].begin(), v[p.first].end(), p.second);
    cout << setw(6) << setfill('0') << p.first;
    cout << setw(6) << setfill('0') << (pp - v[p.first].begin() + 1) << endl;
  }
}


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

int main() {
	string s;
	cin >> s;
	int texta, textb, textc;
	texta = textb = textc = 0;
	for (int i = 0; i <= 2; i++) {
		if (s[i] == 'a') {
			texta = 1;
		}
		if (s[i] == 'b') {
			textb = 1;
		}
		if (s[i] == 'c') {
			textc = 1;
		}
	}

	if (texta == 1&& textb == 1&& textc == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
	system("pause");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    char c; cin >>c;
    cout << (char)(c+1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <cassert>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    string S;
    cin >> S;
    bool flag=false;
    for (int i=1;i<S.length();i++){
        if(S[i]==S[i-1]){
            flag = true;
        }
    }
    if (flag){
        cout << "Bad";
    }
    else cout << "Good";
}

Measured memory_bytes: 256
N, A, B, K = map(int, input().split())

C = [0] * (3 * 10 ** 5 + 5)
rC = [0] * (3 * 10 ** 5 + 5)
MOD = 998244353

C[0] = 1
rC[0] = 1
C[1] = 1
rC[1] = 1
for i in range(2, N + 1):
    C[i] = C[i - 1] * i % MOD

rC[N] = pow(C[N], MOD - 2, MOD)

for i in range(N, 1, -1):
    rC[i - 1] = rC[i] * i % MOD


def calc(n, m):
    return C[n] * rC[n - m] * rC[m] % MOD

num = 0
for i in range(N + 1):
    if (K - A * i) % B == 0:
        j = (K - i * A) // B
        if 0 <= j <= N:
            num += calc(N, i) * calc(N, j)
            num = num % MOD

if K == 0:
    print(1)
else:
    print(num % MOD)


Measured memory_bytes: 46188
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n = nxt(), k = nxt();
    VI a(n);
    REP(i, n) a[i] = nxt();
    sort(all(a));
    ll c = 0;
    REP(i, n-k) c += a[i];
    cout << c;
    return 0;
}



Measured memory_bytes: 1152
let lim = 330
let () =
  Scanf.scanf "%d %d" @@ fun n ww ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun x y -> x, y)) in
  let w0 = fst a.(0) in

  let dp = Array.make_matrix lim (n+1) 0 in
  a |> Array.iter (fun (w, v) ->
    let w = w - w0 in
    for i = lim-1 downto w do
      for j = n downto 1 do
        if i + j * w0 <= ww then
          dp.(i).(j) <- max dp.(i).(j) (dp.(i-w).(j-1) + v)
    done done);

  Array.fold_left (Array.fold_left max) 0 dp
  |> Printf.printf "%d\n"

Measured memory_bytes: 2432
#include <iostream>
#include <sstream>
#include <string>
#define SIZE 200
using namespace std;

bool isNum(string s) {
  try {
    int n;
    n = stoi(s);
  } catch (...) {
    return false;
  }
  return true;
}

class Stack {
  int *p;
  int top;

public:
  Stack() {
    top = 0;
    p = new int[SIZE];
  };
  ~Stack() { delete[] p; };
  void push(int n) { p[++top] = n; }
  int pop() { return p[top--]; };
  bool isFull() { return top == SIZE - 1; };
  bool isEmpty() { return top == 0; };
};

int main() {
  string s, tmp;
  Stack stk;
  getline(cin, s);
  stringstream ss(s);
  while (ss >> tmp) {
    if (!isNum(tmp)) {
      switch (tmp[0]) {
        int t1, t2;
      case '+':
        t2 = stk.pop();
        t1 = stk.pop();
        stk.push(t1 + t2);
        break;
      case '-':
        t2 = stk.pop();
        t1 = stk.pop();
        stk.push(t1 - t2);
        break;
      case '*':
        t2 = stk.pop();
        t1 = stk.pop();
        stk.push(t1 * t2);
        break;
      }
    } else {
      stk.push(stoi(tmp));
    }
  }
  cout << stk.pop() << endl;

  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int dif = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      dif += a.at(i);
    } else {
      dif -= a.at(i);
    }
  }
  cout << dif;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1 << 30;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

lint log_mul(lint base, lint bit) {
    lint res = 0;

    while (bit) {
        if (bit & 1) res = (res + base) % MOD;
        base = (base + base) % MOD;
        bit >>= 1;
    }

    return res;
}

int main() {
    lint n, k;
    cin >> n >> k;

    lint res = 0;

    COMinit();
    for (int i = 0; i <= min(k, n-1); i++) {
        res += log_mul(COM(n, i), COM(n-1, n-i-1));
        res %= MOD;
    }

    if (res < 0) res += MOD;
    res %= MOD;

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


Measured memory_bytes: 12160
def maxStack(k, p, W):
    nw = 0
    count = 0
    t = 1
    for x in W:
        if x > p:
            return count
        if nw + x <= p:
            nw += x
            count += 1
        else:
            if t == k:
                return count
            else:
                t += 1
                nw = x
                count += 1
    return count


n, k = map(int, raw_input().split())
W = [int(raw_input()) for i in xrange(n)]

left = 1
right = sum(W)
while left < right:
    mid = (left + right) / 2
    v = maxStack(k, mid, W)
    if v >= n:
        right = mid
    else:
        left = mid + 1
print left

Measured memory_bytes: 7336
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

int main() {
  int h, w;
  cin >> h >> w;
  vector<vi> map(h + 2, vi(w + 2, -2));
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    if(c == '.') map[i + 1][j + 1] = -1;
  }
  int ans = 0;
  vector<vi> backup = map;
  rep2(ri, 1, h + 1) rep2(rj, 1, w + 1) {
    if(map[ri][rj] == -2) continue;
    queue<pair<int, int>> q;
    q.push(make_pair(ri, rj));
    map = backup;
    map[ri][rj] = 0;
    vi di = {-1, 0, 0, 1};
    vi dj = {0, -1, 1, 0};
    int m = 0;
    while(!q.empty()) {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      rep(k, 4) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if(map[ni][nj] == -1) {
          q.push(make_pair(ni, nj));
          map[ni][nj] = map[i][j] + 1;
          m = max(m, map[ni][nj]);
        }
      }
    }
    ans = max(ans, m);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  set<int> md;
  int n = 0;
  for (int i=0; i<B; i++) {
    md.insert( A*i % B ); 
  }
  
  if (md.count(C)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

N,S, *A = map(int, sys.stdin.buffer.read().split())
mod = 998244353

answer = [0 for _ in range(S+1)]
power2 = 1

for a in A:
  answer_next = [(2*b)%mod for b in answer]
  if a<=S:
    answer_next[a] = (answer_next[a]+power2)%mod
    for i in range(a+1,S+1):
      answer_next[i] = (answer_next[i]+answer[i-a])%mod
  answer = answer_next
  power2 = (2*power2)%mod

print(answer[S])

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

#ifdef __WIN32
#define LLFORMAT "I64"
#else
#define LLFORMAT "ll"
#endif

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int H, W, n;
	cin >> H >> W >> n;
	vector<vector<int> > all(W + 1);
	for (int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		all[y].push_back(x);
	}
	for (int i = 1; i <= W; ++i) sort(all[i].begin(), all[i].end()), all[i].push_back(H + 1);
	int x = 1, y = 1, ans = H;
	for (int round = 1; ; ++round) {
		++x;
		int i = lower_bound(all[y].begin(), all[y].end(), x) - all[y].begin();
		ans = min(ans, round + all[y][i] - x);
		if(all[y][i] == x) break;
		if(y < W) {
			++y;
			i = lower_bound(all[y].begin(), all[y].end(), x) - all[y].begin();
			if(all[y][i] == x) --y;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) {
    cin >> a[i];
  }

  ll ans = a[0] - 1;
  a[0] = 1;

  ll p = 2;
  REP(i, n) {
    if (a[i] == p) {
      p += 1;
    }
    ll q = (a[i] - 1) / p;
    ans += q;
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
    int n, k, q, tmp;
    cin >> n >> k >> q;

    vector<ll> a(n, k - q);

    for(int i = 0; i < q; ++i)
    {
        cin >> tmp;
        a[tmp - 1]++;
    }

    for(int i = 0;  i < n; ++i)
        cout << (a[i] > 0 ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 4040
fn main() {
    let mut s = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    while let (Some(x), Some(y)) = (iter.next(), iter.next()) {
        let x = x.parse::<usize>().expect("something wrong");
        let y = y.parse::<usize>().expect("something wrong");
        if x == 0 && y == 0 {
            break;
        }
        println!("{} {}", min(x, y), max(x, y));
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 5032
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __
.' ____ \ [  |      (_)                [  |
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |,
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/

*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

class SegmentTree {
private:
  int n;
  vi dat;

public:
  SegmentTree(int n) {
    this->n = 1;
    while (this->n < n) this->n *= 2;
    dat = vi(2 * this->n - 1, INT_MAX);
  }

  void update(int idx, int x)
  {
    idx = n + idx - 1;
    dat[idx] = x;

    while (idx > 0) {
      idx = (idx - 1) / 2;
      dat[idx] = min(dat[idx * 2 + 1], dat[idx * 2 + 2]);
    }
  }

  int query(int a, int b, int idx = 0, int l = 0, int r = INT_MIN)
  {
    if (r == INT_MIN) r = n;
    if (a >= r || l >= b) return INT_MAX;
    if (a <= l && r <= b) return dat[idx];

    int c = query(a, b, idx * 2 + 1, l, (l + r) / 2);
    int d = query(a, b, idx * 2 + 2, (l + r) / 2, r);
    return min(c, d);
  }
};

signed main()
{
  int n = in(), q = in();
  SegmentTree seg(n);
  REP(i, q) {
    int c = in(), x = in(), y = in();
    if (c == 0) {
      seg.update(x, y);
    } else {
      // ????????????
      print(seg.query(x, y + 1));
    }
  }

  return 0;
}

Measured memory_bytes: 3896
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto A = new long[][](3);
    foreach (i; 0 .. 3)
        A[i] = aryread();
    long N = lread();
    auto B = new bool[][](3, 3);
    foreach (_; 0 .. N)
    {
        long b = lread();
        foreach (i; 0 .. 3)
            foreach (j; 0 .. 3)
                if (A[i][j] == b)
                {
                    B[i][j] = true;
                }
    }
    bool a = B[0][0] && B[0][1] && B[0][2];
    bool b = B[1][0] && B[1][1] && B[1][2];
    bool c = B[2][0] && B[2][1] && B[2][2];
    bool d = B[0][0] && B[1][0] && B[2][0];
    bool e = B[0][1] && B[1][1] && B[2][1];
    bool f = B[0][2] && B[1][2] && B[2][2];
    bool g = B[0][0] && B[1][1] && B[2][2];
    bool h = B[0][2] && B[1][1] && B[2][0];
    if (a || b || c || d || e || f || g || h)
    {
        writeln("Yes");
    }
    else
    {
        writeln("No");
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> v(n);
  rep(i,n)cin>>v[i];
  sort(v.begin(),v.end());
  double res=v[0];
  rep1(i,n-1){
      res=(res+(double)v[i])/2.0;
  }
  cout<<res<<"\n";
  
  return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
ll h[100010];
bool ok[100010];
int main()
{
	int n,m;
	cin>>n>>m;
	for( int i=1; i<=n; i++ )
	{
		ll tmp;
		cin>>tmp;
		h[i] = tmp;
		ok[i]=true;
	}
	for(int i=0; i<m; i++)
	{
		ll a,b;
		cin>>a>>b;
		if( h[a]>h[b] )
			ok[b]=false;
		else if( h[b] > h[a] )
			ok[a]=false;
		else
			ok[a]=false,ok[b]=false;
	}
	int sum=0;
	for( int i=1; i<=n; i++ )
	{
		if(ok[i]) sum++;
	}
	cout << sum << endl;
	return 0;
}



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

void solve() {
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; i++) {
        if(a[i] >= b[n/2]) {
            cout << b[-1 + n/2] << "\n";
        }
        else {
            cout << b[n/2] << "\n";
        }
    }
}

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


Measured memory_bytes: 4756
using System;

namespace OJcsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] ans = new double[10000];
            int count = 0;
            do
            {
                ans[count] = 0;
                int siai = int.Parse(Console.ReadLine());
                if (siai == 0)
                    break;
                int []de=new int[siai];
                de[0] = int.Parse(Console.ReadLine());
                int saikou = de[0], saitei = de[0];
                for (int n = 1; n < siai; n++)
                {
                    de[n] = int.Parse(Console.ReadLine());
                    if (de[n] > saikou)
                        saikou = de[n];
                    if (de[n] < saitei)
                        saitei = de[n];
                }
                for (int n = 0; n < siai; n++)
                {
                    ans[count] += de[n];
                }
                ans[count] = Math.Floor((ans[count] - saikou - saitei) / (siai - 2));
                count++;
            } while (true);
            for (int n = 0; n < count; n++)
            {
                Console.WriteLine(ans[n]);
            }
        }
    }
}

Measured memory_bytes: 5764
N = gets.to_i
sqn = Math.sqrt(N)

counter = Hash.new(0)

1.upto(sqn) do |x|
  1.upto(sqn) do |y|
    1.upto(sqn) do |z|
      n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x

      counter[n] += 1
    end
  end
end

puts (1..N).map { |n| counter[n] }


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

int main(){
  int64_t A,B;
  cin >> A >> B;
  int64_t x=A+B;
  if(x%2==0){
    cout << x/2 << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int h,m1,m2,m3,w;
	m1=0;
	m2=0;
	m3=0;
	for(int i=0;i<10;i++){
		scanf("%d",&h);
		if(m3<h){
			m3=h;
			if(m2<m3){
				w=m2;
				m2=m3;
				m3=w;
				if(m1<m2){
					w=m1;
					m1=m2;
					m2=w;
				}
			}
		}
	}
	printf("%d\n%d\n%d\n",m1,m2,m3);
	return 0;
}


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

const ll INF = 1LL << 60;

ll N;
int main() {
    cin >> N;

    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 15 == 0) continue;
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

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

int main()
{
  int n,m;
  cin>>n>>m;
  vector<int> a(m);
  int sum=0;
  for(int i=0;i<m;i++)
  {
    cin>>a.at(i);
    sum+=a.at(i);
  }
  if(n>=sum)
    cout<<n-sum<<endl;
  else
    cout<<-1<<endl;
}
  
  

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int MAX_N = 100000;
const int INF   = 1e9;



int n;
int a[MAX_N + 10];


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

    int ans = 0;
    int i   = 1;
    while (1) {
        while (1) {
            // 途中でa[i]=0になったら区切る
            if (a[i] == 0 || i > n) { break; }

            if (a[i] % 2 == 0) {
                ans += a[i] / 2;
                a[i] = 0;
                break;
            }
            else {
                ans += a[i] / 2;
                a[i] = 1;
            }


            if (a[i + 1] - a[i] >= 0) {
                a[i + 1] -= a[i];
                ans      += a[i];
            }
            else {
                ans     += a[i + 1];
                a[i]    -= a[i + 1];
                a[i + 1] = 0;
            }
            i++;
        }
        i++;
        if (i > n) { break; }
    }
    cout << ans << endl;

    return 0;
}


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

typedef long long int ll;

int main(){
	int n;
	cin >> n;
   	vector<int> A(n, 0);
   	vector < vector<ll> > cost(n, vector<ll> (n, 0));
   	vector< ll > presum(n+1, 0);
   	for(int i = 0; i < n; i++){
		cin >> A[i];
		cost[i][i] = 0;
		presum[i+1] = presum[i] + A[i];
	}
   
   	ll mini;
   	for(int k = 1; k < n; k++){
		for(int i = 0; (i + k) < n; i++){
          	mini = -1;
			for(int j = i; j < i+k; j++){
				if(mini == -1){
					mini = cost[i][j] + cost[j+1][i+k] + presum[i+k+1] - presum[i];
				}
				else{
					mini = min(mini, cost[i][j] + cost[j+1][i+k] + presum[i+k+1] - presum[i]);
				}
 			}
			cost[i][i+k] = mini;
		}
	}	
	
   	cout << cost[0][n-1] << endl;

   	return 0;
   
}


Measured memory_bytes: 4904
// gocon
package main

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

// global
var sc = bufio.NewScanner(os.Stdin)
var m = []float64{0, 0, -1}
var mem = [3000][3000]float64{}

func cal(a, b float64) float64 {
    if a != 0 && b != 0 {
        return 100 * b / (a + b)
    } else {
        return 0
    }
}

func dfs(water float64, suger float64, p float64, nums []float64) float64 {
    wi := int(water)
    si := int(suger)
    
    if water + suger > nums[5] {
        // pass
    }else if mem[wi][si] == 0{
        mem[wi][si] = cal(water,suger)
    }else{
        return mem[wi][si]
    }

    if water != 0 && ( suger/water > nums[4] / 100 || water+suger > nums[5]) {
        return p
    }
    
    if m[2] < cal(water,suger){
        m = []float64{water,suger,cal(water,suger)}
    }

    ans := nmax(
        dfs(water+nums[0] * 100, suger, cal(water, suger), nums),
        dfs(water+nums[1] * 100, suger, cal(water, suger), nums),
        dfs(water, suger+nums[2], cal(water, suger), nums),
        dfs(water, suger+nums[3], cal(water, suger), nums),
    )
    return ans
}

func main() {
    st := strings.Split(nextLine()," ")
    nums := (Filter(st))
    
    //nums := [6]float64{1, 2, 10, 20, 15, 200}
    dfs(nums[0]*100, 0, 0, nums)
    dfs(nums[1]*100, 0, 0, nums)
    fmt.Println(m[0]+m[1],m[1])
}


// ----------------------------------//
//              utils                //
// ----------------------------------//
func nmax(args ...float64) float64 {
    ret := -1000000000.01
    for _, v := range args { if ret < v { ret = v }}
    return ret
}

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func Filter(s []string) []float64 {
    var p []float64 // == nil
    var val float64
    for _, v := range s {
            val,_ = strconv.ParseFloat(v,64)
            p = append(p,val)
    }
    return p
}


Measured memory_bytes: 45696
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        ll n,m,a,sum=0;
        cin>>n>>m;
        rep(i,0,m-1){cin>>a;sum+=a;}
        if(sum>n)cout<<"-1";
        else cout<<n-sum;
        
    return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		int n=Integer.parseInt(str);
		for(int i=0;i<n;i++)
		{
			int N=Integer.parseInt(br.readLine());
			str=br.readLine();
			int[] u=new int[N+1];
			int[] d=new int[N+1];
			for(int j=0;j<N+1;j++)
			{
				u[j]=0;d[j]=0;
			}
			String down=str.substring(2*N,4*N);
			for(int j=1;j<N;j++)
			{
				if(str.substring(2*j-1,2*j).equals("Y")||str.substring(2*j,2*j+1).equals("Y"))
				{
					u[j]++;
				}
			}
			for(int j=1;j<N;j++)
			{
				if(down.substring(2*j-1,2*j).equals("Y")||down.substring(2*j,2*j+1).equals("Y"))
				{
					d[j]++;
				}
			}
			if(str.substring(0,1).equals("Y")){u[0]++;}if(str.substring(2*N-1,2*N).equals("Y")){u[N]++;}
			if(down.substring(0,1).equals("Y")){d[0]++;}if(down.substring(2*N-1,2*N).equals("Y")){d[N]++;}


			int ans=N;
			int f=-1,l=-1;
			int ff=-1,ll=-1;
			for(int j=0;j<N+1;j++)
			{
				if(u[j]==1){f=j;break;}
			}
			for(int j=N;j>=0;j--)
			{
				if(u[j]==1){l=j;break;}
			}
			for(int j=0;j<N+1;j++)
			{
				if(d[j]==1){ff=j;break;}
			}
			for(int j=N;j>=0;j--)
			{
				if(d[j]==1){ll=j;break;}
			}


			int uc=0,dc=0;
			for(int j=0;j<N+1;j++)
			{
				uc+=u[j];
				dc+=d[j];
			}



			if(ff==-1)
			{
				ans+=uc;
			}
			else
			{
				ans=ans+uc+dc;
				if(ff<f)
				{
					ans++;
				}
				if(ll>l)
				{
					ans++;
				}


			}

			System.out.println(ans);





		}
	}

}

Measured memory_bytes: 34588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int64_t A;
    string B;
    cin >> A >> B;
    string s = "";
    s.push_back(B[0]);
    s.push_back(B[2]);
    s.push_back(B[3]);
    int x = stoi(s);
    cout << A * x / 100 << "\n";
    return 0;
}


Measured memory_bytes: 3632
A, B, K = map(int, input().split())
a, b = [], []
for i in range(1,A+1):
    if A % i == 0:
        a.append(i)
for j in range(1,B+1):
    if B % j == 0:
        b.append(j)
lis = [k for k in a if k in b]
lis.reverse()
print(lis[K-1])

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <math.h>

struct point {
    double x, y;
};

void koch(int d, point p1, point p2) {
    if ( d == 0 ) {
        return;
    }
    
    point s, t, u;
    double rad = M_PI * 60.0 / 180.0;
    s.x = ( 2*p1.x + 1*p2.x ) / 3;
    s.y = ( 2*p1.y + 1*p2.y ) / 3;
    t.x = ( 1*p1.x + 2*p2.x ) / 3;
    t.y = ( 1*p1.y + 2*p2.y ) / 3;
    u.x = ( t.x - s.x ) * cos( rad ) - ( t.y - s.y ) * sin( rad ) + s.x;
    u.y = ( t.x - s.x ) * sin( rad ) + ( t.y - s.y ) * cos( rad ) + s.y;
    
    koch(d-1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(d-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(d-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(d-1, t, p2);
    //printf("%.8f %.8f\n", p2.x, p2.y);
}

int main() {
    int n;
    scanf("%d", &n);
    
    point p1, p2;
    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;
    printf("%.8f %.8f\n", p1.x, p1.y);
    koch(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);
    
    return 0;
}

Measured memory_bytes: 3172