akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n,k;
    cin >> n >> k;
    double p=0.0;
    repi(i,1,n+1){
        int ctr=0;
        ll c=i;
        while(c<k){
            c*=2;
            ctr++;
        }
        p+=(1.0/n)*pow(0.5,ctr);
    }
    print(p);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
//#define for(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0};

void solve(){
	string s;
	cin>>s;
	int arr[27]={0};
	for(int i=0;i<s.size();i++){
		//cout<<s[i]-65<<endl;
		arr[s[i]-65]++;
	}
	int cnt=0;
	for(int i=0;i<27;i++){
		if(arr[i]>0)cnt++;
	}
	if(cnt==2){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
}
signed main(){
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

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

int main(){
int N;
  string S;
  cin>>N>>S;
  int res=0, ans=0;
  for(int i=0; i<N; i++){
   if(S[i]=='E'){ans++;}
  }  // 全体のEの数。Sが全てEでも最大値、全てWでも最小値に使える。
  
  res=ans;
  
  for(int i=0; i<N; i++){
   if(S[i]=='W'){ans++;}  //  W/EEWW、WE/EWW、...という区切りで見ていく。
   if(S[i]=='E'){ans--;}  // Wが来たら方向転換の必要があるからans++する
    res=min(res, ans);  // Eが来たら方向転換の必要はなく、ansは既に全体のEの数を含むからans--する
  }  //  加えられたWの数と、残ったEの数の最小が、方向転換の最小値となる。
 
  cout<<res;
}


Measured memory_bytes: 900
#include<stdio.h>

int main(){
	
	
	double x;
	
	double countodd=0;
	
	double total=0;
	
	scanf("%lf",&x);
	
	for(int i=1;i<=x;i++){
		
		if(i%2!=0){
			countodd++;
		}
		
	}
	
	total=countodd/x;
	
	printf("%.9lf\n",total);
	
	return 0;
}


Measured memory_bytes: 128
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    A=[int(input()) for _ in range(N)]

    if A[0]!=0:
        print(-1)
        exit()
    ans=0
    d=0
    for i in range(1,N):
        if A[i]==0: continue
        if A[i]>d+1:
            print(-1)
            exit()
        d=A[i]
        if A[i]==A[i-1]+1:
            ans+=1
        else:
            ans+=A[i]

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 50524
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[100005];
int aa[100005];
int prevs[100005];
bool color[100005];
queue<int>myqueue;
int ans = 0 ;
pair<int,int>aaaa[100005] ;
map<pair<int,int>,int>sagor ;
void bfs(int n,int x)
{
   aa[1] = 0 ;
   prevs[1]= 0 ;
   aa[0] = 0 ;
   color[1] = 1 ;
   sagor[make_pair(0,1)] = -1 ;
    while(!myqueue.empty())
    {
        int s = myqueue.front();
        myqueue.pop();
        int r=1;
        for(int i = 0 ; i < adj[s].size() ; i++ )
        {
            if(color[adj[s][i]]==1)
            {
                myqueue.push(adj[s][i]) ;
               // cout<<r<<" ";
                if(r==aa[s])r++;
               // cout<<r<<endl;

                sagor[make_pair(s,adj[s][i])] = r ;
                ans = max(ans,r) ;

                color[adj[s][i]] = 0 ;
                prevs[adj[s][i]] = s ;
                aa[adj[s][i]] = r;
                   r++;

            }
        }
    }




}
int main()
{
    int n;
    cin>>n ;
    for(int i = 1 ; i < n ; i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        //adj[y].push_back(x);
        aaaa[i] = make_pair(x,y) ;

    }
    for(int i = 1 ; i <= n ; i++ )
    {
        color[i]=1;
    }
    myqueue.push(1);
    bfs(n,1);
    cout<<ans<<endl;
     for(int i = 1 ; i < n ; i++ )
    {
        cout<<sagor[aaaa[i]]<<endl;
    }
    while(!sagor.empty())
    {
        sagor.clear() ;
    }


    return 0;
}


Measured memory_bytes: 12288
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n:usize=read();
    let m:usize=read();
    let a=(0..n).map(|_|read::<String>().chars().collect::<Vec<char>>()).collect::<Vec<Vec<char>>>();
    let b=(0..m).map(|_|read::<String>().chars().collect::<Vec<char>>()).collect::<Vec<Vec<char>>>();
    for i in 0..(n-m+1){
        for j in 0..(n-m+1){
            let mut f=1;
            for k in 0..m{
                for l in 0..m{
                    if a[i+k][j+l]!=b[k][l]{f=0}
                }
            }
            if f>0{
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


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

using namespace std;
typedef long long ll;
const int MAXN = 500100;

int N, Q;
string S;

set <int> s[26];

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> S >> Q;
    for (int i = 0; i < N; i++)
    {
        s[S[i]-'a'].insert(i);
    }

    for (int i = 0; i < Q; i++)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int x; cin >> x;
            char c; cin >> c;
            x--;

            s[S[x]-'a'].erase(x);
            s[c-'a'].insert(x);
            S[x] = c;
        }
        else
        {
            int l, r;
            cin >> l >> r;
            l--, r--;

            int nc = 0;
            for (int j = 0; j < 26; j++)
            {
                auto it = s[j].lower_bound(l);
                if (it == s[j].end()) continue;
                if (*it <= r)
                    nc++;
            }
            cout << nc << "\n";
        }
    }
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

const long double PI = (acos(-1));

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

  int a, b, x;
  cin >> a >> b >> x;
  ll v = a * a * b; //体積
  long double h = 2 * (v-x) / pow(a, 2);
  long double ans = 0.0;
  if (h <= b) {
    // 桁数と変数名を指定
    //cout << fixed << setprecision(6) << ans << endl;
    //cout << fixed << setprecision(7) << h << endl;
    //ans = atan2(h, a) * 180 / M_PI; // こっちがわはあってる
    ans = atan(2*double(a*a*b-x)/(a*a*a)) * 180 / M_PI;
    // 桁数と変数名を指定
    //cout << fixed << setprecision(6) << ans << endl;
  } else {
    h = double(2*x)/b/b;
    //cout << fixed << setprecision(7) << h << ", " << b << endl;
    //ans = 90.0 - double(atan(h/a)) * double(180.0) / M_PI;
    ans = atan(double(b * b * a) / 2 / x) * double(180.0) / M_PI;
    //ans = b * atan
    //cout << fixed << setprecision(7) << atan2(h, b)<< endl;
  }
  cout << fixed << setprecision(7) << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    cin >> n;
    ll sum = 0;
    vector<ll> accum(n+1, 0);
    rep(i, n) accum[i+1] = accum[i] + (ll)(i+1);
    int idx = lower_bound(accum.begin(), accum.end(), n) - accum.begin();
    rep(i, idx) {
        if (accum[idx] - n == (i+1)) continue;
        cout << i+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 81384
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($n,$k) = explode(" ",trim(fgets(STDIN)));
//$a = explode(" ",trim(fgets(STDIN)));
$hh = explode(" ",trim(fgets(STDIN)));
foreach($hh as $v) {
  $h[]=(int)$v;
}
$N=(int)$n;
$K=(int)$k;

$dp[0]=0;
for($i=1;$i<$N;++$i) {
  $dp[$i]=PHP_INT_MAX;
  $limit = min($i,$K);
  for($j=1;$j<=$limit;++$j) {
    $dp[$i]=min($dp[$i],$dp[$i-$j]+abs($h[$i]-$h[$i-$j]));
  }
}
printf("%d\n",$dp[$N-1]);


Measured memory_bytes: 23024
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
int main(){
    int n,x,s=0;
    cin>>n>>x;
    vector<int> v(n);
    rep(i,0,n) {
        cin>>v[i];
        s+=v[i];
    }
    s=x-s;
    sort(v.begin(),v.end());
    int cnt=0;
    rep(i,0,n){
        while(s-v[i]>=0){
            s-=v[i];
            cnt++;
        }    
    }
    cout<<n+cnt;
}

Measured memory_bytes: 256
cand = ["AC", 'WA', 'TLE', "RE"]
res_map = {}
for c in cand:
    res_map[c] = 0

N = int(input())
for _ in range(N):
    s = input()
    res_map[s] += 1
for c in cand:
    print("{} x {}".format(c, res_map[c]))


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

int main() {
 int N;
  cin >> N;
  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);
  bool answer=true;
  for (int i=0;i<N; i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  for(int i=0;i<N;i++){
    if(t.at(i)%2==0){
      if((x.at(i)+y.at(i))%2!=0){
        answer=false;
      }
    }
    else if(t.at(i)%2==1){
      if((x.at(i)+y.at(i))%2!=1){
        answer=false;
      }
    }
  }
  if(t.at(0)<x.at(0)+y.at(0)){
    answer=false;
  }
  for(int i=0;i<N-1;i++){
    if(x.at(i+1)+y.at(i+1)-x.at(i)-y.at(i)>t.at(i+1)-t.at(i)){
      answer=false;
    }
  }
 if(answer){ 
  cout << "Yes" << endl;
 }
  else{
    cout << "No" << endl;
  }
  } 
  


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
char bw[] = {'B', 'W'};

struct STATE { int x, y, t; };

char pile[52][52];
int terr[52][52];

void init()
{
	for (int i = 0; i < 52; i++){
		for (int j = 0; j < 52; j++){
			pile[i][j] = 0;
			terr[i][j] = 0;
		}
	}
}

int main()
{
	int w, h;
	while (scanf("%d %d", &w, &h), w + h){
		init();
		
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				scanf(" %c", &pile[i][j]);
			}
		}
		
		queue<STATE> que;
		for (int t = 0; t <= 1; t++){
			for (int i = 1; i <= h; i++){
				for (int j = 1; j <= w; j++){
					if (pile[i][j] == bw[t]){
						for (int dir = 0; dir < 4; dir++){
							int tx = i + dx[dir];
							int ty = j + dy[dir];
							if (pile[tx][ty] == '.'){
								que.push( {tx, ty, t} );
							}
						}
					}
				}
			}
		}
		
		while (!que.empty()){
			STATE st = que.front(); que.pop();
			if (terr[st.x][st.y] & (1 << st.t)) continue;
			terr[st.x][st.y] |= (1 << st.t);
			for (int dir = 0; dir < 4; dir++){
				int tx = st.x + dx[dir];
				int ty = st.y + dy[dir];
				if (pile[tx][ty] == '.' && !(terr[tx][ty] & (1 << st.t))){
					que.push( {tx, ty, st.t} );
				}
			}
		}
		
		int cnt[2] = {0};
		for (int t = 0; t <= 1; t++){
			for (int i = 1; i <= h; i++){
				for (int j = 1; j <= w; j++){
					cnt[t] += !(terr[i][j] ^ (1 << t));
				}
			}
		}
		
		printf("%d %d\n", cnt[0], cnt[1]);
	}
	
	return 0;
}

Measured memory_bytes: 1260
(n,), *dd = [list(map(int, s.split())) for s in open(0)]

cnt = 0
ans = False
for i in range(n):
    a,b = dd[i]
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ans = True
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61932
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    string s;
    cin>>s;
    int a=0,b=0;
    rep(i,s.size()){
        if(s[i]=='0') a++;
        else b++;
    }
    cout<<2*min(a,b);
}

Measured memory_bytes: 512
import bisect
import numpy as np
n = int(input())


arr = np.arange(4500) + 1
arr = arr.cumsum()

div = bisect.bisect_left(arr, n) + 1

arr = np.arange(div) + 1
rem = arr.sum() - n
arr = arr[np.where(arr != rem)]

print(*arr, sep="\n")

Measured memory_bytes: 13016
function main(input) {
  const lines = input.split("\n").map((e) => Number(e))
  var min = Math.min(lines[0], lines[1])
  min += Math.min(lines[2], lines[3])
  console.log(min)
}


(() => {
  process.stdin.resume();
  process.stdin.setEncoding('utf8');
  var input_string = '';
  process.stdin.on('data', chunk => input_string += chunk);
  process.stdin.on('end', () => main(input_string));
})()


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

const int mod = 1e9 + 7;
const int MN = 2000010;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}
int inv(int x) {
    return exp(x, mod - 2);
}
int fact[MN], invf[MN];
int comb(int n, int k) {
    return 1LL * fact[n] * invf[k] % mod * invf[n - k] % mod;
}

