akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
//#include<boost/multi_array.hpp>
//#include<boost/optional.hpp>
//#include<boost/range/irange.hpp>
//#include<boost/range/algorithm.hpp>
//#include<boost/range/adaptors.hpp>

using namespace std;
//namespace adaptor = boost::adaptors;

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

void Main()
{
	int x, y;
	cin >> x >> y;
	if(x * 2 <= y && y <= x * 4 && y % 2 == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define all(c) begin(c),end(c)
const ll INF = 1e10;
int main() {
	cin.sync_with_stdio(false);
	string N;
	cin >> N;
	if (N[0] == N[1] && N[1] == N[2] || N[1] == N[2] && N[2] == N[3])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#define taskname "t"
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
typedef long long lli;
typedef vector<int> TAdj;
const int maxN = 2e5 + 1;

int n, m;
lli bit[maxN];
TAdj ke[maxN];
int L[maxN], R[maxN];

void Enter()
{
    cin >> n >> m;
    for (int i=1;i<n;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
       // ke[v].push_back(u);
    }
}

int Time = 0;

void Visit(int u)
{
    L[u] = ++Time;
    for (int v: ke[u]) Visit(v);
    R[u] = Time;
}

void Init()
{
    fill_n(bit + 1, n, 0);
    Visit(1);
}

void Increase(int x, lli Delta)
{
    for (; x > 0; x &= x - 1)
        bit[x] += Delta;
}

lli Query(int x)
{
    lli res =0;
    for (x = L[x]; x <= n; x += x & -x)
        res += bit[x];
    return res;
}

void Solve()
{
    for (; m > 0; --m)
    {
        int u,x;
        cin >> u >> x;
        Increase(R[u], x);
        Increase(L[u]-1, -x);
    }
    for (int i=1;i<=n;i++) cout<<Query(i)<<" ";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // freopen(taskname".inp", "r", stdin);
 //   freopen(taskname".out", "w", stdout);
    Enter();
    Init();
    Solve();
}


Measured memory_bytes: 22784
#include<iostream>
using namespace std;
struct list {
	int u;
	int k;
	int v[100];
};

int main() {
	int n;
	struct list link[100];
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> link[i].u;
		cin >> link[i].k;
		for (int j = 0; j < link[i].k; j++) {
			cin >> link[i].v[j];
		}
	}
	int MAD[100][100] = {};

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < link[i].k; j++) {
			MAD[i][(link[i].v[j])-1] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << MAD[i][j];
			if(j!=n-1)cout << " ";
		}
		cout << endl;
	}
}


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

bool solve();

int main()
{
	if (solve()) puts("Yes");
	else puts("No");

	return 0;
}

