akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;


int main(){
  int N;
  long int Y;
  cin>>N>>Y;
  int y1=0;
  int y5=0;
  int y10=0;
  bool ans = 0;
  for(y1=0;y1<N+1;y1++){
    for(y5=0;y5<N+1;y5++){
      if(ans==1)break;
      y10=N-y1-y5;
      if(y10>=0){
        long int total=y1*1000+y5*5000+y10*10000;
        if(total==Y){ans=1;cout<<y10<<" "<<y5<<" "<<y1<<endl;}
      }
    }
  }
  if(ans==0)cout<<"-1 -1 -1"<<endl;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int ans = 0;
	if(k <= a){
		ans += k;
	}
	else{
		ans += a;
		k -= a;

		if(b <= k){
			k -= b;
			ans -= k;
		}
	}

	cout << ans;
	return 0;
}

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

using namespace std;

int main()
{
    int n, l;
    cin >> n >> l;
    int sum = 0;
    int min = 300;
    for(int i = l; i <= n + l - 1; i++)
    {
        sum += i;
        if(abs(i) <= abs(min))
        {
            min = i;
        }
    }
    cout << sum - min;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[0]*(n+1)
a[0]=1
for _ in range(m):
    b=int(input())
    a[b]=-1

for i in range(0,n+1):
    if a[i]<0:
        continue
    if i+1>n:
        continue
    if (not a[i+1]<0):
        a[i+1]+=a[i]
        a[i+1]%=1000000007
    if i+2>n:
        continue
    if (not a[i+2]<0):
        a[i+2]+=a[i]
        a[i+2]%=1000000007

print(a[n])


Measured memory_bytes: 46168
#include<stdio.h>
#include<math.h>
#define INF 1e+10

int n;
double x[100],y[100],z[100],r[100];
double dist[100][100];

double max(double a,double b){
	return a<b?b:a;
}
double min(double a,double b){
	return a<b?a:b;
}
double square(double x){
	return x*x;
}
double distance(int a,int b){
	double d = sqrt(square(x[a]-x[b])+square(y[a]-y[b])+square(z[a]-z[b]));
	return max(0.0 ,d-r[a]-r[b]);
}
double prime(){
	int i,cur=0,count=1;
	int used[100];
	double res=0,mind[100], mi;
	for(i=0;i<n;i++)mind[i]=INF;
	for(i=0;i<n;i++)used[i]=0;
	used[cur]=1;
	while(count<n){
		for(i=0;i<n;i++)mind[i] = min(mind[i], dist[cur][i]);
		mi = INF;
		for(i=0;i<n;i++){
			if(!used[i] && mind[i]<mi){
				mi = mind[i];
				cur = i;
			}
		}
		res += mi;
		used[cur] = 1;
		count++;
	}
	return res;
} 
int main(){
	int i,j;
	while(scanf("%d",&n)==1&&n){
		for(i=0;i<n;i++)
			scanf("%lf %lf %lf %lf",x+i,y+i,z+i,r+i);
		for(i=0;i<n;i++){
			for(j=i+1;j<n;j++)dist[i][j]=dist[j][i]=distance(i,j);
		}
		printf("%.3f\n",prime());
	}
}

Measured memory_bytes: 744
#include <bits/stdc++.h>
using namespace std;
int main(){
  int r, d, a;
  cin >> r >> d >> a;
  vector<int> x(11);
  x[0]=a;
  for (int i=1;i<11;i++){
    x[i]=r*x[i-1]-d;
    cout << x[i] << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll X,Y;
void input(){
    fast_io();
    cin >> X >> Y;
}

bool firstWin(ll x, ll y){
    if(x<=1 && y<=1) return false;
    bool ret = false;
    for (int i = 1; 2*i <= x; i++)
    {
        ret |= !firstWin(x-2*i,y+i);
        // if(ret) return ret;
    }
    for (int i = 1; 2*i <= y; i++)
    {
        ret |= !firstWin(x+i,y-2*i);
        // if(ret) return ret; 
    }
    return ret;
}

string TLEsolve(ll x, ll y){
    string ans = firstWin(x,y)?"Alice":"Brown";
    cout << ans << " ";
    return ans;
}

int solve(){
    if(abs(X-Y)<=1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
    return 0;
}

int test(){
    for (int x = 0; x < 10; x++)
    {
        for (int y = 0; y < 10; y++)
        {
            // printf("%d %d ",x,y);
            TLEsolve(x,y);
        }
        cout << "\n";
    }
    return 0;
}

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

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> x(N), y(N), num(N);
    for(int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
        num[i] = i;
    }

    int cnt = 0;
    double ans = 0;
    do {
        cnt++;
        for(int i = 0; i < N - 1; ++i) {
            ans +=
                sqrt((x[num[i]] - x[num[i + 1]]) * (x[num[i]] - x[num[i + 1]]) +
                     (y[num[i]] - y[num[i + 1]]) * (y[num[i]] - y[num[i + 1]]));
        }
    } while(next_permutation(num.begin(), num.end()));

    printf("%.10lf\n", ans / cnt);
    return 0;
}


Measured memory_bytes: 256
#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 rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    string S;cin >> S;
    if(S[2] == S[3]){
        if(S[4] == S[5]){
           cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <math.h>

#define M 1046527
#define L 15

char H[M][L];

long long convertToNum(char* str) {
    long long result = 0;
    for (int i = 0; i < strlen(str); ++i) {
        int j = 0;
        switch (str[i]) {
            case 'A':
                j = 1;
                break;
            case 'C':
                j = 2;
                break;
            case 'G':
                j = 3;
                break;
            case 'T':
                j = 4;
                break;
        }
        result += j * pow(5, i);
    }
    return result;
}

int h1(int i) {
    return i % M;
}

int h2(long long i) {
    return 1 + i % (M - 1);
}

int getHash(long long key, int i) {
    return (h1(key) + h2(key) * i) % M;
}

bool find(char* str) {
    int i = 0;
    long long num = convertToNum(str);
    while (int key = getHash(num, i++)) {
        if (strcmp(H[key], str) == 0) return true;
        if (H[key][0] == '\0') break;
    }
    return false;
}

void insert(char* str) {
    int i = 0;
    long long num = convertToNum(str);
    while (int key = getHash(num, i++)) {
        if (strcmp(H[key], str) == 0) break;
        if (H[key][0] == '\0') {
            strcpy(H[key], str);
            break;
        }
    }
    return;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < M; ++i) { H[i][0] = '\0'; }

    for (int i = 0; i < n; ++i) {
        char command[7];
        char c[L];
        scanf("%s %s", command, c);
        if (command[0] == 'i') insert(c);
        if (command[0] == 'f') {
            if (find(c)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}

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

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p=-1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main() {
  int n, q;
  cin >> n >> q;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q) {
    int p, x;
    cin >> p >> x;
    --p;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) {
    cout << ans[i] << endl;
  }
  return 0;
}


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

const int N = 1e5 + 10;

int a[N];

int main(){
	int n, len, t, dir, cnt;
	scanf("%d %d %d",&n,&len,&t);
	cnt = 0;
	for (int i = 1; i <= n; i++){
		scanf("%d %d",&a[i],&dir);
		a[i] += (dir == 1 ? t : -t);
		cnt += a[i] / len;
		if (a[i] % len < 0) cnt--;
		a[i] = (a[i] % len + len) % len;
	} 
	sort(a + 1, a + n + 1);
	cnt = (cnt % n + n) % n;
	for (int i = cnt + 1; i <= n; i++) printf("%d\n", a[i]);
	for (int i = 1; i <= cnt; i++) printf("%d\n", a[i]);
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
 int a,b,c,d;
 scanf("%d%d%d",&a,&b,&c);
 if(a>b){
  d=a;
  a=b;
  b=d;
 }


 if(b>c){
  d=b;
  b=c;
  c=d;
 }


 if(a>b){
  d=a;
  a=b;
  b=d;
 }

printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
 
using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f                     first                 
#define  s                     second                
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  1e5+8;
const ll   mod   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
 
ll t=1,n,k,a[N],dp[N];
 
void solve(){
    cin>>n>>k;
    for(int i = 0; i < n; i++) cin>>a[i];
    memset(dp,0,sizeof(dp));
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        ll x = max(0ll,i-k);
        dp[i] = dp[i-1]+abs(a[i]-a[i-1]);
        for(int j = i-2; j >= x; j--)
            dp[i] = min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
    cout<<dp[n-1]<<endl;
}
 
int main(){
    fastio;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,sum=1;
    string s;
    cin>>n>>s;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]){
            sum++;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 512
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map { it.toInt() - 1 }
    var ans = 0
    for(i in list.indices) {
        val target = list[i]
        if(list[target] == i) {
            ans++
        }
    }
    println(ans/2)
}



Measured memory_bytes: 49792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
int a,b;
  cin>>a>>b;
  if(a!=1&&b!=1)
    cout<<1;
  if(a!=2&&b!=2)
    cout<<2;
    if(a!=3&&b!=3)
    cout<<3;
  }

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

double Snuke(long long X) {
	double Y = 0;
	long long Z = X;
	while (Z) {
		Y += Z % 10;
		Z /= 10;
	}
	return (double)X / Y;
}

int main() {
	int K;
	cin >> K;
	vector<long long> V;
	for (int i = 0; i < 16; i++) {
		for (int j = 1; j <= 1000; j++) {
			if (i == 0 && j == 1) continue;
			V.push_back(j * pow(10, i) - 1);
		}
	}
	sort(V.begin(), V.end());
	V.erase(unique(V.begin(), V.end()), V.end());
	for (int i = 0; i < V.size(); i++) {
		for (int j = i + 1; j < V.size(); j++) {
			if (Snuke(V[i]) > Snuke(V[j])) {
				V.erase(V.begin() + i);
				i--;
				break;
			}
		}
	}
	for (int i = 0; i < K; i++) {
		cout << V[i] << endl;
	}
}

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

int main(){
    int ans=0;
    int k;
    cin >> k;

    if(k%2==0)ans=(k/2)*(k/2);
    else ans=((k+1)/2)*(k/2);

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5+20;
int n,a[N],c[N],d[N];
long long s1[N],s2[N],f[N];
int main(void)
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]) , c[a[i]]++;
    for (int i=1;i<=n;i++) d[c[i]]++;
    for (int i=1;i<=n;i++)
        s1[i] = s1[i-1] + 1LL * i * d[i],
        s2[i] = s2[i-1] + d[i];
    for (int i=1;i<=n;i++) f[i] = ( s1[i] + ( s2[n] - s2[i] ) * i ) / i;
    for (int k=1;k<=n;k++)
    {
        int l = 1 , r = n;
        while ( l + 1 < r )
        {
            int mid = l + r >> 1;
            k <= f[mid] ? l = mid : r = mid;
        }
        if ( k <= f[r] ) printf("%d\n",r);
        else if ( k <= f[l] ) printf("%d\n",l);
        else puts("0");
    }
    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vi row;  // init : -1
vi col, dpos, dneg;  // free:0, cant put:1
vec<vec<bool>> grid;
/*FUNCs=================================================*/
// i行目までok
void recursive(int i) {
    if(i==8) {
        rep(j,8)rep(k,8) if(grid[j][k]&&row[j]!=k) return;

        rep(i,8)rep(j,8) {
            cout << (row[i]==j ? 'Q' : '.');
            if(j==7) cout << '\n';
        }
        return;
    }

    for(int j = 0; j < 8; ++j) {
        if(col[j]!=0 || dpos[i+j]!=0 || dneg[i-j+7]!=0) continue;
        row[i] = j;
        col[j] = 1; dpos[i+j] = 1; dneg[i-j+7] = 1;
        
        recursive(i+1);
        // i==8に到達できない場合以下のコード(バックトラック)が実行される

        row[i] = -1;
        col[j] = 0; dpos[i+j] = 0; dneg[i-j+7] = 0;
    }
    return;
}

/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int k, p,q; cin >> k;
    row.resize(8, -1);
    col.resize(8);
    dpos.resize(15);
    dneg.resize(15);
    grid.resize(8,vec<bool>(8));

    rep(i,k) {
        cin >> p >> q;
        grid[p][q] = 1;
    }

    recursive(0);

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3200
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int r = sc.nextInt();
	System.out.println(r*r);
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

int main() {
	int N; cin >> N;
	vector<pair<int, int>>ab(N);
	for (int i = 0; i < N; i++)cin >> ab[i].second >> ab[i].first;
	sort(ab.begin(), ab.end());

	long long time = 0;
	for (int i = 0; i < N; i++) {
		time += ab[i].second;
		if (time > ab[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("/");
		if(Integer.parseInt(s[1]) > 4) {
			System.out.println("TBD");
		}else {
			System.out.println("Heisei");
		}

		sc.close();
	}
}

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


int func(int x){
    if (x % 2 == 1) return 0;
    return func(x / 2) + 1;
}

int main(){
    int N;
    cin >> N;
    int ans = 1;
    
    for (int i = 1; i <= N; i++) {
        if (func(i) > func(ans)) {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i).sort

maxi = a[-1]
mini = a[0]

ans = []
(n - 2).times do |i|
  v = a[i + 1]
  if v < 0
    ans << [maxi, v]
    maxi -= v
  else
    ans << [mini, v]
    mini -= v
  end
end

ans << [maxi, mini]
maxi -= mini
puts maxi
ans.each do |x,y|
  puts "#{x} #{y}"
end

Measured memory_bytes: 19040
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void){

	int cnt=0;
	string str;
	string inp;

	while(1){
		inp=getchar();
		str+=inp;
		cnt++;
		if(cnt>=5){
			if(str[cnt-1]=='e'&&str[cnt-2]=='l'&&str[cnt-3]=='p'&&str[cnt-4]=='p'&&str[cnt-5]=='a') str[cnt-1]='h',str[cnt-2]='c',str[cnt-3]='a',str[cnt-4]='e',str[cnt-5]='p';
			else if(str[cnt-1]=='h'&&str[cnt-2]=='c'&&str[cnt-3]=='a'&&str[cnt-4]=='e'&&str[cnt-5]=='p') str[cnt-1]='e',str[cnt-2]='l',str[cnt-3]='p',str[cnt-4]='p',str[cnt-5]='a';
		}
		if(inp=="\n") break;
	}
	cout<<str;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vec> mat;
int main(){
    ll n,X[200001],L[200001];
    cin>>n;
    rep(i,n) cin>>X[i]>>L[i];
    vector<P> A;
    rep(i,n) A.push_back(P(X[i]+L[i],X[i]-L[i]));
    sort(A.begin(),A.end());
    int ans=1,r=A[0].first;
    rep(i,n) if(r<=A[i].second) r=A[i].first,ans++;
    cout<<ans;
}

Measured memory_bytes: 4216
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    ll ng = -1, ok = 1e15;
    while(ok - ng > 1){
        ll mid = (ok + ng) / 2;
        ll cost = 0;
        rep(i,n){
            if(a[i]*f[i] > mid){
                cost += a[i] - mid/f[i];
            }
        }
        if(cost > k) ng = mid;
        else ok = mid;
    }
    cout << ok << endl;
    return 0;
}


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

int f(int x) {
    int a = 0;
    for (auto &&i : to_string(x)) {
        a += i - '0';
    }
    return a;
}

int main(void) {
    string n;
    cin >> n;
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = 1; i <= stoi(n); i++) {
        int x = f(i);
        if (a <= x && x <= b) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3696
function GCD() {
  loop='n?(tmp=n,n=m%n,m=tmp,loop):m'
  echo $((($1>$2)?(m=$1,n=$2):(m=$2,n=$1),loop))
}

function LCM() {
  echo $((($1*$2)/$(GCD $1 $2)))
}

read A B C D
echo $((
  A--,
  lcm=$(LCM $C $D),
  (B-A)-((B/C-A/C)+(B/D-A/D)-(B/lcm-A/lcm))
))

Measured memory_bytes: 632
n = int(input())
A = sorted(list(map(int, input().split())))
up2_max = 0
up2_2nd = 0
up4_max = 0

from bisect import bisect_left, bisect_right
B = sorted(list(set(A)), reverse=True)
for cand in B:
  num = bisect_right(A, cand) - bisect_left(A, cand)
  if num >= 4:
    up4_max = cand
    break
for i, cand in enumerate(B):
  num = bisect_right(A, cand) - bisect_left(A, cand)
  if num >= 2:
    up2_max = cand
    break
for j in range(i+1, n):
  num = bisect_right(A, B[j]) - bisect_left(A, B[j])
  if num >= 2:
    up2_2nd = B[j]
    break
print(max(up4_max**2, up2_max * up2_2nd))

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  uint64_t a,b;
  cin >> a >> b;
 
  cout << a/b << " " << a%b << " ";
  cout << std::fixed << std::setprecision(6) << a/(double)b << endl;


  return 0;
}


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

public class Main {
	
	static int N;
	static int[] A;
	
	static void input() throws IOException {
		N = readInt();
		A = readMultiInt();
	}
	
	static void process() {
		for (int i = 0; i < N; i++) {
			int n = A[i];
			int j = i - 1;
			while( j >= 0 && A[j] > n) {
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = n;
			output0();
		}
	}
	
	static void output0() {
		for (int i = 0; i < N - 1; i++) {
			System.out.print(A[i] + " ");
		}
		System.out.println(A[N - 1]);
	}
	
	static void output() {
	}
	
	//??\?????±?????¨???
	static BufferedReader in;
	
	static void initBufferedReader() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}
	
	static String readString() throws IOException {
		return in.readLine();
	}
	
	static int readInt() throws NumberFormatException, IOException {
		return Integer.valueOf(readString());
	}
	
	static int[] readMultiInt() throws IOException {
		String input = readString();
		String[] values = input.split(" ");
		int[] result = new int[values.length];
		for (int i = 0; i < values.length; i++) {
			result[i] = Integer.valueOf(values[i]);
		}
		return result;
	}
	
	static String arrayToString(int[] data) {
		String result = "";
		for (int i = 0; i < data.length; i++) {
			if (i >= data.length - 1) {
				result += String.valueOf(data[i]);
			} else {
				result += String.valueOf(data[i]) + " ";
			}
		}
		return result;
	}
	
	static long factional(int n) {
		int result = 1;
		for (int i = 1; i <= n; i++) {
			result *= i;
		}
		return result;
	}
	
	public static void main(String[] args) throws IOException {
		initBufferedReader();
		input();
		process();
		output();
	}
	
}

Measured memory_bytes: 30824
from bisect import bisect_left


def solve(string):
    a, b, q, *stx = map(int, string.split())
    s = [-10**10] + stx[:a] + [2 * 10**10]
    t = [-10**10] + stx[a:a + b] + [2 * 10**10]
    x = dict([])
    i_s = 0
    i_t = 0
    for _x in sorted(set(stx[-q:])):
        """
        while s[i_s] < _x:
            i_s += 1
        while t[i_t] < _x:
            i_t += 1
        """
        i_s, i_t = bisect_left(s, _x), bisect_left(t, _x)
        ls, rs = s[i_s - 1], s[i_s]
        lt, rt = t[i_t - 1], t[i_t]
        r_max = max(rs, rt)
        l_min = min(ls, lt)
        x[_x] = min([
            r_max - _x, _x - l_min, rt - ls + min(rt - _x, _x - ls),
            rs - lt + min(rs - _x, _x - lt)
        ])
    return "\n".join([str(x[_x]) for _x in stx[-q:]])


if __name__ == '__main__':
    n, m, l = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, l) + '\n'.join([input() for _ in range(n + m + l)])))


Measured memory_bytes: 42644
#include <iostream>
#define N_MAX 100
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int K,N,A,B,i,j,k;
string S,Sa;
int x[N_MAX];
int y[N_MAX];
int num[N_MAX] = {0};
double ans=0;

int main(){
  cin >> N;
  for (i=0;i<N;i++) cin >> x[i];
  sort(x, x + N, greater<int>());
  ans = x[0]-x[N-1];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
using namespace std;
int n,a,b,head[10002],cnt,ans,m;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
char s[42];
int main(){
	n=3;
	scanf("%s",s+1);
	for(re int i=1;i<=n;++i){
		re int pos=i,cnt=0;
		while(s[pos]=='R')++cnt,++pos;
		ans=max(ans,cnt);
	}
	printf("%d",ans);
}

Measured memory_bytes: 3828
#include <iostream>
#define MAX(x,y) (((x)>(y))?(x):(y))
#define MIN(x,y) (((x)>(y))?(y):(x))
using namespace std;
int main(void){
    int n, k, n0, n1;
    long long sum;
    cin >> n;
    cin >> n0;
    n1=n0;
    sum=n0;
    for(int i=1;i<n;i++){
        cin >> k;
        n0=MIN(k,n0);
        n1=MAX(k,n1);
        sum+=k;
    }
    cout << n0 << " " << n1 << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3112
# -*- coding: utf-8 -*-

import sys
from collections import Counter
from functools import reduce
from operator import xor

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=[INT() for i in range(N)]

mnbit=[0]*N
for i, a in enumerate(A):
    bina=format(a, 'b')
    mnbit[i]=len(bina)-bina.rfind('1')
C=Counter(mnbit)

res=format(reduce(xor, A, 0), 'b')
cnt=0
ln=len(res)
for i in range(ln):
    idx=len(res)-i
    if res[i]=='1':
        if C[idx]:
            res=format(int(res, 2)^int('1'*idx, 2), '0'+str(ln)+'b')
            cnt+=1
        else:
            print(-1)
            exit()
print(cnt)


Measured memory_bytes: 8432
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  vector<ll> vl; 
  rep (i, n) {
    int x; cin >> x;
    ++mp[x];
  }

  for (auto v : mp) {
    if (v.second >= 2) {
      if (v.second >= 4) {
        vl.push_back(v.first);
      }
      vl.push_back(v.first);
    }
  }

  if (vl.size() >= 2) {
    sort(vl.rbegin(), vl.rend());
    cout << vl[0] * vl[1] << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 8112
import os, sys, re, math

lines = sys.stdin.readlines()

a = [int(n) for n in lines[0].split()]

costs = []
s = sum(a)
for i in range(3):
    for j in range(3):
        if i != j:
            costs.append(abs(a[j] - a[i]) + abs((s - a[i] - a[j]) - a[j]))
print (min(costs))


Measured memory_bytes: 3188
N,M=map(int,input().split())
a=[int(input()) for _ in range(M)]

a.append(N+10)
dp=[0]*(N)
j=0

for i in range(1,N+1):
    if i==1 and 1!=a[j]:
        dp[0]=1
    elif i==2:
        if 2==a[j]:
            dp[1]=0
            j+=1
        else:
            dp[1]=dp[0]+1

    elif i!=a[j]:
        dp[i-1]=dp[i-2]+dp[i-3]
    else:
        j+=1
    

print(dp[N-1]%1000000007)
    

Measured memory_bytes: 460020
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n';
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    ll d, a;
    cin >> n >> d >> a;
    vector<pair<int, int>> m(n);
    ll x, h;
    REP(i, n) {
        cin >> x >> h;
        m[i] = make_pair(x, h);
    }
    SORT(m);

    ll ans = 0;
    ll total = 0;
    deque<pair<ll, ll>> q;
    REP(i, n) {
        while (!q.empty() and q.front().first < m[i].first) {
            total -= q.front().second;
            q.pop_front();
        }
        m[i].second -= total;
        if (m[i].second <= 0) continue;
        ll c = (m[i].second + a - 1) / a;
        ans += c;
        total += c * a;
        q.emplace_back(m[i].first + d * 2, c * a);
    }
    cout << ans << endl;
}



Measured memory_bytes: 3456
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
ans=0
if s>=0:
    if s/n-s//n<=1+s//n-s/n:
        c=s//n
    else:
        c=1+s//n
else:
    if s/n-(int(s/n)-1)<=int(s/n)-s/n:
        c=(int(s/n)-1)
    else:
        c=int(s/n)
for i in range(n):
    ans+=(a[i]-c)**2
print(ans)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

struct node {
    int x,y,l;
    node(int x, int y, int l) : x(x), y(y), l(l){}
    bool operator>(const node &another) const {
        return l > another.l;
    }
};

int main(void) {
    int  h,w;
    cin >> h >> w;
    int dp[h][w];
    rep(i,h)rep(j,w)dp[i][j]=1<<30;
    dp[0][0]=1;
    string s[h];
    rep(i,h)cin >> s[i];
    int cnt=0;
    rep(i,h)rep(j,w)if(s[i][j]=='.')cnt++;
    priority_queue<node, vector<node>, greater<node> > pq;
    pq.push(node(0,0,1));
    do {
        node now = pq.top();
        pq.pop();
        int x=now.x,y=now.y,l=now.l;
        DEBUG{
            printf("%d %d l : %d",x,y,l);
        }
        if(x>0&&s[x-1][y]=='.'&&(dp[x-1][y]==-1||dp[x-1][y]>l+1)){
            dp[x-1][y]=l+1;
            pq.push(node(x-1,y,l+1));
        }
        if(y>0&&s[x][y-1]=='.'&&(dp[x][y-1]==-1||dp[x][y-1]>l+1)){
            dp[x][y-1]=l+1;
            pq.push(node(x,y-1,l+1));
        }
        if(x<h-1&&s[x+1][y]=='.'&&(dp[x+1][y]==-1||dp[x+1][y]>l+1)){
            dp[x+1][y]=l+1;
            pq.push(node(x+1,y,l+1));
        }
        if(y<w-1&&s[x][y+1]=='.'&&(dp[x][y+1]==-1||dp[x][y+1]>l+1)){
            dp[x][y+1]=l+1;
            pq.push(node(x,y+1,l+1));
        }
    }while(!pq.empty());
    if(dp[h-1][w-1]==(1<<30))cout << -1 << endl;
    else cout << cnt-dp[h-1][w-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a,b;
int main()
{
     cin>>a>>b;
    if(a+b==15) cout<<"+"<<endl;
    else if(a*b==15)  cout<<"*"<<endl;
    else  cout<<"x"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
    BufferedReader bf;
    PrintWriter writer;
    StringBuilder sb;
    static boolean local_system = false;

    void run() throws IOException {
        int[] c = ints();
        int[] d = ints();
        Arrays.sort(d);
        int sum = 0;
        for(int i = 0,h=c[1];i<h;i++) sum+=d[i];
        writer.println(sum);
    }

    public static void main(String[] args) throws IOException {
        long start_time = System.currentTimeMillis();
        Main obj = new Main();
        obj.run();
        long end_time = System.currentTimeMillis();
        if (local_system) obj.writer.println("Time : " + (end_time - start_time));
        obj.close();
    }

    public Main(){
        writer = new PrintWriter(System.out);
        bf = new BufferedReader(new InputStreamReader(System.in));
        sb = new StringBuilder();
    }

    public int getInt() throws IOException {
        return Integer.parseInt(bf.readLine());
    }

    public long getLong() throws IOException {
        return Long.parseLong(bf.readLine());
    }

    public int[] ints() throws IOException {
        String[] data = bf.readLine().split(" ");
        int[] send = new int[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Integer.parseInt(data[i]);
        return send;
    }

    public long[] longs() throws IOException {
        String[] data = bf.readLine().split(" ");
        long[] send = new long[data.length];
        for (int i = 0, h = data.length; i < h; i++) send[i] = Long.parseLong(data[i]);
        return send;
    }

    public void close() throws IOException{
        writer.flush();
        writer.close();
        bf.close();
    }
}




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

#define int int_fast64_t

signed main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr);

  int ops=0;
  int acnt=0;
  enum class state { garbage, a, ab };
  state s = state::garbage;
  string str; cin >> str;
  for (char c : str) {
    if (c == 'A') {
      if (s != state::a) {
        s = state::a;
        acnt = 0;
      }
      ++acnt;
    } else if (c == 'B') {
      if (s == state::a) {
        s = state::ab;
      } else {
        s = state::garbage;
      }
    } else if (c == 'C') {
      if (s == state::ab) {
        // A...A B C -> B C A...A
        ops += acnt;
        s = state::a;
      } else {
        s = state::garbage;
      }
    } else {
      assert(false);
    }
  }
  cout << ops << '\n';
}



Measured memory_bytes: 720
/*
一个长度为n的排列，每次可交换 |i−j|≥K 并且 |a_i−a_j|=1 的数对, 求经过若干次变换后最小字典序的排列
*/
#include<set>
#include<iostream>
#include<cstdio>
using namespace std;

const int N=500010;

struct node{
	int s,t,nxt;
}e[2*N];

int n,k,tot,p[N],q[N],h[N],d[N];

set<int>S;
set<int> :: iterator it;

int main(){
//	freopen("permutation.in","r",stdin);
//	freopen("permutation.out","w",stdout);
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]),q[p[i]]=i;
	for(int i=1;i<=n;i++){
		if(i>k) S.erase(p[i-k]);
		it=S.insert(p[i]).first;
		if ((++it)!=S.end()){
			e[++tot]=(node){i,q[*it],h[i]};
			h[i]=tot;d[q[*it]]++;
		}
	}
	S.clear();
	for(int i=n;i;i--){
		if(i+k<=n) S.erase(p[i+k]);
		it=S.insert(p[i]).first;
		if((++it)!=S.end()){
			e[++tot]=(node){i,q[*it],h[i]};
			h[i]=tot;d[q[*it]]++;
		}
	}
	S.clear();
	for(int i=1;i<=n;i++)
		if(!d[i]) S.insert(i);
	for(int i=1;i<=n;i++){
		it=S.begin(),S.erase(it),p[*it]=i;
		for(int j=h[*it];j;j=e[j].nxt)
			if (!(--d[e[j].t]))
				S.insert(e[j].t);
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",p[i]);
	return 0;
}

Measured memory_bytes: 46464
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int m=scan.nextInt();
		int cnt=0;
		while(m-->0) {
			int a=scan.nextInt();
			cnt+=a;
		}
		if(n-cnt>=0) System.out.println(n-cnt);
		else System.out.println("-1");
	}

}


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

int main(){
  string S,T;
  cin >> S >> T;
  string A="abcdefghijklmnopqrstuvwxyz";
  vector<int> s(26,0),t(26,0);
  for (int i=0;i<S.size();i++){
    for (int j=0;j<26;j++){
      if (S[i]==A[j]){
        s[j]++;
      }
    }
  }
  for (int i=0;i<T.size();i++){
    for (int j=0;j<26;j++){
      if (T[i]==A[j]){
        t[j]++;
      }
    }
  }
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  if (s==t){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 904
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		if( Character.isUpperCase(a.charAt(0))) {
		    System.out.println( "A" );
		}
		else {
		    System.out.println( "a" );
		}
	}
}


Measured memory_bytes: 35480
#include<cstdio>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
    if(a+b>=c) return puts("No"),0;
    long long x=4ll*(a*1ll)*(1ll*b);
    long long y=a*1ll*a+b*1ll*b+c*1ll*c+2ll*a*b-2ll*a*c-2ll*b*c;
    x<y?puts("Yes"):puts("No");
    return 0;
}

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

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

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};


ll n;
ll s;

unordered_map<ll, unordered_map<ll, ll>> hm;

ll f(ll b ,ll n) {
    if (hm.find(b)!=hm.end() && hm[b].find(n)!=hm[b].end()) return hm[b][n];
    if (n < b) return n;
    return hm[b][n]=f(b,n/b) + n%b;

}

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> s;
    if (n==s) {
        cout << n+1 << endl;
        return 0;
    }
    
    for (ll i = 2; i <= sqrt(n)+1; i++) {
        if (f(i,n) == s) {
            cout << i << endl;
            return 0;
        }
    }
    
    if (n < s) {
        cout << -1 << endl;
        return 0;
    }
    
    for (ll i = sqrt(n); i >= 1; i--) {
        if ((n-s)%i == 0) {
            ll b = (n-s)/i + 1;
            if (n/b + n%b == s) {
                cout << b << endl;
                return 0;
            }
        }
    }
    
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 63860
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  cin>>n;
  int arr[n+1];
  for(int i=1;i<=n;i++)
    cin>>arr[i];
  	
  long long	int dp[n+1][n+1];
  for(int i=0;i<=n;i++)
    for(int j=0;j<=n;j++)
      //for(int k=0;k<=2;k++)
        dp[i][j]=0;
  
  for(int dist=0;dist<n;dist++)
  {
    for(int i=1;i<=n-dist;i++)
    {
      int j=dist+i;
      if(i==j)
      {
        dp[i][j]=arr[i];
        continue;
      }
      dp[i][j]=max(arr[j]-dp[i][j-1],arr[i]-dp[i+1][j]);
     
    }
  }
  
 /** for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=n;j++)
    {
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }**/
   
  cout<<dp[1][n]<<endl;
  return 0;
}

Measured memory_bytes: 70656
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n; ++i) {
    cout << s[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int d; cin>>d;
    switch(d){
        case 25: cout<<"Christmas"<<endl; break;
        case 24: cout<<"Christmas Eve"<<endl; break;
        case 23: cout<<"Christmas Eve Eve"<<endl; break;
        case 22: cout<<"Christmas Eve Eve Eve"<<endl; break;

    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
int array[100005]={0};
struct uftree{
private:
  int par[100005]={0},rank[100005]={0};
public:
  uftree(int n){
    for(int i=1;i<=n;i++){
      par[i]=i;
      rank[i]=0;
    }
  }
  int find(int x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(rank[a]==rank[b]){
      par[a]=b;
      rank[b]++;
    }
    else if(rank[a]<rank[b]) par[a]=b;
    else par[b]=a;
  }
};
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++){
    int a;
    cin>>a;
    array[a]=i;
  }
  uftree uf=uftree(n);
  for(int i=1;i<=m;i++){
    int a,b;
    cin>>a>>b;
    uf.unite(a,b);
  }
  int ans=0;
  for(int i=1;i<=n;i++) if(uf.same(array[i],i)) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
int main() {
  char s[100001];
  char ans[50001];

  scanf("%s", s);
  
  int i;
  for(i=0;i<strlen(s);i+=2)
    ans[i/2] = s[i];
  ans[i/2+1] = 0;

  printf("%s", ans);
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
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;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template
ll score[20],prob[20],bonus[20];
ll n,p[20],c[20];
ll g,pre[20],ans;
ll mn (){
    ll steps = 0;
    for(int i=1;i<=n;i++){
        pre[i] = pre[i-1] + bonus[i];
        if(pre[i-1]<g && g<=pre[i]){
            ll need = g - pre[i-1];
            ll point = score[i];
            ll x = need/score[i];
            if(point * x >= need){}
            else{x++;}

            if(x>prob[i]){x=prob[i];}
            steps += x;
            break;
        }
        else{
            steps += prob[i];
        }
    }
    return steps;
}
int arr [20];
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>g;
    for(int i=1;i<=n;i++)arr[i]=i;
    for(int i=1;i<=n;i++){
        cin>>p[i]>>c[i];
        c[i] += p[i]*i*100;
    }

    for(int i=1;i<=n;i++){
        score[i] = arr[i] * 100;
        prob[i] = p[arr[i]];
        bonus[i] = c[arr[i]];
    }
    ans = LONG_LONG_MAX;
    ans = min(ans,mn());
    while(next_permutation(arr+1,arr+1+n)){
        for(int i=1;i<=n;i++){
            score[i] = arr[i] * 100;
            prob[i] = p[arr[i]];
            bonus[i] = c[arr[i]];
        }
        ans = min(ans,mn());
    }
    cout<<ans<<newl;

}


Measured memory_bytes: 256