int solve(vector<int> &X, vector<int> &Y) {
    int ret = 0;

    for(int i = Y[1]; i <= Y[2]; i++) {
        int dx1 = X[1] - X[0] - 1;
        int dy1 = i - Y[0];
        int dx2 = X[3] - X[1];
        int dy2 = Y[3] - i;

        ret += 1LL * comb(dx1 + dy1, dx1) * comb(dx2 + dy2, dx2) % mod * (mod - X[1] - i) % mod;
        ret %= mod;
    }
    for(int i = Y[1]; i <= Y[2]; i++) {
        int dx1 = X[2] - X[0];
        int dy1 = i - Y[0];
        int dx2 = X[3] - X[2] - 1;
        int dy2 = Y[3] - i;

        ret += 1LL * comb(dx1 + dy1, dx1) * comb(dx2 + dy2, dx2) % mod * (X[2] + i + 1) % mod;
        ret %= mod;
    }
    for(int i = X[1]; i <= X[2]; i++) {
        int dx1 = i - X[0];
        int dy1 = Y[1] - Y[0] - 1;
        int dx2 = X[3] - i;
        int dy2 = Y[3] - Y[1];

        ret += 1LL * comb(dx1 + dy1, dx1) * comb(dx2 + dy2, dx2) % mod * (mod - Y[1] - i) % mod;
        ret %= mod;
    }
    for(int i = X[1]; i <= X[2]; i++) {
        int dx1 = i - X[0];
        int dy1 = Y[2] - Y[0];
        int dx2 = X[3] - i;
        int dy2 = Y[3] - Y[2] - 1;

        ret += 1LL * comb(dx1 + dy1, dx1) * comb(dx2 + dy2, dx2) % mod * (i + Y[2] + 1) % mod;
        ret %= mod;
    }

    return ret;
}