bool solve()
{
	int N;
	scanf("%d", &N);
	std::vector<int> H(N);
	for (auto& e: H) scanf("%d", &e);
	for (int i{N - 2}; i >= 0; i--)
	{
		if (H[i] > H[i + 1] + 1) return false;
		if (H[i] == H[i + 1] + 1) H[i]--;
	}
	return true;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 31 21:05:29 JST 2020
 **/

signed main() {
    Int a, b;
    std::cin >> a >> b;
    std::cout << a * b << std::endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
#define rep(i,n,m) for((i)=(int)(n);(i)<=(int)(m);(i)++)

int memo[301];

int main(void){
  int i,j,n,coin[18];

  rep(i,0,16)coin[i]=(i+1)*(i+1);
  memo[0]=1;

  rep(i,0,16)rep(j,1,300)
    if(j>=coin[i])memo[j]+=memo[j-coin[i]];
  
  while(scanf("%d",&n),n)
    printf("%d\n",memo[n]);
  
  return 0;
}

Measured memory_bytes: 0
'use strict'

/////////////////////////////////////
//コピペスペース//////////////////////

//定数
const INF  =  900719925474099 // Math.floor(Number.MAX_SAFE_INTEGER / 10);

//スペース区切りの数字列を数字の配列にして返す
function mapint(line){return line.split(' ').map((v)=>parseInt(v));}

function lower_bound(d,a,b,e){
    for(var c;1<b-a;)
        d[c=0|(a+b)/2]<e ? a=c : b=c;
    return d[a]<e?b:a
};

const N109 = 1000000000;
const MOD = N109+7;

//コピペスペース//////////////////////
/////////////////////////////////////

function Main(input){
	let temp = input.trim();
	let n = parseInt(temp);

	let count = 0;
	for(let i=1;i<=n;i++){
		if(i<=9){
			count++;
		}else if(100<=i&&i<=999){
			count++;
		}else if(10000<=i&&i<=99999){
			count++;
		}
	}
	console.log(count);
}

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


Measured memory_bytes: 7500
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;
typedef queue<ll> qi;
typedef queue<char> qc;
typedef queue<string> qs;
typedef vector<char> vc;
typedef vector<string> vs;
typedef map<char,ll> mpci;
typedef map<ll,ll> mpii;
typedef map<string,ll> mpsi;
typedef set<ll> sei;
typedef set<char> sec;
typedef set<string> ses;
typedef stack<ll> si;
typedef stack<char> sc;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pll> vpll;
typedef vector<pdd> vdd;
typedef unsigned int uint;
typedef long double ld;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vii> vvii;
/*=====================================================================*/
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define len(a) (int)(a.length())
#define all(s) (s).begin(),(s).end()
#define fi first
#define se second
#define be begin
#define en end
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<n;i++)
#define ford(i,p,n) for(int i=n-1;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define zero(a) memset(a,0,sizeof(a))
#define number(a,num) memeset(a,num,sizeof(a))

/*=====================================================================*/

inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
/*======================================================================*/
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
int ans=0;
/*======================================================================*/
int main()
{
  /*
	ios_base::sync_with_stdio(0);
	cin(tie);
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  int n,p;
  cin>>n>>p;
  rep(i,n)
  {
  	int a;
  	cin>>a;
  	if(a>=p)
  	  ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    long int a,b,c,k,s=0,i=0;
    scanf("%ld%ld%ld%ld",&a,&b,&c,&k);
    while(i<k){
        if(a>0){
            s++; a--;
        }
        else if(b>0)
            b--;
        else 
            s--;
        i++;
    }
    printf("%ld\n",s);
    return 0;
}

Measured memory_bytes: 1708
<?php
# 整数の入力
fscanf(STDIN, "%d", $a);
# スペース区切りの整数の入力
//fscanf(STDIN, "%d %d", $b, $c);
# 文字列の入力
$s=fgets(STDIN);
$array=explode(' ', $s);
asort($array);
$sum = 0;
//var_dump($array);
//exit;

while(count($array) != 1){
 $sum = (array_splice($array, 0, 1)[0] + array_splice($array, 0, 1)[0]) / 2;
 array_push($array, $sum);
 asort($array);
}

echo $sum;
?>

Measured memory_bytes: 3828
#include <bits/stdc++.h> 
using namespace std; 
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int main()
{
  //flash;
	int x;
	cin>>x;
	ve hedi;
	ll ans=0;
	for (int i = 0; i < x-1; ++i)
	{
		ll yo;
		cin>>yo;
		if(i==0)ans+=yo;
		if(i==(x-2))ans+=yo;
		hedi.pb(yo);
	}
	for (int i = 1; i < (x-1); ++i)
	{
		if(hedi[i]<=hedi[i-1])ans+=hedi[i];
		else ans+=hedi[i-1];
	}
	cout<<ans;
  return 0;
}
//code the AC sol !
// BS/queue/map


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
state = [list(input().rstrip()) for _ in range(H)]

def nexts(h, w):
    pq = []
    if h != 0: pq.append((h-1, w))
    if w != 0: pq.append((h, w-1))
    if h != H-1: pq.append((h+1, w))
    if w != W-1: pq.append((h, w+1))
    return pq


def bfs(sh, sw):
    Ds = [[-1]*W for _ in range(H)]
    q = [(sh, sw)]
    d = 0
    Ds[sh][sw] = 0
    while q:
        qq = []
        d += 1
        for h, w in q:
            for nh, nw in nexts(h, w):
                if state[nh][nw] == "#":
                    Ds[nh][nw] = -2
                elif Ds[nh][nw] == -1:
                    Ds[nh][nw] = d
                    qq.append((nh, nw))
        q = qq
    
    maxd = 0
    for h in range(H):
        for w in range(W):
            if maxd < Ds[h][w]:
                maxd = Ds[h][w]
                lh, lw = h, w
    return maxd

ans = 0
for h in range(H):
    for w in range(W):
        if state[h][w] == ".":
            d = bfs(h, w)
            ans = max(ans, d)

print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split())

A_list = list(map(int, input().split()))

a = list(map(lambda x: x*(-1), A_list))

import heapq
import math


heapq.heapify(a)



for i in range(M):
        max_p = heapq.heappop(a)
        max_p = max_p / 2
        heapq.heappush(a, max_p)

res=0
for i in range(N):
        a[i] = -a[i]
        res += math.floor(a[i])

print(res)

Measured memory_bytes: 14228
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 nn, aa;
	cin >> nn;
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> aa;
		if(aa % 2 == 0)
		{
			if(aa % 5 == 0 || aa % 3 == 0)
			{
				continue;
			}
			else
			{
				puts("DENIED");
				return 0;
			}
		}
	}
	puts("APPROVED");
	return 0;
}

Measured memory_bytes: 3612
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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






int main(){
    int N, K; std::cin >> N >> K;
    std::vector<int> h(N), dp(N, 2*INF);
    for(int i(0); i < N; ++i) std::cin >> h[i];
    dp[0] = 0; dp[1] = std::abs(h[0]-h[1]);
    for(int i(1); i < N; ++i){
        for(int j(1); j <= K; ++j){
            if(i - j < 0) break;
            chmin(dp[i], dp[i-j] + std::abs(h[i] - h[i-j]));
        }
    }
    std::cout << dp[N-1] << std::endl;
    return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  string s; cin>>s;
  map<char,ll> m;
  rep(i,n){
    m[s[i]]++;
  }
  ll ans=m['R']*m['G']*m['B'];
  
  ll span=1;
  ll tmp=0;
  while(span<=n){
    rep(i,n){
      if(i+span*2>=n) break;
      if(s[i]!=s[i+span] && s[i+span]!=s[i+span*2] && s[i]!=s[i+span*2]){
        tmp++;
      }
    }
    span++;
  }
  cout<<ans-tmp<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int A[1];
int size=1;
int m=2;
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
/*
bool prime(ll n){if(n==1)return false;for(ll i=2;i*i<=n;i++)if(n%i==0){return false;}return true;}
void prime_fact(int n){for(int i=2;i*i<=n;i++){int count=0;if(n%i==0){while(n%i==0)n/=i,count++;cout<<i<<"^"<<count<<" ";}}if(n>1)cout<<n<<"^1";}
ll power(ll base ,ll pow){ll res=1;while(pow>0){if(pow&1)res*=base,pow-=1;else base*=base,pow/=2;}return res;}
void prime_fact_seieve(int n){for(int i=2;i<=size;i++){if(A[i]==0)for(ll j=i;j<=size;j+=i)if(A[i]==0)A[j]=i;}while(n>2){cout<<A[n]<<"*";n/=A[n];}}
template <class X> X gcd(X a , X b) { return b==0?a: gcd( b, a%b); }
template <class X> X lcm(X a , X b) { return a/gcd(a,b) * b ; }
ll Ab[N][N],I[N][N];  // identity matrix and a matrix to store result
void multiply(ll I[][N],ll A[][N],int dim)
{   int res[dim+1][dim+1];
    for(int i=0;i<dim;i++)
    {  for(int j=0;j<dim;j++)
        {
           res[i][j]=0;
           for(int k=0;k<dim;k++)
           {  res[i][j]+=((I[i][k]%mod)*(A[k][j])%mod)%mod;}}}

        for(int i=0;i<dim;i++)
            for(int j=0;j<dim;j++)
                I[i][j]=res[i][j];}
void powerMat(ll A[][N],int dim,int n)
{   for(int i=0;i<dim;i++)
    for(int j=0;j<dim;j++)
    {if(i==j) I[i][j]=1;
     else     I[i][j]=0;}
     while(n>0)
     {
         if(n%2)
         multiply(I,A,dim),n--;
         else
         multiply(A,A,dim),n/=2;
     }
     for(int i=0;i<dim;i++)
         for(int j=0;j<dim;j++)
             A[i][j]=I[i][j];
}
void printMat(ll A[][N],int dim)
{
    for(int i=0;i<dim;i++)
    {for(int j=0;j<dim;j++)
        {
            cout<<A[i][j]<<" ";
        }cout<<"\n";}
}
// REMEMBER PREFIX SUM SUFFIX SUM OR GCD VERY INTERESTING QUESTIONS
ll power(ll base ,ll pow,ll mo){ll res=1;while(pow>0){if(pow&1)res=(res%mo*base%mo)%mo,pow-=1;else base=(base%mo*base%mo)%mo,pow/=2;}return res;}*/
bool Binary(vector<int> arr,int n,int ele,int b)
{  int l=0,r=n-1,m;
   while(l<=r)
   {
       m=l+(r-l)/2;
       if(arr[m]==ele)
       {arr[m]=b;return true;}
       else if(arr[m]>ele)
           r=m-1;
       else
           l=r+1;
   }
    return false;

}

int main()
{
    fast;
    int n,m;
    cin>>n>>m;
    int arr[31];
    f(i,31)arr[i]=0;
    int temp=n;
    int count=0;
    while(n--)
    {
        int k;
        cin>>k;
        while(k--)
        {
            int a;
            cin>>a;
            arr[a]++;
        }
    }
    f(i,31)
    {  \
        if(arr[i]==temp)
            count++;
    }
    cout<<count;


}


Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <queue>
#include <map>
#include <string>
const int INF = 99999999;
const int MIN = -0xffffff0;
using namespace std;

int num[4];
int flag = 0;
char op[5];

void DFS(int step,int sum){
    if(flag) return;
    if(step == 4){
        if(sum == 7) flag = 1;
        else flag = 0;
        return ;
    }
    if(step == 0){
        sum = num[step];
        DFS(step+1,sum);
        return;
    }
    for(int i=0;i<2;i++){
        if(!i){
            DFS(step+1,sum+num[step]);
            if(flag){
                op[step] = '+';
                return ;
            }
        }
        else{
            DFS(step+1,sum-num[step]);
            if(flag){
                op[step] = '-';
                return;
            }
        }
    }
}

int main(){
    char s[5];
    cin >> s;
    for(int i=0;i<4;i++) num[i] = s[i]-'0';
    DFS(0,0);
    cout << num[0];
    if(flag){
        for(int i=1;i<=3;i++) cout << op[i] << num[i];
        cout << "=7";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#include <bits/stdc++.h>
string x,s,u;
int a,c;
int main(){
    cin>>x>>s;
    cin>>a>>c;
    cin>>u;
    if(x==u){
        a-=1;
        cout<<a<<' '<<c<<endl;
    }
    else{
        c-=1;
        cout<<a<<' '<<c<<endl;
    }
}

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

#define N_MAX   100
#define E_MAX   1000
#define E_BUF_MAX   4 * E_MAX + 1

double calc_distance(const int *x, const int *y, int dx, int p);
double calc_chebychev_dist(const int *x, const int *y, int dx);
int read(int *x, int *y, int *n);
int read_elements(int *data, int n);

double calc_distance(const int *x, const int *y, int dx, int p)
{
    int i;
    double sum = 0;

    if(p < 0) return calc_chebychev_dist(x, y, dx);

    for(i=0;i<dx;i++) {
        sum += pow((double)(abs(x[i] - y[i])), (double)p);
    }

    return pow(sum, 1.0 / (double)p);
}

double calc_chebychev_dist(const int *x, const int *y, int dx)
{
    int i;
    int d_max = abs(x[0] - y[0]);

    for(i=1;i<dx;i++) {
        int d;
        if(d_max < (d = abs(x[i] - y[i]))) d_max = d;
    }

    return (double)d_max;
}

int read_elements(int *data, int n)
{
    int i;
    char str[E_BUF_MAX] = {};
    char temp[] = " \n";

    fgets(str, E_BUF_MAX, stdin);
    data[0] = atoi(strtok(str, temp));
    for(i=1;i<n;i++) {
        data[i] = atoi(strtok(NULL, temp));
    }

    return 0;
}

int read(int *x, int *y, int *n)
{
    scanf("%d%*c", n);
    if(*n == 0) return 0;

    read_elements(x, *n);
    read_elements(y, *n);

    return 1;
}

int main(void)
{
    int i;
    int n;
    int x[N_MAX] = {};
    int y[N_MAX] = {};

    read(x, y, &n);

    printf("%.8f\n", calc_distance(x,y,n,1));
    printf("%.8f\n", calc_distance(x,y,n,2));
    printf("%.8f\n", calc_distance(x,y,n,3));
    printf("%.8f\n", calc_distance(x,y,n,-1));

    return 0;
}

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

using ll = long long;

int main()
{
    ll N;
    cin >> N;

    ll wa = 5;
    ll count = 0;
    while(true){
        if(N / wa == 0){
            break;
        }
        count += N / wa;
        wa *= 5;
    }

    ll wa2 = 10;
    ll count2 = 0;
    while (true)
    {
        if (N / wa2 == 0)
        {
            break;
        }
        count2 += N / wa2;
        wa2 *= 5;
    }

    if(N % 2 == 0){
        cout << count2 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int w,a,b,ans;
    scanf("%d %d %d",&w,&a,&b);
    if(a<b){
        if(a+w<b){
            ans=b-(a+w);
        }
        else if(a+w>b){
            ans=0;
        }
    }else{
        if(b+w<a)
        ans=a-(b+w);
        else
            ans=0;
    }
    printf("%d\n",ans);
    return 0;
   }

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

S = input()
N = len(S)+1

ans = [-1]*(N)

for i in range(N-2):
	if S[i] == ">" and S[i+1] == "<":
		ans[i+1] = 0

if S[0] == "<":
	ans[0] = 0

if S[-1] == ">":
	ans[-1] = 0

for i in range(N-1):
	if S[i] == "<" and ans[i] != -1 and ans[i]+1 > ans[i+1] and ans[i+1] != 0:
		ans[i+1] = ans[i] + 1

#print(ans)

for i in range(N-2, -1, -1):
	if S[i] == ">" and ans[i+1] != -1 and ans[i+1]+1 > ans[i] and ans[i] != 0:
		ans[i] = ans[i+1] + 1

#print(ans)
print(sum(ans))

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	set<int>s;
	int in;
	for(int i = 0; i < 3; i++){
		cin >> in;
		s.insert(in);
	}

	cout << s.size() << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long long n;
    cin>>n;

    long long five=0,bord=1;

    bord=1;
    if(n%2==0){
      while(n>=bord){
	bord*=5;
	five+=(n/bord)/2;
      }
      cout<<five<<'\n';
    }
    else{
      cout<<0<<'\n';
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

for i in range(N-1):
    if H[i] > H[i+1]:
        H[i] -= 1
    elif H[i] == H[i+1]:
        if H[i]-1 >= H[i-1]:
            H[i] -= 1

for i in range(N-1):
    if H[i] > H[i+1]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  string s,t;
  cin >> s >> t;
  string ans = "Yes";
  rep(i,s.size()){
    if(s.at(i) != t.at(i))ans = "No";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	LL n; cin >> n;

	double ans = 0;

	LL YEN = 0;
	double BTC = 0.0;
	for (int i = 0; i < n; i++) {
		double x; string s; cin >> x >> s;

		if (s == "JPY") {
			YEN += x;
		}
		else {
			BTC += x;
		}

	}

	ans = YEN + BTC * 380000.0;

	cout << fixed << setprecision(12) << ans << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}


int main(){
    int n,check=0,ans=0,b;
    cin>>n;
    vector<int> a(n),c(n-1);
    rep(i,n) cin>>a[i];
    rep(i,n){
        cin>>b;
        ans+=b;
    }
    rep(i,n-1) cin>>c[i];
    rep(i,n){
        if(check!=0 && a[i]-check==1){
            ans+=c[check-1];
        }
        check=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
numbertable = []
for i in range(0, 3):
	numbertable.append(list(map(int, input().split())))
flag = True
for i in range(0, 3):
	for j in range(0, 3):
		if numbertable[i][j] + numbertable[(i+1)%3][(j+1)%3] != numbertable[i][(j+1)%3] + numbertable[(i+1)%3][j]:
			flag = False
			break
	if not flag: break
if flag: print('Yes')
else: print('No')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

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

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

ll check(vector<ll> a){
  ll sum = 0;
  ll odd = 0;
  ll one = 0;
  YYS(w, a){
    sum += w;
    if(w % 2 == 1){
      odd++;
    }
    if(w == 1){
      one++;
    }
  }
  if(one >= 1){
    if(sum % 2 == 0){
      return 0;
    } else {
      return 1;
    }
  }
  if(sum % 2 == 0){
    return 0;
  }
  if(odd > 1){
    return 1;
  }
  assert(odd == 1);
  vector<ll> na(0);
  YYS(w, a){
    if(w % 2 == 1){
      na.pb(w - 1);
    } else {
      na.pb(w);
    }
  }
  ll g = na[0];
  YYS(w, na){
    g = __gcd(g, w);
  }
  REP(i, SZ(na)){
    na[i] /= g;
  }
  return 1 - check(na);
}

int main(){

  ll n = in();
  vector<ll> a(n);
  ll sum = 0;
  REP(i, n){
    a[i] = in();
    sum += a[i];
  }
  if(n % 2 == 0){
    if(sum % 2 == 0){
      puts("Second");
    } else {
      puts("First");
    }
    return 0;
  }

  ll ans = check(a);

  if(ans == 0){
    puts("First");
  } else {
    puts("Second");
  }
  
  return 0;
}


Measured memory_bytes: 38004
#include<iostream>
#define endl "\n"
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int A=c;
	int T =a;
	while (1){	
		A = A - b;
		T = T - d;
		if (A <= 0){ cout << "Yes"; break; }
		if (T <= 0){ cout << "No"; break; }
	}
	return 0;
}

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

int main() {
  int DIV = 998244353;
  int N, S; cin >> N >> S;
  int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  int D[S+1]; D[0] = 1;
  for (int i = 1; i <= S; i++) D[i] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = S-A[i]; j >= 0; j--) {
      long n = D[j];
      if (j == 0) n = i+1;
      if (j + A[i] == S) n *= N-i;
      D[j+A[i]] = (D[j+A[i]] + n) % DIV;
    }
  }
  cout << D[S] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;

int n, m;
int ans;
 
int main(){
  ios_base::sync_with_stdio(false);

  cin >> n >> m;
  
  int nn = (1 << m); 
   
  ans += (n - m) * 100;
  ans += m * 1900; 
  ans *= nn; 
  
  cout << ans << endl;
 
  return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define int int64_t
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int n, cnt = 0, ans = 0;
   cin >> n;
   int a = sqrt(n);
   vector<int> x;

   reps(i, a)
   {
      if (n % i == 0)
      {
         ans = (i - 1) + (n / i - 1);
         x.push_back(ans);
      }
   }

   sort(all(x));

   cout << x[0] << '\n';
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] map = new int[h][w];
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                map[i][j] = sc.nextInt();
            }
        }
        ArrayList<String> li = new ArrayList<>();
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                int pi = i+1;
                int pj = j+1;
                if(map[i][j] % 2 == 0 || i == h-1 && j == w-1){
                    continue;
                }else if(j == w-1){
                    li.add(pi + " " + pj + " " + (pi+1) + " " + pj);
                    map[i+1][j]++;
                }else{
                    li.add(pi + " " + pj + " " + pi + " " + (pj+1));
                    map[i][j+1]++;
                }
            }
        }
        System.out.println(li.size());
        for(String s : li){
            System.out.println(s);
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed 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<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    string o,e;
    cin >> o >> e;
    rep(i,0,min(sz(o),sz(e)))cout << o[i] << e[i];
    if(sz(o) > sz(e))cout << o[sz(o)-1] << endl;
    else cout << endl;
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec x(n),y(n),h(n);
  for(ll i=0;i<n;i++) {
    cin >> x[i] >> y[i] >> h[i];
  }
  for(ll tx=0;tx<=100;tx++) {
    for(ll ty=0;ty<=100;ty++) {
      ll th=inf;
      for(ll i=0;i<n;i++) {
        th=min(th,abs(tx-x[i])+abs(ty-y[i])+h[i]);
      }
      ll f=1;
      for(ll i=0;i<n;i++) {
        ll tth=max(th-abs(tx-x[i])-abs(ty-y[i]),0LL);
        if(tth!=h[i])f=0;
      }
      if(f) {
        cout << tx << " " <<  ty << " " << th << endl;
        return 0;
      }
    }
  }
}

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

void solve(int n){
	if(!n)
		return;
	if(n%(-10) < 0)
		solve((n-10)/(-10));
	else
		solve(n/(-10));
	if(n%(-10) < 0)
		cout << 10+n%(-10);
	else
		cout << n%(-10);
}

int main(){
	int n;
	while(true){
		cin >> n;
		if(!n)
			return 0;
		solve(n);
		cout << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int n,a,b,c;
string s[100005];
char ans[100005];
void print(){
	cout<<"Yes"<<endl;
	for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
}
void check(){
	for(int i=1;i<=n;i++){
		if(s[i]=="AB"){
			if(a==0&&b==0){
				cout<<"No";
				exit(0);
			}
			if(a==1&&b==1&&c==0&&i!=n&&s[i+1]=="AC"){
				ans[i]='A';
				a++;
				b--;
				continue;
			}
			if(a==1&&b==1&&c==0&&i!=n&&s[i+1]=="BC"){
				ans[i]='B';
				b++;
				a--;
				continue;
			}
			if(a>b){
				ans[i]='B';
				b++;
				a--;
			}else{
				ans[i]='A';
				a++;
				b--;
			}
		}
		if(s[i]=="AC"){
			if(a==0&&c==0){
				cout<<"No";
				exit(0);
			}
			if(a==1&&b==0&&c==1&&i!=n&&s[i+1]=="AB"){
				ans[i]='A';
				a++;
				c--;
				continue;
			}
			if(a==1&&b==0&&c==1&&i!=n&&s[i+1]=="BC"){
				ans[i]='C';
				c++;
				a--;
				continue;
			}
			if(a>c){
				ans[i]='C';
				c++;
				a--;
			}else{
				ans[i]='A';
				a++;
				c--;
			}
		}
		if(s[i]=="BC"){
			if(b==0&&c==0){
				cout<<"No";
				exit(0);
			}
			if(a==0&&b==1&&c==1&&i!=n&&s[i+1]=="AB"){
				ans[i]='B';
				b++;
				c--;
				continue;
			}
			if(a==0&&b==1&&c==1&&i!=n&&s[i+1]=="AC"){
				ans[i]='C';
				c++;
				b--;
				continue;
			}
			if(b>c){
				ans[i]='C';
				c++;
				b--;
			}else{
				ans[i]='B';
				b++;
				c--;
			}
		}
	}
	print();
}
int main(){
	cin>>n>>a>>b>>c;
	for(int i=1;i<=n;i++) cin>>s[i];
	check();
	return 0;
}


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

int main(){
  int N;
  string s, t;
  cin >> N;
  cin >> s;
  cin >> t;
  
  int twin = 0;

  for(int i=1; i<=N; i++){
    for(int j=0; j<i; j++){
      if(s.at(N - i + j) != t.at(j)){
        break;
      }
      else if(j + 1 == i){
        twin = i;
      }
    }
  }

  int ans = N * 2 - twin;
  cout << ans << endl;
}

Measured memory_bytes: 256
N, K = list(map(int, input().split()))
S = input()
ans = 0

for i in range(N):
    if S[i] == 'L' and i != 0 and S[i] == S[i-1]:
        ans += 1
    elif S[i] == 'R' and i != N - 1 and S[i] == S[i+1]:
        ans += 1

print(min(ans + 2 * K, N-1))


Measured memory_bytes: 40048
import java.util.Arrays;
import java.util.Scanner; // 文字列を標準入力からscanする

public class Main { 

  static long return_smaller(long a, long b){
    if(a > b){
      return b;
    }
      return a;
  }
    
  public static void main(final String[] args) {
    Scanner scan = new Scanner(System.in);
		String str = "";
    str = scan.nextLine();
    String[] strs2 = str.split(" ");
    int N = Integer.parseInt(strs2[0]);
    int K = Integer.parseInt(strs2[1]);
    
    long[] hi = new long[N+K+1];
    long[] dp = new long[N+K+1];
    long oo = 1L << 60;
    Arrays.fill(dp, oo);

    str = scan.nextLine();
    String[] strs3 = str.split(" ");
    for(int i=0; i<strs3.length; i++) {
      hi[i] = Integer.parseInt(strs3[i]);
    }
    scan.close();

    int i = 0;
    int j = 0;

    dp[0] = 0;
    for (i = 0; i < N; i++) {
      for(j = 1; j <= K; j++){
        dp[i+j] = return_smaller(dp[i+j], dp[i] + Math.abs(hi[i] - hi[i+j]));
      }
    }

    System.out.println(dp[N-1]);

  }
}

Measured memory_bytes: 63988
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var w = int.Parse(Console.ReadLine());
        string res = S[0].ToString();
        int current = 0;
        while (current + w < S.Length)
        {
            current += w;
            res += S[current].ToString();
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N, M; cin >> N >> M;
    vector<int> X(M);
    for(int &x:X){
        cin >> x;
    }
    
    sort(X.begin(), X.end());
    vector<int> diff(M-1);
    ll sum = 0;
    for(int i=0; i<M-1; i++){
        sum += abs(X[i+1] - X[i]);
        diff[i] = abs(X[i+1] - X[i]);
    }
    
    sort(diff.begin(), diff.end(), greater<int>());
    for(int i=0; i<min((int)diff.size(), N-1); i++){
        sum -= diff[i];
    }

    cout << sum << endl;
    
    
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
#include<stdio.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

int dp[50010];
int c[30];

int main(void){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<=50000;i++)dp[i]=50000;
	for(int i=0;i<m;i++){
		cin>>c[i];
		dp[c[i]]=1;
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<m;j++){
			if(i>=c[j]){
				dp[i]=min(dp[i],dp[i-c[j]]+1);
			}
		}
	}
	cout<<dp[n]<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N,K; cin>>N>>K;
	vector<int> A(N);
	for (int i=0; i<N; i++)
		cin>>A[i];
	for (int i=K; i<N; i++)
		cout<<(A[i]>A[i-K] ? "Yes" : "No")<<"\n";
	return 0;
}

Measured memory_bytes: 3988
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
long long go_next[26][300000];
int main(){
#define int long long
	string s, t;
	cin >> s >> t;
	long long modder = s.length();
	s += s;
	REP(i, 26) {
		go_next[i][s.length()-1] = -1;
	}
	for (int i = s.length() - 2; i >= 0; --i) {
		REP(q, 26) {
			go_next[q][i] = go_next[q][i + 1];
		}
		go_next[s[i+1] - 'a'][i] = i+1;
	}
	long long now_itr = -1;
	long long ans = 0;
	for (int i = 0; i < modder; ++i) {
		if (s[i] == t[0]) {
			now_itr = i;
			break;
		}
	}
	if (now_itr == -1) {
		cout << -1 << endl;
		return 0;
	}
	ans = now_itr + 1;
	for (int i = 1; i < t.length(); ++i) {
		long long next_visit = go_next[t[i] - 'a'][now_itr];
		if (next_visit == -1) {
			cout << -1 << endl;
			return 0;
		}
		ans += next_visit - now_itr;
		now_itr = next_visit % modder;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 60316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();

        char prev = s.toCharArray()[0];
        int res = 1;
        for (char c : s.toCharArray()) {
            if (prev == c) {
                continue;
            }
            res++;
            prev = c;
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 26768
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, M;
    cin >> N >> M;
    if(N==M) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3580