akhauriyash/Code-Regression huggingface dataset:
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i, a, b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i, a, b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a, b) a=min((a),(b))
#define CHMAX(a, b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main() {
    int N; cin >> N;
//    vector<string> vsN(N); REP(i, N) cin >> vsN.at(i);

//    int M;cin >> M;
//    vector<string> vsM(M); REP(i, M) cin >> vsM.at(i);

    vi test(0);

    REP(i, 10) if(pow(2, i) <= 100)test.push_back(pow(2, i));

//    DEBUG_VEC(test);

    int ans;
    REP(i, test.size()) if(test.at(i) <= N) ans = test.at(i);

//    int ans;
//    REP(i, N) {
//        int num = i;
//        int done = 0;
//        REP(j, 1000){
//            if(num % 2 == 0){
//                done++;
//                num /= 2;
//            }else{
//                break;
//            }
//        }
//        ans = max(ans, done);
//    }
//
    cout << ans;


    return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll mod = 1e9 + 7;

constexpr int MAX_N = 310;
ll dp[MAX_N][MAX_N][MAX_N];

int main() {
  dp[0][0][0] = 1;
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m), x(m);
  // index[i] := r[j] = i であるような j
  vector<vector<int>> index(n + 1);
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> x[i];
    index[r[i]].push_back(i);
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (dp[i][j][k] == 0) continue;
        vector<int> v = {i, j, k};
        sort(v.begin(), v.end());
        bool f = true;
        int ma = max({i, j, k});
        for (auto idx : index[ma]) {
          if (x[idx] == 1) {
            if (l[idx] <= v[1]) f = false;
          }
          if (x[idx] == 2) {
            if (l[idx] <= v[0] || v[1] < l[idx]) f = false;
          }
          if (x[idx] == 3) {
            if (v[0] < l[idx]) f = false;
          }
        }
        if (!f) {
          //cerr << i << " " << j << " " << k << endl;
          dp[i][j][k] = 0;
          continue;
        }
        dp[ma + 1][j][k] += dp[i][j][k];
        dp[ma + 1][j][k] %= mod;

        dp[i][ma + 1][k] += dp[i][j][k];
        dp[i][ma + 1][k] %= mod;

        dp[i][j][ma + 1] += dp[i][j][k];
        dp[i][j][ma + 1] %= mod;
      }
    }
  }
  ll ret = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (i == n || j == n || k == n) ret = (ret + dp[i][j][k]) % mod;
      }
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 227584
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
int n,p,K,f[155][155],g[305][155][155];
void solve1()
{
	K/=2;
	f[0][0]=1;
	for(int i=1;i<=(n+1)/2;i++)
	{
		for(int j=0;j<=K;j++) f[i][0]=(f[i][0]+f[i-1][j])%p;
		for(int j=0;j<K;j++) f[i][j+1]=(f[i][j+1]+f[i-1][j])%p;
	}
	int ans1=0,ans2=0;
	for(int i=0;i<=K;i++) ans1=(ans1+f[n/2][i])%p;
	for(int i=0;i<=K;i++) ans2=(ans2+f[(n+1)/2][i])%p;
	printf("%lld\n",1ll*ans1*ans2%p);
}
void solve2()
{
	int last=0;g[0][0][0]=1;
	for(int i=2;i-K<=n;i+=2)
	{
		for(int j=0;j<=n;j++)
		for(int k=0;k<=K+1;k++) g[i][0][0]=(g[i][0][0]+g[i-2][j][k])%p;
		if(i<=n)
		{
			for(int j=0;j<=n;j++)
			for(int k=0;k<=K+1;k++) g[i][j+1][0]=(g[i][j+1][0]+g[i-2][j][k])%p;
		}
		if(i-K>=1)
		{
			for(int j=0;j<=n;j++)
			{
				for(int k=1;k<=K;k++) g[i][0][k+1]=(g[i][0][k+1]+g[i-2][j][k])%p;
				g[i][0][0]=(g[i][0][0]+g[i-2][j][0])%p;
			}
		}
		if(i<=n&&i-K>=1)
		{
			for(int j=0;j<=n;j++)
			for(int k=0;max(k,j+1)<=K;k++)
			{
				g[i][j+1][max(k+1,j+2)]=(g[i][j+1][max(k+1,j+2)]+g[i-2][j][k])%p;
			}
		}
		last=i;
	}
	int ans=0;
	for(int j=0;j<=n;j++)
	for(int k=0;k<=K+1;k++) ans=(ans+g[last][j][k])%p;
	printf("%d\n",ans);
}
int main()
{
	n=read(),K=read(),p=read();
	if(!(K&1)) solve1();
	else solve2();
}

