akhauriyash/Code-Regression huggingface dataset:
/*
AizuOnline A0051
Differential II
*/
#include <stdio.h>
#include <stdlib.h>

compare_char(char *a,char *b)
{return(*a-*b);
}
compare_char_r(char *a,char *b)
{return(*b-*a);
}

main()
{
  char n8[10];
  int n;
  
  long int maxval,minval;

  scanf("%d",&n);
  while(n--)
    {
      scanf("%s",n8);
      qsort(n8,8,1,compare_char);
      sscanf(n8,"%ld",&minval);
      qsort(n8,8,1,compare_char_r);
      sscanf(n8,"%ld",&maxval);

      printf("%ld\n",maxval-minval);
    }

return(0);
}

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

int main(){
  int A, B;
  std::cin >> A >> B;
  for(int i = 0; i < 10000; ++i){
    if(std::floor(i*0.08) == A && std::floor(i*0.10) == B ){
      std::cout << i;
      return 0;
    }
  }
  std::cout << "-1";
  return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
    int x,y;
    for( ;; ) {
        cin>>x>>y;
        if( 0==x && 0==y ) { break; }
         
        if( x < y ) {
            cout <<x<<" "<<y<<endl;     
        } else {
            cout <<y<<" "<<x<<endl;
        }
    }
      
    return 0;
}

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

#define int long long int
#define ull unsigned long long int
#define for0(i, n) for (int i = 0; i < (int)(n); i++) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); i++) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); i++) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; i--) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; i--) // reverse 1 based


#define pb push_back
#define fi first
#define se second

#define I_max (int)1e9+7
#define size6 (int)1e6


#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())


using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef double ld;

//-----------------------------------------------------------------------------------END-------------------------------------------------------------------------------------//

int a[size6];


bool inc(vi vec){
	for1(i,vec.size()-1){
		if(vec[i]<vec[i-1])return 0;
	}
	return 1;
}


void solve(){
	int n;cin>>n;
	vi a(n);
	for0(i,n)cin>>a[i];

	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());

	int ans=0,id=0;
	for0(i,n-1){
		ans+= a[id];
		if(i%2==0)id++;
	}
	cout<<ans<<'\n';
}



int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout.precision(10);
	//cout << fixed;
	//int tt;cin>>tt;
	//while(tt--){
		solve();
	//}
	return 0;
}




Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#define mem(x,y)		(x*)malloc(sizeof(x)*(y))

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	int* an = mem(int,a);
	int* bu = mem(int,b);
	int i,j;
	int max = 0;
	for(i = 0;i < a;i++)
	{
		scanf("%d",an+i);
	}
	for(i = 0;i < b;i++)
	{
		scanf("%d",bu+i);
	}
	for(i = 0;i < b;i++)
	{
		int pt = i;
		for(j = 0;j < a;j++)
		{
			if(an[j] == bu[pt])
			{
				pt++;
			}
			if(pt == b)
				break;
		}
		if((pt-i)>max)
		{
			max = pt-i;
		}
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 444
import java.util.*;

class Main {
public static void main(String args[]) {
  Scanner sc = new Scanner(System.in);
  
  int N = sc.nextInt();
  String A = sc.next();
  String B = sc.next();
  String C = sc.next();
  
  int sum = 0;
  for(int i = 0;i < N;i++) {
    if(A.charAt(i) == B.charAt(i)) {
      if(A.charAt(i) == C.charAt(i)) {
      } else {
        sum += 1;
      }
    } else {
      if(B.charAt(i) == C.charAt(i)) {
        sum += 1;
      } else {
        if(A.charAt(i) == C.charAt(i)) {
        	sum += 1;
        } else {
          sum += 2;
        }
      }
    }
  }
  
  System.out.println(sum);
}
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, A, B; scanf("%d %d %d", &N, &A, &B);
  vector<int> H(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &H[i]);
  }

  ll low = 0, high = INF + 10;
  ll diff = A - B;
  while (high - low > 1) {
    ll mid = (high + low) / 2;
    ll cnt = 0;
    bool ok = true;
    for (int i = 0; i < N; ++i) {
      ll val = H[i] - mid * B;
      if (val <= 0) { continue; }
      cnt += (val + diff - 1) / diff;
      if (cnt > mid) {
        ok = false;
        break;
      }
    }
    if (ok) { high = mid; }
    else { low = mid; }
  }
  printf("%lld\n", high);
  return 0;
}


Measured memory_bytes: 640
def nCr(n, r): 
  
    return (fact(n) // (fact(r)  
                * fact(n - r))) 
  
# Returns factorial of n 
def fact(n): 
  
    res = 1
      
    for i in range(2, n+1): 
        res = res * i 
          
    return res 


e, o = map(int, input().split())

ans = nCr(e, 2) + nCr(o, 2)
print(ans)

Measured memory_bytes: 3064
#include <iostream> 
#include <cstdio>
#include <set>
#include <cstring>

using namespace std;

#define For(i , a , b) for (int i = a , _b = b ; i <= _b ; ++i)
#define Ford(i , a  ,b) for (int i = a , _b = b : i >= _b ; --i)
#define Rep(i , n) for (int i = 0 , _n = n ; i < _n ; ++i)
#define sz(A) ((int)A.size())
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)

