akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

struct Card {
  char type;
  int value;
  std::string raw;

  Card(std::string s) {
    raw = s;
    type = s[0];
    value = s[1] - '0';
  }
};

void swap(std::vector<Card>& cards, int a, int b) {
  auto buf = cards[a];
  cards[a] = cards[b];
  cards[b] = buf;
}

std::vector<Card> bubbleSort(std::vector<Card> cards) {
  for (int i = 0; i < cards.size(); i++) {
    for (int j = cards.size() - 1; j > i; j--) {
      if (cards[j].value < cards[j - 1].value) swap(cards, j, j - 1);
    }
  }
  return cards;
}
std::vector<Card> selectionSort(std::vector<Card> cards) {
  for (int i = 0; i < cards.size(); i++) {
    int min = i;
    for (int j = i; j < cards.size(); j++) {
      if (cards[j].value < cards[min].value) min = j;
    }
    if (i != min) swap(cards, i, min);
  }
  return cards;
}

bool isStable(const std::vector<Card>& origin,
              const std::vector<Card>& sorted) {
  std::vector<std::vector<Card>> originTable(9, std::vector<Card>());

  std::for_each(origin.begin(), origin.end(), [&](Card card) {
    originTable[card.value - 1].push_back(card);
  });

  for (int i = sorted.size() - 1; i >= 0; i--) {
    auto& card = sorted[i];
    auto& back = originTable[card.value - 1].back();
    if (back.type != card.type) return false;
    originTable[card.value - 1].pop_back();
  }
  return true;
}

void trace(std::vector<Card>& cards) {
  for (int i = 0; i < cards.size(); i++) {
    std::cout << cards[i].raw;
    std::cout << (i == cards.size() - 1 ? '\n' : ' ');
  }
}

