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


using namespace std;

int main(){
    int n,K;
    cin >> n >> K;
    vector <int> x(n),y(n);
    vector <int> xary,yary;

    for(int i=0; i<n; i++){
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }
    sort(begin(xary),end(xary));
    sort(begin(yary),end(yary));
    long long int ans = 1LL *(xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=0; k<n; k++){
                for(int l=k+1; l<n; l++){
                    int count = 0;
                    long long lx = xary[i], rx = xary[j];
                    long long by = yary[k], uy = yary[l];
                    for(int m=0; m<n; m++){
                        if(lx <= x[m] && x[m] <= rx && by <= y[m] && y[m] <= uy)count++;
                    }
                    if(count >= K) ans = min(ans,1LL *(rx - lx) * (uy - by));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict';

const main = input => {
  input = input.split('\n');
  const n = Number(input.shift());
  const dic = new Hash();
  for (let i = 0; i < n; ++i) {
    const tmp = input[i].split(' ');
    const c = tmp[0];
    const key = getKey(tmp[1]);
    if (c === 'insert') {
      dic.insert(key);
    } else {
      console.log(dic.search(key) ? 'yes' : 'no');
    }
  }
};

function getChar(ch) {
  if (ch === 'A') return 1;
  else if (ch === 'C') return 2;
  else if (ch === 'G') return 3;
  else if (ch === 'T') return 4;
}

function getKey(str) {
  // let sum = 0;
  // let p = 1;
  // for (let i = 0; i < str.length; i++) {
  //   sum += p * getChar(str[i]);
  //   p *= 5;
  // }
  return parseInt(
    str
      .split('')
      .map(getChar)
      .join(''),
    5
  );
}

const M = 1046527;

class Hash {
  constructor() {
    this.T = [];
  }
  insert(key) {
    let i = 0;
    // eslint-disable-next-line no-constant-condition
    while (true) {
      const j = h(key, i);
      if (!this.T[j]) {
        this.T[j] = key;
        return j;
      } else {
        ++i;
      }
    }
  }
  search(key) {
    let i = 0;
    // eslint-disable-next-line no-constant-condition
    while (true) {
      const j = h(key, i);
      if (this.T[j] === key) {
        return j;
      } else if (this.T[j] === undefined || i >= M) {
        return undefined;
      } else {
        ++i;
      }
    }
  }
}

function h1(key) {
  return key % M;
}

function h2(key) {
  return 1 + (key % (M - 1));
}

function h(key, i) {
  return (h1(key) + i * h2(key)) % M;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 245252
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  REP(i, D) {
    cin >> p[i] >> c[i];
  }

  int mask = 0, result = 1e9;
  for (mask=0; mask<(1<<D); ++mask) {
    int point = 0, num = 0, rest_max = -1;
    for (int i=0; i<D; ++i) {
      if (mask >> i & 1) {
        point += (i+1)*p[i]*100 + c[i];
        num += p[i];
      } else {
        rest_max = i;
      }
    }
    if (point < G) {
      int d = (rest_max+1)*100;
      int need = (G - point + d - 1) / d;
      if (need >= p[rest_max]) continue;
      num += need;
    }
    result = min(result, num);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,x[MAX],m,d[MAX],ans[MAX],tmp[MAX];ll K;
double a[MAX];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)x[i]=read();
	m=read();cin>>K;
	for(int i=1;i<=n;++i)d[i]=i,ans[i]=i;
	for(int i=1;i<=m;++i)
	{
		int x=read();
		swap(d[x],d[x+1]);
	}
	while(K)
	{
		if(K&1)
		{
			for(int i=1;i<=n;++i)tmp[i]=ans[d[i]];
			for(int i=1;i<=n;++i)ans[i]=tmp[i];
		}
		for(int i=1;i<=n;++i)tmp[i]=d[d[i]];
		for(int i=1;i<=n;++i)d[i]=tmp[i];
		K>>=1;
	}
	for(int i=1;i<=n;++i)a[i]=x[ans[i]]-x[ans[i]-1];
	for(int i=1;i<=n;++i)printf("%.1lf\n",a[i]+=a[i-1]);
	return 0;
}

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

typedef long long ll;
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(c) c.begin(),c.end()
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
#define pu push
#define pb push_back
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
const ll MOD = 1000000007;
const int inf = 1000000001;
const ll INF = 1e16;
ll i,j,k;
// #define max 105

int main(){
    fio();
    ll a,b;
    cin>>a>>b;
    cout<<(a+b)%24;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define debug(x_) cerr << #x_ << ":" << x_ << endl;
#define debug2(x__) for(auto a__ : x__) cerr << a__ << " "; cerr << endl;
#define debug3(x___ , sx___) rep(i, sx___) cerr << x___[i] << " "; cerr << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[3];
    rep(i, 3) cin >> a[i];
    sort(a, a + 3);
    cout << a[0] + a[1] + a[2]*10 << endl;
    return 0;
}



Measured memory_bytes: 256
N = int(input())
s1 = input()
s2 = input()

MOD = int(1e9) + 7

tate = "tate"
yoko = "yoko"

i = 0
ans = 0
pre = ""
if s1[i] == s2[i]:
    ans = 3
    i += 1
    pre = tate
else:
    ans = 6
    i += 2
    pre = yoko

while i < N:
    if s1[i] == s2[i]:
        if pre == tate:
            ans *= 2
        elif pre == yoko:
            ans *= 1
        i += 1
        pre = tate
    else:
        if pre == tate:
            ans *= 2
        elif pre == yoko:
            ans *= 3
        i += 2
        pre = yoko
    ans %= MOD
print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
int answer=0;
cin>>a>>b;
  for(int i=0;i<2;i++)
  {
    if(a>=b)
	{
      answer+=a;
      a--;
	}
	else
	{
      answer+=b;
      b--;
    }
  }
cout<<answer<<endl;
return 0;
}

Measured memory_bytes: 256
N = int(input())
xu = [[] for _ in range(N)]
for i in range(N):
    xu[i] = list(input().split())
    xu[i][0] = float(xu[i][0])
for i in xu:
    if i[1] == 'BTC':
        i[0] = i[0]*380000.0
print(sum(x[0] for x in xu))

Measured memory_bytes: 3060
#include <set>
#include <cstdio>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int dist[100][100];
int p[100];
int k[100];
const int MAX = 100000000;

typedef vector<vector<int> > G;

int flow(G &g, int s, int d){
  int n = g.size();
  int ans = 0;

  while(true){
    vector<int> prevs(n,-1);
    queue<int> q;
    bool ok = false;
    
    prevs[s]=n;
    q.push(s);
    while(!q.empty()){
      int now = q.front();
      q.pop();
      if(now == d){
        ok = true;
        break;
      }
      for(int i=0;i<n;i++){
        if(g[now][i]>0){
          if(prevs[i]==-1){
            prevs[i]=now;
            q.push(i);
          }
        }
      }
    }

    if(!ok) return ans;

    int f = MAX;
    int pos = d;
    while(pos != s){
      int pos2 = prevs[pos];
      f = min(f,g[pos2][pos]);
      pos = pos2;
    }
    pos = d;
    while(pos != s){
      int pos2 = prevs[pos];
      g[pos2][pos]-=f;
      g[pos][pos2]+=f;
      pos = pos2;
    }
    ans += f;
  }
}

int main(){
  int n, m, l;
  while(~scanf("%d%d%d", &n, &m, &l)){
    G g(2 * n + 2, vector<int>(2 * n + 2, 0));
    const int source      = 2 * n;
    const int distination = 2 * n + 1;

    REP(i,n) REP(j,n) dist[i][j] = MAX;
    REP(i,n) dist[i][i] = 0;
    REP(i,m){
      int a, b, d;
      scanf("%d%d%d", &a, &b, &d);
      a--; b--;
      dist[a][b] = dist[b][a] = d;
    }

    REP(k,n) REP(i,n) REP(j,n)
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    REP(i,n) scanf("%d", p + i);
    REP(i,n) scanf("%d", k + i);

    REP(i,n) REP(j,n) if(dist[i][j] < l){
      g[i][n + j] = MAX;
    }

    REP(i,n){
      g[source][i]          = p[i];
      g[n + i][distination] = k[i];
    }

    printf("%d\n", flow(g, source, distination));
  }
  return 0;
}

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

class P
{
public:
	int first, second;
	P(int a = 0, int b = 0):first(a),second(b){}

	bool operator < (const P &ano) const{
		if(first != ano.first){
			return first < ano.first;
		}
		else 
			return second > ano.second;
	}

};

int n,m;

void solve()
{
	vector<P> d(m);
	int in;

	for(int i = 0; i < m; i++){
		d[i].first = 0;
		d[i].second = i+1;
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> in;
			if(in)
				d[j].first++;
		}
	}
	sort(d.begin(), d.end());

	cout << d[m-1].second;
	for(int i = m-2; i >= 0; i--)
		cout << ' ' << d[i].second;
	cout << endl;

}

	

int main(void)
{
	while(cin >> n >> m, n | m)
		solve();
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<30
#define ALEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

ll gcd(ll a, ll b) {
    if(a < b) swap(a, b);
    while(b > 0) {
        int r = a % b;
        a = b;
        b = r;
    }
    return a;
}

ll lcm(ll a, ll b) {
    if(a == 0 || b == 0) {
        cout << "Error" << endl;
        return 0;
    }

    return (a * b / gcd(a, b));
}

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

  ll a, b;
  while(cin >> a >> b) cout << gcd(a, b) << " " << lcm(a, b) << endl;

  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr1[52],arr2[52];
    int n,c=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr1[i];
    }
    for(int j=1; j<=n; j++)
    {
        arr2[j-1]=j;
    }
    for(int k=0; k<n; k++)
    {
        if(arr1[k]!=arr2[k])
        {
            c++;
        }
    }
    if(c==0 || c==2)
        cout<<"YES"<<endl;
    else
        cout<<"NO\n"<<endl;


}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define max(a,b) ((a<b) ? (b):(a))