typedef pair<int , int> pt;

const int maxn = 300000 + 123;
int a[maxn];
int n;

void ReadData() {
	cin >> n;
	For(i,1,n * 3) cin >> a[i];
}

long long prefixSum[maxn]; /// need to be maximized
long long suffixSum[maxn]; /// need to be minimized
const long long INF = 1e18;
void Process() {
	multiset<int> S;
	memset(prefixSum,-1,sizeof(prefixSum));
	memset(suffixSum,-1,sizeof(suffixSum));

	long long sumInSet = 0;
	For(i,1,n * 3) {
		S.insert(a[i]);
		sumInSet += a[i];
		if ((int)S.size() == n + 1) { /// must erase the smallest element
			sumInSet -= *(S.begin());
			S.erase(S.begin());
		}
		if ((int)S.size() == n) {
			prefixSum[i] = sumInSet;
		}
	}

	S.clear();
	sumInSet = 0;
	for (int i = n * 3 ; i >= 1; i--) {
		S.insert(a[i]);
		sumInSet += a[i];
		if ((int)S.size() == n + 1) {
			sumInSet -= *(--S.end());
			S.erase(--S.end());
		}
		if ((int)S.size() == n) {
			suffixSum[i] = sumInSet;
		}
	}

	long long res = -INF;
	For(i,1,n * 3) {
		if (suffixSum[i] != -1 && prefixSum[i - 1] != -1) {
			res = max(res, prefixSum[i - 1] - suffixSum[i]);
		}
	}
	cout << res << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	//freopen("input.inp" , "r" , stdin);
	ReadData();
	Process();

	return 0;

}			

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

#include <fstream>
#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                  ' '
#define EPS                  1e-9
#define mod                  1e9+7
#define P_INF                1e9+17
#define N_INF               -1e9+17
#define pi                   2*acos(0.0)
#define fi(s, n)             for(int i=s; i<n; i++)
#define fj(s, n)             for(int j=s; j<n; j++)
#define rfk(s, n)            for(int k=n-1; k>=s; k--)
#define unique(a)            a.resize(unique(a.begin(), a.end()) - a.begin())

typedef double ld;
typedef long long int ll;
typedef unsigned long long int ul;
using namespace std;

class BDigits {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, b;
        in >> n >> b;
        out << (int) (log(n) / log(b)) + 1 << endl;

    }
};