int X[6], Y[6];

int main() {
    fact[0] = 1;
    for(int i = 1; i < MN; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
    }
    for(int i = 0; i < MN; i++) {
        invf[i] = inv(fact[i]);
    }

    for(int i = 0; i < 6; i++) {
        cin >> X[i];
    }
    for(int i = 0; i < 6; i++) {
        cin >> Y[i];
    }

    int ans = 0;
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < 2; j++) {
            for(int a = 0; a < 2; a++) {
                for(int b = 0; b < 2; b++) {
                    vector<int> x, y;
                    x.push_back(i? X[0] - 1 : X[1]);
                    x.push_back(X[2]);
                    x.push_back(X[3]);
                    x.push_back(a? X[5] + 1 : X[4]);
                    y.push_back(j? Y[0] - 1 : Y[1]);
                    y.push_back(Y[2]);
                    y.push_back(Y[3]);
                    y.push_back(b? Y[5] + 1 : Y[4]);
                    int tmp = solve(x, y);
                    if(i ^ j ^ a ^ b) {
                        ans += mod - tmp;
                        ans %= mod;
                    }
                    else {
                        ans += tmp;
                        ans %= mod;
                    }
                }
            }
        }
    }
    printf("%d", ans);
}


Measured memory_bytes: 16384
//AcFreak

