akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
using namespace std;
int n;
int a[1000006];
int mx1[1000006], mx2[1000006];
int pos[40];
int main() {
    cin >> n;
    for (int i = 0; i <= (1 << n) - 1; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= (1 << n) - 1; ++i) {
        int cnt = 0;
        int tmp = i;
        do {
            int tp = a[tmp];
            if (tp > mx1[i]) {
                swap(tp, mx1[i]);
            }
            if (tp > mx2[i]) {
                swap(tp, mx2[i]);
            }
            tmp = (tmp - 1) & i;
        } while (tmp != i);
    }
    int res = 0;
    for (int i = 1; i <= (1 << n) - 1; ++i) {
        res = max(res, mx1[i] + mx2[i]);
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 12288
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("inline")
//#pragma GCC optimize("-ffast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("inline-small-functions")
//#pragma GCC optimize("-finline-small-functions")
//#pragma GCC optimize("-fexpensive-optimizations")
//#pragma GCC optimize("-funsafe-loop-optimizations")
//#pragma GCC optimize("inline-functions-called-once")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
const int maxn = 2e5 + 33, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char c;
    cin >> c;
    cout << char(c+1);
}


Measured memory_bytes: 256
mod = 998244353
n,k = map(int,input().split())
lr = [[int(i) for i in input().split()] for j in range(k)]

dp = [0]*(n+1)
dp_rui = [0]*(n+1)

dp[1] = 1
dp_rui[1] = 1

for i in range(2,n+1):
    for j in range(k):
        lft = i - lr[j][1]
        rht = i - lr[j][0]
        #print(i,lft,rht)
        if rht <= 0:
            continue
        lft = max(1,lft)
        dp[i] += dp_rui[rht] - dp_rui[lft-1]
        #print(dp_rui[rht],dp_rui[lft-1])
        dp[i] %= mod
        #print(dp)
        #print(dp_rui)
    dp_rui[i] = dp_rui[i-1] + dp[i]
    dp_rui[i] %= mod

print(dp[n]%mod)

Measured memory_bytes: 76792
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

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

  vi n;
  rep(i, ns.size()) n.push_back(ns[i] - '0');
  int keta = n.size();

  map<pi, int> mp;
  mp[pi{0, 0}] = 1;
  mp[pi{1, 1}] = 1;

  if (n[0] > 1){
    mp[pi{1, 0}] = n[0] - 1;
  }

  for (int kn=1;kn<keta;kn++){
    map<pi, int> new_mp;
    for(int ic=0;ic<=k;ic++) for(int b=0;b<=1;b++){
      int num = mp[pi{ic, b}];
      if (ic > k || num == 0) continue;
      if (b){
        if (n[kn]){
          new_mp[pi{ic+1, 1}] += num;
          new_mp[pi{ic, 0}] += num;
        }else{
          new_mp[pi{ic, 1}] += num;
        }

        if (n[kn] > 1){
          new_mp[pi{ic+1, 0}] += num * (n[kn] - 1);
        }
      }else{
        new_mp[pi{ic+1, 0}] += num * 9;
        new_mp[pi{ic, 0}] += num;
      }
    }
    mp = new_mp;
  }

  ll ans = mp[pi{k, 0}] + mp[pi{k, 1}];
  cout << ans << endl;

  return 0;
}

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

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

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

  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);

  sort(a.rbegin(), a.rend());
  ll b=0,c=0;
  rep(i,n-1){
    if(b==0&&a.at(i)==a.at(i+1)){b=a.at(i); i+=2;}
    if(b!=0&&i+1<n&&a.at(i)==a.at(i+1)){c=a.at(i);break;} 
  }
  cout << b*c;
}

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

const int N = 3005;

int a[N];
int dp[N];
int par[N];
vector <int> adj[N];

void dfs(int v) {
	dp[v] = false;
	for (auto u : adj[v]) {
		if (u != par[v]) {
			par[u] = v;
			dfs(u);
			if (!dp[u] && a[u] < a[v])
				dp[v] = true;	
		}

	}
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			par[j] = 0;
		}
		dfs(i);
		if (dp[i]) {
			cout << i << " ";
		}
	}
	return 0;
}

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