int main(void){
	int n;
	int i;
	int x[100];
	int y[100];
	double one=0.0,two=0.0,three=0.0,inf=0.0;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&x[i]);
	for(i=0;i<n;i++) scanf("%d",&y[i]);
	
	for(i=0;i<n;i++) one += fabs((double)x[i] - (double)y[i]);
	for(i=0;i<n;i++) two += ((double)((double)x[i] - (double)y[i])*(double)((double)x[i] - (double)y[i]));
	for(i=0;i<n;i++) inf = max(fabs((double)x[i] - (double)y[i]),inf);
	for(i=0;i<n;i++) three += fabs((double)((double)x[i] - (double)y[i])*(double)((double)x[i] - (double)y[i])*(double)((double)x[i] - (double)y[i]));
	printf("%.7lf\n",one);
	printf("%.7lf\n",sqrt(two));
	printf("%.7lf\n",cbrt(three));
	printf("%.7lf\n",inf);
	return 0;
}

Measured memory_bytes: 656
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
int N,K;
cin>>N>>K;
int A[N];
rep(i,N){
    cin>>A[i];
}
sort(A,A+N);
int ans=0;
rep(i,K){
    ans+=A[i];
}
cout<<ans<<endl;
return 0;
}

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

int main() {
  int N;
  cin >> N;
  int V[N], C[N];

  for (int i = 0; i < N; i++) {
    cin >> V[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> C[i];
  }

  int ans = 0;

  for (int i = 0; i < N; i++) {
    if (V[i] - C[i] > 0) {
      ans += (V[i] - C[i]);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <utility>
using namespace std;

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  --x1,--y1,--x2,--y2;
  vector<string> C(H);
  for(int i = 0; i < H; ++i){
    cin >> C[i];
  }
  const int INF = 1e9;
  vector D(H,vector(W,vector(4,pair<int,int>(INF,0))));
  using tup = tuple<int,int,int,int,int>;//const, dir, h, w, k
  // deque<tup> Q;
  priority_queue<tup,vector<tup>,greater<>> Q;
  for(int i = 0; i < 4; ++i){
    // Q.emplace_back(1,i,x1,y1,K);
    Q.emplace(1,i,x1,y1,K);
    D[x1][y1][i] = {1,K};
  }
  const int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
  while(Q.size()){
    // auto [c, d, h, w, k] = Q.front();
    auto [c, d, h, w, k] = Q.top();
    // Q.pop_front();
    Q.pop();
    if(D[h][w][d].first < c or (D[h][w][d].second > k)) continue;
    if(!k) d = -1;
    for(int i = 0; i < 4; ++i){
      int h_ = h + dx[i], w_ = w + dy[i];
      if(h_ < 0 or h_ >= H) continue;
      if(w_ < 0 or w_ >= W) continue;
      if(C[h_][w_] == '@') continue;
      int c_ = c + (i != d);
      int k_ = (k > 0 and i == d ? k-1 : K-1);
      if(D[h_][w_][i].first > c_ or (D[h_][w_][i].first == c_ and D[h_][w_][i].second < k_)){
        D[h_][w_][i] = {c_,k_};
        tup t = {c_,i,h_,w_,k_};
        if(c_ == c){
          // Q.push_front(t);
          Q.push(t);
        }else{
          // Q.push_back(t);
          Q.push(t);
        }
      }
    }
  }
  int ans = INF;
  for(int i = 0; i < 4; ++i)
    ans = min(ans,D[x2][y2][i].first);
  if(ans >= INF) ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 144880
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner Sc =new Scanner(System.in);
        int a = Sc.nextInt();
        int b = Sc.nextInt();
        int c = Sc.nextInt();

        if(a < b && b < c){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26400
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/


signed main() {
	int n; cin >> n;
	if (n % 2) {
		cout << n - 1 + (n - 1)*(n - 3) / 2 << endl;
		for (int i = 1; i < n; i++) {
			cout << i << " " << n << endl;
		}
		for (int i = 1; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (i + j != n)cout << i << " " << j << endl;
			}
		}
	}
	else {
		cout << n * (n - 2) / 2 << endl;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (i + j != n + 1)cout << i << " " << j << endl;
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();
		if (S<=W) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
		
		
      	sc.close();
    }
		
		
}


Measured memory_bytes: 27084
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i=(begin);i<=(end);i++)
#define REP(i, n) FOR(i,1,n)
#define IFOR(i, begin, end) for(ll i=(end);i>=(begin);i--)
#define IREP(i, n) IFOR(i,1,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())

#define ll long long
using namespace std;

int main()
{
	stringstream ss;
    // 入力
    ll N;
    cin>>N;
    int k=-1;

    for(int i=1;i*(i-1)/2<=N;i++){
        // cout<<i*(i-1)/2<<endl;
        if(i*(i-1)/2==N) {
            k=i;
            break;
        }
    }
    if(k==-1) {
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    cout<<k<<endl;
    
    ll id=1;
    ll S[k+1][k+1];
    FOR(i,1,k){
        FOR(j,i+1,k){
            S[i][j]=id;
            S[j][i]=id;
            id++;
        }
    }

    FOR(i,1,k){
        cout<<k-1<<" ";
        FOR(j,1,i-1){
            cout<<S[i][j]<<" ";
        }
        FOR(j,i+1,k-1){
            cout<<S[i][j]<<" ";
        }
        if(i<k) cout<<S[i][k]<<endl;
    }

    return 0;
}

Measured memory_bytes: 2944
n = int(input())
c = {
    'S': [0]*13,
    'H': [0]*13,
    'C': [0]*13,
    'D': [0]*13
}
for i in range(n):
    s, num = input().split()
    c[s][int(num)-1] = 1

for i in ["S", 'H', 'C', 'D']:
    for j in range(13):
        if c[i][j] == 0:
            print(i, j+1)


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

#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);
	int n, x;
	cin >> n >> x;
	vi v(n);
	REP(i, n)cin >> v[i];
	ll pos = 0;
	int cnt = 1;
	REP(i, n) {
		pos += v[i];
		if (x >= pos)cnt++;
	}
	cout << cnt << endl;
}


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

int main(){
  int i;
  int j;
  int change;
  int num = 0;
  int count = 0;
  int flag = 1;
  int *data;

while(1){
scanf("%d",&num);
if(1 <= num && num <= 100){
  break;
}
}
data = (int *)malloc(sizeof(int)*num);

for(j = 0;j < num;j++){
  while(1){
  scanf("%d",&data[j]);
  if(data[j] >= 0 && data[j] <= 100){
    break;
  }
}
}

  while(flag){
    flag = 0;

for(i = num - 1;i > 0;i--){
  if(data[i] < data[i - 1]){
    change = data[i];
    data[i] = data[i - 1];
    data[i - 1] = change;
    flag = 1;
    count++;
  }
  }
}

for(i = 0;i < num-1;i++){
  printf("%d ",data[i]);
}
printf("%d",data[num - 1]);
printf("\n");
printf("%d",count);
printf("\n");
return 0;
}



Measured memory_bytes: 2124
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)


const double inf = 10000;
const double eps = 1e-11;

double f(double x,double a,double b,double c,double d){
  return a*x*x*x+b*x*x+c*x+d;
}

double bsearchdec(double l,double r,double a,double b,double c,double d){
  double mid;
  rep(i,200){
    mid = (l+r)/2;
    if (f(mid,a,b,c,d) > 0)l=mid;
    else r=mid;
  }
  return mid;
}

double bsearchinc(double l,double r,double a,double b,double c,double d){
  double mid;
  rep(i,200){
    mid = (l+r)/2;
    if (f(mid,a,b,c,d) >0)r=mid;
    else l=mid;
  }
  return mid;
}

pair<double,double> qu(double a,double b,double c){
  double tmp = sqrt(b*b-4*a*c+0);
  double waru=2*a;
  return make_pair((-b-tmp)/waru,(-b+tmp)/waru);
}

main(){
//   for(double i=-100;i<=100;i+=0.001){
//     double tmp = f(i,1,3,3,1);
//     if (fabs(tmp) < 1e-10)cout << i << endl;
//   }
//   return 0;
  double a,b,c,d;
  int te;
  cin>>te;
  while(te--){
    cin>>a>>b>>c>>d;
    int neg=0,pos=0;
    if (4*b*b - 12*a*c < 0){
      //      cout <<"no info" << endl;
      double ans;
      if (a > 0)ans=bsearchinc(-inf,inf,a,b,c,d);
      else if (a < 0)ans=bsearchdec(-inf,inf,a,b,c,d);
      if (fabs(f(ans,a,b,c,d))>1e-10||fabs(ans)<1e-10);
      else if (ans > 0)pos++;
      else if (ans < 0)neg++;      
    }else {
      pair<double,double> ahoge=qu(3*a,2*b,c);
      //cout << ahoge.first <<" " << ahoge.second << endl;
      if (ahoge.first > ahoge.second)swap(ahoge.first,ahoge.second);
      double tmp[3];
      if (a > 0){
	tmp[0]=bsearchinc(-inf,ahoge.first,a,b,c,d);
	tmp[1]=bsearchdec(ahoge.first,ahoge.second,a,b,c,d);
	tmp[2]=bsearchinc(ahoge.second,inf,a,b,c,d);
      }else if(  a < 0){
	//cout <<"test " << endl;
	tmp[0]=bsearchdec(-inf,ahoge.first,a,b,c,d);
	tmp[1]=bsearchinc(ahoge.first,ahoge.second,a,b,c,d);
	tmp[2]=bsearchdec(ahoge.second,inf,a,b,c,d);
      }
      rep(i,3){
	//printf("%d %.15lf %.15lf\n",i,tmp[i],f(tmp[i],a,b,c,d));
	bool flag=true;
	if (fabs(f(tmp[i],a,b,c,d))>1e-10 || fabs(tmp[i]) < 1e-10)continue;
	if (tmp[i] > 0){
	  pos++;
	}else if (tmp[i] < 0){
	  neg++;
	}
      }
    }
    cout << pos <<" " << neg << endl;
  }

  return false;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
const int maxn=2e3+10;
const LL mod=1e9+7;
int a[maxn],b[maxn];LL dp[maxn][maxn];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=0;i<m;i++) scanf("%d",&b[i]);
	for(int i=0;i<=n;i++) dp[i][0]=1;
	for(int i=0;i<=m;i++) dp[0][i]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			dp[i+1][j+1]=(dp[i][j+1]%mod+dp[i+1][j]%mod-dp[i][j])%mod;
			if(a[i]==b[j]) dp[i+1][j+1]+=dp[i][j];
			dp[i+1][j+1]=(dp[i+1][j+1]+10*mod)%mod;
		}
	}
	cout<<(dp[n][m]%=mod);
}

Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N,T, tt; ll ans=0;cin>>N>>T;
    vector<ll> t;
    for(int i=0; i<N;i++){
      cin>>tt; t.push_back(tt);
    }
    if(N==1){
      cout<<T<<endl; return 0;
    }

    for(int i=0; i<N-1;i++){
      ll d=t[i+1] -t[i];
      if(d<=T) ans+=d;
      else ans += T;
    }
    ans+=T;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