int main() {
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    BDigits solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N, M; cin >> N >> M;
  vector<pair<pair<int,int>, ll>> LRC(M);
  rep(i,M){
    cin >> LRC[i].first.first >> LRC[i].first.second >> LRC[i].second;
    LRC[i].first.first--;
    LRC[i].first.second--;
  }
  vector<vector<int>> G(N);
  vector<vector<ll>> CO(N);
  rep(i,M){
    G[LRC[i].first.first].pb(LRC[i].first.second);
    CO[LRC[i].first.first].pb(LRC[i].second);
  }
  rep(i,N-1){
    G[i+1].pb(i);
    CO[i+1].pb(0);
  }

  // ここからダイクストラ
  vector<ll> D(N, -1);
  vector<bool> used(N, false);
  priority_queue<pair<ll,int>,
                 vector<pair<ll,int>>,
                 greater<pair<ll,int>>> q;

  q.push({0,0});
  int cnt = 0;
  while(!q.empty()){
    pair<ll,int> nowNode = q.top(); q.pop();
    if(used[nowNode.second]) continue;
    used[nowNode.second] = true;
    D[nowNode.second] = nowNode.first;
    rep(i, (int)G[nowNode.second].size()){
      if(D[G[nowNode.second][i]] != -1 && D[G[nowNode.second][i]] <= D[nowNode.second] + CO[nowNode.second][i]) continue;
      q.push({D[nowNode.second] + CO[nowNode.second][i], G[nowNode.second][i]});
      cnt++;
    }
  }
  // rep(i,N) cout << D[i] << endl;
  // cout << cnt << endl;
  cout << D[N-1] << endl;
  return 0;
}


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

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

    bool a[26] = {false};
    for (int i = 0; i < s.length(); ++i) {
        a[s[i] - 'a'] = true;
    }

    for (int i = 0; i < 26; ++i) {
        if (!a[i]) {
            cout << (char)('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(fabs(c-a)<=d||(fabs(b-a)<=d&&fabs(c-b)<=d))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;


int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    int sumA = 0;
    for(int i = 0; i < M; ++i){
        cin >> A[i];
        sumA += A[i];
    }
    
    if(sumA > N){
        cout << -1 << endl;
    }else{
        cout << N-sumA << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long double
#define PI 3.1415926535897932

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    ll hr=h*5+5*m/60;
    //cout<<m<<" "<<hr<<endl;
    ll ang=6*abs(hr-m);
    ang=min(360-ang,ang);
    ll ans=a*a+b*b-(2*a*b*cos ( ang * PI / 180.0 ));
    ll ans2=sqrt(ans);
    cout<<setprecision(15)<<ans2<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int t = n;
  int sum = 0;
  while(n>0){
  sum += n%10;
  n /= 10;
  }
  
  if(t%sum == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
 }


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

using namespace std;

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

    if (s.length() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3576
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<u32>();
    let (n, i) = (line[0], line[1]);
    println!("{}", n-i+1);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
using namespace std;
int main(){
long n,i,j,k,x,y;
string s[8],t[8],u;
cin>>n;
for(k=0;k<n;k++){
for(i=0;i<8;i++)cin>>s[i];
cin>>x>>y;x--;y--;
L1:
for(i=-3;i<=3;i++){
if(-1-y<i&&i<8-y)if(s[y+i][x]=='1')s[y+i][x]='*';
if(-1-x<i&&i<8-x)if(s[y][x+i]=='1')s[y][x+i]='*';
}
s[y][x]='0';
for(i=0;i<8;i++)
for(j=0;j<8;j++)if(s[i][j]=='*'){s[i][j]=='0';y=i;x=j;goto L1;}
cout<<"Data "<<k+1<<":"<<endl;
for(i=0;i<8;i++)cout<<s[i]<<endl;
}
return 0;
}

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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N;
   cin >> N;
   vector<ll> A(N + 1), B(N);
   rep(i, N + 1) cin >> A.at(i);
   rep(i, N) cin >> B.at(i);

   ll max_mon = 0;

   rep(i, N) {
     if (B.at(i) <= A.at(i)) max_mon += B.at(i);
     else if (B.at(i) >= A.at(i) + A.at(i + 1)) {
       max_mon += A.at(i) + A.at(i + 1);
       A.at(i + 1) = 0;
     }
     else {
       max_mon += B.at(i);
       A.at(i + 1) = A.at(i + 1) - (B.at(i) - A.at(i));
     }
   }
   cout << max_mon << endl;
 }


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{

	char a[11];
	char b[11];
	char c[11];
	int d, e;
	scanf("%s%s", a, b);
	cin >> d >> e;
	scanf("%s" , c);
	if(strcmp(c, a)==0) d--;
	else e--;
	cout << d << " "<< e;



	return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int A = nextInt();
  int B = nextInt();
  cout << (A-1) * (B-1) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	long long int N;
	long long int sum = 0;
	scanf("%lld", &N);
	
	for(int i = 0; i <= N; i++){
		if(i % 3 == 0 || i % 5 == 0){
			continue;
		}else{
			sum += i;
		}
	}
	
	printf("%lld", sum);
	
	return 0;
}

Measured memory_bytes: 1732
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

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

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

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int n, m, k;
char mz[20][1010];
int U[1010], D[1010], tot, cnt[1010];
int ans = INF;
int sum[20][1010];
bool check() {
	for (int i = 1; i <= tot; i++) {
		if (cnt[i] > k)return false;
	}
	return true;
}
int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++) {
		scanf(" %c", &mz[i][j]);
		sum[i][j] = mz[i][j] - '0';
	}
	for (int j = 1; j <= m; j++) {
		for (int i = 1; i <= n; i++) {
			sum[i][j] += sum[i - 1][j];
		}
	}
	for (int i = 0; i < (1 << (n - 1)); i++) {
		int u = 1, d = 1;
		int tmp = 0;
		for (int j = 0; j < 10; j++) {
			if (i&(1 << j))tmp++;
		}
		tot = 0;
		while (u <= n) {
			for (; d < n && !(i&(1 << (d - 1))); d++);
			U[++tot] = u; D[tot] = d;
			u = d + 1;
			d = u;
		}
		bool flg = 1;
		for (int j = 1; j <= m; j++) {
			for (int c = 1; c <= tot; c++) {
				cnt[c] = sum[D[c]][j] - sum[U[c] - 1][j];
			}
			if (!check()) { flg = 0; break; }
		}
		if (!flg)continue;
		int l = 1, r = 1;
		while (l <= m) {
			for (int j = 1; j <= tot; j++)cnt[j] = 0;
			while (r <= m) {
				for (int j = 1; j <= tot; j++) {
					cnt[j] += sum[D[j]][r] - sum[U[j] - 1][r];
				}
				if (!check())break;
				r++;
			}
			l = r;
			tmp++;
		}
		ans = min(ans, tmp - 1);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) { cin >> h[i]; }
    vector<int> dp(N, INF);
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        for (int k = 1; k <= K; k++) {
            if (i + k < N) {
                dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
            }
        }
    }
    cout << dp[N - 1] << endl;
    return 0;
}


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

int main(){
 int N;
 cin >> N;
 
  long sum = 0;
  
  for (int i=1;i<=N;i++) {
    if (i%3==0) continue;
    if (i%5==0) continue;
    sum += i;
  }
  
  cout << sum << endl;
  
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n, 0);

    //配列を作る
    for (int i=0; i<n; i++){
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());

    int counter = 0;

    if (d.size() > 0){
        counter++;
    }

    for (int i=1; i<n; i++){
        if (d.at(i) > d.at(i-1)){
            counter++;
        }
    }

    cout << counter << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   string s;
   cin>>s;
   int n=s.size();
   bool c=true;
   for(int i=0;i<n/2;i++){
       if(s[i]!=s[n-i-1])c=false;
   }
   int t=(n-1)/2;
   for(int i=0;i<n;i++){
       if(i>t-i-1)break;
       if(s[i]!=s[t-i-1])c=false;
   }
    t=(n+3)/2;
    for(int i=0;i<n;i++){
       if(n-i-1<t+i-1)break;
       if(s[t-1+i]!=s[n-i-1])c=false;
   }
   if(c)cout<<"Yes"<<"\n";
   else cout<<"No"<<"\n";
}


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

