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

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    string c[h];
    int hb[h] = {0}, wb[w] = {0}, ab = 0;
    for (int i = 0; i < h; i++)
    {
        cin >> c[i];
        for (int j = 0; j < w; j++)
        {
            if(c[i][j] == '#')hb[i]++;
        }
    }

    for (int i = 0; i < w; i++)
    {
        for (int j = 0; j < h; j++)
        {
            if(c[j][i] == '#')wb[i]++;
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if(c[i][j] == '#')ab++;
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << h); i++)
    {
        bitset<6> hbit(i);
        for (int j = 0; j < (1 << w); j++)
        {
            bitset<6> wbit(j);

            int buf = ab;
            for (int kk = 0; kk < h; kk++)
            {
                if(hbit[kk] == 1)
                {
                    buf -= hb[kk];
                }
            }
            for (int kk = 0; kk < w; kk++)
            {
                if(wbit[kk] == 1)buf -= wb[kk];
            }
            
            for (int kk = 0; kk < h; kk++)
            {
                for (int l= 0; l < w; l++)
                {
                    if(hbit[kk] == 1 && wbit[l] == 1 && c[kk][l] == '#')buf++;
                }
            }
            
            if(buf == k)ans++;
        }
    }

    
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
int a[200000];
int q[1000];
int clean[200000];
int par[200000][2];
int main(){
	int N,M,Q;
	cin>>N>>M>>Q;
	for(int i=0;i<M;i++){
		cin>>a[i];
	}
	for(int i=0;i<Q;i++){
		cin>>q[i];
	}
	for(int i=0;i<N;i++){
		clean[i]=1;
	}
	for(int i=2;i<N-1;i++){
		par[i][0]=i+1;
		par[i][1]=i-1;
	}
	par[0][0]=1;
	par[0][1]=N-1;
	par[1][0]=2;
	par[1][1]=0;
	par[N-1][0]=0;
	par[N-1][1]=N-2;
	int bat=0;
	for(int i=0;i<M;i++){
		for(int j=0;j<a[i];j++){
			if(a[i]%2==0){
				bat=par[bat][0];
			}
			else{
				bat=par[bat][1];
			}
		}
		par[par[bat][1]][0]=par[bat][0];
		par[par[bat][0]][1]=par[bat][1];
		clean[bat]=0;
		bat=par[bat][0];
	}
	for(int i=0;i<Q;i++){
		cout<<clean[q[i]]<<endl;
	}
	/*int N,M,p;
	cin>>N>>M>>p;
	int d[100001];
	for(int i=0;i<M;i++){
		cin>>d[i];
		if(d[i]>=p){
			d[i]=d[i]-p;
		}
		else{
			d[i]=N-(p-d[i]);
		}
	}
	sort(d,d+M);
	d[M]=d[0];
	int sum[10001];
	for(int i=0;i<M;i++){
			sum[i]=min(d[i]*2+N-d[i+1],(N-d[i+1])*2+d[i]);
	}
	sum[M]=min(d[M-1],N-d[0]);
	int answer=99999999;
	for(int i=0;i<M+1;i++){
		answer=min(answer,sum[i]*100);
	}
	cout<<answer<<endl;*/
	
	//cout<<sum[0]<<endl;
	/*int N,M;
	int h[100],m[100],k[100],g[100];
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>h[i]>>m[i];
	}
	cin>>M;
	for(int i=0;i<M;i++){
		cin>>k[i]>>g[i];
	}
	int n[200];
	for(int i=0;i<N+M;i++){
		if(i<N){
			n[i]=h[i]*60+m[i];
		}
		else{
			n[i]=k[i-N]*60+g[i-N];
		}
	}
	sort(n,n+N+M);
	if(n[0]%60>=10){
		cout<<n[0]/60<<':'<<n[0]%60;
	}
	else{
		cout<<n[0]/60<<':'<<0<<n[0]%60;
	}
	for(int i=1;i<N+M+1;i++){
		if(n[i]!=n[i-1] && i!=N+M){
		if(n[i]%60>=10){
			if(i<N+M-1){
				cout<<' '<<n[i]/60<<':'<<n[i]%60;
			}
			else{
				cout<<' '<<n[i]/60<<':'<<n[i]%60;
			}
		}
      else{
			if(i<N+M-1){
				cout<<' '<<n[i]/60<<':'<<0<<n[i]%60;
			}
			else{
				cout<<' '<<n[i]/60<<':'<<0<<n[i]%60;
			}
		}
	}
	else if(i==N+M){
		cout<<endl;
	}
}*/
	/*int N;
	cin>>N;
	int K[100],P[100];
	for(int i=0;i<N;i++){
		cin>>K[i]>>P[i];
	}
	for(int i=0;i<N;i++){
		if(K[i]%P[i]==0){
			cout<<P[i]<<endl;
		}
		else{
			cout<<K[i]%P[i]<<endl;
		}
*/
	/*int c1,c5,c10,c50,c100,c500;
	cin>>c1>>c5>>c10>>c50>>c100>>c500;
	if(c1+c5*5+c10*10+c50*50+c100*100+c500*500>=1000){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}*/
	/*int d,c;
	cin>>d>>c;
	cout<<d*c<<endl;*/
	//cout << "Hello world!!" << endl;
	return 0;
}