int main()
{
    string S, T;
    cin >> S >> T;
    for (size_t i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

#define int long long
#define double long double
#define pq priority_queue
#define pb push_back
#define mp make_pair

int root(int dsu[],int x)
{
  while(dsu[x]!=x)
  {
    dsu[x]=dsu[dsu[x]];
    x=dsu[x];
  }
  return x;
}

void init(int dsu[], int n)
{
  for(int i=0;i<=n;i++)
  {
    dsu[i]=i;
  }
}

void un(int dsu[],int x,int y)
{
  int a=root(dsu,x);
  int b=root(dsu,y);
  dsu[a]=dsu[b];
}

void printprecise(double l,int precision){
    std::cout << std::fixed;
    std::cout << std::setprecision(precision);
    std::cout << l <<endl;
}

int gcd(int x,int y)
{
  if(x==0)
  {
    return y;
  }
  else
  {
    return gcd(y%x,x);
  }
}

int lcm(int x,int y)
{
  return (x*y)/gcd(x,y);
}

main() 
{

  
  int n;
  cin>>n;
  int cst[n][3]={0};
  int mat[n][3];
  for(int i=0;i<n;i++)
  {
    cin>>mat[i][0]>>mat[i][1]>>mat[i][2];
    // cst[i][0]=10000000000;
    // cst[i][1]=10000000000;
    // cst[i][2]=10000000000;
  }
  cst[0][0]=mat[0][0];
  cst[0][1]=mat[0][1];
  cst[0][2]=mat[0][2];
  for(int i=1;i<n;i++)
  {
    cst[i][0]=(max(cst[i-1][1]+mat[i][0],cst[i-1][2]+mat[i][0]));
    cst[i][1]=(max(cst[i-1][0]+mat[i][1],cst[i-1][2]+mat[i][1]));
    cst[i][2]=(max(cst[i-1][1]+mat[i][2],cst[i-1][0]+mat[i][2]));
  }
  int ans=max(cst[n-1][0],max(cst[n-1][1],cst[n-1][2]));
  cout<<ans;

}

  // #ifndef ONLINE_JUDGE
  // cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  // #endif
// }
// #ifndef ONLINE_JUDGE
// cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
// #endif

Measured memory_bytes: 4992
S = list(input())

prev = ""
index = 0
ans = 0
while index < len(S):
#    print("index[{}] S[{}]".format(index, S))
    if prev == "":
        prev = S[index]
        index = index + 1
        continue

    if S[index] != prev:
        S.pop(index)
        S.pop(index - 1)
        ans = ans + 2
        if len(S) == 0:
            break

        index = index - 2 if index - 2 > 0 else 0
        prev = ""

    else:
        prev = S[index]
        index = index + 1

print(ans)

Measured memory_bytes: 3956
#include <cassert>
#include <utility>

template <class Abelian, template <class T> class Container>
class potentialized_union_find {
	class node_type;

public:
	using value_structure = Abelian;
	using value_type = typename value_structure::value_type;
	using container_type = Container<node_type>;
	using size_type = typename container_type::size_type;

protected:
	container_type c;

private:
	class node_type {
	public:
		typename potentialized_union_find::size_type parent, size;
		typename potentialized_union_find::value_type value;
	};
	value_type potential(size_type x) {
		value_type ret = value_structure::identity();
		while (x != c[x].parent) {
			c[x].value = value_structure::operation(c[x].value, c[c[x].parent].value);
			ret = value_structure::operation(ret, c[x].value);
			x = c[x].parent = c[c[x].parent].parent;
		}
		return ::std::move(ret);
	}

public:
	potentialized_union_find() : c() {}
	explicit potentialized_union_find(const size_type size)
		: c(size, { 0, 1, value_structure::identity() }) {
		for (size_type i = 0; i < size; ++i)
			c[i].parent = i;
	}

	bool empty() const { return c.empty(); }
	size_type size() const { return c.size(); }

	size_type find(size_type x) {
		assert(x < size());
		while (x != c[x].parent) {
			c[x].value = value_structure::operation(c[x].value, c[c[x].parent].value);
			x = c[x].parent = c[c[x].parent].parent;
		}
		return x;
	}
	value_type diff(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		assert(same(x, y));
		return value_structure::operation(potential(y),
			value_structure::inverse(potential(x)));
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return c[find(x)].size;
	}

	::std::pair<size_type, size_type> unite(size_type x, size_type y,
		value_type d) {
		assert(x < size());
		assert(y < size());
		d = value_structure::operation(value_structure::operation(d, potential(x)),
			value_structure::inverse(potential(y)));
		x = find(x);
		y = find(y);
		if (x != y) {
			if (c[x].size < c[y].size) {
				::std::swap(x, y);
				d = value_structure::inverse(d);
			}
			c[x].size += c[y].size;
			c[y].parent = x;
			c[y].value = ::std::move(d);
		}
		return { x, y };
	}
};

template <class T> class plus_abelian {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return x + y;
	}
	static value_type identity() { return value_type(0); }
	static value_type inverse(const value_type &x) { return -x; }
	static value_type reverse(const value_type &x) { return x; }
};

#include<iostream>
#include<vector>
template<class T>
using vec = ::std::vector<T>;

int main() {
	int n, m;
	::std::cin >> n >> m;
	potentialized_union_find<plus_abelian<int>, vec> T(n);
	while (m--) {
		int l, r, d;
		::std::cin >> l >> r >> d;
		--l;
		--r;
		if (T.same(l, r) && T.diff(l, r) != d) {
			::std::cout << "No" << ::std::endl;
			return 0;
		}
		else {
			T.unite(l, r, d);
		}
	}
	::std::cout << "Yes" << ::std::endl;
	return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

import static java.lang.Math.min;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long h = in.nextInt();
        long w = in.nextInt();
        long res = (h * w + 1) / 2;
        if (min(h, w) == 1) {
            res = 1;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 25300
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  cin>>A[0];
  ll now=A[0];
  ll ans=0;
  vi cnt(50);
  for(int i=0;i<50;i++){
    if(BITLE(i) & A[0]){cnt[i]++;break;}
  }
  for(int i=1;i<n;i++){
    cin>>A[i];
    now^=A[i];
    for(int j=0;j<50;j++){
      if(BITLE(j) & A[i]){cnt[j]++;break;}
    }
  }
  //for(int i=0;i<5;i++)cout<<cnt[i]<<" ";cout<<endl;
  for(int i=30;i>=0;i--){
    if(now & BITLE(i)){
      
      if(cnt[i]>0){
	ans++;
	now^=(BITLE(i)-1);
      }else{
	cout<<-1<<endl;
	return 0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;++i)
#define fos(j,i,n) for(int j=i;j<n;++j)
#define N 100004
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define M 1000000007
#define ll long long
#define abs(x) (x<0?(-x):x)
#define dis(k) cout << k << endl
#define forr(i,n) for(int i= n-1;i>=0;--i)
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
 
int main(){
	fast;
	int t;
	t=1;
	//cin >> t;
	while(t--){
		 ll int h,n,in;
		cin >> h >>n;
		vector<int> v;
		ll int s=0;
		fo(i,h){
			cin >> in;
			v.push_back(in);
		}
		sort(v.begin(),v.end());
		fo(i,h-n)
		s+=v[i];
		dis(s);
	}
	return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<functional>
#include <iomanip>

using namespace std;

int main() {
   int N;
   cin >> N;
   int V[ N ];
   int count[ 3 ] = { 0 };
   for( int i = 0; i < N; i++ ) {
      cin >> V[ i ];
      count[ V[ i ] - 1 ]++;
   }

   // Count can be increased, so we need upto N
   double*** dp = ( double *** ) malloc( sizeof( double** ) * ( N + 1 ) );
   for( int i = 0; i < N + 1; i++ ) {
      dp[ i ] = ( double ** ) malloc( sizeof( double ** ) * ( N + 1 ) );
      for( int j = 0; j < N + 1; j++ ) {
         dp[ i ][ j ] = ( double * ) malloc( sizeof( double * ) * ( N + 1 ) );
         for( int k = 0; k < N + 1; k ++ ) {
            dp[ i ][ j ][ k ] = -1;
         }
      }
   }

   function< double ( int, int, int ) > getDp;
   getDp = [ & ] ( int i, int j, int k ) -> double {
      // i -> Count of 1
      // j -> Count of 2
      // k -> Count of 3
      if( i == 0 && j == 0 && k == 0 ) {
         return 0;
      }
      if( dp[ i ][ j ][ k ] != -1 ) {
         return dp[ i ][ j ][ k ];
      }
      // Count for zeroed entries
      int z = N - i - j - k; // Can't be N as i,j,k = (0,0,0) is considered already

      // formula: E[ i, j, k ] = ( z/N ) * ( 1 + E[ i, j, k ] )
      //                         + ( i/N ) *( 1 + E[ i-1, j, k ] )
      //                         + ( j/N ) * ( 1 + E[ i + 1, j - 1, k ] )
      //                         + ( k/N ) * ( 1 + E[ i, j + 1, k - 1 ] )

      dp[ i ][ j ][ k ] = ( 1.0 * N / ( N - z ) ) * (
               1.0 * z / N
             + ( i == 0 ? 0 : ( 1.0 * i / N ) * ( 1 + getDp( i - 1, j, k ) ) )
             + ( j == 0 ? 0 : ( 1.0 * j / N ) * ( 1 + getDp( i + 1, j - 1, k ) ) )
             + ( k == 0 ? 0 : ( 1.0 * k / N ) * ( 1 + getDp( i, j + 1, k - 1 ) ) ) );

      return dp[ i ][ j ][ k ];
   };

   cout << fixed << setprecision( 20 )
        << getDp( count[ 0 ], count[ 1 ], count[ 2 ] );
   return 0;
}


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

using namespace std;

int main()
{
  string S;
  cin >> S;
 if(S == "RRR") {cout << 3 << endl;}
  else if(S == "SRR"  || S == "RRS") {cout << 2 << endl;}
  else if(S == "SSR" || S == "SRS" || S == "RSS" || S == "RSR") {cout << 1 << endl;}
  else if(S == "SSS") {cout << 0 << endl;}
}

Measured memory_bytes: 3624
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n, d] = spi[0].split(' ');

    let ans = 0;
    for (let i = 1; i < spi.length; i++) {
        const [x, y] = spi[i].split(' ');
        if (Math.sqrt(x ** 2 + y ** 2) <= d) ans++;
    }

    console.log(ans);
};

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


Measured memory_bytes: 62960
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void call(int n){

	for (int i = 1; i <= n; i++){
		if (i % 3 == 0){
			cout << " " << i;
		}
		else {
			for (int s = i; s >= 3; s /= 10){
				if (s % 10 == 3){
					cout << " " << i;
					break;
				}
			}
		}
	}
	cout << endl;
}

int main(void){

	int n;
	cin >> n;
	call(n);

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

/*
 suppose all +
 1000000009 is a (proven) prime.
 calculate geometric series
 a = first period
 r = (a^-1 * b)k
 r^n = first period


 */

int const MaxSize = 2e5 + 5;
int N;
LL ps[MaxSize];
map<LL, int> psCnt;

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);
	cin >> N;
	LL ans = 0;

	psCnt[0]++;

	LPE(i, 1, N)
	{
		LL cn;
		cin >> cn;
		LL curPS = ps[i - 1] + cn;

		if (psCnt.count(curPS)) {
			ans += (LL) psCnt[curPS];
			//cout << i << " " << curPS << " " << ans << endl;
		}

		ps[i] = curPS;
		psCnt[curPS]++;
	}

	cout << ans;

	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int a, b, c; cin >> a >> b >> c;
  cout << b + min(c, a+b+1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



constexpr int MAX_SIZE = 2e5+1;
int n, q, l = 0, r;
char Golem[MAX_SIZE], T[MAX_SIZE], D[MAX_SIZE];

int main(void){
  scanf("%d %d\n", &n, &q);
  r = n - 1;
  scanf("%s", Golem);
  REP(i, q){scanf("\n%c %c", T + i, D + i);}
  rREP(i, q){
    if(D[i] == 'L'){ // L
      if(Golem[l] == T[i]) l++;
      if(r != n - 1 and Golem[r+1] == T[i]) r++;
    }
    else{
      if(l != 0 and Golem[l-1] == T[i]) l--;
      if(Golem[r] == T[i]) r--;
    }
  }
  printf("%d\n", r-l+1);
  return 0;
}

Measured memory_bytes: 896
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b,c; cin>>a>>b;
	c=b+(b-a);
	cout<<c;
	return cout<<endl,0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10);x/=10;}reverse(all(res)); return res;}

string w="zabcdefghij";
int level(int x,string s){
  int a=0;
  rep(i,x){
    REP(j,1,12){
      if(s[i]==w[j]){
        if(a<j) a=j;
        break;
      }
    }
  }
  return a;
}

void solve() {
  vector<vector<string>> dp(11,vector<string>());
  dp[1].pb("a");
  vi note(11,0);
  note[1]=1;
  REP(i,2,11){
    rep(j,note[i-1]){
      string s=dp[i-1][j];
      int a=level(i-1,s);
      string t=s;
      REP(k,1,a+2){
        s=t;
        s+=w[k];
        dp[i].pb(s);
        note[i]++;
      }
    }
  }
  int n; cin>>n;
  rep(i,note[n]) out(dp[n][i]);
  //outv(note);
}

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


Measured memory_bytes: 9588
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#include <string>
#include <algorithm>


int main(){
    int n,x;cin >> n >> x;
    int arr[n];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }


    int ans=0;

    sort(arr,arr+n);

    for(int i=0;i<n;i++){
        x=x-arr[i];
        if(x>=0)ans++;
        else break;
    }

    if(x>0&&ans>0) ans--;

    cout << ans << endl;

}

Measured memory_bytes: 3632
from collections import Counter


def solve(V):
    n = len(V)
    ac = Counter(V[::2]).most_common(2)
    bc = Counter(V[1::2]).most_common(2)

    if ac[0][0] != bc[0][0]:
        return n - ac[0][1] - bc[0][1]
    else:
        if len(ac) == 1 and len(bc) == 1:
            return n // 2
        elif len(ac) != 1 and len(bc) == 1:
            return n - ac[1][1] - bc[0][1]
        elif len(ac) == 1 and len(bc) != 1:
            return n - ac[0][1] - bc[1][1]
        else:
            return n - max(ac[0][1] + bc[1][1], ac[1][1] + bc[0][1])


if __name__ == "__main__":
    n = int(input())
    l = input()
    print(solve(l.split(" ")))


Measured memory_bytes: 16800
#include <stdio.h>
int main()
{
  int n,i;
  while((scanf("%d",&n)) != EOF){
    for(i=0x01; i<0x400; i = (i<<1)){
      if(n==i) printf("%d\n", i);
      else if((n&i)==i) {
	printf("%d ", i);
	n -= i;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int maxn=1e5+5;
ll GEt_ans(ll a)
{
    if(a%4==1)
        return 1;
    else if(a%4==2)
        return a+1;
    else if(a%4==3||a==0)
        return 0;
    else
        return a;
}
int main()
{
    ll a,b;
    cin>>a>>b;
    ll ans=GEt_ans(b)^GEt_ans(a-1);
    cout<<ans<<endl;

}


Measured memory_bytes: 256
N = int(input())
S = input()
K = int(input())

K_new = K - 1
i = 0

for i in range(0,N):
    if S[i] != S[K_new]:
        print("*", end="")
        i += 1
    else:
        print(S[i], end="")
        i += 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
int main(void){
    
    int H,W;
    cin >> H >> W;
    char t[H][W];
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> t[i][j];
        }
    }
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(t[i][j] == '#') {
                if(i == 0) {
                    if(j == 0) {
                        if(t[i+1][j] == '#' || t[i][j+1] == '#') {
                            continue;
                        }else {
                            cout << "No" << endl;
                            return 0;
                        }
                    }else if(j == W-1) {
                        if(t[i+1][j] == '#'|| t[i][j-1] == '#') {
                            continue;
                        }else {
                            cout << "No"<< endl;
                        }
                    }
                }else if(i == H-1) {
                    if(j == 0) {
                        if(t[i-1][j] == '#' || t[i][j+1] == '#') {
                            continue;
                        }else {
                            cout << "No" << endl;
                            return 0;
                        }
                    }else if(j == W-1) {
                        if(t[i-1][j] == '#'|| t[i][j-1] == '#') {
                            continue;
                        }else {
                            cout << "No" << endl;
                        }
                    }
                }else {
                    if(t[i-1][j] == '#'|| t[i+1][j]== '#'|| t[i][j-1] == '#' || t[i][j+1] == '#') {
                        continue;
                    }else {
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
double ep(int all,double p){
    return all*(1/p);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int M=in();
    int all;
    all=1900*M+100*(N-M);
    double p;p=pow(0.5,M);
    cout<<ep(all,p)<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <climits>
using namespace std;

int main()
{
	int n,a[100001];
	int i = 1, j = 1 ;
	int ans = 0,now=1;
	
	cin >> n;
	for (i; i <= n; i++)cin >> a[i];
	i = 1;
	while (now != 2 and ans < n) {
		now = a[now];
		ans++;
	}
	if (ans < n)	cout << ans << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 640
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n;
int a[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);
	ll sum=0; REP(i,n) sum+=a[i];
	ll l=0,r=sum,ret=LLONG_MAX;
	REP(i,n-1) {
		l+=a[i],r-=a[i]; ll cur=abs(l-r); if(cur<ret) ret=cur;
	}
	printf("%d\n",ret);
}

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n, m;
        cin>>n>>m;
        long long a[n], sum=0, count=0;
        for(int i=0;i<n;i++){
                cin>>a[i];
                sum+=a[i];
        }if(sum%(4*m)>0){
                sum=sum/(4*m)+1;
        }else{
                sum=sum/(4*m);
        }for(int i=0;i<n;i++){
                if(a[i]>=sum){
                        count++;
                }
        }if(count>=m){
                cout<<"Yes"<<endl;
        }else{
                cout<<"No"<<endl;
        }
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define INF 1145141919810
#define ll long long
using namespace std;

ll n;
 
ll solv(vector<ll> a,bool flag){
    ll sum=0,ans=0;
    rep(i,n){
        sum+=a[i];
        if(flag){
            if(sum>=0){
                ans+=abs(sum)+1;
                sum=-1;
            }
        }else{
            if(sum<=0){
                ans+=abs(sum)+1;
                sum=1;
            }
        }flag=!flag;
    }return ans;
}

int main(){
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    cout<<min(solv(a,true),solv(a,false))<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<utility>
#include<iterator>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
//#define t ll t;cin>>t;while(t--)
#define nn cout<<endl;
#define ff(a,n) for(ll i=a;i<n;i++)
#define cY cout<<"YES\n"
#define cN cout<<"NO\n"
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define sc second
#define fs first
#define c(a) cout<<a<<endl

void solve()
{
	ll n,x,t; cin>>n>>x>>t;
	ll ans=0;
	ll i=0;
	while(1)
	{
		i++;
		ans+=x;
		if(ans>=n) break;
	}
	ans=i*t;
	cout<<ans;
}

int main()
{
	solve();
}
/*




*/


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

int main() {
  int N , M;
  cin >> N >> M;
  
  for (int i = 0; i <= N; i++){
    if( (i)*2+(N-i)*4 == M){
		cout << "Yes" << endl ;
		break;
    }  
	if(i == N){
     	cout << "No" << endl ;    
    }
    
  } 

}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;



/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


bool isLeapYear(int year)
{
	if (year % 4 == 0)
	{
		if (year % 100 == 0)
		{
			if (year % 400 == 0)
			{
				return true;
			}
			return false;
		}
		return true;
	} else {
		return false;
	}
}


int main()
{
	int a, b;
	bool first_flag = true;
	
	while (cin >> a >> b, a || b)
	{
		if (first_flag)
		{
			first_flag = false;
		} else {
			cout << endl;
		}
		
		bool flag = false;
		
		for (int y=a; y<=b; y++)
		{
			if (isLeapYear(y))
			{
				cout << y << endl;
				flag = true;
			}
		}
		
		if (!flag) cout << "NA" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
/*
    This is the solution from syr.
    OJ:
    ProblemID:
    Date:
    Status:Unknown
*/
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

using namespace std;

const int debug=0;
const int INF=1e9+7;

int n,m;

int main(){
	scanf("%d%d",&n,&m);
	if(n>m) swap(n,m);
	if(n==1){
		if(m==1) puts("1");
		else printf("%d\n",max(m-2,0));
		return 0;
	}else{
		printf("%lld\n",(long long)(n-2)*(m-2));
		return 0;
	}
}

/*
Sample Input
*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication50
{
    class Program
    {
        static void Main()
        {
            decimal[] a = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            Console.WriteLine(a[0]*a[1]/ 3.305785M);
        }
    }
}

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

int main() {
	int n, m;
	cin >> n >> m;
	int ans = n;
	rep(i,m) {
		int a;
		cin >> a;
		ans -= a;
	}
	if (ans >= 0) cout << ans << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
 
int main (){
  int A,B;
  cin>>A>>B;
  if (A>=13){
    cout<<B<<endl;
  }
  else if (A<=5){
    cout<<"0"<<endl;
  }
  else {
    cout<<B/2<<endl;
  } 
}  

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),k = sc.nextInt(),x = sc.nextInt(),y = sc.nextInt();
		System.out.println(n < k ?  n * x : k * x + ((n-k) *  y));
	}

}


Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <utility>
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T> &v) {
  int n = v.size();
  for (int i = 0; i < n; ++i) {
    if (i > 0) cout << ' ';
    cout << v[i];
  }
  cout << '\n';
}

int main() {
  int n;
  ll d;
  cin >> n >> d;
  ll x, y;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    if (x * x + y * y <= d * d) {
      ++cnt;
    }
  }
  cout << cnt << '\n';

  return 0;
}


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

using namespace std;
int n, c;
const long long INF = 1e18L + 5;

int main() {
    scanf("%d %d", &n, &c);
    vector<int> w(n);
    vector<int> v(n);
    int total_value = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &w[i], &v[i]);
        total_value += v[i];
    }

    // dp[i][j] := minimum total "weight" with the first i items to make total value j
    vector<long long> dp(total_value + 1, INF);
    dp[0] = 0;

    // O(NV)
    for (int i = 1; i <= n; ++i) {
        vector<long long> cur(total_value + 1, 0);
        for (int j = 0; j <= total_value; ++j) {
            if (j >= v[i - 1]) cur[j] = min(dp[j], dp[j - v[i - 1]] + w[i - 1]);
            else cur[j] = dp[j];
        }
        dp = cur;
    }

    long long ans = 0;
    for (int i = total_value; i >= 0; i--) {
        if (dp[i] <= c) {
            ans = max(ans, (long long) i);
            break;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 4880
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll =long long;
using P = pair<int,int>;

int que_0dx[4] = {1, 0, -1, 0};
int que_0dy[4] = {0, 1, 0, -1};

int que_1dx[24] =
{-2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2};
int que_1dy[24] =
{-2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2};

int main(int argc, const char * argv[]) {
    
    int H, W;
    int CH, CW;
    int DH, DW;
    char S[1000][1000];
    int COST[1000][1000];
    
    cin >> H >> W;
    cin >> CH >> CW;
    cin >> DH >> DW;
    
    CH--;
    CW--;
    DH--;
    DW--;
    
    for(int h=0; h<H; h++){
        string s;
        cin >> s;
        
        for(int w=0; w<W; w++){
            S[h][w] = s[w];
            COST[h][w] = -1;
        }
    }
    

    deque<P> que_0;
    deque<P> que_1;
    que_0.push_front(P(CH, CW));
    
    COST[CH][CW] = 0;
    
    while(que_0.size()){
        while(que_0.size()){

            P p = que_0.front();
            que_1.push_back(p);
            que_0.pop_front();

            for(int i=0; i<4; i++){

                int ny = p.first + que_0dy[i];
                int nx = p.second + que_0dx[i];
                
                if(ny<0 || ny >= H || nx<0 || nx >= W) continue;
                if(COST[ny][nx] > -1) continue;

                if(S[ny][nx] == '.'){
                    COST[ny][nx] = COST[p.first][p.second];
                    que_0.push_back(P(ny, nx));
                }
            }
        }
        
        while(que_1.size()){

            P p = que_1.front();
            que_1.pop_front();
            
            for(int i=0; i<24; i++){

                int ny = p.first + que_1dy[i];
                int nx = p.second + que_1dx[i];
                
                
                if(ny<0 || ny >= H || nx<0 || nx >= W) continue;
                if(COST[ny][nx] > -1) continue;
                
                if(S[ny][nx] == '.'){
                    COST[ny][nx] = COST[p.first][p.second]+1;
                    que_0.push_back(P(ny, nx));
                }
            }
        }
    }
    
    cout << COST[DH][DW] <<  endl;
    
    return 0;
}




Measured memory_bytes: 8052
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

std::string w;
int list[30];

int main()
{
	in >> w;

	rep(i, w.length())
	{
		++list[w[i] - 'a'];
	}
	rep(i, 26)
	{
		if (list[i] % 2 == 1)
		{
			out << "No" << std::endl;
			return 0;
		}
	}

	out << "Yes" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b,c;cin>>a>>b>>c;
  if (a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

typedef pair<int,int> P;
bool dpx[8010][32040],dpy[8010][32040];

int main(){
  string s;
  cin >> s;
  int x,y;
  cin >> x >> y;
  vector<int> ud,rl;
  int num = 0,cur = 0,sumrl = 0,sumud = 0;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) == 'T'){
      if(num % 2 == 0){
        rl.push_back(cur);
        sumrl += cur;
        //cout << cur << endl;
      }
      else{
        ud.push_back(cur);
        sumud += cur;
        //cout << cur << endl;
      }
      num++;
      cur = 0;
    }
    else{
      cur++;
      if(i == s.size()-1){
        if(num % 2 == 0){
          rl.push_back(cur);
          sumrl += cur;
          //cout << cur << endl;
        }
        else{
          ud.push_back(cur);
          sumud += cur;
          //cout << cur << endl;
        }
      }
    }
  }
  int pls = 16000;
  for(int i = 0;i <= rl.size();i++) for(int j = -2*sumrl;j <= 2*sumrl;j++) dpx[i][j+pls] = false;
  for(int i = 0;i <= ud.size();i++) for(int j = -2*sumud;j <= 2*sumud;j++) dpy[i][j+pls] = false;
  dpx[1][rl.at(0)+pls] = true;dpy[0][pls] = true;
  for(int i = 1;i < rl.size();i++){
    for(int j = -sumrl;j <= sumrl;j++){
      if(dpx[i][j+rl.at(i)+pls] == true || dpx[i][j-rl.at(i)+pls] == true) dpx[i+1][j+pls] = true;
      else dpx[i+1][j+pls] = false;
    }
  }
  for(int i = 0;i < ud.size();i++){
    for(int j = -sumud;j <= sumud;j++){
      if(dpy[i][j+ud.at(i)+pls] == true || dpy[i][j-ud.at(i)+pls] == true) dpy[i+1][j+pls] = true;
      else dpy[i+1][j+pls] = false;
    }
  }
  if(dpx[rl.size()][x+pls] == true && dpy[ud.size()][y+pls] == true){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 248320
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int n;

    Scanner in = new Scanner(System.in);

    n = in.nextInt();

    for(int i=1; i<=n; i++){
        int x = i;
        
        if(x%3 == 0){
            System.out.print(" " + i);
        }else{
            while(x>0){
                if(x%10 == 3){
                    System.out.print(" " + i);
                    break;
                }
                x = x/10;
            }
        }
    }
    System.out.println();
  }
}

Measured memory_bytes: 28796
#include <iostream>
#include <stdio.h>
#define swap(a,b) {a=a+b; b=a-b; a=a-b;}

using namespace std;

void q4() {
	double a, b, c, d, e, f;
	for (; cin >> a >> b >> c >> d >> e >> f;) {
		//cin >> a >> b >> c >> d >> e >> f;
		//scanf_s("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f);

		if (a == 0) {
			swap(a, d);
			swap(b, e);
			swap(c, f);
		}
		b /= a;
		c /= a;
		a = 1;

		e -= b * d;
		f -= c * d;
		d = 0;

		f = f / e;
		e = 1;
		
		c -= f * b;
		b = 0;

		printf("%.3f %.3f\n", c, f);
	}
}

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

Measured memory_bytes: 3124
# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b

n, k = map(int, input().split())
buildings = list(map(int, input().split()))
# 一番目は必ず見えるとして、それ以外のどれが見えるかを考える。
# どれが見えるかは、全部やればいい。
most_left = buildings[0]
buildings = buildings[1:]
ans = float('inf')
for i in range(2 ** len(buildings)):
    if bin(i).count('1') < k - 1:
        continue
    t = most_left # 初期化
    cost = 0
    for j in range(len(buildings)):
        if (i >> j) & 1:
            if t >= buildings[j]:
                cost += t - buildings[j] + 1 # 差分より、1高い必要がある。
                t += 1 #新しく増築したモノが、前のモノより高くなる。
            else:
                # より高い建物があった場合、costは増加しないが視界を塞ぐ建物は高くなる。
                t = buildings[j]
        else: # より高い建物があった場合、costは増加しないが視界を塞ぐ建物は高くなる。
              # そして、これは建物を高くしようとしていなくても、発生する。
            if t < buildings[j]:
                t = buildings[j]
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 40940
def grinp(h):
  ret=[]
  for i in range(h):
    ret.append(list(input()))
  return ret
h,w=map(int,input().split())
grid=grinp(h)
fa=False
for i in range(h):
  for j in range(w):
    if grid[i][j]==".":
      continue
    fl=0
    if i!=0 and grid[i-1][j]=="#":
      fl+=1
    if i!=h-1 and grid[i+1][j]=="#":
      fl+=1
    if j!=0 and grid[i][j-1]=="#":
      fl+=1
    if j!=w-1 and grid[i][j+1]=="#":
      fl+=1
    if fl==0:
      fa=True
      break
  if fa:
    break
if fa:
  print("No")
else:
  print("Yes")
    

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


int main()
{
	string S;
	int N, K;
	char A;
	cin >> N >> S >> K;
	A = S.at(K-1);
	for (int i=0;i<N;i++){
      	if (S.at(i)!=A)S.at(i) = '*';
	}
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var A = one[0];
	var B = one[1];
	if(B == 1){
		myout(0);
		return;
	}
	if(B <= A){
		myout(1);
	}else{
		var mass = 1;
		var count = 0;
		while(B > mass){
			count++;
			mass += A - 1;
		}
		myout(count);
	}
	
}


Measured memory_bytes: 31264