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

using namespace std;

int N;

int main(){
    cin >> N;
    vector<int> v(N);
    for(int i=0;i<N;i++) cin >> v[i];
    vector<int> w = v;
    sort(w.begin(),w.end());
    for(int i=0;i<N;i++){
        if(v[i] <= w[N/2-1]){
            cout << w[N/2] << endl;
        }else{
            cout << w[N/2-1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3712
import collections
N = int(input())
a = list(map(int,input().split()))
ans = 0
c = collections.Counter(a)
for i,j in zip(c.keys(),c.values()):
    if(j>i):
        ans += j-i
    elif(j==i):
        pass
    else:
        ans += j
print(ans)

Measured memory_bytes: 22340
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n;
    cin >> n;
    map<string, vector<pair<int, int>>> mp;
    vector<string> keys;
    for(int i = 0; i < n; i++){
        string s;
        int x;
        cin >> s >> x;
        if(mp.find(s) == mp.end()){
            keys.push_back(s);
            pair<int, int> pr;
            pr.first = x;
            pr.second = i;
            vector<pair<int, int>> v;
            v.push_back(pr);
            mp[s] = v;
        }else{
            pair<int, int> pr;
            pr.first = x;
            pr.second = i;
            mp[s].push_back(pr);
        }
    }
    sort(keys.begin(), keys.end());
    for(int i = 0; i < keys.size(); i++){
        sort(mp[keys[i]].begin(), mp[keys[i]].end());
        reverse(mp[keys[i]].begin(), mp[keys[i]].end());
        for(int j = 0; j <  mp[keys[i]].size(); j++){
            cout << mp[keys[i]][j].second + 1 << "\n";
        }
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

void solve() {
    string s, t; cin >> s >> t;
    int n = s.length(), m = t.length();
    auto dp = vec<int>(n + 1, m + 1);
    FOR(i, 0, n)FOR(j, 0, m) {
        chmax(dp[i + 1][j + 1], dp[i][j + 1]);
        chmax(dp[i + 1][j + 1], dp[i + 1][j]);
        if (s[i] == t[j])chmax(dp[i + 1][j + 1], dp[i][j] + 1);
    }
    cout << dp[n][m] << "\n";
}

int main() {
    init();

    int q; cin >> q;
    FOR(i, 0, q)solve();
}


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

#include <set>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int main(){
  const int n = getInt();
  vector<int> l(n);
  vector<int> h(n);
  vector<int> p(n);

  REP(i,n){
    l[i] = getInt();
    h[i] = getInt();
    p[i] = getInt();
  }

  vector<int> dp(400, -1);
  dp[0] = 0;

  REP(i,n) REP(j,dp.size()) if(dp[j] != -1){
    for(int k = l[i]; k <= h[i] && j + k < (int)dp.size(); k++){
      dp[j + k] = max(dp[j + k], dp[j] + p[i]);
    }
  }

  const int m = getInt();
  vector<int> ans(m);
  REP(i,m){
    ans[i] = dp[getInt()];
    if(ans[i] == -1){
      puts("-1");
      return 0;
    }
  }
  REP(i,m) printf("%d\n", ans[i]);

  return 0;
}

Measured memory_bytes: 1036
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>

using namespace std;

int main(){
    int p,q,r;
    cin >> p >> q >> r;
    int mn = min(p+q, q+r);
    mn = min(mn, r+p);
    cout << mn << endl;
}


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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int n,x,ans;
    for(;;){
        scanf("%d %d",&n,&x);
        ans=0;
        if(n==0) break;
        for(int i=1;i<n-1;i++){
            for(int j=i+1;j<n;j++){
                if(n>=x-i-j && j<x-i-j){
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

int main() {
	
	int p0x,p0y,p1x,p1y,q;
	cin>>p0x>>p0y>>p1x>>p1y>>q;
	
	for(int i=0;i<q;++i){
		int x,y;
		cin>>x>>y;
		
		int crossp = (p1x-p0x) * (y-p0y) - (p1y-p0y) * (x-p0x);
		int dotp = (p1x-p0x) * (x-p0x) + (p1y-p0y) * (y-p0y);
		
		if(crossp>0)cout<<"COUNTER_CLOCKWISE"<<endl;
		else if(crossp<0)cout<<"CLOCKWISE"<<endl;
		else{
			if(dotp<0)cout<<"ONLINE_BACK"<<endl;
			else if( abs(p1x-p0x) >= abs(x-p0x) && abs(p1y-p0y) >= abs(y-p0y) )cout<<"ON_SEGMENT"<<endl;
			else cout<<"ONLINE_FRONT"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
int N;
long ans,A,B,M=2e9;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A>>B;
		ans+=A;
		if(A>B&&M>B)M=B;
	}
	cout<<(M>1e9?0:ans-M)<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *parent, *left, *right;
};

Node *NIL;
Node *root;

void insert(int k){
  Node *x = root;
  Node *y = NIL;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL){
    y = x;
    if (z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;
  if (y == NIL){
    root = z;
  } else {
    if (z->key < y->key) y->left = z;
    else y->right = z;
  }
}

void preorder(Node *u){
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

void inorder(Node *u){
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

int main(){
  int n, i, x;
  string com;

  scanf("%d", &n);
  for (i=0; i<n; i++){
    cin >> com;
    if (com == "insert"){
      scanf("%d", &x);
      insert(x);
    } else if (com == "print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 26780
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef vector<int> vi;
vi ans,ans2;
const int inf=1e9;
int polnum[205];
int dp[1000005];
int odddp[1000005];
int ntet=0;
void ready()
{
  for(;;ntet++)
  {
    polnum[ntet]=ntet*(ntet+1)*(ntet+2)/6;
    if(polnum[ntet]>=1000000) break;
  }
  for(int i=0;i<=1000000;i++)
    {
      dp[i]=odddp[i]=inf;
    }
    dp[0]=odddp[0]=0;
}

int main()
{
  ready();
  int mx=0;
  for(int i=0;i<5;i++)
  {
    for(int j=0;j<=1000000;j++)
    {
      for(int k=0;k<ntet;k++)
      {
				if(j+polnum[k]>=1000000) break;
				if(polnum[k]%2==1) odddp[j+polnum[k]]=min(odddp[j+polnum[k]],odddp[j]+1);
				dp[j+polnum[k]]=min(dp[j+polnum[k]],dp[j]+1);
				mx=max(mx,j+polnum[k]);
				mx=min(mx,1000000-1);
      }
    }
  }
  int n;
  while(cin >> n,n) cout << dp[n]<<" " << odddp[n] << endl;
  return 0;
}



Measured memory_bytes: 10820
n = int(input())
l = list(map(int,input().split()))
i = 0
j = 0
k = 0
m = 0

for i in range(n):
    for j in range(i):
        if l[j] >= k:
           k = l[j]
    if l[i] >= k:
        m = m + 1

    
print(m)

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

int main(void) {
    float a, b, c, d, e, f, x, y;

    while (scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=EOF) {
        x=(c*e-b*f)/(a*e-b*d);
        y=(-c*d+a*f)/(a*e-b*d);

        if (x==-0.0) x=abs(x);
        if (y==-0.0) y=abs(y);

        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}



Measured memory_bytes: 2084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine()) % 10;

		switch (n) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			break;
		case 3:
			System.out.println("bon");
			break;
		}
	}
}


Measured memory_bytes: 32704
import * as fs from 'fs';

//in
// 3 1
//out
// ABC
const main = (inp: string) => {
    const [n, k]: number[] = inp.split('\n')[0].split(' ').map(Number);
    const s: string[] = inp.split('\n')[1].split('');
    for (let i: number = 0; i < n; i++) {
        if (i === k-1) {
            s[i] = s[i].toLowerCase();
        }
    }
    console.log(s.join(''));
};

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



Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_N = 205;
const ll INF = 1e10;
ll d[MAX_N][MAX_N];
vector<int> r;

void init()
{
	rep(i,MAX_N)
	{
		rep(j,MAX_N)
		{
			if (i == j) d[i][j] = 0;
			else d[i][j] = INF;
		}
	}
}

int main()
{
	init();
	int N,M,R;
	cin >> N >> M >> R;
	rep(i,R)
	{
		int p;
		cin >> p;
		p--;
		r.push_back(p);
	}
	sort(r.begin(),r.end());
	rep(i,M)
	{
		int a,b;
		ll c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = c;
		d[b][a] = c;
	}
	rep(k,N)
	{
		rep(i,N)
		{
			rep(j,N)
			{
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	/*
	rep(i,N)
	{
		rep(j,N)
		{
			cout << d[i][j] << " ";
		}
		cout << endl;
	}
	cout << "a" << endl;
	*/
	ll ans = INF;
	do
	{
		ll temp = 0;
		rep(i,R-1)
		{
			temp += d[r[i]][r[i+1]];
		}
		/*
		rep(i,R)
		{
			cout << r[i] << " ";
		}
		cout << temp << endl;
		*/
		ans = min(ans,temp);
	}
	while(next_permutation(r.begin(), r.end()));

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
        return 0;
    }
    if (r < 2800) {
        cout << "ARC" << endl;
        return 0;
    }
    cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 3644
import itertools
import math
import heapq

N = int(input())
nums = list(map(int,input().split(" ")))

half1 = nums[:N]
middle= nums[N:2 *N]
half2 = nums[2 *N:]
half2  = list(map(lambda x:-x ,half2) )

heapq.heapify(half1)
heapq.heapify(half2)
count = 0
lsum = sum(half1)
rsum = sum(half2)
ruiseki_left = [lsum]
ruiseki_right= [rsum]

for i in range(N):
    head = half1[0]
    if middle[i] > head:
        ruiseki_left.append(ruiseki_left[-1]  - head +  middle[i])
        heapq.heappop(half1)
        heapq.heappush(half1,middle[i])
    else:
        ruiseki_left.append(ruiseki_left[-1] )
middle.reverse()
for i in range(N):
    head = half2[0]
    if middle[i] > head:
        ruiseki_right.append(ruiseki_right[-1]  - head +   (-middle[i]))
        heapq.heappop(half2)
        heapq.heappush(half2,-middle[i])
    else:
        ruiseki_right.append(ruiseki_right[-1])
# print(ruiseki_left)
# print(ruiseki_right)
ans = - (10 **20)
for i in range(N + 1):

    ans = max(ans,ruiseki_left[i] + ruiseki_right[N - i])
print(ans)

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

typedef long long lli;

const lli mod = 1000000007LL;

lli N;
lli T[100005];
lli A[100005];
lli m[100005], h[100005];

int main() 
{
  cin >> N;
  for (lli i = 0; i < N; ++i) {
    cin >> T[i];
  }
  for (lli i = 0; i < N; ++i) {
    cin >> A[i];
  }

  fill(m, m + N, 1LL << 60);
  fill(h, h + N, 0);
  h[0] = T[0];
  for (lli i = 1, j = T[0]; i < N; ++i) {
    if (T[i-1] != T[i]) {
      h[i] = j = T[i];
    } else {
      m[i] = j;
    }
  }
  if (h[N-1] > 0 && A[N-1] != h[N-1] || h[N-1] == 0 && A[N-1] > m[N-1]) {
    cout << 0 << endl;
    return 0;
  }
  h[N-1] = A[N-1];
  for (lli i = N-2, j = A[N-1]; i >= 0; --i) {
    if (A[i+1] != A[i]) {
      if (h[i] > 0 && A[i] != h[i] || h[i] == 0 && A[i] > m[i]) {
	cout << 0 << endl;
	return 0;
      }
      h[i] = j = A[i];
    } else {
      m[i] = min(m[i], j);
      if (h[i] > 0 && h[i] > m[i]) {
	cout << 0 << endl;
	return 0;
      }
    }
  }
  lli res = 1;
  for (lli i = 0; i < N; ++i) {
    if (h[i] == 0) {
      res = res * m[i] % mod;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3456
#include <cstdio>

using namespace std;

int main() {
  long long i;
  long long N;
  long long ans;
  scanf("%lld", &N);
  if (N <= 9) {
    ans = N;
  } else {
    for (i = 9; i <= 99; i += 10) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 99; i <= 999; i += 100) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 999; i <= 9999; i += 1000) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 9999; i <= 99999; i += 10000) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 99999; i <= 999999; i += 100000) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 999999; i <= 9999999; i += 1000000) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 9999999; i <= 99999999; i += 10000000) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 99999999; i <= 999999999; i += 100000000) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 999999999; i <= 9999999999; i += 1000000000) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 9999999999; i <= 99999999999; i += 1e10) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 99999999999; i <= 999999999999; i += 1e11) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 999999999999; i <= 9999999999999; i += 1e12) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 9999999999999; i <= 99999999999999; i += 1e13) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 99999999999999; i <= 999999999999999; i += 1e14) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 999999999999999; i <= 9999999999999999; i += 1e15) {
      if (i <= N) {
	ans = i;
      }
    }
    for (i = 9999999999999999; i <= 99999999999999999; i += 1e12) {
      if (i <= N) {
	ans = i;
      }
    }
  }
  int real_ans = 0;
  while (ans > 0) {
    real_ans += ans % 10;
    ans = ans/10;
  }
  printf("%d", real_ans);
  return 0;
}


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

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

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 3572
<?php

while (true) {
    fscanf(STDIN, '%f', $a);
    if (feof(STDIN)) {
        break;
    }
    $s = $a;
    for ($i = 2; $i <= 10; $i++) {
        if ($i % 2 === 0) {
            $a *= 2;
        } else {
            $a /= 3;
        }
        $s += $a;
    }
    echo $s . PHP_EOL;
}

Measured memory_bytes: 6608
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;
const int INF = 1 << 30;

bool is_prime(int n) {
    if (n <= 1) return false;
    bool fg = true;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) fg = false;
    }
    return fg;
}

int main() {
    int q;
    cin >> q;
    vi l(q), r(q);
    rep(i, q) cin >> l[i] >> r[i];

    int m = -1;
    int mi = INF;
    rep(i, q) {
        m = max(m, r[i]);
        mi = min(mi, l[i]);
    }

    set<int> primes;
    primes.insert(2);

    for (int i = mi; i <= m; i+=2) {
        if (is_prime(i)) primes.insert(i);
    }

    vector<int> ps(m+1, 0);
    ps[mi] = (primes.find(mi) != primes.end()) && (primes.find((mi+1)/2) != primes.end());

    for (int i = mi; i < m; i+=2) {
        ps[i+2] = ps[i];
        if ((primes.find(i+2) != primes.end()) && (primes.find((i+3)/2) != primes.end())) ps[i+2]++;
    }

    rep(i, q) {
        int lz = max(l[i]-2, 0);
        cout << ps[r[i]] - ps[lz] << "\n";
    }

    return 0;
}


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

#define FOR(i,N) for(int i=0;i<N;i++)
#define ROF(i,N) for(int i=N-1;i>=0;i--)
#define ROF1(i,a,b) for(int i=(b);i>=(a);i--)
#define FOR1(i,a,b) for(int i=(a);i<=(b);i++)
#define FORi(i,a,b,c) for(int i=(a);i<=(b);i+=(c))

#define read freopen("IN.txt","r",stdin)
#define write freopen("OT.txt","w",stdout)
#define fastread {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mem(a,b)          memset(a,b,sizeof(a))
#define EPS 1e-9
#define PI              acos(-1.0)
#define INF             2e16

#define ll              long long
#define ull             unsigned long long
#define ft              first
#define sd              second
#define bn              begin
#define en              end
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define all(x) x.begin(), x.end()


#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};

int main()
{
#ifdef SunWalker
    //read;
   //write;
#endif

     int a,b,soc=0,cnt=0;
     cin>>a>>b;
     while(soc < b-1)
     {
          cnt++;
          soc+=a-1;
     }
     cout<<cnt<<"\n";

return 0;
}



Measured memory_bytes: 256
S = input()
N = len(S)
ok = 1
if S != "".join(list(reversed(S))):
    ok = 0

if S[:(N - 1) // 2] != "".join(list(reversed(S[:(N - 1) // 2]))):
    ok = 0

if S[(N + 2) // 2:] != "".join(list(reversed(S[(N + 2) // 2:]))):
    ok = 0

if ok == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
/*****************
 *   I<3   C++   *
 *  IWANT ANYAC  *
 * ILOVEPROGRAM! *
 *IT'SINTERESTING*
 * ILOVEPROGRAM! *
 *  INCONTESTS   *
 *   GETSCORE    *
 *    ACCODE     *
 *     LETS      *
 *      GO       *
 *****************/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
#define MASK(a) (1<<(a))
#define MASKX(x,a) ((x)<<(a))
#define BIT(a,b) ((a>>b)&1)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

char last;
int cnt=0;
string s;

int main()
{
	cin>>s;
	last=s[0];
	for(int i=0;i<SZ(s);i++)
	{
		if(s[i]!=last)
		{
			cnt++;
			last=s[i];
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 512
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n = ii()
    a = li()
    tmp = [0 for i in range(n+1)]
    for i in a:
        tmp[i]+=1
    for i in range(1,n+1):
        print(tmp[i])



main()




Measured memory_bytes: 34004
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

#debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    S = SI()

    head = 0
    g_list = []
    while True:
        next = S.find('LR') + 1
        if next == 0:
            break
        g_list.append(S[:next])
        head = next
        S = S[head:]
        dprint(head, next, g_list)
    g_list.append(S)

    dprint(g_list)

    ans = []
    for g in g_list:
        lidx = g.find('L')
        rcnt = 0
        lcnt = 0
        for i in range(lidx):
            if (lidx-i+1)%2 == 0:
                rcnt += 1
            else:
                lcnt += 1
        for i in range(lidx, len(g)):
            if (lidx - i)%2 == 0:
                lcnt += 1
            else:
                rcnt += 1

        for i in range(len(g)):
            if i == lidx - 1:
                ans.append(rcnt)
            elif i == lidx:
                ans.append(lcnt)
            else:
                ans.append(0)

    print(' '.join([str(a) for a in ans]))
solve()

Measured memory_bytes: 13644
main(n,a,b,d,x,i){ while(~scanf("%d",&n)){if(!n)exit(0);for(a=0,b=500;n-->0;){for(d=i=0;i++<5;d+=x)scanf("%d",&x);if(d>a)a=d;if(d<b)b=d;}printf("%d %d\n",a,b);}}

Measured memory_bytes: 0
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    #シンプルに！！
    
    mod=10**9+7
    N,M=MI()
    S=LI()
    T=LI()
    
    dp=[[0]*(M+1) for _ in range(N+1)]
    #i文字目までとj文字目まで見た．
    
    for i in range(N+1):
        dp[i][0]=1
    for j in range(M+1):
        dp[0][j]=1
    
    for i in range(N):
        for j in range(M):
            #まとめたせいで繊維が少し不自然かも
            #基本はdp[i][j]を2回数えているのでひく，でもi文字目とj文字目が一致していればたす
            dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]
            if S[i]!=T[j]:
                dp[i+1][j+1]-=dp[i][j]
            dp[i+1][j+1]%=mod

    print(dp[-1][-1])
    
    

main()


Measured memory_bytes: 72412
#include <bits/stdc++.h>
using namespace std;
string s,v,x;int a,b;
int main()
{
    cin>>s>>v>>a>>b>>x;
    if(s==x)cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;
    return 0;
}


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

using namespace std;

#define EPS (1e-5)

typedef complex<double> P;

vector<P> crossPoint(P a, P b)
{
	vector<P> res;
	if (abs(abs(b - a) - 2.0) < EPS)
	{
		P c = a + b;
		res.push_back(P(c.real() / 2, c.imag() / 2));
	}
	else if (abs(b - a) < 2.0)
	{
		P ab = b - a;
		P center = a + P(ab.real() / 2, ab.imag() / 2);
		P un1 = (ab * P(0, +1)) / abs(ab);
		P un2 = (ab * P(0, -1)) / abs(ab);
		double dist = sqrt(1 - pow(abs(ab) / 2, 2));
		P c1 = center + un1 * dist;
		P c2 = center + un2 * dist;
		res.push_back(c1);
		res.push_back(c2);
	}
	return res;
}

void solve()
{
	int n;
	while (cin >> n, n)
	{
		vector<P> p(n);
		for (int i = 0; i < n; ++i)
		{
			double x, y;
			char ch;
			cin >> x >> ch >> y;
			p[i] = P(x, y);
		}
		int ans = 1;
		for (int i = 0; i < n; ++i)
		{
			for (int j = i + 1; j < n; ++j)
			{
				vector<P> v = crossPoint(p[i], p[j]);
				if (v.empty())
				{
					continue;
				}
				int countA = 2;
				int countB = 2;
				for (int k = 0; k < n; ++k)
				{
					if (i == k || j == k)
					{
						continue;
					}
					if (abs(v[0] - p[k]) - 1.0 < EPS)
					{
						countA++;
					}
					if (v.size() == 2 && abs(v[1] - p[k]) - 1.0 < EPS)
					{
						countB++;
					}
				}
				ans = max(ans, max(countA, countB));
			}
		}
		cout << ans << endl;
	}
}
int main(void)
{
	solve();
	return 0;
}

Measured memory_bytes: 1260
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		System.out.println(a + b < 24 ? a + b : (a + b) % 24);
	}
}


Measured memory_bytes: 35596
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int sum = 0;
		int[] Num = new int[200000];
		int N = scan.nextInt();
		int K = scan.nextInt();
		int[] A = new int[N];
		for(int i = 0; i < N; i++) {
			A[i] = scan.nextInt() - 1;
			Num[A[i]]++;
		}
		Arrays.sort(Num);
		for(int i = 0; i < Num.length - K; i++) {
			sum += Num[i];
		}
		System.out.println(sum);
		scan.close();

	}

}


Measured memory_bytes: 67288
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll N,M,Q;

vector<vl> v;
vl history;

void dfs(ll dep, ll x) {
    if (dep == N) {
        vl copied = history;
        v.push_back(copied);
        return;
    } else {
        for(ll i=x; i<=M; i++) {
            history[dep] = i;
            dfs(dep+1, i);
        }
    }
}

int Main() {
    cin >> N >> M >> Q;
    vl a(Q);
    vl b(Q);
    vl c(Q);
    vl d(Q);

    rep(i,Q) {
        cin >> a[i];
        cin >> b[i];
        cin >> c[i];
        cin >> d[i];
    }
    
    history.resize(N);
    dfs(0,1);
//    
//    for (auto &e: v) {
//        for (auto u: e) {
//            cout << u << " ";
//        }
//        cout << endl;
//    }
//    
    ll ans = 0;
    for (auto &e: v) {
        ll sum = 0;
        rep(i, Q) {
            if (e[b[i]-1]- e[a[i]-1] == c[i]) {
                sum += d[i];
            }
        }
        ans = max(ans, sum);
    }
    
    cout << ans << endl;
    
    return 0;
}

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


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(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)

const int MAX_COMB = 2e7 + 3;
const LL mod = 1e9 + 7;
LL fct[MAX_COMB+1];
LL invfct[MAX_COMB+1];

void build(){
	fct[0] = fct[1] = 1;
	repp(i,2,MAX_COMB+1){
		fct[i] = fct[i-1] * i % mod;
	}
	LL x = fct[MAX_COMB];
	invfct[MAX_COMB] = 1;
	for(int i = mod - 2 ; i > 0 ; i >>= 1){
		if(i % 2 == 1) (invfct[MAX_COMB] *= x) %= mod;
		(x *= x) %= mod;
	}
	repm(i,MAX_COMB,0){
		invfct[i-1] = invfct[i] * i % mod;
	}
}

LL comb(int x , int y){
	if(x < 0 || y < 0 || x < y) return 0;
	return fct[x] * invfct[y] % mod * invfct[x-y] % mod;
}

int main(){
	build();
	LL H,W,K; cin >> H >> W >> K;
	LL ans = 0;
	repp(s,1,K+1){
		LL z = (s+1)*comb(W+H,s)%mod + W*H%mod*comb(W+H-2,s-2)%mod;
		z = z*fct[s]%mod*fct[K-s]%mod*comb(W+H-s,K-s)%mod;
		(ans += z) %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 312832
from collections import defaultdict, Counter

def comb(n: int, k: int) -> int:
    ans = 1
    for i in range(1, k+1):
        ans *= n - i + 1
        ans //= i
    return ans

n, a, b = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
c = Counter(v)

cand = defaultdict(int)
for m in range(a, b+1):
    s = sum(v[:m])
    k = len(list(filter(lambda x: x == v[m-1], v[:m])))
    l = c[v[m-1]]

    cand[s / m] += comb(l, k)

# print(cand)
ans1 = max(cand.keys())
print(ans1)
print(cand[ans1])


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  if(1+2*(k-1)<=n) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int x=scan.nextInt();
    int y=x;
    if(x==2){
      System.out.println(x);
    }else {
      while(true){
        boolean ok=true;
        for(int i=2;i<y;i++){
          if(y%i==0){
            ok=false;
            break;
          }
        }
        if(ok){
          break;
        }
        y++;
      }
      System.out.println(y);
    }
  }
}

Measured memory_bytes: 23380
import java.util.*
import kotlin.math.abs

fun main(args: Array<String>){
    val sc=Scanner(System.`in`)
    val n=sc.nextInt()
    //これが候補数
    var t=sc.nextInt()
    //このTは平均気温を求める際に用いる
    val a=sc.nextInt()
    //この気温に最も近い宮殿を選ぶ
    var tem=Double.MAX_VALUE
    var key=0
    for(i in 1..n){
        val h=sc.nextInt()
        var tee=abs(a-(t-h*0.006))
        if(tem>tee){
            key=i
            tem=tee
        }
    }
    println(key)


}

Measured memory_bytes: 39756
#include<stdio.h>
int main(){
int n,t,s,r;
t=0;s=0;
int a[100],b[100];
scanf("%d",&n);
for(int k=0;k<n;k++){
scanf("%d",&a[k]);
}
for(int k=0;k<n;k++){
scanf("%d",&b[k]);
}
for(int k=0;k<n;k++){
t=t+a[k];
s=t;
for(int l=k;l<n;l++){
s=s+b[l];
}
if(s>r)r=s;
}
printf("%d",r);
return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku
int n,m;
int g[8][8];
int v[8]={1,};
int ans=0;

void dfs(int k){
	int i,f;
	rep(i,n)if(!v[i])break;
	if(i==n){
		ans++;
		return;
	}
	rep(i,n){
		if(g[k][i]&&!v[i]){
			v[i]=1;
			dfs(i);
			v[i]=0;
		}
	}
}
		
int main(void){
	int a,b,i;
	n=in(),m=in();
	rep(i,m){
		a=in(),b=in();
		a--,b--;
		g[a][b]=g[b][a]=1;
	}
	dfs(0);
	print(ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B && A != C) {
        cout << "Yes" << endl;
    } else if (A == C && B != C) {
        cout << "Yes" << endl;
    } else if (B == C && A != C) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        
        String s = stdIn.next();
        
        char c[] = s.toCharArray(); 
            
        for(int i = s.length() - 1; i >= 0; i--){
            System.out.print(c[i]);
        }
        System.out.println();

        stdIn.close();
    }
}


Measured memory_bytes: 25860
#include <iostream>
#include <cstdio>
#include <string.h>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
   	int a, b, c;
   	char d,e;
	cin >> a >> d>> b >> e >> c;
	//cout << a << b << c; 
	if (b > 4) {
		cout << "TBD";
	} 
	else {
		cout << "Heisei";
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int i = 0;
		while (i < C) {
			if (B >= A) {
				B -= A;
				i++;
			} else {
				break;
			}
		}
		System.out.println(i);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

int main(){
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printf("%d\n", b + min(c, a + b + 1));
}

Measured memory_bytes: 764
def main():
    s = input()
    t = input()

    alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]

    for i in alphabet:
        if s + i == t:
            print("Yes")
            quit(0)
    print("No")



if __name__ == "__main__":
    main()

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((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 debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int dp[3005][3005];
int main()
{
	string s, t;
	cin >> s >> t;
	
	int n = s.size(), m = t.size();
	For(i,1,n+1){
		For(j,1,m+1){
			if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}

	string ans = "";
	while(n > 0 && m > 0){
		if(dp[n][m] == dp[n-1][m]){
			n--;
		} else if(dp[n][m] == dp[n][m-1]) {
			m--;
		} else {
			n--;
			m--;
			ans.push_back(s[n]);
		}
	}
	rSORT(ans);
	cout << ans << endl;
}


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

using namespace std;

#define int long long

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}

#define FOR(a,b,c) for(int a=b, __c=c; a<=__c; ++a)
#define FORD(a,b,c) for(int a=b, __c=c; a>=__c; --a)
#define forv(a,b) for(auto &a:b)

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define reset(f,x) memset(f,x,sizeof(f))
#define fasty ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

const int N=2e5+5;
const int inf=1e18;
int n,m;
vector<int> in[N],out[N];
struct pack{
   int l,r,val;
} a[N];
int it[N<<2], lz[N<<2];

#define goc 1,0,n
#define mid l+(r-l)/2
#define lef i<<1,l,mid
#define rig i<<1|1,mid+1,r

void trans(int i){
   if(lz[i]){
      int T=lz[i];
      lz[i<<1]+=T; lz[i<<1|1]+=T;
      it[i<<1]+=T; it[i<<1|1]+=T;
      lz[i]=0;
   }
}
void upd(int i,int l,int r,int u,int v,int val){
   if(v<l || u>r) return;
   if(u<=l && r<=v){
      it[i]+=val;
      lz[i]+=val;
      return;
   }
   trans(i);
   upd(lef,u,v,val); upd(rig,u,v,val);
   it[i]=max(it[i<<1], it[i<<1|1]);
}
int que(int i,int l,int r,int u,int v){
   if(v<l || u>r) return -inf;
   if(u<=l && r<=v) return it[i];
   trans(i);
   return max(que(lef,u,v), que(rig,u,v));
}

int32_t main(){
   fasty;

   #define task "w"
   if(fopen(task".in","r")) freopen(task".in","r",stdin);

   cin>>n>>m;
   FOR(i,1,m){
      int l,r,val;
      cin>>l>>r>>val;
      a[i]={l,r,val};
      in[l].pb(i);
      out[r].pb(i);
   }

   int ans=0;
   FOR(i,1,n){
      forv(v,in[i]) upd(goc,0,a[v].l-1,a[v].val);
      int tmp=que(goc,0,i-1);
      ans=max(ans,tmp);
      upd(goc,i,i,tmp);
      forv(v,out[i]) upd(goc,0,a[v].l-1,-a[v].val);
   }
   cout<<ans<<'\n';
}
/**
  f[i] : max value 1->n with ans[i] = 1;
  	   = max f[j] + a[t] for t with l[t]<=i<=r[t];
         			           and !l[t]<=j<=r[t];
  n^2 can be done iterating through all posibilities;
  we speed up the algo with a seg : seg[i] as f[i]
  while iterating through a position : i,
  all query with start point at i , we update the range [0,i-1] : a[t];
  same as if we meet a end point  , we update the range [0,i-1] : -a[t];
*/

Measured memory_bytes: 38360
n=int(input())
a=0
b=0
c=0
for i in range(n):
	d,e,f=map(int,input().split())
	if abs(f-c)+abs(e-b)<=d-a and \
	(d-a-(abs(f-c)+abs(e-b)))%2==0:
		a=d
		b=e
		c=f
	else:
		print("No")
		exit()
print("Yes")

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

int main(){
    int H, W, i, j;
    
    while(true){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        
        for(j = 0; j < W; j++) cout << "#";
        cout << endl;
        
        for(i = 1; i < H-1; i++){
            for(j = 0; j < W; j++){
                if(j == 0) cout << "#";
                else if(j == W-1) cout << "#\n";
                else cout << ".";
            }
        }
        
        if(H > 1){
            for(j = 0; j < W; j++) cout << "#";
            cout << endl;
        }
    cout << endl;
    }
    
    return 0;
}


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

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	x = x2-x1;
	y = y2-y1;

	cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    double sides;
    int target;
    cin >> sides >> target;
    vector<double> twos = {1};
    int curr = 1;
    while(curr <= target) {
        curr = curr * 2;
        twos.push_back(curr);
    }
    double ans = 0;
    for(int i = 1; i <= sides; i++) {
        if(i >= target) {
            ans += (1 / sides);
            continue;
        }
        for(int j = 0; j < twos.size(); j++) {
            if(twos[j] * i >= target) {
                ans += (1 / sides) * (1 / twos[j]);
                break;
            }
        }
    }
    printf("%.15f", ans);
}

Measured memory_bytes: 3840
#include <iostream>
#include <numeric>
#include <assert.h>
#include <stdio.h>

#define SIZE_OF_ARRAY(D) (sizeof(D)/sizeof(D[0]))

using namespace std;

int maxElement(const int* array, size_t size)
{
    assert(array != NULL);
    assert(size >= 1);

    int max = array[0];
    for (size_t i = 1; i < size; ++i) {
        if (max < array[i]) {
            max = array[i];
        }
    }

    return max;
}

int main()
{
    int K, N;

    cin >> K >> N;

    int A[N], D[N+1];

    // 始点から各家への距離を配列Aへ格納
    for(int i=0; i<N; i++)
    {
        cin >> A[i];
    }
    
    D[0] = A[0];
    for(int i=1; i<N; i++)
    {
        D[i] = A[i] - A[i-1];
    }
    D[N] = A[0] + (K - A[N-1]);

    //int sum = accumulate(D, D+SIZE_OF_ARRAY(D), 0);
    int max = maxElement(D, SIZE_OF_ARRAY(D));

    cout << K - max << endl;

    return 0;

}

Measured memory_bytes: 1920
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n=arr.shift()-0;
var a=arr.shift().split(" ").map(Number);
var m=arr.shift()-0;
var b=arr.shift().split(" ").map(Number);
var memo=0;
var cnt = 0;
for(var i=0;i<m;i++){
   var num=b[i];
   for(var j=memo;j<n;j++){
      memo=j;
      if(num==a[j]){
         cnt++;
         break;
      }
   }
}
console.log((cnt==m)?1:0);


Measured memory_bytes: 55688