Measured memory_bytes: 6244
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((a != b && b == c && a != c) || (a == b && b != c && a != c) || (a != b && b != c && a == c)){
        cout << "Yes";
    }
    else {
     cout << "No";   
    }
 return 0;   
}

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

int main() {
    int card[9];
    int numbers[105];
    for (int i = 0; i < 9; i++) card[i] = 0;
    for (int i = 0; i < 105; i++) numbers[i] = -1;
    int a;
    for (int i = 0; i < 9; i++) {
        cin >> a;
        numbers[a] = i;
    }
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (numbers[a] < 0) continue;
        card[numbers[a]] = 1;
    }
    
    bool flg = false;
    for (int i = 0; i < 3; i++) {
        if (card[i*3] + card[i*3+1] + card[i*3+2] == 3) flg = true;
        if (card[i] + card[i+3] + card[i+6] == 3) flg = true;
    }
    if (card[2] + card[4] + card[6] == 3) flg = true;
    if (card[0] + card[4] + card[8] == 3) flg = true;
    if (flg) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200000+5;
struct point{
	long double x,y;
	point(){}
	point(long double _x,long double _y){
		x=_x;y=_y;
	}
	point operator -(const point &b) const{
		return point(x-b.x,y-b.y);
	}
	double operator *(const point &b) const{
		return x*b.y-y*b.x;
	}
};
__int128 rd(){
	__int128 x=0,f=1;char ch=getchar();
	while(!isdigit(ch))f=(ch=='-'?-1:f),ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*f;
}
__int128 a[N],b[N],A[N],B[N],c[N];
long double ans;
bool check(int i,int j,int k){
	return 1ll*(a[j] - a[i]) * (k - i) <= 1ll*(a[k] - a[i]) * (j - i);
}
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)
		A[i]=rd();
	for(int i=1;i<=n;++i)
		B[i]=rd();
	int pos=max_element(A+1,A+n+1)-A;
	for(int i=pos;i<=n;++i)
		a[i-pos]=A[i],b[i-pos]=B[i];
	for(int i=1;i<=pos;++i)
		a[n-pos+i]=A[i],b[n-pos+i]=B[i]; 
	for(int i=2;i<=n;++i)
		c[i]=2*(c[i-1]+b[i-1])-c[i-2],ans+=c[i],a[i]-=c[i];
	vector<int> vec;vec.push_back(0);
	for(int i=1;i<=n;++i){
		while(vec.size()>1 && check(vec[vec.size()-2],vec[vec.size()-1],i)) vec.pop_back();
		vec.push_back(i);
	}	
	for(int i=0;i<vec.size()-1;++i){
		int l=vec[i],r=vec[i+1];
		for(int j=l+1;j<r;++j)
			ans+=1.0L*(1ll*(j-l)*a[r]+1ll*(r-j)*a[l])/(r-l);
		ans+=a[r];
	}
	printf("%.12Lf",ans/n);
	return 0;
}

Measured memory_bytes: 19812
#include <stdio.h>