#include<bits/stdc++.h>
#define lint long long int 
#define mp make_pair
#define pb push_back
#define f first
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s second
#define endl '\n'
#define pii pair<lint,lint >
using namespace std;


vector<lint >arr(300005);
vector<lint >sum(300005,0);

pii haha[4];

pii smin(lint l,lint r)
{

    lint low=l;
    lint high=r-1;
    lint mid;
    lint ans=l;
    while(low<=high)
    {
    mid=(low+high)/2;
    
    if(sum[mid]-sum[l-1] <= sum[r] -sum[mid])
        {
            ans=mid;
            low=mid+1;
        }
        else
            high=mid-1;
    }

    lint mina=min(sum[ans]-sum[l-1] ,sum[r]-sum[ans]);
    lint maxa=max(sum[ans]-sum[l-1] ,sum[r]-sum[ans]);

    return make_pair(mina,maxa);
}

pii smax(lint l,lint r)
{

    lint low=l;
    lint high=r-1;
    lint mid;
    lint ans=r-1;
    while(low<=high)
    {
    mid=(low+high)/2;
    
    if(sum[mid]-sum[l-1] >= sum[r] -sum[mid])
        {
            ans=mid;
            high=mid-1;
        }
        else
            low=mid+1;
    }

    lint mina=min(sum[ans]-sum[l-1] ,sum[r]-sum[ans]);
    lint maxa=max(sum[ans]-sum[l-1] ,sum[r]-sum[ans]);

    return make_pair(mina,maxa);
}







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

      lint i,j,k;

     
      for(i=1;i<=n;i++)
      {
        cin>>arr[i];
        sum[i]+=(sum[i-1]+arr[i]);
      }

      lint ans=9999999999;


      for(i=2;i<n-1;i++)
      {
        haha[0]=smin(1,i);
        haha[1]=smax(1,i);
        haha[2]=smax(i+1, n);
        haha[3]=smin(1+i ,n);

            for(j=0;j<2;j++)
            {
                for(k=0;k<2;k++)
                {
                    lint mina=min(haha[j].f ,haha[2+k].f);
                    lint maxa=max(haha[j].s ,haha[2+k].s);
                    ans=min(ans,maxa-mina);
                }
            }
      }
cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 4992
n,a,b=map(int,input().split())
if (b-a)%2==0:
  ans=(b-a)//2
elif a-1<n-b:
  ans = a - 1 + (b-a+1)//2
else:
  ans = (n-b) + (b-a+1)//2
  
print(ans)

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	int t = 0, pos = 0;
	while (pos < x) {
		t++;
		pos = (t * (t + 1)) / 2;
	}
	cout << t << endl;
}


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

d.sort()