char a[4][4];
inline int read()
{
	int num=0,f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar())
	if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
	num=(num<<1)+(num<<3)+c-48;
	return num*f;
}
void init()
{
	for(int i=1;i<=3;++i)
		for(int j=1;j<=3;++j)cin>>a[i][j];
}
void work()
{
	cout<<a[1][1]<<a[2][2]<<a[3][3];
}
int main()
{
	init();
	work();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        String t;
        String wk;
      
        t = s.substring(n/2);
        wk = t + t;
      	
      	if (wk.equals(s)) {
          System.out.print("Yes");
        } else {
          System.out.print("No");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); ++i)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define DEB 0

map<pair<char,int>,int> memo;
int array[256];

int parse_cur(string in){
#if DEB
  cout << "parse_cur: " << in << endl;
#endif
  
  if( '0'<=in[0] && in[0]<='9' ){ // number
    return atoi(in.c_str());
  }else{
    char ar = in[0];
    int x = 0;
    int k;
    for(k=1; k<in.size(); k++){
      if( in[k]=='[' )x++;
      if( in[k]==']' )x--;
      if( x==0 ) break;
    }
    if( k==in.size() ) { puts("okasii"); exit(0); }
    // a[12344]
    // 0123456k
    string tmp = in.substr(2, k-2);
    int d = parse_cur(tmp);
    if( array[ar] <= d ) return -1; // failed
    if( memo.count(mp(ar,d))==0 ) return -1; //failed
    return memo[mp(ar,d)];
  }
}
pair<char,int> parse_where(string in){
#if DEB
  cout << "parse_where: " << in << endl;
#endif
  
  char ar = in[0];
  // a[123]
  // 012345
  int d = parse_cur(in.substr(2,in.size()-3));

  if( d==-1 ) return mp(-1,-1); //failed
  if( array[ar] <= d ) return mp(-1,-1);

  return mp(ar,d);
}