using namespace std;

int n, k;
int v[200001];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> v[i];
    sort(v, v + n);
    long long sum = 0;
    for (int i = 0; i < n - k; ++i)
        sum += v[i];
    return cout << sum, 0;
}


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

typedef struct node{
    int a;
    int y[15];
}node;

void f(node* n){
    n->a = -1;
    for(int i=0; i<15; i++){
        n->y[i] = -1;
    }
}

int main(){
    int n;
    scanf("%d",&n);
    node a[n];
    for(int i=0; i<n; i++){
        f(&a[i]);
    }
    int x[n][15], y[n][15];
    for(int i=0; i<n; i++){
        scanf("%d", &(a[i].a));
        for(int j=0; j<a[i].a; j++){
            scanf("%d%d", &x[i][j], &y[i][j]);
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<a[i].a; j++){
            a[i].y[x[i][j] - 1] = y[i][j];
        }
    }
    int bi = pow(2, n) - 1;
    int max = 0;
    for(int i=bi; i>=0; i--){
        int k=i;
        int target = 0;
        int flag = 1;
        int count = 0;
        while(k > 0){
            if(k%2 == 1){
                count++;
                for(int j=0; j<n; j++){
                    if(a[target].y[j] == -1){
                        continue;
                    }else{
                        int buf = i;
                        for(int l=0; l<j; l++){
                            buf = buf/2;
                        }
                        if(buf % 2 != a[target].y[j]){
                            flag = 0;
                        }
                    }
                }
            }
            k = k/2;
            target++;
        }
        if(flag){
            //printf("%d\n", i);
            if(max < count){
                max = count;
            }
        }
    }
    printf("%d", max);

    return 0;
}

Measured memory_bytes: 256
I=lambda:map(int,input().split())
N=0xfffff
n,q=I()
c=list(I())
Q=[]
R=range
for i in R(q):l,r=I();Q.append(l<<40|r<<20|i)
Q.sort()
A=[[n]for i in R(N)]
for i in R(n)[::-1]:A[c[i]].append(i)
B=[0]*N
def P(a,x):
	i=a[-1]
	i+=1
	while i<=n:B[i]+=x;i+=i&-i
for i in A:P(i,1)
t=0
o=[0]*q
for x in Q:
	l=(x>>40)-1
	r=x>>20&N
	i=x&N
	while t<l:
		b=A[c[t]]
		P(b,-1)
		b.pop()
		P(b,1)
		t+=1
	while r:o[i]+=B[r];r-=r&-r
	while l:o[i]-=B[l];l-=l&-l
for i in o:print(i)