c=0
if d[N//2] == d[N//2-1]:
    print(0)
else:
    K=d[N//2-1]+1
    while K <= d[N//2]:
        K+=1
        c+=1

    print(c)
    


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

int main()
{
	string s, t; cin >> s >> t;
	
	const int n = s.size();

	string ans = "No";
	
	for (int i = 0; i < n; i++) {

		if (s == t) {
			ans = "Yes";
			break;
		}

		string tmp = s.substr(0, n - 1);
		string tmpS = s.at(n - 1) + tmp;

		s = tmpS;

	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
struct Info{
	int x,y,z;
}a[1010];
int i,j,k;
bool cmp(const Info&a,const Info&b){
	return a.x*i+a.y*j+a.z*k>b.x*i+b.y*j+b.z*k;
}
int n,m,ans;
signed main(){
	cin>>n>>m;
	for(i=1;i<=n;i++)cin>>a[i].x>>a[i].y>>a[i].z;
	for(i=-1;i<=1;i+=2){
		for(j=-1;j<=1;j+=2){
			for(k=-1;k<=1;k+=2){
				sort(a+1,a+n+1,cmp);
				int p[4];
				p[1]=p[2]=p[3]=0;
				for(int w=1;w<=m;w++)p[1]+=a[w].x,p[2]+=a[w].y,p[3]+=a[w].z;
				ans=max(ans,p[1]*i+p[2]*j+p[3]*k);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
//
//   “Daḷhaṃ sikkhatha santiyā.” - Utthana Sutta (Sutta Nipata) 
//    Saket Saumya 
//    MAY 02 2020
//

#include<bits/stdc++.h>

using namespace std;


#define ll long long 
#define all(x) x.begin(),x.end()
#define endl '\n'
#define RESET   "\033[0m"
#define RED     "\033[31m"      /* Red */
#define what_is(x) cerr << RED << #x << " is " << x  << RESET << endl;
 

const long long MOD = 1e9+7 ;
const int N=(2e5)+5;
const long long INF=1LL << 57;
 
// Data Structures
vector <ll> vec(N),v1, v2, v3;
vector < pair <ll, pair < ll , ll >  > > vp, vp1, vp2;
set < ll > se;
unordered_set <ll > use;
multiset < ll > ms;
map <  ll, ll > mp, done, mp1;
unordered_map < string, ll > ump;


ll t, n, m, p, q, x, y, a, b, c, mini= LLONG_MAX, maxi= LLONG_MIN,res, ans;


queue <pair <ll, ll > > bfsq;
ll vis[N];
vector < pair <ll, ll> >  adj[N], adj1[N];
ll visited[1005][1005] ;
char mat[1005][1005];
ll dp[105][10005];


//<-------------------------------------------CODE STARTS HERE --------------------------------------------------------------->// 


signed  main(){
        
            ios_base::sync_with_stdio(false);
            cin.tie(nullptr);cout.tie(nullptr);
          
            cin >> x;
            p = 100;
            while (p < x){
                    p += (p/100);
                    ans++;
            }
            cout << ans << endl;




















                
                
                
 
                
 
 
 
        
        
 
 
 
}       
       
 
 
       
       
       
       
       
       
       
 
 
 
 
 
        
        
 
 
           
 
       
       
 
            
       
       
       
       
       
       
        
 
 
 
 
 
 
       
 
 
 
 
 
        
 
 
       
 
 
       
       
       
       
       
       
       
 
 
 
 
 
        
        
 
 
           
 
       
       
 
            
       
       
       
       
       
       
        
 
 
 
 
 
 
       
 
 
 
 
 
        
 
 

       
       
       
       
       
 
 
 
 
 
        
        
 
 
           
 
       
       
 
            
       
       
       
       
       
       
        
 
 
 
 
 
 
       
 
 
 
 
 
        
 
 
       
 
 
       
       
       
       
       
       
       
 
 
 
 
 
        
        
 
 
           
 
       
       
 
            
       
       
       
       
       
       
        
 
 
 
 
 
 
       
 
 
 
 
 
        
 
 




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

long long n,ans,a[111111],l1[111111],r1[111111],l2[111111],r2[111111],___[111111];
set<long long> s;

bool cmp(long long x,long long y)
{
	return a[x]>a[y];
}
int main()
{
	int i;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
		___[i]=i;
	}
	sort(___+1,___+n+1,cmp);
	for (i=1;i<=n;i++)
	{
		long long x=___[i];s.insert(x);
		set<long long>::iterator it=s.lower_bound(x);
		set<long long>::iterator tmp=it;
		if (tmp==s.begin())
		{
			l1[x]=x;l2[x]=0;
		}
		else
		{
			tmp--;l1[x]=x-*tmp;
			if (tmp==s.begin())
			{
				l2[x]=*tmp;
			}
			else
			{
				l2[x]=*tmp;
				tmp--;
				l2[x]-=*tmp;
			}
		}
		tmp=it;
		tmp++;
		if (tmp==s.end())
		{
			r1[x]=n-x+1;r2[x]=0;
		}
		else
		{
			r1[x]=*tmp-x;
			r2[x]=-*tmp;
			tmp++;
			if (tmp==s.end())
			{
				r2[x]+=n+1;
			}
			else
			{
				r2[x]+=*tmp;
			}
		}
	}
	for (i=1;i<=n;i++)
	{
		ans+=l1[i]*r2[i]*a[i]+l2[i]*r1[i]*a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
const int maxn = 110;
typedef long long ll;
ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	else return (gcd(b,a%b));
}
ll lcm(ll x,ll y)
{
	return x/gcd(x,y)*y;
}
ll t[maxn];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&t[i]);
	}
	ll g = t[0];
	for(int i=1;i<n;i++)
	{
		g = lcm(g,t[i]);
	}
	cout<<g<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, k, a[2000];
int ans;
int cnt[2010]; 
int coun[2010];

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (a[i] > a[j])ans++;
		}
	}
	for (int i = 0; i < n; i++) {
		coun[a[i]]++;
		for (int j = 2000; j > a[i]; j--)cnt[j]++;
	}
	ans *= k;
	ans %= mod;
	int b = (k * (k - 1) / 2) % mod;
	for (int i = 1; i <= 2000; i++) {
		ans += coun[i] * cnt[i] * b;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

  int n; cin >>n;
  vector<int> a(n); rep(i,n) cin >> a[i];

  bool flag = true;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        flag = false;
      } 
    } 
  }

  if (flag) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  } 

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans;
    if(n<9){
      ans = n;
    }else if(n<100){
      ans = 9;
    }else if(n<1000){
      ans = 9+n-99;
    }else if(n<10000){
      ans = 909;
    }else if(n<100000){
      ans = 909+n-9999;
    }else{
      ans = 90909;
    }
    System.out.println(ans);

  }
}