int main(){
  string in;
  while(cin>>in,in!="."){
    // init
    memo.clear();
    memset(array,-1,sizeof(array));
    
    vector<string> vs;
    vs.pb(in);
    while(cin>>in,in!=".")vs.pb(in);

    // ツ静ゥツ個セ
    int i;
    for(i=0; i<vs.size(); i++){
      if( vs[i].find("=") == string::npos ){
        char ar;
        int len;
        sscanf(vs[i].c_str(),"%c[%d]",&ar,&len);
#if DEB
        printf("%c[%d]\n",ar,len);
#endif
        array[ar] = len;
      }else{ // ツ妥」ツ禿シ
        int p = vs[i].find("=");
        
        int d = parse_cur(vs[i].substr(p+1)); //naniwo
        if( d==-1 ){
          break;
        }

        // a[12]=
        // 01234p
        pair<char, int> pr = parse_where(vs[i].substr(0,p)); //dokoni
        if( pr.first==-1 && pr.second==-1 ){
          break;
        }

        memo[pr] = d;
        
      }
    }
    if( i==vs.size() ){
      puts("0");
    }else{
      printf("%d\n",i+1);
    }
  }
  return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    const int MX = 3550;
    ll n; cin >> n;
    
    if(n%2 == 0){
        cout << n/2 << " " << n << " " << n << endl;
        return;
    }
    
    rep3(x, 1, MX){
        rep3(y, 1, MX){
            ll nume = n * x * y;
            ll deno = 4*x*y - n*x - n*y;
            if(deno <= 0) continue;
            if(nume % deno == 0 && nume / deno <= MX){
                cout << nume/deno << " " << x << " " << y << endl;
                return;
            }
        }
    }

    return;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}