Measured memory_bytes: 11124
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int a, b;
    cin >> a >> b;
    if(b < a) cout << a - 1 << endl;
    else cout << a << endl;
}

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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debp(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	int x; cin >> x;
	int curr = 100, times = 0;
	while (curr < x) {
		curr = curr * 1.01;
		times++;
	}
	cout << times << endl;
	return 0;
}


Measured memory_bytes: 3652
s=input()
N=len(s)

ans=0
g=0
p=0
for i in range(N):
    if s[i]=="p":
        p+=1
        if p>g:
            ans-=1
            p-=1
            g+=1 
    else:
        g+=1
        val=g-p
        if val==2:
            ans+=1
            g-=1
            p+=1
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int k,s;
  cin>>k>>s;
  int c=0;
  for(int i = 0; i <= k; i++){
    for(int j = 0; j <= k; j++){
      int z = s-i-j;
      if(z>=0&&z<=k) c++;
    }
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		
		for(int m=0; m<n; m++)
		{
			String input = scanner.next();					
			int[] num = new int[8];
			
			for(int i=0; i<8; i++)
			{
				num[i] = Integer.parseInt(input.substring(i, i+1));
			}
			
			for(int i=0; i<8; i++)
			{
				for(int j=0; j<8; j++)
				{
					if(num[i] < num[j])
					{
						int buf = num[i];
						num[i] = num[j];
						num[j] = buf;
					}
				}
			}
			
			String min = "";
			String max = "";
			for(int i=0; i<8; i++)
			{
				min += num[i];
				max += num[7-i];
			}
			
			System.out.println(Integer.parseInt(max) - Integer.parseInt(min));
		}
	}
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;



ll pow_mod(ll n, ll k, ll m) {
	ll r = 1;
	for (; k > 0; k >>= 1) {
		if (k & 1)r = (r*n) % m;
		n = (n*n) % m;
	}
	return r;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

set<VI> s;
ll n, k;

void dfs(int cnt,VI v) {
	if (cnt == k) {
		s.insert(v);
		return;
	}
	REP(i, n) {
		if (v[i] == 0)continue;
		REP(j, n) {
			if (i == j)continue;
			v[i]--;
			v[j]++;
			dfs(cnt + 1, v);
			v[j]--;
			v[i]++;
		}
	}


}

int main() {
	

	cin >> n >> k;

	COMinit();
	if (k >= n - 1){
		cout << COM(2 * n - 1, n) << endl;
		return 0;
	}
	ll ans = COM(2 * n - 1, n);

	ll kk = n - 1;

	while (kk != k) {
		ll cur = COM(n - 1, kk)*COM(n, kk);
		cur %= mod;
		ans -= cur;
		ans += mod;
		ans%=mod;

		kk--;
	}
	
	cout << ans << endl;
	
}




Measured memory_bytes: 12160
import java.util.Scanner
object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val as = Array.fill(n)(sc.nextInt)
  def gcd(l: Int, r: Int): Int = if (r == 0) l else if (l % r == 0) r else gcd(r, l % r)
  val gcdsL = as.scanLeft(0)((z, a) => gcd(z, a))
  val gcdsR = as.scanRight(0)((a, z) => gcd(z, a))
  println(gcdsL.zip(gcdsR.tail).map(z => gcd(z._1, z._2)).max)
}

Measured memory_bytes: 72408
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var qa = from a in Console.ReadLine().Split(' ')
					select long.Parse(a);
			var aList = new List<long>(qa);
			var qb = from a in Console.ReadLine().Split(' ')
					select long.Parse(a);
			var bList = new List<long>(qb);

			// なるべく前の勇者に倒させる
			long total = 0;
			long remain = 0;
			for (int i = 0; i < n + 1; i++)
			{
				if (aList[i] <= remain)
				{
					total += aList[i];  // 余力のみで全滅
					if (i < n)
					{
						remain = bList[i];  // 次回の余力
					}
				}
				else
				{
					total += remain;
					long current = aList[i] - remain;

					if (i < n)
					{
						if (current >= bList[i])
						{
							total += bList[i];  // 倒せるだけ倒す
							remain = 0;
						}
						else
						{
							total += current;   // 全滅
							remain = bList[i] - current;    // 次回の余力
						}
					}
				}
			}
			Console.WriteLine(total);
		}
	}
}