Measured memory_bytes: 35648
#include <iostream>

using namespace std;

int solve(int x, int y) {
    int ans = 2e9 + 10;
    if (y - x >= 0)
        ans = min(ans, y - x);

    int x1 = -x;
    if (y - x1 >= 0)
        ans = min(ans, y - x1 + 1);

    int y1 = -y;
    if (y1 - x >= 0)
        ans = min(ans, y1 - x + 1);

    if (y1 - x1 >= 0)
        ans = min(ans, y1 - x1 + 2);

    return ans;
}

int main() {
    int x, y;
    cin >> x >> y;
    cout << solve(x, y) << endl;
}


Measured memory_bytes: 256
require 'prime'
def phi_func(n)
    factors=n.prime_division
    fct=factors.pop
    phi=(fct[0]-1)*fct[0]**(fct[1]-1)
    if factors.size.zero?
        return phi
    else
        m=Prime.int_from_prime_division(factors)
        return phi*phi_func(m)
    end
end

n=gets.to_i
p phi_func(n)


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

using namespace std;

typedef long long ll;

int main(){
  ll n,k;
  cin>>n>>k;
  bool ddigit[10]={false};
  for(int i=0;i<k;i++){
    ll digit;
    cin>>digit;
    ddigit[digit]=true;
  }
  bool found=false;
  ll test=n;
  // we will get number without ddigit in 10*N
  while(!found){
    ll hasD=false;
    ll temp=test;
    while(!hasD&&temp>0){
      ll d=temp%10;
      if(ddigit[d]){
        hasD=true;
      }
      temp=temp/10;
    }
    if(hasD){
      test++;
    }else{
      found=true;
    }
  }
  cout<<test<<endl;
  return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int INF = 1000000007;

    int X;
    cin >> X;
    int ans = 0;
    for (int i = 1; 1; i++) {
        int sum = (1 + i) * i / 2;
        if (sum >= X) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
	val (x, n) = readLine()!!.split(" ").map{it.toInt()}

  	if (n == 0) { 
      println(x)
      return
	}

  	val ns = readLine()!!.split(" ").map{it.toInt()}
	if (!ns.contains(x)) { 
      println(x)
      return
	}
  
  	var i = x + 1
  	var j = x - 1
  	while (true) {
    	if (!ns.contains(j)) {
        	println(j)
          	return
        } else if (!ns.contains(i)) {
        	println(i)
          	return
        } else {
        	i += 1
          	j -= 1
        }
    }
}

Measured memory_bytes: 36532
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [[n-1 for n in list(map(int, input().split()))] + [-1] for _ in range(N)]
A = [a[::-1] for a in A]

def main(N, A):
    now = [A[i].pop() for i in range(N)]
    day = 0
    rest = N * (N-1)
    candidate = set(range(N))

    # WCS O(N**2) <- 1日に1試合だけのときN(N-1)/2回while文が繰り返される
    while True:
        # terminal condition
        # O(1)
        if rest == 0:
            return day

        change = []
        next_candidate = set()
        for i in candidate:
            if now[now[i]] == i:
                j = A[i].pop()
                change.append((i, j))
                # あとで(a, b)でnow[a] = bに更新する
                next_candidate.add(i)
                if j != -1:
                    next_candidate.add(j)
                
                rest -= 1
                have_match = True

        if len(change) == 0:
            return -1
        for (a, b) in change:
            now[a] = b
            
        candidate = next_candidate
        
        day += 1

print(main(N, A))

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

typedef long long ll;

const ll MOD=1e9+7;

ll rep_pow(int n, int p) {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        ll t = rep_pow(n, p / 2);
        return t * t % MOD;
    } else {
        return n * rep_pow(n, p - 1) % MOD;
    }
}

int main() {
    string s; cin >> s;
    int n=s.size();
    vector<ll> coma(n);
    vector<ll> comc(n);
    ll a_count=0, c_count=0;
    ll aq=0, cq=0;
    for (int i=0; i<=n-3; ++i) {
        if (s[i]=='A') {
            ++a_count;
        } else if (s[i]=='?') {
            ++aq;
        }
        if (aq==0) {
            coma[i+1]=a_count;
        } else {
            coma[i+1]=(3*a_count+aq)%MOD*rep_pow(3, aq-1)%MOD;
        }
    }
    for (int i=n-1; i>=2; --i) {
        if (s[i]=='C') {
            ++c_count;
        } else if (s[i]=='?') {
            ++cq;
        }
        if (cq==0) {
            comc[i-1]=c_count;
        } else {
            comc[i-1]=(3*c_count+cq)%MOD*rep_pow(3, cq-1)%MOD;
        }
    }
    ll ans=0;
    for (int i=1; i<n-1; ++i) {
        if (s[i]=='B'||s[i]=='?') {
            ans+=coma[i]*comc[i]%MOD;
            ans%=MOD;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2048
NW = list(map(int, input().split()))
wv = []
for i in range(NW[0]):
    wv.append(list(map(int, input().split())))

dp = [[0] * (NW[1]+1) for i in range(NW[0]+1)]
for i in range(NW[0]+1):
    for sum_w in range(NW[1]+1):
            try:
                if (sum_w - wv[i][0])>=0:
                    dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-wv[i][0]] + wv[i][1])
                dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
            except:
                continue

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

Measured memory_bytes: 120812
import sys
from collections import deque
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
buf = [None] * m
cnt = {k: [] for k in range(n + 1)}
for i in range(m):
    p, y = na()
    cnt[p].append((y, i))
for p, l in cnt.items():
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)