template<typename T>
void maxi(T &a, T &b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T &b) {
	a = min(a, b);
}

int main() {
	int ans1 = 0;
	int ans2 = 0;
	int N, M, X;
	cin >> N >> M >> X;
	rep(M) {
		makei(a);
		if (a < X)++ans1;
		else ++ans2;
	}
	say(min(ans1, ans2));
}

Measured memory_bytes: 256
n, m = input().split()
b = input().split()
sum = 0
for x in b:
    sum += int(x)
yy=0
for y in b:
    if int(y) >= sum/(4*int(m)):
        yy+=1
if yy < int(m):
    print("No")
else:
    print("Yes")

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

int main(){
    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<ll> p(A), q(B), r(C);
    rep(i, 0, A) cin >> p[i];
    rep(i, 0, B) cin >> q[i];
    rep(i, 0, C) cin >> r[i];

    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    priority_queue<ll, vector<ll>, greater<ll>> que;
    
    ll sum = 0;
    
    rep(i, 0, X){
        sum += p[i];
        que.push(p[i]);
    }

    rep(i, 0, Y){
        sum += q[i];
        que.push(q[i]);
    }

    ll ri = 0;
    rep(i, 0, min(X+Y,C)){
        auto t = que.top();
        //cerr << t << " " << r[ri] << endl;
        if(t < r[ri]){
            sum -= t;
            sum += r[ri];
            que.pop();
            que.push(r[ri]);
            ri++;
        }else{
            break;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4724
// @skylag
//I am into me now ;)
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int
int power(int a,int n,int m)
{
    int res=1;
    while(n)
    {
        if(n&1)
        {
            res=((res)*(a));
            n--;
        }
        else
        {
            a=((a)*(a));
            n/=2;
        }
    }
    return res;
}

void solve(int t)
{
    
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    a[0]=1;
    vector<bool> ans;
    int dp[n+1];
    dp[0]=1;
    for(int i=k+1;i<=n;i++)
    {
        if(a[i]>a[i-k])
            cout<<"Yes\n";
        else cout<<"No\n";
    }

}
int32_t main()
{
    SKY;
    //freopen("/Users/skylags/Desktop/input.txt","r",stdin);
    //freopen("/Users/skylags/Desktop/output.txt","w",stdout);
    int t=1;
    //cin>>t;
    int flag=1;
    while(t--)
    {
        solve(flag);
        flag++;
    }
}
/*Codechef July Lunchtime (Div.2)*/
//cout<<"Case #"<<t<<":"<<"\n";
//int n;
//cin>>n;
//vector<pair<int,int>> v(n);
//for(int i=0;i<n;i++)
//{
//    cin>>v[i].F>>v[i].S;
//}
//int ans=0;
//int temp=0;
//sort(ALL(v));
//int start=0;
//unordered_map<int,int> forward,backward;
//for(int i=0;i<n;i++)
//{
//
//}
//while(1)
//{
//    int temp=0;
//    for(int i=start;i<n;i++)
//    {
//        temp+=v[i].S;
//
//    }
//}
//ans=max(ans,v[n-1].S);
//cout<<ans<<"\n";


Measured memory_bytes: 5192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC145A
{
    class Program
    {
        static void Main(string[] args)
        {
            int r, s;

            r = int.Parse(Console.ReadLine());

            s = (r * r) / 1;

            Console.WriteLine(s);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
n = gets.to_i
a = gets.chomp.split(/\s/).map { |x| x.to_i }.sort_by { |x| x }

if a[0] == 0 then
  puts 0
  return
end

y = 1
a.reverse_each do |x|
  y *= x
  if y > 1_000_000_000_000_000_000 then
    y = -1
    break
  end
end

puts y


Measured memory_bytes: 26308
a, b, x = gets.chomp.split(" ").map(&:to_f)
theta = 0.0
capacity = a * a * b

if (capacity / 2.0) < x then
    theta = Math.atan(2.0 * (capacity - x) / a**3)
else
    theta = Math.atan((a * b * b) / (2.0 * x))
end

puts theta * 180.0 / Math::PI

Measured memory_bytes: 3836
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL  INF=1<<31;
const LL MOD=1000000007;



int main(){
     int n;
     int a[100010]={0};
     cin>>n;
     for(int i=0;i<n;++i){
          int u;cin>>u;
           a[u]++;
     }
     bool han=true;
     if(n%2==1){
          if(a[0]!=1){
               han=false;
          }
     }
     if(n%2==0){
          if(a[0]!=0){
               han=false;
          }
     }
     for(int i=1;i<=n-1;++i){
          if(n%2==1){
               if(i%2==0){
                    if(a[i]!=2)han=false;
               }
               if(i%2==1){
                    if(a[i]!=0)han=false;
               }
          }
          if(n%2==0){
               if(i%2==0){
                    if(a[i]!=0)han=false;
               }
               if(i%2==1){
                    if(a[i]!=2)han=false;
               }
          }

     if(!han)break;
     }

     if(!han)cout<<0<<endl;
     else{
          int aaa=n/2;
          int ans=1;
          for(int i=0;i<aaa;++i){
               ans=(ans*2)%MOD;
          }
          cout<<ans<<endl;
     }


}
     

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 1000000000
#define MOD 1000000007
#define ll long long
using namespace std;

int main(){
    int n;
    ll ans;
    int a;
    cin>>n;
    rep(i,n){
        cin>>a;
        (ans+=a)%=2;
    }
    if (ans==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

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

using namespace std;
int a[110];

int main()
{
    int n,x;  cin >> x >> n;
    for(int i = 0;i<n;i++)  cin >> a[i];
    int Min = 1e9,Ans;
    for(int i = x - n - 1;i<=x + n + 1;i++){
        bool flag = true;
        for(int j = 0;j<n;j++){
            if(a[j] == i)  flag = false;
        }
        if(flag){
            if(abs(i - x) < Min){
                Min = abs(i - x);
                Ans = i;
            }
        }
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define For(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>  
#define vf vector<float>
#define pi (int,int)
#define vpi vector<pair<int,int>>
#define vs vector<string>
#define mp make_pair
#define ll long long
#define vc vector<char>
#define rng(x) x.begin(),x.end()
#define b(x) x.begin()
#define e(x) x.end()
#define F first
#define S second
#define me max_element
#define ne min_element
const int N=(1e5+2);
using namespace std;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  
  ll n,d,x,y,c=0;
  cin>>n>>d;
  while(n--)
  {
    cin>>x>>y;
    if(((x*x)+(y*y))<=(d*d)) c++;
  }
  cout<<c;
  return 0;
}


        

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		// Sを1回転させる。Tと一致したらYesしてbreak
		String result = "No";
		String s_turned = s;
		for (int i = 0; i < s.length(); i++) {
			char c1 = s_turned.charAt(0);
			String s_temp = s_turned.substring(1);
			s_turned = s_temp + c1;
			if (s_turned.equals(t)) {
				result = "Yes";
				break;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef long long llint;
typedef vector<long long int> vint;
typedef vector< vector<int> > vvint;
typedef vector<string> vstr;


int main(void) {
	string S;
	cin >> S;
	llint N,A,B;
	A = 0;
	B = 0;
	N = S.length();
	vint a(N),b(N);
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			if (S[i] - '0' != 0)A++;
			if (S[i] - '0' != 1)B++;
		}
		else {
			if (S[i] - '0' != 0)B++;
			if (S[i] - '0' != 1)A++;
		}
	}
	cout << min(A, B) << endl;
}


Measured memory_bytes: 2048
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		
		String v=s.next();
		for(int i=0;i<=v.length();++i) {
			for(int j=i;j<=v.length();++j) {
				if("keyence".equals(v.substring(0,i)+v.substring(j))) {
					System.out.println("YES");
					return;
				}
			}
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main(){
    long long int n,red,blue,sum = 0,count = 0;
    long long int a,b;
    string s;

    cin >> n >> blue >> red;
    sum = red + blue;

    a = n/sum;
    b = n%sum;

    if(b == 0){
        cout << fixed << setprecision(0) << a*blue << endl;
    }else if(b  <= blue){
        cout << fixed << setprecision(0) <<  a * blue + b << endl;
    }else{
        cout << fixed << setprecision(0) << (a+1)*blue << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	string s;cin>>s;
	int a=(s[0]-'0')*10+(s[1]-'0');
	int b=(s[2]-'0')*10+(s[3]-'0');
	int f=0;
	if(a>0 && a<13) f++;
	if(b>0 && b<13) f+=2;
	if(f==0) cout<<"NA"<<endl;
	if(f==1) cout<<"MMYY"<<endl;
	if(f==2) cout<<"YYMM"<<endl;
	if(f==3) cout<<"AMBIGUOUS"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
 
int main(){
    str s; cin >> s;
    int ans = 0;
    for (int i=0; i<s.length()/2; i++){
        if(s[i] != s[s.length()-1-i]){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)


if __name__ == "__main__":
    N, M = tuple(map(int, input().split(" ")))
    As = list(map(int, input().split(" ")))
    S = sum(As)
    As = [a for a in As if a >= S/(4*M)]
    if len(As) >= M:
        print("Yes")
    else:
        print("No")


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

long long n, a[3123123];
long long t[6000 * 4];

void upd (int v, int tl, int tr, int pos, int new_val = 0) {
	if (tl == tr)
		t[v] += 1;
	else {
		int tm = (tl + tr) / 2;
		if (pos <= tm)
			upd (v*2, tl, tm, pos, new_val);
		else
			upd (v*2+1, tm+1, tr, pos, new_val);
		t[v] = t[v*2] + t[v*2+1];
	}
}
int get (int v, int tl, int tr, int l, int r) {
	if (l > r)
		return 0;
	if (l == tl && r == tr)
		return t[v];
	int tm = (tl + tr) / 2;
	return get (v*2, tl, tm, l, min(r,tm))
		+ get (v*2+1, tm+1, tr, max(l,tm+1), r);
}

const int mod = 1e9 + 7;
long long lf[5000], rt[5000];
long long k;
int main() {
    ios_base::sync_with_stdio(0);
    long long ans = 0;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];

	for(int i = 1; i <= n; i++) {
		lf[i] = get(1, 1,  2000, 1, a[i] - 1), upd(1, 1, 2000, a[i]);
		long long f = k;
		long long sec = k - 1;
		//cout << (f * sec) << '\n';
		 f = (f * sec / 2) % mod;
		 ans = (ans + (f * lf[i]) % mod) % mod; 

		 //ans = (ans + ((lf[i] * k - 1) * (lf[i] * k) / 2) %mod) % mod;//cout << (lf[i] * k - 1) * (lf[i] * k) / 2 << endl;
	}
	memset(t, 0, sizeof(t));
	for(int i = n; i >= 1; i--) {
		rt[i] = get(1, 1, 2000,1, a[i] - 1), upd(1, 1, 2000, a[i]);
		long long f = k;
		long long sec = k + 1;
		f = (f * sec / 2) % mod;
				//cout << (f * sec) << '\n';
		 ans = (ans + (f * rt[i]) % mod) % mod; 
	}
	//for(int i = 1; i <=n ;i++) ans =(ans + (lf[i] + rt[i] + lf[i]) * k) % mod, cout << lf[i] << ' ' << rt[i] << endl;
	//cout << mod - ans << endl;
	cout << ans;
}
//1 2 1 1 2 1 1 2 1
//1 2 3 4 1 2 3 4

Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1e5+11,INF=~0u>>2;
map<int,int> mp;
int n,ans;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();
	for(int i=1;i<=n;++i){
		int tmp=read();
		mp[i]=tmp;
		if(mp[tmp]==i) ans++;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 4992
s=input()
ans = len(s)
then = [s]
for i in s:
    cnt = 0
    while len(set(then[0])) >1:
        cnt += 1
        tmp = then.pop()
        empty=""
        for j in range(len(tmp)-1):
            if tmp[j]==i or tmp[j+1]==i:
                empty += i
            else:
                empty += tmp[j]
        then.append(empty)
    ans=min(ans,cnt)
    then=[s]
print(ans)

Measured memory_bytes: 41836
#include <stdio.h>
int main()
{
	int n,m,c,i,j,flag,sum,now;
	int keisu[500];
	sum=0;
	scanf("%d%d%d",&n,&m,&c);
	for(i=1;i<=m;i++)
	{
		scanf("%d",&keisu[i]);
	}
	for(i=1;i<=n;i++)
	{
		flag=0;
		for(j=1;j<=m;j++)
		{
			scanf("%d",&now);
			flag=flag+(now*keisu[j]);
		}
		flag=flag+c;
		if(flag>0)
		{
			sum++;
		}
	}
	printf("%d",sum);
			
			
		
	
}

Measured memory_bytes: 128
from heapq import *
N,M = map(int,input().split())
l = [[0] for _ in range(M+1)] 
for _ in range(N):
    a, b = map(int, input().split())
    if a<=M:
        l[a].append(b)

ans = 0
h = []

for i in range(1,M+1):
  for j in l[i]:
    heappush(h, -j)
  ans += heappop(h)
ans *= -1
print(ans)

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

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

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

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

template<class T>
inline void readv(vector<T>&v){
  if(v.empty()){
    cerr << "void readv(vector<T>&v) v.empty()\n";
  }
  for(auto&&e:v){
    cin >> e;
  }
}

int getk(int n){
  int k = 0;
  while(n){
    k++;
    n/=10;
  }
  return k;
}

int main(){
  int n;cin >> n;
  int c = 0;
  for(int i = n; i > 0; --i)if(getk(i) % 2 == 1)c++;
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)

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

#n,m<=10**5

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

uf = UnionFind(m+1) #初期化

lastcheck=set([])
klkl=[]
for _ in range(n):
    kl=list(map(int,input().split()))[1:]
    if len(kl)>1:
        for item in kl[1:]:
            uf.union(kl[0]-1,item-1)
    klkl.append(kl)
uf_list=uf.members(klkl[0][0]-1)
#print(uf_list)
flag=0
for kl in klkl:
    for item in kl:
        item-=1
        if item not in uf_list:
            flag=1
        else:
            break
if flag==1:
    print("NO")
else:
    print("YES")
    














Measured memory_bytes: 86616