int main() {
  int n;
  std::cin >> n;
  std::vector<Card> cards;
  for (int i = 0; i < n; i++) {
    std::string buf;
    std::cin >> buf;
    cards.emplace_back(buf);
  }
  auto bCards = bubbleSort(cards);
  auto sCards = selectionSort(cards);
  trace(bCards);
  std::cout << (isStable(cards, bCards) ? "Stable" : "Not stable") << std::endl;
  trace(sCards);
  std::cout << (isStable(cards, sCards) ? "Stable" : "Not stable") << std::endl;
  return 0;
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1.0e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main() {
	int n;
	cin >> n;
	vi x(n);
	rep(i,n) cin >> x[i];
	
	int ans = INF;
	for(int i = 0; i <= 100; i++){
		int sum = 0;
		for(int j = 0; j < n; j++){
			sum += pow(x[j]-i,2);
		}
		ans = min(ans,sum);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const 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;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s, t;

    s.push_back(-1e15);
    rep(i, 0, A) {
        ll tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    s.push_back(1e15);

    t.push_back(-1e15);
    rep(i, 0, B) {
        ll tmp;
        cin >> tmp;
        t.push_back(tmp);
    }
    t.push_back(1e15);

    ll score_s[A], score_t[B];
    rep(i, 0, A + 2) {
        int idx = lower_bound(t.begin(), t.end(), s[i]) - t.begin();
        score_s[i] = min(abs(s[i] - t[idx - 1]), abs(s[i] - t[idx]));
    }

    rep(i, 0, B + 2) {
        int idx = lower_bound(s.begin(), s.end(), t[i]) - s.begin();
        score_t[i] = min(abs(t[i] - s[idx - 1]), abs(t[i] - s[idx]));
    }

    vector<ll> rsl;
    rep(i, 0, Q) {
        ll x;
        cin >> x;
        int idx = lower_bound(t.begin(), t.end(), x) - t.begin();
        int idx2 = lower_bound(s.begin(), s.end(), x) - s.begin();
        ll tmp = abs(x - t[idx - 1]) + score_t[idx - 1];
        ll tmp2 = abs(x - t[idx]) + score_t[idx];
        ll tmp3 = abs(x - s[idx2 - 1]) + score_s[idx2 - 1];
        ll tmp4 = abs(x - s[idx2]) + score_s[idx2];
        rsl.push_back(min(tmp, min(tmp2, min(tmp3, tmp4))));
    }
    rep(i, 0, rsl.size()) cout << rsl[i] << endl;

}


Measured memory_bytes: 5364
#include<cstdio>  
#include<cstring>  
#include<iostream>  
#include<algorithm>  
using namespace std;  
typedef long long ll;  
const int N=1e6+10;  
int n,m,a[4][N];  
ll ans,cnt[N];  
  
   
int main()  
{  
//  freopen("in.in","r",stdin);  
//  freopen("out.out","w",stdout);  
    scanf("%d",&n);  
    for(int i=1;i<=3;i++)  
        for(int j=1;j<=n;j++)  
        scanf("%d",&a[i][j]);  
    for(int i=1;i<=3;i++)  
        sort(a[i]+1,a[i]+n+1);  
    for(int i=1,j=1;j<=n;j++)  
    {  
        while(a[1][i]<a[2][j]&&i<=n) i++;  
        cnt[j]=i-1;  
    }  
//  for(int i=1;i<=n;i++)  
//      printf("cnt=%d\n",cnt[i]);  
//改用前缀和（dp思想）   
    for(int i=1;i<=n-1;i++) cnt[i+1]=cnt[i]+cnt[i+1];   
    for(int i=1,j=1;j<=n;j++)  
    {  
        while(a[2][i]<a[3][j]&&i<=n) i++;  
//      for(int m=1;m<=i-1;m++)  
//          ans+=cnt[m] ;  
        ans+=cnt[i-1];  
          
     }   
  
    printf("%lld\n",ans);  
    return 0;  
}  

Measured memory_bytes: 14592
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N;
  cin >> N;
  vector<int> r(N,0);
  for(int i=1;i<N;i++){
    int a;
    cin >> a;
    r[a-1]++;
  }

  for(int i=0;i<N;i++){
    cout << r[i] << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 4052
n = int(input())
dormitory = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]

for i in range(n):
    data = [int(j) for j in list(input().split())]
    tower = data[0]-1
    rank = data[1]-1
    room = data[2]-1
    dormitory[tower][rank][room] += data[3]

for i in range(0, 4):
    for j in range(0, 3):
        print(" "+" ".join(map(str, dormitory[i][j])))
    if i == 3:
        break
    else:
        print('#'*20)
    

Measured memory_bytes: 7712
def A():
    a = int(input())
    s = str(input())
    if a<3200:
        print('red')
    else:
        print(s)

def B():
    n = int(input())
    a = input().split()
    s = 0
    for i in range(n):
        s += (1/int(a[i]))
    print(1/s)

def C():
    n = int(input())
    v = sorted([int(i) for i in input().split()])

    if n == 2:
        print((v[0]+v[1])/2)
        return

    for i in range(1, n):
        v[i] = (v[i]+v[i-1])/2

    print(v[-1])

C()

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}


int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if(a[i]%2 == 0) {
            if(a[i]%3 == 0 || a[i]%5 == 0) {

            } else {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;
    return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <map>
#include <set>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <functional>
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<int, int> P;

LL X;
LL i=1, ans;

int main()
{
	in >> X;

	while (X > 0)
	{
		X -= i;
		++ans;
		++i;
	}

	out << ans << std::endl;
	return 0;
}

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

ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
// a x + b y = gcd(a, b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll g = a;
    x = 1;
    y = 0;
    if(b != 0)
        g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

int main() {
    int k;
    int sum = 0;
    cin >> k;
    rep(i, k) rep(j, k) rep(x, k) sum += gcd(i, gcd(j, x));
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] A = nextIntArray(sc, N);

		sc.close();

		long[] b = new long[200100];
		for (int a : A) {
			b[a]++;
		}

		long[] c = new long[200100];
		long sum = 0;
		for (int i = 0; i < b.length; i++) {
			if (b[i] >= 2) {
				c[i] = (b[i] * (b[i] - 1)) / 2;
				sum += c[i];
			}
		}

		for (int i = 0; i < A.length; i++) {
			long ans = sum;

			ans -= c[A[i]];

			long n = b[A[i]] - 1;
			if (n > 0) {
				ans += (n * (n - 1)) / 2;
			}

			out.println(ans);
		}

	}

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

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 93128
#include <stdio.h>
int main(){
  int i,j,minj,N,A[100],temp,count=0,flag;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&A[i]);
  for(i=0;i<N;i++){
    minj = i;//minj最小値が入っている要素番号(iと仮定)                          
    flag=1;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]){
        minj=j;//最小値の要素番号をminjに格納                                   
        flag=0;
      }
      if(j==N-1&&flag==1)count--;
    }
    temp=A[i];
    A[i]=A[minj];
    A[minj]=temp;
    count++;
  }
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i==N-1){
      printf("\n");
      break;
    }
    printf(" ");
  }
  printf("%d\n",count);
  return 0;
}