print('\n'.join(buf))



Measured memory_bytes: 53472
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>

#define MOD 1000000007
#define INF 2147483647

typedef long long lint;
using namespace std;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T abs(T num) { return num > 0 ? num : -num; }

int main()
{
	int a, b;
	scanf("%d %d", &a, &b);

	lint dif = b - a;
	lint t = dif * (dif + 1) / 2;

	printf("%lld", t - b);

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  int ans = 1;
  for(int i = 0; i < n; i++){
    if(d[i] > d[0]){
      ans++;
      d[0] = d[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	private static final int max = 500000;
	private static int count = 0;
	private static int[] l = new int[max/2+1];
	private static int[] r = new int[max/2+1];
	private static int sentinel = 1000000001;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n  = Integer.parseInt(br.readLine());
		String[] AStr = br.readLine().split(" ");
		int[] A = new int[n];
		for(int i = 0; i < n ; i++){
			A[i] = Integer.parseInt(AStr[i]);
		}

		mergeSort(A,0,n);

		StringBuilder sb = new StringBuilder();

		for(int i = 0 ; i < n ; i++){
			sb.append(A[i] + " ");
		}

		System.out.println(sb.toString().trim());
		System.out.println(count);

	}

	private static void mergeSort(int[] A,int left,int right){
		if(left + 1 < right){
			int mid = (right + left) / 2;
			mergeSort(A,left,mid);
			mergeSort(A,mid,right);
			merge(A,left,mid,right);
		}
	}

	private static void merge(int[] A,int left,int mid,int right){
		for(int i = 0 ; i < mid - left ; i++) l[i] = A[left + i];
		for(int i = 0 ; i < right - mid ; i++) r[i] = A[mid + i];
		l[mid - left] = r[right - mid] = sentinel;

		int x = 0;
		int y = 0;

		for(int i = left ; i < right; i++ ){
			if(l[x] <= r[y]){
				A[i] = l[x++];
			}else{
				A[i] = r[y++];
			}
			count++;
		}
	}
}

Measured memory_bytes: 156740
import java.util.Scanner;

//Flying Jenny
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] c = {4,1,4,1,2,1,2,1};
		while(sc.hasNext()){
			int[] a = new int[8];
			for(int i=0;i<8;i++)a[i]=sc.nextInt();
			int min = Integer.MAX_VALUE;
			String v = "";
			for(int top=0;top<8;top++){
				int r = 0;
				String m = "";
				for(int j=0;j<8;j++){
					r += Math.max(0, a[j]-c[(top+j)%8]);
					m += c[(top+j)%8];
				}
				if(r<min){
					min = r;
					v = m;
				}
				else if(r==min&&m.compareTo(v)<0)v = m;
			}
			System.out.print(v.charAt(0));
			for(int i=1;i<8;i++)System.out.print(" "+v.charAt(i));
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
program fizzbuzz_sum
  implicit none
  integer(8) :: n, i, s = 0_8
  read(*,*) n
  do i = 1_8, n
    if (mod(i,3_8)*mod(i,5_8) == 0_8) cycle
    s = s+i
  end do
  write(*,'(i0)') s
end program fizzbuzz_sum

Measured memory_bytes: 2920
#include "stdio.h"
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;



class Puzzle
{
public:
	string T;
	string P;

	void input()
	{
		cin >> T;
		cin >> P;

	}

	void play()
	{
		if (T.size() < P.size()) return;

		for (int si = 0; si <= (T.size() - P.size()); si++) {
			if (T.substr(si, P.size()) == P) {
				cout << si << "\n";
			}
		}
	}

};


int main()
{
	Puzzle puz;

	puz.input();
	puz.play();

    return 0;
}




Measured memory_bytes: 3196
#include <stdio.h>

int main(){
    
    while(1){
        int i=0,sum=0;
        char num[1001];

        scanf("%s", num);
        if(num[0]-'0'==0) break;
        
        while(num[i]){
        sum+=num[i]-'0';
        i++;
        }
    printf("%d\n",sum);
    }
    
    return(0);
}

Measured memory_bytes: 536
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions 

#endif


int main_C() {
    std::cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vi H(N); REP(i, N) cin >> H[i];

    if (N == 1) {
        cout << "Yes" << endl;
        return 0;
    }

    vi dh(N-1);
    REP(i, N-1) dh[i] = H[i + 1] - H[i];

    bool ok = true;
    int cnt = 0;
    REP(i, N-1) {
        if (dh[i] == -1) cnt++;
        else if (dh[i] > 0) cnt = 0;

        if (cnt>=2 || dh[i] < -1) {
            ok = false;
            break;
        }
    }
    if (cnt >= 2) ok = false;

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int A,B,x;
    scanf("%d %d",&A,&B);
    if(A<10 && B<10){
        x=A*B;
        printf("%d\n",x);   
    }
    else{
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 128
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,ans=0;
  string s;
  cin >> n >> s;
  for(int i=0; i<n; i++) {
    if(s.substr(i,3)=="ABC") {
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){

	int n, dp[100010][3];
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++){
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		
		dp[i][0] = (i == 0 ? 0 : max(dp[i - 1][1], dp[i - 1][2])) + a;
		dp[i][1] = (i == 0 ? 0 : max(dp[i - 1][0], dp[i - 1][2])) + b;
		dp[i][2] = (i == 0 ? 0 : max(dp[i - 1][1], dp[i - 1][0])) + c;
	}
	
	printf("%d", max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])));
	
	return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    ll k;cin>>k;
    vector <ll> vec(n);
    for(int i=0;i<n;i++){
		cin>>vec[i];
    }
    vector <ll> dp(n,INT_MAX);
    dp[0]=0;
    for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i-j>=0){
				dp[i]=min(dp[i],dp[i-j]+abs(vec[i]-vec[i-j]));
			}
		}
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
import kotlin.math.*
import kotlin.system.exitProcess

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() //single long
private fun readDouble() = readLn().toDouble() //single double