int main(void)
{
	int H, W;
	int i,j;
    scanf("%d %d",&H,&W);
    (((H>=3)&&(H<=300))&&((W>=3)&&(W>=300)));
    while(!((H==0)&&(W==0)))
	{
		for (i = 1; i <= H; i++)
		{
			for ( j = 1; j <=W ; j++)
			{
				if((i+j)%2==0)
				{
					printf("#");
				}
				else
				{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d %d",&H,&W);
	}	
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    ll k;
    cin>>s>>k;
    for(int i=0;i<min((ll)s.size(),k);i++){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    x = [0]*51
    for a in xrange(0,10):
        for b in xrange(0,10):
            for c in xrange(0,10):
                for d in xrange(0,10):
                    x[a+b+c+d] +=1
    print x[n]

Measured memory_bytes: 4204
#include<bits/stdc++.h>
using namespace std;
int n,c,k,a[101010],ans=1,nowpeople=1,p;
int main()
{
	cin>>n>>c>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	p=a[0];
	for(int i=1;i<n;i++)
	{
		if(nowpeople!=c)
		{
			if(a[i]-p<=k)
			{
				nowpeople++;
			}
			else
			{
				ans++;
				nowpeople=1;
				p=a[i];
			}
		}
		else
		{
			ans++;
			nowpeople=1;
			p=a[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

void solve() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h+2, vector<char>(w+2));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if(a[i][j] == '.') {
                continue;
            }
           bool l = (a[i][j - 1] == '#');
           bool r = (a[i][j + 1] == '#');
           bool d = (a[i + 1][j] == '#');
           bool u = (a[i - 1][j] == '#');
           if(l + r + d + u == 0) {
               cout << "No";
               return;
           }

        }
    }
    cout << "Yes";
}

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


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<char,int> p;
    int ans=0;
    for(int i=0;i<1000;i++){
        int c[3]={i/100,(i-c[0]*100)/10,i-100*c[0]-10*c[1]};
        int f=0;
        for(int j=0;j<n;j++){
            if(s[j]==(c[f]+'0')){
                f++;
            }
            if(f==3){
                break;
            }
        }
        if(f==3){
            ans++;
        }
    }
    //cout<<p.size()<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000

int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	int ans = 0;
	for(int i=0;i<N;i++){
		if(i==0){
			ans++;
			continue;
		}
		if(S[i]!=S[i-1]){
			ans++;
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  int d1 = Y - 2 * X;
  // int d2 = 4 * X - Y;
  if (d1 >= 0 && d1 <= 2 * X && d1 % 2 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3636
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (a, b, c) = i.read3::<usize, usize, usize>();

    let m = if a >= b && a >= c {
        a
    } else if b >= c {
        b
    } else {
        c
    };
    let r = a + b + c + m * 9;
    writeln!(o, "{}", r).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


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

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

int main() {
	ios::sync_with_stdio(false);
	
	int a, b, s, t;
	s = 0;
	t = 0;
	rep(i, 4) {
		cin >> a;
		s += a;
	}
	rep(i, 4) {
		cin >> b;
		t += b;
	}
	
	cout << (t>s?t:s) << endl;
	
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ma = 0, ans;
  for(int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if(ma < a) {
      ma = a;
      ans = a + b;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define ll long long
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000

vector<bool>prime(MAX, true);
vector<ll>fact(MAX);
vector<ll>factinv(MAX);

ll  fastpower(ll a, ll n)
{
	ll res = 1;
	while(n > 0)
	{
		if(n % 2 != 0)
		{
			res = (res * a) % MOD;
		}
		n /= 2;
		a=(a * a) % MOD;
	}
	return res;
}

void getprime()
{
	for(ll i = 2;i < MAX; i++)
	{
		if(prime[i-1])
		{
			for(ll j = i*i; j < MAX; j += i)
				prime[j-1] = false;
		}
	}
}

void getfact()
{
	fact[0] = 1;
	factinv[0] = 1;
	
	for(ll i = 1; i < MAX; i++)
		fact[i] = (fact[i-1] * i)%MOD;
	
	for(ll i = 1; i < MAX; i++)
		factinv[i] = (factinv[i-1] * fastpower(i, MOD -2) )%MOD;

}

int main()
{
  ll n;
  cin>>n;
  ll sum=0;
  for(ll i=1;i<=n;i++)
  {
    if(i%3!=0 && i%5!=0)
      sum+=i;
   	
  }
  cout<<sum;
  
  return 0;
}

Measured memory_bytes: 18904
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int h, w;
	cin >> h >> w;
	int a, b;
	cin >> a >> b;

	vector<vector<int>> ans(h, vector<int>(w, 0));

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (j < a && i < b)
			{
				ans[i][j] = 0;
			}
			else if (j < a && i>=b)
			{
				ans[i][j] = 1;
			}
			else if (j >= a && i < b)
			{
				ans[i][j] = 1;
			}
			else
			{
				ans[i][j] = 0;
			}
		}
	}

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			cout << ans[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

int main() {
  string n;
  int i = 0;
  
  cin >> n;
  if((n[0] == n[1]) && (n[0] == n[2]) && (n[0] == n[3])) cout << "Yes" << endl;
  else if((n[0] == n[1]) && (n[0] == n[2])) cout << "Yes" << endl;
  else if((n[1] == n[2]) && (n[1] == n[3])) cout << "Yes" << endl;
  else cout << "No" << endl;

}

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

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
char c[4]={'P', 'W', 'G', 'Y'};
int N, out=0;
cin >> N;
char in[110];

rep(i,N){
 cin >> in[i];
}

rep(i,N){
rep(j,4) if(in[i] == c[j]){
out++;
c[j] = NULL;
}


}

if(out == 4) cout << "Four"<<endl;
else if(out == 3) cout <<"Three"<<endl;
return 0;
}

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
constexpr int mod = 1e9 + 7;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream &operator<<(ostream &os, const mint &a) { return (os << a.x); }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int num;
  int x;
  cin >> x;

  num = 0;
  num += (x / 500) * 1000;
  x -= (x / 500) * 500;

  num += (x / 5) * 5;
  cout << num << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll N,M;
  cin>>N>>M;
  vector<string> A(N);
  for(ll i=0;i<N;i++) {
cin>>A[i];
  }
  vector<string> B(M);
  for(ll i=0;i<M;i++) {
cin>>B[i];
  }
  
  for(ll i=0;i<N-M+1;i++) {
for(ll j=0;j<N-M+1;j++) {
  bool a=true;
  
for(ll h=0;h<M;h++) {
for(ll k=0;k<M;k++) {
  if(A[i+h][j+k]!=B[h][k]) {
a=false;
  }
}
}
  if(a) {
cout<<"Yes"<<endl;
  return 0;
  }
}
  }
  
  cout<<"No"<<endl;
}
  

  
  
  
  
  


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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long x;
  cin >> x;
  long long ans = (1000 * (x / 500));
  x %= 500;
  ans += (5 * (x / 5));
  cout << ans << '\n';
  return 0;
}


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

int main() {
	int N = 0;
	int Alice = 0;
	int Bob = 0;
	int Max = 0;
	cin >> N;
	vector<int> Card(N); 
	for (int Loop = 0; Loop < N; Loop++) {
    	cin >> Card.at(Loop);
    }  
	for (int Loopi = 0; Loopi < N; Loopi++) {
        Max = 0;
		for (int Loopii = 0; Loopii < N; Loopii++) {
            sort(Card.begin(),Card.end());
        	reverse(Card.begin(),Card.end());
        	Max = Card.at(0);
        	if (Loopii % 2 == 0) {
            	Alice += Max;
            }
      		else {
            	Bob += Max;
            }
         	Card.at(0) = 0;
    }
    }
	cout << Alice - Bob << endl;;
}











































































































































































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

int gcd(int a, int b) {
  if (b==0) return a;
  return gcd(b,a%b);
}
 
 
signed main() {
	int k;
	cin >> k;
	int sum = 0;
	for(int a=1;a<=k;a++) 
		for(int b=1;b<=k;b++) 
			for(int c=1;c<=k;c++) {
				sum+=gcd(gcd(a,b),c);
			}
	cout<<sum<<endl;
	
}


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

using namespace std;

typedef long long ll;
// const ll MOD = 1000000007;

int main() {
  int M;
  ll K;
  cin>>M>>K;
  if (M == 0) {
    if (K == 0) cout<<0<<" "<<0<<endl;
    else cout<<-1<<endl;
  } else if (M == 1) {
    if (K == 0) cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;
    else cout<<-1<<endl;
  } else {
    ll n = 1LL << M;
    ll N = n - 1;
    if (K >= n) cout<<-1<<endl;
    else {
      vector<ll> u,v;
      for (ll i = 0; i < n; i++) {
        if (i == K) continue;
        v.push_back(i);
      }
      u = v;
      reverse(v.begin(),v.end());
      u.push_back(K);
      v.push_back(K);
      for (ll i = 0; i < n; i++) cout<<u[i]<<" ";
      for (ll i = 0; i < n; i++) cout<<v[i]<<" ";
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
typedef  long long ll;
#define INF 1000000000
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    vector<int>x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    int left=0,right=k-1,min_len=0;
    min_len=x[right]-x[left]+min(abs(x[right]),abs(x[left]));
    int current_len=min_len;
    while(right<n){
        int next_len=x[right]-x[left]+min(abs(x[left]),abs(x[right]));
        if(next_len<min_len){
            min_len=next_len;
        }
        left++;
        right++;
    }
    cout<<min_len<<endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int X;
    cin >> X;
    int cur = 100;
    for(int i = 1; i < 4000; ++i) {
        int rishi = cur / 100;
        cur += rishi;
        if(X <= cur) {
            printf("%lld\n", i);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3784
n = int(input())
ct = [[0] * 10 for _ in range(10)]

for i in range(n + 1):
    i = str(i)
    ct[int(i[0])][int(i[-1])] += 1

ans = 0
for i in range(1, 10):
    ans += ct[i][i] ** 2
for i in range(1, 10):
    for j in range(i + 1, 10):
        ans += ct[i][j] * ct[j][i] * 2
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

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

    int n = s.size();
    rep(i, n) {
        if (i % 2 == 0) {
            if (s[i] == 'R' or s[i] == 'U' or s[i] == 'D') {

            } else {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (s[i] == 'L' or s[i] == 'U' or s[i] == 'D') {

            } else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main(){
    long long n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    long long ans = 0;
    int maxi = 0;
    rep(i,n){
        maxi = max(maxi,a[i]);
        int Bi = maxi;
        ans += Bi - a[i];
    }

    cout << ans << endl;

    return 0;


}

Measured memory_bytes: 4072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<queue>
using namespace std;

int main() {
	int n, m, c[1010], v[1010] = {};
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		c[i] = a;
	}
	for (int i = 0; i < m; i++) {
		int j;
		cin >> j;
		for (int k = 0; k < n; k++) {
			if (c[k] <= j) {
				v[k]++;
				break;
			}
		}
	}

	int ans = 0, num = 0;
	for (int i = 0; i < n; i++) {
		if (num < v[i]) {
			ans = i;
		}
		num = max(num, v[i]);
	}
	cout << ans+1 << endl;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

using int128=__int128_t;

istream &operator>>(istream &is,int128 &x){
	string s;
	is>>s;
	x=0;
	for(int i=0;i<(int)s.size();i++){
		if(isdigit(s[i])){
			x*=10;
			x+=(s[i]-'0');
		}
	}
	if(s[0]=='-'){
		x*=-1;
	}
	return is;
}

ostream &operator<<(ostream &os,const int128 &x){
	if(x==0){
		return (os<<"0");
	}
	int128 n=x;
	if(x<0){
		os<<"-";
		n=-n;
	}
	string s="";
	while(n>0){
		s+=(char)((n%10)+'0');
		n/=10;
	}
	reverse(s.begin(),s.end());
	return (os<<s);
}

void solve()
{
	int n;
	cin>>n;
	vector<int128>a(n);
	rep(i,n)cin>>a[i];
	rep(i,n){
		if(a[i]==0){
			cout<<0;
			return;
		}
	}
	const int128 m=1000000000000000000;
	int128 mul=1;
	rep(i,n){
		mul*=a[i];
		if(mul>m){
			cout<<-1;
			return;
		}
	}
	cout<<mul;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 4700
read n
read a b
read -a p
c0=0
c1=0
c2=0
for x in ${p[@]}
do
    if((x<=a))
    then
        c0=$((c0+1))
    elif((x<=b))
    then
        c1=$((c1+1))
    else
        c2=$((c2+1))
    fi
done
((c0<c1)) && echo $((c0<c2?c0:c2)) || echo $((c1<c2?c1:c2))


Measured memory_bytes: 3764
<?php
list($X, $Y, $A, $B, $C) = ints();
$P = ints();
$Q = ints();
$R = ints();
rsort($P);
rsort($Q);
for($i = 0; $i < $X; ++$i){
    $R[] = $P[$i];
}
for($i = 0; $i < $Y; ++$i){
    $R[] = $Q[$i];
}
rsort($R);
$ans = 0;
for($i = 0, $I = $X+$Y; $i < $I; ++$i){
    $ans+=$R[$i];
}
echo $ans;

function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}


Measured memory_bytes: 35328
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin >> n;
	unordered_map<string, int> m;
	int mx = 0;
	set<string> ss;
	while(n--)
	{
		string s; 
		cin >> s;
		++m[s];
		mx = max(mx, m[s]);
	}
	for (auto it : m)
	{
		if (it.second == mx) ss.insert(it.first);
	}
	for (auto st : ss)
	{
		cout << st << endl;
	}



}


Measured memory_bytes: 33308
#include<bits/stdc++.h>
#define int long long 
#define rap(i,n) for(int i=0;i<n;++i)
using namespace std;
int n,w,we[100000],va[100000],dp[110][100000];
signed main() {
  cin>>n>>w;
  rap(i,n) cin>>we[i]>>va[i];
  rap(i,w) dp[0][i]=0;
  rap(i,n){
    for(int j=0;j<=w;++j){
      if(j>=we[i]) dp[i+1][j]=max(dp[i][j-we[i]]+va[i],dp[i][j]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout<<dp[n][w]<<"\n";
}

Measured memory_bytes: 82176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll ans[100010];
int main() {
	string s;
	cin>>s;
	ll cnt=0;
	for(ll i=0;i<s.size();i++){
		if(s[i]=='R'){
			cnt++;
		}
		else{
			ans[i]+=cnt/2;
			ans[i-1]+=(cnt+2-1)/2;
			cnt=0;
		}
	}
	for(ll i=s.size()-1;i>=0;i--){
		if(s[i]=='L'){
			cnt++;
		}
		else{
			ans[i]+=cnt/2;
			ans[i+1]+=(cnt+2-1)/2;
			cnt=0;
		}
	}	
	for(ll i=0;i<s.size();i++){
		cout <<ans[i]<<" ";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 4480
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    double x;
    cin >> x;
    double final=100;
    int t=1;
    while(1)
    {
        final=final*1.01;
        final=floor(final);
        if(final>=x)
            break;
            else
                t++;
    
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
/*
考察
一点値決めればあとは自動で決まる気がする
0にiを入れたときの各値をiで表してあげて、可能の範囲を見て決定
0にiを入れてトポロジカルチックにやる？
とりあえずBFSとかで適当にやって、最後にその範囲とかからガンバルンバ
*/
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,M;cin>>N>>M;
  typedef pair<int,int> P;
  std::vector<P> edge[N];
  while(M--){
    int u,v,s;cin>>u>>v>>s;u--;v--;
    edge[u].push_back(P(v,s));
    edge[v].push_back(P(u,s));
  }
  std::vector<P> val[N];
  val[0].push_back(P(0,1));
  queue<P> que;//親、子
  std::vector<int> used(N,0);
  que.push(P(-1,0));
  while(que.size()){
    P p=que.front();que.pop();
    int pa=p.first,now=p.second;
    if(used[now])continue;used[now]++;
    for(auto q:edge[now]){
      int po=q.first,we=q.second;
      if(po==pa)continue;
      val[po].push_back(P(we-val[now][0].first,-val[now][0].second));
      if(!used[po])que.push(P(now,po));
    }
  }
  int ans_i=-LINF,tmp;
  for(int i=0;i<N;i++){
    for(int j=1;j<val[i].size();j++){
      if(val[i][0]==val[i][j])continue;
      int n=val[i][0].second-val[i][j].second;
      int num=val[i][j].first-val[i][0].first;
      if(!n)fin(0);
      if(abs(num)%abs(n))fin(0);
      tmp=num/n;
      //cout<<i<<" "<<j<<" "<<val[i][0].first<<" "<<val[i][0].second<<" "<<val[i][j].first<<" "<<val[i][j].second<<" "<<ans_i<<" "<<tmp<<endl;
      if(ans_i>-LINF&&ans_i!=tmp)fin(0);
      ans_i=tmp;
    }
  }
  if(ans_i>-LINF){
    for(int i=0;i<N;i++)
      if(val[i][0].first+val[i][0].second*ans_i<=0)fin(0);
    fin(1);
  }
  int mn=-LINF,mx=LINF;
  for(int i=0;i<N;i++){
    int num=val[i][0].first,n=val[i][0].second;
    if(!n){
      if(val[i][0].first>0)continue;
      fin(0);
    }
    if(n>0){//num<n*aになるようにaを設定（mnを）
      mn=max(mn,(-num)/n+1);
    }
    else{//num<n*aになるようにaを設定(mxを)
      tmp=num/(-n);if(!(abs(num)%abs(n)))tmp--;
      mx=min(mx,tmp);
    }
  }
  //for(int i=0;i<N;i++)cout<<"VAL"<<val[i][0].first<<" "<<val[i][0].second<<endl;
  //cout<<mn<<" "<<mx<<endl;
  fin(max(0LL,mx-mn+1));
}


Measured memory_bytes: 15216
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		boolean flg = true;
		int ans = 0;
		a:for(int i = 1;i < s.length;i++){
			for(int j = 0;j < (s.length-i)/2;j++){
				if(!s[j].equals(s[(s.length-i)/2+j])){
					flg = false;
				}
			}
			if(flg && (s.length - i) % 2 == 0){
				ans = s.length-i;
				break a;
			} else {
				flg = true;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21332
import bisect

N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

comb = 0
mid_start = 0

while mid_start < N:
    mid_value = B[mid_start]
    mid_end = bisect.bisect_right(B,mid_value)
    mid_num = mid_end - mid_start
    top_end = bisect.bisect_left(A,mid_value)
    top_num = top_end
    bottom_start = bisect.bisect_right(C,mid_value)
    bottom_num = N - bottom_start
    comb += top_num * mid_num * bottom_num
    mid_start = mid_end

print(comb)

Measured memory_bytes: 106704
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var M = input[1];
            var route = new List<int>[N + 1];
            for (int i = 0; i < N + 1; i++) route[i] = new List<int>();
            for (int i = 0; i < M; i++)
            {
                input = ReadArrayInt();
                route[input[0]].Add(input[1]);
                route[input[1]].Add(input[0]);
            }
            for (int i = 0; i < route[1].Count; i++)
            {
                for (int j = 0; j < route[route[1][i]].Count; j++)
                {
                    if (route[route[1][i]][j] == N)
                    {
                        Console.WriteLine("POSSIBLE");
                        Console.ReadLine();
                        return;
                    }
                }
            }

            Console.WriteLine("IMPOSSIBLE");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 38584
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;
int main(){
	string s;
	cin >> s;
	int k;
	cin >> k;
	REP(i, s.size()){
		if(k >= 1 + 'z' - s[i] && s[i] != 'a'){
			k -= 1 + 'z' - s[i];
			s[i] = 'a';
		}
	}
	k %= 26;
	REP(i, k){
		if(s[s.size()-1] == 'z') s[s.size()-1] = 'a';
		else s[s.size()-1] += 1;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 512
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i64 = input();
    let k: i64 = input();

    let mut m = n / k;
    let mut ans = m * (m - 1) * (m - 2) + 3 * m * (m - 1) + m;
    if k % 2 == 0 {
        if n / k * k + k / 2 <= n {
            m += 1;
        }
        ans += m * (m - 1) * (m - 2) + 3 * m * (m - 1) + m;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
typedef pair<int, string> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
    int n, m;
    cin >> n;
    vector<P> vec;
	for(int i = 0; i < n; i++)
    {
        string c;
		int d;
        cin >> c >> d;
        vec.push_back(P(d, c));
    }
	sort(vec.begin(), vec.end());
	cin >> m;
	vector<string> color(m + 1);
	for(int i = 0; i < m; i++) cin >> color[i]; 
	int val = -1, cnt = 0;
	for(int i = 0; i < n; i++)
    {
		if(cnt >= m) break;
		if (vec[i].first <= val) continue;
		if (vec[i].second == color[cnt])
	   	{
			val = vec[i].first;
			cnt++;
		}
	}
	cout << (cnt == m ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 20848
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k,i,j,x,ans=0;
  	cin>>n>>k;
  	for(i=0;i<n;i++){
		cin>>x;
      	ans+=min(2*x,2*(k-x));
    }

  	cout<<ans<<endl;
}
		

Measured memory_bytes: 256
N = int(input())
MOD = int(1e+9) + 7



prime = [2]

for i in range(2, 1001):
    for j in range(2,i-1):
        if i % j == 0:
            break

    else:
        prime.append(i)

factor = [1] * 1001


for i in range(1, N+1):
    for p in prime:
        if i == 1:
            break
        while i % p == 0:
            i /= p
            factor[p] += 1

ans = 1
for fact in factor:
    ans *= fact
    ans %= MOD

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=2001 ;
int main()
{
   fast ;
   ll s,w ;
   cin>>s>>w ;
   if(s<=w)
   {
       cout<<"unsafe" ;
   }
   else
    cout<<"safe" ;



}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll int128_t
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
int const mod = 998244353;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            res = res*a;
            res %= m;
        }
        a=a*a;
        a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x){
    return power(x,mod-2,mod);
}

int const N = 5e5+5;
int const inf = 2e16;

void solve(){  
    int i,j;
    int n,m; cin>>n>>m;
    int sm = 0;
    for(i=0;i<m;i++){
        int x; cin>>x; sm+=x;
    }
    cout<<max(-1LL , n-sm)<<endl;
}             


int32_t main(){
    IOS;
    int t;
    t = 1;
    // precompute();
    // cin>>t;
    for(int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}


/*

*/

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

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

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

    int dp[n];
    dp[0] = 0;

    for (int i = 1; i < n; ++i) {
        dp[i] = abs(h[i] - h[i - 1]) + dp[i - 1];
        for(int j = 2; (j <= k) && (i - j >= 0); ++j) {
            dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
        }
    }

    std::cout << dp[n - 1];

    return 0;
}

Measured memory_bytes: 1024
def calc(x, y, z):
    return (x**2 + y**2 + z**2 + x*y + y*z + z*x)

def main():
    N = int(input())

    val = [0] * 100000

    for x in range(1,101):
        for y in range(1,101):
            for z in range(1,101):
                val[calc(x,y,z)] += 1

    for i in range(1,N+1):
        print(val[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 69392
/*
  AOJ #2808
  title:Password
  @kankichi573
 */
#include <stdio.h>
char a1[26],a2[26][26],a3[26][26][26],a4[26][26][26][26];
char s[400001];

void solve()
{
  int i,j,k,l;
  for(i=0;i<26;i++)
    if(a1[i]==0)
      {
	printf("%c\n",i+'a');
	return;
      }

  for(i=0;i<26;i++)
    for(j=0;j<26;j++)
    if(a2[i][j]==0)
      {
	printf("%c%c\n",i+'a',j+'a');
	return;
      }

  for(i=0;i<26;i++)
    for(j=0;j<26;j++)
      for(k=0;k<26;k++)
	if(a3[i][j][k]==0)
	  {
	    printf("%c%c%c\n",i+'a',j+'a',k+'a');
	    return;
	  }

  for(i=0;i<26;i++)
    for(j=0;j<26;j++)
      for(k=0;k<26;k++)
	for(l=0;l<26;l++)
	  if(a4[i][j][k][l]==0)
	    {
	      printf("%c%c%c%c\n",i+'a',j+'a',k+'a',l+'a');
	      return;
	    }
}

int main()
{
  int N,i;
  char *p;

  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%s",s);
      for(p=s;*p;p++)
	{
	  a1[*p-'a']=1;
	  if(p[1])
	    {
	      a2[*p-'a'][p[1]-'a']=1;
	      if(p[2])
		{
		  a3[*p-'a'][p[1]-'a'][p[2]-'a']=1;
		  if(p[3])
		    a4[*p-'a'][p[1]-'a'][p[2]-'a'][p[3]-'a']=1;
		}
	    }
	}
    }
  solve();
  return(0);
}

Measured memory_bytes: 2656
#include <bits/stdc++.h>
using namespace std;
#define vll vector<long long>
#define mll map<long long,long long>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define pb push_back
#define prll pair<long long,long long>
typedef long long ll;
typedef long double ld;
#define rep(i,a,n)   for(ll i=a; i<n; i++)
#define rrep(i,a,n)  for(ll i=n-1; i>=a; i--)
typedef map<string,ll> msl;
#define mx 100001
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll revrsno(ll n){
    ll k=0;
    vll z;
    while(n>0){
        z.pb(n%10);
        n/=10;
    }
    rep(i,0,z.size()) k=k*10+z[i];
    return k;
}
bool isPrime(ll n){
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
bool isPowerOfTwo(ll n) { 
   if(n==0) 
   return false; 
   return (ceil(log2(n)) == floor(log2(n))); 
}
ll Totfun(ll n){
    ll z=n;
    if(n%2==0){
        while(n%2==0){
            n/=2;
        }
        z/=2;
    }
    for(ll i=3;i<=sqrt(n);i+=2){
        if(isPrime(i)&&n%i==0){
          while(n%i==0){
            n/=i;
          }
        z-=z/i;  
        }
    }
    if(n>1){
        z-=z/n;
    }
    return z;
}
ll maxPrimeFactor(ll n) { 
    ll maxPrime=-1; 
    while(n%2==0){
        maxPrime=2; 
        n>>=1; 
    } 
    for (ll i=3;i<=sqrt(n);i+=2) { 
        while(n%i==0){ 
            maxPrime=i; 
            n=n/i; 
        } 
    } 
    if (n>2) maxPrime=n; 
    return maxPrime; 
} 
/*
vll a[mx];
ll l[mx],d[mx];
void dfs(ll x,ll y){
   l[x]=1; d[x]=y;
   for(ll i:a[x])
   if(!l[i])
   dfs(i,y+1);
}
void bfs(ll x){
    queue<ll> q;
    q.push(x);
    l[x]=1;
    d[x]=0;
    while(!q.empty()){
        ll cur=q.front();
        q.pop();
        for(ll i : a[cur]){
            if(1-l[i]){
                q.push(i);
                d[i]=d[cur]+1;
                l[i]=1;
            }
        }
    }
}
*/
 /*sort(a,a+n);
    ll d=1;
    vll z;
    for(ll i=1;i<n;i++){
    if(a[i]==a[i-1]){
        d++;
    }
    else{
            z.pb(d);
            d=1;
    }
    }
    z.pb(d);*/
int main(){
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
   cout.tie(NULL);
   ll n,ans=0;
   ld sum=0;
   cin>>n;
   ll a[n];
   rep(i,0,n){
       cin>>a[i];
       sum+=a[i];
   }
   sum/=n;
   sum=round(sum);
   rep(i,0,n) ans+=(a[i]-sum)*(a[i]-sum);
   cout<<ans;
   return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int k, n;
    vector<int> h;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        h.push_back(tmp);
    }
    sort(h.begin(), h.end());

    int min = INF;
    for (int i = k - 1; i < n; i++)
    {
        int sub = h[i] - h[i - k + 1];
        // cout << h[i] << "," << h[i - k - 1] << "," << sub << endl;

        if (sub < min)
            min = sub;
    }
    cout << min << endl;
}


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

int main() {
	int a, b, d, r;
	double f;
	double x, y;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	x = a;
	y = b;
	f = x / y;
	cout << d << " " << r << " " <<fixed<< f << endl;
	cin >> a;

}


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

using pii = pair<int, int>;
using ll  = long long;
#define rep(i, j) for (int i = 0; i < (int)(j); i++)
#define repeat(i, j, k) for (int i = (j); i < (int)(k); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << " : " << x << endl

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

template <class T>
bool set_max(T &a, const T &b) {
    return a < b ? a = b, true : false;
}
// vector
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &a : v) is >> a;
    return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &t : v) os << "\t" << t;
    return os << endl;
}
// pair
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &v) {
    return os << "<" << v.first << ", " << v.second << ">";
}

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

int main() {
    string S;
    cin >> S;
    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a,b,c,d,e,f;
  cin >> a;
  cin >> b;
  c = a * b;
  d = c / 2;
  e = c % 2;
  f = d + 1;
  if((a == 1) || (b == 1)) {
    cout << 1;
  } else if (e == 0){
    cout << d;
  } else if (e == 1) {
    cout << f;
  }
}

Measured memory_bytes: 256