Measured memory_bytes: 37020
N = int(input())
t_0, x_0, y_0 = 0, 0, 0

for n in range(N):
  t_1, x_1, y_1 = [int(txyz) for txyz in input().split()]
  d_01 = abs(x_1 - x_0) + abs(y_1 - y_0)
  dt = t_1 - t_0
  if dt < d_01:
    print("No")
    break
  else:
    t_d = dt - d_01
    if t_d % 2 == 0:
      t_0, x_0, y_0 = t_1, x_1, y_1
    else:
      print("No")
      break
else:
  print("Yes")

Measured memory_bytes: 46184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}

int main(){
  int N; cin >> N;
  vector<string> S(N); rep(i,N) cin>>S[i];
  ll ans = 0;
  vector<ll> SS;
  rep(i,N){
    bool ok = true;
    int idx=-1;
    rep(j,sz(S[i])){
      if(S[i][j]=='.'){
        idx=j;
      }
    }
    if(idx==-1) {
      idx=sz(S[i]);
      S[i]+=".0";
    }
    while(sz(S[i]) <= idx+9) S[i]+='0';
    //cout << S[i] << endl;
    string s="";
    rep(j,sz(S[i])) if(S[i][j]!='.') s+=S[i][j];
    ll num = stoll(s);
    //cout << num << endl;
    SS.pb(num);
  }

  ll s5[64][64];
  rep(i,64) rep(j,64) s5[i][j] = 0;
  rep(i,sz(SS)){
    ll now = SS[i];
    int t=0, f=0;
    while(now%2==0){
      t++; now/=2;
    }
    while(now%5==0){
      f++; now/=5;
    }

    int lastt = max(0,18-t);
    int lastf = max(0,18-f);
    for(int tt=lastt;tt<64;tt++){
      for(int ff=lastf;ff<64;ff++){
        ans += s5[ff][tt];
      }
    }
    s5[f][t]++;
  }


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


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

namespace Program
{
    public class ABC126C
    {
        static public void Main(string[] args)
        {
            var N = NextInt;
            var K = NextInt;

            var denomis = new int[N];
            for (int i = 1; i <= N; ++i)
            {
                if (i >= K)
                {
                    denomis[i - 1] = 1;
                    continue;
                }
                var count = Math.Ceiling(Math.Log((double)K / (double)i) / Math.Log(2));
                denomis[i - 1] = 1;
                for (int j = 0; j < count; ++j)
                {
                    denomis[i - 1] *= 2;
                }
            }
            var maxDenomi = denomis.Max();
            var numes = new double[N];
            for (int i = 0; i < N; ++i)
            {
                numes[i] = (double)maxDenomi / (double)denomis[i];
            }

            Console.WriteLine(((double)numes.Sum()) / (double)maxDenomi / (double)N);
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => int.Parse(Console_.NextString());
        static long NextLong => long.Parse(Console_.NextString());
        static string NextString => Console_.NextString();

        static IEnumerable<long> Prime(long x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (long)(Math.Sqrt(x) / 2);
            for (long i = 1; i <= max; ++i)
            {
                if (table[i]) continue;
                var add = 2 * i + 1;
                yield return add;
                for (long j = 2 * i * (i + 1); j <= halfx; j += add) table[j] = true;
            }
            for (long i = max + 1; i <= halfx; ++i) if (!table[i]) yield return 2 * i + 1;
        }
        static IEnumerable<long> Divisor(long x)
        {
            if (x < 1) yield break;
            var max = (long)Math.Sqrt(x);
            for (long i = 1; i < max; ++i)
            {
                if (x % i != 0) continue;
                yield return i;
                if (i != x / i) yield return x / i;
            }
        }
        static long GCD(long a, long b)
        {
            long tmpa = a, tmpb = b;
            while (tmpb > 0) { var tmp = tmpb; tmpb = tmpa % tmpb; tmpa = tmp; }
            return tmpa;
        }
    }
}


Measured memory_bytes: 12384
#include <bits/stdc++.h>  
using namespace std;  
typedef long long ll; 
typedef long double ld; 
const int INF = 0x3f3f3f3f;  
const int N = 200000 + 5;

int main()
{
	int n;
	cin >> n;
	int a = n / 100, b = n / 10 % 10,c = n % 10;
	if(a == 7 || b == 7 || c == 7)
		cout << "Yes" << endl;
	else
		cout << "No" << endl; 
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

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

Measured memory_bytes: 256
package main

import (
"fmt"
"strconv"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	val,_ := strconv.ParseInt(strconv.Itoa(a)+strconv.Itoa(b),10,64)
	flag := false
	for i:= 1;i<1001;i++{
		if val ==int64(i*i) {
			flag =true
			break
		}
	}
	if flag{
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<double> a(n),b(n);
  REP(i,n) cin >> a[i];
  REP(i,n) cin >> b[i];
  double ans = 0;
  REP(i,n) ans += abs(a[i]-b[i]);
  cout << ans << endl;
  ans = 0;
  REP(i,n) ans += ((a[i]-b[i])*(a[i]-b[i]));
  cout << sqrt(ans) << endl;
  ans = 0;
  REP(i,n) ans += pow(abs(a[i]-b[i]),3.);
  cout << pow(ans,1./3) << endl;
  ans = 0;
  REP(i,n) ans = max(ans,abs(a[i]-b[i]));
  cout << ans << endl;
}


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

#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef tuple<int, int, int> TP;
typedef vector<int> VI;
typedef double T;
typedef vector<T> VT;
typedef vector<VT> VVT;

const LL MOD = 1e9 + 7;
const double EPS = 1e-10;
mt19937 rng(7); // random generator using 7 for seed

const int MAXN = 1e5 + 10;

LL h[MAXN];
LL dp[MAXN];

int main() {
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) {
        cin >> h[i];
    }
    dp[2] = abs(h[1] - h[2]);
    for(int i=3;i<=n;i++) {
        dp[i] = min(abs(h[i]-h[i-2]) + dp[i-2], abs(h[i]-h[i-1]) + dp[i-1]);
    }
    printf("%lld\n", dp[n]);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    string N;
    cin >> N;
    int cnt = 0;
    rep(i, 4) if (N[i] == '2') cnt += 1;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


N = input()

good = [str(i)*3 for i in range(10)]

flag = "No"
for num in good:
    if num in N:
        flag = "Yes"

print(flag)


Measured memory_bytes: 9112
#include <cstdio>
#include <list>
#include <algorithm>

using namespace std;

int main()
{
	list<int> L;
    list<int>::iterator cur = L.end();
	int n;
	scanf("%d", &n);
	int cmd, tmp;
	for (int i = 0; i < n; i ++) {
		scanf("%d", &cmd);
		switch (cmd)
		{
		case 0:
			scanf("%d", &tmp);
            cur = L.insert(cur, tmp);
			break;
		case 1:
			scanf("%d", &tmp);
            if (tmp > 0)
            {
				for (int i = 0; i < +tmp; i++)
                    cur++;
			}
			else
            {
				for (int i = 0; i < -tmp; i++)
                    cur--;
			}
			break;
		case 2:
            cur = L.erase(cur);
			break;
    	}
	}
    for (int x: L)
        printf("%d\n", x);
	return 0;
}



Measured memory_bytes: 18192
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <set>
using namespace std;
#define INF 1010101010
#define MOD 1000000007
#define LL long long
using Coord = pair<int, int>;

int main() {
    map<Coord, LL> m;
    LL h, w, n;
    cin >> h >> w >> n;
    for (int i = 0; i < n; i++) {
        LL a, b;
        cin >> a >> b;
        for (int j = -1; j <= 1; j++)
            for (int k = -1; k <= 1; k++)
                if (a+j >= 2 && b+k >= 2 && a+j <= h-1 && b+k <= w-1) m[make_pair(a+j, b+k)]++;
    }

    vector<LL> cnt(10, 0);

    for (const auto& e: m) {
        cnt[e.second]++;
    }

    cnt[0] = (w-2) * (h-2) - m.size();


    for (int i = 0; i < 10; i++) {
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 56448
#include<stdio.h>

int ac[100000];
int wa[100000];

int main(){
  int n,m;
  int i;
  int p;
  char s[3];
  int asum = 0;
  int wsum = 0;

  scanf("%d %d", &n, &m);

  for(i = 0;i < n;i++){
    ac[i] = 0;
    wa[i] = 0;
  }

  for(i = 0;i < m;i++){
    scanf("%d %s", &p, s);

    if(s[0] == 'W'){
      if(ac[p] != 1) {
        wa[p]++;
      }
    }

    else{
      if(ac[p] != 1){
        ac[p]++;
      }
    }
  }

  for(i = 0;i < n;i++){
    if(ac[i + 1] == 1){
      asum++;
      wsum += wa[i + 1];
    }
  }

  printf("%d %d\n", asum, wsum);

  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    cin>>N;
    ll A;
    //MEMSET(co, 0);
    ll chi[500005];
    MEMSET(chi, 0);
    rep1(i, N-1){
        cin>>A;
        chi[A-1]++;
    }
    rep(i, N){
        cout<<chi[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 7552
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e7+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
int main(void){
	string str;cin>>str;
	str[3]='8';
	cout<<str<<endl;
	RE;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>

int main(void)
{
	int N = 0, K = 0;
	std::cin >> N;
	std::cin >> K;

	std::vector<long long int> h;
	for (int i = 0; i < N; i++)
	{
		long long int a = 0;
		std::cin >> a;
		h.push_back(a);
	}

	/*for (int i = 1; i < N; i++)
	{
		for (int j = i; j >= 1 && h[j] < h[j - 1]; j--)
		{
			long long int tmp = 0;
			tmp = h[j - 1];
			h[j - 1] = h[j];
			h[j] = tmp;
		}
	}*/
	std::sort(h.begin(), h.end());

	long long int min = 9999999999;
	for (int i = 0; i + K-1 < N; i++)
	{
		if (min >(h[i + K-1] - h[i]))
		{
			min = h[i + K-1] - h[i];
		}
	}

	std::cout << min << std::endl;

	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int a[110];
int main(){
	n=read();
	for(register int i=1;i<=n;i++)a[i]=read();
	int ans=0;
	for(register int i=1;i<=n;i++){
		for(register int j=i+1;j<=n;j++)
			ans+=a[i]*a[j];
	}
	printf("%d\n",ans);
	return 0;
}

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

namespace ForAtcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var n = inputLongArray[0];
            var k = inputLongArray[1];
            long[] inputLongFruitsArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            Array.Sort(inputLongFruitsArray);
            long result = 0;
            for (var i = 0; i < k; i++)
            {
                result += inputLongFruitsArray[i];
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 28520
#import 
#=input()
n=int(input())
#=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
l = []
for i in range(n):
    l += [input()]
ac = l.count('AC')
wa = l.count('WA')
tle = l.count('TLE')
re = l.count('RE')
print(f'AC x {ac}')
print(f'WA x {wa}')
print(f'TLE x {tle}')
print(f'RE x {re}')

Measured memory_bytes: 16196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long ul;

int main()
{
	ll n, k;
	cin >> n >> k;
	ll j = k;
	for (int i = 1; i < n; i++)
		j *= (k - 1);
	cout << j << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    vector<int> c{a.front()};
    for (int i=1; i<N; ++i) {
        auto it = lower_bound(rbegin(c), rend(c), a[i]);
        if (it == rbegin(c)) {
            c.push_back(a[i]);
        } else {
            *(--it) = a[i];
        }
    }
    cout << c.size() << endl;
}


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

typedef long long ll;

const int N=4009;
const int md=924844033;

int n,k;
bool vis[N][N];
int ed[N],tot;
int f[N][N][2];
int g[N],fac[N];

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        for(int j=0;j<=1;j++)
            if(!vis[i][j])
            {
                int len=0;
                for(int x=i,y=j;x<=n;x+=k,y^=1)
                    vis[x][y]=1,++len;
                ed[tot+=len]=1;
            }
    f[1][0][0]=1;
    for(int i=1;i<=tot;i++)
        for(int j=0;j<=n;j++)
        {
            f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%md;
            if(!ed[i])
                f[i+1][j+1][1]=f[i][j][0];
        }
    for(int i=0;i<=n;i++)
        g[i]=(f[tot][i][0]+f[tot][i][1])%md;
    
    fac[0]=1;
    for(int i=1;i<=n;i++)
        fac[i]=(ll)fac[i-1]*i%md;
    
    ll ans=fac[n];
    for(int i=1,j=-1;i<=n;i++,j=-j)
        ans=((ll)ans+md+(ll)j*fac[n-i]*g[i]%md)%md;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 136704
import sys
sys.setrecursionlimit(200200)
input = sys.stdin.readline
MOD=10**9+7
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N-1)]
G = [[] for _ in range(N)]
for i, (a, b) in enumerate(AB):
    a -= 1
    b -= 1
    G[a].append((b, i))
    G[b].append((a, i))

P = [0] * N
visited = [False] * N
visited[0] = True
def dfs(x, i):
    e = 1
    for v, c in G[x]:
        if not visited[v]:
            visited[v] = True
            e += dfs(v, c)
    P[i] = e
    return e

dfs(0, -1)
W = [1] * (N + 1)
inv_2 = pow(2, MOD-2, MOD)
for i in range(N):
    W[i+1] = W[i]*inv_2%MOD
ans = (W[N] + 1) * (N - 1) % MOD
for i in range(N-1):
    ans -= W[P[i]] + W[N-P[i]]
    ans %= MOD
print((ans - inv_2*N - W[N] + 1) % MOD)

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

int main(){
  string s;
  cin >> s;

  if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) cout << "Yes";
  else if(s[0] == s[2] && s[2] != s[1] && s[1] == s[3]) cout << "Yes";
  else if(s[0] == s[3] && s[3] != s[1] && s[1] == s[2]) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

    int a, b; cin>>a>>b;

    for(int i=1; i<=10000; i++){
        int ca = (i * 8) / 100;
        int cb = (i * 10) / 100;

        if(ca == a && cb == b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
from decimal import Decimal

a, b, c = list(map(int, input().split()))

# ans = "Yes" if (math.sqrt(a) + math.sqrt(b)) < math.sqrt(c) else "No"
root = Decimal("0.5")
ans = "Yes" if ((a ** root) + (b ** root)) < (c ** root) else "No"


print(ans)


Measured memory_bytes: 5076
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int mod = 1000000007;
int h, w;
string s[1000];
int dp[1000][1000];

signed main() {
	int i, j;
	cin >> h >> w;
	rep(i, h) cin >> s[i];
	
	dp[0][0] = 1;
	rep(i, h) {
		rep(j, w) {
			if (i + 1 < h && s[i + 1][j] == '.') {
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= mod;
			}
			if (j + 1 < w && s[i][j + 1] == '.') {
				dp[i][j + 1] += dp[i][j];
				dp[i][j + 1] %= mod;
			}
		}
	}
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 9088
n = int(input())
strings = [input() for _ in range(n)]

count_a_last = 0
count_b_first = 0
coincide = True
internal = 0
for s in strings:
	internal += s.count("AB")

	if s[0] == "B" and s[-1] == "A":
		count_a_last += 1
		count_b_first += 1
	elif s[0] == "B":
		count_b_first += 1
		coincide = False
	elif s[-1] == "A":
		count_a_last += 1
		coincide = False

concat = min(count_a_last, count_b_first)
if concat > 0 and coincide :
	concat -= 1
print(internal + concat)


Measured memory_bytes: 3700
def binarySearch(A, n, key):
	
	left = 0
	right = n
	while (left < right):
		mid = (left + right) // 2
		if (key == A[mid]):
			return 1
		if (key > A[mid]):
			left = mid + 1
		elif (key < A[mid]):
			right = mid
	
	return 0

if __name__ == '__main__':
	
	n = int(input())
	L = list(map(int, input().split()))

	q = int(input())
	Key = list(map(int, input().split()))

	cnt = 0
	for i in range(q):
		if (binarySearch(L, n, Key[i])):
			cnt += 1

	print(cnt)

Measured memory_bytes: 18692
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int a[1000005],u;
template<typename T>void read(T &a)
{
    T x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(; isdigit(c);c=getchar())x=x*10+c-'0';
    a=x*f;
}
int main()
{
	int a,b,c;
	int to;
	read(a),read(b),read(c),read(to);
	int ans=0;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)if(500*i+100*j+50*k==to)ans++;
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int N;
	cin >> N;

	int C[501] = {}, S[501] = {}, F[501] = {};
	rep1(i, N - 1) cin >> C[i] >> S[i] >> F[i];

	rep1(K, N) {
		int T = 0;

		for (int i = K; i < N; i++) {
			if (T < S[i]) T = S[i];
			if (T % F[i]) T += F[i] - T % F[i];
			T += C[i];
		}
		co(T);
	}

	Would you please return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
a = list(map(int, input().split()))
if N == 1:
    print(1)
    exit()

ans = []
ans.append(a[1] - a[0])
mina = min(a[1], a[0])
maxri = ans[0]
for i in range(2, N):
    ans.append(a[i] - mina)
    maxri = max(ans[i - 1], maxri)
    mina = min(a[i], mina)

print(ans.count(maxri))

Measured memory_bytes: 14252
#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 = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 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 A, B; std::cin >> A >> B;
    for(int i(1); i < 1000000; ++i){
        if(i * 8 / 100 == A){
            if(i / 10 == B){
                std::cout << i << std::endl;
                return 0;
            }
        }
    }
    std::cout << -1 << std::endl;
    return 0;
}


Measured memory_bytes: 256
require 'pp'

N,Q = readline.chomp.split.map(&:to_i)
s = readline.chomp
a = Array.new(s.length, 0)
sum = 0
(1..(s.length-1)).each do |i|
  if s[i-1] == 'A' and s[i] == 'C'
    sum += 1
  end
  a[i] = sum
end

Q.times do |i|
  l,r = readline.chomp.split.map(&:to_i).map {|x| x-1}
  ans = a[r] - a[l]
  #ans -= 1 if s[l-1] == 'A' and s[l] == 'C'
  puts ans
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=3e5+10,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,an=0,mx=0;
  cin>>n;
  for(int i=0;i<n;i++){
  	int a;
  	cin>>a;
  	if(a>=mx)an++;
  	mx=max(mx,a);
  }
  cout<<an;
  return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a, b, k;
    cin >> a >> b >> k;
    if (a > 0) {
        ll t = min(a, k);
        a -= t;
        k -= t;
    }
    if (b > 0) {
        ll t = min(b, k);
        b -= t;
        k -= t;
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
        SAME AS EDITORIAL
        TC 26*Q*logn which is less than mlogm where m=1e6
        for erase,insert TC = log(n)
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
set<int>A[26];
void solve()
{
    string s;
    int n,q,i,t,l,r,p;cin>>n;
    char c,x;
    cin>>s>>q;
    fo(i,0,sz(s))A[s[i]-'a'].insert(i+1);
    
    while(q--)
    {
        cin>>t;
        if(t==1)
        {
            cin>>p>>c;
            x=s[p-1];
            s[p-1]=c;
            A[x-'a'].erase(p);
            A[c-'a'].insert(p);
        }
        else
        {
            cin>>l>>r;
            set<int>::iterator it;
            int cnt=0;
            fo(i,0,26)
            {
                it=A[i].lower_bound(l);
                if(it!=A[i].end()&&(*it<=r))cnt++;
            }
            cout<<cnt<<"\n";
        }
    }
    
    
}
int main()
{
   fastio
   solve();
  return 0;
}


Measured memory_bytes: 24220
#include<iostream>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1e9;
 
int main() {
    int H, N;
    cin >> H >> N;
 
    int A[N], B[N];
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
 
    int F[H+1];
    rep(i,H+1) F[i] = INF;
 
    rep(i,H+1)rep(j,N) {
        if (A[j] >= i) F[i] = min(F[i], B[j]);
        else F[i] = min(F[i], F[i - A[j]] + B[j]);
    }
    cout << F[H];
    return 0;
}

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

double possibility(int n,int k){
    double ans = 1;
    while(n<k){
        ans/=2;
        n*=2;
    }
    return ans;
}

int main(){
    int n,k;
    std::cout<<std::fixed<<std::setprecision(10);
    cin>>n>>k;

    double ans=0;

    for (int i = 1; i <= n; i++)
    {
        //i->k
        ans += (possibility(i,k))/n;
    }
    

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

Measured memory_bytes: 256
S = input()
l = list(S)
s = int(len(S))
res=""
for i in range(2,s,2):
    str=S[:-i]
    m = int(len(str)/2)
    p = str[:m]
    q = str[m:]
    if p==q:
        res = str
        print(len(res))
        break     

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

using namespace std;

using ll = long long;

int main(){
    ll n, k;
    cin >> n >> k;
    ll arr[k];
    for(ll i = 0; i < k; ++i){
        cin >> arr[i];
    }
    ll ans = arr[k - 1] - arr[0];
    for(ll i = 1; i < k; ++i){
        ans = min(ans, n - arr[i] + arr[i - 1]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
 
enum {A, X, Y, Z, W, B, ERROR};
int map[6][2] = {
	{X, Y},
	{ERROR, Z},
	{X, ERROR},
	{W, B},
	{B, Y},
	{Y, X}
};
 
int main(void)
{
	int sw;
	int now_pos;
	
	for (now_pos = A; (sw = getchar()) != '#';){
		if (sw == '\n'){
			puts(now_pos == B ? "Yes" : "No");
			now_pos = A;
			continue;
		}
		if (now_pos == ERROR) continue;
		now_pos = map[now_pos][sw == '1'];
	}
	return (0);
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
long long int n,x,t,ans;
int main() {
	cin>>n>>x>>t;
	while(1) {
		if(n-x>0) {
			n-=x;
			ans+=t;
		}
		if(n-x<0) {
			cout<<ans+t;
			return 0;
		}
		if(n-x==0) {
			cout<<ans+t;
			return 0;
		}
	}
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define MAXM 300005
#define TRACE(x) cout<<#x<<" = "<<x<<'\n'
#define TRACE2(x, y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<'\n'
#define TRACEA(arr, i) cout<<#arr<<"["<<i<<"]"<<" = "<<arr[i]<<'\n'
#define PRINT(arr, n) for (int iDx = 0; iDx < n; iDx++) printf("%d%c", arr[iDx], " \n"[iDx == n-1])
#define SZ(x) (int)(x).size()
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;

int arr[MAXM];
long long pbsr[MAXM], pkcl[MAXM];
priority_queue<int, vector<int>, greater<int> > bsr;
priority_queue<int> kcl;

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d", &N);
	M = 3*N;
	for (int i = 0; i < M; i++) {
		scanf("%d", &arr[i]);
	}
	long long sum = 0;
	for (int i = 0; i < N; i++) bsr.push(arr[i]), sum += arr[i];
	pbsr[N-1] = sum;
	for (int i = N; i < 2*N; i++) {
		bsr.push(arr[i]);
		sum += arr[i];
		sum -= bsr.top();
		bsr.pop();
		pbsr[i] = sum;
	}
	sum = 0;
	for (int i = M-1; i >= 2*N; i--) kcl.push(arr[i]), sum += arr[i];
	pkcl[2*N] = sum;
	for (int i = 2*N-1; i > N-1; i--) {
		kcl.push(arr[i]);
		sum += arr[i];
		sum -= kcl.top();
		kcl.pop();
		pkcl[i] = sum;
	}
	long long ans = -INF;
	for (int i = N-1; i < 2*N; i++) {
		ans = max(ans, pbsr[i]-pkcl[i+1]);
	}
	printf("%lld\n", ans);
	
	return 0;
}



Measured memory_bytes: 5112
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static int ans=0;
	static ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>();
	static boolean vis[]=new boolean[2*(int)1e5+1];
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int nodes=fs.nextInt();
		int edges=fs.nextInt();
		for(int i=0;i<=nodes+1;i++)
			adj.add(new ArrayList<Integer>());
		for(int i=1;i<=edges;i++)
		{
			int a=fs.nextInt();
			int b=fs.nextInt();
			adj.get(a).add(b);
			adj.get(b).add(a);
		}
		for(int i=1;i<=nodes;i++)
		{
			if(vis[i]==false)
			{
				ans=Math.max(ans,dfs(i));
			}
		}
		System.out.println(ans);
	}
	public static int dfs(int node)
	{
		int res=0;
		vis[node]=true;
		res++;
		for(int child:adj.get(node))
		{
			if(vis[child]==false)
			{
				res=res+dfs(child);
			}
		}
		return res;
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 114692