Measured memory_bytes: 2100
n = int(input())
a = list(map(int, input().split()))
if a[0] > 0 or a.count(0) > 1:
  print(0)
  exit()
  
a = sorted(a)
dp = [0]*(n+1)
dp[0] = 1
count_list = [0]*n
count_list[0] = 1
for i in range(1, n):
  count_list[a[i]] += 1
for i in range(1, a[n-1]+1):
  dp[i] = dp[i-1] * count_list[i-1] ** count_list[i] % 998244353
print(dp[a[n-1]])

Measured memory_bytes: 54580
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=100005;
int n,k;
struct P{
	int a[Maxn];
	P(){
		memset(a,0,sizeof(a));
	}
	void Out(){
		for (int i=1;i<=n;i++){
			printf("%d ",a[i]);
		}
	}
}p,q;
P inv(P x){
	P ret;
	for (int i=1;i<=n;i++){
		ret.a[x.a[i]]=i;
	}
	return ret;
}
P mul(P x,P y){
	P ret;
	for (int i=1;i<=n;i++){
		ret.a[i]=y.a[x.a[i]];
	}
	return ret;
}
P qp(P x,int pw){
	P ret;
	for (int i=1;i<=n;i++){
		ret.a[i]=i;
	}
	while (pw){
		if (pw&1) ret=mul(ret,x);
		x=mul(x,x);
		pw>>=1;
	}
	return ret;
}
int main(){
	scanf("%d %d",&n,&k);
	for (int i=1;i<=n;i++){
		scanf("%d",&p.a[i]);
	}
	for (int i=1;i<=n;i++){
		scanf("%d",&q.a[i]);
	}
	P pr=inv(p),qr=inv(q);
	if (k==1){
		p.Out();
		return 0;
	}
	if (k==2){
		q.Out();
		return 0;
	}
	if (k==3){
		P ret=mul(pr,q);
		ret.Out();
		return 0;
	}
	k-=4;
	P tmp=mul(qr,mul(p,mul(q,pr)));
	int W=k/6;
	k%=6;
	tmp=qp(tmp,W);
	if (k==0){
		tmp=mul(tmp,qr);
		P ans=mul(tmp,mul(pr,inv(tmp)));
		ans.Out();
	}
	else if (k==1){
		tmp=mul(tmp,mul(qr,p));
		P ans=mul(tmp,mul(qr,inv(tmp)));
		ans.Out();
	}
	else if (k==2){
		tmp=mul(tmp,mul(qr,p));
		P ans=mul(tmp,mul(mul(p,qr),inv(tmp)));
		ans.Out();
	}
	else if (k==3){
		tmp=mul(tmp,mul(qr,mul(p,q)));
		P ans=mul(tmp,mul(p,inv(tmp)));
		ans.Out();
	}
	else if (k==4){
		tmp=mul(tmp,mul(qr,mul(p,mul(q,pr))));
		P ans=mul(tmp,mul(q,inv(tmp)));
		ans.Out();
	}
	else if (k==5){
		tmp=mul(tmp,mul(qr,mul(p,mul(q,pr))));
		P ans=mul(tmp,mul(mul(pr,q),inv(tmp)));
		ans.Out();
	}
	
	return 0;
} 

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  
  for(int i=0; i<N; i++){
    S.pop_back();
    
    int j = 0;
    while(j< S.size() / 2){
      if(S.size() %2 == 1){
        break;
      }
      if(S.at(j) != S.at(S.size() / 2 + j)){
        break;
      }
      j++;
    }
   if(j == S.size() / 2){
    cout << S.size() << endl;
    break;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;

void  solve(){
    int cnt=0,n;
    string s;
    cin>>n>>s;
    for(int i=1;i<n-1;i++)
        if(s[i-1] =='A'&&s[i]=='B'&&s[i+1]=='C') cnt++;
        cout<<cnt;
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=0
ans=[]
for _ in range(n):
  ans.append('a')
for i in range(m):
  s,c=map(int,input().split())
  if ans[s-1]!='a' and ans[s-1]!=str(c):
    a=-1
  ans[s-1]=str(c)
if ans[0]=='a' and n!=1:
  ans[0]='1'

if ans[0]=='0' and n!=1:
  a=-1
if ans[0]=='a' and n==1:
  ans[0]='0'
for j in range(n):
  if ans[j]=='a':
    ans[j]='0'
if a==-1:
  print(a)
else:
  print(''.join(ans))

Measured memory_bytes: 38384
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int count(int N)
{
        int cnt = 0;
        while (N % 2 == 0)
        {
                cnt++;
                N /= 2;
        }
        return cnt;
}

int main()
{
        string A;

        cin >> A;
        int start, end;
        rep(i, A.size())
        {
                if (A[i] == 'A')
                {
                        start = i;
                        break;
                }
        }
        for (int i = A.size() - 1; i >= 0; i--)
        {
                if (A[i] == 'Z')
                {
                        end = i;
                        break;
                }
        }

        cout << end - start + 1 << endl;
        return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#define MAX 1000
using namespace std;

int main()
{
	int i,count=0;
	int temp[MAX];
	string ss;


	while(1)
	{
		cin >> ss;

		if(ss=="0") break;
	
		for(i=0;i<ss.size();i++)
		{
			temp[i] = (int)ss[i]-48;
		}

		for(i=0;i<ss.size();i++)
		{
			count = count + temp[i];
		}

		cout << count << endl ;
		count = 0;

	}




	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005;
int a[N];
multiset<int> s;
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,m;
  cin>>n>>m;
  rep(i,1,n+1) cin>>a[i],s.insert(a[i]);
  while(m--)
    {
      auto it=*s.rbegin();
      s.erase(s.find(it));
      it/=2;
      s.insert(it);
    }
  ll ans=0;
  for(auto it:s)  ans+=it;
  cout<<ans<<endl;
  return 0 ;
}


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

int main() {
  int N;
  cin >> N;
  int start_t = 0, start_x = 0, start_y = 0;
  bool flg = true;
  for (int i = 0; i < N; ++i) {
    int end_t, end_x, end_y;
    cin >> end_t >> end_x >> end_y;
    int dif_t = end_t - start_t, dif_x = end_x - start_x, dif_y = end_y - start_y;
    if ((dif_t - dif_x - dif_y) % 2 != 0 || dif_t < dif_x + dif_y) {
      flg = false;
      break;
    }
    start_t = end_t, start_x = end_x, start_y = end_y;
  }
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

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

func isKaibun(s string) bool {
	for i := 0; i < len(s)/2; i++ {
		if s[i] != s[len(s)-1-i] {
			return false
		}
	}
	return true
}

func main() {
	scanner := makeWordScanner()
	s := eGetLine(scanner)
	a := isKaibun(s)
	b := isKaibun(s[:(len(s)-1)/2])
	c := isKaibun(s[(len(s)+3)/2-1:])
	if a && b && c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}

type ints []int

func ToString(slice []int) string {
	format := fmt.Sprint(slice)
	return fmt.Sprint(format[1 : len(format)-1])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
    int N; cin >> N;
	FOR(i, 1, 10) FOR(j, 1, 10) {
        if (i * j == N) {
            puts("Yes");
            return;
        }
    }
    puts("No");
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll x,a,b;
    cin>>x>>a>>b;
    if(abs(a-x)>abs(b-x)) cout<<"B"<<endl;
    else cout<<"A"<<endl;
}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    

    solve();


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define fr1(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define viii vector <pair<ll,pair<ll,ll> > >
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mp(i,j) make_pair(i,j)
#define fi first
#define se second
#define input(a,n) fr(i,0,n)cin>>a[i]
#define output(a,n) fr(i,0,n)cout<<a[i]<<endl
#define dbg cout<<"hurr"<<endl;
#define dbg2 cout<<"hurr2"<<endl;
#define md 1000000007
#define inf 999999999999999999
#define sp << " " <<
#define endl "\n"
#define pi 3.14159265358979323846
#define fixd(x) cout << fixed << setprecision(x);
#define sz size()
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
void solve(){
ll n,a;
cin>>n;
a=n%10;
if(a==2 || a==4 || a==5 || a==7 || a==9){
    cout<<"hon"<<endl;
    return;
}
if(a==0 || a==1 || a==6 || a==8){
    cout<<"pon"<<endl;
    return;
}
if(a==3){
    cout<<"bon"<<endl;
    return;
}

}
int main()
{   fast;
    ll t=1;
   // cin>>t;
    fr(zz,1,t+1){
    solve();
    }
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    map<ll, ll> mp;
    ll res = 0;
    rep(i, n){
        ll buf; cin >> buf;
        mp[buf]++;
    }
    for(auto m:mp){
        if(m.first <= m.second) res += m.second - m.first;
        else res += m.second;
    }
    cout << res;
    cout << endl;
    return 0;
}



Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>
#include <vector>
#define PB push_back
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const int MOD=1e9+7;
LLI modpow(LLI a,LLI b,LLI m){
    LLI ret=1;
    while(b>0){
        if(b&1)(ret*=a)%=m;
        (a*=a)%=m;
        b>>=1;
    }
    return ret;
}
vector<LLI> kaijo[2];
vector<LLI> gyaku[2];
void comb1(int k,LLI n,LLI m){
    kaijo[k].PB(1);
    FOR(i,1,n+1){
        kaijo[k].PB((kaijo[k][i-1]*i)%m);
    }
    FOR(i,0,n+1){
        gyaku[k].PB(modpow(kaijo[k][i],m-2,m));
    }
}
LLI comb2(int k,LLI n,LLI r,LLI m){
    return (((kaijo[k][n]*gyaku[k][n-r])%m)*gyaku[k][r])%m;
}
int main(void){
    int n; cin>>n;
    const int nmax=100010;
    int b[nmax][2]={};
    int st,en;
    FOR(i,0,n+1){
        int a; cin>>a;
        b[a-1][0]++;
        if(b[a-1][0]==2){
            st=b[a-1][1];
            en=i;
        }
        b[a-1][1]=i;
    }
    comb1(0,n+1,MOD);
    comb1(1,n+st-en,MOD);
    FOR(i,0,n+1){
        cout<<(comb2(0,n+1,i+1,MOD)-(i>n+st-en?0:comb2(1,n+st-en,i,MOD))+MOD)%MOD<<endl;
    }
}


Measured memory_bytes: 5236
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var T = parseInt(input[1].split(" ")[0]);
  var A = parseInt(input[1].split(" ")[1]);
  H = new Array(N);
  tmp= input[2].split(" ");
  var K=10000;
  var ans=0;
  for(i=0;i<N;i++){
    H[i]=parseInt(tmp[i]);
    var b = T-H[i]*0.006;
    if(Math.abs(A-b)<K){
      K=Math.abs(A-b);
      ans=i+1;
    }
  }
  var ans;
  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21192
/* AOJ 0082
 *
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0082
 *
 */

#include <stdio.h>


int c[8][8] = {
    {4,1,4,1,2,1,2,1},
    {1,4,1,2,1,2,1,4},
    {4,1,2,1,2,1,4,1},
    {1,2,1,2,1,4,1,4},
    {2,1,2,1,4,1,4,1},
    {1,2,1,4,1,4,1,2},
    {2,1,4,1,4,1,2,1},
    {1,4,1,4,1,2,1,2},
};

int main(){

    int p[8];
    int missed;
    int V;
    int pos;
    int mi,n;
    int i, j;
    int vi;

    while(scanf("%d %d %d %d %d %d %d %d", p, p+1, p+2, p+3, p+4, p+5, p+6, p+7)==8){
        missed = -1;
        for(i=0;i<8;i++){
            mi = 0;
            vi = 0;
            for(j=0;j<8;j++){
                n = p[j] - c[i][j];
                if(n > 0)
                    mi += n;
                vi *= 10;
                vi += c[i][j];
            }
            if(missed == -1){
                missed = mi;
                V = vi;
                pos = i;
            }else if(missed > mi){
                missed = mi;
                V = vi;
                pos = i;
            }else if(missed == mi){
                if(V > vi){
                    missed = mi;
                    V = vi;
                    pos = i;
                }
            }
        }
        printf("%d %d %d %d %d %d %d %d\n", 
                c[pos][0], c[pos][1], c[pos][2], c[pos][3], c[pos][4], c[pos][5], c[pos][6], c[pos][7]);
    }

    return 0;
}

Measured memory_bytes: 0
use whiteread::parse_line;

fn main() {
    let (n, a, b): (usize, usize, usize) = parse_line().unwrap();
    let ans;

    if n == 1 && a != b {
        ans = 0;
    } else if n == 1 || n == 2 {
        ans = 1;
    } else if a > b {
        ans = 0;
    } else if a == b {
        ans = 1;
    } else {
        ans = (b - a) * (n - 2) + 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N, W;
ll dp[105][100005];

int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> N >> W;
	vector<int> w(N), v(N);
	for(int i = 0; i < N; i++) {
		cin>>w[i]>>v[i];
	}
	
	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= W; j++) {
			if(i == 0) { if(j >= w[i]) dp[i][j] = v[i];}
			else if(j - w[i] >= 0) dp[i][j] = max(v[i] + dp[i-1][j-w[i]], dp[i-1][j]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	
	cout<<dp[N-1][W]<<endl;

    return 0;
}


Measured memory_bytes: 80128
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main(void){
 
  int n;
  cin >> n;
  int a[n];
  int flag = 0;
  
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a + n);
  
  for(int i = 0; i < n - 1; i++){
    if(a[i] == a[i + 1]){
      flag++;
    }

  }
  
  if(flag == 0){
    cout << "YES" << endl;
  }else{
	cout << "NO" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define maxn 1002333
using namespace std;
int vis[maxn];
int main() {
	int K;
	scanf("%d", &K);
	vis[7 % K] = 1;
	if(vis[0]) {
		puts("1");
	} else {
		bool flag = false;
		int cur = 7 % K;
		for(int i = 2; i <= K + 233; ++i) {
			cur = (cur * 10 + 7) % K;
			vis[cur] = i;
			if(cur == 0) {
				printf("%d\n", i);
				flag = true;
				break;
			}
		}
		if(!flag) puts("-1");
	}
	return 0;
}

Measured memory_bytes: 7712
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);

    ll n;
    cin>>n;
    ll a[n];
    multiset<ll> s1;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        s1.insert(a[i]);
    }

    for (int i = 0; i < n; ++i)
    {
        s1.erase(s1.lower_bound(a[i]));
        cout<<*s1.rbegin()<<endl;
        s1.insert(a[i]);
    }

    return 0;
}

Measured memory_bytes: 14492
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n,a[300005];
  ll ans=0;
  cin>>n;
  rep(i,n*3)cin>>a[i];
  sort(a,a+n*3);reverse(a,a+n*3);
  for(int i=1;i<n*2;i+=2)ans+=a[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 1408
# https://img.atcoder.jp/abc131/editorial.pdf

import sys

n, k = map(int, input().split())

maxPossible = (n-2) * (n-1) // 2

if k > maxPossible:
    print(-1)
    sys.exit()
ret = []

# うに(1が中心)
for i in range(2, n+1):
    ret.append((1, i))

# maxPossible - k 個の辺を追加
count = 0
for i in range(2, n+1):
    if count == maxPossible - k:
        break
    for j in range(i+1, n+1):
        ret.append((i, j))
        count += 1
        if count == maxPossible - k:
            break

print(len(ret))
for u, v in ret:
    print(u, v)


Measured memory_bytes: 3992
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e7+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)


int main()
{
    
    int x,n;
    scf(x),scf(n);
    
    set<int>s;
    
    rep(i,0,n)
    {
        int a;
        scf(a);
        
        s.insert(a);
    }
    
    int m=0,z=0,d1=1e6,d2=1e7;
    
    for(int i=x;i>=-100;i--)
    {
        if(s.find(i)==s.end())
        {m=i;
        d1=abs(x-i);
        break;}
        
    }
    
    rep(i,x,102)
    {
        
         if(s.find(i)==s.end())
        {   z=i;
            d2=abs(x-i);
            break;
            
        }
    
    }
    
    if(d1<=d2)
    prin(m);

    else
    prin(z);
        
    
    
}

Measured memory_bytes: 3752
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll>a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(all(a));
    ll sm = 0;
    rep(i,max(0,n-k)){
        sm += a[i];
    }
    cout << sm << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc133_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N, A, B;
  cin >> N >> A >> B;
  
  ll ans = min(A * N, B);

  cout << ans << endl;
}

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

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int N;
  int X;
  cin >> N >> X;
  int sum = 0;
  int min_m = 1000;
  for(int ii=0; ii<N; ii++){
    int m;
    cin >> m;
    X -= m;
    sum++;
    min_m = min(min_m, m);
  }
  sum += (X / min_m);
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
int main() {
    string ans="Yes";

    int N; cin >> N;

    ll a_bigger_than_b=0LL, b_bigger_than_a=0LL;
    vector<ll>a(N),b(N);
    rep(i,N){
        cin >> a[i];
    }
    rep(i,N){
        cin >> b[i];
    }
    rep(i,N){
        if(a[i]>b[i]){
           a_bigger_than_b+=(a[i]-b[i]);
        }else{
           b_bigger_than_a+=(b[i]-a[i])/2;
        }
    }

    if(a_bigger_than_b>b_bigger_than_a){
        ans="No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
from collections import Counter

n = int(input())
s = input()

c = Counter(s)
ans = c['R'] * c['G'] * c['B']

for d in range(1, n//2 + 1):
    i = 0
    j = d
    k = 2*d
    while k < n:
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
        i += 1
        j += 1
        k += 1

print(ans)


Measured memory_bytes: 68812
#include "bits/stdc++.h"
using namespace std;
#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
const long long INF = 1LL << 60;
typedef long long ll;

int main()
{
	int i, j; cin >> i >> j;
	cout << i - j + 1 << endl;
}


Measured memory_bytes: 256
n = int(input())
a = input().split()

alice = 0
bob = 0
fnum = 0
snum = 0

for i in range(int((n + 1)/2)):
    fir = 0
    sec = 0
    for j in range(int(n - i * 2)):
        if int(a[j]) > fir:
            sec = fir

            fir = int(a[j])
        elif int(a[j]) > sec:
            sec = int(a[j])
    alice += fir
    bob += sec
    a.remove(str(fir))
    if sec == 0:
        break
    else:
        a.remove(str(sec))

print(alice - bob)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			for(int i=1;;i++) {
				int buf = sc.nextInt();
				if(buf == 0) break;
				System.out.println(String.format("Case %d: %d", i, buf));
			}
		}
	}
}


Measured memory_bytes: 58256
def chmin(a, b) a < b ? a : b end
  a,b,c,x,y = gets.split.map(&:to_i)
  
  if x < y
    x,y = y,x
    a,b = b,a
  end
  
  
  min_mix = chmin(a+b,2*c)
  min_a = chmin(a, 2*c)
  s = min_mix * y + (x-y)*min_a
  puts s

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

int main() {
  int x, y; cin >> x >> y;
  bool ok = false;
  for (int i = 0; i < 100; ++i) {
    for (int j = 0; j < 100; ++j) {
      if (i + j == x && i*2 + j*4 == y) ok = true;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3584
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
count = 0

if sum(a) == 0:
    print(0)
    exit()


for i in range(1, n+1):
    if i == n:
        if a[0] == 1 and sum(b) % 2 == 0:
            b[0] = 1
            count += 1
        elif a[0] == 0 and sum(b) % 2 == 1:
            b[0] = 1
            count += 1
    elif a[n-i] == 1 and sum(b[n-i::n-i+1]) % 2 == 0:
        b[n-i] = 1
        count += 1
    elif a[n-i] == 0 and sum(b[n-i::n-i+1]) % 2 == 1:
        b[n-i] = 1
        count += 1


if count == 0:
    print(-1)
else:
    print(count)
    for i in range(len(b)):
        if b[i] == 1:
            print(i+1, end=' ')

Measured memory_bytes: 8256