private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints
private fun readLongs() = readStrings().map{it.toLong()} // list of longs
private fun readDoubles() = readStrings().map { it.toDouble() } // list of doubles

fun main(){
    val (n, k) = readInts()
    val h = readLongs()

    val inf = Long.MAX_VALUE
    val dp = LongArray(n){inf}

    dp[0] = 0

    dp[0] = 0 //初期位置にいる時はコスト0

    //２つ目の足場は特例
    dp[1] = abs(h[0] - h[1])
    if(n == 2){
        println(dp[1])
        exitProcess(0)
    }

    for(i in 2 until n){
        if(i-k <= 0){
            //0~(i-1)までループ
            for(j in 0..i-1){
                dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]))
            }
        }else{
            //k回ループ
            for(j in 1..k){
                dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]))
            }
        }

    }

    println(dp[n-1])
}

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

int main(void) {
  int A, B;
  cin >> A >> B;
  int board[100][100];
  memset(board, 0, sizeof(board));
  swap(A,B);
  for (int i = 0; i < A - 1; i++) {
    int r = 4 * (i % 25) + 1;
    int c = 4 * (i / 25) + 1;
    for (int di = -1; di <= 1; di++) {
      for (int dj = -1; dj <= 1; dj++) {
        if (di == 0 && dj == 0) continue;
        int nr = r + di, nc = c + dj;
        board[nr][nc] = 1;
      }
    }
    B--;
  }
  cerr << B << endl;
  if (B > 0) {
    for (int i = 0; i < B; i++) {
      int r = 2 * (i % 50);
      int c = 99 - 2 * (i / 50);
      board[r][c] = 1;
    }
  }
  if (B < 0) {
    B = -B;
    int i = 0;
    while (B) {
      int r = 4 * (i / 2 % 25) + 1;
      int c = 4 * (i / 2 / 25) + 1;
      if (i % 2 == 0) {
        board[r + 2][c - 1] = 1;
        board[r + 2][c] = 1;
        board[r + 2][c + 1] = 1;
        if (r != 97 && c == 1) B--;
        // if (r != 97 && c == 1)
        //  cerr << r << " " << c << endl;
      } else {
        board[r - 1][c + 2] = 1;
        board[r][c + 2] = 1;
        board[r + 1][c + 2] = 1;
        board[r + 2][c + 2] = 1;
        if (i / 2 + 25 <= A) B--;
        // if (i / 2 + 25 <= A)
        //   cerr << r << " " << c << endl;
      }
      i++;
    }
  }

  cout << "100 100" << endl;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      cout << (board[i][j] ? '.' : '#');
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
#include <stack>
#include <utility>
#include <queue>

using namespace std; 

int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	int sum = a + b;
	if (sum % 3 == 0 || a%3==0 || b%3==0)
	{
		printf("Possible\n");
		return false;
	}
	else
	{
		printf("Impossible\n");
		return false;
	}


	return false;
}

Measured memory_bytes: 256
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll x;
	cin>>x;
	ll now=100;
	ll ans=0;
	while(now<x)
	{
		now+=now/100;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3652