Measured memory_bytes: 249612
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll sum = 0;
  ll ans = 0;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    sum += a * b;
    ans += b;
  }
  ans--;
  while (sum > 9) {
    ans += sum / 10;
    sum = sum % 10 + sum / 10;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int n,p,a;
bool isAllEven=1;
int main()
{
	cin>>n>>p;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(a%2==1){
			isAllEven=0;
		}
	}
	cout<<setprecision(20);
	if(isAllEven==1){
		if(p==1){
			cout<<0<<endl;
		}
		else{
			cout<<pow(2,n)<<endl;
		}
	}
	else{
		cout<<pow(2,n-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<long long>> ab(n, vector<long long>(2));
  vector<vector<long long>> cd(m, vector<long long>(2));

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

  for (int i=0; i<m; i++) {
    cin >> cd[i][0] >> cd[i][1];
  }

  for (int i=0; i<n; i++) {
    vector<long long> ma(m);
    long long min=numeric_limits<long long>::max();
    for (int j=0; j<m; j++) {
      ma[j]=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]);
      if (min>ma[j]) min=ma[j];
    }
    for (int k=0; k<m; k++) {
      if (ma[k]==min) {
        cout << k+1 << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
long long a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
int main()
{
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

void solve(){
    int n, k;
    cin >> n; cin >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int count = 0;
    for(int i = n-1; i >= 0; i--){
        if(h[i] < k) break;
        count++;
    }
    cout << count << endl;
}


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

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>
#include <iterator>

typedef long long ll;
typedef unsigned long long ull;
constexpr ll mop = 1000000007;
constexpr ll mop2 = 998244353;

using namespace std;



int main() {
	ll n;
	string s;
	cin >> n >> s;
	vector<ll> list;
	list.resize(n + 1);
	list[0] = 0;
	ll tmpB = 0;
	for (ll i = 1; i <= n; i++) {
		if (s[i - 1] == '#') {
			tmpB++;
		}
		list[i] = tmpB;
	}
	ll ans = INT64_MAX;
	ll numBlack = list[n];
	for (ll i = 0; i <= n; i++) {
		ll tmp = list[i] + ((n - numBlack) - (i - list[i]));
		if (ans > tmp) {
			ans = tmp;
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 2180
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

dd p[3030], dp[3030][3030][2];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> p[i];

	dp[1][1][0] = p[1];
	dp[1][0][1] = 1 - p[1];

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

	dd sum = 0;

	for(int i = n / 2 + 1; i <= n; i++) {
		sum += dp[n][i][0] + dp[n][i][1];
	}

	cout << setprecision(11) << sum;
}

Measured memory_bytes: 141824
import sys
input = sys.stdin.readline
import fractions


def main():
    N = int(input())
    A = list(map(int, input().split()))

    L_gcds = [0] * N
    L_gcd_tmp = L_gcds[0]
    for i in range(1, N):
        L_gcd_tmp = fractions.gcd(L_gcd_tmp, A[i-1])
        L_gcds[i] = L_gcd_tmp

    R_gcds = [0] * N
    R_gcd_tmp = R_gcds[0]
    for j in range(1, N):
        R_gcd_tmp = fractions.gcd(R_gcd_tmp, A[N-j])
        R_gcds[j] = R_gcd_tmp
    R_gcds.reverse()

    LR_gcds = [0] * N
    for k in range(0, N):
        LR_gcds[k] = fractions.gcd(L_gcds[k], R_gcds[k])

    print(max(LR_gcds))

main()

Measured memory_bytes: 16136
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n = 0; cin >> n;
  vector<double> vi(n);
  for(double &c : vi) {
    cin >> c;
  }
  sort(vi.begin(), vi.end());
  vector<double> sum(n -1, 0);
  for(int i = 0; i < n -1; i++) {
    if(i == 0) {
      sum.at(0) = (vi.at(0) + vi.at(1)) /2;
    }
    else {
      sum.at(i) = (sum.at(i -1) + vi.at(i +1)) /2;
    }
  }
  cout << sum.at(n -2) << endl;
}

Measured memory_bytes: 3772
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int S=10004;
const double TW=2*acos(-1.0);
map<int,bool> mp;
vector<int> res;
int n,a[S];
long long b[S];
inline int mi(int a,int b){return a<b?a:b;}
bool pd(int x)
{
	for (int i=n;i>=0;--i) b[i]=a[i];
	for (int i=n;i>=x;--i) b[i-(x-1)]+=b[i];
	for (int i=mi(x-1,n);i>=0;--i)
		if (b[i]%x) return false;
	return true;
}
inline int gcd(int a,int b) {return b?gcd(b,a%b):a;}
inline int ab(int a){return a>0?a:-a;}
inline bool pr(int x)
{
	for (int i=2;i*i<=x;++i)
		if (x%i==0) return false;
	return true;
}
int main()
{
//	freopen("4125.in","r",stdin);
//	freopen("4125.out","w",stdout);
	scanf("%d",&n);
	for (int i=n;i>=0;--i)
		scanf("%d",a+i);
	int g=ab(a[0]);
	for (int i=n;i;--i) g=gcd(g,ab(a[i]));
	for (int i=2;i*i<=g;++i)
		if (g%i==0)
		{
			res.push_back(i);
			mp[i]=true;
			while (g%i==0) g/=i;
		}
	if (g>1) {mp[g]=true;res.push_back(g);}
	for (int i=2;i<=n;++i)
		if (!mp[i] && pr(i) && pd(i))
			res.push_back(i);
	sort(res.begin(),res.end());
	for (int x:res) printf("%d\n",x);
	return 0;
}



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

// 'r'  " 
int main(){
  string s,a,b,c,d;
  cin >> s;
  int n = s.size();
  n /= 2;
  a = b = s.substr(0,n);
  c = d = s.substr(n+1,n);
  reverse(b.begin(),b.end());
  reverse(d.begin(),d.end());
  bool ans = (a==b)&&(c==d)&&(a==d);
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i < 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  if (n == 1) ans = 1;
  else{
    repm(i, 2, n + 1){
      repm(j, 2, n + 1){
        if ((int)pow(i, j) <= n) ans = max(ans, (int)pow(i, j));
        else break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
pair<int,int> pii;
vector<int> vec;
int main()
{
  int n,q;
  string s;
  int l[100005],r[100005];
  int sum[100005];
  cin>>n>>q;
  cin>>s;
  for(int i=0; i<q; i++){
    cin>>l[i]>>r[i];
  }
  sum[0]=0;

  for(int i=1; i<s.size(); i++){
    sum[i]=sum[i-1];
    if(s[i-1]=='A' && s[i]=='C'){
      sum[i]+=1;
    }
  }

  for(int i=0; i<q; i++){
    cout<<sum[r[i]-1]-sum[l[i]-1]<<'\n';
  }

  return 0;
}


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

using namespace std;

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

int two_count(long long int n) {
	int ret = 0;
	for (;;) {
		if (n % 2 == 1) break;
		n /= 2;
		ret++;
	}
	return ret;
}


int main() {
	int n;
	cin >> n;
	vector<long long int> a(n);
	
	REP(i, n) {
		cin >> a[i];
	}

	int cnt = 0;
	for (auto v : a) {
		cnt += two_count(v);
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<int,P>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	string s;
	cin>>s;
	int ans=0;
	f(i,6){
		ans+=s[i]-'0';
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, 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; }

ll n, k;

int main() {
    cin >> n >> k;
    vector<ll> Avec(n, 0);
    for(int i = 0; i < n; ++i) cin >> Avec.at(i);
    sort(Avec.rbegin(), Avec.rend());

    int bit = 0;
    for(bit = 0; (1LL<<bit) <= k; ++bit);
    // cout << bit << endl;
    vector<int> bitcnt;
    for(int i = 0; i < n; ++i) {
        if(i == 0) {
            for(int bbit = 0; (1LL<<bbit) <= Avec.at(i); ++bbit) {
                if(Avec.at(i)&(1LL<<bbit)) bitcnt.emplace_back(1);
                else bitcnt.emplace_back(0);
            }
        }else {
            for(int bbit = 0; (1LL<<bbit) <= Avec.at(i); ++bbit) {
                if(Avec.at(i)&(1LL<<bbit)) bitcnt.at(bbit)++;
            }
        }
    }

    int cntlen = bitcnt.size();
    if(cntlen < bit) {
        for(int i = cntlen; i < bit; ++i) bitcnt.emplace_back(0);
    }

    reverse(bitcnt.begin(), bitcnt.end());
    // 0 2 2 2になってる

    vector< vector<ll> > dp(45, vector<ll>(2, -1));
    ll nlen = bitcnt.size();
    
    dp[0][0] = 0;
    for(ll i = 0; i < nlen; ++i) {
        ll mask = 1LL<<(nlen-i-1);
        int cnt1 = bitcnt.at(i);
        int cnt0 = n - cnt1;
        if(dp[i][1] >= 0) chmax(dp[i+1][1], dp[i][1] + mask*max(cnt1, cnt0));
        if(dp[i][0] >= 0) {
            if(k&mask) {
                chmax(dp[i+1][1], dp[i][0] + mask*cnt1);
                chmax(dp[i+1][0], dp[i][0] + mask*cnt0);
            }else {
                chmax(dp[i+1][0], dp[i][0] + mask*cnt1);
            }
        }
    }

    cout << max(dp[nlen][0], dp[nlen][1]) << endl;
}

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

using namespace std;
struct I{I(){ios::sync_with_stdio(false);cin.tie(0);cout<<setprecision(10);cout<<fixed;}}init;

namespace dsu{
    #define SZ 500000
    int mem[2][SZ];
}
class UF{
public:
    int *par,*rank;
    int find(int x){
        if(par[x]==x)return x;
        else return par[x]=find(par[x]);
    }
    bool unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return false;
        if(rank[x]<rank[y])par[x]=y;
        else{
            par[y]=x;
            if(rank[x]==rank[y])rank[x]++;
        }
        return true;
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    UF(int n):par(dsu::mem[0]),rank(dsu::mem[1]){
        for(int i=0;i<n;i++)par[i]=i,rank[i]=0;
    }
};
int main(){
    using P=complex<double>;
    int N,M;
    cin>>N>>M;
    double total=0;
    vector<P> xy(N);
    for(int i=0;i<N;i++){
        double x,y;cin>>x>>y;
        xy[i]=P(x,y);
    }
    using T=tuple<double,int,int>;
    vector<T> edge(M);
    for(int i=0;i<M;i++){
        int p,q;
        cin>>p>>q;p--,q--;
        double len=abs(xy[p]-xy[q]);
        total+=len;
        edge[i]=T(len,p,q);
    }
    sort(edge.begin(),edge.end());
    reverse(edge.begin(),edge.end());
    UF uf(N);
    for(auto &e:edge){
        double len;int p,q;
        tie(len,p,q)=e;
        if(uf.unite(p,q))
            total-=len;
    }
    cout<<total<<endl;

    return 0;
}

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

int main(){
  int h, w, i, j;
  cin >> h >> w;
  char a[h + 2][w + 2];
  char b[h][w];
  for(i = 1; i < h + 1; i++){
    for(j = 1; j < w + 1; j++){
      cin >> a[i][j];
    }
  }
  for(i = 0; i < w + 2; i++){
    a[0][i] = '.';
    a[h + 1][i] = '.';
  }
  for(i = 0; i < h + 2; i++){
    a[i][0] = '.';
    a[i][w + 1] = '.';
  }

  int num;
  for(i = 1; i < h + 1; i++){
    for(j = 1; j < w + 1; j++){
      if(a[i][j] == '.'){
	num = 0;
	if(a[i-1][j-1] == '#') num++;
	if(a[i-1][j] == '#') num++;
	if(a[i-1][j+1] == '#') num++;
	if(a[i][j-1] == '#') num++;
	if(a[i][j+1] == '#') num++;
	if(a[i+1][j-1] == '#') num++;
	if(a[i+1][j] == '#') num++;
	if(a[i+1][j+1] == '#') num++;
	b[i - 1][j - 1] = num + 48;
      }else{
	b[i - 1][j - 1] = '#';
      }
    }
  }
  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      cout << b[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#ifndef CPP_LOAD_MAIN
#define CPP_LOAD_MAIN
#include "Main.cpp"

namespace A
{
	struct Program
	{
		// variables
		int A, B;

		void Main()
		{
			// main program
			cin >> A >> B;
			cout << (B % A == 0 ? B + A : B - A) << endl;
		}

		// methods
	};
}

int main()
{
	A::Program program;
	program.Main();

#ifdef _DEBUG
	system("pause");
#endif
	return 0;
}
#else

#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <queue>
using namespace std;

namespace A
{
	// utilities

	/// <summary>
	/// Calculate GCD
	/// </summary>
	template<typename T>
	T gcd(T a, T b, T &x, T &y)
	{
		T x1 = 0, x2 = 1;
		T y1 = 1, y2 = 0;
		T q = 0;

		while (b != 0)
		{
			T tmp = x2;
			x2 = x1 - q * x2;
			x1 = tmp;
			tmp = y2;
			y2 = y1 - q * y2;
			y1 = tmp;

			q = a / b;

			tmp = b;
			b = a % b;
			a = tmp;
		}

		x = x2;
		y = y2;
		return a;
	}
	/// <summary>
	/// Calculate GCD
	/// </summary>
	template<typename T>
	T gcd(T a, T b)
	{
		T x, y;
		return gcd(a, b, x, y);
	}
}
#endif


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

int main() {
	int n;
	// cin>>n;
	string s;
	cin>>s;
	n=s.size();
	int ans=0,r=0,b=0;
	for(int a1=0;a1<n;++a1){
		if(s[a1]=='0')++r;
		else ++b;
		if(r!=0 && b!=0){
			++ans;
			--r,--b;
		}
	}
	cout<<2*ans;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 100000000000000

vector<int> p;
vector<bool> p_table(MAX+1,true);
void prime(){
  p_table.at(0)=false,p_table.at(1)=false;
  for(int i=2;i<=MAX;i++){
    if(p_table.at(i)){
      p.push_back(i);
      for(int j=2;i*j<=MAX;j++){
        p_table.at(i*j)=false;
      }
    }
  }
}

int main(){
  int N;
  cin>>N;
  prime();
  int n=0;
  vector<int> ans;
  for(int i=0;n<N;i++){
    if(p.at(i)%5==2){
      ans.push_back(p.at(i));
      n++;
    }
  }
  for(int i=0;i<N;i++){
    cout<<ans.at(i)<<" ";
  }
  cout<<endl;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    int x = s.length(), ct = 0;
    for(int i = 0; i < x; ++i){
        if(s[i] != s[x - i - 1]){
            ct++;
        }
    }
    cout << ct /2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

//read question carefully!

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n, a, b;
        cin >> n >> a >> b;
        string s;
        cin >> s;
        for (int i = 0; i < n; ++i)
        {
            if (s[i] == 'a')
            {
                if (a + b > 0)
                {
                    cout << "Yes"
                         << "\n";
                    a--;
                }
                else
                {
                    cout << "No"
                         << "\n";
                }
            }
            else if (s[i] == 'b')
            {
                if (a + b > 0 && b > 0)
                {
                    cout << "Yes"
                         << "\n";
                    b--;
                }

                else
                {
                    cout << "No"
                         << "\n";
                }
            }
            else
            {
                cout << "No"
                     << "\n";
            }
        }
    }
}

Measured memory_bytes: 3708
/**
	Language: C++
	Author  : 21
**/

#include <bits/stdc++.h>

using namespace std;

#define FastIO() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define Debug(v) cerr << '\n' << #v << ":\t" << v << '\n'

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;

int main() {
	FastIO();
	int t;
	cin >> t;
	cout << fixed << setprecision(5) << 2 * M_PI * t << '\n';
}


Measured memory_bytes: 3796
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    iroha = list(map(int, input().split()))
    if iroha.count(5)==2 and iroha.count(7)==1:
        print("YES")
    else:
        print("NO")
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10352
while 1:
    n = input()
    if n == 0:
        break
    s = [input(), input()]
    if s[0] > s[1]:
        max = 0
        min = 1
    else:
        max = 1
        min = 0
    for i in range(2, n):
        s.append(input())
        if s[i] > s[max]:
            max = i
        elif s[i] < s[min]:
            min = i
    s[max] = 0
    s[min] = 0
    sum = 0
    for i in range(n):
        sum += s[i]
    ave = sum / (n-2)
    print ave

Measured memory_bytes: 4240
n, k = map(int, input().split())
s = list(input())

if s[k-1] == 'A':
    s[k-1] = 'a'
elif s[k-1] == 'B':
    s[k-1] = 'b'
else:
    s[k-1] = 'c'

print(''.join(s))

Measured memory_bytes: 38396
N, M = map(int, input().split())
a = set(int(input()) for _ in range(M))
dp = [0] * (N + 1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1

for i in range(2, N + 1):
    if i - 2 not in a:
        dp[i] += dp[i-2]
        dp[i] %= 1000000007
    if i - 1 not in a:
        dp[i] += dp[i-1]
        dp[i] %= 1000000007

print(dp[N])


Measured memory_bytes: 58200
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print(lst[k-1])

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

int main(){
   int a, b;
   cin >> a >> b;
   if(a > b){
       cout << "a > b" << endl;
   }
   else if(a < b){
       cout << "a < b" << endl;
   }
   else{
       cout << "a == b" << endl;
   }
}


Measured memory_bytes: 3092
# coding:utf-8
n = int(input())
a = list(map(int, input().split()))
m = max(a)
count = [0 for _ in range(m + 1)]
ans = 0

for i in a:
    if count[i] != 0:
        count[i] = 2
        continue
    for j in range(i, m + 1, i):
        count[j] += 1


for i in a:
    if count[i] == 1:
        # print(i)
        ans += 1

print(ans)


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

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a(n - 1), b(n - 1);
	vector<vector<int>> g(n);
	map<pair<int, int>, int> ma;
	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		g[a[i]].push_back(b[i]), g[b[i]].push_back(a[i]);
		ma[make_pair(a[i], b[i])] = -1;
	}

	int ans = 0;
	rep(i, n) {
		ans = max(ans, (int)g[i].size());
	}
	cout << ans << endl;


	vector<int> used(n);
	vector<set<int>> usedc(n);
	queue<int> que;
	que.push(0);
	used[0] = 1;

	while (not que.empty()) {
		int u = que.front(); que.pop();
		int color = 1;
		for (auto v : g[u]) {
			if (used[v]) {
				continue;
			}
			if (ma[make_pair(min(u, v), max(u, v))] != -1) {
				continue;
			}
			while (usedc[u].count(color) || usedc[v].count(color)) {
				color++;
			}
			used[v] = 1;
			ma[make_pair(min(u, v), max(u, v))] = color;
			usedc[u].insert(color), usedc[v].insert(color);
			que.push(v);
		}
	}

	for (int i = 0; i < n - 1; ++i) {
		cout << ma[make_pair(a[i], b[i])] << endl;
	}
	return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int a[n];
    int E[n], W[n];
    int e = 0, w = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'W'){
            w++;
        }
        W[i] = w;
    }
    for(int i = n-1; i >= 0; i--){
        if(s[i] == 'E'){
            e++;
        }
        E[i] = e;
    }
    for(int i = 0; i < n; i++){
        if(i == 0) a[i] = E[1];
        else if(i == n-1) a[i] = W[n-2];
        else a[i] = E[i+1] + W[i-1];
    }
    sort(a, a+n);
    cout << a[0] << endl;
    return 0;
}

Measured memory_bytes: 4228
n,m,x=map(int,input().split())

v=[]
l=[]
for i in range(n):
    c=list(map(int,input().split()))
    v.append(c[0])
    l.append(c[1:])
    
ans=sum(v)
for i in range(2**n):
    total=0
    flag=True
    r=[0]*m
    for j in range(n):
        if (i >> j) & 1:
            total += v[j]
            for k in range(m):
                r[k] += l[j][k]
    
    for i in r:
        if i < x:
            flag=False
            break
    if flag:
        ans = min(ans,total)
    
if not flag:
    print(-1)
    exit()
print(ans)   

Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
bool fanc(int x,int y,int z){
    if(x == y && x != z)
        return true;
    
    return false;
}
int main()
{
    int a,b,c;
    cin >> a >> b >> c;

    if(fanc(a,b,c) || fanc(b,c,a) || fanc(c,a,b))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )
#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = (c).begin(); it != (c).end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define PB( n ) push_back( ( n ) )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define fst first
#define snd second

vector<string> rot( vector<string> org )
{
	vector<string> res;

	REP( i, 0, 8 )
	{
		string line;
		for ( int j = 7; 0 <= j; j-- )
		{
			line += org[j][i];
		}
		res.PB( line );
	}

	return res;
}

void output( vector<string> vs )
{
	UREP( i, 0, vs.size() )
	{
		UREP( j, 0, vs[i].length() )
		{
			cout << vs[i][j];
		}
		cout << endl;
	}

	return;
}

int main()
{
	vector<string> pattern;

	REP( i, 0, 8 )
	{
		string input;
		cin >> input;
		pattern.PB( input );
	}

	for ( int s = 90; s <= 270; s += 90 )
	{
		cout << s << endl;
		pattern = rot( pattern );
		output( pattern );
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define alpha_size 26


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    
    
    int n, inner_rating;
    cin >> n >> inner_rating;
    if (n >= 10)
      cout << inner_rating << endl;
    else
      cout << inner_rating + 100 * (10 - n) << endl;
}


Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string N;
  cin>>N;
  if(N[2]==N[3]&&N[4]==N[5])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}

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

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

void solve() {
  string s;
  cin >> s;
  if(s.back() == 's') {
    s += "es";
  } else {
    s += "s";
  }
  cout << s << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);

  int TC = 1;
  for(int i = 1; i <= TC; i++) {
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3608